What is the operator precedence for quantifiers?
Is the term $$\forall x p(x) \rightarrow \forall x q(x)$$ equal to $$\forall x (p(x) \rightarrow \forall x q(x))$$ or $$(\forall x p(x)) \rightarrow (\forall x q(x))$$
In other words: What is the operator precedence of $\forall$ and $\exists$? Does it make a difference?
There is no "precedence" between quantifiers: in a formula like $\forall x \ \exists y \ \varphi$, the "inner" $\exists$ is in the scope of the "outer" $\forall$.
The recursive definition of formula for FOL is (having defined term) more or less this :
(i) $t_1=t_2$ and $P^n(t_1,\ldots,t_n)$ are atomic formulas, where $t_1,\ldots,t_n$ are terms and $P^n$ is a $n$-ary predicate symbol;
(ii) if $\varphi, \psi$ are formulas, then $\lnot \varphi, \varphi \land \psi, \varphi \lor \psi, \varphi \to \psi$ are formulas;
(iv) if $\varphi$ is a formula, then $((∀x)\varphi), ((∃x)\varphi)$ are formulas.
Then we can introduce abbreviations for readibility; see :
- Herbert Enderton, A Mathematical Introduction to Logic, page 78 :
For parentheses we will omit mention of just as many as we possibly can. Toward that end we adopt the following conventions:
Outermost parentheses may be dropped. For example, $∀x α → β$ is $(∀x α → β)$.
$\lnot, ∀$, and $∃$ apply to as little as possible. For example,
$¬α ∧ β$ is $((¬α) ∧ β)$, and not $¬(α ∧ β)$;
$∀x α → β$ is $(∀x α → β)$, and not $∀x(α → β)$;
$∃x α ∧ β$ is $(∃x α ∧ β)$, and not $∃x(α ∧ β)$.
In such cases we might even add gratuitous parentheses, as in $(∃x α)∧β$.
∧ and ∨ apply to as little as possible, subject to item 2. For example, $¬α ∧ β → γ$ is $((¬α) ∧ β) → γ$.
When one connective is used repeatedly, the expression is grouped to the right. For example, $α → β → γ$ is $α → (β → γ)$.
Thus, we have a "formal" specification for the syntax: it must be unambiguous, i.e. "processable" by a machine.