<<

Motivation Hilbert Systems The Calculus Examples Summary

Logic for Computer Science 2.2 Natural Deduction

Jens Otten

University of Oslo

Jens Otten (UiO) for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 1 / 22

Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary Satisfiability and

Definition (Satisfiable, Valid, ). Let A be a formula and U= A , ... be a of formulae A . ∈F { 1 } i ∈F I A is satisfiable iff v (A) = T for some . I I A satisfying interpretation is a model for A. U= A , ... is satisfiable iff there is (common) model for all A . { 1 } i A/U is unsatisfiable iff A/U is not satisfiable.

I A is valid, denoted = A, iff v (A) = T for all interpretations . | I I A is invalid iff A is not valid.

I A is a logical consequence of U, denoted U = A, iff every | model of U is a model of A.

Theorem (Logical Consequence and Validity). Let A and U= A , ..., A . Then U = A iff = A A. ∈F { 1 n} | | i i → Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171V Autumn ’18 2 / 22 Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary Validity and Complexity

I A is valid, denoted = A, iff v (A) = T for all interpretations | I I I for a given formula A, testing for every possible interpretation I whether v (A) = T holds is an “expensive” task I n I if A contains n (different) atoms, i.e. = n, then2 truth |PA| assignments have to be tested

I the problem of determining if a formula A is valid is co-NP-complete, i.e. all known solutions/algorithm have an exponential time complexity

I if P = NP, then there is a solution/algorithm that has a polynomial time complexity

Goal: “” to derive valid formulae in a purely syntactical and more efficient way

Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 3 / 22

Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary Calculus and Proof

Definition 21 (Calculus/Deductive System). A calculus consists of and rules. w1 wn Axioms have the form w ; rules have the form ···w (w1,..., wn are the premises, w is the conclusion). A proof of w is a tree whose (inner) nodes are rules of the calculus such that each premise of a rule is a conclusion of another rule or an . Definition 22 (Proof, Derivation). Let = A ,... be axioms and = R ,... be rules of a calculus. A { 1 } R { 1 } 1. Let Ai be of the form w . Then w is a proof of w. ∈ A w is a derivation of w. w1 wn 2. Let R be a rule of the form ··· and 1, ..., n i ∈ R w D D proofs/derivations of w , ..., w . Then 1 n is also a 1 n D ···Dw proof/derivation of w. Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 4 / 22 Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary Hilbert Systems

Goal: calculus (or deductive system) to formalize mathematical reasoning

I published by in 1922/1934

I contains 3 axioms and 1

I proofs are constructed as a sequence of formulae, each of which is either

I an axiom (or a formula that has been previously proved) or I a derivation of a formula from previous formulae in the sequence using the rule of inference

I uses only the logical connectives (implication) and () → ¬ I A B can be defined as (A B) A ∧ B can be defined as ¬A →B ¬ ∨ ¬ →

Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 5 / 22

Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary Hilbert’s H Definition 23 ( ). H The axioms of are: H A (B A) (Axiom 1) ` → → (A (B C)) ((A B) (A C)) (Axiom 2) ` → → → → → → ( B A) (A B) (Axiom 3) ` ¬ → ¬ → → The rule of inference of is (“MP” for short): H A A B MP ` `B → ` Remark: All axioms of are valid formulae. The modus ponens inference H rule of states that “a formula B can be inferred from A and A B”. H → Definition 24 (Provable, ). A formula A is provable in a calculus (here in ), written A, iff H ` there is a proof for A in the calculus ( ). A is called a theorem. H Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 6 / 22 Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary Hilbert System — Examples

Theorem 25 (A A). → A A for formula A. ` → Proof. 1. A ((A A) A) (Axiom 1∗) ` → → → 2. (A ((A A) A)) ((A (A A)) (A A)) (Axiom 2∗) 3. ` (A → (A →A)) → (A →A) → → → → (MP 1,2) 4. ` A →(A →A) → → (Axiom 1 with B A) 5. ` A → A→ (MP≡ 3,4) ` → ∗: with B (A A) ≡ → Examples:

I A (B A) (Axiom 1) ` → → I p (( q r) p) (Axiom 1) ` → ¬ → → (with A p and B ( q r)) ≡ ≡ ¬ →

Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 7 / 22

Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary The Deduction Rule

Goal: simplify proofs in by using derived rules H Definition 26 (U A). ` Let U be a set of formulae and A be a formula. The notation U A means that formulae in U are assumptions in the proof of A ` (as axioms also allowed: U U0 with U0 U). ` ⊆ Definition 27 (Deduction Rule). U A B The deduction rule is ∪ { } ` . U A B ` → Theorem 28 (). The deduction rule is a sound derived rule, i.e., it does not increase the increase the set of provable formulae () in . H Proof. It is shown by induction on the length n of the proof of U A B how to obtain a proof of U A B that does not use the ∪ { } ` ` → deduction rule; for details see [Ben-Ari 2012, page 57].

Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 8 / 22 Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary Derived Rules in H

