Let $S\subset\mathbb{R}^n$, with $n\geq 3$, such that for any hyperplane $L$ one has $L\cap S$ closed, semialgebraic, and convex. Is it true that $S$ itself is semialgebraic?


A colleague explained to me that closedness is necessary, as one can take an open ball in $\mathbb{R}^n$ and paste a sufficiently nasty curve into its boundary. 


It is probably possible to weaken the convexity assumption to something like "no isolated points", and still have a meaningful question.


PS. the is basically a question recently asked by Lev Birbrair and Aris Daniilidis.


PPS. The if $n=2$ then for any convex set $S$ the intersection with a line is semialgebraic, so the answer is obvious "no" in this case.




---


One way, suggested by Birbrair, to make question more interesting is to assume in addition that $S$ is defined in an $o$-minimal structure. This would preclude examples like in the my own answer below.



Do convex closed semialgebraic hyperplane cross-sections imply semi-algebraicity?
Here I record an answer based on very kind comments above (and offline).
The construction starts from a closed ball $B\subset\mathbb{R}^3$ and an infinite sequence $\mathcal{L}:=\{L^+\_k\}$ of open half-spaces, satisfying the condition 
$$B\cap L^+\_i\cap L^+\_j=\emptyset\quad\text{ if and only if $i\neq j$.}\qquad\qquad (\*)$$ Denote $L^-\_k:=\mathbb{R}^3\setminus L\_k^+$, and set $$B^-:=B\cap L^-\_1\cap L^-\_2\cap\dots\cap L^-\_k\cap\dots$$
Zariski closure of the boundary $\partial B^-$ of $B^-$ contains infinitely many planes $\partial L\_k^-$, and thus it cannot be a surface.
Theorem 3.20 in [lecture notes](https://perso.univ-rennes1.fr/michel.coste/polyens/SAG.pdf) by Michel Coste says that the Zariski closure of the boundary $\partial S$ of a semialgebraic set $S$ is algebraic of the same dimension as $\partial S$. Applying it to the $B^-$, we obtain that $\partial B^-$ is not semialgebraic, threfore $B^-$ is not semialgebraic, as well.


It remains to construct an appropriate $\mathcal{L}$, so that any plane $P$ intersects only finitely many $B\cap L\_k$. Each $B\cap L\_k$ is a spherical cap of radius $r\_k$ and centre $C\_k\in\partial B$. Let $\pi$ be the stereographic projection of $\partial B$ from the north pole onto the tangent plane $\Pi$ at the south pole $O\in\Pi$. Let $M\gg 0$, $c\_k:=((k+M)^{-1},(k+M)^{-2})\in\Pi$, for $k\geq 1$; set $C\_k=\pi^{-1}(c\_k)$ and $r\_k:=e^{-k-M}$, thus specifying a particular $\mathcal{L}$. Then $(\*)$ holds. As $O$ is the limit point of $\{C\_k\}$, any plane $\Omega$, to have a chance to intersect infinitely many $B\cap L\_k$, and thus provide non-semialgebraic $B^-\cap\Omega$, must pass through $O$.


To establish that such an $\Omega$ does not exist, it suffices to show that any line $\ell$ in $\Pi$ intersects only finitely many disks $D\_k\subset\Pi$ with centre at $c\_k$ of radius $r\_k$. As the points $c\_k$ lie on a parabola $y=x^2$, 
$\ell$ won't hit inifinitely many $D\_k$, unless it is tangent to it at $O$. So it remains to consider the case of $\ell$ being the line $y=0$. As $r\_k$ decreases exponentially, but the $y$-coordinate $(k+M)^{-2}$ of $c\_k$ only quadratically, there will be $K$ so that for any $k>K$ the
intersection of $\ell$ and $D\_k$ is empty. Thus any plane intersects $B^-$ in a semialgebraic set, and we are done.


