Let $X$ be a compact metric space, $A,B\subset X$ be subsets and $f\colon X\times X\to \mathbb{R}$ a continuous function that is strictly positive on $A\times B$. Do there exist increasing sequences of subsets $A_1\subseteq A_2\subseteq \dots$ and $B_1\subseteq B_2\subseteq \dots$ such that:

- $A=\bigcup_{n\in\mathbb{N}}A_n$ and $B=\bigcup_{n\in\mathbb{N}}B_n$;
- for every $n\in\mathbb{N}$, the restriction of $f$ to $A_n\times B_n$ is bounded away from zero?

We can also rephrase the question as follows. Let $X,A,B$ as before and let $C\subset X\times X$ be a closed subset such that $(A\times B)\cap C= \emptyset$. Do there exist increasing sequences of compact sets $K^A_1\subseteq K^A_2\subseteq \dots$ and $K^B_1\subseteq K^B_2\subseteq \dots$ such that:

- $A\subseteq\bigcup_{n\in\mathbb{N}}K^A_n$ and $B\subseteq\bigcup_{n\in\mathbb{N}}K^B_n$;
- $(K^A_n\times K^B_n)\cap C = \emptyset$ for every $n\in\mathbb{N}$?

If true, this sounds like a useful lemma and I would not be surprised if it already appeared somewhere else. I need this fact (or something similar) to reduce some statement about operators on product spaces to the compact case, but I thus far failed to find a proof or a counterexample. Any suggestion?