MAT2033 · Week 1 · propositional logic, predicates and quantifiers

Propositional logic, predicates and quantifiers

Connectives, truth tables, laws of logical equivalence, and translating and negating statements with ∀/∃. The first midterm question almost always comes from here.

propositionconnectiveconditionalbiconditionalexclusive ortruth tabletautologycontradictioncontingencylogical equivalenceDe Morgan's lawsconverseinversecontrapositivepredicatedomain of discourseuniversal quantifierexistential quantifiercounterexample

The language of discrete mathematics is logic. The symbols you learn this week will show up in every proof, every set question and every algorithm for the rest of the semester. The midterm questions on this topic are mechanical: build a truth table, show two statements are equivalent using the laws, translate an English sentence into symbols, negate a statement with quantifiers. There are few rules, but they have to be fully memorized.

Golden rules:

  1. p→qp \to q is false only when pp is true and qq is false. All three other rows are true.
  2. Never change the table order. With 3 variables, pp: TTTTFFFF, qq: TTFFTTFF, rr: TFTFTFTF.
  3. Use a single law in each step and write its name. The instructor gives marks for the names.
  4. “All” takes an arrow, “some” takes an and. ∀x (A→B)\forall x\,(A \to B), ∃x (A∧B)\exists x\,(A \land B).
  5. When negating, the quantifier flips: ∀↔∃\forall \leftrightarrow \exists, then negate the inside.

Propositions and connectives

Proposition: a declarative sentence that is either true (T) or false (F). “7 is prime” is a proposition (true). "2+2=52 + 2 = 5" is a proposition (false). “Close the door” and "x+1=3x + 1 = 3" are not propositions: the first is a command, and in the second you cannot say true or false until xx is known.

You combine propositions with connectives:

SymbolNameWhen is it true?
¬p\lnot pnegation (not)when pp is false
p∧qp \land qconjunction (and)when both are true
p∨qp \lor qdisjunction (or, inclusive)when at least one is true
p⊕qp \oplus qexclusive or (either … or …)when exactly one is true
p→qp \to qconditional (if … then)always, except p=T,q=Fp = T, q = F
p↔qp \leftrightarrow qbiconditional (if and only if)when both have the same value
ppqqp→qp \to qp↔qp \leftrightarrow qp⊕qp \oplus q
TTTTF
TFFFT
FTTFT
FFTTF

Why is the conditional defined this way?

p→qp \to q works like a promise. The instructor says “If you hand in the homework, I will give you 10 points.” The instructor has lied in only one case: you handed it in (p=Tp = T) and did not get the points (q=Fq = F). If you did not hand it in (p=Fp = F), the instructor has not broken the promise whatever they do, so the statement stays true. This is called “vacuously true”.

PITFALL · If pp is false, p→qp \to q is true. “From a false hypothesis anything follows.” The rows of the table where p=Fp = F are automatically T. Knowing this cuts the work in half.

Translation patterns

These are the patterns the exam likes; all of them are expressed with p→qp \to q:

EnglishSymbol
if pp, then qq / qq if pp / qq whenever ppp→qp \to q
pp only if qqp→qp \to q
pp is sufficient for qq / qq is necessary for ppp→qp \to q
qq unless pp¬p→q\lnot p \to q (that is, p∨qp \lor q)
pp if and only if qq / pp iff qqp↔qp \leftrightarrow q

“Only if” is the most confused pattern. “You can enter the exam only if you have an ID” = if you entered the exam, you definitely have an ID: “entered” →\to “has ID”. Having an ID does not guarantee entering.

Converse, inverse, contrapositive

For p→qp \to q there are three relatives:

  • converse: q→pq \to p
  • inverse: ¬p→¬q\lnot p \to \lnot q
  • contrapositive: ¬q→¬p\lnot q \to \lnot p

Only the contrapositive is equivalent to the original. The converse and the inverse are equivalent to each other, but not to the original. “If it rains, the ground gets wet” is true. The converse “if the ground is wet, it has rained” can be false (someone spilled water). The contrapositive “if the ground is dry, it has not rained” carries the same information as the original.

Building a truth table

Template:

  1. Count the variables: with nn variables there are 2n2^n rows.
  2. Fill the columns in the standard order (golden rule 2 above).
  3. Break the expression down from the inside out, with a helper column for each part.
  4. Look at the last column: all T means tautology, all F means contradiction, mixed means contingency.

