Are $C([0,1])$ and $C(\mathbb{R})$ elementarily equivalent as rings? For a topological space $X$, let $C(X)$ denote the ring of continuous functions $X\to\mathbb{R}$, equipped with pointwise addition and multiplication. This question is related to this one of Noah Schweber's; in particular, the question arises from trying to understand how much topological data about $X$ is encoded in the first-order theory of the ring $C(X)$. For example, $C(X)$ has a non-trivial idempotent if and only if $X$ is disconnected. A natural question to ask is when the first-order theory of $C(X)$ can also detect whether $X$ is compact, and this is the context in which the question below arises. For further elaboration and additional context, see Noah's post and the answers and comments below it.
Let $[0,1]$ and $(0,1)$ be the closed and open unit intervals in $\mathbb{R}$. Note that there is an injective ring morphism $\iota:C([0,1])\hookrightarrow C((0,1))$ that takes a map $\alpha:[0,1]\to\mathbb{R}$ to its restriction $\alpha|_{(0,1)}$.

Question: Is the map $\iota$ elementary? If the answer is no, do we nonetheless have an elementary equivalence $C([0,1])\equiv C((0,1))$?

I suspect a negative answer, but I don't see a path for showing this. A natural first idea is to somehow try to exploit that $\operatorname{im}\alpha\subseteq\mathbb{R}$ is bounded for every $\alpha\in C([0,1])$. So, for example, one can define a formula $$u>v\equiv \exists w\big[u-v=w^2\big]\wedge\exists w\big[(u-v)w=1\big].$$ Then, for any space $X$ and any continuous $\alpha,\beta:X \to\mathbb{R}$, we have $C(X)\models\alpha>\beta$ if and only if $\alpha(x)>\beta(x)$ for each $x\in X$. Indeed, $C(X)\models \exists w[\alpha-\beta=w^2]$ if and only if $\alpha(x)\geqslant\beta(x)$ for each $x\in X$, and $C(X)\models \exists w[(\alpha-\beta)w=1]$ if and only if $\alpha(x)\neq\beta(x)$ for each $x\in X$.
With this in hand, it is fairly straightforward to come up with a first-order theory that is satisfiable in $C((0,1))$ but not in $C([0,1])$, provided we are willing to add an additional constant symbol to our language. Indeed, let $a$ be a new constant symbol, and define a theory $T$ in the language of rings along with $a$ by taking $\neg(a<n)\in T$ for each $n\in\omega$. Then realizing $a$ as any homeomorphism $(0,1)\to\mathbb{R}$ will make $C((0,1))$ into a model of $T$, but no realization of $a$ can do the same for $C([0,1])$, since any continuous image of $[0,1]$ in $\mathbb{R}$ is bounded.
However, this is of course not enough to show that $C([0,1])\not\equiv C((0,1))$ as rings, and I don't see an easy way of extending the argument. If there were some way to uniformly define the subring $\mathbb{R}$ in $C([0,1])$ and $C((0,1))$, then we would be done: if $\theta(w)$ were such a definition, then $C([0,1])$ would be a model of the sentence $\forall v\exists w[\theta(w)\wedge (w>v)]$ and $C((0,1))$ would be a model of its negation. But I'm struggling to come up with such a formula $\theta$, and I'm not even convinced it can be done. Any insight, either on this approach or on a different one, would be much appreciated.
 A: Regarding your more general question, the answer is no: if $X$ is any non-compact pseudocompact space, then we have a natural (topological) isomorphism $C(X)\cong C(\beta X)$. For instance, $C(\omega_1)\cong C(\omega_1+1)$ (with the order topology on both $\omega_1$ and $\omega_1+1$).
Thus, even topological isomorphism type of $C(X)$ is not enough to characterise compactness of $X$.
(Kudos to Henno Brandsma for pointing out the name of this property and the example of $\omega_1$.)
In fact, one might even have non-trivial spaces with trivial $C(X)$, although in that case, the space cannot be completely regular. For instance, any directed poset with the final order topology is an example (a non-$T_1$ one), which is non-compact if the posets has an infinite strong antichain. There are also $T_3$ examples, see this post.
A: I don't have a complete proof of the second fact, but I do have some results.

*

*There is no elementary embedding from $C((0, 1))$ to $C([0, 1])$.

