M384 · Logic · Week 7

Classical Propositional Logic: Formulas and Truth

Monday: the language of propositional logic, translation between English and formulas, recursive definitions and structural induction. Wednesday: valuations, the truth value of a formula, truth tables, tautologies.

Goals for this week

By the end of this week you will be able to:

Day 1 (Monday, October 5): The language of propositional logic

Today we define the formulas of propositional logic, practice translating between English and formulas, and use the recursive structure of formulas to define functions and to prove facts about all formulas.

What we are using from before
  • In the languages \(\mathcal A\), \(\mathcal S\) and \(\mathcal S^{\dagger}\) every sentence had one fixed shape, such as All \(p\) are \(q\). There was no way to join two sentences with "and", "or" or "if ... then", and no way to negate a sentence.
  • A proof by induction on proof trees shows a property for every tree: it holds for the leaves, and every rule turns trees with the property into a tree with the property.
  • Induction on \(\mathbb N=\{0,1,2,\dots\}\): if \(P(0)\) holds, and \(P(n)\) implies \(P(n+1)\) for every \(n\), then \(P(n)\) holds for every \(n\).

1. Formulas

In arithmetic, \(2+2=4\) and \(3\cdot5>20\) are well-formed expressions: the first is true, the second is false, but both are allowed. The string \(2+\div3=5\) is not allowed at all; it is not true and not false, it just does not parse. Before we can ask whether a statement of logic is true, we need the same kind of precision: an exact rule that says which strings of symbols count as formulas.

Propositional logic studies the words not, and, or and if ... then used between whole statements. The simplest statements are left unanalyzed: we only give them names.

Definition 7.1: primitive propositions and connectives

We fix a countable set \(\mathrm{PROP}\) of primitive propositions (also called atomic propositions). We use the letters \(p,q,r,s\), possibly with subscripts, for them.

The connectives are four symbols:

symbolnameread askind
\(\neg\)negationnotunary
\(\wedge\)conjunctionandbinary
\(\vee\)disjunctionorbinary
\(\to\)implicationif ... thenbinary

A unary connective acts on one formula, a binary connective joins two formulas.

Definition 7.2: formulas

The formulas of propositional logic are defined by the following clauses.

  1. Every primitive proposition \(p\in\mathrm{PROP}\) is a formula.
  2. If \(\varphi\) is a formula, then \(\neg\varphi\) is a formula.
  3. If \(\varphi\) and \(\psi\) are formulas, then \((\varphi\wedge\psi)\), \((\varphi\vee\psi)\) and \((\varphi\to\psi)\) are formulas.
  4. Nothing else is a formula: every formula is obtained from primitive propositions by finitely many applications of clauses 2 and 3.

We write \(\mathcal L(\neg,\wedge,\vee,\to)\) for the set of all formulas. The same definition is often written in one line:

\[\varphi\ ::=\ p\ \mid\ \neg\varphi\ \mid\ (\varphi\wedge\varphi)\ \mid\ (\varphi\vee\varphi)\ \mid\ (\varphi\to\varphi)\qquad (p\in\mathrm{PROP}).\]

Read it from left to right: a formula is either a primitive proposition, or the negation of a formula, or the conjunction of two formulas, or the disjunction of two formulas, or an implication from one formula to another.

The Greek letters are not formulas

The letters \(\varphi,\psi,\chi\) are not symbols of the language. They are variables that we use to talk about formulas: "\(\neg\varphi\) is a formula" means that for every formula, putting \(\neg\) in front of it gives a formula. The language we study is the object language; the English and mathematics we use to talk about it is the metalanguage. The same distinction appeared in Week 5, where \(\overline\varphi\) was our name for a sentence and not a symbol of \(\mathcal S^{\dagger}\).

Example 7.3: building a formula step by step

We show that \(((p\wedge q)\to r)\vee\neg q\) is a formula by building it with the clauses of Definition 7.2.

  1. \(p\), \(q\) and \(r\) are formulas, by clause 1.
  2. \((p\wedge q)\) is a formula, by clause 3 applied to \(p\) and \(q\).
  3. \(((p\wedge q)\to r)\) is a formula, by clause 3 applied to \((p\wedge q)\) and \(r\).
  4. \(\neg q\) is a formula, by clause 2 applied to \(q\).
  5. \((((p\wedge q)\to r)\vee\neg q)\) is a formula, by clause 3 applied to the formulas of steps 3 and 4.

The last formula is written with one pair of parentheses fewer at the outside; Convention 7.5 below allows this. Figure 1 shows the same construction as a tree, read from the bottom up.

p q p∧q r (p∧q)→r q ¬q ((p∧q)→r)∨¬q
Figure 1. The parse tree of \(((p\wedge q)\to r)\vee\neg q\). Every node is a formula. A node with two children was built with a binary connective, a node with one child with \(\neg\), and the leaves are primitive propositions.
Definition 7.4: parse tree, main connective, immediate subformulas

Every formula has exactly one construction from primitive propositions. (This fact is called unique readability. We use it without proof; the parentheses in clause 3 are what make it true.) The construction drawn as a tree, with the formula at the root, is the parse tree of the formula.

The connective introduced in the last step of the construction is the main connective. The formulas it was applied to are the immediate subformulas.

  • \(\neg\varphi\) has main connective \(\neg\) and one immediate subformula, \(\varphi\).
  • \(\varphi\wedge\psi\), \(\varphi\vee\psi\), \(\varphi\to\psi\) have main connective \(\wedge\), \(\vee\), \(\to\) and two immediate subformulas, \(\varphi\) and \(\psi\).
  • A primitive proposition has no main connective.

For instance, the main connective of the formula of Figure 1 is \(\vee\), and its immediate subformulas are \((p\wedge q)\to r\) and \(\neg q\).

Convention 7.5: dropping parentheses

Officially every binary connective comes with a pair of parentheses. To make formulas easier to read we allow exactly two simplifications.

  1. The outermost pair of parentheses may be dropped: we write \(p\wedge q\) for \((p\wedge q)\).
  2. Negation takes the narrowest scope: \(\neg p\vee q\) means \((\neg p)\vee q\), never \(\neg(p\vee q)\).

No other parentheses may be dropped. In particular \(p\wedge q\to r\) is not a formula: it could mean \((p\wedge q)\to r\) or \(p\wedge(q\to r)\), and these are different formulas (Figure 2). Also \(p\wedge q\wedge r\) is not a formula; write \((p\wedge q)\wedge r\) or \(p\wedge(q\wedge r)\).

p q p∧q r (p∧q)→r (a) main connective → p q r q→r p∧(q→r) (b) main connective ∧
Figure 2. The two formulas that the string \(p\wedge q\to r\) could stand for. They have the same symbols in the same order, but different constructions, so they are different formulas.
Example 7.6: formula or not?

We use Definition 7.2 together with Convention 7.5.

  1. \(\neg\neg p\to p\). A formula. Negation has narrow scope, so the two negations apply only to the first \(p\): the string means \((\neg\neg p)\to p\). The main connective is \(\to\).
  2. \(p\,\neg\!\wedge q\). Not a formula. The clauses never put \(\neg\) between a formula and a binary connective.
  3. \((p\to q)\vee\neg(r\wedge p)\). A formula with main connective \(\vee\). Its immediate subformulas are \(p\to q\) and \(\neg(r\wedge p)\).
  4. \(p\vee q\wedge r\). Not a formula: two binary connectives without parentheses to group them.
  5. \(\neg(p\to(q\to p))\). A formula. Here the parentheses after \(\neg\) are needed, so the negation applies to the whole implication, and the main connective is \(\neg\).
  6. \((p\wedge q))\). Not a formula. In every formula the left and right parentheses come in matching pairs, because clause 3 adds them in pairs; this string has one more right parenthesis than left ones.