Example. (p∧¬r)→(q∨r)(p \land \lnot r) \to (q \lor r)

ppqqrr¬r\lnot rp∧¬rp \land \lnot rq∨rq \lor rresult
TTTFFTT
TTFTTTT
TFTFFTT
TFFTTFF
FTTFFTT
FTFTFTT
FFTFFTT
FFFTFFT

The last column has one F and the rest T: contingency. Quick check: the arrow is F only when “left T, right F”. The rows where the left side is T (p=T,r=Fp=T, r=F) are only rows 2 and 4; among them, only row 4 has the right side F.

Logical equivalence

AA and BB are equivalent if they take the same value in every row: A≡BA \equiv B. In other words, A↔BA \leftrightarrow B is a tautology. You can show it in two ways: a truth table or a chain of laws.

LawFormula
Conditionalp→q≡¬p∨qp \to q \equiv \lnot p \lor q
De Morgan¬(p∧q)≡¬p∨¬q\lnot(p \land q) \equiv \lnot p \lor \lnot q, ¬(p∨q)≡¬p∧¬q\lnot(p \lor q) \equiv \lnot p \land \lnot q
Double negation¬¬p≡p\lnot\lnot p \equiv p
Distributivep∧(q∨r)≡(p∧q)∨(p∧r)p \land (q \lor r) \equiv (p \land q) \lor (p \land r), p∨(q∧r)≡(p∨q)∧(p∨r)p \lor (q \land r) \equiv (p \lor q) \land (p \lor r)
Negationp∨¬p≡Tp \lor \lnot p \equiv T, p∧¬p≡Fp \land \lnot p \equiv F
Identityp∧T≡pp \land T \equiv p, p∨F≡pp \lor F \equiv p
Dominationp∨T≡Tp \lor T \equiv T, p∧F≡Fp \land F \equiv F
Idempotentp∨p≡pp \lor p \equiv p, p∧p≡pp \land p \equiv p
Commutative, associativep∨q≡q∨pp \lor q \equiv q \lor p, (p∨q)∨r≡p∨(q∨r)(p \lor q) \lor r \equiv p \lor (q \lor r)
Absorptionp∨(p∧q)≡pp \lor (p \land q) \equiv p, p∧(p∨q)≡pp \land (p \lor q) \equiv p
Biconditionalp↔q≡(p→q)∧(q→p)p \leftrightarrow q \equiv (p \to q) \land (q \to p)

Chain strategy: first turn the arrows into ∨\lor with the conditional law, then push the ¬\lnot in front of parentheses inward with De Morgan, delete the ¬¬\lnot\lnot, and finally distribute and simplify.

Example 1. Show that (p→q)∨(p→r)≡p→(q∨r)(p \to q) \lor (p \to r) \equiv p \to (q \lor r).

(p → q) ∨ (p → r)
≡ (¬p ∨ q) ∨ (¬p ∨ r)        conditional law (twice)
≡ (¬p ∨ ¬p) ∨ (q ∨ r)        commutative and associative laws
≡ ¬p ∨ (q ∨ r)               idempotent law
≡ p → (q ∨ r)                conditional law   ∎

Example 2. Show that ¬(p∨¬q)∨(¬p∧¬q)≡¬p\lnot(p \lor \lnot q) \lor (\lnot p \land \lnot q) \equiv \lnot p.

¬(p ∨ ¬q) ∨ (¬p ∧ ¬q)
≡ (¬p ∧ ¬¬q) ∨ (¬p ∧ ¬q)     De Morgan's law
≡ (¬p ∧ q) ∨ (¬p ∧ ¬q)       double negation law
≡ ¬p ∧ (q ∨ ¬q)              distributive law (common ¬p factored out)
≡ ¬p ∧ T                     negation law
≡ ¬p                         identity law   ∎

TIP · Don’t build a table to show NOT equivalent. Find a single row where the two sides differ. The sentence “For p=F,q=Tp = F, q = T the left side is T and the right side is F” earns full marks.

Predicates and quantifiers

"x>3x > 3" is not a proposition, because xx is not known. This is called a predicate: P(x)P(x). Once you give xx a value it becomes a proposition: P(5)P(5) is true, P(1)P(1) is false. The set of values xx can take is called the domain (domain of discourse). Without a domain, the truth of a quantified statement cannot be determined.

