Knaph

The course as a book

Logic Level 6: Logic About Logic

Turn logic on itself - ask whether proofs ever lie, whether every valid argument can be proved, what no machine can decide, and why some true claims can never be proved.

Talking About Logic

Logic About Logic

A chess player moves the pieces. A chess writer sits beside the board and asks different questions. Can white always win? Can a game go on for ever? Both talk about chess, but they do not do the same thing. In logic too, we have played the game for five levels. Now we ask: what do we know about the game itself?

Playing and asking about playing

In Levels 1 to 5 we used logic. We made truth tables, we wrote proofs, we worked with all and some. That was the player's work. Now we step back and ask questions about the whole system. This is metalogic, which means logic about logic.

Two boxes, one above the other. The lower box, the game, shows a pawn and the words we play chess. The upper box, the writer, shows a notebook and the words we ask questions about chess. An arrow points from the upper box down to the lower one.

The question "can white always win?" is not a move in chess. It is about chess. The same is true here: "does this proof system ever prove something false?" is not a proof. It is a question about proofs.

Two languages

The symbols and rules we use for logic are the object language. It is the thing we study: letters, ¬ ∧ ∨ → ↔, ∀x, ∃x, and the proofs built from them.

The language in which we talk about it is the metalanguage. In this course the metalanguage is plain English, with a few extra signs we add as we go. When we say "this formula has three letters", that sentence is English. It is not a formula.

Keeping the two apart will matter more and more. The next lesson shows how they get mixed up.

Four big questions

This course asks four questions about the logic we already know.

A map with the words Our logic in the middle and four arrows leaving it, towards four boxes: Sound? Complete? Decidable? What cannot be done?

First, soundness: does a proof ever lead to something false? Second, completeness: is every truth we can state also provable? Third, decidability: can a machine always tell us the answer, yes or no? Fourth, the limits: what can logic never do? We meet the halting problem, the liar and Gödel's famous result in 1931.

Each answer comes with a small example, and the idea of its proof in plain words. The full proofs are longer, and we say so each time.

Try it at home

  1. Think of a game you know. Write one move, and then one question about the game as a whole, such as "can the first player always win?".
  2. Write down which of your two sentences is a move and which is about the game.
  3. Copy the four big questions into your notebook, in your own words.

Words to know

  • metalogic - logic about logic: questions about a logic system itself
  • object language - the language we study, here the symbols of logic
  • metalanguage - the language we use to talk about it, here English
  • soundness - a proof system never proves anything false

Big idea

Using logic and asking questions about logic are two different jobs: the system is the object language, and the questions are asked in a metalanguage.

Lesson page →

Using a Word and Naming It

Paris is a big city. Paris has five letters. Both sentences begin with the same word, yet one is about a city and the other about a word. How do we show which one we mean?

Using and naming

In "Paris is big" we use the word to talk about the city. In "'Paris' has five letters" we name the word to talk about the word itself. The quotes do the work. They say: look at these letters, not at the city.

On the left a city skyline with the sentence Paris is big. On the right the word Paris in quotation marks with the sentence has five letters. A label under each says using on the left and naming on the right.

Without quotes, "Paris has five letters" would say the city has five letters, which is nonsense.

The same for formulas

A formula is just a string of symbols. When we talk about a formula, we write it in code and say what we mean in English.

The formula (P ∧ Q) has five symbols: a bracket, P, ∧, Q and a bracket. Is it true? Not yet. It is true or false only when P and Q have a meaning, from a key or a row of a table. The string alone is not a claim.

So there are two kinds of statement. "P is true" talks about the world, using P. "The formula P has one symbol" talks about the symbol.

Formulas of any shape

Sometimes we want to say something about every formula. For that we need a name for "any formula". We use φ (read "phi") and ψ (read "psi").

Now "φ ∧ ψ" means: any formula made of two formulas joined by ∧. The formulas P ∧ Q and (P → R) ∧ ¬S both have this shape. φ and ψ are not letters of a key. They are words of the metalanguage.

Two formulas, P ∧ Q and not P and R, each with an arrow pointing to the shape phi and psi joined by the sign and.

A rule like "from φ → ψ and φ, we may write ψ" is then one rule for endlessly many proofs.

Careful

Do not write a metalanguage sentence inside a formula. "P is a formula" is not itself a formula, and P is not a sentence about formulas. Mixing the levels leads to nonsense, and later in this course it leads to the liar paradox.

Try it at home

  1. Write one true sentence that uses a word, and one that names it, with quotes.
  2. Count the symbols of ¬(P ∨ Q). Write down each one.
  3. Write three different formulas that all have the shape φ → ψ.

Words to know

  • use - to use a word to talk about what it stands for
  • name (mention) - to put a word in quotes and talk about the word itself
  • φ and ψ - signs for any formula, in the metalanguage

Big idea

Quotes turn a word into a name of itself, and φ and ψ let us speak about any formula at once; they belong to the metalanguage.

Lesson page →

What Counts as a Formula

Is P ∧ ∨ Q a formula? Your eye says no, but why? To talk about all formulas, we need to say exactly which strings count. The question: what are the rules for building a formula?

Three building rules

A formula is a string we may build in these steps. Each rule uses φ and ψ for any formulas already built.

Rule 1: a letter, such as P, is a formula. Rule 2: if φ is a formula, then ¬φ is a formula. Rule 3: if φ and ψ are formulas, then (φ ∧ ψ), (φ ∨ ψ), (φ → ψ) and (φ ↔ ψ) are formulas. Nothing else is a formula. A string that can be built this way is called well-formed.

As in earlier levels, we may drop the outer brackets when writing, so P ∧ Q stands for (P ∧ Q).

Testing strings

Let us test three strings. Is ¬(P ∧ Q) a formula? Yes. P and Q are formulas by rule 1. (P ∧ Q) is one by rule 3. Then ¬(P ∧ Q) is one by rule 2.

Is P ∧ ∨ Q a formula? No. The sign ∨ needs a formula on each side, and no rule puts two signs together.

Is (P) a formula? No. Rule 1 gives P, and no rule adds brackets around one formula alone.

Three strings in a list. The string not, bracket, P and Q, bracket, is marked yes. The string P, and, or, Q is marked no. The string bracket P bracket is marked no. Each has a short note.

The formula tree

Building a formula can be drawn as a tree. The last rule used is the root. For (P ∧ ¬Q) → R the root is →, its main connective, and below it are the two formulas it joins.

A tree. At the top the sign arrow. Below it on the left the sign and, with the letter P and the sign not above the letter Q beneath it. On the right the letter R.

Read it from the bottom up and you see how it was built. Every formula has exactly one tree, so there is only one way to read it. Logicians use that fact when they prove things about all formulas at once.

Try it at home

  1. Decide which are formulas: ¬¬P, P ¬ Q, (P ∨ Q) → R, ∧ P.
  2. For each one that is, write the rules you used to build it.
  3. Draw the tree of ¬(P ∨ (Q ∧ R)) on paper.

Words to know

  • well-formed formula - a string that can be built with the building rules
  • building rule - a step that makes a new formula from smaller ones
  • formula tree - a drawing of how a formula is built, with the main connective at the root

Big idea

A formula is exactly what the three building rules can make, and each one has a single tree.

Lesson page →

Two Kinds of Follows

Two friends say "Q follows from P → Q and P". The first has a proof, written line by line. The second tried every row of a truth table. Are they saying the same thing? The question: how many kinds of "follows" do we have?

Follows by proof

In Level 4 we wrote proofs: numbered lines, rules, boxes. We write Γ ⊢ φ. Γ (read "gamma") is a list of premises, and the sign ⊢ is a turnstile. The whole line reads "φ can be proved from Γ".

For example P → Q, P ⊢ Q is true: one use of →E gives Q. A proof is about rules and lines. It needs no meaning, so a machine can check it.

Two roads leaving the premises on the left. The upper road, marked with the proof sign, goes through the words rules and lines. The lower road, marked with the truth sign, goes through the words rows and worlds. Both end at a box labelled phi, with a question mark between the two roads.

Follows by truth

In Level 3 we checked rows. We write Γ ⊨ φ, with a double turnstile. It reads "φ is true in every row where Γ is". In Level 5 we say worlds instead of rows.

Again P → Q, P ⊨ Q. The premises are P → Q and P. Only a row where both are true matters.

PQP → Q
TTT
TFF
FTT
FFT

Only the first row makes both premises true (P is true and P → Q is true), and Q is true there. So P → Q, P ⊨ Q. This is about truth, not about lines.

