Convexity of a bi-variate function when its second derivatives are discontinuous? A piecewise function $F(x_1,x_2)$ is continuous, so are its 1st partial derivatives. However, its 2nd partial derivatives are discontinuous, that is , $F$ is not of class $C^2$. But its Hessian satisfies the convexity condition piecewise (even turns out to be symmetric), i.e. all its principal minors are non-negative, so is $F$ jointly convex even it is not of class $C^2$?
 A: Proposition. Suppose $U\subset \mathbb R^n$ is a convex domain, and $F:U\to\mathbb R $ is a $C^1$ function. Suppose further that $F$ is second-order differentiable on $U\setminus N$, where $N$ is a closed set  that is locally $(n-1)$-rectifiable. If the Hessian matrix of $F$ is positive semidefinite on $U\setminus N$, then $F$ is convex.
(Remark: a set that is a finite union of smooth $(n-1)$ hypersurfaces is locally  $(n-1)$-rectifiable.)
Proof. A $C^1$ function $F:U \to \mathbb R$ is convex if and only if its derivative is monotone: 
$$\langle \nabla F(a)-\nabla F(b),a-b\rangle \ge 0,\quad \forall a,b\in U \tag1$$
For a given pair $a,b$, the intersection of the line segment $[a,b]$ with $N$ may happen to be infinite. But recall that the piece of $N$ in a ball surrounding $[a,b]$ has finite $(n-1)$-dimensional measure. Fubini's theorem implies that for almost every vector $u$ orthogonal to $[a,b]$, the shifted segment $[a+u,b+u]$ meets $N$ in a finite set (possibly empty). By continuity, it suffices to prove (1) for a dense subset of pairs $a,b$. Thus, we may assume that $[a,b]\cap N$ is finite. 
The restriction of $F$ to $[a,b]$, denoted  $f(t)=F((1-t)a+tb)$, has nonnegative second derivative  outside of a finite subset of $[0,1]$. Since $f'$ is continuous on $[0,1]$, it follows that $f'(1)\ge f'(0)$. In terms of $F$ this says precisely that (1) holds. $\Box$