StatementMeaningWhen is it true?When is it false?
∀x P(x)\forall x\, P(x)P(x)P(x) for every xxif every element of the domain satisfies itif there is a single counterexample
∃x P(x)\exists x\, P(x)P(x)P(x) for at least one xxif there is a single exampleif no element satisfies it

Over a finite domain, quantifiers are big “and”s and “or”s. If the domain is {1,2,3}\{1, 2, 3\}, then ∀x P(x)≡P(1)∧P(2)∧P(3)\forall x\,P(x) \equiv P(1) \land P(2) \land P(3) and ∃x P(x)≡P(1)∨P(2)∨P(3)\exists x\,P(x) \equiv P(1) \lor P(2) \lor P(3). That is why negating a quantifier is exactly De Morgan:

¬∀x P(x)≡∃x ¬P(x)¬∃x P(x)≡∀x ¬P(x)\lnot \forall x\, P(x) \equiv \exists x\, \lnot P(x) \qquad \lnot \exists x\, P(x) \equiv \forall x\, \lnot P(x)

If “Everyone passed” is false, it means “there is someone who did not pass”. It does not mean “nobody passed”.

Effect of the domain: ∃x (2x=1)\exists x\,(2x = 1) is true over the reals (x=12x = \tfrac12) and false over the integers. Quantifiers bind before all connectives except ¬\lnot: ∀x P(x)∧Q(x)\forall x\, P(x) \land Q(x) means (∀x P(x))∧Q(x)(\forall x\, P(x)) \land Q(x).

Translation: arrow or and?

The domain is all people, A(x)A(x): ”xx is an athlete”, S(x)S(x): ”xx is a student”.

SentenceCorrectWrong (why)
All athletes are students.∀x (A(x)→S(x))\forall x\,(A(x) \to S(x))∀x (A(x)∧S(x))\forall x\,(A(x) \land S(x)): says “everyone is an athlete and a student”
Some athletes are students.∃x (A(x)∧S(x))\exists x\,(A(x) \land S(x))∃x (A(x)→S(x))\exists x\,(A(x) \to S(x)): becomes automatically true because of someone who is not an athlete
No athlete is a student.∀x (A(x)→¬S(x))\forall x\,(A(x) \to \lnot S(x))
Not all athletes are students.∃x (A(x)∧¬S(x))\exists x\,(A(x) \land \lnot S(x))

The trap in the second row comes from the vacuous truth of the conditional: a single person in the domain who is not an athlete makes A(x)→S(x)A(x) \to S(x) true, and the sentence says nothing.

Worked example: negation

“Every student who studies passes.” S(x)S(x): studies, P(x)P(x): passes.

∀x (S(x) → P(x))                    original
¬∀x (S(x) → P(x))                   negate
≡ ∃x ¬(S(x) → P(x))                 the quantifier flips
≡ ∃x (S(x) ∧ ¬P(x))                 ¬(a → b) ≡ a ∧ ¬b

In English: “There is a student who studies but does not pass.” Don’t leave the negation as “Not every student who studies passes”; the question usually asks for “no negation in front of a quantifier”.

Common mistakes

Wrong ideaThe truth
If pp is false, p→qp \to q is falseIt is true. The arrow is false only for T→FT \to F
”pp only if qq” = q→pq \to pp→qp \to q
”qq unless pp” = p→qp \to q¬p→q\lnot p \to q
The converse is equivalent to the originalOnly the contrapositive is equivalent
¬(p∧q)≡¬p∧¬q\lnot(p \land q) \equiv \lnot p \land \lnot q¬p∨¬q\lnot p \lor \lnot q; ∧\land and ∨\lor swap
¬∀x P(x)≡∀x ¬P(x)\lnot \forall x\,P(x) \equiv \forall x\,\lnot P(x)∃x ¬P(x)\exists x\,\lnot P(x); the quantifier flips too
“Some A are B” = ∃x (A→B)\exists x\,(A \to B)∃x (A∧B)\exists x\,(A \land B)
“All A are B” = ∀x (A∧B)\forall x\,(A \land B)∀x (A→B)\forall x\,(A \to B)
I tried a few examples, so ∀\forall is true∀\forall cannot be proved by examples; but a single counterexample breaks it
Answering without looking at the domainThe same statement can be true in R\mathbb{R} and false in Z\mathbb{Z}

Test yourself

Exam-style questions. Solve them on paper first, then reveal the answer.

Question 1easy