A truth table with columns P, Q and P → Q. Only the first row, circled, makes both premises true, and Q is true in it.

Two ideas, one question

The two signs mean different things. One says a proof exists. The other says no row or world breaks the argument. With no premises, ⊢ φ says φ is a theorem, and ⊨ φ says φ is a tautology.

The two big questions of this course follow. If Γ ⊢ φ, must Γ ⊨ φ? That is soundness. If Γ ⊨ φ, must Γ ⊢ φ? That is completeness. We do not answer yet. First we need tools to prove things about all proofs and all formulas.

The signs ⊬ and ⊭ mean not: no proof exists, or some row breaks it.

Try it at home

  1. Write the argument P → Q, ¬Q so ¬P once with ⊢ and once with ⊨. Say each aloud in words.
  2. Which of the two could a friend check without knowing what P and Q mean?
  3. Write, in your own words, the two questions: does ⊢ always give ⊨, and does ⊨ always give ⊢?

Words to know

  • ⊢ (turnstile) - a proof exists, using the rules
  • ⊨ (double turnstile) - true in every row or world where the premises are true
  • theorem - a formula with a proof from no premises
  • Γ (gamma) - a list of premises

Big idea

Proving (⊢) and being true in every row (⊨) are two different ideas, and asking whether they always agree starts the course.

Lesson page →

Proving Things About Every Formula

Proof by Climbing

Line up dominoes, one behind the other, as far as you like - even for ever. You push the first. Will every domino fall? You cannot watch them all. Yet you can be sure if you check just two things. What are they?

Two things to check

First, the first domino falls, because you push it. Second, each domino stands close enough to the next one that, if it falls, it knocks the next one down. That is all. The first falls, so the second falls, so the third falls, for as long as the line goes.

A row of five dominoes numbered 1 to 5 and then three dots. A hand pushes domino 1, and a curved arrow runs from each domino to the next one.

This is proof by climbing, which mathematicians call induction. It is a kind of mathematical proof for claims about every natural number: 1, 2, 3 and so on. First show the claim for the first number: the first step. Then show the climbing step: if the claim holds for a number n, it holds for the next number, n plus one.

An example: odd numbers

Add the first odd numbers. 1 is 1×1. 1 + 3 is 4, which is 2×2. 1 + 3 + 5 is 9, which is 3×3. One more: 1 + 3 + 5 + 7 is 16, which is 4×4. The pattern: the first n odd numbers add up to n×n (read: n times n).

Four squares made of dots, with 1, 4, 9 and 16 dots. Each square is the one before it plus an L-shaped layer of 3, 5 and 7 dots.

Will it hold for every n? Here is the climbing step. Suppose the first n odd numbers add up to n×n. The next odd number is 2×n + 1. For n = 3 the next odd number is 7, and 2×3 + 1 = 7. So the first n + 1 odd numbers add up to n×n + 2×n + 1. That is exactly (n+1)×(n+1). Check with n = 3: 9 + 7 = 16 = 4×4.

The claim holds for the first number, and the step works for every n. So the claim holds for every n. Notice that the step only says "if it holds for n". It never asks us to know that it does. The dominoes do that work, one after another.

Checking is not enough

Checking 1, 2, 3 and 4 is not a proof. It only gives hope. The number n×n + n + 41 is a prime (no divisors except 1 and itself) for n = 0, 1, 2 and so on, all the way up to 39. At n = 40 it gives 1681, and 1681 is 41×41. Forty good cases proved nothing. The first step and the climbing step cover every case at once, with no gaps.

Careful

Checking many cases is not a proof. Only the first step together with the climbing step covers every case.

Try it at home

  1. Add the first five odd numbers, 1 + 3 + 5 + 7 + 9. Is the sum 5×5?
  2. In your notebook, draw dots in squares of 1, 4 and 9. Colour the L-shaped layer added each time.
  3. Explain in one sentence why pushing the first domino is not enough without the climbing step.

Words to know

  • proof by climbing - a proof that a claim holds for every number: the first step, then the climbing step (also called induction)
  • first step - showing the claim for the first number
  • climbing step - showing that if the claim holds for n, it holds for n plus one

Big idea

To prove a claim for endlessly many cases, show it for the first, and show that each case leads to the next.

Lesson page →

Climbing the Formula Tree

Every formula is built from letters by a few rules, one step at a time. There are endlessly many formulas, so we cannot check them one by one. Yet logicians say things about every formula at once. How?

The same climb, on a tree

Recall the building rules from What Counts as a Formula. A letter is a formula. If φ and ψ (read: phi and psi, any formulas) are formulas, then so are ¬φ, (φ ∧ ψ), (φ ∨ ψ), (φ → ψ) and (φ ↔ ψ). Nothing else is a formula.

So we can climb as in the last lesson, but along the tree. The first step: show the claim for every letter. Then one climbing step for each rule: if the claim holds for the parts, it holds for the whole. This is structural induction. Every formula is built by the rules from letters, so the claim holds for every formula.

The tree of the formula ¬P ∧ (Q ∨ R) with a tick on every node. A note beside the three letters reads first step, and a note beside the other nodes reads climbing steps.

Be careful to cover every rule. A proof that forgets the rule for ¬ says nothing about ¬P.

Example 1: the brackets

Claim: in every formula written with its full brackets, the number of opening brackets equals the number of closing ones.

First step: a letter has no brackets, so 0 and 0. Now the steps. ¬φ has the same brackets as φ, so the counts stay equal. For (φ ∧ ψ), say φ has a opening and a closing brackets, and ψ has b and b. The new formula has a + b + 1 opening and a + b + 1 closing ones, still equal. The rules for ∨, → and ↔ are the same. So the claim holds for every formula.

A check: ((P ∧ Q) → ¬R) has two opening and two closing brackets.

Example 2: one value in every row

Claim: in every row of a truth table, every formula gets exactly one value, T or F. This is why truth tables always work.

First step: in a row, each letter is given T or F, exactly one. Step for ¬φ: φ has one value, and the table of ¬ turns it into one other value. Step for (φ ∧ ψ): φ has one value and ψ has one. The table of ∧ gives one answer for each pair, so the whole has one value. The same for ∨, → and ↔.

The tree of ¬P ∧ (Q ∨ R) in the row P true, Q false, R true. Each node shows its value: P is T, the ¬ above it is F, Q is F, R is T, the ∨ is T and the ∧ at the top is F.

This is the idea of the proof. The full proof is longer only because it lists every rule in the same way.

Careful

Every building rule needs its own step. Skip one and the proof has a hole.

Try it at home

  1. Write the formula ¬(P → Q) with full brackets, and count its opening and closing brackets.
  2. Draw its tree. Take the row P true, Q false, and write the value of every node.
  3. Explain why the proof about brackets needs a separate step for each rule.

Words to know

  • structural induction - a proof that a claim holds for every formula: first the letters, then each building rule
  • formula tree - a picture of how a formula was built, with its main connective at the top

Big idea

To prove something about every formula, show it for the letters, and show that each building rule keeps it true.

Lesson page →

Enough Connectives

A friend says: "I want exactly one of the two: tea or coffee, not both." We have no symbol for that. Must we invent one? Or can the symbols we have already say it - and say any other table too?

From a table to a formula

Here is the table we want, for "exactly one of P and Q".

PQexactly one of P and Q
TTF
TFT
FTT
FFF

Look at each row with T in the last column. For the row P true, Q false, write a row-formula: P ∧ ¬Q. It is true in that row and in no other. For the row P false, Q true, write ¬P ∧ Q. Now join the row-formulas with ∨: (P ∧ ¬Q) ∨ (¬P ∧ Q).

The truth table for exactly one of P and Q. The two rows with T are circled, and beside them are their row-formulas, P and not Q, and not P and Q, joined by or.

Check all four rows. Row TT: P ∧ ¬Q is false and ¬P ∧ Q is false, so F. Row TF: the first is true, so T. Row FT: the second is true, so T. Row FF: both are false, so F. The formula gives exactly the table.

Any table at all

This works for any table. For each row with T, write the letters that are true as they are, and the letters that are false with ¬. Join them with ∧. A row with P true, Q false, R true gives (P ∧ ¬Q) ∧ R. It is true in that row only. Then join all the row-formulas with ∨. The result is true exactly in the rows with T.

What if no row has T? Then the table is false everywhere. The formula P ∧ ¬P does that: it is false when P is true, and false when P is false.

