Try   HackMD

Excursion on the rules of logic

Last lecture we looked in some detail at a proof stating that if a program is finitely branching then termination can always be shown by a measure function to the natural numbers.

I want to use the opportunity to show you the patterns that arise when establishing an argument and then formalise them as rules of logic.

Aims of this lecture

  • To help you understand better how proofs work, to learn how to navigate a proof without getting lost.

  • To understand that proofs are structured in the same way as programs, by nesting blocks:

    • In the same way as a new block in programming may introduce new local variables, a new block in a proof introduces new assumptions.
    • An inner block can refer to all variables/assumptions declared in the outer blocks.
    • Closing a block makes the variables/assumptions that are local to the block invisible to the outside.
    • While a program computes outputs from inputs, a proof computes a proof of the conclusion from proofs of assumptions.
  • To train ourselves in the "double-think" between formalism (just following the rules) and meaning (being guided by what we want to achieve and understand). This double-think is as valuable a skill in programming as it is in maths.

  • To learn the rules of logic.

  • To explain the idea that all of formal, deductive reasoning can be reduced to this small set of rules.

  • Going back to our lecture on induction, we then understand that this small set of rules is an inductive definition of the set of all provable statements in (as far as we know) all of mathematics.[1]

Analysing a proof in detail

In the following I will provide a "director's commentary" on the proof from the previous lecture.

Show: If

A is finitely branching and terminating, then there is a measure function
ϕ:AN
.

The next step needs no understanding, it is purely formal: To prove an implication, you assume the assumptions and show the conclusion.

Assume that

A is finitely branching and terminating.
Show that there is a measure function
ϕ:AN
.

Here we need an idea as we have to show an existential statement ("there is"). You cannot come up with the definition wihtout understanding what is going on.

Define

ϕ(a)=|{bAab}|.
Show that
abϕ(a)>ϕ(b)
.

Implication again, purely formal reasoning.

Assume

ab.
Show
ϕ(a)>ϕ(b)
.
This, in turn, means that we have to show the following two statements.

The next step consists of several smaller steps. The first one is still formal, but we need to know the definition of

|...|. The second one is more subtle as we replace
>
by
and this only works if we know that the sets involved are finite. So compressing all of this in one step needs some mathematical experience. Finally, there is another purely formal reasoning step: We use that
is really a conjunction of two statements and that proving a conjunction means to prove each conjunct separately.

(One)

{cAac}{dAbd}

This follows from

being transitive.

The last line above could be expanded with more detail.

(Two) There is

x{cAac} and
x{dAbd}
.

To show that such an

x exists means to show that
there is
xA
such that
ax
and not
bx
.

An existential statement again. Again we need an idea. Here we see a good example of double-think. One can guess that it is

x=a that is needed both by looking at the data available and by understanding what is going on. If you can combine both ways of thinking you have a clear advantage.

Define

x=a. We need to check two statements.

(First) Show:

aa.
This follows because
is reflexive by definition.

(Second) Show: not

ba.
We argue by contradiction.

To show a negation, one reasons by contradiction.

Assume

ba.
Then
a+a
.
Which contradicts that
(A,)
is terminating.

We showed not

ba.

The rest is easy. As in programming, we should just check that all blocks close properly.

We showed (First) and (Second).

We showed (Two).

We showed

ϕ(a)>ϕ(b).

We showed

abϕ(a)>ϕ(b).

We showed that there is a measure function

ϕ:AN.

We showed that if

A is finitely branching and terminating, then there is a measure function
ϕ:AN
.

Remark: It is interesting to speculate whether the more concise proof or the proof with more detail is easier to understand. The short proof leaves more details for the reader to fill in. The longer proof drowns the ideas in lots of "bureaucracy". Ultimately, I believe, the answer must be to master the double-think: To be able to switch between a high and a low level of abstraction effortless. This is similar to listening to polyphonic music: Our brains are not made for following several tunes at the same time. Maths and programming need a similar effort if one wants to appreciate their beauty.

The rules of logic

The purely formal, idea-free content of the above proof can be condensed into a set of formal rules, the rules of logic.

Let us go over a few of them.

Universal quantifier

The following explains the rule called

-
I
in Gentzen. Suppose the claim we want to prove is of the form [2]
x.F(x)

where

F(x) is a property that depends on
x
.

For example, if

A and
B
are sets, we may want to prove
AB
, that is,
x.xAxB

The rule of reasoning in this case is simple:

Assume that we have an
a
, then show
F(a)

Or in symbolic notation:

F(a)x.F(x)

Notice that there is an important side-condition, namely that we need to choose a name

a that has not been used before. We say that
a
is fresh.

Implication

The following explains the rule called

-
I
in Gentzen. Suppose the claim is
AB

The rule is:

Assume
A
, then show
B

Or in symbolic notation:

B[A]AB

Existential quantifier

Suppose the statement is

y.P(y)

The rule in this case asks us to identify (define) a particular

a and then show that
a
has property
P
, that is, that
P(a)
.

Define
a
, then show
P(a)

Or in symbolic notation:

F(a)x.F(x)

Exercises

Exercise: Find examples of applications of these rules in the proof of the theorem of the previous lecture.

Exercise: Which of the other rules of Gentzen can you identify in the proof of the previous lecture?

Exercise: Think about the following: Is it possible to reduce all steps in this proof to an application of one of this rules? What about other proofs or even all proofs?

Exercise: Give a formal proof, using Gentzen rules, that every number divisible by 4 is divisible by 2. You may use the laws of arithmetic freely. [Hint:

x is divisible by
n
can be formalised as
y.x=ny
.]

References

All rules as given by Gentzen. The original paper and a link to an English translation.

The style of writing proofs with indentation is due to Fitch, a summary of the rules is here and there are also latex macros for writing Fitch style proofs.

An excellent (maybe the best ever (?)) popular science book on formal systems is Goedel Escher Bach.


  1. The idea that mathematics can be reduced to logic (in the sense discussed here) is the central message of Russel and Whitehead's Principa Mathematica. But it was Gentzen who found this beautifully simple set of rules called Natural Deduction. ↩︎

  2. x is short for "forall
    x
    ". ↩︎