Precedence (what happens first)

In arithmetic, multiplication has precedence over addition, meaning that multiplications are done before additions. This, and other rules, mean that people and computers interpret mathematical expressions consistently. Logic also has rules so that logical expressions are interpreted consistently.

Simple conditions can be combined using several of the operators AND, OR and NOT to form more complicated conditions. There are conventions about how these more complicated conditions are interpreted.

In arithmetic brackets can be used to show the order in which calculations are to be done. Anything in brackets is evaluated before anything else. In an expression with $\times$ and $+$, if there are no brackets to specify order, $\times$ is done before $+$ as multiplication has precedence over addition. That is, all multiplications are done before additions. So $2+3\times 4$ is evaluated by doing the multiplication first and then the addition:
$$2+3\times 4 = 2+12 = 14.$$
However $(2+3)\times 4 = 5\times 4 = 20$.

Much the same is true in logic:
$$\boxed{\text{Evaluate expressions in brackets first.}}$$ NOT has precedence over AND and OR, so unless brackets indicate otherwise
$$\boxed{\text{NOT is done before AND, OR.}}$$

For example, when finding the truth value of NOT $a$ AND NOT $b$, evaluate NOT $a$, evaluate NOT $b$; only then consider AND.

If in doubt, use brackets to show how an expression is to be evaluated.

Beware: Some programming languages have extra precedence rules or conventions. It is best to use brackets when mixing AND and OR in an expressions as conventions here do vary.

Examples

We begin with a note on notation. "NOT $4\gt 5$" only makes sense if it read as "NOT$(4\gt 5)$". If we read it as "(NOT $4)\gt 5$" or (NOT $4\gt ) 5$" it makes no sense. So it is acceptable to write "NOT $4\gt 5$" as this is not ambiguous.

  • Find the truth value of NOT $4\gt 5$ AND NOT $1=1$.
    Answer: NOT $\underbrace{4\gt 5}_{F}$ ANF NOT $\underbrace{1=1}_{T}$ becomes $\underbrace{\text{NOT F}}_{T}$ AND $\underbrace{\text{NOT T}}_{F}$ which is T AND F. This is F.
  • Evaluate $!(1+2=5||!1=1)$.
    Answer: We must begin with the part of the expression in brackets. $!(\underbrace{1+2=5}_{F}||!\underbrace{1=1}_{T})$. We have !(F||!T); this is !(F||F), which is !F. This is T.
  • Evaluate $11\lt 12\&\& (1+2=5||!1=1)$. Here brackets have been used to show what we must evaluate first.
    Answer:  $11\lt 12\&\& \underbrace{(1+2=5||!1=1)}_{\text{Evaluate this first}}$. The expression in brackets is $(\underbrace{1+2=5}_{F}||!\underbrace{1=1}_{T})$ which is F||F which is F.
    The original expression is $\underbrace{11\lt 12}_{T}\&\&\underbrace{(1+2=5||!1=1)}_{F}$, which is T&&F, which is F.
Practice Questions
Find the truth values of the following:
$2+3=5$
$5\gt 6$
$(2+3=5)\&\&(5\gt 6)$
$(2+3=5)||(5\gt 6)$
$(2+3=5)$ AND $(5\gt 6)$
$(2+3=5)$ OR $(5\gt 6)$
$!(2+3=5)$
$(2+3=5)\&\&!(5\gt 6)$
$!(2+3=5)\&\&(5\gt 6)$
$(2+3=5\&\&5\gt 6)||3+3=6$
$!!(2+3=5)$

Based on the information given decide whether each part is true or false.

  • Ann is $34$ years old, female and her annual income is$\$100,000$.
  • Adam is $18$ years old, male and his annual income is $\$10,000$.
  • Ali is $70$ years old, male and his annual income is $\$30,000$.
Ann's age is $\lt 25$.
Adam is male.
$!$ Adam is male.
Ali's income is $\gt \$20,000$.
Ann's age is $\lt 25$ AND Adam is male.
Ann's age is $\lt 25$ OR Adam is male.
(Adam is $18$ years old) $||$ (Adam's income is not $\$10,000$).
(Adam is $18$ years old) $\&\&$ (Ali is $18$ years old).
(Adam is $18$ years old) $\&\&$ (Ali is $70$ years old).
Ali's annual income is $\$50,000\; \&\&$ Ann is $10$ years old.
Ali's annual income is $\$50,000\; ||$ Ann is $10$ years old.
Ann is not $18$ years old $\&\&$ Ann is not female.
(Ali is at least $70$ years old) $\&\&\;\big{[}$Ann's age is $\lt 34\;||\;!$(Adam's income is $\gt \$20,000\big{]}$

Want some more help on this topic? Take a look at this page.