A drawing with a box of not, and, or in the middle. Arrows run out of it to if-then and if-and-only-if, each with the formula that replaces it. Below, or is written with not and and.

So ¬, ∧ and ∨ are enough: every truth table can be written with them.

The others were shortcuts

Then → and ↔ were shortcuts all along. P → Q has the same table as ¬P ∨ Q: both are false only in the row P true, Q false. And P ↔ Q is the same as (P → Q) ∧ (Q → P).

We can do even better. By De Morgan's rule from Level 4, P ∨ Q has the same table as ¬(¬P ∧ ¬Q). So ¬ and ∧ alone are enough. Careful: the row-formulas give a correct formula, not always the shortest one.

Careful

"Enough" is about what can be said, not about how short it is. Shortcuts are still useful to read.

Try it at home

  1. Write the table for "P or Q, but not both" in your notebook. Is it the same as "exactly one"?
  2. Make a table for "P and Q have the same value". Write its row-formulas and join them.
  3. Check in a table that P → Q and ¬P ∨ Q agree in all four rows.

Words to know

  • row-formula - a formula made to be true in one chosen row and false in all others
  • enough - a set of connectives is enough when every truth table can be written with it

Big idea

Every truth table can be written with ¬, ∧ and ∨ alone, so the other connectives are only shortcuts.

Lesson page →

One Connective Is Enough

A chip maker wants to make a million chips. Each kind of gate costs money to design. Could a single kind of gate build all the others? Is one connective enough for everything?

A new connective: NAND

Write P ↑ Q, read "P nand Q". It means "not both P and Q". Its table is false only when both are true.

PQP ↑ Q
TTF
TFT
FTT
FFT

It is also called the Sheffer stroke, after Henry Sheffer, who showed in 1913 what it can do. Charles Peirce had seen it about 1880.

Building ¬ and ∧ from it

First ¬. Use P twice: P ↑ P. If P is true, then "not both P and P" is false. If P is false, it is true. So P ↑ P is the same as ¬P.

Two wiring drawings. On the left, one NAND box with both inputs coming from P, and the output labelled not P. On the right, two NAND boxes in a row, giving P and Q.

Now ∧. Take (P ↑ Q) ↑ (P ↑ Q). The inside P ↑ Q is "not both". Using it twice turns it into "not not both", which is "both". Check the four rows. TT: inside F, then F ↑ F is T. TF: inside T, then T ↑ T is F. FT: the same, F. FF: inside T, so F. That is the table of ∧.

So ¬ and ∧ come from ↑ alone. By the last lesson, ¬ and ∧ are enough for every table. So one connective is enough. Chips are built this way: whole computers can be made from NAND gates only.

Not every connective is enough

Can we use ∧ alone? No. Look at the row where every letter is true. A formula made only with letters and ∧ is true in that row: a letter is true, and (φ ∧ ψ) is true when both parts are. We can prove it by climbing the formula tree. But ¬P is false in that row. So no formula with only ∧ has the table of ¬P.

A small tree with four leaves, all P, joined by and, each node marked T. Beside it stands not P marked F, with a crossed arrow between them.

The same holds for ∨ alone. NAND is special because it can turn a true into a false.

Careful

A connective being enough is special. ∧ alone is not enough, because it can never turn all-true into false.

Try it at home

  1. Make the table of P ↑ P in your notebook. Is it the table of ¬P?
  2. Check (P ↑ P) ↑ (Q ↑ Q) in all four rows. Which connective is it?
  3. Draw gates as boxes with arrows, and wire three NAND boxes to make ∧.

Words to know

  • NAND - not both: P ↑ Q is false only when P and Q are both true
  • Sheffer stroke - the sign ↑ for NAND, after Henry Sheffer (1913)

Big idea

The single connective NAND can build ¬ and ∧, so it can build every truth table.

Lesson page →

Soundness: Proofs Never Lie

Proofs Never Lie

You build a proof, line by line, with the rules from Level 4. You reach a conclusion. But should you believe it? A proof is only a pile of steps that follow rules. Why should following rules ever lead to something true? That is the question of this lesson.

What soundness says

Level 4 gave us proofs. Level 3 gave us truth tables. They are two different things (see Two Kinds of Follows). Write Γ ⊢ φ when φ can be proved from the premises Γ. Write Γ ⊨ φ when φ is true in every row where all of Γ is true. (Γ is read "gamma": a list of premises. φ is read "phi": any formula.)

A proof system is sound when every proof gives a true result. In symbols: if Γ ⊢ φ, then Γ ⊨ φ. Whatever the rules prove really follows. Proofs never lie.

Two boxes joined by an arrow. The left box says Γ ⊢ φ, a proof exists. The right box says Γ ⊨ φ, every row that makes Γ true makes φ true. The arrow between them is labelled soundness.

This is a claim about the whole system, seen from outside. We cannot just hope it is true. We must check it.

Checking one rule

Every proof is made of rules. If each rule is safe, then every proof is safe. So we check the rules, one at a time, with a small table. Take →E: from P → Q and P, write Q. The rule is safe if no row has P → Q true, P true and Q false.

A truth table for P, Q and P → Q with four rows. The first row, where P and Q are both true, is circled. It is the only row where P and P → Q are both true, and Q is true there too.

Look at the table. P is true only in rows 1 and 2. In row 2, P → Q is false. So row 1 is the only row with both premises true, and Q is true there. No row breaks the rule. →E is safe. The other rules pass the same kind of check. For example ∧E: from P ∧ Q write P. The only row with P ∧ Q true has P true.

A rule that fails

Now invent a rule. From P → Q and Q, write P. It looks like →E, but it is not. Try the table again. Row 3 has P false and Q true. Then P → Q is true, Q is true, and P is false. This row breaks the rule.

The same truth table with the third row circled in red, where P is false and Q is true. Both P → Q and Q are true there, but P is false.

With this rule the system would prove P from P → Q and Q. In words: "If it rained, the grass is wet. The grass is wet. So it rained." The sprinkler may have done it. A system with this rule would not be sound. Soundness means every rule passes its table.

Be careful: this lesson checks single rules. Rules with boxes need more care, and that is the next lesson. The full proof of soundness is longer. This is the idea.

Careful

Same word, different idea. In Level 1 a sound argument is valid with true premises. A sound proof system is one whose proofs are all valid. The first is about one argument. The second is about a whole system.

Try it at home

  1. Check ∨I with a table: from P, write P ∨ Q. Is there a row with P true and P ∨ Q false?
  2. Invent a bad rule: from P ∨ Q, write P. Find the row that breaks it.
  3. Write one sentence saying why a bad rule would make a proof system unsound.

Words to know

  • sound (proof system) - every argument it proves is valid: if Γ ⊢ φ then Γ ⊨ φ
  • Γ (gamma) - a list of premises
  • safe rule - a rule with no row where the lines it uses are true and the line it writes is false

Big idea

A proof system is sound when each rule is safe, so whatever is proved really follows.

Lesson page →

Checking Every Step

A proof can have fifty lines, or five hundred. There are endlessly many proofs. We cannot check each one with a table. Yet we want to say: every proof, of any length, is safe. How can we be sure of that?

Climbing along the lines

We use the climbing idea from earlier in this course, but along the lines of a proof. The claim is this. Each line is true in every row where the premises, and any assumptions still open, are all true. Here a row means one row of a truth table.

The first step: a line that is a premise, or an assumption, is true in such a row. The climbing step: a later line comes from earlier lines by a rule. The earlier lines are true. The rule is safe (last lesson). So the new line is true. Climb to the last line. It is the conclusion, and no assumption is open. So it is true in every row where the premises are true. That is Γ ⊨ φ.

A proof of P → R from P → Q and Q → R. Lines 1 and 2 are premises. Lines 3 to 5 are inside a box with the assumption P. Line 6 is P → R, written after the box closes. Lines 4 and 5 are highlighted.

The step that closes a box

Look at the proof in the picture. Lines 4 and 5 sit in the box, so P is an open assumption. They are true only in rows where the premises are true and P is true. They are not true in every row with true premises. Take a row where the premises are true and P is false: then lines 4 and 5 may be false.

Line 6 closes the box (→I). Is it safe? Take any row where the premises are true. If P is false there, P → R is true at once. If P is true there, lines 3 to 5 are true, so R is true, and P → R is true. Either way line 6 is true. The assumption is gone, and the line is true anyway. That is why closing a box is safe.

Two cases for line 6. In the first case P is false, so P → R is true. In the second case P is true, so the lines in the box are true, R is true, and P → R is true.