A practical test for the main connective: it is the one connective that is not inside any pair of parentheses. If there is none outside all parentheses and the formula starts with \(\neg\), the main connective is that \(\neg\).

Exercise 1: formula or not, and the main connective

Self-check only. Nothing here counts towards your grade.

For each string decide whether it is a formula (with Convention 7.5). If it is, choose its main connective.

  1. \(\neg(p\vee q)\to r\): main connective \(\to\). The negation applies to \((p\vee q)\), and the implication joins \(\neg(p\vee q)\) and \(r\).
  2. \(p\to\neg\neg q\): main connective \(\to\).
  3. \(\neg p\wedge(q\vee r)\): main connective \(\wedge\). By narrow scope the negation applies only to \(p\).
  4. \((p\vee\neg)\wedge q\): not a formula. \(\neg\) must be followed by a formula.
  5. \(p\to q\to r\): not a formula. Two binary connectives need parentheses to group them.
  6. \(\neg(\neg p\wedge\neg q)\): main connective \(\neg\). Every other connective is inside the parentheses.

2. From English to formulas, and back

Propositional logic does not look inside simple statements. "It is raining" and "I take my umbrella" are treated as units, and only the way they are joined matters. To translate, we first decide which simple statements we need and give them names.

Definition 7.7: dictionary

A dictionary assigns to some primitive propositions a simple English statement. A translation of an English sentence is a formula built from these primitive propositions whose structure matches the logical structure of the sentence.

Each entry of a dictionary should be a complete, positive statement without "not", "and", "or" or "if". The negative and compound sentences are then built with the connectives. For instance:

letterstatement
\(r\)It is raining.
\(c\)It is cold.
\(u\)I take my umbrella.
\(w\)I walk to campus.

We use this dictionary until the end of Section 2.

English has more ways to say "if" than the four connectives suggest. One more connective is useful for translation. It is not a new symbol of the language; it is a shorthand.

Definition 7.8: the biconditional

We write \(\varphi\leftrightarrow\psi\) as an abbreviation for \((\varphi\to\psi)\wedge(\psi\to\varphi)\), and read it "\(\varphi\) if and only if \(\psi\)". For instance \(w\leftrightarrow\neg r\) is short for \((w\to\neg r)\wedge(\neg r\to w)\).

The table lists the most common English patterns. Here \(A\) and \(B\) stand for the translations of the parts.

Englishformula
not \(A\); it is not the case that \(A\)\(\neg A\)
\(A\) and \(B\); \(A\) but \(B\); \(A\) although \(B\); both \(A\) and \(B\)\(A\wedge B\)
\(A\) or \(B\); either \(A\) or \(B\)\(A\vee B\)
if \(A\) then \(B\); \(B\) if \(A\); \(A\) only if \(B\); \(B\) provided that \(A\)\(A\to B\)
\(A\) is sufficient for \(B\); \(B\) is necessary for \(A\)\(A\to B\)
\(A\) unless \(B\)\(\neg B\to A\)
neither \(A\) nor \(B\)\(\neg A\wedge\neg B\)
not both \(A\) and \(B\)\(\neg(A\wedge B)\)
\(A\) if and only if \(B\)\(A\leftrightarrow B\)
either \(A\) or \(B\), but not both\((A\vee B)\wedge\neg(A\wedge B)\)
Several rows have more than one correct formula. For instance "neither \(A\) nor \(B\)" can also be written \(\neg(A\vee B)\). Tomorrow we will be able to check that such formulas always have the same truth value.
Method 7.9: how to translate a sentence
  1. Find the simple statements and look them up in the dictionary.
  2. Find the main connective of the English sentence: the word that joins its two largest parts, or the "not" that applies to the whole sentence.
  3. Translate each part in the same way, and put parentheses around every part that has a binary connective.
  4. Read your formula back in plain English and compare it with the original sentence.
Example 7.10: eight translations

Dictionary of Definition 7.7.

  1. It is raining but it is not cold. "But" joins the two parts, and logic only keeps the "and": \(r\wedge\neg c\).
  2. If it is raining, I take my umbrella. \(r\to u\).
  3. I take my umbrella only if it is raining. This says: whenever I take my umbrella, it is raining. So \(u\to r\). Compare with sentence 2, which is \(r\to u\).
  4. I take my umbrella if it is raining. "\(B\) if \(A\)" is "if \(A\) then \(B\)": \(r\to u\), the same as sentence 2.
  5. I walk to campus unless it is raining. If it is not raining, I walk: \(\neg r\to w\).
  6. It is neither raining nor cold. \(\neg r\wedge\neg c\).
  7. It is not both raining and cold. The "not" applies to the conjunction: \(\neg(r\wedge c)\). This is weaker than sentence 6: it allows rain without cold.
  8. If it is cold and raining, then I take my umbrella and I do not walk to campus. The main connective is "if ... then". The antecedent is \(c\wedge r\), the consequent is \(u\wedge\neg w\). Both need parentheses: \((c\wedge r)\to(u\wedge\neg w)\).
Three patterns that are often translated the wrong way
  • Only if. "\(A\) only if \(B\)" is \(A\to B\), not \(B\to A\). "You pass only if you take the exam" does not say that taking the exam makes you pass. It says that passing requires taking the exam.
  • Unless. "\(A\) unless \(B\)" is \(\neg B\to A\). The formula \(A\vee B\) is another correct translation; it always has the same truth value. The formula \(B\to\neg A\) is not a correct translation: "I walk unless it is raining" does not tell us what I do when it rains.
  • Or. In logic \(\vee\) is inclusive: \(A\vee B\) allows both. When the sentence explicitly excludes both ("but not both", "exactly one of"), write the exclusion out as in the last row of the table.

Words like "but", "although" and "yet" express contrast or surprise. A translation keeps only the "and"; the contrast is lost, and this is intended.

Example 7.11: necessary and sufficient conditions in mathematics

Fix a natural number \(n\) and use the dictionary \(e\): \(n\) is even, \(f\): \(n\) is divisible by \(4\), \(t\): \(n\) is prime.

  1. Being divisible by 4 is sufficient for being even. \(f\to e\).
  2. Being even is necessary for being divisible by 4. Again \(f\to e\): a necessary condition is the consequent.
  3. \(n\) is divisible by 4 only if \(n\) is even. Once more \(f\to e\). Sentences 1 to 3 are three ways to say the same thing.
  4. If \(n\) is even and prime, then \(n\) is not divisible by 4. \((e\wedge t)\to\neg f\).
  5. \(n\) is even if and only if \(n\) is divisible by 4. \(e\leftrightarrow f\). This one is false for \(n=6\); translation does not care whether a sentence is true.
Example 7.12: one sentence, two formulas

It is raining and it is cold or I take my umbrella.