For each (external) $n \in \mathbb{N}$, let $\pi(n)$ be the term recursively defined by $\pi(0) = 0$, $\pi(s(n)) = n + 1$.
Now consider that we can encode the fact that $\forall x (f(x) \leq g(x))$ in the language of rings as $\exists h (f + h^2 = g)$.
In particular, we can encode the fact that $\forall x (f(x) \leq n)$ in the language of rings as $\exists h (f + h^2 = \pi(n))$.
Now suppose there were some elementary embedding $i : C((0, 1)) \to C([0, 1])$. Then consider $f(x) = \frac{1}{x}$, $f \in C((0, 1))$.
By compactness, there exists some $n \in \mathbb{N}$ such that $i(f)(x) \leq n$ for all $x$. But there is no $n$ such that $f(x) \leq n$ for all $n$.
So given the statement $\phi(x) :\equiv \exists h (x + h^2 = \pi(n))$, we see that $\phi(f)$ is false but $\phi(i(f))$ is true.


*The restriction map $C([0, 1]) \to C((0, 1))$ is not an elementary embedding.

Proof: let $f(x) = x$, $f \in C([0, 1])$. Then $i(f)$ is a unit while $f$ is not.
A: Here is an easy answer to your first question.  Your map $\iota$ is not an elementary embedding.  Note, for instance, that the function $f(x)=x$ is not a unit in $C([0,1])$, but $\iota(f)$ is a unit.  This is expressible in the first-order language of rings (with $f$ as a parameter) so $\iota$ is not an elementary embedding.
The second question also has a negative answer though it is rather more complicated.  First, I claim that there is a first-order formula $\varphi(f)$ in the language of rings which says "$f$ vanishes at exactly one point" when interpreted in both $C([0,1])$ and $C((0,1))$.  Replacing $f$ with $f^2$, we may assume $f\geq 0$ for this purpose. I claim the vanishing set of a function $f\geq 0$ is disconnected iff we can write $f=gh$ where $g,h\geq 0$, neither $g$ nor $h$ is a unit, and $g+h$ is a unit.  One direction is easy: if such $g$ and $h$ exist, then the vanishing set of $f$ is the disjoint union of two nonempty closed sets, namely the vanishing sets of $g$ and $h$.  Conversely, suppose the vanishing set of $f$ is disconnected, so there is some $c\in (0,1)$ such that $f(c)\neq 0$ but $f$ vanishes at points both below and above $c$.  Then you can take $g(t)=f(t)$ for $t\leq c$ and $g(t)=f(c)$ for $t\geq c$ and $h(t)=1$ for $t\leq c$ and $h(t)=f(t)/f(c)$ for $t\geq c$.
Also note that $f$ is a zero-divisor iff $f$ vanishes on some (nondegenerate) interval.  So, we can express that $f$ vanishes at exactly one point by saying that $f^2$ is not a unit but its vanishing set is neither disconnected nor contains an interval.
Now the idea is that we use functions vanishing at points as representatives of those points, and distinguish $C([0,1])$ from $C((0,1))$ since $[0,1]$ has endpoints and $(0,1)$ does not.  Note first that if $f$ and $g$ vanish at exactly one point, they vanish at the same point iff $f^2+g^2$ is not a unit.  Now, $C([0,1])$ has a function $f$ which vanishes at exactly one point such that for any other function $g$ which vanishes exactly at that same point, either $g$ or $-g$ is a square (namely, take $f$ to vanish only at one of the endpoints of $[0,1]$).  However, $C((0,1))$ does not have any such function $f$ (since for any $a\in (0,1)$ you can take a function that is positive on one side of $a$ and negative on the other side).

Let me say a bit about how this generalizes.  If $X$ is a topological space, let $Z(X)$ be the poset of zero sets in $X$ (i.e., vanishing sets of elements of $C(X)$) ordered by inclusion.  If $X$ is a nice (e.g., metrizable) space, then $Z(X)$ is just the poset of closed subsets of $X$.  I claim that the poset $Z(X)$ together with the map $z:C(X)\to Z(X)$ mapping a function to its vanishing set is interpretable in $C(X)$ (uniformly in $X$).
Indeed, if $f,g\in C(X)$, note that $z(f)$ is disjoint from $z(g)$ iff $f^2+g^2$ is a unit.  Then, we can say $z(f)\subseteq z(g)$ iff for all $h$ such that $z(h)$ and $z(g)$ are disjoint, $z(h)$ and $z(f)$ are also disjoint.  So, we can define the equivalence relation $f\sim g$ iff $z(f)=z(g)$, and thus interpret $Z(X)$ (together with the map $z$) as the quotient of $C(X)$ by this equivalence relation, and we also can define the ordering on $Z(X)$.
So in particular, if $C(X)$ and $C(Y)$ are elementarily equivalent, then so are the posets $Z(X)$ and $Z(Y)$.  For nice spaces, this means the posets of closed (or equivalently, open) sets are elementarily equivalent.  You can also identify the points of $X$ (for nice $X$) as the minimal nonzero elements of the lattice $Z(X)$, and, for instance, express statements like "$X\setminus\{x\}$ is connected for all $x\in X$".  I don't know a way of using this to express compactness-like statements or whether functions are bounded, though.