Why the name must be new

Level 5 said: ∀I needs a new name. Soundness shows why. Key: Domain: people; Tx: x is tall. Say the premise is Ta. Someone writes ∀x Tx by ∀I, with the name a. That breaks the rule, because a is in a premise, so it is not new.

A world with two people, a and b. Person a has the tag T for tall. Person b has no tag. The premise Ta is true, but the claim for every x, Tx, is false.

In this world the premise is true and the conclusion is false. A rule that allows that is unsound. The new-name condition stops it. It is not decoration. It is what keeps ∀I safe.

Be careful: this is a sketch. A full proof checks every rule in this way, including ∨E, ¬I and ∃E. It takes longer, but it is the same idea.

Careful

Lines in a box are not true in every row where the premises are true. They are true where the premises and the open assumptions are true.

Try it at home

  1. Take the proof in the lesson. Pick a row where P is false and the premises are true. Which lines in the box are false there?
  2. Make a world with two people where Ta is true but ∀x Tx is false. Draw it.
  3. Say in your own words: why can a box line be false in a row where the premises are true?

Words to know

  • open assumption - an assumption whose box has not been closed yet
  • climbing along the lines - showing a claim for the first line, then that each line keeps it
  • new name - a name that is not in any premise or open assumption

Big idea

Soundness is shown by climbing along the lines of a proof: each rule keeps truth, and closing a box is safe.

Lesson page →

Why No Proof Exists

You try to prove an argument for an hour, and fail. Maybe you are not clever enough. Maybe no proof exists. How could you ever be sure that none exists? There are endlessly many proofs to try.

Failing is not knowing

Write Γ ⊬ φ when φ cannot be proved from Γ. (The stroke through ⊢ means not.) To show this, we cannot try every proof. There are endlessly many. A hard search that ends with nothing tells us only about us.

There is a better way. Soundness says: if Γ ⊢ φ, then Γ ⊨ φ. Turn it round. If Γ ⊭ φ, then Γ ⊬ φ. One bad row, or one counter-model, shows that no proof exists. One example is enough for all the endless proofs.

A chain of three boxes. The first says: one bad row or world. The arrow leads to a second box: Γ ⊭ φ. The next arrow, labelled soundness, leads to a third box: Γ ⊬ φ, no proof exists.

A bad row

Take P → Q, Q and the conclusion P. Could we prove it? Try the row where P is false and Q is true. Then P → Q is true, Q is true, and P is false. The premises hold and the conclusion fails. So P → Q, Q ⊭ P.

A truth table for P, Q and P → Q. The third row, where P is false and Q is true, is circled. In that row P → Q and Q are true and P is false.

By soundness, P → Q, Q ⊬ P. No proof exists, in any length, by any clever route. We did not search for proofs at all. We used one row.

A world for all and some

The same works for all and some. Key: Domain: animals in a pond; Dx: x is a duck; Fx: x is a frog. Argument: ∃x Dx, ∃x Fx, so ∃x(Dx ∧ Fx). Some animal is a duck, some animal is a frog, so some animal is both?

A small world with two animals, a and b. Animal a has the tag D for duck. Animal b has the tag F for frog. No animal has both tags.

Take a world with two animals: a is a duck, b is a frog. The premises are true. No animal is both, so the conclusion is false. This is a counter-model. By soundness, no proof exists.

Be careful: the other way round is not yet settled. If you find no bad row and no counter-model, that does not tell you a proof exists. Counter-models can also be endless. A later module says more.

Try it at home

  1. Show that P ∨ Q, P does not prove ¬Q. Find a bad row.
  2. Use the pond key. Make a world where ∃x Dx is true and ∃x Fx is false.
  3. Explain in two sentences why one bad row beats an endless search.

Words to know

  • ⊬ - not provable: no proof of the conclusion from the premises exists
  • counter-model - a world where the premises are true and the conclusion is false
  • bad row - a row where the premises are true and the conclusion is false

Big idea

One bad row or counter-model shows that no proof exists, because a sound system proves only what follows.

Lesson page →

A System That Never Clashes

Imagine a rule book that lets you prove "the door is open" and, a page later, "the door is not open". Such a book is useless. Can our proof system ever do that? And how can we be sure it never will?

A consistent system

Level 4 had the sign ⊥ (read "falsum"): a claim that is false in every row. A proof system is consistent when it cannot prove ⊥ from no premises. In symbols: ⊬ ⊥. It never clashes with itself.

Soundness gives this at once. Suppose ⊢ ⊥. By soundness ⊨ ⊥: ⊥ would be true in every row. But ⊥ is false in every row. So there is no proof of ⊥.

A truth table with the letter P and the sign ⊥. The column of ⊥ has F in both rows. A note says: a proof of ⊥ would need T in every row.

Why it matters

Suppose a system could prove ⊥. By explosion (from ⊥, anything), it could then prove every claim. It would prove "snow is white" and "snow is not white". A proof would tell us nothing, because everything would have a proof.

Two panels. The left panel, a consistent system, shows some claims proved and some not. The right panel, an inconsistent system, shows every claim proved.

Soundness protects us. Because the rules are safe, ⊥ is out of reach, and so is the flood of proofs after it. So proofs mean something.

Claims that fit together

Level 3 used the same word for claims. A set of claims is consistent if one row makes all of them true. Take P ∨ Q and ¬P. The row with P false and Q true makes both true. They are consistent.

A truth table for P and Q with columns P ∨ Q and ¬P. The row where P is false and Q is true is circled. Both columns have T in it.

Soundness also says: if one row makes all of Γ true, then Γ ⊬ ⊥. A proof of ⊥ from Γ would give Γ ⊨ ⊥. So that row would make ⊥ true. It cannot. So no proof of ⊥ exists from P ∨ Q and ¬P.

Be careful: the reverse, that every set without a clash has such a row, is a harder question. It comes in the next module. We do not claim it yet.

Careful

Two uses of one word. A consistent system is one that does not prove ⊥. A consistent set of claims is one that a row makes all true. They are linked, but not the same idea.

Try it at home

  1. Is the set P → Q, P, ¬Q consistent? Look for a row.
  2. Try to find a row making P ∧ Q and ¬P both true. What happens?
  3. Write one sentence: what goes wrong if a system can prove ⊥?

Words to know

  • ⊥ (falsum) - a claim false in every row
  • consistent (system) - it cannot prove ⊥ from no premises
  • consistent (claims) - some row or world makes all of them true

Big idea

A sound system is consistent, because ⊥ is false in every row and so can never be proved.

Lesson page →

Completeness: Every Truth Has a Proof

Can Every Truth Be Proved?

You meet an argument. You check the table: no row breaks it, so it is valid. Then you try to prove it with the rules, and an hour passes with no proof. Is a proof out there at all? Or does our proof system have a hole? That is the question of this lesson.

The other direction

Earlier in this course we met soundness: if Γ ⊢ φ, then Γ ⊨ φ. Read it again. Γ ⊢ φ says φ can be proved from Γ. Γ ⊨ φ says φ is true in every row, or world, where Γ is. (Γ is read "gamma", a list of premises. φ is read "phi", any formula.) Soundness says: a proof never lies.

Now turn the arrow round. Completeness says: if Γ ⊨ φ, then Γ ⊢ φ. Whatever follows, in the sense of the tables, can be proved. The system has no hole. Every valid argument has a proof.

Two boxes. The left box says Γ ⊢ φ, a proof exists. The right box says Γ ⊨ φ, true in every row. An arrow from left to right is labelled soundness. An arrow from right to left is labelled completeness.

Two roads, one place

Put the two together. Soundness and completeness say: Γ ⊢ φ exactly when Γ ⊨ φ. The set of arguments that have a proof, and the set of valid arguments, are the same set. One road goes by rules and lines. The other goes by rows and worlds. Both reach the same place.

Take P → Q, P so Q. The table says valid. One use of →E gives a proof. Now take P → Q, Q so P. The row with P false and Q true breaks it, so it is not valid. By soundness no proof exists. The two roads agree here, and completeness says they agree everywhere.

This was a real question. A system could be sound and still too weak: it might prove nothing at all. Completeness says ours is not too weak.

When and what for

Emil Post showed in 1921 that this holds for logic with letters and truth tables. Kurt Gödel showed in 1930 that it holds for logic with all and some too, with the proof rules of that level. Both results are theorems, with long proofs. The next lesson shows the idea of the first.

What does it give you? Say you are stuck on a proof of an argument you know is valid. Completeness tells you a proof exists. So keep looking.