The English sentence does not say how to group its parts, and there are two candidates:

  • \((r\wedge c)\vee u\): either it is raining and cold, or I take my umbrella. This is satisfied on a sunny day on which I happen to take my umbrella.
  • \(r\wedge(c\vee u)\): it is raining, and it is cold or I take my umbrella. On a sunny day this is not satisfied, whatever I take.

Spoken English uses pauses and word order to separate the two readings ("either it is raining and cold, or ..."; "it is raining, and either ..."). A formula has to choose one, and the parentheses record the choice. When a sentence is ambiguous, say which reading you translate.

Example 7.13: from formulas to English

Same dictionary. For the way back, read the main connective first, then fill in the parts.

  1. \((r\vee c)\to\neg w\): If it is raining or cold, I do not walk to campus.
  2. \(\neg(w\wedge\neg u)\): It is not the case that I walk to campus without my umbrella. A smoother version: I do not walk to campus without my umbrella.
  3. \(w\to(u\vee\neg r)\): If I walk to campus, then I take my umbrella or it is not raining.
  4. \(\neg r\to\neg u\): If it is not raining, I do not take my umbrella. Equivalently: I take my umbrella only if it is raining. Compare sentence 3 of Example 7.10.
Exercise 2: translate into propositional logic

Self-check only. Nothing here counts towards your grade.

Dictionary: \(a\): Alice comes to the party. \(b\): Bob comes to the party. \(m\): There is music. \(d\): We dance.

Type a formula for each sentence. You can use the buttons, or type ~ for \(\neg\), & for \(\wedge\), | for \(\vee\), -> for \(\to\) and <-> for \(\leftrightarrow\). Follow Convention 7.5: put parentheses around every part that has a binary connective. Any correct translation is accepted, not only one stored answer.

  1. \(a\wedge\neg b\).
  2. \(d\to m\). "We dance only if there is music": dancing requires music.
  3. \(m\to(\neg b\to d)\). The main connective is the first "if". Inside, "we dance unless Bob comes" is \(\neg b\to d\). The formula \(m\to(b\vee d)\) is also correct.
  4. \(\neg a\wedge\neg b\), or \(\neg(a\vee b)\).
  5. \(b\to a\). "\(A\) if \(B\)" is \(B\to A\).
  6. \(\neg(a\wedge b)\).
  7. \((a\vee b)\wedge\neg(a\wedge b)\). One more correct answer is \((a\wedge\neg b)\vee(\neg a\wedge b)\).

3. Recursive definitions and structural induction

Formulas are built from primitive propositions by the connectives, in finitely many steps. So to define a function on all formulas it is enough to say what it does on primitive propositions, and how its value on a compound formula is obtained from its values on the immediate subformulas. Below, \(\bullet\) stands for any binary connective \(\wedge\), \(\vee\) or \(\to\).

Definition 7.14: length, number of connectives, rank \[\begin{aligned} \mathit{length}(p)&=1\\ \mathit{length}(\neg\varphi)&=\mathit{length}(\varphi)+1\\ \mathit{length}(\varphi\bullet\psi)&=\mathit{length}(\varphi)+\mathit{length}(\psi)+1 \end{aligned}\] \[\begin{aligned} \mathit{conn}(p)&=0\\ \mathit{conn}(\neg\varphi)&=\mathit{conn}(\varphi)+1\\ \mathit{conn}(\varphi\bullet\psi)&=\mathit{conn}(\varphi)+\mathit{conn}(\psi)+1 \end{aligned}\] \[\begin{aligned} \mathit{rank}(p)&=0\\ \mathit{rank}(\neg\varphi)&=\mathit{rank}(\varphi)+1\\ \mathit{rank}(\varphi\bullet\psi)&=\max\{\mathit{rank}(\varphi),\mathit{rank}(\psi)\}+1 \end{aligned}\]

\(\mathit{length}(\varphi)\) counts the symbols of \(\varphi\), ignoring parentheses. \(\mathit{conn}(\varphi)\) counts the occurrences of connectives. \(\mathit{rank}(\varphi)\) is the depth of the parse tree: the number of levels below the root.

Definition 7.15: subformulas and occurring primitive propositions \[\begin{aligned} \mathit{sub}(p)&=\{p\} & \mathit{occ}(p)&=\{p\}\\ \mathit{sub}(\neg\varphi)&=\mathit{sub}(\varphi)\cup\{\neg\varphi\} & \mathit{occ}(\neg\varphi)&=\mathit{occ}(\varphi)\\ \mathit{sub}(\varphi\bullet\psi)&=\mathit{sub}(\varphi)\cup\mathit{sub}(\psi)\cup\{\varphi\bullet\psi\} \quad & \mathit{occ}(\varphi\bullet\psi)&=\mathit{occ}(\varphi)\cup\mathit{occ}(\psi) \end{aligned}\]

The elements of \(\mathit{sub}(\varphi)\) are the subformulas of \(\varphi\): the formulas at the nodes of its parse tree. \(\mathit{occ}(\varphi)\) is the set of primitive propositions that occur in \(\varphi\). Both are sets, so a formula that appears twice in the tree is counted once.

Example 7.16: computing with the recursive definitions

Let \(\varphi=(p\wedge\neg q)\to(q\vee p)\).

Length. Each line applies one clause of Definition 7.14 to the outermost connective that is still unevaluated:

\[\begin{aligned} \mathit{length}(\varphi)&=\mathit{length}(p\wedge\neg q)+\mathit{length}(q\vee p)+1\\ &=\big(\mathit{length}(p)+\mathit{length}(\neg q)+1\big)+\big(\mathit{length}(q)+\mathit{length}(p)+1\big)+1\\ &=\big(1+(1+1)+1\big)+\big(1+1+1\big)+1=8. \end{aligned}\]

Check by counting: the symbols are \(p,\wedge,\neg,q,\to,q,\vee,p\).

Connectives. In the same way \(\mathit{conn}(\varphi)=4\): the connectives are \(\wedge\), \(\neg\), \(\to\), \(\vee\).

Rank. \(\mathit{rank}(\neg q)=1\), so \(\mathit{rank}(p\wedge\neg q)=\max\{0,1\}+1=2\). \(\mathit{rank}(q\vee p)=\max\{0,0\}+1=1\). Hence \(\mathit{rank}(\varphi)=\max\{2,1\}+1=3\).

Subformulas. \(\mathit{sub}(\varphi)=\{p,\ q,\ \neg q,\ p\wedge\neg q,\ q\vee p,\ \varphi\}\), six formulas. The parse tree has eight nodes, but \(p\) and \(q\) each occur twice.

Occurring primitive propositions. \(\mathit{occ}(\varphi)=\{p,q\}\).

Theorem 7.17: the principle of structural induction

Let \(P(\varphi)\) be a statement about formulas. Suppose that

  1. (base case) \(P(p)\) holds for every primitive proposition \(p\);
  2. (step for \(\neg\)) whenever \(P(\varphi)\) holds, \(P(\neg\varphi)\) holds;
  3. (steps for the binary connectives) whenever \(P(\varphi)\) and \(P(\psi)\) hold, so do \(P(\varphi\wedge\psi)\), \(P(\varphi\vee\psi)\) and \(P(\varphi\to\psi)\).

Then \(P(\varphi)\) holds for every formula \(\varphi\).