Let pp be true, qq be false and rr be true. Find the truth value of (p∨q)→(¬r∧q)(p \lor q) \to (\lnot r \land q).

Show answer
False

Left side: p∨q=T∨F=Tp \lor q = T \lor F = T. Right side: ¬r∧q=F∧F=F\lnot r \land q = F \land F = F. The arrow is false only for T→FT \to F: T→F=FT \to F = F.

Question 2easy

Let gg: "you can use the gym", ss: "you are a student", tt: "you are staff". Write in symbols: "You can use the gym only if you are a student or staff."

Show answer
g→(s∨t)g \to (s \lor t)

The pattern "p only if q" means p→qp \to q: if you use the gym, you are definitely a student or staff. The conclusion is s∨ts \lor t. Writing the reverse direction ((s∨t)→g(s \lor t) \to g) is the classic mistake.

Question 3easy

Write the converse and the contrapositive of: "If nn is divisible by 6, then nn is even." Which of the two is always equivalent to the original?

Show answer
Converse: if n is even, then n is divisible by 6. Contrapositive: if n is not even, then n is not divisible by 6. The contrapositive.

pp: "6 divides n", qq: "n is even". The converse is q→pq \to p (the direction flips). The contrapositive is ¬q→¬p\lnot q \to \lnot p (the direction flips and both parts are negated). Only the contrapositive is equivalent to the original. Here the converse is even false: n=4n = 4 is even but not divisible by 6.

Question 4medium

Construct the truth table of (p→q)→(q→p)(p \to q) \to (q \to p). Is it a tautology, a contradiction or a contingency?

Show answer
Contingency (false only when p = F, q = T)

The rows are TT, TF, FT, FF. p→qp \to q: T, F, T, T. q→pq \to p: T, T, F, T. Outer arrow: T→T=TT\to T = T, F→T=TF \to T = T, T→F=FT \to F = F, T→T=TT \to T = T. The last column is TTFT: it has both T and F, so it is a contingency.

Question 5medium

In how many rows of its truth table is (p⊕q)∧(q∨r)(p \oplus q) \land (q \lor r) true?

Show answer
3

There are 8 rows. p⊕qp \oplus q is T only when pp and qq differ: the rows TF* and FT* (4 rows). Among these, the ones where q∨rq \lor r is also T are TFT (r=Tr=T), FTT, FTF (q=Tq=T). In row TFF, q∨r=Fq \lor r = F. Total: 3 rows.

Question 6medium

Using the laws of logic (name each law), show that ¬(p→q)→p\lnot(p \to q) \to p is a tautology.

Show answer
It is equivalent to T, so it is a tautology.

¬(p→q)→p≡¬¬(p→q)∨p\lnot(p\to q) \to p \equiv \lnot\lnot(p \to q) \lor p (conditional law)≡(p→q)∨p\equiv (p \to q) \lor p (double negation)≡(¬p∨q)∨p\equiv (\lnot p \lor q) \lor p (conditional law)≡(p∨¬p)∨q\equiv (p \lor \lnot p) \lor q (commutative + associative)≡T∨q\equiv T \lor q (negation law)≡T\equiv T (domination law). One law per step, with its name.

Question 7hard

Are p→(q→r)p \to (q \to r) and (p→q)→r(p \to q) \to r logically equivalent? Justify.

Show answer
No. For p = F, q = F, r = F the first is T and the second is F.

A single row is enough to show they are not equivalent. When p=Fp = F, p→(q→r)p \to (q \to r) is automatically T. On the other side p→q=Tp \to q = T; if we choose r=Fr = F then (p→q)→r=T→F=F(p\to q) \to r = T \to F = F. The values differ, so they are not equivalent. (Check: the rows where they differ are FTF and FFF.)

Question 8easy

Let Q(x)Q(x) be "x2−5x+6=0x^2 - 5x + 6 = 0", the domain being all integers. Find the truth values of ∃x Q(x)\exists x\, Q(x) and ∀x Q(x)\forall x\, Q(x).

Show answer
∃x Q(x) is true, ∀x Q(x) is false

x2−5x+6=(x−2)(x−3)x^2 - 5x + 6 = (x-2)(x-3). x=2x = 2 satisfies it, so ∃x Q(x)\exists x\,Q(x) is true (one example is enough). For ∀\forall a single counterexample is enough: for x=0x = 0, 6≠06 \ne 0, so it is false.

Question 9medium

