Associate a function to an expression

definitionlogic

This is related to my previous question on expressions. Consider a countably infinite set of variables, indexed by the positive integers. Suppose also we are considering the set of real numbers as our domain. How would we associate a function to an expression, as in how would we formally define it. For example, should $x_2$ be associated to the identity function on $\mathbb{R}$, or to the projection function on $\mathbb{R}^2$ that returns the second coordinate? Also, should something like $x_1+x_2-x_3+x_3$ be defined on $\mathbb{R}^3$, or $\mathbb{R}^2$? Is there some mathematical text where the mapping from expressions to functions is formally defined?

Best Answer

You're right that there's some flexibility here. The simplest approach is to just clear everything up by adding some "metadata." Say that an annotated term (in a given language, using $\mathbb{N}$-indexed variables) is a pair $(t,n)$ where $t$ is a term in the language and every variable occurring in $t$ has index $\le n$. Then we can construe each annotated term $(t,n)$ as a function from the $n$th Cartesian power of our structure to itself.

The default, then, is to use the smallest possible $n$. So for example (abusing parentheses for simplicity) "$x_1+x_2$" and "$x_1+x_2+x_3-x_3$" would refer to functions from $\mathbb{R}^2$ and from $\mathbb{R}^3$ respectively; their "equivalence" would amount to the fact that the former is the projection of the latter.

  • Note that in this approach we do lose some parsimony: e.g. taking the term "$x_5+x_2$" we have to have $n\ge 5$, and so we can't construe that as a function from $\mathbb{R}^2$ even though it only has two variables occurring in it. If you want to get around this you can modify the definition of "annotated term" above to refer to pairs $(t,X)$ where $t$ is a term and $X$ is a finite sequence of variables, such that each variable in $t$ occurs in $X$. For example, we then would interpret $(2\cdot x_5+x_2, \langle x_5,x_3,x_2\rangle)$ as the function $$\mathbb{R}^3\rightarrow\mathbb{R}: (a,b,c)\mapsto 2\cdot a+c$$ (because the sequence part tells us that $x_5$ is the first variable in our approach here). This also has the advantage that we can use any set of variables that we want, instead of just $\mathbb{N}$-indexed ones.

Unfortunately this is generally swept under the rug, but hopefully the above indicates that it's pretty straightforward to treat if you really want to. It's also worth noting that usually we go the other way: we first declare that we're going to consider functions $\mathbb{R}^n\rightarrow\mathbb{R}$, and then interpret terms with variables only from $\{x_1,...,x_n\}$ as maps $\mathbb{R}^n\rightarrow\mathbb{R}$ in the obvious way. So a lot of the time this doesn't come up at all: while it's true that we can interpret a given term as living on different domains, since we specify what domain we're interested in at the outset we don't care about this ambiguity.