A row of failed attempts, each marked with a red cross, then an arrow to a green box. The box says a proof exists, keep looking.

Be careful: completeness says a proof exists. It does not say the proof is short, or easy to find. It does not give a method either. It is a promise that the search is not hopeless.

Careful

Completeness says a proof exists, not that it is easy to find.

Try it at home

  1. Take P ∧ Q so P. Check it with a table. Then find a one-line proof. Do the two roads agree?
  2. Take P ∨ Q so P. Find the row that breaks it. What does soundness say about a proof?
  3. In your own words: what is the difference between soundness and completeness? Use the words "proof" and "row".

Words to know

  • complete (proof system) - every valid argument has a proof: if Γ ⊨ φ then Γ ⊢ φ
  • Γ (gamma) - a list of premises
  • φ (phi) - any formula

Big idea

Soundness and completeness together: a proof exists exactly when the argument is valid.

Lesson page →

The Idea Behind Completeness

Completeness says every valid argument has a proof. But how could anyone show that? We cannot list all proofs, or try all arguments. Here is the idea, for logic with letters, in four steps. It is a sketch: the full proof is longer.

Turn it round

We want: if Γ ⊨ φ, then Γ ⊢ φ. That says the same as: if Γ ⊬ φ, then Γ ⊭ φ. (⊬ means "cannot be proved". ⊭ means "some row makes Γ true and φ false".) So we start with no proof, and we must build a breaking row.

One bridge was left over from soundness. A set of claims is consistent when no proof of ⊥ starts from it. The bridge says: a consistent set has a row that makes all of it true. The sketch below builds that row.

Four boxes in a row joined by arrows. One: no proof of φ from Γ. Two: Γ with not-φ is consistent. Three: choose each letter, true or false, keeping the set consistent. Four: the row makes Γ true and φ false.

Step one: add the denial

Suppose Γ ⊬ φ. Add ¬φ to Γ. Is the new set consistent? Yes. If we could prove ⊥ from Γ and ¬φ, then a box that assumes ¬φ and reaches ⊥ would give φ by IP (the Level 4 rule for proof by contradiction). Then Γ ⊢ φ, and that is not so.

Take P ∨ Q so P. There is no proof. Our set is P ∨ Q, ¬P. It is consistent.

Step two: choose the letters

Go through the letters one by one. For each letter, add the letter or its negation, whichever keeps the set consistent. One of the two always does. Why? If adding Q gave ⊥, and adding ¬Q gave ⊥ too, then the set before already proves ¬Q and ¬¬Q. That is ⊥, and the set was consistent.

In our example, take P first. Adding P gives ⊥ at once, because ¬P is there. So we keep ¬P. Now Q. Adding ¬Q gives ⊥: from P ∨ Q and ¬P we prove Q, which clashes. So we add Q.

Two rows of choices. For the letter P, the choice P is crossed out in red and the choice not-P is kept in green. For the letter Q, the choice not-Q is crossed out in red and the choice Q is kept in green.

Step three: read off the row

The choices say: P false, Q true. In this row P ∨ Q is true and ¬P is true. So P is false. This row makes the premise true and the conclusion false. It breaks the argument: P ∨ Q ⊭ P.

In general the row makes every formula of the set true, so it makes Γ true and φ false. That every formula comes out true takes one more climb up the formula tree. We skip it here. So Γ ⊭ φ, and completeness follows.

Be careful: this is the idea, for letter logic only, and the full proof is longer. Leon Henkin used this style of proof in 1949 for all and some (optional to remember).

Try it at home

  1. Take P → Q, ¬Q so ¬P. Is it valid? The set to test is P → Q, ¬Q, ¬¬P. Does a row make all three true?
  2. Take P ∨ Q so P. Write the set P ∨ Q, ¬P. Say in your own words why adding ¬Q would give ⊥.
  3. Say in one sentence why we add the denial of φ at the start.

Words to know

  • consistent (set) - no proof of ⊥ starts from it
  • ⊬ - cannot be proved
  • ⊭ - some row makes the premises true and the conclusion false

Big idea

If there is no proof, add the denial of the conclusion, choose the letters one by one, and read off a row that breaks the argument.

Lesson page →

Trees That Hunt Counter-Models

A truth table with ten letters has 1024 rows. A proof needs a clever idea. Is there a neat method that hunts for a breaking row, and shows you one when it finds it? There is. It looks like a tree on its side, and it is the subject of this lesson.

Start with the denial

A truth tree tests an argument. Write the premises in a list. Add the denial of the conclusion, ¬ and the conclusion. Now ask: can all lines be true together? If they can, the argument is broken. If they cannot, it is valid.

To find out, break each line into simpler lines, by these rules. Read ¬φ as "not φ".

LineWhat we write
φ ∧ ψboth φ and ψ, one under the other
φ ∨ ψsplit in two: φ on one branch, ψ on the other
φ → ψsplit: ¬φ on one branch, ψ on the other
¬(φ ∧ ψ)split: ¬φ on one branch, ¬ψ on the other
¬¬φjust φ

Two more rules exist: ¬(φ ∨ ψ) gives ¬φ and ¬ψ together, and ¬(φ → ψ) gives φ and ¬ψ together. Each rule says how a line can be true. An ∨ is true if one side is, so the tree splits.

A branch that closes

Take P → Q, P so Q. The list is P → Q, P, ¬Q. Break P → Q: the tree splits into ¬P and Q.

A truth tree. The top holds three lines: P → Q, P and not-Q. Two branches go down. The left branch holds not-P and has a red cross. The right branch holds Q and has a red cross.

A branch is one path from the top to the bottom. The left branch holds P and ¬P. That cannot be true, so we mark the branch with ✗: it is closed. The right branch holds Q and ¬Q. It is closed too. Every branch is closed, so no row makes the whole list true. The argument is valid.

A branch that stays open

Now take P → Q, Q so P. The list is P → Q, Q, ¬P. Break P → Q: the tree splits into ¬P and Q.

A truth tree. The top holds three lines: P → Q, Q and not-P. Two branches go down. The left branch holds not-P and the right branch holds Q. Both are marked open in green.

Look at the left branch. Its lines are Q, ¬P and ¬P. No letter clashes with its negation, and nothing is left to break. This branch is open. Read it off: P false, Q true. In that row P → Q is true, Q is true, P is false. A counter-row, and the argument is not valid. The right branch gives the same row.

Evert Beth gave this method in 1955. Raymond Smullyan made it popular in 1968. Be careful: an open branch counts only when every line on it is broken down.

Try it at home

  1. Make the tree for P ∨ Q, ¬P so Q. The list is P ∨ Q, ¬P, ¬Q. Does every branch close?
  2. Make the tree for P → Q so Q → P. Break ¬(Q → P) into Q and ¬P. What does the open branch say?
  3. Check your counter-row in a truth table.

Words to know

  • truth tree - a test that breaks lines down to find a row that makes the premises true and the conclusion false
  • closed branch - a branch with a letter and its negation; marked ✗
  • open branch - a finished branch with no clash; it gives a counter-row

Big idea

Break the premises and the denied conclusion into pieces: if every branch closes the argument is valid, and an open branch gives a counter-row.

Lesson page →

Trees for All and Some

Trees found breaking rows for letters. Can the same method handle ∀ and ∃, where a world can have endlessly many things? It can, with two new rules. And one tree will teach us that a method can be good and still never stop.

Two new rules

Key for this lesson: Domain: animals; Dx: x is a dog; Bx: x barks; r: Rex. The tree keeps the old rules and adds two.

Using some. A line ∃x Dx says some animal is a dog. We do not know which one. So write Da with a new name a, a name not yet on the branch. It is the same care as ∃E in the proofs of Level 5.

Using all. A line ∀x(Dx → Bx) is true of every animal. So write its instance for every name on the branch: Dr → Br, and Da → Ba if a is on the branch too. A name that arrives later gets its instance too. An all-line is never used up.

A tree that closes

Take ∀x(Dx → Bx), Dr so Br. The list is ∀x(Dx → Bx), Dr, ¬Br. Only the name r is on the branch. Using all gives Dr → Br. That line splits into ¬Dr and Br.

A truth tree. The top holds four lines: for every x, Dx → Bx; Dr; not-Br; and Dr → Br. Two branches go down. The left branch holds not-Dr and has a red cross. The right branch holds Br and has a red cross.

The left branch has Dr and ¬Dr: closed. The right branch has Br and ¬Br: closed. All branches are closed, so no world makes the premises true and Br false. The argument is valid.

