Let $B \in \mathcal B (Y)$ and $C \in \mathcal B(X \times Y)$. Is $\{x \in X \mid \exists y \in B \text{ s.t. } (x, y) \in C\} \in \mathcal B(X)$? Let $X,Y$ be second-countable topological spaces. Let $\mathcal B(X), \mathcal B(Y),\mathcal B(X \times Y)$ be the Borel $\sigma$ algebras of $X, Y , X \times Y$ respectively.

Question: Let $B \in \mathcal B (Y)$ and $C \in \mathcal B(X \times Y)$. Is $A := \{x \in X \mid \exists y \in B \text{ s.t. } (x, y) \in C\} \in \mathcal B(X)$?


*

*Lemma: The Borel $\sigma$-algebra of the countable product of second-countable topological spaces coincides with the product of the Borel $\sigma$-algebras.


*Remark: Let $\langle X_{i}, \Sigma_{i} \rangle_{i \in I}$ be a family of measurable spaces, $X$ a set, and $\langle f_{i}: X \rightarrow X_{i}\rangle_{i \in I}$ a family of mappings. Then the $\sigma$-algebra generated by $\langle f_{i}\rangle_{i \in I}$, denoted by $\sigma(f_{i}: i \in I)$, is the smallest $\sigma$-algebra on $X$ such that every $f_{i}$ is $\sigma (f_{i}: i \in I) / \Sigma_{i}$-measurable. Let $\pi_i : \prod_{i\in I} X_i \to X_i$ be the projection maps. Then the product $\sigma$-algebra $\otimes_{i\in I} \Sigma_i$ on $\prod_{i\in I} X_i$ is the $\sigma$-algebra generated by $\langle \pi_{i}\rangle_{i \in I}$.
My attempt: By our Lemma, $\mathcal B(X) \otimes \mathcal B(Y) = \mathcal B(X \times Y)$. Let $A' = (X \times B) \cap C$. Then $A' \in \mathcal B(X \times Y)$ and $A = \pi_1 (A')$ with $\pi_1: X \times Y \to X$ being the projection map. Because the projection of a measurable set is not necessarily measurable, it may be the case that $A \notin \mathcal B(X)$.
However, I could not come up with a counter-example. Could you please provide one?
Update: My question arises from the following problem.  Let $C \in \mathcal B(X \times Y)$ such that if $(x, y), (x, y') \in C$ then $y=y'$. This means $C$ is the graph of a function $f:A \to Y$ for some $A \subset X$. I'm interested in whether $f$ is measurable, i.e., $f^{-1} (B) \in \mathcal B(X)$ for every $B \in \mathcal B(Y)$.
 A: This answer gives details on my comments. The first example of a Borel measurable subset of $\mathbb{R}^2$ with a non-Borel projection onto the first dimension was by Souslin (around the year 1917, Souslin then died in 1919). Souslin did this in reaction to a mistake that Lebesgue made in one of his proofs (Lebesgue's theorem was correct but the proof was wrong).

Here is a partially explicit example: Let $f:\mathbb{R}\rightarrow\mathbb{R}$ be any Borel measurable function whose image $f(\mathbb{R})$ is not a Borel subset of $\mathbb{R}$ (such functions exist). Define
$$ C = \{(f(y), y) \in \mathbb{R}^2: y \in \mathbb{R}\}$$
Then $C$ is a Borel measurable subset of $\mathbb{R}^2$. [Proof: Define the Borel measurable function $g:\mathbb{R}^2\rightarrow \mathbb{R}$ by $g(x,y)=f(y)-x$. Then $g^{-1}(\{0\}) = \{(x,y) \in \mathbb{R}^2: f(y)=x\}=C$ is Borel.] However, the projection of $C$ onto the first dimension is $f(\mathbb{R})$, which is not Borel.

Followup on your update: While the above gives a counter-example to your first question, there is still hope regarding your update. In general, a function $f:\mathbb{R}\rightarrow\mathbb{R}$ is Borel measurable if and only if its graph is a Borel measurable subset of $\mathbb{R}^2$. In my example above I just inverted the coordinates of the graph of $f$ so I could project onto the first dimension instead of the second dimension.
Since you want to work with more general sets $X$ and $Y$, here is a result that may be of use:
Claim: Let $X$ and $Y$ be two Polish spaces and let $f:X\rightarrow Y$ be a function. Suppose the graph $G=\{(x,f(x)): x \in X\}$ is a Borel measurable subset of $X \times Y$ (using the product topology). Then $f$ is a Borel measurable function.
Proof: Fix $B$ as a Borel measurable subset of $Y$. We want to show $f^{-1}(B)$ is a Borel measurable subset of $X$.  Define the following two disjoint sets:
\begin{align}
A_1 &= G \cap \{(x,y) \in X \times Y : y \in B\}\\
A_2 &= G \cap \{(x,y) \in X \times Y : y \notin B\} 
\end{align}
Since $A_1$ is the intersection of two Borel measurable sets, it is Borel measurable.  The projection $\pi_X(A_1)$ to the first dimension is a continuous function of a Borel measurable subset of the Polish space $X \times Y$ to the Polish space $X$, and hence $\pi_X(A_1)$ is an analytic subset of $X$.  Likewise, $A_2$ is Borel measurable and its projection $\pi_X(A_2)$ is again an analytic subset of $X$.  However $\pi_X(A_2)$ is the complement of $\pi_X(A_1)$. Another theorem of Souslin is that if an analytic subset of a Polish space has an analytic complement, then both the set and its complement are Borel. So $\pi_X(A_1)$ is Borel, but we also have $\pi_X(A_1)=f^{-1}(B)$. $\Box$
