Problem: Prove or disprove that for a finite set $\mathcal{A}$ and $\mathcal{B}$ both equipped with discrete topology, the function $f:\mathcal{A}^\mathbb{N} \rightarrow \mathcal{B}$ is continuous if and only if $f$ depends on finite number of coordinates on $\mathcal{A}^\mathbb{N}$.
(Note: $f$ depends on finite number of coordinates on $\mathcal{A}^{\mathbb{N}}$ if and only if there exist $n\in \mathbb{N}$ and a function $g:\mathcal{A}^n \rightarrow \mathcal{B}$ such that for any $(x_i)_{i\in\mathbb{N}} \in \mathcal{A}^\mathbb{N}$, $f((x_i)_{i\in\mathbb{N}})=g(x_1x_2...x_n)$.)
I can prove that if $f$ depends on finite number of coordinates, then $f$ must be continuous. However, for another direction, intuitively I believe that it must be true as well, but I cannot prove it. Here is my attempt:
Attempt: To avoid triviality, assume that $|\mathcal{A}|>1$, $|\mathcal{B}|>1$ and $|f(\mathcal{A}^\mathbb{N})|>1$. For any $n \in \mathbb{N}$ and any $a_i \in \mathcal{A}$, define the cylinder set $$C[a_1a_2...a_n]=\{(x_i)_{i\in\mathbb{N}} \in \mathcal{A}^\mathbb{N} \mid x_1x_2...x_n=a_1a_2...a_n\}.$$ Let's call $n$ as the length of the cylinder set. Based on some reading, the collection of all cylinder sets is the basis of discrete product topology on $\mathcal{A}^\mathbb{N}$.
Let $b \in f(\mathcal{A}^\mathbb{N})$. Since $f$ is continuous, $f^{-1}(\{b\})$ is open. By definition of basis, $f^{-1}(\{b\})$ is the union of some collection of cylinder sets. By property of cylinder sets, if two cylinder sets intersect, then one of them is a subset of another. Therefore, we can assume that $f^{-1}(\{b\})$ is the union of some collection of pairwise disjoint cylinder sets.
My next idea us to show that the collection of cylinder sets above is finite. If this is true, then we set $\ell$ to be the longest length of cylinder sets in the collection. Therefore, for any $(x_i)_{i\in\mathbb{N}} \in \mathcal{A}^\mathbb{N}$, it is sufficient to check for $x_1x_2...x_{\ell}$ to determine whether $f((x_i)_{i\in\mathbb{N}})=b$. We can do this for any $b \in f(\mathcal{A}^\mathbb{N})$.
However, I am stuck at proving that $f^{-1}(\{b\})$ is the finite union of some collection of pairwise disjoint cylinder sets.
Question: May anyone help me to continue my proof? Or is there any other way of proving this? Or is this statement wrong?
It's trivial that if $f$ depends on finitely many coordinates, then $f$ is continuous, in this setting: $\mathcal{A}^n$ is discrete (as $n$ is finite and $\mathcal{A}$ is discrete) so $g$ is always continuous as a function on a discrete space and by definition $f= g \circ \pi_n$, where $\pi_n: \mathcal{A}^\mathbb{N} \to \mathcal{A}^n$ is the projection onto the first $n$ coordinates (continuous by the definition of the product topology) so $f$ is also continuous as a composition of continuous maps.
The other direction is also quite simple: $f^{-1}[\{b\}]$ is a compact (and open) subset of $\mathcal{A}^\mathbb{N}$ and so a finite union of basic open sets (i.e. cilinder sets):
$$f^{-1}[\{b\}]= \bigcup \{ C[F], F \in \mathcal{F}_b\}$$
where $C[F]$ is a cilinder set based on a finite tuple $F$ from some finite power $\mathcal{A}^{n(F)}$, and we collect all needed $F$ for the fibre in some finite set of tuples $\mathcal{F}_b$.
Then $N=\max\{n(F): F \in \cup_{b \in B} \mathcal{F}_b\}$ is a well-defined (finite) integer and then you can go and show that (fixing some $a_0 \in \mathcal{A}$) that $g(x_1,\ldots,x_N) = f(x_1,x_2,\ldots,x_N, a_0,a_0,\ldots)$ is well-defined (i.e. does not depend on how we fill in the final coordinates) and witnesses the fact that $f$ depends on the first $N$ coordinates.