An open branch gives a world

Take ∃x Dx so Br. The list is ∃x Dx, ¬Br. Using some gives Da, with a new name a. Nothing is left to break, and nothing clashes. The branch is open.

A world with two animals, a and r. Animal a has the tag D, for dog. Animal r has no tags. Beside it a note says: some animal is a dog, but Rex does not bark.

Read the world off the branch. It has the things a and r. The thing a is a dog. The thing r does not bark. Now ∃x Dx is true, because a is a dog, and Br is false. A counter-model, and the argument is not valid.

A tree that never ends

Level 5 had this argument. Key: Lxy: x is less than y. Premises: every thing has something bigger, and "less than" chains. Conclusion: some thing is less than itself. Start with a name a. The first premise gives ∃y Lay, so we add Lab with a new name b. For b it gives ∃y Lby, so we add Lbc with a new name c. Then d, then e.

A chain of circles a, b, c, d with an arrow from each to the next, and three dots after. Each new circle comes from using the all-line on the one before.

Each new name brings a new ∃, which brings a new name. If we follow the rules, the tree keeps growing and never finishes. That fits Level 5: this argument is broken only by an endless world. So a tree can run for ever. What that means for every method is the next question.

Be careful: for letters a tree always ends. With ∀ and ∃ it may not.

Careful

An all-line is never used up: write it again for each name that appears later.

Try it at home

  1. Take ∀x(Dx → Bx) and Dr, and write the lines of the tree again on paper. Which name does the all-line use?
  2. Take ∃x Dx and ∃x Bx so ∃x(Dx ∧ Bx). Using some twice needs two different names. Why?
  3. Draw the chain a, b, c, d, and say why the tree for the endless argument keeps growing.

Words to know

  • new name - a name not yet on the branch, used when we use a some-line
  • every name - an all-line is written for each name on the branch
  • counter-model - a world that makes the premises true and the conclusion false

Big idea

With all and some, a tree uses a new name for some and every name for all, and it may never end.

Lesson page →

What a Machine Can Decide

A Test That Always Answers

A friend gives you an argument with ten letters. Is it valid? You could try the rows by hand, but that is slow. So you ask: can a machine do it? Can a machine always give an answer, for every argument of this kind, yes or no? That is the question of this lesson.

What a test must be

Think of a machine as a box. A question goes in. An answer comes out. For a test to count, three things must be true. The steps are exact: no guessing, no feeling. It works for every question of one kind. And it always stops, with yes or no. Such a method is a decision procedure. (It is an algorithm.)

The kind of question here: "Is this argument valid?", for arguments made of sentence letters and ¬ ∧ ∨ → ↔. If a decision procedure exists for a kind of question, we call the kind decidable.

A rounded box labelled test. An arrow goes in from the left, labelled any argument in letters. An arrow goes out to the right, labelled yes or no, and always.

The truth table is one

In Level 3 we tested validity by a table. List every row. In each row, check: are all premises true and the conclusion false? If some row does that, the argument is not valid. If none does, it is valid. The steps are exact. The list of rows is finite. So the test always stops.

How many rows? One letter gives 2 rows. Two letters give 4. Three give 8. Each new letter doubles the rows. So n letters give 2ⁿ rows. Ten letters give 1024. Twenty letters give 1,048,576. That is a lot, and a person would give up. But a machine works through them and stops.

A table with three columns: letters, rows and a bar. One letter gives 2 rows, two letters 4, three letters 8, four letters 16, ten letters 1024. The bars grow longer each time.

So validity in letter logic is decidable. Slow does not mean undecidable. A test that takes a year still counts, if it surely stops.

Checking is not finding

Now take a proof, as in Level 4: numbered lines, each with a rule. Someone hands you a proof and asks: is it correct? Look at each line. Does its rule fit the lines it names? There are finitely many lines, and each check is exact. So checking a given proof is decidable too.

Finding a proof is a different question. Which line do you write next? No rule of the system says. That is the question of the rest of this module: for which kinds of question can a machine always answer?

Careful

Slow is not the same as undecidable. A very long test still counts if it surely stops.

Try it at home

  1. Take P → Q, P so Q. How many letters? How many rows? Write the rows and decide: valid or not.
  2. How many rows does a table with 5 letters have? And one with 6? What happens to the number when you add one letter?
  3. Think of a question with no exact steps, like "Is this poem beautiful?". Which of the three needs does it fail?

Words to know

  • decision procedure - a method with exact steps, for every question of one kind, that always stops with yes or no
  • decidable - a kind of question is decidable if some decision procedure answers every question of that kind
  • 2ⁿ - two multiplied by itself n times: the number of rows for n letters

Big idea

A decision procedure always stops with yes or no. Truth tables decide validity for letter logic.

Lesson page →

The Diagonal Trick

Write a list. The first item is an endless row of 0s and 1s. So is the second, and the third, and on without end. A friend says: whatever list you write, I can make a row that is not on it, and I do not need to see the whole list. How can that be? That is the question of this lesson.

An endless list of endless rows

An endless row is a string of 0s and 1s that never ends, like 0 1 0 0 1 .... A list of them has a first row, a second row, a third row, and so on, one for each counting number (see natural numbers). Here are the first five rows of some list.

A list of five endless rows of 0s and 1s, numbered 1 to 5, each with three dots at the end. Row 1 is 0 1 0 0 1, row 2 is 1 1 0 1 0, row 3 is 0 0 0 1 1, row 4 is 1 0 1 1 0, row 5 is 1 1 0 0 0.

Walk the diagonal and flip

Now build a new row. Look at place 1 of row 1: it is 0. Look at place 2 of row 2: it is 1. Place 3 of row 3: 0. Place 4 of row 4: 1. Place 5 of row 5: 0. These places run down a diagonal. Flip each digit: 0 becomes 1, and 1 becomes 0. The new row starts 1 0 1 0 1, and goes on in the same way down the whole list.

The same five rows, with the diagonal digits circled: 0, 1, 0, 1, 0. Below the list is the new row 1 0 1 0 1, each digit the flip of the circled one above it.

Is the new row on the list? It is not row 1: at place 1 it has 1, and row 1 has 0. It is not row 2: at place 2 it has 0, and row 2 has 1. In general, it differs from row n at place n. So it is not row n, for any n. The list misses it. And the list was any list we liked. So no list of endless rows holds them all.

What it shows, and where it returns

Georg Cantor found this in 1891. Counting numbers can be put in a list, and so can the even numbers. But the endless rows of 0s and 1s cannot. Some endless collections are bigger than the counting numbers. Be careful: this does not say every endless collection is bigger. It says this one is.

The trick is more than a fact about rows. Take everything on a list, walk the diagonal, change each item. It returns three times later in this course: in a program that no one can write, in a set that cannot exist, and in a sentence about its own proof.

A box labelled the diagonal trick, with three arrows to three boxes: a program that cannot exist, a set that cannot exist, and a sentence that says it cannot be proved.

Careful

The trick shows that this collection cannot be listed. It does not say every endless collection is too big to list.

Try it at home

  1. Write four rows of four digits. Walk the diagonal, flip it, and write the new row. Check it differs from each row.
  2. Change one row of your list, but not the diagonal digit. Does the new row change?
  3. Write the counting numbers 1, 2, 3 ... next to the even numbers 2, 4, 6 ... Can you pair each with one? Why is that a list?

Words to know

  • endless row - a string of 0s and 1s that never ends
  • diagonal - place 1 of row 1, place 2 of row 2, place 3 of row 3, and so on
  • flip - change 0 to 1 and 1 to 0

Big idea

Walk the diagonal and flip each digit: the new row differs from every row on the list, so no list holds all endless rows.

Lesson page →

The Program That Cannot Exist

Your phone app freezes. Is it thinking hard, or is it stuck for ever? You wish for a checker: give it any program and its input, and it tells you "stops" or "loops". Could such a checker exist? That is the question of this lesson.

The question

A program, given an input, either stops after some steps, or loops: it runs for ever (see loops). The halting problem asks: given a program and an input, which one happens? Some cases are easy. A program that prints "hello" and ends stops. A program that says "repeat for ever" loops.

But we want one method for all programs and all inputs. In 1936 Alan Turing showed that there is none. A program is only text, so it can be the input of another program, even of itself, as an editor can open its own file. The proof uses that.

A rounded box labelled Stopper. Two arrows go in from the left, labelled a program and its input. Two answers come out on the right, stops and loops.

Suppose Stopper exists

