Defining a continuous function on a completely regular totally disconnected space

A topological space $$X$$ is totally disconnected if the connected components in $$X$$ are the one-point sets. Also, a $$T_1$$ topological space $$X$$ such that for every closed subset $$C$$ of $$X$$ and every point $$x \in X\setminus C$$, there is a continuous function $$f:X\rightarrow[0,1]$$ such that $$f(x)=0$$ and $$f(C)={1}$$ is called completely Regular.

Now let $$X$$ be a completely regular totally disconnected topological space and $$f$$ be a real-valued continuous function over $$X$$( that is, $$f\in C(X)$$). Now if $$A\subseteq X$$ such that $$f(A)=\{0, 1\}$$, how can we define a real-valued continuous function $$g$$ over $$X$$ such that $$g(X)=\{0,1\}$$ and $$f(a)=g(a)$$ for all $$a\in A$$?

• What is the origin of your question? – Paul Frost Oct 3 '18 at 12:44
• This cannot always be done. There are even separable metric counterexamples. – Henno Brandsma Oct 3 '18 at 16:38

Your desired property could be reformulated as “every two subsets of $$X$$ that are functionally separated are clopenly separated”. This property (together with complete regularity) is called strong zero-dimensionality. In the context of Hausdorff spaces we have the following implications: \begin{align}\text{strongly zero-dimensional} \implies \text{zero-dimensional} \implies \text{totally separated} \implies \text{totally disconnected}.\end{align} The implications cannot be reversed. For example the Cantor's leaky tent with the apex removed is a metrizable totally disconnected space that is not totally separated. On the other hand, if your space $$X$$ is compact, then all the conditions are equivalent.
• We will have a counterexample in a totally disconnected separable metric space of dimension $n > 0$. E.g. Erdös space will do as well. – Henno Brandsma Oct 3 '18 at 16:37