Suppose some formula fails \(P\), and take one with the smallest possible number of construction steps. It is not a primitive proposition, by the base case. So its last construction step applied a connective to one or two formulas with fewer steps, and those satisfy \(P\) by the choice of a smallest counterexample. The matching inductive step then gives \(P\) for our formula, a contradiction. □

This has the same shape as induction on proof trees in Week 3: the primitive propositions play the role of the leaves, and the connectives play the role of the rules. There are four inductive steps, one for each connective. When the steps for \(\wedge,\vee,\to\) are identical, we do them once for \(\bullet\).

Proposition 7.18

For every formula \(\varphi\), \(\mathit{length}(\varphi)>\mathit{conn}(\varphi)\).

Structural induction on \(\varphi\).

Base case: \(\mathit{length}(p)=1>0=\mathit{conn}(p)\).

Step for \(\neg\): assume \(\mathit{length}(\varphi)>\mathit{conn}(\varphi)\). Then \(\mathit{length}(\neg\varphi)=\mathit{length}(\varphi)+1>\mathit{conn}(\varphi)+1=\mathit{conn}(\neg\varphi)\).

Step for \(\bullet\): assume the claim for \(\varphi\) and for \(\psi\). Then \[\begin{aligned}\mathit{length}(\varphi\bullet\psi)&=\mathit{length}(\varphi)+\mathit{length}(\psi)+1\\ &>\mathit{conn}(\varphi)+\mathit{conn}(\psi)+1=\mathit{conn}(\varphi\bullet\psi).\end{aligned}\] □

Proposition 7.19

For every formula \(\varphi\), \(\mathit{rank}(\varphi)\le\mathit{conn}(\varphi)\).

Structural induction on \(\varphi\).

Base case: \(\mathit{rank}(p)=0\le0=\mathit{conn}(p)\).

Step for \(\neg\): if \(\mathit{rank}(\varphi)\le\mathit{conn}(\varphi)\), then \(\mathit{rank}(\neg\varphi)=\mathit{rank}(\varphi)+1\le\mathit{conn}(\varphi)+1=\mathit{conn}(\neg\varphi)\).

Step for \(\bullet\): assume \(\mathit{rank}(\varphi)\le\mathit{conn}(\varphi)\) and \(\mathit{rank}(\psi)\le\mathit{conn}(\psi)\). The maximum of two numbers is at most their sum when both are \(\ge0\), so \[\begin{aligned}\mathit{rank}(\varphi\bullet\psi)&=\max\{\mathit{rank}(\varphi),\mathit{rank}(\psi)\}+1\\ &\le\max\{\mathit{conn}(\varphi),\mathit{conn}(\psi)\}+1\\ &\le\mathit{conn}(\varphi)+\mathit{conn}(\psi)+1=\mathit{conn}(\varphi\bullet\psi).\end{aligned}\] □

Example 7.20: a false claim, and a true one next to it

Claim: every formula has at least as many connectives as distinct primitive propositions, \(\mathit{conn}(\varphi)\ge|\mathit{occ}(\varphi)|\).

This is false, and one formula is enough to show it: for \(\varphi=p\) we have \(\mathit{conn}(p)=0\) and \(|\mathit{occ}(p)|=1\). An induction proof would fail already at the base case.

Corrected claim: \(\mathit{conn}(\varphi)\ge|\mathit{occ}(\varphi)|-1\) for every \(\varphi\).

Base case: \(0\ge1-1\).

Step for \(\neg\): \(\mathit{conn}(\neg\varphi)=\mathit{conn}(\varphi)+1>\mathit{conn}(\varphi) \ge|\mathit{occ}(\varphi)|-1=|\mathit{occ}(\neg\varphi)|-1\).

Step for \(\bullet\): for two finite sets, \(|X\cup Y|\le|X|+|Y|\). So \[\begin{aligned}\mathit{conn}(\varphi\bullet\psi)&=\mathit{conn}(\varphi)+\mathit{conn}(\psi)+1\\ &\ge\big(|\mathit{occ}(\varphi)|-1\big)+\big(|\mathit{occ}(\psi)|-1\big)+1\\ &\ge|\mathit{occ}(\varphi)\cup\mathit{occ}(\psi)|-1=|\mathit{occ}(\varphi\bullet\psi)|-1.\end{aligned}\] □

To refute a statement about all formulas, give one formula for which it fails. To prove it, give an induction.

Exercise 3: compute with the recursive definitions

Self-check only. Nothing here counts towards your grade.

Fill in the table for \(\varphi_1=\neg(p\to q)\vee(\neg p\wedge(q\to r))\) and \(\varphi_2=\neg\neg(p\wedge q)\to(r\vee\neg r)\).

\(\varphi_1\): length \(11\), conn \(6\), rank \(3\), and \(9\) subformulas: \(p,\ q,\ r,\ p\to q,\ \neg(p\to q),\ \neg p,\ q\to r,\ \neg p\wedge(q\to r),\ \varphi_1\). The rank is \(3\) because both immediate subformulas have rank \(2\).

\(\varphi_2\): length \(10\), conn \(6\), rank \(4\), and \(9\) subformulas: \(p,\ q,\ p\wedge q,\ \neg(p\wedge q),\ \neg\neg(p\wedge q),\ r,\ \neg r,\ r\vee\neg r,\ \varphi_2\). The deepest branch is \(\varphi_2,\ \neg\neg(p\wedge q),\ \neg(p\wedge q),\ p\wedge q,\ p\).

Day 2 (Wednesday, October 7): Valuations and truth tables

Today we give formulas a meaning: a valuation assigns a truth value to every primitive proposition, and recursion extends it to all formulas. We compute truth values by hand, build truth tables, and sort formulas into tautologies, contradictions and the rest.

What we are using from before
  • Formulas: \(\varphi::=p\mid\neg\varphi\mid(\varphi\wedge\varphi)\mid(\varphi\vee\varphi)\mid (\varphi\to\varphi)\) with \(p\in\mathrm{PROP}\). We drop the outermost parentheses, and \(\neg\) has narrow scope: \(\neg p\vee q\) means \((\neg p)\vee q\).
  • \(\varphi\leftrightarrow\psi\) abbreviates \((\varphi\to\psi)\wedge(\psi\to\varphi)\).
  • Every formula has a unique parse tree. The connective at its root is the main connective.
  • Functions on formulas are defined by recursion: a value for each \(p\), and a rule for \(\neg\) and for each binary connective \(\bullet\). Statements about all formulas are proved by structural induction: a base case for \(p\), and one step for each connective.
  • \(\mathit{occ}(\varphi)\) is the set of primitive propositions that occur in \(\varphi\): \(\mathit{occ}(p)=\{p\}\), \(\mathit{occ}(\neg\varphi)=\mathit{occ}(\varphi)\), \(\mathit{occ}(\varphi\bullet\psi)=\mathit{occ}(\varphi)\cup\mathit{occ}(\psi)\).

4. Valuations and the truth value of a formula

So far \(\wedge\) is only a symbol. Nothing connects it with the meaning of "and". We now make the connection through truth: we say when a formula is true. A primitive proposition has no structure that could decide this, so its truth value is simply given. Everything else is computed.

Definition 7.21: valuation

