Exercise
I'm attempting the following exercise:
Fix a subbasis $\mathcal{S}$ of $X$. Prove that $X$ is completely regular $(T_{3\tfrac{1}{2}}$) if and only if for each point $x\in X$ and neighborhood $V\in\mathcal{S}$ with $x\in V$, there exists a map $f:X\to [0,1]$ such that $f(x)=0$ and $f(y)=1$ for $y\in X-V$.
The forward direction is straightforward (assuming I approached it correctly) but I'm having trouble with the converse.
My Attempt
$(\Leftarrow)$ Suppose that $C\subset X$ is a closed set with $x\not\in C$. $X-C$ is open, so $X-C$ is a union of finite intersections of members of $\mathcal{S}$; for simplicity assume that we can write $$ X-C=V_1\cap V_2\cap\cdots\cap V_n $$ for some $V_1,\ldots, V_n\in\mathcal{S}$. Since $x\in X-C$, it follows that $x\in V_i$ for each $i$, and the hypothesis asserts that there exist maps $f_i:X\to [0,1]$ such that $f_i(x)=0$ and $f(y)=1$ for $y\in X-V_i$. Now (by DeMorgan's Law in set theory) $$ C=(X-V_1)\cup (X-V_2)\cup\cdots\cup (X-V_n). $$ so it seems that we need to construct some map $f:X\to [0,1]$ such that $f|_{V_i}=f_i$ for each $i$. But I cannot think of an easy way to do this. If I could, then it shouldn't be hard to provide a proof for the general case (that $X-C$ is the union of more than just one finite intersection of elements of $\mathcal{S}$).
Comments and Concerns
I thought about defining $f=\prod_{i=1}^{n}f_i$, but when $y\in X-V_i$ and $y\not\in X-V_j$ for some $i\neq j$, there is no guarantee that $f(y)=1$. I also thought of defining $f$ in some piecewise manner, but I would likely lose continuity in this process. Could anyone give me a hint as to go about constructing this $f$? Thanks very much in advance.
Edit: I almost forgot to mention: this problem is "part a" in a sequence of exercises which we allowed to assume that all spaces are at least $T_1$; however I don't think it really plays a role in this specific problem.
HINT: Let $g=\prod_{k=1}^n(1-f_k)$. Clearly $g(x)=1$. Now suppose that
$$y\in X\setminus\bigcap_{k=1}^nV_k=\bigcup_{k=1}^n(X\setminus V_k)\;;$$
then there is a $k\in\{1,\ldots,n\}$ such that $f_k(y)=1$, so $g(y)=0$. Now $g$ isn’t quite what you want, but ... ?