Proving convexity of a set through intersection with a line I know that we can prove that a function $f $ is convex by proving that it is convex when it is evaluated on any arbitrary line that intersects its domain. 
However, can we prove the convexity of a set by proving the convexity of a function  evaluated in any arbitrary line of the set? Because I saw this in a class, but I am a bit confused because in this way we proved the convexity of the function, and not of the set, right?
I am wondering if the convexity of the set follows from the convexity of the function, since a necessary condition for a function to be convex is the convexity of its domain. 
For example:
$$C= \{x \mid f(x) := x^TQx + q^Tx +c \le 0\}$$ 
with $Q$ positive semi-definite.
Can I show that the function $g(t)=f(b+tv)$ is convex and conclude that C is convex? If yes, why? My logic would say to prove that $g(t)\le0$ for $t$ that is an admissible point. And I can prove this, say, applying the definition (i.e. taking $t1, t2$) belonging to the set.
Thank you.
 A: Define
$$
   f(x) = x^TQx + b^Tx + c
$$
where $Q$ is PSD.
To prove that $f$ is convex provided that $g(t)=f(b + tv)$ is convex for $b$ and $v$ arbitrary proceed as follows.
Take $x,y\in{\mathbf R}^n$ and $0\le\theta\le1$. Put $z = \theta x + (1-\theta)y$. We have to show that
$$
    f(z)\le\theta f(x) + (1-\theta)f(y).
$$
Now define $g(t) = f(b + tv)$, where $b = y$ and $v = x - y$. By hypothesis, $g$ is convex. Therefore
\begin{align*}
         f(z) &= f(y + \theta(x-y))\\
              &=g(\theta) \\
              &= g(\theta1 + (1-\theta)0)\\
              &\le \theta g(1) + (1-\theta)g(0) \\
              &= \theta f(x) + (1-\theta)f(y).
\end{align*}
(Once we fix $x$ and $y$ all that concerns to the definition of convexity lines on the line segment that joins $x$ with $y$. This is why the convexity of $g$ is equivalent to the convexity of $f$.)
Now, once you know that $f$ is convex (by whatever means), you can show that
$$
    C = \{x\mid f(x)\le0\}
$$
is convex too. Take $x,y,\theta$ and $z$ as above. We have
$$
  f(z) \le \theta f(x)+(1-\theta)f(y)
                            \le \theta 0 + (1-\theta)0
                             =0,
$$
which shows that $\theta x + (1-\theta)y\in C$.
Note: you can use the same reasoning when replacing $0$ in $C$ with any real number $\alpha$. Also, you should picture the fact that these *sub-level* sets (this is how they are called) are convex by drawing a convex function (such as $x^2$) and visualizing them in the domain.
A: A function is convex if and only if the epigraph of the function is convex. If a set is the epigraph of some function you can prove that it's convex by proving the function is convex.