We write \(\mathrm T\) for true and \(\mathrm F\) for false. A valuation is a function \(v:\mathrm{PROP}\to\{\mathrm T,\mathrm F\}\). It gives a truth value to every primitive proposition, in any combination.

For instance, \(v(p)=\mathrm T\), \(v(q)=\mathrm F\), and \(v(s)=\mathrm T\) for all other primitive propositions \(s\), defines a valuation.

Definition 7.22: the truth value \([\![\varphi]\!]_v\)

Given a valuation \(v\), the truth value \([\![\varphi]\!]_v\in\{\mathrm T,\mathrm F\}\) of a formula \(\varphi\) is defined by recursion on \(\varphi\):

\[\begin{aligned} [\![p]\!]_v&=\mathrm T &&\text{iff}\quad v(p)=\mathrm T\\ [\![\neg\varphi]\!]_v&=\mathrm T &&\text{iff}\quad [\![\varphi]\!]_v=\mathrm F\\ [\![\varphi\wedge\psi]\!]_v&=\mathrm T &&\text{iff}\quad [\![\varphi]\!]_v=\mathrm T\ \text{and}\ [\![\psi]\!]_v=\mathrm T\\ [\![\varphi\vee\psi]\!]_v&=\mathrm T &&\text{iff}\quad [\![\varphi]\!]_v=\mathrm T\ \text{or}\ [\![\psi]\!]_v=\mathrm T\\ [\![\varphi\to\psi]\!]_v&=\mathrm T &&\text{iff}\quad [\![\varphi]\!]_v=\mathrm F\ \text{or}\ [\![\psi]\!]_v=\mathrm T \end{aligned}\]

In each line, if the condition on the right fails, the value on the left is \(\mathrm F\). The "or" on the right is inclusive. We read \([\![\varphi]\!]_v\) as "the truth value of \(\varphi\) under \(v\)".

The truth value of a compound formula depends only on the truth values of its immediate subformulas. This is what makes the connectives truth-functional. The dependence is summarized in the truth tables of the connectives. The column for \(\leftrightarrow\) is computed from the abbreviation: both implications are true exactly when \(\varphi\) and \(\psi\) have the same value.

\(\varphi\)\(\psi\)\(\neg\varphi\) \(\varphi\wedge\psi\)\(\varphi\vee\psi\)\(\varphi\to\psi\) \(\varphi\leftrightarrow\psi\)
TTFTTTT
TFFFTFF
FTTFTTF
FFTFFTT
Table 1. The truth tables of the connectives. Each row is one combination of truth values of \(\varphi\) and \(\psi\).
The implication is false in only one row

\(\varphi\to\psi\) is false only when \(\varphi\) is true and \(\psi\) is false. Think of If a number is prime and greater than 2, then it is odd. The number \(14\) is not a counterexample: it is not prime, so the claim says nothing about it. A counterexample would have to make the antecedent true and the consequent false. So an implication with a false antecedent counts as true.

This is called material implication. It does not capture every use of "if" in English. If today is Saturday, then I am in Buffalo is true on a Tuesday by this definition, which is not how we usually understand the sentence. The material implication is the part of "if" that propositional logic can model with two truth values.

The table also lets us compute with \(\mathrm T\) and \(\mathrm F\) as we compute with numbers: \(\mathrm T\wedge\mathrm F=\mathrm F\), \(\neg\mathrm F=\mathrm T\), \(\mathrm F\to\mathrm F=\mathrm T\). In such a computation the connectives are operations on \(\{\mathrm T,\mathrm F\}\), while inside \([\![\ ]\!]_v\) they are symbols of the language. The recursive definition turns one into the other.

Example 7.23: computing a truth value step by step

Let \(\varphi=(p\wedge\neg q)\to(q\vee r)\) and let \(v\) be a valuation with \(v(p)=\mathrm T\), \(v(q)=\mathrm F\), \(v(r)=\mathrm F\). Each line applies Definition 7.22 or Table 1 once:

\[\begin{aligned} [\![(p\wedge\neg q)\to(q\vee r)]\!]_v &=[\![p\wedge\neg q]\!]_v\to[\![q\vee r]\!]_v &&\text{main conn. }\to\\ &=\big([\![p]\!]_v\wedge[\![\neg q]\!]_v\big)\to\big([\![q]\!]_v\vee[\![r]\!]_v\big) &&\wedge,\ \vee\\ &=\big(\mathrm T\wedge\neg[\![q]\!]_v\big)\to\big(\mathrm F\vee\mathrm F\big) &&\text{values of }v\\ &=\big(\mathrm T\wedge\neg\mathrm F\big)\to\mathrm F &&\\ &=\big(\mathrm T\wedge\mathrm T\big)\to\mathrm F=\mathrm T\to\mathrm F=\mathrm F. \end{aligned}\]

So \([\![\varphi]\!]_v=\mathrm F\). The antecedent is true and the consequent is false: this is the one row in which an implication fails.

If we change only \(v(r)\) to \(\mathrm T\), the consequent becomes \(\mathrm F\vee\mathrm T=\mathrm T\) and the value of \(\varphi\) becomes \(\mathrm T\to\mathrm T=\mathrm T\).

The same computation can be written on the parse tree. Start at the leaves, where \(v\) gives the values, and move up: each node gets its value from its children by Table 1 (Figure 3).

p T q F ¬q T p∧¬q T q F r F q∨r F (p∧¬q)→(q∨r) F
Figure 3. The computation of Example 7.23 on the parse tree. The value at a node is computed from the values of its children; the value at the root is \([\![\varphi]\!]_v\).
Example 7.24: sentences in a situation

Dictionary: \(r\): It is raining. \(c\): It is cold. \(u\): I take my umbrella. \(w\): I walk to campus. A situation is a valuation. Suppose today it is raining, it is not cold, I take my umbrella and I do not walk: \(v(r)=\mathrm T\), \(v(c)=\mathrm F\), \(v(u)=\mathrm T\), \(v(w)=\mathrm F\).

  1. It is raining but not cold, \(r\wedge\neg c\): \(\mathrm T\wedge\neg\mathrm F=\mathrm T\wedge\mathrm T=\mathrm T\).
  2. I take my umbrella only if it is raining, \(u\to r\): \(\mathrm T\to\mathrm T=\mathrm T\).
  3. I walk to campus unless it is raining, \(\neg r\to w\): \(\neg\mathrm T\to\mathrm F=\mathrm F\to\mathrm F=\mathrm T\). It is raining, so the sentence makes no claim about today, and it is true.
  4. If it is cold and raining, I take my umbrella and do not walk, \((c\wedge r)\to(u\wedge\neg w)\): the antecedent is \(\mathrm F\wedge\mathrm T=\mathrm F\), so the implication is \(\mathrm T\) without looking at the consequent.
  5. It is not both raining and cold, \(\neg(r\wedge c)\): \(\neg(\mathrm T\wedge\mathrm F)=\neg\mathrm F=\mathrm T\).
  6. If it is raining or cold, I walk to campus, \((r\vee c)\to w\): \(\mathrm T\to\mathrm F=\mathrm F\).

Sentence 4 shows a useful shortcut: an implication with a false antecedent is true, and a disjunction with one true part is true, so sometimes half of a formula does not need to be computed.

A valuation assigns values to all primitive propositions, infinitely many of them. For one formula only finitely many of these values matter.

Proposition 7.25: only the occurring primitive propositions matter

