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.

Practice Questions

Find the truth values of the following:

$2+3=5$ [ ]True [ ]False

$5\gt 6$ [ ]True [ ]False

$(2+3=5)\&\&(5\gt 6)$ [ ]True [ ]False

$(2+3=5)||(5\gt 6)$ [ ]True [ ]False

$(2+3=5)$ AND $(5\gt 6)$ [ ]True [ ]False

$(2+3=5)$ OR $(5\gt 6)$ [ ]True [ ]False

$!(2+3=5)$ [ ]True [ ]False

$(2+3=5)\&\&!(5\gt 6)$ [ ]True [ ]False

$!(2+3=5)\&\&(5\gt 6)$ [ ]True [ ]False

$(2+3=5\&\&5\gt 6)||3+3=6$ [ ]True [ ]False

$!!(2+3=5)$ [ ]True [ ]False

Check Answers

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

Ann's age is $\lt 25$. [ ]True [ ]False

Adam is male. [ ]True [ ]False

$!$ Adam is male. [ ]True [ ]False

Ali's income is $\gt \$20,000$. [ ]True [ ]False

Ann's age is $\lt 25$ AND Adam is male. [ ]True [ ]False

Ann's age is $\lt 25$ OR Adam is male. [ ]True [ ]False

(Adam is $18$ years old) $||$ (Adam's income is not $\$10,000$). [ ]True [ ]False

(Adam is $18$ years old) $\&\&$ (Ali is $18$ years old). [ ]True [ ]False

(Adam is $18$ years old) $\&\&$ (Ali is $70$ years old). [ ]True [ ]False

Ali's annual income is $\$50,000\; \&\&$ Ann is $10$ years old. [ ]True [ ]False

Ali's annual income is $\$50,000\; ||$ Ann is $10$ years old. [ ]True [ ]False

Ann is not $18$ years old $\&\&$ Ann is not female. [ ]True [ ]False

(Ali is at least $70$ years old) $\&\&\;\big{[}$Ann's age is $\lt 34\;||\;!$(Adam's income is $\gt \$20,000\big{]}$ [ ]True [ ]False

Check Answers

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