2

Examples of priority issues are as follows:

  • $\lnot P\wedge Q$ is $(\lnot P)\wedge Q$ or $\lnot (P\wedge Q)$?
  • $P \wedge Q\rightarrow R$ is $(P \wedge Q)\rightarrow R$ or $P \wedge (Q\rightarrow R)$ ?
  • $\forall x \in A, P\rightarrow Q$ is $(\forall x \in A, P)\rightarrow Q$ or $\forall x \in A, (P\rightarrow Q)$ ?
Hayatsu
  • 363
  • 3
    This is why I say "parentheses, please." For logical connectives I always go to the next attached symbol. – Sean Roberson May 12 '23 at 00:37
  • In my experience, the usual order of precedence is $$\lnot, (\land, \lor), \to, \leftrightarrow.$$ So then $\lnot P \land Q$ should be parsed as $(\lnot P) \land Q$, $P \land Q \to R$ should be parsed as $(P \land Q) \to R$, etc. Note that $\land$ and $\lor$ are usually viewed as equal-precedence, so that you always use parentheses to disambiguate them. – HallaSurvivor May 12 '23 at 01:44
  • I'm just leaving this as a comment, since I don't think there's any "standard" order that everybody uses. For instance, some people break the $\land, \lor$ tie by always parenthesizing left to right (so that $A \lor B \land C$ parses as $(A \lor B) \land C$ while others give $\land$ higher precedence (presumably by analogy with multiplication being higher precedence than addition?). See here for instance. – HallaSurvivor May 12 '23 at 01:46
  • @HallaSurvivor And parenthesising $\lor;\land$ right to left is not uncommon either. – ryang May 12 '23 at 02:58
  • Is there a standard?! Are you kidding?! There are at least 10 different standards! :) – Z. A. K. May 12 '23 at 04:02

1 Answers1

2

The usual precedence convention is:

  1. quantification
  2. negation
  3. conjunction, disjunction
  4. conditional, biconditional

Among and , or among , or among and , always use parentheses.

And if the reader (or software) may not be familiar with the above precedence convention—or is suspected to be using a different one—then using parentheses helps; however, too many parentheses does decrease human-readability.


  • $\lnot P\wedge Q$

    is $(\lnot P)\wedge Q\quad$ or $\quad\lnot (P\wedge Q)$ ?

The former.

  • $P \wedge Q\rightarrow R$

    is $(P \wedge Q)\rightarrow R$ or $P \wedge (Q\rightarrow R)$ ?

The former.

  • $\forall x \in A, P\rightarrow Q$

    is $(\forall x \in A, P)\rightarrow Q$ or $\forall x \in A, (P\rightarrow Q)$ ?

Ambiguous: it's unclear whether the comma is being used as a delimiter, in which case $$\forall x{\in} A\;(P\rightarrow Q)$$ is the intended meaning, or whether the comma is being logically superfluous (i.e., doesn't alter meaning and can be ignored), in which case $$(\forall x{\in} A\;P)\rightarrow Q$$ is the intended meaning.

ryang
  • 38,879
  • 14
  • 81
  • 179
  • Other people's mileage definitely definitely does vary. Conjunction has higher precedence than disjunction for a lot of authors. And in the world of computational logic, quantification has lowest precedence in a lot of systems like HOL. – Rob Arthan May 13 '23 at 22:09
  • @RobArthan In my comment under the OP, I acknowledged and even gave an example of how authors sort out the precedence between and . Listing them within the same hierarchy in my above answer is just so that should we encounter a formula like Px ∧ Qx ∨ Rx we should know to ask for clarification; on re-reading, I can see how calling that order "the usual precedence" is inaccurate. – ryang May 14 '23 at 08:26
  • @RobArthan I've never heard of quantification having the lowest precedence, but will take your word for it; I do wonder whether someone who writes ∀xPx → Q to mean ∀x(Px → Q) is not actually giving ∀ the lowest precedence but because they are mistaking that the latter as equivalent to (∀xPx) → Q. – ryang May 14 '23 at 08:26
  • I think the computational logic world adopted lowest precedence for quantification because it agrees with the $\lambda$-calculus: where right from the get-go no-one ever wanted $\lambda x . f x$ to mean $(\lambda x. f) x$. Often notations that use this convention also use a dot or a bullet after the bound variable (as I just did in the $\lambda$-calculus): this is reminiscent of the dot convention used by Russell and Whitehead (though thankfully nothing like as complicated: my single dot just says "now go as far to the right as you can"). – Rob Arthan May 14 '23 at 20:44
  • @RobArthan I too was thinking that your claim (about quantifiers having low precedence) is related to the lambda calculus dot. So, not only does the dot confuse precedence order for those who may/may not be using the dot like in lambda calculus, there are systems that act as if there is an invisible lambda-calculus dot anyway (thereby making it impossible to know how to read logic formulae without an explanatory preface)? What a mess, haha. I think Bram28 made a good point recently about how logic like any language has concurrent strands of evolution, so systems differ; it's bemusing that – ryang May 15 '23 at 04:17
  • as structured and systematic as logic notation is, there's nevertheless no guarantee of inter-system consistency. – ryang May 15 '23 at 04:19