Let \(\varphi\) be a formula and let \(v,w\) be valuations with \(v(p)=w(p)\) for every \(p\in\mathit{occ}(\varphi)\). Then \([\![\varphi]\!]_v=[\![\varphi]\!]_w\).

Structural induction on \(\varphi\). The statement \(P(\varphi)\) is: for all valuations \(v,w\) that agree on \(\mathit{occ}(\varphi)\), \([\![\varphi]\!]_v=[\![\varphi]\!]_w\).

Base case. \(\mathit{occ}(p)=\{p\}\), so \(v(p)=w(p)\), and \([\![p]\!]_v=v(p)=w(p)=[\![p]\!]_w\).

Step for \(\neg\). Let \(v,w\) agree on \(\mathit{occ}(\neg\varphi)=\mathit{occ}(\varphi)\). By \(P(\varphi)\), \([\![\varphi]\!]_v=[\![\varphi]\!]_w\). The value of \(\neg\varphi\) is computed from the value of \(\varphi\) alone, so \([\![\neg\varphi]\!]_v=[\![\neg\varphi]\!]_w\).

Step for \(\bullet\). Let \(v,w\) agree on \(\mathit{occ}(\varphi\bullet\psi)=\mathit{occ}(\varphi)\cup\mathit{occ}(\psi)\). Then they agree on \(\mathit{occ}(\varphi)\) and on \(\mathit{occ}(\psi)\), so \(P(\varphi)\) and \(P(\psi)\) give \([\![\varphi]\!]_v=[\![\varphi]\!]_w\) and \([\![\psi]\!]_v=[\![\psi]\!]_w\). The value of \(\varphi\bullet\psi\) is computed from these two values by Table 1, so \([\![\varphi\bullet\psi]\!]_v=[\![\varphi\bullet\psi]\!]_w\). □

So for a formula with \(n\) distinct primitive propositions there are only \(2^n\) cases to consider, one for each combination of their values. This is the idea behind truth tables. For instance, in Example 7.23 the value \(v(s)\) of a primitive proposition \(s\notin\{p,q,r\}\) played no role.

Exercise 4: truth values under one valuation

Self-check only. Nothing here counts towards your grade.

Let \(v(p)=\mathrm T\), \(v(q)=\mathrm F\), \(v(r)=\mathrm T\), \(v(s)=\mathrm F\). Find \([\![\varphi]\!]_v\) for each formula.

  1. \(\neg p\vee q=\neg\mathrm T\vee\mathrm F=\mathrm F\vee\mathrm F=\mathrm F\).
  2. \((p\to q)\to s=(\mathrm T\to\mathrm F)\to\mathrm F=\mathrm F\to\mathrm F=\mathrm T\).
  3. \(\neg(q\wedge s)\wedge r=\neg(\mathrm F\wedge\mathrm F)\wedge\mathrm T=\mathrm T\wedge\mathrm T=\mathrm T\).
  4. \((r\to p)\wedge(q\vee\neg s)=(\mathrm T\to\mathrm T)\wedge(\mathrm F\vee\mathrm T)=\mathrm T\wedge\mathrm T=\mathrm T\).
  5. \(p\to(q\to(r\to s))\): the inner \(q\to(r\to s)\) has antecedent \(\mathrm F\), so it is \(\mathrm T\), and \(\mathrm T\to\mathrm T=\mathrm T\).
  6. \(\neg(p\vee(q\wedge\neg r))=\neg(\mathrm T\vee\dots)=\neg\mathrm T=\mathrm F\). A disjunction with a true part is true.

5. Truth tables

Method 7.26: the truth table of a formula
  1. List the primitive propositions of \(\mathit{occ}(\varphi)\), say \(n\) of them, as the first columns.
  2. Write the \(2^n\) rows of truth values in a fixed order: the first column is \(\mathrm T\) in the first half of the rows and \(\mathrm F\) in the second half, the next column alternates in halves of each half, and so on. The last column alternates \(\mathrm T,\mathrm F\).
  3. Add one column for each subformula, ordered so that every column comes after the columns of its immediate subformulas. Fill each entry from those columns with Table 1.
  4. The last column is \(\varphi\) itself. Its entry in a row is \([\![\varphi]\!]_v\) for every valuation \(v\) that gives these values to the primitive propositions of that row.

By Proposition 7.25 every valuation falls under exactly one row, so the table describes the value of \(\varphi\) under all valuations.

Example 7.27: a formula that is true in every row

The truth table of \(\neg(p\wedge q)\to(\neg p\vee\neg q)\):

\(p\) \(q\) \(p\wedge q\) \(\neg (p\wedge q)\) \(\neg p\) \(\neg q\) \(\neg p\vee \neg q\) \(\neg (p\wedge q)\to (\neg p\vee \neg q)\)
TTTFFFFT
TFFTFTTT
FTFTTFTT
FFFTTTTT

The first column after the bar is computed from \(p\) and \(q\) by the table of \(\wedge\); the second negates it, and so on. The last column is \(\mathrm T\) in every row, so the formula is true under every valuation.

Some books write the same computation more compactly, with each value under the connective that produces it in one long line. The entries are the same; only the layout differs.

Example 7.28: reading a table

The truth table of \((p\to q)\to(q\to p)\):

\(p\) \(q\) \(p\to q\) \(q\to p\) \((p\to q)\to (q\to p)\)
TTTTT
TFFTT
FTTFF
FFTTT

The formula is false in exactly one row: \(p\) false and \(q\) true. In that row \(p\to q\) is true (false antecedent) and \(q\to p\) is false. In words: the converse of a true implication can be false. A true \(p\to q\) does not give \(q\to p\).

Example 7.29: three primitive propositions

The truth table of \(((p\vee q)\wedge\neg r)\to p\) has \(2^3=8\) rows:

\(p\) \(q\) \(r\) \(p\vee q\) \(\neg r\) \((p\vee q)\wedge \neg r\) \(((p\vee q)\wedge \neg r)\to p\)
TTTTFFT
TTFTTTT
TFTTFFT
TFFTTTT
FTTTFFT
FTFTTTF
FFTFFFT
FFFFTFT

In the first four rows \(p\) is true, so the implication is true whatever the antecedent is. Only the last four rows need work, and among them only the row \(p=\mathrm F\), \(q=\mathrm T\), \(r=\mathrm F\) makes the antecedent true. There the formula is false.

Exercise 5: complete a truth table

Self-check only. Nothing here counts towards your grade.

Complete the truth table of \((p\wedge\neg q)\vee(q\to r)\). Click a cell to switch between empty, \(\mathrm T\) and \(\mathrm F\). Fill the columns from left to right.

\(p\) \(q\) \(r\) \(\neg q\) \(p\wedge \neg q\) \(q\to r\) \((p\wedge \neg q)\vee (q\to r)\)
TTTFFTT
TTFFFFF
TFTTTTT
TFFTTTT
FTTFFTT
FTFFFFF
FFTTFTT
FFFTFTT

The formula is false exactly when both disjuncts are false. \(q\to r\) is false only when \(q=\mathrm T\) and \(r=\mathrm F\), and then \(\neg q=\mathrm F\), so \(p\wedge\neg q\) is false too. These are the rows \(\mathrm{TTF}\) and \(\mathrm{FTF}\).

