Let $f:[0,1]\to[0,1]$ be given. The level sets of $f$ (ie the collection of all sets of the form $\{x\in[0,1]:f(x)=y\}$, for each fixed $y\in[0,1]$) partition the domain of $f$. I am curious for set theoretic or point set topology criteria for which partitions of $[0,1]$ could be the level sets for a continuous function. That is, can someone fill in the blank in the following "theorem".



> 
> **THEOREM**: Let $\mathscr{P}$ be a partition of $[0,1]$. The following are equivalent.
> 
> 
> 1. There is some **continuous** function $f:[0,1]\to[0,1]$ such that the collection of level sets of $f$ is exactly the partition
> $\mathscr{P}$.
> 2. The partition $\mathscr{P}$ satisfies the property \_\_\_\_\_\_\_\_\_\_.
> 
> 
> 


Even in the case where all the parts of $\mathscr{P}$ are finite, the picture seems pretty mysterious to me. For example, it is perfectly fine to have $\mathscr{P}$ consist of all pairs, and one singleton (for example the level sets of $f(x)=(x-1/2)^2$), but impossible for $\mathscr{P}$ to consist of all pairs except for two singletons. Can someone see a non-analytic over-arching principle which discerns the the first case from the second?


As a side note, the question can obviously be posed with the $[0,1]$ as domain and codomain replaced by arbitrary topological spaces $V$ and $W$.


EDIT: Fixed the counter-example above.



Which partitions of $[0,1]$ are collection of level sets of a real continuous function?
Any map $[0,1]\to[0,1]$ is a quotient map onto its image, and the image must be either a point or a closed interval. So a partition comes from such a map iff the quotient of $[0,1]$ by the equivalence relation associated to the partition is homeomorphic to either a point or an interval. In particular, given any characterization of an interval up to homeomorphism (among all spaces which are continuous images of an interval, which can themselves be [nicely characterized](https://en.wikipedia.org/wiki/Space-filling_curve#The_Hahn.E2.80.93Mazurkiewicz_theorem) if you assume they are Hausdorff), you get a characterization of such partitions.


Here is one such characterization, though maybe not a very easy one to apply. It is known that any compact connected metrizable space with at most two non-cut-points is homeomorphic to either a point or $[0,1]$, and any Hausdorff quotient of $[0,1]$ is metrizable. So a quotient of $[0,1]$ is homeomorphic to either a point or $[0,1]$ iff it is Hausdorff and has at most two non-cut-points.


These conditions can be stated explicitly in terms of the partition as follows. Say that an element $A\in\mathscr{P}$ is a *cut-set* for $\mathscr{P}$ if $\mathscr{P}\setminus\{A\}$ can be split into two disjoint nonempty subpartitions $\mathscr{Q}$ and $\mathscr{R}$ such that $\bigcup\mathscr{Q}$ and $\bigcup\mathscr{R}$ are both open subsets of $[0,1]$. Then a partition $\mathscr{P}$ is the level sets of a continuous map $[0,1]\to[0,1]$ if and only if:


1. The equivalence relation associated to $\mathscr{P}$ is closed as a subset of $[0,1]\times[0,1]$, and
2. All but at most two elements of $\mathscr{P}$ are cut-sets.


(Condition (1) is equivalent to the quotient being Hausdorff, and condition (2) is equivalent to the quotient having at most two non-cut-points.)