U B A I Contrapositive rule: U` ¬A →B ¬ ` → Axiom 3 U B A U ( B A) (A B) ` ¬ → ¬ ` ¬ → ¬ → → MP U A B ` → A B B C I Transitivity: ` → A `C → ` → Prove (A B) [(B C) (A C)] (using deduction rule), → → → → → then use MP rule twice

I Further derivable rules: e.g., exchange of antecedent, , reductio ad absurdum

Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 9 / 22

Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary and Completeness

Correctness and completeness are important criteria for calculi. Definition 29 (Soundness/Correctness). A calculus is sound iff all provable formulae (i.e. theorems) are valid, i.e. for all A: if A then = A. ` | Definition 30 (Completeness). A calculus is complete iff all valid formulae are provable (i.e. theorems), i.e. for all A: if = A then A. | ` Theorem 31 (Soundness and Completeness of ). H The Hilbert System is sound and complete. H Proof. Soundness: the proof is by structural induction on the length of the proof. The axioms are valid and the inference rule MP preserves validity. Completeness: translation into calculus, see also [Ben-Ari 2012, page 64ff.].

Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 10 / 22 Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary Hilbert Systems — Summary

Hilbert Systems

I are axiomatic systems, i.e., they are essentially based on axioms

I are the simplest and historically first proof systems for first-order logic

I allow to mechanically verify if a formula is an axiom and whether it follows correctly from other formulae by one of the inference rules

I are easy to describe, but proofs/derivations in them are hard to read and understand, and are also (very!) hard to find

The problem with Hilbert systems is that they offer no guidance on how to find a proof of a formula.

Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 11 / 22

Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary Proof Search Calculi

efficiency ¨* DPLL ¨ 6 ¨¨ × ¨¨ ¨ Resolution ¨ Connection Calculus × ¨ × ¨¨ ¨¨ ¨¨ ¨¨ ¨¨ ¨¨ Tableau Calculus ¨¨ × ¨ - ¨ time ¨¨ ¨¨ ¨¨ ¨¨ ×

Natural Deduction ×

? readability

Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 12 / 22 Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary Gentzen’s Natural Deduction

Goal: A derivation system intended to mirror actual reasoning

“First I wanted to construct a formalism which comes as close as possible to actual reasoning. Thus arose a calculus of natural deduction.” [G. Gentzen]

I the calculus of natural deduction was developed by Gehard Gentzen in the 1930’s I he was dissatisfied with axiomatic systems in the Hilbert tradition, which did not seem to capture mathematical reasoning practices very directly I instead of many axioms and one rule, he introduced only one axiom and rules for each

Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 13 / 22

Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary Natural Deduction — Assumptions

I natural deduction systems are close to the informal reasoning used in mathematical proofs; natural deduction proofs begin with assumptions, inference rules are then applied

I the inference rules come in two flavours, an introduction and an elimination rule for each logical operator I they introduce a logical operator in the conclusion or removea logical operator from a premise of the rule I some of the rules allow an assumption to be discharged; to indicate which assumption is discharged by which inference, a label is assigned to the assumption and the inference