6. Tautologies, contradictions and satisfiable formulas

Definition 7.30
  • \(\varphi\) is a tautology, written \(\vDash\varphi\), if \([\![\varphi]\!]_v=\mathrm T\) for every valuation \(v\). In the truth table: the last column is all \(\mathrm T\).
  • \(\varphi\) is a contradiction if \([\![\varphi]\!]_v=\mathrm F\) for every valuation \(v\): the last column is all \(\mathrm F\).
  • \(\varphi\) is satisfiable if \([\![\varphi]\!]_v=\mathrm T\) for at least one valuation \(v\): some row has \(\mathrm T\).
  • \(\varphi\) is contingent if it is neither a tautology nor a contradiction: the last column has both values.

A tautology is true "in virtue of its form": its truth does not depend on the values given to the primitive propositions. For instance \(p\vee\neg p\) is a tautology, \(p\wedge\neg p\) is a contradiction, and \(p\to q\) is contingent and satisfiable.

Proposition 7.31
  1. \(\varphi\) is a tautology iff \(\neg\varphi\) is a contradiction.
  2. \(\varphi\) is satisfiable iff \(\varphi\) is not a contradiction.
  3. \(\varphi\) is satisfiable iff \(\neg\varphi\) is not a tautology.

(1) For every \(v\), \([\![\neg\varphi]\!]_v=\mathrm F\) iff \([\![\varphi]\!]_v=\mathrm T\). So "\(\neg\varphi\) is false under every \(v\)" says the same as "\(\varphi\) is true under every \(v\)". (2) "Not false under every \(v\)" means "true under some \(v\)". (3) \(\varphi\) is true under some \(v\) iff \(\neg\varphi\) is false under some \(v\), iff \(\neg\varphi\) is not a tautology. □

Example 7.32: two translations that always agree

On Monday we translated neither \(A\) nor \(B\) both as \(\neg A\wedge\neg B\) and as \(\neg(A\vee B)\). With \(r\) and \(c\) for the two statements, the claim is that \(\neg(r\vee c)\leftrightarrow(\neg r\wedge\neg c)\) is a tautology:

\(r\) \(c\) \(r\vee c\) \(\neg (r\vee c)\) \(\neg r\) \(\neg c\) \(\neg r\wedge \neg c\) \(\neg (r\vee c)\leftrightarrow (\neg r\wedge \neg c)\)
TTTFFFFT
TFTFFTFT
FTTFTFFT
FFFTTTTT

The column of \(\leftrightarrow\) is \(\mathrm T\) exactly where the two columns it joins agree, and they agree in every row. So the two translations have the same truth value in every situation.

Example 7.33: English sentences that are true in every situation

Same dictionary as in Example 7.24.

  • Either it is raining or it is not raining, \(r\vee\neg r\): a tautology. It tells us nothing about the weather.
  • If it is raining and cold, then it is raining, \((r\wedge c)\to r\): a tautology. If the antecedent is true, then \(r\) is true.
  • If it is raining, then it is raining and cold, \(r\to(r\wedge c)\): contingent. It is false when \(r=\mathrm T\) and \(c=\mathrm F\).
  • It is raining and it is not raining, \(r\wedge\neg r\): a contradiction.

A full truth table is not always the fastest way. To show that a formula is a tautology, it is enough to show that no valuation makes it false. Often one can search for such a valuation directly, working from the main connective downwards.

Example 7.34: searching for a falsifying valuation

(a) \((p\to q)\to(q\to p)\). For the whole implication to be false we need \(p\to q=\mathrm T\) and \(q\to p=\mathrm F\). The second condition forces \(q=\mathrm T\) and \(p=\mathrm F\). Check the first: \(\mathrm F\to\mathrm T=\mathrm T\). So the valuation with \(p=\mathrm F\), \(q=\mathrm T\) makes the formula false, and it is not a tautology. This is the row found in Example 7.28.

(b) \((p\to(q\to r))\to((p\to q)\to(p\to r))\). Suppose some valuation makes it false.

  1. The consequent \((p\to q)\to(p\to r)\) must be \(\mathrm F\) and the antecedent \(p\to(q\to r)\) must be \(\mathrm T\).
  2. For the consequent to be false: \(p\to q=\mathrm T\) and \(p\to r=\mathrm F\). The second forces \(p=\mathrm T\), \(r=\mathrm F\). Then the first forces \(q=\mathrm T\).
  3. Now the antecedent is \(\mathrm T\to(\mathrm T\to\mathrm F)=\mathrm T\to\mathrm F=\mathrm F\). But step 1 needed it to be \(\mathrm T\).

Every choice was forced, and we reached a contradiction. So no valuation makes the formula false, and it is a tautology. This took one line of values instead of eight rows.

One table, infinitely many tautologies

The computation in Example 7.27 used only the truth values of \(p\) and \(q\), not what they are. If we replace \(p\) and \(q\) by any formulas \(\varphi\) and \(\psi\), every valuation gives \(\varphi\) and \(\psi\) one of the four combinations of values, and the same row of the table applies. So every formula of the form \(\neg(\varphi\wedge\psi)\to(\neg\varphi\vee\neg\psi)\) is a tautology. Such an expression with Greek letters is a formula scheme; it stands for all of its instances. The same holds for Example 7.34(b), where \(p,q,r\) can be replaced by any formulas.

Exercise 6: find a valuation

Self-check only. Nothing here counts towards your grade.

Choose the values of \(p,q,r\). The check computes the formula under your valuation, so every correct valuation is accepted.

(a) Make \((p\to q)\to(\neg q\to r)\) false.

(b) Make \(((p\vee q)\wedge(\neg p\vee\neg q))\wedge(q\to r)\) true.

(a) We need \(p\to q=\mathrm T\) and \(\neg q\to r=\mathrm F\). The second forces \(\neg q=\mathrm T\) and \(r=\mathrm F\), so \(q=\mathrm F\). Then \(p\to q=\mathrm T\) forces \(p=\mathrm F\). The only answer is \(p=q=r=\mathrm F\).

(b) \((p\vee q)\wedge(\neg p\vee\neg q)\) says that exactly one of \(p,q\) is true. If \(p=\mathrm T\), \(q=\mathrm F\), then \(q\to r\) is true for both values of \(r\). If \(p=\mathrm F\), \(q=\mathrm T\), then \(r\) must be \(\mathrm T\). Three valuations work: \(\mathrm{TFT}\), \(\mathrm{TFF}\) and \(\mathrm{FTT}\) (values of \(p,q,r\)).

Exercise 7: tautology, contradiction, or contingent?

Self-check only. Nothing here counts towards your grade.

  1. \((p\to q)\vee(q\to p)\): tautology. If \(q=\mathrm T\) the first disjunct is true; if \(q=\mathrm F\) the second is.
  2. \((p\wedge q)\wedge\neg(p\vee q)\): contradiction. \(p\wedge q\) true makes \(p\vee q\) true.
  3. \((p\to q)\to p\): contingent. True when \(p=\mathrm T\); false when \(p=q=\mathrm F\).
  4. \(((p\to q)\to p)\to p\): tautology. To make it false we need \(p=\mathrm F\) and \((p\to q)\to p=\mathrm T\); but with \(p=\mathrm F\) we get \(p\to q=\mathrm T\) and \(\mathrm T\to\mathrm F=\mathrm F\).
  5. \(\neg(p\to(q\to p))\): contradiction. \(p\to(q\to p)\) is a tautology: if \(p=\mathrm T\) the consequent \(q\to p\) is true, and if \(p=\mathrm F\) the antecedent is false.
  6. \((p\vee q)\to(p\wedge q)\): contingent. True when \(p=q\); false when exactly one is true.