Suppose someone has built Stopper. Given any program and input, it always stops, and it always answers "stops" or "loops" correctly. Now we use Stopper to build a new program, Contrary. Contrary takes a program p. It asks Stopper: "Does p stop when its input is p itself?"

Then Contrary does the opposite. If Stopper says "stops", Contrary loops for ever. If Stopper says "loops", Contrary stops at once.

A large box labelled Contrary. Inside it is the box Stopper, with an arrow in from p and an arrow out. A small box after Stopper reads: if stops then loop, if loops then stop.

Run Contrary on itself

Now give Contrary to itself. Stopper must say what Contrary does on that input. Suppose it says "stops". Then Contrary loops for ever, so Stopper was wrong. Suppose it says "loops". Then Contrary stops, so Stopper was wrong again.

Two rows. In the first, Stopper says stops, and Contrary loops, marked wrong in red. In the second, Stopper says loops, and Contrary stops, marked wrong in red.

Both answers are wrong. But Stopper was said to be always right. So Stopper cannot exist. Contrary is easy to build once Stopper exists, so the thing that cannot exist is Stopper. This is the diagonal trick: Contrary differs from every program p on the input p.

Be careful. This does not say we can never tell if a program stops. We can for many. It says there is no single method that answers correctly for every program and input.

Careful

This does not say that no program can be known to stop. It says no single method works for all.

Try it at home

  1. Write a one-line program that stops, and one that loops for ever. Could you tell which is which? Say how.
  2. In the story, what does Contrary do if Stopper says "stops" about it? And if Stopper says "loops"?
  3. In your own words: why does the story end with Stopper, and not Contrary, being impossible?

Words to know

  • halting problem - tell, for any program and input, whether it stops or loops for ever
  • loops - runs for ever and never gives an answer
  • Contrary - the program built from Stopper that does the opposite of what Stopper says about it

Big idea

No program answers "stops or loops?" correctly for every program and input: Contrary, run on itself, defeats any Stopper.

Lesson page →

No Test for All and Some

For letter logic, a table always answers. Now take arguments with all and some. Earlier we met one whose only breaking world is endless. Can a machine test every argument in that logic, as the table does for letters? And if not, what can a machine still do? That is the question of this lesson.

No machine for all and some

In 1936 Alonzo Church and Alan Turing each showed this: no decision procedure tells, for every argument with all and some, whether it is valid. The idea is short. The halting problem can be written as an argument in this logic. A method that answered every such argument would then answer the halting problem, and we know none does. The full proof is longer.

Be careful. This does not say that we can settle no argument. Many we settle, by a proof or by a small counter-model. It says there is no single method that settles every one.

Two boxes. The left box, letter logic, says a table always answers yes or no. The right box, all and some, says no method always answers. Yes comes with a proof, but no may never come.

Half a test

Something is still possible. A proof is a finite list of lines, and checking one is decidable. So a machine can write all lists of lines, one after another, and check each. By completeness, a valid argument has a proof. So for a valid argument the machine reaches it, and answers yes.

For an argument that is not valid, no proof exists. The machine goes on and on. Silence tells you nothing: a proof might come in the next minute. This is half a test: the yes answers always come, but the no answers may never come.

Two rows of boxes. The top row, a valid argument, shows tries marked with red crosses, then a green tick: yes. The bottom row, an invalid argument, shows tries marked with red crosses going on for ever, with three dots.

The tree that never ends

Remember the truth tree for the argument about "less than", where every thing has something bigger. Each new name needs another, so the tree adds a, b, c ... and never closes and never ends. That fits the half test: for this argument no finite search says no. Some invalid arguments have a small breaking world, and a search can find it. This one has none.

So the map is this. Letter logic is decidable. All and some is only half decidable.

Careful

No answer yet is not the same as no. The machine may simply not have reached the proof.

Try it at home

  1. Say the half test in your own words: when do you get an answer, and when may you wait for ever?
  2. A machine has run for a week on an argument and found no proof. May you say the argument is not valid? Why?
  3. Name the two logics of this lesson. For each, say what a machine can promise.

Words to know

  • half a test - a test where yes always comes in time, but no may never come
  • Church and Turing 1936 - no single method decides validity for all and some
  • completeness - every valid argument has a proof

Big idea

No machine decides every argument with all and some, but a machine listing proofs finds one for each valid argument.

Lesson page →

Paradox and Gödel

This Sentence Is False

A man says: "What I am saying now is false." Is he telling the truth? If he is, then what he says holds, so it is false. If he is not, then it is not false, so it is true. Something is wrong, and it is not a trick of words. What exactly goes wrong? That is the question of this lesson.

The loop

Take the sentence L: "This sentence is false." It talks about itself. People have known puzzles like it since Eubulides, in the 4th century BC. It is called the liar paradox. A paradox is a short argument from steps that look fine to a result that cannot be.

Try both answers, as in Level 4 when we assumed something and followed it. Suppose L is true. Then things are as it says, so L is false. Suppose L is false. Then things are not as it says, so L is not false: it is true. True leads to false, and false leads to true.

A box holding the sentence this sentence is false. A blue arrow labelled if true goes from the box to the word false, and an amber arrow labelled if false goes from there back to the word true. The two arrows make a loop.

Why it is not just a silly sentence

You might say: it is nonsense, ignore it. But the loop is made from two ideas that sound sensible. First: every claim is true or false, one of the two. Second: a language can say of its own sentences that they are true or false. Put them together, and L can be built. So one of the two must be given up, or limited.

Look at what L does. Earlier in this course we saw that a word between quotes names the word, and that mixing using and naming makes nonsense. L mixes them in a knot: it is a sentence, and it also speaks about itself, saying it has the value false.

Two boxes joined by a plus sign and an arrow to a third box. The first box says every claim is true or false. The second says a language can speak of its own truth. The third box says the liar sentence appears.

One answer: a language above

In 1933 Alfred Tarski gave one clear answer. Talk about the truth of sentences of a language only in a different language above it, a metalanguage, as we did with chess in the first lessons. Then "true" is a word of the language above. The sentence L would have to say about itself, in its own language, a word that only belongs to the language above. So L is not a sentence of the language it talks about, and the loop never starts.

Two levels, one above the other. The upper box is labelled the language that talks about truth. The lower box is labelled the language being talked about. An arrow goes down from the upper to the lower, and none comes back.

This is one answer, not the only one. Some logicians allow a third value, neither true nor false. Others accept some sentences that are both. We follow Tarski because it fits what this course does: logic studied from outside.

Careful

A paradox is not a proof that logic is broken. It shows two sensible ideas cannot both be kept without limits.

Try it at home

  1. Write your own self-talking sentence, such as "This sentence has five words." Is it true? Then try "This sentence has six words." Neither is a paradox. Why not?
  2. Say aloud the two answers for L: true gives false, false gives true. Write the loop on paper with arrows.
  3. Ask a friend: can a sentence be neither true nor false? Write down their reasons.

Words to know

  • paradox - steps that look fine lead to a result that cannot be
  • liar paradox - the sentence that says of itself that it is false
  • metalanguage - the language we use to talk about another language, here to talk about its truth

Big idea

The liar sentence is true only if false and false only if true. Tarski's answer: speak of truth only from a language above.

Lesson page →

The Set of All Ordinary Sets

In a village there is one barber. He shaves every man who does not shave himself, and no one else. Who shaves the barber? Try an answer, and it fails. That is a small story. The same shape, in 1902, broke a whole system of logic. How can a story about a barber break a system? That is the question of this lesson.

Who shaves the barber?

The rule says: the barber shaves a man if and only if that man does not shave himself. Does the barber shave himself? Suppose yes. Then he is a man who shaves himself, and the rule says he shaves only men who do not. So he does not. Suppose no. Then he is a man who does not shave himself, and the rule says he shaves such men. So he does.

A barber stands between two boxes. The left box says shaves himself, with a red cross. The right box says does not shave himself, with a red cross. Under the barber it says either answer contradicts the rule.

Both answers fail. The honest conclusion: there is no such barber. A village with this rule cannot exist. Nothing is wrong with logic here. The rule asked for the impossible.

The same shape with sets

A set is a collection of things. A set can be a member of another set. Most sets are not members of themselves. The set of all cups is not a cup. Call such a set ordinary: it is not a member of itself.

Now collect them. Let R be the set of all ordinary sets. Is R a member of R? Suppose yes. Then R is a member of itself, so it is not ordinary, but R holds only ordinary sets. So no. Suppose no. Then R is not a member of itself, so it is ordinary, and R holds every ordinary set. So yes. Either answer gives the opposite. This is Russell's paradox.

