4

I've been having a discussion with my friend about scoping rules in mathematical syntax. By scoping I mean a set of rules that define how variable and function names could be chosen so that at any given point no name used is ambiguous. As I'm a programmer, the concept of scoping feels very natural to me, so I started wondering whether there are some strict rules of such kind defined for mathematical syntax. If so, what are they?

The actual problem we've been arguing about with my friend was whether arguments of a function should be considered "global" or "local". Is the following notation correct (unambiguous)?

f(x) = x + 3; x ∈ ℝ
g(x) = 2x + 7; x ∈ ℤ

I believed it was, because x, as an argument, only has its meaning in the context of a function. My friend could not agree with that - he considered x "global" and therefore understood this snippet as some nasty and obviously incorrect attempt to double-define the domain of f and g. Do any standarized rules exist to support either claim?

Krotton
  • 143
  • The local interpretation is what is meant. There is nothing special about the letter "$x$"the function as written is just a rule for how to map numbers from some set into another set where $x$ is a place holder for members of the original set. – Spencer Dec 17 '13 at 21:51

2 Answers2

4

When defining a function, we usually start by saying what the domain and range are, like $f:\mathbb{R}\to\mathbb{R}$ ($f$ is a function from $\mathbb{R}$ to $\mathbb{R}$) and $g:\mathbb{Z}\to\mathbb{Z}$ (for your example functions). However, I believe your notation is unambiguous, the only real interpretation that I can see would be that you would read this as "$f\left(x\right)=x+3$ where $x\in\mathbb{R}$."

Now, it could be ambiguous as to whether you're saying that the domain is $\mathbb{R}$ or if you're just defining the part of $f$ for $x\in\mathbb{R}$ where your domain could be, say, $\mathbb{C}$. However, I think you'll find that most mathematicians wouldn't mind your syntax at all. Mathematics can be written in an ambiguous way while still being obvious in its intended interpretation, if that makes sense. If all you say when defining $f$ is "$f\left(x\right)=x+3$; $x\in\mathbb{R}$," I'm sure most would realize quickly that your intended domain is $\mathbb{R}$.

If you want to be more formal in your presentation, though, it would suffice to simply write this as "$f:\mathbb{R}\to\mathbb{R}$ where $f\left(x\right)=x+3$," and similarly for $g$.

The short answer: Your syntax works in practice for mathematicians, though your compiler/interpreter might complain if you try to program like that.

EDIT: Now I realize that the complaint by your friend might be about using $x$ twice rather than about how you know what domain you're using. Again, this is common in mathematics, and your syntax works.

Just explain to your friend in your favorite programming language why this works (I'll use C++ here):

double f(double x) { return x+3; }

int g(int x) { return 2*x+7; }

This is exactly how you're defining your functions, and g++ doesn't whine about it. You're right about this being about scope.

Brian
  • 2,147
4

I have never seen a list of scoping rules defined for mathematical expressions. However, I'd be willing to venture the following as generally accepted:

  1. An argument of a function is local to the function. That is, it is considered clear to write: $$f(x) = x^2,\; \text{ for }x \in\Bbb{R} \\ g(x) = x^4,\;x \text{ for }\in\Bbb{Z}$$
  2. If one writes "Let $x$ be..." this is a "global" definition with respect to the section of text; viz, $x$ is defined that way until the end of the proof/lemma/chapter/whatever.
  3. It is improper form to use a globally defined variable as an argument to a function. For example, it is poor form to write:

    Let $x=4$. And, let $g(x) = 4x^2$. (This causes confusion for the rest of the proof--to which $x$ do you refer?)

  4. Rule of thumb: Try to make scoping not an issue. Trivial instances where it is clear what the author means (like in point $1$) don't matter--a human is parsing the text, not a computer. If you have to think about it for more than a second or two, try to make it clearer.

apnorton
  • 17,706