Where this is going

We now have one way to say that a formula is "always true": \(\vDash\varphi\), checked by truth tables. Next week we define a second, completely different notion, \(\vdash\varphi\): \(\varphi\) can be derived from axioms by rules, without any mention of truth. The main results of the coming weeks are that the two notions pick out exactly the same formulas, and that a truth table gives a mechanical test for both.

Homework 7

Before you start

  • Fill in your name below. Do not write your student number; it is already attached to your Canvas upload.
  • Show your work. An answer without the steps behind it earns no points. For a truth value, show the computation. For a claim about all formulas, give an induction proof. For a false claim, give one specific counterexample.
  • Typing formulas. Under every text box there is a row of buttons that insert \(\neg\), \(\wedge\), \(\vee\), \(\to\), \(\leftrightarrow\), \(\vDash\) and other symbols at the cursor. You may also type ~, &, |, -> and <->. Follow Convention 7.5 for parentheses. In the truth tables of Question 5, type T or F in each cell.
  • Two answer modes. Every question has a Type mode and a Write by hand mode. In Write by hand mode the text boxes are replaced by a ruled area you can write on with a pen, a finger or the mouse. Parse trees (Question 2) are easiest to draw in this mode. Only the mode you have selected for a question goes into the PDF. Switching modes does not delete what you entered in the other mode.
  • How to submit. Press "Save homework as PDF" at the bottom, save the file, and upload it to Canvas.
  • Your answers are saved automatically in this browser. If you open the file on a different computer they will not be there.
  • Total: 100 points.

Question 1: translation20 points

Dictionary: \(s\): Sarah studies. \(p\): Sarah passes the exam. \(h\): The exam is hard. \(t\): Sarah has time.

(a) to (e) (2 pts each) Translate into propositional logic.
  1. Sarah passes the exam only if she studies.
  2. If the exam is hard, Sarah passes unless she does not study.
  3. Sarah studies if she has time, but the exam is hard.
  4. The exam is not hard and Sarah does not study, yet she passes.
  5. Having time is necessary for Sarah to study, and studying is sufficient for passing.
(f) (4 pts) The sentence Sarah passes if and only if she studies and the exam is not hard can be read in two ways. Give a formula for each reading, and describe in one sentence a situation in which the two readings say different things.
(g) (6 pts) Translate into natural English, using the same dictionary: (i) \((t\wedge\neg h)\to(s\vee p)\); (ii) \(\neg(s\wedge\neg p)\). For (ii), also give a second English sentence with the same meaning that uses "if ... then".

Question 2: formulas and parse trees15 points

Consider the four strings

  1. \(\neg(p\to\neg q)\vee(q\wedge r)\)
  2. \(p\wedge q\vee\neg r\)
  3. \((\neg\neg p\to(q\vee\neg p))\to r\)
  4. \(\neg(p\wedge(q\to))\)
(a) (4 pts) Which of them are formulas, with Convention 7.5? For each string that is not a formula, say what goes wrong.
(b) (11 pts) For each string that is a formula: give its main connective and its immediate subformulas, draw its parse tree, and list the set of all its subformulas. In Type mode, describe the tree level by level, starting at the root.

Question 3: recursion and structural induction20 points

For a formula \(\varphi\), let \(f(\varphi)\) be the number of occurrences of primitive propositions in \(\varphi\), counting repetitions (so \(f(p\to p)=2\)), and let \(g(\varphi)\) be the number of occurrences of the symbol \(\wedge\) in \(\varphi\).

(a) (4 pts) Give recursive definitions of \(f\) and \(g\), in the style of Definition 7.14. Note that \(g\) needs separate clauses for \(\wedge\) and for the other binary connectives.
(b) (8 pts) Prove by structural induction that \(f(\varphi)>g(\varphi)\) for every formula \(\varphi\). Write out every case.
(c) (8 pts) Is it true that \(\mathit{rank}(\varphi)\ge\mathit{conn}(\varphi)\) for every formula \(\varphi\)? Justify your answer with an induction proof or a counterexample. If you give a counterexample, compute both numbers for it with Definition 7.14.

Question 4: truth values15 points

Let \(v\) be a valuation with \(v(p)=\mathrm F\), \(v(q)=\mathrm T\), \(v(r)=\mathrm F\), \(v(s)=\mathrm T\).

(a) to (c) (4 pts each) Compute \([\![\varphi]\!]_v\) step by step, as in Example 7.23, for
  1. \(\neg(p\vee q)\vee(r\wedge s)\)
  2. \((p\to(q\to r))\vee\neg s\)
  3. \(((q\leftrightarrow s)\wedge\neg p)\to(r\vee\neg(p\to q))\)
(d) (3 pts) Let \(w\) be the valuation with \(w(p)=\mathrm F\), \(w(q)=\mathrm T\), \(w(r)=\mathrm T\), \(w(s)=\mathrm F\). Without computing, explain why \([\![(p\wedge q)\vee\neg q]\!]_w=[\![(p\wedge q)\vee\neg q]\!]_v\). Name the result you use.

Question 5: truth tables20 points

(a) (7 pts) Complete the truth table of \((p\to q)\leftrightarrow(\neg q\to\neg p)\), and say whether the formula is a tautology, a contradiction or contingent.
\(p\) \(q\) \(p\to q\) \(\neg q\) \(\neg p\) \(\neg q\to \neg p\) \((p\to q)\leftrightarrow (\neg q\to \neg p)\)
TT
TF
FT
FF
(b) (9 pts) Complete the truth table of \(((p\to q)\wedge(q\to r))\to(r\to p)\). Classify the formula, and list every valuation of \(p,q,r\) that makes it false.
\(p\) \(q\) \(r\) \(p\to q\) \(q\to r\) \((p\to q)\wedge (q\to r)\) \(r\to p\) \(((p\to q)\wedge (q\to r))\to (r\to p)\)
TTT
TTF
TFT
TFF
FTT
FTF
FFT
FFF
(c) (4 pts) Without a full truth table, decide whether \(\neg((p\to q)\vee(q\to p))\) is satisfiable. Justify your answer.

Question 6: knights and knaves10 points

On an island every inhabitant is a knight, who always tells the truth, or a knave, who always lies. You meet three inhabitants \(A\), \(B\), \(C\). They say:

  • \(A\): \(B\) is a knave or \(C\) is a knight.
  • \(B\): If \(A\) is a knight, then \(C\) is a knave.
  • \(C\): \(A\) and \(B\) are not both knights.

Use the dictionary \(a\): \(A\) is a knight, \(b\): \(B\) is a knight, \(c\): \(C\) is a knight.

(a) (4 pts) An inhabitant's statement is true exactly when the inhabitant is a knight. Use this to write one formula for each of the three inhabitants.
(b) (6 pts) Find every valuation of \(a,b,c\) that makes all three formulas true, and say who is a knight and who is a knave. Justify that there are no other solutions, with a truth table or with a case analysis.