A large circle labelled R, the set of all ordinary sets. A small circle R sits outside it with a question mark. Two arrows lead away. If R is inside R, then R is not ordinary, so it is not inside. If R is outside R, then R is ordinary, so it is inside.

What it broke

In 1879 Gottlob Frege built the first modern system of logic. Later he used a rule for sets: any property gives a set of everything with that property. "Ordinary" is a property, so the rule gives R. In 1902 Bertrand Russell wrote to Frege and showed him this. The system proved a contradiction. By explosion, a system that proves a contradiction proves everything, so it says nothing.

The diagonal trick is in here. Look at any set S. By its definition, R holds S exactly when S does not hold S. So R differs from each set S in this one place: whether S is a member of S. Flip the diagonal, and you get a set that is on no list.

A small table. The rows are the sets A, B and C and the new set R. The columns are A, B and C. Along the diagonal, A does not hold A, B holds B and C does not hold C. The row for R shows the opposite on the diagonal: R holds A, does not hold B and holds C.

Modern set theory fixed this. It does not allow a set from any property alone. It only lets you pick out, from a set you already have, the things with a property. Then R cannot be formed.

Careful

The barber story shows there is no such barber. It does not show that sets are nonsense. Only the rule "any property gives a set" has to go.

Try it at home

  1. Write the barber's rule in one sentence. Then follow both answers on paper with a line for each.
  2. Find a village rule of your own with the same shape, like "the librarian lists every library that does not list itself". Does a librarian like that exist?
  3. Name three ordinary sets, such as the set of all cups. Why is each one not a member of itself?

Words to know

  • ordinary set - a set that is not a member of itself
  • Russell's paradox - the set of all ordinary sets is a member of itself exactly when it is not
  • member - a thing that belongs to a set

Big idea

The set of all ordinary sets cannot exist: either answer to "is it a member of itself?" gives the opposite. The same diagonal shape as the barber.

Lesson page →

True but Unprovable

Can a proof system for the whole numbers prove every true fact about them? In 1931 Kurt Gödel answered, and the answer surprised everyone. A good system, he showed, always leaves out a claim that is true. How can a claim be true, yet have no proof? That is the question of this lesson.

The claim, stated exactly

Be careful with the claim, because it is easy to say too much. Take a proof system for arithmetic, the facts about the whole numbers (see natural numbers). Three things must hold. It is consistent: it never proves a claim and its opposite. Its proofs can be checked by a machine, as in the lesson on decidability. And it can say the basic facts of adding and multiplying.

Then Gödel's first incompleteness theorem says: there is a sentence G in its language that is true of the whole numbers, but cannot be proved in the system. Notice the words. Not "cannot be known". Not "is false". It cannot be proved in this system.

Three boxes in a row, each with a tick. The first says consistent, never proves a claim and its opposite. The second says proofs can be checked by a machine. The third says it includes basic arithmetic. Below them an arrow leads to a box saying a true sentence G with no proof here.

The idea, in three steps

First, coding. Give every symbol a number, so every formula is a number, and every proof, being a list of formulas, is a number too. "This number codes a proof of that number" is then a fact about numbers, one a machine can check. So arithmetic can talk about its own proofs. The system now has a metalanguage inside itself.

Second, self-reference. With the diagonal trick, Gödel built a sentence G that says: "The sentence with this code has no proof in the system." The code is G's own code, so G says: "G has no proof." It is the liar sentence with "false" replaced by "unprovable". That is why it is no paradox: G talks about proofs, not about truth, and a machine can check a proof.

A row of three boxes joined by arrows. The first says code every formula and proof as a number. The second says build a sentence G that says G has no proof. The third says check what happens if G had a proof.

Third, the check. Suppose the system proved G. Then a proof of G exists, and the system can check that proof, so it can also prove "G has a proof", which is the opposite of G. The system would prove a claim and its opposite, so it would not be consistent. So if the system is consistent, G has no proof. And that is just what G says. So G is true. We showed this by thinking about the system from outside, which is what this course has been doing. The full proof takes care at every step; this is its idea.

What it does not say

It does not say mathematics is inconsistent. It needs consistency as a condition. It does not say truth is relative. G is simply true of the whole numbers. It does not say we can never learn G: we just did, from outside, as long as the system is consistent. If you add G as a new starting claim, you get a stronger system, and, if it is still consistent, it has a new unprovable sentence of its own. Gödel also showed a second theorem: such a system, if consistent, cannot prove its own consistency.

And completeness? In 1930 Gödel proved that every valid argument has a proof. Valid means true in every world. Now G is true in the whole numbers, but the system cannot prove it. So some strange world obeys all the system's starting claims and makes G false. So the argument from the system's starting claims to G is not valid. No clash: completeness is about valid arguments, incompleteness is about one system for the numbers.

Two worlds side by side. The left, the whole numbers, is labelled G is true. The right, a strange world, is labelled G is false. Both are labelled obey the same starting claims. Under them a note says so the argument to G is not valid, and no proof is needed.

Careful

Unprovable in this system is not unknowable, and it is not false. Do not let the word incomplete grow into more than it says.

Try it at home

  1. Write one sentence saying what "true but unprovable" does not mean. Use the words "in this system".
  2. Say aloud the three conditions for Gödel's theorem. Which one stops us from simply taking every true sentence as a starting claim?
  3. Compare the liar sentence and G in two lines. What is the one word that changes?

Words to know

  • consistent - never proves a claim and its opposite
  • coding - turning formulas and proofs into numbers, so arithmetic can talk about them
  • incomplete - some true sentence of the system's language has no proof in it

Big idea

In a consistent system for arithmetic whose proofs a machine can check, one sentence says it has no proof, and it is true. That is Gödel's 1931 result.

Lesson page →

The Whole Ladder

You have climbed six levels of logic. At the top we turned round and looked at the whole climb. What does logic do well? What can it never do? And what is left to ask? That is the question of this last lesson: what can logic do, and what can it not?

The six steps

Level 1 gave us good reasons: premises, a conclusion, valid or not, and the fallacies that only look good. Level 2 gave us hidden reasons, circle diagrams for all and some, and words that trick us. Level 3 gave us letters, the connectives and truth tables. Level 4 gave us proofs with rules. Level 5 gave us all and some, names and predicates. Level 6 turned logic on itself: is it sound, is it complete, can a machine decide it, and what can no system do?

A ladder of six steps drawn from the bottom up. The labels read good reasons, hidden reasons, letters, proofs, all and some, and logic about logic. A small arrow at the top points back down to the bottom.

What the results say

Each result was stated for one kind of logic. Here they are together.

LogicProofs never lie?Every truth has a proof?A machine decides?
LettersYes (sound)Yes (complete, Post 1921)Yes (truth tables)
All and someYes (sound)Yes (complete, Gödel 1930)Half (Church and Turing 1936)
ArithmeticIf its starting claims are trueNo (Gödel 1931)No (Church 1936)

A grid with three rows and three columns of ticks and crosses. Letter logic has a tick in sound, complete and decidable. All and some has a tick in sound and complete and a half tick in decidable. Arithmetic has a cross in complete and in decidable.

Said fairly, and what comes next

Said fairly: logic is not weak. Letter logic and all and some are sound and complete, which is a great result. Some questions cannot be settled by a machine: the halting problem. And a system for arithmetic always leaves a true sentence out. These are facts about what a system can do. They do not say logic fails, or that truth is only opinion.

Where does logic go next? Logics of "it is possible" and "it is necessary" (see possible and necessary). Logics with more than two truth values, for vague words. And a question logic cannot answer alone: do numbers exist?.

A last checklist. Can you say what soundness is? Completeness? What a decision procedure is? What the diagonal trick does? What Gödel's sentence says? If yes, you have climbed the whole ladder.

Careful

Incomplete and undecidable are about what one system or one machine can do. They do not say logic is broken.

Try it at home

  1. Write the one sentence you would tell a friend about each of the three results: sound, complete, decidable.
  2. Pick the result that surprised you most. Say what it does not claim.
  3. Choose one next step: possible and necessary, vague words, or whether numbers exist. Write one question you would ask.

Words to know

  • sound - proofs only reach valid conclusions
  • complete - every valid argument has a proof
  • decidable - a machine always answers yes or no

Big idea

Letter logic is sound, complete and decidable. All and some is sound and complete, and half decidable. A system for arithmetic is incomplete.

Lesson page →