What are the rules of scope?

What are the rules for scope in standard mathematics? I've mostly been working with informal/standard mathematics so the concepts of 'scope' are not familliar to me.

I understand that a variable can be defined in a specific context and scope, discussing when something is the 'same variable' perhaps is dependent on the scope, so let's say the symbol 'x' is the 'same variable' within the context of the scope. The definition of when something is 'the same variable' or 'in scope' is difficult. Is there a precise definition of this?

These are the rules I seem to understsand so far:

• A bound variable is in scope if it comes after a quantifier or bounding operator only in the expression after that operator

• A variable which is introduced using free occurences is in-scope in the same formula/expression, as long as it is free in the formula.

Are there any other rules that must be known? For example, if I am doing something and I introduce several formulas with free occurences of a symbol 'x' is the scope limited to each formula or is 'x' the same variable in each formula as they are part of the same 'scope'.When given two formulas with occurences of 'x', for each assignment, 'x' is in scope in both formulas if both yield a truth value?

Is it formally correct to introduce the same symbol in a formula twice (through binding) but in different scopes?

Can I use the same symbol for both free and bound variables in the same language?

• see Scope (logic): it is the formula following the quantifier, usually enclosed in parentheses. If parentheses is omitted, the quantifier applies as little as possible. Example: $\forall x Px \to Qx$ vs $\forall x (Px \to Qx)$ Jan 11, 2023 at 14:38
• If we have 'free' variables does scope 'apply'? If I decide one variable takes values in the domain of reals and another in naturals but use the same symbol '$x$' I would say there is different scope, or just a differrent context? Can I use the same symbol as free and bound in the same language? Jan 11, 2023 at 14:44
• No, free variables have occurrences in formulas: var $x$ occurs one in $Px$ and twice in $x=x$. Jan 11, 2023 at 14:49
• "scope" means: the extent of the area or subject matter that something deals with or to which it is relevant. Thus, a quantifier has a scope because it performs an action (bind variables) in a certain formula; the scope is the part of the formula on which quantifier applies. Jan 11, 2023 at 14:50
• Can I use the same symbol as free and bound in the same language? Yes, also if there are treatments of predicate logic (see Gentzen and Smullyan) where $x,y$ are used ONLY bound and $a,b$ are used free. Jan 11, 2023 at 14:52

I'm not aware that anyone has written down formal rules, but as a matter of convention, it's confusing for readers to use the same variable names for both a free and a bound variable so I would avoid it. The most forgivable kinds of recycling are dummy variables such as the indices of summations, e.g. in expressions like

$$a_n = \sum_{k=0}^n b_k$$

the dummy / bound variable $$k$$ indexing the summation is tacitly understood to have local scope confined to the summation and nobody will be confused if you use the same index for a different summation, and similarly for dummy integration variables such as the variable $$t$$ in an expression like

$$g(x) = \int_0^x f(t) \, dt.$$

Other than that I would generally avoid recycling variable names but there are a few forgivable exceptions that you pick up from reading other people's mathematical writing, e.g. nobody will be confused if you write $$f(x), g(x), h(x)$$ with the tacit understanding that $$f, g, h$$ are three functions and $$x$$ is just a dummy variable describing some element of their domain, whatever that is. But if, for example, there is a quantity $$n$$ that you need to keep track of in the course of the argument, definitely do not reuse that symbol to refer to anything else in the argument, even dummy variables.

As you read mathematical writing you'll also pick up conventions for which symbols tend to be "reserved" for which purposes, e.g. it is common to reserve $$i, j, k$$ as dummy variables to index summations (although $$i$$ should be avoided if you need to write down complex numbers), and using these conventions improves readability so it's a good idea not to deviate from them too much.

Just try to write things that aren't confusing to read. You're trying to communicate something to another human, not a compiler. So ultimately the guiding question is: could a typical reader be confused by this notational choice, or not?

• you mean “$x$ ist just a dummy variable describing some element of their domain” … Jan 11, 2023 at 23:05
• Yes, thank you. Jan 12, 2023 at 3:08