Looking for an approach to mathematical notation wherein the universe is divided into disjoint worlds.

Is there a rigorous approach to mathematical notation wherein the "universe" is divided into disjoint "worlds," and the meaning of notation is world-dependent? This would solve a few pesky problems. Ultimately, I'm not looking for a hand-waivy solution, but rather something that is near computer readable.

Here's three examples of pesky issues I'd like solved in a rigorous manner. Note that many of the following issues only arise if we use a set-theoretic foundations, because in such a foundations everything is a set. However, I believe that similar issues would arise in any foundations.

1. If $f$ and $g$ are functions mapping $X \rightarrow Y$ and $*$ is a binary operation on $Y$, I would want $f * g$ to equal $x \mapsto f(x)*g(x)$. So for example, the expression $f \cup g$ should equal $x \mapsto f(x) \cup g(x)$. Of course, if $f$ and $g$ are viewed as sets of ordered pairs, then $f \cup g$ already has a meaning, so we get a conflict. This conflict goes away if we view functions as existing in a different "world" to sets, so that the same notation can mean different things.
2. If $X$ and $Y$ are random variables, I would want $(X,Y)$ to denote the random variable $\omega \mapsto (X(\omega),Y(\omega))$. However, $(X,Y)$ already has a meaning (its an ordered pair), and thus we get a conflict. One possible solution would be to view $X$ and $Y$ as belonging to a world where $(*,*)$ is defined differently to normal.
3. It is common to write $f(X)$ as shorthand for $\{f(x)\,|\,x \in X\}$. However, if natural numbers are constructed in the manner of Von Neumann, then for example $2 = \{0,1\}$, thus $f(2)=\{f(x) \,|\,x \in 2\}=\{f(x) \,|\,x \in \{0,1\}\}=\{f(0),f(1)\}$, which is probably not what the writer meant by $f(2)$. To avoid this, natural numbers should be viewed as living in a world that is disjoint from the world of sets (that is, a natural number should not be identified with its Von Neumann encoding).

So to reiterate, I'm looking for an approach to mathematical notation wherein the universe is divided into disjoint worlds and notation is world-dependent.

EDIT: Caveman in his answer suggests that the simply-typed lambda calculus solves the problem. If anyone knows of a gentle introduction to this field, please leave a comment.

• I'm not totally sure what you want, but +1 for interest. – Ian Coley Mar 22 '13 at 3:53
• The second problem is easy. Denote ordered pairs by $\langle X,Y\rangle$, and not by $(X,Y)$. Also, note that notational overload is not really a problem because we are setting up the context for it when it occurs. The question seems to me very similar in nature to the following "I want that all the objects called 'normal' would have a similar property" or 'regular' instead. That's not going to happen. The third issue is also a notational overload, and in set theory the direct image is often denoted by $f[X]$ or $f"X$, rather than $f(X)$, so where it poses a problem the third problem is gone – Asaf Karagila Mar 24 '13 at 7:38
• @AsafKaragila Yes instead of $(X,Y)$ we could write $\langle X,Y\rangle$, and instead of $f(X)$ we could write $f \circ X$, for example. But this makes the notation worse, not better. I think if you've done a bit of probability theory, you'll probably agree. – goblin Mar 24 '13 at 7:42
• But this is all a set of syntactical problems. Not foundational problems. How to avoid syntax overload and retain readability is a serious problem, I agree. But it can be easily corrected by introducing new syntax. – Asaf Karagila Mar 24 '13 at 7:43
• The idea is to get away with NOT introducing new syntax, while still being unambiguous. How does one do this rigorously? That is a foundational question. – goblin Mar 24 '13 at 7:46

All three questions are purely about the conventions of mathematical notation; there is no need for creative mathematical metaphysics to resolve them. The first two examples you give show that it is not generally possible to extend notation in any way that one might find convenient, without bumping into already established conflicting interpretations. The solution is usually just to modify the notation so that confusion does not arise. Alternatively (and questionably) the old notation can be used anyway, and the reader specifically warned that it is not to be understood by its prior undesired interpretation. The third example points out an established abuse of notation that is already problematic. However, the abuse is so entrenched that anyone who introduced a new notational device to avoid the conflict would be regarded as pedantic, unless the mathematical context was one where both the set $X$ and its elements were in the domain of the function.