Definition 32 (Assumptions). An assumption or initial formula is any formula A in the topmost position of any branch. A discharged assumption is written [A]n where n is the label of the inference that discharged the assumption A.

Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 14 / 22 Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary The Natural Deduction Calculus

I the root of a proof tree is the formula to be proved and the leaves are the initial assumptions

I it is allowed to introduce a new assumption, then reason under that assumption; the same assumption can be used more than once

I to get a (final) proof, all assumptions must be eventually discharged

Definition 33 (Proofs in NK). A proof of a formula A in natural deduction starts from axioms and assumptions and derives A with all assumptions discharged.

Definition 34 (Natural Deduction NK). The axioms of the calculus are discharged assumptions. The rules (for each logical connective) are given in the following.

Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 15 / 22

Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary Rules for Disjunction and Conjunction

I rules for (conjunction) ∧ AB A B A B -I ∧ -E ∧ -E A B ∧ A ∧ B ∧ ∧

I rules for (disjunction) ∨ A n n -I [A] [B] A B ∨ . . ∨ . . . . B . . -I . . A B ∨ . . ∨ A B C C ∨ -En C ∨

Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 16 / 22 Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary Rules for Implication and Negation

I rules for (implication) → [A]n . . A BA . → -E . B → B -In A B → →

I rules for (negation) ¬ [A]n . . AA . ¬ -E . ¬ ⊥ ⊥ -In A ¬ ¬ Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 17 / 22

Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary Rules for False and True

I rules for (false) and (true): ⊥ > -I ⊥ -E > C ⊥ >

I furthermore, (at least) one of the following rules is required; without any of these rules we obtain a natural deduction calculusNJ for (see end of this course) [ A]n ¬. . . A XM . ¬¬ C A A A ¬¬ ∨ ¬ n ⊥A ⊥ C These rules are called “Proof by Contradiction” (included in NK by default), “Double Negation Rule”, and “Excluded Middle”.

Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 18 / 22 Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary Soundness and Completeness

Theorem 35 (Soundness and Completeness of NK).

The calculus of natural deduction NK is sound and complete, i.e.

I if A is provable in NK, then A is valid (if A then = A) ` | I if A is valid, then A is probable in NK (if = A then A) | ` Proof. See [Gentzen 1935].

Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 19 / 22

Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary Examples of NK Proofs

Example:( p q) p Example: p (p q) q ∧ → ∧ → → [p (p q)]1 [p (p q)]1 [p q]1 ∧ → -E ∧ → -E ∧ p q ∧ p ∧ p -E → q -E ∧ -I1 -I1 → (p q) p → p (p q) q → ∧ → ∧ → →

Example:( p q) (p q) ¬ ∨ → → [ p]2 [p]3 ¬ -E ¬ ⊥q -E [q]2 ⊥ 3 [ p q]1 p q -I p q -I → → 2 ¬ ∨ p→ q → -E → -I1 ∨ ( p q) (p q) → ¬ ∨ → → discharging assumptions is optional (see rightmost -I) →

Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 20 / 22 Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary More Examples of NK Proofs

Example:( p (q r)) (p q r) → → → ∧ → See exercises.

Example: p p ∨ ¬ See exercises.

Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 21 / 22

Motivation Hilbert Systems Natural Deduction The Calculus Examples Summary Summary

I calculus: formal deductive system to derive formula in a syntactical way

I Hilbert systems: three axioms, but only one rule of inference I are easy to describe, but proofs in them are hard to read and understand, and are also (very!) hard to find

I Gentzen’s natural deduction is closer to actual reasoning I consists (mainly) of two inference rules (introduction and elimination) for each logical connective I main concept are assumptions that are discharged by certain rules

I natural deduction proofs are easier to understand and to find I but finding a natural deduction proof is still not straightforward

I Thursday: sequent calculus

Jens Otten (UiO) Logic for CS — 2.2 Natural Deduction INF3170/4171 Autumn ’18 22 / 22