The domain is {1,2,3,4}\{1, 2, 3, 4\}. Determine the truth values of (a) ∀x (x is odd→x2<10)\forall x\,(x \text{ is odd} \to x^2 < 10) and (b) ∃x (x is even∧x2>15)\exists x\,(x \text{ is even} \land x^2 > 15).

Show answer
(a) true, (b) true

(a) It is enough to look at the odd values (for even values the arrow is automatically T): 12=1<101^2 = 1 < 10, 32=9<103^2 = 9 < 10. All hold, so it is true.
(b) We need one even number whose square is greater than 15: x=4x = 4, 16>1516 > 15. True.

Question 10medium

Let M(x)M(x): "xx misses practice" and B(x)B(x): "xx is benched", the domain being the players of a team. Express "Every player who misses practice is benched" in logic, then write its negation with no negation sign in front of a quantifier, and say it in English.

Show answer
∀x (M(x) → B(x)); negation: ∃x (M(x) ∧ ¬B(x)), "Some player misses practice but is not benched."

The pattern "Every ... who ..." needs ∀\forall and an arrow: ∀x (M(x)→B(x))\forall x\,(M(x) \to B(x)). Negation: ¬∀x (… )≡∃x ¬(M(x)→B(x))\lnot\forall x\,(\dots) \equiv \exists x\,\lnot(M(x)\to B(x)), then ¬(a→b)≡a∧¬b\lnot(a \to b) \equiv a \land \lnot b. The result is ∃x (M(x)∧¬B(x))\exists x\,(M(x) \land \lnot B(x)).

Question 11hard

Let S(x)S(x): "xx is a student" and L(x)L(x): "xx is lazy", the domain being all people. Express "No student is lazy" in two equivalent ways, one using ∀\forall and one using ∃\exists.

Show answer
∀x (S(x) → ¬L(x)) and ¬∃x (S(x) ∧ L(x))

"No student is lazy" = "there is no lazy student": ¬∃x (S(x)∧L(x))\lnot\exists x\,(S(x) \land L(x)). Pushing the negation inside gives ∀x ¬(S(x)∧L(x))≡∀x (¬S(x)∨¬L(x))≡∀x (S(x)→¬L(x))\forall x\,\lnot(S(x)\land L(x)) \equiv \forall x\,(\lnot S(x) \lor \lnot L(x)) \equiv \forall x\,(S(x) \to \lnot L(x)). Both say the same thing.

Question 12hard

Determine the truth value of ∀x (x2≥x)\forall x\,(x^2 \ge x) when the domain is (a) all real numbers, (b) all integers.

Show answer
(a) false, (b) true

(a) Counterexample x=12x = \tfrac12: 14≥12\tfrac14 \ge \tfrac12 is false. One example breaks ∀\forall.
(b) x2−x=x(x−1)x^2 - x = x(x-1). Over the integers, if x≤0x \le 0 both factors are ≤0\le 0, and if x≥1x \ge 1 both are ≥0\ge 0; the product is always ≥0\ge 0. True. Same sentence, different domain, different answer.

Verification: All truth tables, equivalences and quantifier truth values were checked by brute force with node (all rows / finite domain and a scan over -1000..1000) (verify/MAT2033/01.mjs).

Review card

p→q is F only for T→F. p↔q is T if they are the same. p⊕q is T if they differ. p→q ≡ ¬p∨q ¬(p→q) ≡ p∧¬q p↔q ≡ (p→q)∧(q→p) De Morgan: ¬(p∧q) ≡ ¬p∨¬q ¬(p∨q) ≡ ¬p∧¬q "p only if q" = p→q "q if p" = p→q "q unless p" = ¬p→q "p sufficient for q" = p→q "q necessary for p" = p→q converse q→p, inverse ¬p→¬q, contrapositive ¬q→¬p (only this one is equivalent) n variables → 2^n rows; p: TTTTFFFF, q: TTFFTTFF, r: TFTFTFTF all T tautology, all F contradiction, mixed contingency To show not equivalent: ONE row with different values is enough ∀: one counterexample makes it false. ∃: one example makes it true. ¬∀x P(x) ≡ ∃x ¬P(x) ¬∃x P(x) ≡ ∀x ¬P(x) "All A are B" = ∀x (A(x)→B(x)) "Some A are B" = ∃x (A(x)∧B(x)) Change the domain, change the answer: ∃x(2x=1) is T in R, F in Z