Anda di halaman 1dari 792

Logic for Computer Science

http://www.cse.iitd.ac.in/sak/courses/ilcs/2015-16.index.html

S. Arun-Kumar
Department of Computer Science and Engineering
I. I. T. Delhi, Hauz Khas, New Delhi 110 016.
July 28, 2015

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

1 OF 788

Q UIT

Contents
0

Background Preliminaries

25

0.1

Motivation for the Study of Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

0.2

Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

0.3

Relations and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

0.4

Operations on Binary Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

0.5

Ordering Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

0.6

Partial Orders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

0.7

Well orders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

0.8

Infinite Sets: Countability and Uncountability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

0.9

Induction Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

0.10 Mathematical Induction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73


0.11 Complete Induction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
0.12 Structural Induction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
0.13 Simultaneous Induction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
0.14 Well-ordered Induction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

2 OF 788

Q UIT

Lecture 1: Introduction

116

Lecture 2: Propositional Logic Syntax

131

2.1

Propositions in Natural Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

2.2

Translation of Natural Language Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

2.3

Associativity and Precedence of Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

2.4

Rooted Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

Lecture 3: Semantics of Propositional Logic

174

Lecture 4: Logical and Algebraic Concepts

187

Lecture 5: Identities and Normal Forms

198

Lecture 6: Tautology Checking

215

Lecture 7: Propositional Unsatisfiability

255

7.1

Space Complexity of Propositional Resolution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266

7.2

Time Complexity of Propositional Resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267

Lecture 8: Analytic Tableaux

H OME PAGE

JJ

276

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

3 OF 788

Q UIT

Lecture 9: Consistency & Completeness

287

10 Lecture 10: The Compactness Theorem

301

11 Lecture 11: Maximally Consistent Sets

311

12 Lecture 12: Formal Theories

327

13 Lecture 13: Proof Theory: Hilbert-style

342

14 Lecture 14: Derived Rules

357

15 Lecture 15: The Hilbert System: Soundness

380

16 Lecture 16: The Hilbert System: Completeness

391

17 Lecture 17: Introduction to Predicate Logic

403

18 Lecture 18: The Semantics of Predicate Logic

426

19 Lecture 19: Substitutions

442

20 Lecture 20: Models, Satisfiability and Validity

457

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

4 OF 788

Q UIT

20.1 Some Model Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474


21 Lecture 21: Structures and Substructures

477

22 Lecture 22: Predicate Logic: Proof Theory

494

23 Lecture 23: Predicate Logic: Proof Theory (Contd.)

516

24 Lecture 24: Existential Quantification

530

25 Lecture 25: Normal Forms

547

26 Lecture 26: Skolemization

568

27 Lecture 27: Substitutions and Instantiations

590

28 Lecture 28: Unification

602

29 Lecture 29: Resolution in FOL

635

30 Lecture 30: More on Resolution in FOL

648

31 Lecture 31: Resolution: Soundness and Completeness

660

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

5 OF 788

Q UIT

32 Lecture 32: Resolution and Tableaux

679

33 Lecture 33: Completeness of Tableaux Method

688

34 Lecture 34: Completeness of the Hilbert System

697

34.1 Model-theoretic and Proof-theoretic Consistency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700


35 Lecture 35: First-Order Theories

711

36 Lecture 36: Towards Logic Programming

729

37 Lecture 37: Verification of Imperative Programs

745

38 Lecture 38: Verification of WHILE Programs

757

39 Lecture 39: Concluding Remarks

775

40 References

787

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

6 OF 788

Q UIT

List of Slides
Lecture 1: Introduction
1.
2.
3.
4.
5.
6.
7.
8.
9.

What is Logic?
Reasoning, Truth and Validity
Examples
Objectivity in Logic
Formal Logic
Formal Logic: Applications
Form and Content
Facets of Mathematical Logic
Logic and Computer Science

Lecture 2: Propositional Logic Syntax


1.
2.
3.
4.
5.
6.
7.
8.
9.

H OME PAGE

Truth and Falsehood: 1


Truth and Falsehood: 2
Extending the Boolean Algebra
Table of Truth & Falsehood
Sums & Products
Propositional Logic: Syntax
Propositional Logic: Syntax - 2
Natural Language equivalents
Some Remarks

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

7 OF 788

Q UIT

10. Associativity and Precedence


11. Syntactic Identity
12. Abstract Syntax Trees
13. Subformulae
14. Atoms in a Formula
15. Degree of a Formula
16. Size of a Formula
17. Height of a Formula

Lecture 3: Semantics of Propositional Logic


1. Semantics of Propositional Logic: 1
2. Semantics of Propositional Logic: 2
3. Models and Satisfiability
4. Example: Abstract Syntax trees
5. Tautology, Contradiction, Contingent

Lecture 4: Logical and Algebraic Concepts


1. Logical Consequence: 1
2. Logical Consequence: 2
3. Other Theorems
4. Logical Implication
5. Implication & Equivalence
6. Logical Equivalence as a Congruence

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

8 OF 788

Q UIT

Lecture 5: Identities and Normal Forms


1.
2.
3.
4.
5.
6.
7.
8.
9.

Adequacy
Adequacy: Examples
Functional Completeness
Duality
Principle of Duality
Negation Normal Forms: 1
Negation Normal Forms: 2
Conjunctive Normal Forms
CNF

Lecture 6: Tautology Checking


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.

H OME PAGE

Arguments
Arguments: 2
Validity & Falsification
Translation into propositional Logic
Atoms in Argument
The Representation
Propositional Rendering
The Strategy
Checking Tautology
Computing the CNF
Falsifying CNF

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

9 OF 788

Q UIT

Lecture 7: Propositional Unsatisfiability


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.

Tautology Checking
CNFs: Set of Sets of Literals
Propositional Resolution
Clean-up
The Resolution Method
The Algorithm
Resolution Examples: Biconditional
Resolution Examples: Exclusive-Or
Resolution Refutation: 1
Resolution Refutation: 2
Resolvent as Logical Consequence
Logical Consequence by Refutation

Lecture 8: Analytic Tableaux


1.
2.
3.
4.
5.
6.
7.

Against Resolution
The Analytic Tableau Method
Basic Tableaux Facts
Tableaux Rules
Structure of the Rules
Tableaux
Slim Tableaux

Lecture 9: Consistency & Completeness

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

10 OF 788

Q UIT

1. Tableaux Rules: Restructuring


2. Tableaux Rules: 2
3. Tableau Proofs
4. Consistency
5. Unsatisfiability
6. Hintikka Sets
7. Hintikkas Lemma
8. Tableaux and Hintikka sets
9. Completeness

Lecture 10: The Compactness Theorem


1. Satisfiability of Infinite Sets
2. The Compactness Theorem
3. Inconsistency
4. Consequences of Compactness

Lecture 11: Maximally Consistent Sets


1. Consistent Sets
2. Properties of Finite Character: 1
3. Properties of Finite Character: 2
4. Properties of Finite Character: 3
5. Maximally Consistent Sets
6. Lindenbaums Theorem

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

11 OF 788

Q UIT

Lecture 12: Formal Theories


1. Introduction to Reasoning
2. Proof Systems: 1
3. Requirements of Proof Systems
4. Proof Systems: Desiderata
5. Formal Theories
6. Formal Language
7. Axioms and Inference Rules
8. Axiomatic Theories
9. Syntax and Decidability
10. A Hilbert-style Proof System
11. Rule Patterns

Lecture 13: Proof Theory: Hilbert-style


1. More About Formal Theories
2. An Example Proof
3. Formal Proofs
4. Provability and Formal Proofs
5. The Deduction Theorem
6. About Formal Proofs

Lecture 14: Derived Rules


1. Simplifying Proofs

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

12 OF 788

Q UIT

2. Derived Rules
3. The Sequent Form
4. Proof trees in sequent form
5. Transitivity of Conditional
6. Derived Double Negation Rules
7. Derived Operators
8. Rules for Derived Operators

Lecture 15: The Hilbert System: Soundness


1. Formal Theory: Issues
2. Formal Theory: Incompleteness
3. Soundness of Formal Theories
4. Soundness of the Hilbert System
5. Soundness of the Hilbert System

Lecture 16: The Hilbert System: Completeness


1. Towards Completeness
2. Towards Truth-tables
3. The Truth-table Lemma
4. The Completeness Theorem

Lecture 17: Introduction to Predicate Logic


1. Predicate Logic: Introduction-1
2. Predicate Logic: Introduction-2

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

13 OF 788

Q UIT

3. Predicate Logic: Introduction-3


4. Predicate Logic: Symbols
5. Predicate Logic: Signatures
6. Predicate Logic: Syntax of Terms
7. Predicate Logic: Syntax of Formulae
8. Precedence Conventions
9. Predicates: Abstract Syntax Trees
10. Subterms
11. Variables in a Term
12. Bound Variables And Scope
13. Bound Variables And Scope: Example
14. Scope Trees
15. Free Variables
16. Bound Variables
17. Closure

Lecture 18: The Semantics of Predicate Logic


1. Structures
2. Notes on Structures
3. Infix Convention
4. Expansions and Reducts
5. Valuations and Interpretations
6. Evaluating Terms

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

14 OF 788

Q UIT

7.
8.
9.
10.
11.

Coincidence Lemma for Terms


Variants
Variant Notation
Semantics of Formulae
Notes on the Semantics

Lecture 19: Substitutions


1.
2.
3.
4.
5.
6.
7.

Coincidence Lemma for Formulae


Substitutions
Instantiation of Terms
The Substitution Lemma for Terms
Admissibility
Instantiations of Formulae
The Substitution Lemma for Formulae

Lecture 20: Models, Satisfiability and Validity


1.
2.
3.
4.
5.
6.
7.
8.

H OME PAGE

Satisfiability
Models and Consistency
Examples of Models:1
Examples of Models:2
Examples of Models:3
Logical Consequence
Validity
Validity of Sets of Formulae

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

15 OF 788

Q UIT

9. Negations of Semantical Concepts

Lecture 21: Structures and Substructures


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.

Satisfiability and Expansions


Distinguishability
Evaluations under Different Structures
Isomorphic Structures
The Isomorphism Lemma
Substructures
Substructure Examples
Quantifier-free Formulae
Lemma on Quantifier-free Formulae
Universal and Existential Formulae
The Substructure Lemma

Lecture 22: Predicate Logic: Proof Theory


1.
2.
3.
4.
5.
6.
7.
8.

H OME PAGE

Proof Theory: First-Order Logic


Proof Rules: Hilbert-Style
The Mortality of Socrates
The Mortality of the Greeks
Faulty Proof:2
A Correct Proof
The Sequent Forms
The Case of Equality

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

16 OF 788

Q UIT

9. Semantics of Equality
10. Axioms for Equality
11. Symmetry and Transitivity
12. Symmetry of Equality
13. Transitivity of Equality

Lecture 23: Predicate Logic: Proof Theory (Contd.)


1. Alpha Conversion
2. The Deduction Theorem for Predicate Calculus
3. Useful Corollaries
4. Soundness of Predicate Calculus
5. Soundness of The Hilbert System

Lecture 24: Existential Quantification


1. Existential Generalisation
2. Existential Elimination
3. Remarks on Existential Elimination
4. Restrictions on Existential Elimination
5. Equivalence of Proofs

Lecture 25: Normal Forms


1. Natural Deduction: 6
2. Moving Quantifiers
3. Quantifier Movement

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

17 OF 788

Q UIT

4.
5.
6.
7.
8.
9.
10.
11.
12.

More on Quantifier Movement


Prenex Normal Forms
The Prenex Normal Form Theorem
Prenex Conjunctive Normal Form
The Herbrand Algebra
Terms in a Herbrand Algebra
Herbrand Interpretations
Herbrand Models
Ground Quantifier-free Formulae

Lecture 26: Skolemization


1.
2.
3.
4.
5.
6.
7.
8.
9.

Skolemization
Skolem Normal Forms
SCNF
Ground Instance
Herbrands Theorem
The Herbrand Tree of Interpretations
Compactness of Sets of Ground Formulae
Compactness of Closed Formulae

The Lowenheim-Skolem
Theorem

Lecture 27: Substitutions and Instantiations


1. Substitutions Revisited
2. Some Simple Facts

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

18 OF 788

Q UIT

3. Ground Substitutions
4. Composition of Substitutions
5. Substitutions: A Monoid

Lecture 28: Unification


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.

Unifiability
Unification Examples:1
Unification Examples:2
Generality of Unifiers
Generality: Facts
Most General Unifiers
More on Positions
Disagreement Set
Example: Disagreement 1
Example: Occurs Check
Example: Disagreement 3
Example: Disagreement 4
Disagreement and Unifiability
The Unification Theorem

Lecture 29: Resolution in FOL


1. Recapitulation
2. SCNFs and Models
3. SCNFs and Unsatisfiability

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

19 OF 788

Q UIT

4. Representing SCNFs
5. Clauses: Terminology
6. Clauses: Ground Instances
7. Facts about Clauses
8. Clauses: Models
9. Clauses: Herbrands Theorem
10. Resolution in FOL

Lecture 30: More on Resolution in FOL


1. Standardizing Variables Apart
2. Factoring
3. Example: 1
4. Example: 2
5. Refutation

Lecture 31: Resolution: Soundness and Completeness


1. Soundness of FOL Resolution
2. Ground Clauses
3. The Lifting Lemma
4. Lifting Lemma: Figure
5. Completeness of Resolution Refutation: 1
6. Completeness of Resolution Refutation: 2
7. Completeness of Resolution Refutation: 3

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

20 OF 788

Q UIT

Lecture 32: Resolution and Tableaux


1.
2.
3.
4.
5.

FOL: Tableaux
FOL: Tableaux Rules
FOL Tableaux: Example 1
First-Order Tableaux
FOL Tableaux: Example 2

Lecture 33: Completeness of Tableaux Method


1.
2.
3.
4.
5.

First-order Hintikka Sets


Hintikkas Lemma for FOL
First-order tableaux and Hintikka sets
Soundness of First-order Tableaux
Completeness of First-order Tableaux

Lecture 34: Completeness of the Hilbert System


1.
2.
3.
4.

Deductive Consistency
Models of Deductively Consistent Sets
Deductive Completeness
The Completeness Theorem

Lecture 35: First-Order Theories


1. (Simple) Directed Graphs
2. (Simple) Undirected Graphs
3. Irreflexive Partial Orderings

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

21 OF 788

Q UIT

4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.

Irreflexive Linear Orderings


(Reflexive) Preorders
(Reflexive) Partial Orderings
(Reflexive) Linear Orderings
Equivalence Relations
Peanos Postulates
The Theory of The Naturals
Notes and Explanations
Finite Models of Arithmetic
A Non-standard Model of Arithmetic
Z-Chains

Lecture 36: Towards Logic Programming


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

H OME PAGE

Reversing the Arrow


Horn Clauses
Goal clauses
Logic Programs
Sorting in Logic
Prolog: Selection Sort
Prolog: Merge Sort
Prolog: Quick Sort
Prolog: SEND+MORE=MONEY
Prolog: Naturals

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

22 OF 788

Q UIT

Lecture 37: Verification of Imperative Programs


1.
2.
3.
4.
5.
6.
7.
8.

The WHILE Programming Language


Programs As State Transformers
The Semantics of WHILE
Programs As Predicate Transformers
Correctness Assertions
Total Correctness of Programs
Examples: Factorial 1
Examples: Factorial 2

Lecture 38: Verification of WHILE Programs


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.

H OME PAGE

Proof Rule: Epsilon


Proof Rule: Assignment
Proof Rule: Composition
Proof Rule: The Conditional
Proof Rule: The While Loop
The Consequence Rule
Proof Rules for Partial Correctness
Example: Factorial 1
Towards Total Correctness
Termination and Total Correctness
Example: Factorial 2
Notes on Example: Factorial

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

23 OF 788

Q UIT

13. Example: Factorial 2 Made Complete


14. An Open Problem: Collatz

Lecture 39: Concluding Remarks


1. Summary
2. The Limitations of Predicate Logic
3. Sortedness
4. Many-Sorted Logic: Symbols
5. Many-Sorted Signatures
6. Many-Sorted Signature: Terms
7. Many-Sorted Predicate Logic
8. Reductions

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

24 OF 788

Q UIT

0. Background Preliminaries

al-go-rism n. [ME algorsme<OFr.< Med.Lat. algorismus, after Muhammad ibn-Musa AlKharzimi (780-850?).] The Arabic system of numeration: DECIMAL SYSTEM.
al-go-rithm n [Var. of ALGORISM.] Math. A mathematical rule or procedure for solving a
problem.
4word history: Algorithm originated as a varaiant spelling of algorism. The spelling was
probably influenced by the word aruthmetic or its Greek source arithm, number. With the
development of sophisticated mechanical computing devices in the 20th century, however,
algorithm was adopted as a convenient word for a recursive mathematical procedure, the
computers stock in trade. Algorithm has ceased to be used as a variant form of the older
word.
Websters II New Riverside University Dictionary 1984.
0.1. Motivation for the Study of Logic

In the early years of this century symbolic or formal logic became quite popular with philosophers
and mathematicicans because they were interested in the concept of what constitutes a correct proof
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

25 OF 788

Q UIT

in mathematics. Over the centuries mathematicians had pronounced various mathematical proofs
as correct which were later disproved by other mathematicians. The whole concept of logic then
hinged upon what is a correct argument as opposed to a wrong (or faulty) one. This has been amply
illustrated by the number of so-called proofs that have come up for Euclids parallel postulate and for
Fermats last theorem. There have invariably been bugs (a term popularised by computer scientists
for the faults in a program) which were often very hard to detect and it was necessary therefore
to find infallible methods of proof. For centuries (dating back at least to Plato and Aristotle) no
rigorous formulation was attempted to capture the notion of a correct argument which would guide
the development of all mathematics.
The early logicians of the nineteenth and twentieth centuries hoped to establish formal logic as a
foundation for mathematics, though that never really happened. But mathematics does rest on one
firm foundation, namely set theory. But Set theory itself has been expressed in first order logic.
What really needed to be answered were questions relating to the automation or mechanizability
of proofs. These questions are very relevant and important for the development of present-day
computer science and form the basis of many developments in automatic theorem proving. David
Hilbert asked the important question, as to whether all mathematics, if reduced to statements of
symbolic logic, can be derived by a machine. Can the act of constructing a proof be reduced to the
manipulation of statements in symbolic logic? Logic enabled mathematicians to point out why an
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

26 OF 788

Q UIT

alleged proof is wrong, or where in the proof, the reasoning has been faulty. A large part of the credit
for this achievement must go to the fact that by symbolising arguments rather than writing them out
in some natural language (which is fraught with ambiguity), checking the correctness of a proof
becomes a much more viable task. Of course, trying to symbolise the whole of mathematics could
be disastrous as then it would become quite impossible to even read and understand mathematics,
since what is presented usually as a one page proof could run into several pages. But at least in
principle it can be done.
Since the latter half of the twentieth century logic has been used in computer science for various
purposes ranging from program specification and verification to theorem-proving. Initially its use
was restricted to merely specifying programs and reasoning about their implementations. This is
exemplified in the some fairly elegant research on the development of correct programs using firstorder logic in such calculi such as the weakest-precondition calculus of Dijkstra. A method called
Hoare Logic which combines first-order logic sentences and program phrases into a specification
and reasoning mechanism is also quite useful in the development of small programs. Logic in this
form has also been used to specify the meanings of some programming languages, notably Pascal.
The close link between logic as a formal system and computer-based theorem proving is proving
to be very useful especially where there are a large number of cases (following certain patterns)

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

27 OF 788

Q UIT

to be analysed and where quite often there are routine proof techniques available which are more
easily and accurately performed by therorem-provers than by humans. The case of the four-colour
theorem which until fairly recently remained a unproved conjecture is an instance of how human
ingenuity and creativity may be used to divide up proof into a few thousand cases and where machines may be used to perform routine checks on the individual cases. Another use of computers
in theorem-proving or model-checking is the verification of the design of large circuits before a
chip is fabricated. Analysing circuits with a billion transistors in them is at best error-prone and at
worst a drudgery that few humans would like to do. Such analysis and results are best performed by
machines using theorem proving techniques or model-checking techniques.
A powerful programming paradigm called declarative programming has evolved since the late seventies and has found several applications in computer science and artificial intelligence. Most programmers using this logical paradigm use a language called Prolog which is an implemented form
of logic1. More recently computer scientists are working on a form of logic called constraint logic
programming.
In the rest of this chapter we will discuss sets, relations, functions. Though most of these topics are
covered in the high school curriculum this section also establishes the notational conventions that
1 actually

H OME PAGE

a subset of logic called Horn-clause logic

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

28 OF 788

Q UIT

will be used throughout. Even a confident reader may wish to browse this section to get familiar
with the notation.
0.2. Sets

A set is a collection of distinct objects. The class of CS253 is a set. So is the group of all first year
students at IITD. We will use the notation {a, b, c} to denote the collection of the objects a, b and
c. The elements in a set are not ordered in any fashion. Thus the set {a, b, c} is the same as the set
{b, a, c}. Further, repetitions of elements in a set do not change it in any way. Two sets are equal if
they contain exactly the same elements. Hence the sets {a, b, c}, {a, b, c, a}, {b, a, c}, {c, b, a, c} are
all equal.
We can describe a set either by enumerating all the elements of the set or by stating the properties that uniquely characterize the elements of the set. Thus, the set of all even positive integers
not larger than 10 can be described either as S = {2, 4, 6, 8, 10} or, equivalently, as S = {x |
x is an even positive integer not larger than 10}
A set can have another set as one of its elements. For example, the set A = {{a, b, c}, d} contains
two elements {a, b, c} and d; and the first element is itself a set. We will use the notation x S to

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

29 OF 788

Q UIT

denote that x is an element of (or belongs to) the set S.


A set A is a subset of another set B, denoted as A B, if x B whenever x A.
An empty set is one which contains no elements and we will denote it with the symbol . For
example, let S be the set of all students who fail this course. S might turn out to be empty (hopefully;
if everybody studies hard). By definition, the empty set is a subset of all sets. We will also assume
an Universe of discourse U, and every set that we will consider is a subset of U. Thus we have
1. A for any set A
2. A U for any set A
The union of two sets A and B, denoted A B, is the set whose elements are exactly the elements
of either A or B (or both). The intersection of two sets A and B, denoted A B, is the set whose
elements are exactly the elements that belong to both A and B. The difference of B from A, denoted
A B, is the set of all elements of A that do not belong to B. The complement of A, denoted A
is the difference of A from the universe U. Thus, we have
1. A B = {x | (x A) or (x B)}
2. A B = {x | (x A) and (x B)}
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

30 OF 788

Q UIT

3. A B = {x | (x A) and (x 6 B)}
4. A = U A
We also have the following named identities that hold for all sets A, B and C.
Basic properties of set union.
1. (A B) C = A (B C)

Associativity

2. A = A

Identity

3. A U = U

Zero

4. A B = B A

Commutativity

5. A A = A

Idempotence

Basic properties of set intersection


1. (A B) C = A (B C)

Associativity

2. A U = A

Identity

3. A =

Zero

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

31 OF 788

Q UIT

4. A B = B A

Commutativity

5. A A = A

Idempotence

Other properties
1. A (B C) = (A B) (A C)

Distributivity of over

2. A (B C) = (A B) (A C)

Distributivity of over

3. (A B) = A B

De Morgans law

4. (A B) = A B

De Morgans law

5. A ( A B) = A B

Absorption

6. A ( A B) = A B

Absorption

The reader is encouraged to come up with properties of set difference and the complementation
operations.
We will use the following notation to denote some standard sets:
The empty set:
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

32 OF 788

Q UIT

The Universe: U
The set of Natural Numbers: N = {0, 1, 2, . . .}. We will include 0 in the set of Natural numbers.
After all, it is quite natural to score a 0 in an examination!
The set of positive integers: P = {1, 2, 3, . . .}
The two-element set: 2 = {0, 1}. More generally for any natural number n we let n = {0, 1, . . . , n
1} the set of all naturals less than n. By convention is the set of all naturals less than 0.
The set of integers: Z = {. . . , 2, 1, 0, 1, 2, . . .}
The set of rational numbers: Q
The set of real numbers: R
The Boolean set: B = {f alse, true}
The Powerset of a set A: 2A is the set of all subsets of the set A.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

33 OF 788

Q UIT

0.3. Relations and Functions

The Cartesian product of two sets A and B, denoted by A B, is the set of all ordered pairs (a, b)
such that a A and b B. Thus,
A B = {(a, b) | a A and b B}
Given another set C we may form the following different kinds of cartesian products (which are not
at all the same!).
(A B) C = {((a, b), c) | a A, b B and c C}
A (B C) = {(a, (b, c)) | a A, b B and c C}
A B C = {(a, b, c) | a A, b B and c C}
The last cartesian product gives the construction of tuples. Elements of the set A1 A2 An
for given sets A1, A2, . . . , An are called ordered n-tuples.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

34 OF 788

Q UIT

An is the set of all ordered n-tuples (a1, a2, . . . , an) such that ai A for all i. i.e.,
An = |A A
{z A}
n times
A binary relation R from A to B is a subset of A B. It is a characterization of the intuitive
notion that some of the elements of A are related to some of the elements of B. We also use the infix
notation aRb to mean (a, b) R. When A and B are the same set, we say R is a binary relation
on A. Familiar binary relations from N to N are =, 6=, <, , >, . Thus the elements of the
set {(0, 0), (0, 1), (0, 2), . . . , (1, 1), (1, 2), . . .} are all members of the relation which is a subset of
N N.
In general, an n-ary relation among the sets A1, A2, . . . , An is a subset of the set A1 A2 An.
Definition 0.1 Let R A B be a binary relation from A to B. Then
1. For any set A0 A the image of A0 under R is the set defined by
R(A0) = {b B | aRb f or some a A0}
2. For every subset B 0 B the pre-image of B 0 under R is the set defined by
R1(B 0) = {a A | aRb f or some b B 0}
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

35 OF 788

Q UIT

3. R is onto (or surjective) with respect to A and B if R(A) = B.


4. R is total with respect to A and B if R1(B) = A.
5. R is one-to-one (or injective) with respect to A and B if for every b B there is at most one
a A such that (a, b) R.
6. R is a partial function from A to B, usually denoted R : A * B, if for every a A there is
at most one b B such that (a, b) R. R is a total function from A to B, usually denoted
R : A B if R is a partial function from A to B and is total. Notice that every total function
is also a partial function. A is called the domain and B the co-domain. The range of the
function is R(A).
7. R is a one-to-one correspondence (or bijection) if it is an injective and surjective total function.
Notes.
1. Given a (partial or total) function f : A * B, the binary relation it corresponds to is called the
graph of the function and graph(f ) = {(a, b) A B | f (a) = b}.
2. A binary relation R AB may also be thought of as a total function R : 2A 2B . Likewise
R1 the converse of the relation R, may be thought of as a total function R1 : 2B 2A (c.f.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

36 OF 788

Q UIT

parts 1 and 2 of definition 0.1 where relation symbol has been overloaded).
3. Similarly every partial function f : A * B may be overloaded to mean the total function
f : 2A 2B , which yields the image of A0 for each A0 A. Likewise even though the
converse (see part 2 of definition 0.6) of graph(f ) may not be a function, the total inverse
function f 1 : 2B 2A is well defined and for each B 0 B, yields the pre-image of B 0.
Notation. Let f be a total function from set A to set B. Then
1-1

f : A B will denote that f is injective,


B will denote that f is surjective, and
f : A
onto
1-1

B will denote that f is bijective,


f : A
onto
Example 0.2 The following are some examples of familiar binary relations along with their properties.
1. The relation on N is a relation from N to N which is total and onto. That is, both the image
and pre-image of under N are N itself. What are image and the pre-image respectively of the
relation <?
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

37 OF 788

Q UIT

2. The binary relation which associates key sequences from a computer keyboard with their respective 8-bit ASCII codes is an example of a relation which is total and injective.
3. The binary relation which associates 7-bit ASCII codes with their corresponding ASCII characters is a bijection.
The figures 1, 2, 3, 4 and 5 respectively illustrate the concepts of partial, injective, surjective, bijective and inverse of a bijective function on finite sets. The directed arrows go from elements in the
domain to their images in the codomain.
We may equivalently define partial and total functions as follows.
Definition 0.3 A function (or a total function) f from A to B is a binary relation f A B such
that for every element a A there is a unique element b B so that (a, b) f (usually denoted
f (a) = b and sometimes f : a 7 b). We will use the notation R : A B to denote a function R from
A to B. The set A is called the domain of the function R and the set B is called the co-domain of
the function R. The range of a function R : A B is the set {b B | for some a A, R(a) = b}.
A partial function f from A to B, denoted f : A * B is a total function from some subset of A to
the set B. Clearly every total function is also a partial function.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

38 OF 788

Q UIT

x
y

b
z

d
e

f
v

Figure 1: A partial function (Why is it partial?)

The word function unless otherwise specified is taken to mean a total function. Some familiar
examples of partial and total functions are
1. + and (addition and multiplication) on the natural numbers are total functions of the type
f :NNN
2. (subtraction) on the natural numbers is a partial function of the type f : N N * N.
3. div and mod are total functions of the type f : N P N. If a = q b + r such that 0 r < b
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

39 OF 788

Q UIT

B
f

y
w

u
v

Figure 2: An injective function (Why is it injective?)

and a, b, q, r N then the functions div and mod are defined as div(a, b) = q and mod(a, b) = r.
We will often write these binary functions as a b, a div b, a mod b etc. Note that div and mod
are also partial functions of the type f : N N * N.
4. The binary relations =, 6=, <, , >, may also be thought of as functions of the type
f : N N B where B = {f alse, true}.
Definition 0.4 Given a set A, a finite sequence of length n 0 of elements from A, denoted ~a, is

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

40 OF 788

Q UIT

x
y

b
z

d
e

u
v

Figure 3: A surjective function (Why is it surjective?)

a (total) function of the type ~a : {1, 2, . . . , n} A. We normally denote such a sequence of length
n by [a1, a2, . . . , an]. Alternatively, ~a may be regarded as a total function from {0, . . . , n 1} to A
and may be denoted by [a0, a2, . . . , an1]. The empty sequence, denoted [], is also such a function
[] : A and denotes a sequence of length 0.
It is very common in computer science to distinguish between the notion of a sequence and that of a
string or a word.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

41 OF 788

Q UIT

y
w

c
e

u
v

Figure 4: An bijective function (Why is it bijective?)

Definition 0.5 An alphabet is a finite set of symbols also called letters. Any finite sequence of
letters from an alphabet is called a string or a word. A string of length n N is usually written
a1a2 . . . an or a1a2 . . . an, where each ai A, 1 i n. The unique empty string (of length 0) is
usually denoted and the operation of juxtaposing two strings s and t to form a new string is called
(con)catenation.
It is quite clear that there exists a simple bijection from the set An (which is the set of all n-tuples of
elements from the set A) and the set of all sequences of length n of elements from A. We will often
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

42 OF 788

Q UIT

h1

y
w

c
e

u
v

Figure 5: The inverse of the bijective function in Fig 4(Is it bijective?)

identify the two as being the same set even though they are actually different by definition2. The set
of all finite sequences of elements from A is denoted A, where
[

An
A =
n0
2 In

H OME PAGE

a programming language like ML, the difference is evident from the notation and the constructor operations for tuples and lists

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

43 OF 788

Q UIT

The set of all non-empty sequences of elements from A is denoted A+ and is defined as
[
+
A =
An
n>0

An infinite sequence of elements from A is a total function from P to A. The set of all such infinite
sequences is denoted A .
0.4. Operations on Binary Relations

Definition 0.6
1. Given a set A, the identity relation over A, denoted IA, is the set {(a, a) | a A}.
2. Given a binary relation R from A to B, the converse of R, denoted R1 is the relation from B
to A defined as R1 = {(b, a) | (a, b) R}.
3. Given binary relations R A B and S B C, the composition of R with S is denoted
R; S and defined as R; S = {(a, c) | aRb and bSc, f or some b B}.
Note that unlike in the case of functions (where for any function f : A B its inverse f 1 :
B A may not always be defined), the converse of a relation is always defined. Given functions
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

44 OF 788

Q UIT

(whether partial or total) f : A * B and g : B * C, their composition is the function g f : A * C


defined simply as the relational composition graph(f ); graph(g). Hence (g f )(a) = g(f (a)).
The following is an important theorem with various applications in section 0.8.
1-1

Theorem 0.7 (Schroeder-Bernstein Theorem) Let A and B be sets and let f : A B and
g : B A be injective functions. Then there exists a bijection between A and B.
1-1

Proof: Since f and g are both injective (1-1), they are both total functions, but their inverses may
not be total. By injectivity, for any a A, f (a) = b implies that b cannot be the image under f of
any other member of A. Likewise for any b B, g(b) A and for every other b0 B we have
g(b0) 6= g(b). Hence f 1 : B * A and g 1 : A * B are both partial functions.
For any a0 A we define the origin of a0 as a0 itself if g 1(a0) is undefined i.e. if a0 is not the image
of any b B under g. (Likewise for any b0 B, the origin of b0 is b0 itself if f 1(b0) is undefined).
Otherwise g 1(a0) = b1 for a unique b1 B. Now consider the maximal (possibly infinite) sequence

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

45 OF 788

Q UIT

of elements
a0
g 1(a0)
= b1
f 1(b1)
= a2
g 1(a2)
= b3
...
...
f 1(b2k1) = a2k
g 1(a2k ) = b2k+1
...
...

...

...

A,
B,
A,
B,
,
A,
B,

such that for each k > 0, a2k = f 1(b2k1) and b2k+1 = g 1(b2k ). We then have the following cases
for each a0 A.
Case AA. a2m is the origin of a0 for some m 0. That is, the sequence a0, b1, a2, b3, . . . , a2m is
finite and g 1(a2m) is undefined. In this case a2m is the origin of a0 and a0 AA.
Case AB . b2m+1 is the origin of a0 for some m 0. That is, the sequence a0, b1, a2, b3, . . . , a2m, b2m+1
is finite and f 1(b2m+1) is undefined. Then b2m+1 is the origin of a0 and a0 AB .
Case AU . The origin of a0 is undefined. That is, the sequence a0, b1, a2, b3, . . . , a2m, b2m+1, . . . is
infinite. Then a0 AU .
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

46 OF 788

Q UIT

Hence A may be partitioned into three (mutually disjoint) sets AA, AB , AU depending upon the
origins of the elements of A. (Analogously, B may be partitioned into BA, BB and BU ).
Now we may define the total function h : A B such that

f (a) if a AA AU
h(a) =

g 1(a) if a AB
1-1

B i.e. h is a bijection from A to B.


Claim. h : A
onto
` The proof of the claim is easy and is left to the interested reader. In fact, we may show
that the following hold
h(AU ) = BU , h1(BU ) = AU
h(AA) = BA , h1(BA) = AB
h(AB ) = BB , h1(BB ) = AB
a


QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

47 OF 788

Q UIT

0.5. Ordering Relations

We may define the n-fold composition of a relation R on a set A by induction as follows


R 0 = IA
Rn+1 = Rn; R
We may combine these n-fold compositions to yield the reflexive-transitive closure of R, denoted
R, as the relation
[

R =
Rn
n0

Sometimes it is also useful to consider merely the transitive closure R+ of R which is defined as
[
+
R =
Rn
n>0

Definition 0.8 A binary relation R on a set A is


1. reflexive if and only if IA R;
2. irreflexive if and only if IA R = ;

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

48 OF 788

Q UIT

3. symmetric if and only if R = R1;


4. asymmetric if and only if R R1 = ;
5. antisymmetric if and only if for all a and b, a 6= b, (a, b) R implies (b, a) 6 R.3
6. transitive if and only if for all a, b, c A, (a, b), (b, c) R implies (a, c) R.
7. connected if and only if for all a, b A, if a 6= b then aRb or bRa.
Given any relation R on a set A, it is easy to see that R is both reflexive and transitive.
Example 0.9
1. The edge relation on an undirected graph is an example of a symmetric relation.
2. In any directed acyclic graph the edge relation is asymmetric.
3. Consider the reachability relation on a directed graph defined as: A pair of vertices (A, B) is in
the reachability relation, if either A = B or there exists a vertex C such that both (A, C) and
(C, B) are in the reachability relation. The reachability relation is the reflexive transitive closure
of the edge relation.
3 An

H OME PAGE

equivalent definition used in most books is: R is antisymmetric if and only if (a, b), (b, a) R implies a = b.

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

49 OF 788

Q UIT

4. The reachability relation on directed graphs is also an example of a relation that need not be
either symmetric or asymmetric. The relation need not be antisymmetric either.
0.6. Partial Orders

Definition 0.10 A binary relation R on a set A is


1. a preorder if it is reflexive and transitive;
2. a strict preorder if it is irreflexive and transitive;
3. a partial order if is an antisymmetric preorder;
4. a strict partial order if it is irreflexive, asymmetric and transitive;
5. a linear order4 if it is a connected partial order;
6. a strict linear order if it is connected, irreflexive and transitive;
7. an equivalence if it is reflexive, symmetric and transitive.
4 also

H OME PAGE

called total order

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

50 OF 788

Q UIT

Definition 0.11 A partially ordered set, or poset hA, i consists of a set A together with a partial
order relation on A.
Fact 0.12 If hA, i is a poset, then so is hA, i where =1.
Notation. Given a poset hA, i and a, b A, we sometimes write
b a to mean a b,
a < b to mean a b and a 6= b and
b > a to mean a < b.
Fact 0.13 If hA, i is a poset, then < and > are strict partial orders.
For any set A (empty or non-empty) we have that h2A, i is also a poset and in fact, the partial
ordering relation on A can be characterised (upto isomorphism) by the subset relation.
Definition 0.14 Given two posets hA, Ai and hB, B i, a function f : A B is said to be orderpreserving if and only if for all a, a0 A, a A a0 implies f (a) B f (a0). The two posets are said

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

51 OF 788

Q UIT

to be (order-) isomorphic if there exists an order-preserving bijection between them. We denote this
fact by hA, Ai
= hB, B i.
Notice that if f : A B is a bijection then so is f 1 : B A.
Lemma 0.15 For each poset hA, i there exists a set A 2A such that hA, i
= hA , i.
Proof: For each x A let Ax = {a A | a x}. Define the set A = {Ax | x A} 2A and
the function f : A A such that f (x) = Ax for each x A. It is easy to see that f is bijective
and order-preserving i.e. for all x, y A, x y if and only if Ax Ay .
QED
0.7. Well orders

We discuss well-orders since an mportat induction principle depends upon the notion of a wellordering and generalises the principle of mathematical induction.
Definition 0.16 Let hA, i be a poset and B A. An element b B is said to be minimal if there
exists no a B such that a < b. A poset hA, i is called well-founded if every nonempty subset of
A has a minimal element. Equivalently we say that on A is a well-founded.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

52 OF 788

Q UIT

Lemma 0.17 A poset hA, i is well-founded if and only if there is no subset {ai A | i 0} such
that ai > ai+1 for all i 0.
Proof:
(). Assume hA, i is well-founded and there is a subset A0 = {ai A | i 0, ai > ai+1} A.
Clearly A0 contains no minimal element, which is a contradiction.
(). Assume there is no subset A0 = {ai A | i 0, ai > ai+1} A. If hA, i is not
well-founded, there exists a nonempty subset B A which has no minimal element. Consider
any b0 B. Since b0 is not minimal there exists b1 B such that b0 > b1. Again b1 is not
minimal, so there must be a b2 B with b1 > b2. Proceeding in this fashion we find that for each
bi < < b1 < b0, there exists a bi+1 B such that bi+1 < bi < < b1 < b0. We may thus
construct a set B 0 = {bi B | i 0, bi > bi+1} B A which contradicts the assumption
that there is no such subset.
QED
The set B 0 = {bi B | i 0, bi > bi+1} is an example of an infinite descending chain
< bi+1 < bi < < b1 < b0
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

53 OF 788

Q UIT

We usually say that a well-founded set has no infinite descending chain.


0.8. Infinite Sets: Countability and Uncountability

Definition 0.18 A set A is finite if it can be placed in bijection with a set n = {0, . . . , n 1} for
some n N.
The above definition embodies the usual notion of counting. In particular note that the empty set
is finite since it can be placed in bijection with itself.
Definition 0.19 A set A is called infinite if there exists a bijection between A and some proper
subset of itself.
This definition begs the question, If a set is not infinite, then is it necessarily finite?. It turns out
that indeed it is. Further it is also true that if a set is not finite then it can be placed in bijection with
a proper subset of itself. But rigorous proofs of these statements are beyond the scope of this course
and hence we shall not pursue them.
Example 0.20 We give appropriate bijections to show that various sets are infinite. In each case,
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

54 OF 788

Q UIT

note that the codomain of the bijection is a proper subset of the domain.
1. The set N of natural numbers is infinite because we can define the 1-1 correspondence p :
1-1
df

N
P,
with
p(m)
=
m + 1.
onto
1-1

F where
2. The set E of even natural numbers is infinite because we have the bijection e : E
onto
F is the set of all multiples of 4.
3. The set of odd natural numbers is infinite. (Why?)
1-1

N by which
4. The set Z of integers is infinite because we have the following bijection z : Z
onto
the negative integers have unique images among the odd numbers and the non-negative integers
have unique images among the even numbers. More specifically,

2m
if m N
z(m) =
2m 1 otherwise
Example 0.21 The set R of reals is infinite. We outline the proof by considering the nonempty open
interval (a, b) = {p | a < p < b} and use figure 6 as a guide to understand the mapping.
_
0 0

Take any line-segment AB of length b a 6= 0 and bend it into the semi-circle A B and place
it tangent to the x-axis at the point (0, 0) (as shown in the figure). The bijection between the points
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

55 OF 788

Q UIT

y
A

(0,r) C

B
P
P

p"

Figure 6: Bijection between the arc A0 B 0 and the real line

on the semi-circle and the real numbers p, a < p < b is obvious. This semicircle has a radius
ba
. The centre C of this semi-circle is then located at the point (0, r) on the 2-dimensional
r=

plane.
Consider an arbitrary point P 0 on the semi-circle, which corresponds to a real number p, a < p < b.

The ray CP 0 intersects the x-axis at some point P 00 which has the coordinates (p00, 0). Since A0 6=
P 0 6= B 0, the ray cannot be parallel to the x-axis). Similarly from every point P 00 on the x-axis
there exists a unique point P 0 on the semi-circle such that C, P 0 and P 00 are collinear. Each point
P 0 such that A0 6= P 0 6= B 0 on this semi-circle corresponds exactly to a unique real number p in
the open interval (a, b) and vice-versa. Hence there exists a 1-1 correspondence between the points
on the semicircle (excluding the end-points of the semi-circle) and those on the x-axis. Let p00 be

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

56 OF 788

Q UIT

the x-coordinate of the point P 00. Since the composition of bijections is a bijection (see exercises),
we may compose all these bijections to obtain a 1-1 correspondence between each p in the interval
(a, b) and the real numbers.
Definition 0.22 An infinite set is said to be countable (or countably infinite) if it can be placed in
bijection with the set P Otherwise, it is said to be uncountable.
The above definition essentially says that a countably infinite set may be enumerated by selecting a
unique first element, a unique second element and so on. Countability of an infinite set therefore
implies that for any positive integer n, it should be possible to obtain the unique designated n-th
element fromt he set and also for any element in the set, it should be possible to obtain its position
in the enumeration.
Fact 0.23 The following are easy to prove.
1. An infinite set A is countable if and only if there is a bijection between A and N.
2. Every infinite subset of N is countable.
3. If A is a finite set and B is a countable set, then A B is countable.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

57 OF 788

Q UIT

4. If A and B are countable sets, then A B is also countable.


Theorem 0.24 N2 is a countable set.
Proof:
We show that N2 is countably infinite by devising a way to order the elements of N2 which guarantees
that there is indeed a 1-1 correspondence. For instance, an obvious ordering such as

...

(0, 0)
(1, 0)
(2, 0)

(0, 1)
(1, 1)
(2, 1)

(0, 2)
(1, 2)
(2, 2)
...

(0, 3)
(1, 3)
(2, 3)

...
...
...
...

is not a 1-1 correspondence because we cannot answer the following questions with (unique) answers.
1. What is the n-th element in the ordering?
2. What is the position in the ordering of the pair (a, b) for arbitrary naturals a and b?

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

58 OF 788

Q UIT

y
Di

D4

(a1, b+1)
(a, b+1)

D3
(a,b)

D2
5

D1
7

D0
x
0

Figure 7: Counting lattice-points on the diagonals

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

59 OF 788

Q UIT

So it is necessary to construct a more rigorous and ingenious device to ensure a bijection. So we

consider the ordering implicitly defined in figure 7. By traversing the blue rays D0, D1, D2, . . . in
order, we get an obvious ordering on the elements of N2. However it should be possible to give
unique answers to the above questions.
(a + b)(a + b + 1) + 2b
is the required bijection.
2

Proof outline: The function f defines essentially the traversal of the rays D0, D1, D2, . . . in order

as we shall prove. It is easy to verify that D0 contains only the pair (0, 0) and f (0, 0) = 0. Now

consider any pair (a, b) 6= (0, 0). If (a, b) lies on the ray Di, then it is clear that i = a + b. Now

consider all the pairs that lie on the rays D0, D1, . . . , Di15
Claim f : N2 N defined by f (a, b) =

The number of such pairs is given by the triangular number


i(i + 1)
2
Since we started counting from 0 this number is also the value of the lattice point (i, 0) under the
function f . This brings us to the starting point of the ray Di and after crossing b lattice points along
i + (i 1) + (i 2) + + 1 =

5 Under the usual (x, y) coordinate system, these are all the lattice points on and inside the right triangle defined by the three points (i 1, 0), (0, 0) and (0, i 1). A lattice point in the (x, y)-plane is point
whose x and y coordinates are both integers.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

60 OF 788

Q UIT

the ray Di we arrive at the point (a, b). Hence


i(i + 1)
+b
2
(a + b)(a + b + 1) + 2b
=
2
We leave it as an exercise to the reader to define the inverse of this function. (Hint: Use triangular
numbers!)
QED

f (a, b) =

Theorem 0.25 The countable union of countable sets is countable, i.e. given a family A = {Ai |
S
Ai is countable, i N} of countable sets, their union A = iN Ai is also countable.
Proof: For simplicity we assume that the sets are all pairwise disjoint i.e. Ai Aj = for each
i 6= j. Hence for each element a A, there exists a unique i N such that a Ai. This implies
1-1
there exists a bijection h : A {(i, a) | a Ai, i N}. Since each Ai is countable, there
onto

1-1

1-1

N for each i N. Define the bijection g : A N2 such that


exists a bijection fi : Ai
onto
onto
g(a) = (i, fi(a)). By theorem 0.24 it follows that A is countable.
QED

Example 0.26 Let the language M0 of minimal logic be generated by the following process from
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

61 OF 788

Q UIT

a countably infinite set of atoms A, such that A does not contain any of the symbols , ,
( and ).
1. A M0,
2. If and are any two elements of M0 then () and ( ) also belong to M0, and
3. No string other than those obtained by a finite number of applications of the above rules belongs
to M0.
We prove that the M0 is countably infinite.
Solution There are at least two possible proofs. The first one simply encodes of formulas into unique
natural numbers. The second uses induction on the structure of formulas and the fact that a countable union of countable sets yields a countable set. We postpone the second proof to the chapter on
induction. So here goes!
Proof:
Since A is countably infinite, there exists a 1 1 correspondence ord : A P
which uniquely enumerates the atoms in some order. This function may be extended to a function ord0 which includes the symbols ,(,),, such that ord0(00) = 1, ord0(() = 2,
ord0()00) = 3, ord0( 00) = 4, and ord0(A00) = ord(A00) + 4, for every A A. Let Syms =

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

62 OF 788

Q UIT

A {00, (, )00, 00}. Clearly ord0 : Syms P is also a 1 1 correspondence. Hence there
also exist inverse functions ord1 and ord01 which for any positive integer identify a unique symbol
from the domains of the two functions respectively.
Now consider any string6 belonging to Syms. It is possible to assign a unique positive integer to
this string by using powers of primes. Let p1 = 2, p2 = 3, . . . , pi, . . . be the infinite list of primes in
increasing order. Let the function encode : Syms P be defined by induction on the lengths of
the strings in Syms, as follows. Assume s Syms, a Syms and 00 denotes the empty string.
encode(00) = 1
0
encode(sa) = encode(s) pmord (a)
where s is a string of length m 1 for m 1.
It is now obvious from the unique prime-factorization of positive integers that every string in Syms
has a unique positive integer as its encoding and from any positive integer it is possible to get
the unique string that it represents. Hence Syms is a countably infinite set. Since the language
of minimal logic is a subset of the Syms it cannot be an uncountable. Hence there are only two
possibilities: either it is finite or it is countably infinite.
Claim. The language of minimal logic is not finite.
6 This

H OME PAGE

includes even arbitrary strings which are not part of the language. For example, you may have strings such as )(.

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

63 OF 788

Q UIT

Proof of claim. Suppose the language were finite. Then there exists a formula in the language
such that encode() is the maximum possible positive integer. This Syms and hence is a string
of the form a1 . . . am where each ai Syms. Clearly
encode() =

m
Y

piord (ai)

i=1

. Now consider the longer formula = (). It is easy to show that


ord0 (()

encode() = 2

ord0 (00 )

m
Y

00 )

pi+2ord (ai) pm+3ord ()

i=1

and encode() > encode() contradicting the assumption of the claim.


Hence the language is countably infinite.

QED

Not all infinite sets that can be constructed are countable. In other words even among infinite sets
there are some sets that are more infinite than others. The following theorem and the form of its
proof was first given by Georg Cantor and has been used to prove several results in logic, mathematics and computer science.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

64 OF 788

Q UIT

Theorem 0.27 (Cantors diagonalization). The powerset of N (i.e. 2N, the set of all subsets of N)
is an uncountable set.
Proof: Firstly, it should be clear that 2N is not a finite set, since it can be placed in bijection with
2P which is a proper subset of 2N.
Consider any subset A N. We may represent this set as an infinite sequence A composed of 0s
and 1s such that A(i) = 1 if i A, otherwise A(i) = 0. Let = { | for eachi N, (i) {0, 1}}
1-1
such
be the set of all such sequences. It is easy to show that there exists a bijection g : 2N
onto
that g(A) = A, for each A N. Clearly, therefore 2N is countable if and only if is countable.
1-1

N, then g f is the required bijection from 2N to N.


Hence, if there exists a bijection f :
onto
On the other hand, if there is no bijection f then 2N is uncountable if and only if is uncountable.
We make the following claim which we prove by Cantors diagonalization.
Claim. The set is uncountable.
1-1

.
We prove the claim as follows. Suppose is countable then there exists a bijection h : N
onto
In fact let h(i) = i , for each i N. Now consider the sequence constructed in such a manner

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

65 OF 788

Q UIT

that for each i N, (i) 6= i(i). In other words,



0 if i(i) = 1
(i) =
1 if i(i) = 0
Since is an infinite sequence of 0s and 1s, . But from the above construction it follows that
since is different from every sequence in it cannot be a member of , leading to a contradiction.
Hence the assumption that the bijection h exists is wrong. Hence the assumption that is countable
must be wrong.
QED

It is possible to generalize the above theorem and the proof to all powersets as follows.
Theorem 0.28 (The Powerset theorem). There is no 1-1 correspondence between a set and its
powerset.
Proof: Let A be any set and let 2A be its powerset. Assume that g : A 2A is a 1-1 correspondence between A and 2A. This implies for every a A, g(a) A is uniquely determined and
further for each B A, g 1(B) exists and is uniquely determined.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

66 OF 788

Q UIT

For any a A, a is called an interior member if a g(a) and otherwise a is an exterior member.
Consider the set
X = {x A | x 6 g(x)}
which consists of exactly the exterior members of A. Since g is a 1-1 correspondence, there exists a
unique x A such that X = g(x). Note that X could be the empty set.
x is either an interior member or an exterior member. If x is an interior member then x g(x) = X
which contradicts the assumption that X contains only exterior members. If x is an exterior member
then x 6 g(x) = X. But then since x is an exterior member x X, which is a contradiction. Hence
the assumption that there exists a 1-1 correspondence g between A and 2A must be false. QED 
Example 0.29 We show using the Schroeder-Bernstein theorem 0.7 that there exists a bijection between the sets 2P and the real closed-open interval [0, 1). We construct two injective mappings
f : 2P [0, 1) and g : [0, 1) 2P as follows: For any A P let f (A) = 0.d1d2d3 . . . such that
di = 1 if i A and di = 2 otherwise. Clearly for every A there exists a unique image in [0, 1) and
no two distinct subsets of P would have identical images. Hence f is injective.
1-1

1-1

To define g we consider only normal binary representations of real numbers. That is, we consider
only binary representations which do not have an infinite sequence of trailing 1s, since any num-

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

67 OF 788

Q UIT

ber of the form 0.b1b2 . . . bi101 equals the real number 0.b1b2 . . . bi110 which is normal. Every
real number in [1, 0) has a unique normal representation. Now consider the function defined by
g(0.b1b2b3 . . .) = {i P | bi = 1}. g is clearly a well-defined function and it is injective as well.
Hence they are both uncountable sets.
Exercise 0.1
1. Find the fallacy in the proof of the following purported theorem.
Theorem: If x = y then 2 = 1.
Proof:
1. x = y
2. x2 = xy
3. x2 y 2 = xy y 2
4. (x + y)(x y) = y(x y)
5. x + y = y
6. 2y = y
7. 2 = 1

Given
Multiply both sides by x
Subtract Y 2 from both sides
Factorize
Cancel out (x y)
Substitute x for y, by equation 1.
Divide both sides by y

QED

2. Prove that if A B then 2A 2B .


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

68 OF 788

Q UIT

3. Prove that for any binary relations R and S on a set A,


(a) (R1)1 = R
(b) (R S)1 = R1 S 1
(c) (R S)1 = R1 S 1
(d) (R S)1 = R1 S 1
4. Prove that the composition operation on relations is associative. Give an example of the composition of relations to show that relational composition is not commutative.
5. Prove that the composition of bijections is a bijection. That is, prove that for any bijective total
1-1
1-1
1-1

C.
functions f : A
B
and
g
:
B
C,
their
composition
is
the
function
g

f
:
A
onto
onto
onto
6. Is the composition of injective functions also injective? Is the composition of surjective functions
also surjective? Prove or disprove the two statements.
7. Prove that the inverse of a bijective function is also a bijective function.
8. Prove that for any binary relations R, R0 from A to B and S, S 0 from B to C, if R R0 and
S S 0 then R; S R0; S 0

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

69 OF 788

Q UIT

9. Prove or disprove7that relational composition satisfies the following distributive laws for relations, where R A B and S, T B C.
(a) R; (S T ) = (R; S) (R; T )
(b) R; (S T ) = (R; S) (R; T )
(c) R; (S T ) = (R; S) (R; T )
10. Prove that for R A B and S B C, (R; S)1 = (S 1); (R1).
11. Show that a relation R on a set A is
(a) antisymmetric if and only if R R1 IA
(b) transitive if and only if R; R R
(c) connected if and only if (A A) IA R R1
12. Consider any reflexive relation R on a set A. Does it necessarily follow that A is not asymmetric? If R is asymmetric does it necessarily follow that it is irreflexive?
13. Prove that
(a) Nn, for any n > 0 is a countably infinite set,
7 that

H OME PAGE

is, find an example of appropriate relations which actually violate the equality

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

70 OF 788

Q UIT

(b) If {Ai|i 0} is a countable collection of pair-wise disjoint sets (i.e. Ai Aj = for all
S
i 6= j) then A = i0 Ai is also a countable set.
(c) N the set of all finite sequences of natural numbers is countable.
14. Prove that
(a) N the set of all infinite sequences of natural numbers is uncountable,
(b) the set of all binary relations on a countably infinite set is an uncountable set,
(c) the set of all total functions from N to N is uncountable.
15. Prove that there exists a bijection between the set 2N and the open interval (0, 1) of real numbers.
What can you conclude about the cardinality of the set 2N in relation to the set R?
16. Prove that the composition operation on relations is associative. Give an example of the composition of relations to show that relational composition is not commutative in general.
17. Consider any reflexive relation R on a set A. Does it necessarily follow that R is not asymmetric? If R is asymmetric does it necessarily follow that it is irreflexive?
18. Prove that for any relation R on a set A,
(a) S = R (R)1 and T = (R R1) are both equivalence relations.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

71 OF 788

Q UIT

(b) Prove or disprove: S = T .


19. Given any preorder R on a set A, prove that the kernel of the preorder defined as R R1 is an
equivalence relation.
20. Consider any preorder R on a set A. We give a construction of another relation as follows. For
each a A, let [a]R be the set defined as [a]R = {b A | aRb and bRa}. Now consider the set
B = {[a]R | a A}. Let S be a relation on B such that for every a, b A, [a]RS[b]R if and only
if aRb. Prove that S is a partial order on the set B.
1-1

21. For any two sets A and B, A  B if there exists an injective function f : A B.
(a) Prove that  is a preorder on any collection of sets.
(b) Prove that any bijection between sets defines an equivalence relation on the collection of sets.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

72 OF 788

Q UIT

0.9. Induction Principles

Theorem: All natural numbers are equal.


Proof: Given a pair of natural numbers a and b, we prove they are equal by performing
complete induction on the maximum of a and b (denoted max(a, b)).
Basis. For all natural numbers less than or equal to 0, the claim holds.
Induction hypothesis. For any a and b such that max(a, b) k, for some natural k 0,
a = b.
Induction step. Let a and b be naturals such that max(a, b) = k + 1. It follows that
max(a 1, b 1) = k. By the induction hypothesis a 1 = b 1. Adding 1 on both sides
we get a = b
QED.
Fortune cookie on Linux
0.10. Mathematical Induction

Anyone who has had a good background in school mathematics must be familiar with two uses of
induction.
1. definition of functions and relations by mathematical induction, and
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

73 OF 788

Q UIT

2. proofs by the principle of mathematical induction.


Example 0.30 We present below some familiar examples of definitions by mathematical induction.
1. The factorial function on natural numbers is defined as follows.
Basis. 0! = 1
Induction step. (n + 1)! = n! (n + 1)
2. The n-th power (where n is a natural number) of a real number x is often defined as
Basis. x1 = x
Induction step. xn+1 = xn x
3. For binary relations R, S on A we define their composition (denoted R; S) as follows.
R; S = {(a, c) | for some b A, (a, b) R and (b, c) S}
We may extend this binary relational composition to an n-fold composition of a single relation
R as follows.
Basis. R1 = R

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

74 OF 788

Q UIT

Induction step. Rn+1 = R; Rn


Similarly the principle of mathematical induction is the means by which we have often proved (as
opposed to defining) properties about numbers, or statements involving the natural numbers. The
principle may be stated as follows.

Principle of Mathematical Induction Version 1


A property P holds for all natural numbers provided
Basis. P holds for 0, and
Induction step. For arbitrarily chosen n > 0,
P holds for n 1 implies P holds for n.

The underlined portion, called the induction hypothesis, is an assumption that is necessary for
the conclusion to be proved. Intuitively, the principle captures the fact that in order to prove any
statement involving natural numbers, it is suffices to do it in two steps. The first step is the basis and
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

75 OF 788

Q UIT

needs to be proved. The proof of the induction step essentially tells us that the reasoning involved in
proving the statement for all other natural numbers is the same. Hence instead of an infinitary proof
(one for each natural number) we have a compact finitary proof which exploits the similarity of the
proofs for all the naturals except the basis.
Example 0.31 We prove that all natural numbers of the form n3 + 2n are divisible by 3.
Proof:
Basis. For n = 0, we have n3 + 2n = 0 which is divisible by 3.
Induction step. Assume for an arbitrarily chosen n 0, n3 + 2n is divisible by 3. Now consider
(n + 1)3 + 2(n + 1). We have
(n + 1)3 + 2(n + 1) = (n3 + 3n2 + 3n + 1) + (2n + 2)
= (n3 + 2n) + 3(n2 + n + 1)
which clearly is divisible by 3.
QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

76 OF 788

Q UIT

Several versions of this principle exist. We state some of the most important ones. In such cases,
the underlined portion is the induction hypothesis. For example it is not necessary to consider 0 (or
even 1) as the basis step. Any integer k could be considered the basis, as long as the property is to
be proved for all n k.

Principle of Mathematical Induction Version 2


A property P holds for all natural numbers n k for some natural number k, provided
Basis. P holds for k, and
Induction step. For arbitrarily chosen n > k,
P holds for n 1 implies P holds for n.

Such a version seems very useful when the property to be proved is either not true or is undefined
for all naturals less than k. The following example illustrates this.
Example 0.32 Every positive integer n 8 is expressible as n = 3i + 5j where i, j 0.
Proof: .
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

77 OF 788

Q UIT

Basis. For n = 8, we have n = 3 + 5, i.e. i = j = 1.


Induction step. Assuming for an arbitrary n 8, n = 3i + 5j for some naturals i and j, consider
n + 1. If j = 0 then clearly i 3 and we may write n + 1 as 3(i 3) + 5(j + 2). Otherwise
n + 1 = 3(i + 2) + 5(j 1).
QED
However it is not necessary to have this new version of the Principle of mathematical induction at
all as the following reworking of the previous example shows.
Example 0.33 The property of the previous example could be equivalently reworded as follows.
For every natural number n, n + 8 is expressible as n + 8 = 3i + 5j where i, j 0.
Proof: .
Basis. For n = 0, we have n + 8 = 8 = 3 + 5, i.e. i = j = 1.
Induction step. Assuming for an arbitrary n 0, n+8 = 3i+5j for some naturals i and j, consider
n + 1. If j = 0 then clearly i 3 and we may write (n + 1) + 8 as 3(i 3) + 5(j + 2). Otherwise
(n + 1) + 8 = 3(i + 2) + 5(j 1).

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

78 OF 788

Q UIT

QED
In general any property P that holds for all naturals greater than or equal to some given k may be
transformed equivalently into a property Q, which reads exactly like P except that all occurrences
of n in P are systematically replaced by n + k. We may then prove the property Q using the
first version of the principle.
What we have stated above informally is, in fact a proof outline of the following theorem.
Theorem 0.34 The two principles of mathematical induction are equivalent. In other words, every
application of PMI - version 1 may be transformed into an application of PMI version 2 and
vice-versa.
In the sequel we will assume that the principle of mathematical induction always refers to the first
version.
0.11. Complete Induction

Often in inductive definitions and proofs it seems necessary to work with an inductive hypothesis
that includes not just the predecessor of a natural number, but some or all of their predecessors as
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

79 OF 788

Q UIT

well.
Example 0.35 The definition of the following sequence is a case of precisely such a definition where
the function F (n) is defined for all naturals as follows.
Basis. F (0) = 0
Induction step

F (n + 1) =

1
if n = 0
F (n) + F (n 1) otherwise

This is the famous Fibonacci8 sequence.


One of the properties of the Fibonacci sequence is that the sequence converges to the golden ratio9.
For any inductive proof of properties of the Fibonacci numbers, we would clearly need to assume
that the property holds for the two preceding numbers in the sequence.
In the following, we present a principle that assumes a stronger induction hypothesis. And hence
the principle itself seems weaker than the previous versions.
8 named
9 one

H OME PAGE

after Leonardo of Fibonacci.


of the solutions of the equation x2 = x + 1. It was considered an aesthetically pleasing aspect ratio for buildings in ancient Greek architecture.

JJ

II

LCS

G O BACK

F ULL S CREEN

C LOSE

80 OF 788

Q UIT

Principle of Complete Induction (PCI)


A property P holds for all natural numbers provided
Basis. P holds for 0.
Induction step. For an arbirary n > 0
P holds for every m, 0 m < n implies P holds for n

Example 0.36 Let F (0) = 0, F (1) = 1, F (2) = 1, . . ., F (n + 1) = F (n) + F (n 1), . . .


be the Fibonacci sequence. Let be the golden ratio (1 + 5)/2. We now show that the property
F (n + 1) n holds for all n.
Proof: By the principle of complete induction on n.
Basis. For n = 0, we have F (1) = 0 = 1.
Induction step. Assuming the property holds for all m, 0 m n 1, for an arbitrarily chosen

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

81 OF 788

Q UIT

n > 0, we need to prove that F (n + 1) n.


F (n + 1) =

=
=

F (n) + F (n 1)
n1 + n2
by the induction hypothesis
n2( + 1)
n
since 2 = + 1
QED

Note that the feature distinguishing the principle of mathematical induction from that of complete
induction is the induction hypothesis. It appears to be much stronger in the latter case. However,
in the following example we again prove the property in example 0.36 but this time we use the
principle of mathematical induction instead.
Example 0.37 Let P(n) denote the property
F (n + 1) n.
Rather than prove the original statement For all n, P(n) we instead consider the property Q(n)
which we define as
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

82 OF 788

Q UIT

For every m, 0 m n, P(m).


and prove the statement For all n, Q(n). This property can now be proved by mathematical
induction as follows. The reader is encouraged to study the following proof carefully.
Proof: By the principle of mathematical induction on n.
Basis. For n = 0, we have F (1) = 0 = 1.
Induction step. Assuming the property Q(n 1), holds for an arbitrarily chosen n > 0, we need to
prove the property Q for n. But for this it suffices to prove the property P for n, since Q(n) is
equivalent to the conjunction of Q(n 1) and P(n). Hence we prove the property P(n).
F (n + 1) =

=
=

F (n) + F (n 1)
n1 + n2
by the induction hypothesis
n2( + 1)
n
since 2 = + 1
QED

The above example shows quite clearly that the induction hypothesis used in any application of
complete induction though seemingly stronger, can also lead to the proof of seemingly stronger
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

83 OF 788

Q UIT

properties. But in fact, in the end the proofs are almost identical. These proofs lead us then naturally
into the next theorem.
Theorem 0.38 The two principles of mathematical induction are equivalent. In other words, every
application of PMI may be transformed into an application of PCI and vice-versa.
Proof: We need to prove the following two claims.
1. Any proof of a property using the principle of mathematical induction, is also a proof of the
same property using the principle of complete induction. This is so because the only possible
change in the nature of two proofs could be because they use different induction hypotheses.
Since the proof by mathematical induction uses a fairly weak assumption which is sufficient to
prove the property, strengthening it in any way does not need to change the rest of the proof of
the induction step.
2. For every proof of a property using the principle of complete induction, there exists a corresponding proof of the same property using the principle of mathematical induction. To prove
this claim we resort to the same trick employed in example 0.36. We merely replace each occurrence of the original property in the form P(n) by Q(n), where the property Q is defined
as
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

84 OF 788

Q UIT

For every m, 0 m n, P(m).


Since Q(0) is the same as P(0) there is no other change in the basis step of the proof. In the
original proof by complete induction the induction hypothesis would have read
For arbitrarily chosen n > 0, for all m, 0 m n 1, P(m)
whereas in the new proof by mathematical induction the induction hypothesis would read
For arbitrarily chosen n > 0, Q(n 1)
Clearly the two induction hypotheses are logically equivalent. Hence the rest of the proof of
the induction step would suffer no other change. The basis step and the induction step would
together constitute a proof by mathematical induction of the property Q for all naturals n. Since
Q(n) logically implies P(n) it follows that the proof of property P for all naturals has been done
by mathematical induction.
QED
The natural numbers are themselves defined as the smallest set N such that 0 N and whenever
n N, n + 1 also belongs to N. Therefore we may state yet another version of PMI from which the
other versions previously stated may be derived. The intuition behind this version is that a property
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

85 OF 788

Q UIT

P may also be considered as defining a set S = {x | x satisfies property P}. Therefore if a property
P is true for all natural numbers the set defined by the property must be the set of natural numbers.
This gives us the last version of the principle of mathematical induction.

Principle of Mathematical Induction Version 0


A set S = N provided
Basis. 0 S, and
Induction step. For arbitrarily chosen n > 0,
n 1 S implies n S.

We end this section with an example of the use of induction to prove that for any n N, the set of
all n-tuples of natural numbers is only countably infinite.
Example 0.39 Assume there exists a 1-1 correspondence f2 : N2 N. Use this fact to prove by
induction on n, that there exists a 1-1 correspondence fn : Nn N, for all n 2.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

86 OF 788

Q UIT

Solution. In general, to prove that a given function F : A B is a 1-1 correspondence, we may


prove it by contradiction. Then there are 2 cases to consider.
1. F is non-injective. Then there exist elements a, a0 A, such that a 6= a0 and F (a) = F (a0).
2. F is non-surjective. Then there exists an element b B such that F (a) 6= b, for any a A.
It is also easy to show that if F : A B and G : B C are both bijections then their composition
G F : A C is also a bijection.
We now proceed to prove by induction on n.
Basis. For n = 2 it is given that f2 is a bijection.
Induction step. Assume the induction hypothesis,
For some n 2 there exists a bijection fn : Nn N.
We need to prove that there exists a 1-1 correspondence (bijection) between Nn+1 and N. We prove
this by constructing a function fn+1 : Nn+1 N.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

87 OF 788

Q UIT

Let g : Nn+1 (Nn N) be the function defined by


g(x1, . . . , xn, xn+1) = ((x1, . . . , xn), xn+1)
Claim: g is a 1-1 correspondence. The proof is trivial.
Let h : Nn+1 (N N) be defined by
h(x1, . . . , xn, xn+1) = (fn(x1, . . . , xn), xn+1)
Claim: h is a 1-1 correspondence. It can be proved from the fact that fn : Nn N is a bijection.
Since f2 is also a bijection, it follows that the composition of h and f2, viz. f2 h : Nn+1 N is
df
also a bijection. Hence fn+1 defined as fn+1 = f2 h, i.e.
fn+1((x1, . . . , xn, xn+1)) = f2(h((x1, . . . , xn, xn+1)))


is a bijection.
Note.

1. Many people assume automatically that Nn+1 = Nn N or Nn+1 = N Nn. But while it is true
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

88 OF 788

Q UIT

that there exists a bijection between Nn+1 and Nn N, they are not equal as sets. Hence we have
defined the function g though it is not really necessary for the proof.
2. Very often countability is assumed by people and they try to argue that since the sets are countable there should be a bijection. But it should be clear that estabilishing a bijection is necessary
first to prove that the required sets are countable. In fact the aim of this problem is to construct
a bijection to prove that the sets N n are all countable.
0.12. Structural Induction

In many cases such as the syntactic definitions of programming languages, their semantics and the
construction of recursive data types in languages such as ML and Java, it is helpful to consider
a form of induction called structural induction. This form of induction enables us to prove fairly
general properties about the datatypes so constructed and is a convenient tool for defining functions
and proving properties about data types and programs.
Definition 0.40 Let U be a set called the Universe, B a nonempty subset of U called the basis, and
let K called the constructor set be a nonempty set of functions, such that each function f K has
associated with it a unique natural number n 0 called its arity and denoted by (f ). If a function
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

89 OF 788

Q UIT

f has an arity of n 0, then f : Un U. Let X be the family of subsets of U such that each
X X satisfies the following conditions.
Basis. B X
Induction step. if f K is of arity n 0, a1, . . . , an X then f (a1, . . . , an) X
A set A is said to be inductively defined from B, K, U if it is the smallest set (under the subset
ordering ) satisfying the above conditions i.e.
\
A=
X
(1)
XX

The set A is also said to have been generated from the basis B and the rules of generation f K.
As in the other induction principles the underlined portion is the induction hypothesis. It may not
be absolutely clear whether A defined as in (1) satisfies the two conditions of definition 0.40.
Lemma 0.41 A X where A and X are as in definition 0.40.
Proof: We need to show that A satisfies the two conditions that each X X satisfies. It is easy
to see that since since B X for each X X , we have B A and hence A does satisfy the
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

90 OF 788

Q UIT

basis condition. As for the induction step, consider any f K and elements a1, . . . , a(f ) A.
By equation (1) we have a1, . . . , a(f ) X for every X X . Therefore f (a1, . . . , a(f )) X for
every X X which implies f (a1, . . . , a(f )) A. Hence A X .
QED

We may also think of A as the smallest set (under the subset ordering) which satsfies the set equation
[
X = B {f (X n) | f K, (f ) = n 0, X U}
(2)
in the unknown X, where f (X n) = {a | a = f (a1, . . . , an), for some (a1, . . . , an) X n}. We
show in lemma 0.44 that such equations may be solved for their unique smallest solution.
Definition 0.42 Let U, B, K be as in definition 0.40. Then a sequence [a1, . . . , am] of elements of
U is called a construction sequence for am if for all i = 1, . . . , m either ai B or there exists a
constructor f K, of arity n > 0, and 0 < i1, . . . , in < i such that f (ai1 , . . . , ain ) = ai.
ai is said to directly depend on each of the elements ai1 , . . . , ain (denoted aij 1 ai for each
j {1, . . . , n}). ai depends on aj , denoted aj ai if either aj 1 ai or there exists some i0 such
that aj ai0 and ai0 1 ai.
A contains exactly all those elements of U which have a construction sequence. The basis along
with the constructor functions are said to define the terms generated by the rules of construction of
definition 0.40.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

91 OF 788

Q UIT

Example 0.43 Consider the following definition of a subclass of arithmetic expressions, called amexpressions generated only from natural numbers and the addition and multiplication operations.
The rules may be expressed in English as follows.
Basis Every natural number is an am-expression.
Induction step
addition If e and e0 are am-expressions then add(e, e0) is an am-expression.
multiplication If e and e0 are am-expressions then mult(e, e0) is an am-expression.
Initiality Only strings that are obtained by a finite number of applications of the above rules are
am-expressions (nothing else is an am- expression).
In the above definition of am-expressions N is the basis, K = {add, mult} is the set of constructors
each of arity 2 and the universe U consists of all possible finite sequences of symbols drawn from
the natural numbers and applications of the constructors. The smallest set generated from finite
sequences of applications of the basis and induction steps is the set of am-expressions involving only
the naturals and the 2-ary constructors add and mult such that every application of a constructor
has exactly two operands each of which in turn is either a natural number or constructed in a

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

92 OF 788

Q UIT

similar fashion. 0, add(0, 1), mult(add(1, 0), mult(1, 1)) are all am-expressions. On the
other hand,
1. add(0) is not an am-expression since the arity of add is 2,
2. 0, 1 is not an am-expression since it is not a natural number (it is actually a sequence of two
natural numbers) ,
3. mult(, 0) is not an am-expression since is not a natural.
The am-expression mult(add(1, 0), mult(1, 1)) has the following possible construction sequences.
1. [1, 0, add(1, 0), 1, 1, mult(1, 1), mult(add(1, 0), mult(1, 1))]
2. [1, 0, add(1, 0), mult(1, 1), mult(add(1, 0), mult(1, 1))] where replications of am-expressions have
been omitted.
3. [1, 0, mult(1, 1), add(1, 0), mult(add(1, 0), mult(1, 1))] since it does not matter in which order
the two operands of the last element in the sequence occur in the construction sequence as long
as they precede the final am-expression.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

93 OF 788

Q UIT

A convenient shorthand notation called the Backus-Naur Form (BNF) is usually employed to express
the rules of generation . For the set of am-expressions defined above the BNF is as follows.
e, e0 ::= n N | add(e, e0) | mult(e, e0)
It is possible to relate the notions of dependence in a construction sequence to the construction
process by partially ordering the process of construction of elements in an inductively generated set
as follows. Let B, K and U be as in definition 0.40. Consider the infinite sequence of sets
[A0 A1 A2 A3 ]

(3)

defined by mathematical induction as A0 = B and for each i 0, Ai+1 = Ai {f (a1, . . . , a(f )) |


f K, a1, . . . , a(f ) Ai}. Now consider the set
[
A =
Ai
(4)
i0

The following lemma shows that A = A and is indeed the smallest solution to the equation (2).
Moreover (3) gives a construction of the smallest solution by mathematical induction.
Lemma 0.44 Let B, K and U be as in definition 0.40 and A be as in equation (4). Then A = A.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

94 OF 788

Q UIT

Proof: By definition (4) Ai A for each i N


A0 A1 A2 A3 A
We structure the proof in the form of two claims. Firstly we show that A X i.e. A is a set
that satsfies the conditions in definition 0.40. Secondly, we prove that A A. It follows then that
A = A since A X for each X X .
Claim. A X .
Proof of claim. Since B = A0 A, A does satisfy the basis condition. Consider any f K
and elements a1, . . . , a(f ) A. By the definition of A, there exist indices i1, . . . , i(f ) N such
that a1 Ai1 , . . . , a(f ) Ai(f ) . Let i max(i1, . . . , i(f )). It is clear from the definition of Ai
that a1, . . . , a(f ) Ai and hence f (a1, . . . , a(f )) Ai+1 A. Hence A satisfies the second
condition too and therefore A X .
a
Claim. A A.
Proof of claim. We prove by mathematical induction on indices i, that Ai A for every index
i. The basis is trivial since we know that A0 = B A. For the induction step assume for some
k 0, Ak A. We have Ak+1 = Ak {f (a1, . . . , a(f )) | f K, a1, . . . , a(f ) Ak }. For any
a Ak we already know by the induction hypothesis that a A. Any a Ak+1 Ak is then of
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

95 OF 788

Q UIT

the form a = f (a1, . . . , a(f )) where a1, . . . , a(f ) Ak . Again by the induction hypothesis we have
a1, . . . , a(f ) A and since A X , a = f (a1, . . . , a(f )) A. Hence Ak+1 A. a QED

Lemma 0.44 and its proof, in addition to showing us how to obtain least solutions to equations of the
form (2) also show the relationship to the principle of mathematical induction. Further the lemma
gives us a way to quantify dependence of elements in a construction sequence by assigning each
element an order number.
Definition 0.45 The height of any element a (denoted 4(a)) in an inductively generated set A is the
least index i in the monotonic sequence (3) such that a Ai.
In any construction sequence [a1, . . . , am], ai aj only if the height of ai is less than the height of
aj .
Example 0.46 Let S N be the smallest set of numbers defined by
n ::= 0 | n + 1
Clearly this defines the smallest set containing 0 and closed under the successor operation on the
naturals. It follows that S = N. Notice that the above BNF is merely a rewording of the principle of
mathematical induction version 0.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

96 OF 788

Q UIT

Example 0.46 shows that mathematical induction is merely a particular case of structural induction.
Example 0.47 The language of minimal logic was defined in example 0.26. We may redefine the
language by the following BNF
, ::= a A | () | ( )
We prove that the language is countable.
Proof: We first begin by classifying the formulas of the language according to their depth. Let Mk
be the set of formulas of the language such that each formula has a depth at most k for k 0. We

assume that M0 = A and Mk+1 = Mk {(k ), (k k ) | k , k Mk }. Let Mk be the set of

all formulas of depth k + 1 of the form (k ) and let Mk be the set of all formulas of the form
(k k ), where k , k Mk . We then have

Mk+1 = Mk Mk

Mk

= Mk (Mk Mk ) (Mk Mk )
= Mk

H OME PAGE

JJ

II

Nk+1

LCS

Nk+1

G O B ACK

F ULL S CREEN

C LOSE

97 OF 788

Q UIT

Here

Nk+1 =Nk+1

Nk+1

represents the set of all formulas of depth exactly k + 1.

Nk+1

consists

Nk+1

of exactly those formulas of depth k + 1 whose root operator is . Simlarly


represents the set
of all formulas of depth exactly k + 1, whose root operator is . Hence the three sets are mutually
disjoint.
Mk

Nk+1

= , Mk

Nk+1

Nk+1

S
S
S
The entire language may then be defined as the set M0 = k0 Mk = A k>0 Nk k>0 Nk

Mk , Nk+1

= ,

Nk+1

Nk+1

and
is countably infinite for all k 0.
Claim. Each of the sets
Proof of claim. We prove this claim by induction on k. The basis is M0 = A and it is given that it is
countably infinite. The induction step proceeds as follows. We have by the induction hypothesis that
1-1
N. We use numk to construct
Mk is countably infinite. Hence there is a bijection numk : Mk
onto
the 1 1 correspondence numk+1 as follows: We may use numk to define a bijection between

Nk

and N. Similarly there exists a 1-1 correspondence between Nk+1 and N N given by the ordered

pair of numbers (numk (k ), numk (k )) for each (k k ) Nk+1. But we know that there is a 1-1
1-1

N.
correspondence diag : N N
onto

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

98 OF 788

Q UIT


Mk , Nk+1

Nk+1

Hence each of the 3 sets


and
is countably infinite. Their union is clearly countably
infinite by the following 1-1 correspondence.

if k+1 Mk

3 numk (k+1)

numk+1(k+1) = 3 numk (k ) + 1
if k+1 k Nk+1

3 diag(num ( ), num ( )) + 2 if
N
k

k+1

Hence Mk+1 is countably infinite.


Having proved the claim it follows (from the fact that a countable union of countably infinite sets
yields a countably infinite set) that M the language of minimal logic is a countably infinite set. QED
We present below a generalization of the principle of mathematical induction to arbitrary inductively
defined sets. It provides us a way of reasoning about the properties of structures that are inductively
defined.
Theorem. The Principle of Structural Induction (PSI). Let A U be inductively defined by the
basis B and the constructor set K.

H OME PAGE

JJ

II

LCS

G O BACK

F ULL S CREEN

C LOSE

99 OF 788

Q UIT

Principle of Structural Induction (PSI)


A property P holds for all elements ofA provided
Basis. P is true for all basis elements.
Induction step. For each f K, P holds for elements a1, . . . , a(f ) A implies P
holds for f (a1, . . . , a(f )).

Proof: Let P be a property of the elements of U that satisfies the conditions above. Let C be the
set of all elements of A that satisfy the property P, i.e. C = {a A | P holds for a}. It is clear
that B C A. To show that C = A[
it suffices to prove that A C = . Consider the sequence
of sets defined in (3) and the set A =
Ai as given in equation (4). We prove that for all i 0,
i0

Ai C by assuming that there is a smallest i 0 such that Ai 6 C. Since A0 = B C, Ai 6 C


implies i > 0. Consider the smallest i > 0 such that Ai 6 C. There exists a Ai Ai1 which
does not satisfy the property P. Since a 6 Ai1, we have a = f (a1, . . . , a(f )) for some f K such
that a1, . . . , a(f ) Ai1. Further by assumption Ai1 C and hence property P holds for each
of a1, . . . , a(f ). This implies by the induction step that P holds for a, contradicting the assumption
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

100 OF 788

Q UIT

that a does not satisfy P. Hence there is no smallest i such that Ai 6 C. Therefore for all i 0,
Ai C and hence A C from which it follows that P holds for every element of A. QED

Example 0.48 Consider the following BNF of arithmetic expressions
e, e0 ::= n N | (e + e) | (e e0) | (e e0)
Given a string w of symbols, a string u is called a prefix of w if there is a string v such that w = u.
v , where . denotes the (con)catenation) operation on strings. Clearly the empty string  is a prefix
of every string and every string is a prefix of itself. u is called a proper prefix of w if v is a nonempty
string.
Let e be any expression generated by the above BNF and let e0 be a prefix10 of e. Further, let L(e0)
and R(e0) denote respectively the numbers of left and right parentheses in e0. Let P be the property
of strings e in the language of arithmetic expressions given by
For every prefix e0 of e, L(e0) R(e0).
We use the principle of structural induction (theorem 0.12) to prove that property P holds for all
10 e0

H OME PAGE

may or may not be an expression of the language.

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

101 OF 788

Q UIT

expressions in the language.


Basis. It holds for all n N because no natural number has any parentheses.
Induction Hypothesis (IH).
For any e of the form (f g), where {+, x, } and f , g are themselves expressions in
the language
1. For every prefix f 0 of f , L(f 0) R(f 0) and
2. For every prefix g 0 of g, L(g 0) R(g 0)
Induction Step. We do a case analysis of all the possible prefixes of e.
Case e0 = . L(e0) = R(e0).
Case e0 = (. L(e0) = 1 > 0 = R(e0).
Case e0 = (f 0. By the induction hypothesis we have L(f 0) R(f 0) and hence L(e0) =
1 + L(f 0) > R(f 0) = R(e0).
1

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

102 OF 788

Q UIT

Case e0 = (f 0 . By the induction hypothesis we have L(f 0) R(f 0) and hence L(e0) =
1 + L(f 0) > R(f 0) = R(e0).
Case e0 = (f g 0. By the induction hypothesis we have L(f ) R(f ) and L(g 0) R(g 0).
Hence L(e0) = 1 + L(f ) + L(g 0) > R(f ) + R(g 0) = R(e0).
Case e0 = (f g. By the induction hypothesis we have L(f ) R(f ) and L(g) R(g).
Hence L(e0) = 1 + L(f ) + L(g) > R(f ) + R(g) = R(e0).
Case e0 = e = (f g)00. By the induction hypothesis we have L(f ) R(f ) and L(g)
R(g). Hence L(e0) = L(e) = 1 + L(f ) + L(g) R(f ) + R(g) + 1 = R(e0) = R(e).
We leave it as an exercise for the reader to prove that every proof by the principle of mathematical
induction may also be translated into a proof by the principle of structural induction (see example
0.46 and the equivalences between the various versions of the principle of mathematical induction
and complete induction). We are now ready to show that even though structural induction seems to
be more general than mathematical induction they are in fact equivalent in power. In other words,
every proof by the principle of structural induction may also rewritten as a proof by (some version)
of the principle of mathematical induction or complete induction. To do this we need the height (see
definition 0.45) of each element in an inductively defined set.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

103 OF 788

Q UIT

Theorem 0.49 Every proof using the principle of structural induction (PSI) may be replaced by a
proof using the principle of complete induction (PCI).
Proof: Let A be inductively defined by B, K, U and let P be a property of elements of A that has
been proved by the principle of structural induction. Let the property Q(n) for each natural number
n be defined as
The property P holds for all elements of height n
Basis. The basis step n = 0 of the proof of property Q proceeds exactly as the basis step of the proof
by PSI with as many cases are required in the proof of by PSI.
The induction hypothesis. The induction hypothesis is the assumption that Q(m) holds for all 0
m < n.
The induction step The induction step is simply that if the induction hypothesis holds for all m < n
then Q holds for n. The proof by PSI for each constructor in the induction step is a case in the
induction step of the proof Q(n).


QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

104 OF 788

Q UIT

Definition 0.50 Let A be inductively defined by B, K, and U and let V be any arbitrary set. Then
h : A V is said to be an inductively defined function if h(b) = h0(b) and h(f (a1, . . . , a(f ))) =
hf (h(a1), . . . , h(a(f ))) where h0 : B V is a function and for every n-ary constructor f K,
there is an n-ary function hf : V n V . A relation R A V is said to be inductively defined
if
R = {(b, h0(b)) | b B} {(f (a1, . . . , a(f )), hf (v1, . . . , v(f ))) | a1Rv1, . . . , a(f )Rv(f )}
Example 0.51 Consider the language P0 of propositional logic, where the basis is a countable set
A of atoms, and the language is defined by the BNF
, ::= p A | () | ( ) | ( )
Further let B = h{0, 1},, +, .i be the algebraic system whose operations are defined as follows.
0 = 1
and 1 = 0
1 + 1 = 0 + 1 = 1 + 0 = 1 and 0 + 0 = 0
0 0 = 0 1 = 1 0 = 0 and 1 1 = 1
Let 0 : A {0, 1} be a truth value assignment for the propositional atoms. Then the truth values
of propositional formulas in P0 under , is the inductively defined function T : P0 {0, 1}

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

105 OF 788

Q UIT

where = , = + and = . Therefore T extends 0 to P0 as follows.


T [p]
T [()]
T [( )]
T [( )]

=
=
=
=

0(p)
pA
T []
T [] + T []
T [] T []

0.13. Simultaneous Induction

One question that naturally arises is that if induction is merely equation solving, then are there
problems or properties which require us to solve a system of simultaneous equations? We answer
this question with the following example.
Example 0.52 Consider the following BNF which consists of the generation of three different sets
of bit strings (i.e. sequences of 0s and 1s) which are all mutually dependent.
z ::= 0 | z0 | i1
i ::= 1 | t0 | z1
t ::= i0 | t1

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

106 OF 788

Q UIT

In effect this BNF defines a system of three (simultaneous) equations.


Z = {0} {z0 2+ | z Z} {i1 2+ | i I}
I = {1} {t0 2+ | t T } {z1 2+ | z Z}
T = {i0 2+ | i I} {t1 2+ | t T }
For any bit string s let [s] denote the non-negative integer j such that s is a binary representation of
j (there could be leading zeroes). Suppose we need to prove the following property PZ of the set Z.
PZ : Z = {z 2+ | [z] is a non-negative multiple of 3}
The intuition which guides the BNF above (or equivalently the above system of equations) is the
following.
Each z Z is such that [z] = 3l for some l N i.e. [z] is a multiple of 3. In particular, the
bit-string 0 Z. The other sets in the definition of Z are constructed so that if [z] = 3l, for some
l N, then [z0] = 6l is also a multiple of 3 and for each i I, if [i] = 3m + 1 for some m N
then i1 Z since [i1] = 2(3m + 1) + 1 = 3(2m + 1) is a multiple of 3.
Likewise the definitions of I and T are such that for each i I, [i] = 3m + 1 for some natural
m and for each t T , [t] = 3n + 2 for some natural n.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

107 OF 788

Q UIT

The same intuition also guides the proof of property PZ . However, the proof is dependent upon
properties PI for the set I and PT for T where
PI : I = {i 2+ | [i] = 3m + 1, m N}
and
PT : T = {t 2+ | [t] = 3n + 2, n N}
Hence an inductive proof of property PZ requires a simultaneous proof of properties PI and PT .
Lemma 0.53 The elements of the sets Z, I and T satisfy properties PZ , PI and PT respectively.
Proof: We proceed by simultaneous induction on the lengths of strings of 2+.
Basis. There are exactly two bit strings of length 1 viz, 0 and 1 and it follows easily that 0 Z
and 1 I.
Induction Hypothesis (IH).

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

108 OF 788

Q UIT

For some k > 0,


0. each z 0 Z such that |z 0| = k satisfies property PZ ,
1. each i0 I such that |i0| = k satisfies property PI , and
2. each t0 T such that |t0| = k satisfies property PT ,
Induction Step. Consider strings of length k + 1. We need to show that
0. Property PZ holds for z = z 00 and z = i01, where |z 0| = |i0| = k,
1. Property PI holds for i = t00 and i = z 01, where |t0| = |z 0| = k,
2. Property PT holds for t = i00 and t = t01, where |i0| = |t0| = k,
We leave the rest of the proof to be completed by the interested reader.
QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

109 OF 788

Q UIT

0.14. Well-ordered Induction

We have already seen in definition 0.10 that a linear or total order is a connected partial order. We
now use this and definition 0.16 in defining a well-ordered set.
Definition 0.54 A well-ordering of a set is a well-founded total ordering of the set. A well-ordered
set is sometimes called a woset.
Fact 0.55 Let hA, i be a (nonempty) well-ordered set.
1. Every nonempty subset of A has a unique least element.
2. A has a unique least element.
Well-ordered induction generalises the principle of mathematical induction to any set A which may
be enumerated as a sequence [ai | i N] indexed by the non-negative integers. There is an implicit
total ordering in the elements such that ai aj if and only if i j in the integers.Hence any
property P (ai) of elements of the set may be regarded as a property Q(i) of the index of the element
in the set. What makes induction applicable here is the fact that the set N is well-ordered (see
defnition 0.54) by the relation . Hence were a property P to fail for some element aj in the set A,
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

110 OF 788

Q UIT

there would be a least element ai aj for which it would fail and which in turn translates to the
property Q(j) and Q(i) failing in such a fashion that for all (if any) i0 < i, Q(i0) would hold.
Theorem 0.56 The Principle of Well-ordered Induction. Let hA, i be a well-ordered set. Let
X A such that
Basis . The (unique) least element of A is in X and
Induction Step . For each a A, for every a0 A, a0 < a implies a0 X,
Then X = A
Proof: Suppose X 6= A. Then B = A X 6= . Since B A, and A is totally ordered, B has a
unique smallest element b B. But b 6 X, even though for every element a < b, a X. But by
the induction step b X, which is a contradiction.
QED
Note that in the statement of the above theorem, the basis is included (vacuously) in the induction
step. Hence the basis statement in this principle is actually superfluous.
Exercise 0.2
1. Prove that version 1, 2 and 3 of PMI are mutually equivalent.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

111 OF 788

Q UIT

2. Prove that 2+ = Z I T in example 0.52.


3. Find the fallacy in the following proof by PMI. Rectify it and again prove using PMI.
Theorem:
1
1
1
3 1
+
+ ... +
=
12 23
(n 1)n 2 n
Proof: For n=1 the LHS is 1/2 and so is RHS. assume the theorem is true for some n > 1. We
then prove the induction step.
1
1
1
1
LHS =
+
+
+ ... +
1 2 2 3 (n 1)n
n(n + 1)
3 1
1
= +
2 n n(n + 1)
3 1 1
1
= +
2 n n (n + 1)
1
3
=
2 n(n + 1)
which is required to be proved.
4. Let A be any set with a reflexive and transitive binary relation  defined on it. That is to say,
 A x A satisfies the following conditions.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

112 OF 788

Q UIT

(a) For every a A, a  a.


(b) For all a, b, c in A, a  b and b  c implies a  c.
Then show by induction that ; R =n; R for all n 1.
5. Show using PSI that T is well defined.
6. The language of numerals in the arabic notation may be defined by the following simple grammar
d ::= 0|1|2|3|4|5|6|7|8|9
n ::= d|nd
Define the value of a string in this language, so that it conforms to the normally accepted meaning of a numeral
7. For the language of propositions we may also call the function a state, and look upon the
function T as defining the truth value of a proposition in a given state . Now redefine the
meaning of a proposition as the set of states in which the proposition has a truth value of 1. if
denotes the set of all possible states i.e. = { | : B {0, 1}} then
(a) What is the domain and the range of the function ?
(b) Define the function by structural induction.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

113 OF 788

Q UIT

(c) Prove using the principle of structural induction that for any proposition p, and a state ,
T (p) = 1 if and only if tau belongs to the -meaning of p.
8. Let A be a language ,inductively defined by B, K, U. Define the set of syntax tree, TA of the
elements of A as follows:
(a) For each b B, there is a single node labelled b,
(b) For each n-ary operator and a1, . . . , an, a A, if (a1, . . . , an) = a, the syntax tree t of a
is a tree with root labelled by and t1, . . . , tn as the immediate subtree of t, where t1, . . . , tn
are the syntax trees corresponding to a1, . . . , an respectively.
(a) Prove that every element of A has a unique syntax tree if A is free.
(b) Give an example to show that every syntax tree need not define a unique element of A.
9. Let L0 be the language of propositional logic as defined in the last example. Then intuitively
speaking, a propositional formula p is a subformula of a propositional formula q if the syntax
tree of p is a subtree of the syntax tree of q.
(a) Define the notion of subformula inductively.
(b) Let of every formula q, SF(q) denote the set of all subformulas of q. Define SF(q) inductively.
(c) Let p  q if and only if p is a subformula of q. Prove that  is a partial order on L0.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

114 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

115 OF 788

Q UIT

1. Lecture 1: Introduction

Lecture 1: Introduction
Tuesday 26 July 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

116 OF 788

Q UIT

1. What is Logic?
2. Reasoning, Truth and Validity
3. Examples
4. Objectivity in Logic
5. Formal Logic
6. Formal Logic: Applications
7. Form and Content
8. Facets of Mathematical Logic
9. Logic and Computer Science

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

117 OF 788

Q UIT

What is Logic?
Logic is about reasoning:
validity of arguments
consistency among sets of statements
matters of truth and falsehood
Logic is concerned only about the form of reasoning and not
about the content

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

118 OF 788

Q UIT

Reasoning, Truth and Validity


Reasoning is sound only if it is impossible to draw false conclusions from true premises
Sound reasoning can however produce false conclusions
from false premises.
Sound reasoning can also produce true conclusions from
false premises.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

119 OF 788

Q UIT

Examples
Example 1.1
All humans live forever.
Socrates is human.
Hence Socrates lives forever.
Example 1.2
All humans are born with opposable toes
By adulthood opposable toes become non-opposable
John is an adult human
Hence John has no opposable toes.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

120 OF 788

Q UIT

Objectivity in Logic
The traditional logic of Aristotle and Leibniz are essentially
philosophical in nature with its main purpose being to investigate the objective laws of thought.
Objectivity implies essentially that arguments must be communicable to and verifiable by other people.
Objectivity has always implied formalizability.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

121 OF 788

Q UIT

The colours and shades of Logic.


The name mathematical logic may be interpreted in two ways. We may interpret logic as a subject
treated using mathematical methods. We may just as well, think of it as a subject which formalises
the methods of reasoning used in mathematics. This leads us apparently to a paradox. How can
logic be treated mathematically without using logic itself?
We resolve this paradox as follows. We simply separate out the logic that we are studying by
expressing it formally through a language the object language or the target language from the
logic that is used in reasoning about it. The latter logic that is used for reasoning is called the
meta-language.
We will define the object language formally via a grammar (and for good measure we also colourcode the sentences of the object language in green. The meta-language however, is the usual language of mathematics a mixture of natural language with mathematical symbols that is normally
used in mathematical texts. The words of these sentences will usually appear in black and some
times in other colours such as blue (e.g for emphasis) or red (e.g. when we want some concept or
idea to stand out). However since the objects of our study are green, the objects when appearing in
these sentences will still be green.
When treating any object language formally, it also becomes necessary to specify the meanings

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

122 OF 788

Q UIT

of phrases, expressions and sentences in the formal language. Since we will be expressing these
meanings through objects in mathematical structures, these objects will be coloured brown.
The study of logic promises to be pretty colourful, what?

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

123 OF 788

Q UIT

Formal Logic
Logic as a formal language with a syntax to which a semantics
had to be attached.
In turn using mathematical methods within logic, led to its
formalization as mathematical logic
The strict separation of syntax from semantics made logic
a clean and elegant mathematical discipline which could be
then applied to the foundational questions of mathematics.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

124 OF 788

Q UIT

Formal Logic: Applications


Of great use in analysing questions concerning the foundations of mathematics
In clarifying reasoning mechanisms within mathematics.
Identifying various occurrences of circular reasoning which
were previously very hard to identify.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

125 OF 788

Q UIT

Form and Content


The separation of syntax and semantics also led to the separation of form and content and
allowed the formalization of correct methods of reasoning
purely in terms of the syntax.
allowed the possibility of plugging in a semantics as demanded by an application whenever it was necessary
allowed the possibility of mechanizing reasoning completely.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

126 OF 788

Q UIT

Facets of Mathematical Logic


1. A formalization language for mathematics,
2. A calculus clarifying the notion of a mathematical proof
3. mechanization of proof
4. A sub-discipline of mathematics itself
5. A mathmatical tool applicable to various branches of mathematics.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

127 OF 788

Q UIT

Logic and Computer Science


1. Mechanization of reasoning within a formalized syntactic
setup.
2. Applications to program and system specification and verification.
3. As a declarative programming language
4. Proving theorems within areas of mathematics where the
number of cases is too high or the details of proof are too
long and tedious.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

128 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

129 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

130 OF 788

Q UIT

2. Lecture 2: Propositional Logic Syntax

Lecture 2: Propositional Logic Syntax


Wednesday 27 July 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

131 OF 788

Q UIT

1. Truth and Falsehood: 1


2. Truth and Falsehood: 2
3. Extending the Boolean Algebra
4. Table of Truth & Falsehood
5. Sums & Products
6. Propositional Logic: Syntax
7. Propositional Logic: Syntax - 2
8. Natural Language equivalents
9. Some Remarks
10. Associativity and Precedence
11. Syntactic Identity
12. Abstract Syntax Trees
13. Subformulae
14. Atoms in a Formula
15. Degree of a Formula
16. Size of a Formula
17. Height of a Formula

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

132 OF 788

Q UIT

Truth and Falsehood: 1


Our notion of meaning is restricted to absolute truth and absolute falsehood (with nothing else in between) of statements.
Definition 2.1 Let B = h2, {, ., +}, {, =}i be the 2-element
boolean algebra where 2 = {0, 1}.
We use 1 to denote absolute truth and 0 to denote absolute
falsehood and
the boolean operations have their usual meaning in the
booleans.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

133 OF 788

Q UIT

Truth and Falsehood: 2


In other words, for any a, b 2,
a = 1 a is the unary boolean inverse operation,
a + b = max(a, b) is the binary summation operation which
yields the maximum of two boolean values regarded as natural numbers,
a.b = min(a, b) is the binary product operation which yields
the minimum of two boolean values regarded as natural numbers,
a b, and a = b denote the usual binary relations less-thanor-equal-to and equals on natural numbers restricted to the
set {0, 1}.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

134 OF 788

Q UIT

Extending the Boolean Algebra


While and = are binary relations, it is possible to define corresponding binary operations as shown below.
Definition 2.2 For a, b {0, 1} define


1 if a b
1 if a = b
.
.
a b=
a=b=
0 otherwise
0 otherwise

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

135 OF 788

Q UIT

Table of Truth & Falsehood


.
a
0
0
1
1

a a
0 1
1 0

H OME PAGE

JJ

b
0
1
0
1

II

a.b a + b a . b a = b
0
0
1
1
0
1
1
0
0
1
0
0
1
1
1
1

LCS

G O B ACK

F ULL S CREEN

C LOSE

136 OF 788

Q UIT

Boolean identities

Negation
a
= a
Comparison a . b = a + b
.
Equality
a = b = (a . b).(b . a)
a+0
a+1
a+a
a+b
(a + b) + c
a + (b.c)
a+b
a+a
0
a + (a.b)

H OME PAGE

JJ

=
=
=
=
=
=
=
=
=
=

a
Identity
a.1 = a
1
Zero
a.0 = 0
a
Idempotence
a.a = a
b+a
Commutativity
a.b = b.a
a + (b + c)
Associativity
(a.b).c = a.(b.c)
(a + b).(a + c) Distributivity a.(b + c) = (a.b) + (a.c)
a.b
De Morgan
a.b = a + b
1
Simplification
a.a = 0
1
Inversion
1 = 0
a
Absorption a.(a + b) = a

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

137 OF 788

Q UIT

Sums & Products


The Associativity and Commutativity identities allow us to define summations and products over sets of boolean values.
P
df
0<in ai = a1 + + an
Q
df
0<in ai = a1. .an

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

138 OF 788

Q UIT

2.1. Propositions in Natural Languages

We now begin our study of formal logic by studying statements in natural lanaguage. We will
frequently appeal to reasoning methods employed in sentences (actually statements) in natural languages. We initially restrict our study to statements expressed in natural languages. This logic is
often called propositional or sentential logic.
In general sentences in any natural language may be classified into the following forms (usually
indicated by the mood of the sentence. A standard text book on English grammar defines a mood
as the mode or manner in which the action denoted by the verb is represented. It further illustrates
three moods in the English language. English Grammar 101 classifies the verbs in the English
language into four moods (including the infnitive as a mood. But to get really confounded and
confused, the reader needs to refer to Wikipedia where several moods are defined (e.g. optative,
jussive, potential, inferential).
The following example sentences are taken from the references above.
Indicative Mood: expresses an assertion, denial, or question.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

139 OF 788

Q UIT

Little Rock is the capital of Arakansas.


Ostriches cannot fly.
Have you finished your homework?
Imperative Mood: expresses command, prohibition, entreaty, or advice.
Dont smoke in this building.
Be careful!
Have mercy upon us.
Give us this day our daily bread.
Subjunctive Mood: expresses a doubt, a wish or an improbability
God bless you!
I wish I knew his name.
I would rather be paid by cheque.
He walks as though he were drunk.
Loosely speaking natural language sentences which are assertions or denials in the indicative mood
may be considered propositions. Questions however, cannot be considered propositions. More
accurately only those sentences to which one might (at least theoretically) ascribe a truth value
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

140 OF 788

Q UIT

(such as assertions and denials) may be considered to be propositions in our setting. Hence of the
examples given above the only ones which are of interest to us would be
Little Rock is the capital of Arakansas.

(which is an assertion) and


Ostriches cannot fly.

which is a denial (it denies the statement Ostriches can fly). The last indicative statement
Have you finished your homework?
is a question for which no truth value can be assigned. It is therefore not a proposition in the sense
that we understand propositions. Notice that a denial is an assertion too it is simply the negation of
an assertion and hence is a statement to which a truth value may be assigned. We will treat denials
also as assertions and declare that assertions in natural language are all propositions in our sense of
the term.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

141 OF 788

Q UIT

The examples that we have considered above are rather simple. We could consider more examples
of assertions, denials and complex assertions which are made up of assertions and denials. Here are
a few.
God is in his Heaven and all is right with the world.
Time and tide wait for no man.
You can fool some people some of the time, some people all of the time and all the people
some of the time, but you cannot fool all the people all the time.
Anybody who becomes the Prime Minister has a clear national and international agenda.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

142 OF 788

Q UIT

Propositional Logic: Syntax


Definition 2.3
A: a countably infinite collection of propositional atoms.
0 = {, >, , , , , }: the set of operators (also called
connectives) disjoint from A
Each operator has a fixed arity defined by with
() = (>) = 0
() = 1 and
( ) = 2, for {, , , }.
A and are disjoint and parentheses ( and ) of various kinds
are used for grouping.
P0 is the smallest set generated from A and 0.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

143 OF 788

Q UIT

Propositional Logic: Syntax - 2


Alternatively, we may define the language by the following
grammar.
Definition 2.4
, ::= | > | p A | () | ( ) | ( ) | ( ) | ( )
Each expression of this language is also called a well-formed
formula (wff) (or sentence) of P0. Each atom is a simple formula
or sentence. Each sentence having one or more occurrences
of unary or binary operators is called a compound formula. P0
is the set of all sentences.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

144 OF 788

Q UIT

Natural Language equivalents


The (unary and binary) operators of the language P0 are chosen to denote constructs that allow the construction of compound statements from simple ones. The following table shows
the intended meaning of each of the operators in the English
language.
Operator
Name
English rendering

bottom
false
>
top
true

negation
not

conjunction
and

disjunction
or

conditional
if...then

biconditional
if and only if
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

145 OF 788

Q UIT

2.2. Translation of Natural Language Statements

We may translate natural language sentences into propositions by identifying the simplest sentences
as atoms and connecting up the simple sentences using the connectives at our disposal. Naturally,
many of the subtleties of the use of the connectives in natural lanaguages would be lost in translation.
For the purposes of logical reasoning, the table given in Natural Language equivalents is sufficient
for propositional reasoning, if we ignore the subtleties in natural language such as tonal variations,
implied tense and judgmental implications that often come loaded with the sentences. We will have
more to say on this with respect to particular connectives in the following descriptions.
Negation (). This connective is used to mean not, it is not the case that and abbreviated negation
prefixes such as non- and un-. If the atom A denotes the simple statement I am at work, then
(A) denotes I am not at work. In certain cases opposites could be translated using negation.
For example, if the sentence
This dish is good.
is denoted by the atom B, the sentence
This dish is bad.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

146 OF 788

Q UIT

and the statement


This dish is not good.
are both translated as (B). Going further, the sentence
This dish is not bad.
would be translated as (B). As we shall see both the statements B and (B) would be
considered logically (though not syntactically) equivalent and the subtle difference between the
expressions good and not bad would be lost in translation.
Conjunction (). The usual meaning of conjunction as denoting and holds. In addition, the words
but, moreover, furthermore and phrases such as in addition would all be considered synonymous
with and. Notice that the sentence
Rama and Seeta went to the forest
would be considered synonymous with the sentence
Rama went to the forest and Seeta went to the forest
even though the first sentence has an implied meaning of togetherness or simultaneity.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

147 OF 788

Q UIT

The operator is commutative as we shall see later. Therefore for any formulae and ,
would be logically equivalent to . Hence the implied difference between the two sentences
(from [7])
Jane got married and had a baby.
and
Jane had a baby and got married.
is usually lost in translation.
Disjunction (). The usual meaning is an or in the inclusive sense although or is often used in
English in the exclusive sense. Hence would have to be translated to mean either or
or both and .
In our natural language arguments we will use or in the inclusive sense. either or would
refer to an or that is used in the exclusive sense. That is either or would mean that exactly
one of the two propositions holds and both cannot hold at the same time. Therefore the sentence
Ram or Shyam topped the class.
which could be equivalently rendered in English as a compound sentence

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

148 OF 788

Q UIT

Ram topped the class or Shyam topped the class.


Neither of the above sentences rules out the possibility that both Ram and Shyam topped the
class, whereas
Either Ram or Shyam topped the class.
would mean that exactly one of them could have topped the class.
Analogously one might ask what is the correct rendering of the the sentence
Neither Ram nor Shyam topped the class.
If r denotes the atomic statement Ram topped the class and s denotes the atomic statement
Shyam topped the class, then (r) (s) would be an accurate propositional rendering of the
sentence.
Conditional (). Also called the material conditional, it comes pretty close to the English conditional statement of the form If then . Alternative translations are only if , provided
and whenever .
There are other conditionals that we frequently use in English such as unless which may
be rendered as if not and would be represented by the formula (() ).

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

149 OF 788

Q UIT

Biconditional () The translation If then , not otherwise is reserved for the biconditional.
Alternative translations for are if and only if , iff , exactly when and
just in case .
The following tables adapted from [7] summarise the various English renderings of each operator
given arbitrary operands and .
Operation English rendering

not
does not hold
It is not the case that holds

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

150 OF 788

Q UIT

Operation English rendering

and
Both and
but
Not only but
although
despite
yet
while
Operation English rendering

or
or or both
and/or
unless
except when

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

151 OF 788

Q UIT

Operation English rendering


If then
if
only if
When then
when
only when
In case then
in case
provided
is a sufficient condition for
is a necessary condition for

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

152 OF 788

Q UIT

Operation English rendering


if and only if
iff
if and if
If then , and conversely
exactly if
exactly when
just in case
is a necessary and sufficient condition for

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

153 OF 788

Q UIT

Some Remarks
It is convenient to have a syntactic symbol for absolute truth
and absolute falsehood though it is strictly not necessary.
and > are constants and hence have no precedence associated with them.
In a formula of the form , is called the antecedent and
the consequent.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

154 OF 788

Q UIT

2.3. Associativity and Precedence of Operators

Notice that we have defined the language to be fully parenthesized i.e. every compound formula
is enclosed in a pair of parentheses (( )). However it may actually be very distracting and confusing to read formulae with too many parentheses. We will define precedence and associativity
conventions to reduce the number of parentheses while reading and writing formulae.
Associativity conventions. This convention refers to the consecutive occurrences of the same binary
operator. Simple examples from school arithmetic are used to illustrate the conventions used in
disambiguating expressions which are not fully parenthesized.
Left Associativity is the convention that an expression on numbers like 6 3 2 should be
read as ((6 3) 2) (which would yield the value 1). It should not be read as (6 (3 2))
(which would yield the value 5). Here we say that the subtraction operation associates to
the left or that subtraction is a left associative operation. Other binary operations such as
addition, multiplication and division on numbers are also left associative.
Right Associativity is the convention used to group consecutive occurrences of powers of num2
2
bers. For example 43 is to be read as (4(3 )) which would yield the result 49 = 262144. It
should not be read as ((43)2) which would yield the result 642 = 4096. We say that exponen-

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

155 OF 788

Q UIT

tiation is right associative.


Precedence of operators If two different binary operators occur consecutively in an expression, we
need some way to associate and group them unambiguously. This is usually specified for binary operators by a precedence relation. In school arithmetic this usually takes the form of the
bodmas rule specifying that brackets have the highest precedence followed by division and
multiplication which in turn are followed by addition and subtraction. Hence for example an
expression such as 3 4 + 5 is to be read as ((3 4) + 5) representing the value 17. It would be
wrong to read 3 4 + 5 as (3 (4 + 5)) (representing the value 3 9 = 27) since multiplication has a higher precedence than addition or multiplication precedes addition. This is usually
denoted +.
Similarly the expression 3 + 4 5 is to be read as (3 + (4 5)) yielding the value 3 + 20 = 23
and it would be wrong to read it as ((3 + 4) 5) (which represents the value 7 5 = 35).
It is the usual convention in mathematical texts that unless otherwise specified, unary operators
have a higher precedence than binary operators.
Precedence of operators with equal precedence When two distinct binary operators have equal
precedence (e.g. addition and subtraction on numbers) then our convention dictates that in the
absence of parentheses, the left operator has a higher precedence in the expression than the one

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

156 OF 788

Q UIT

on the right i.e. they should be grouped from left to right. Thus 5 + 4 3 is to be read as
((5 + 4) 3) yielding 6 (even though reading it as (5 + (4 3)) yields the same result). Similarly 5 4 + 3 should be read as ((5 4) + 3) (yielding the result 4) rather than as (5 (4 + 3))
(which yields 2). For example 24/4 3 would yield 18 by our convention. While this convention is well-established for left associative operators, it is not clear what the convention is when
there are consecutive occurrences of distinct right associative operators having equal precedence.
However in case of any confusion we may always put in enough parentheses to disambiguate the
expression.
Our interest in precedence, however is restricted to being able to translate an expression written
in linear form unambiguously into its abstract syntax tree. The use of parentheses aids in unambiguously defining an unique abstract syntax tree. Even though we write formulae in linear
form we will always implicitly assume that they represent the corresponding abstract syntax tree.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

157 OF 788

Q UIT

Associativity and Precedence


Our language has been defined to be fully parenthesized.
The binary operators and are left associative i.e. a formula written as should be read as (( ) ).
The binary operators and , on the other hand are right
associative i.e. a formula written as should be
read as ( ( )).
The operator precedence convention we follow is:

i.e. has the highest precedence and has the lowest.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

158 OF 788

Q UIT

Syntactic Identity
The precedence rules make a lot of parentheses redundant.
Instead of propositions written linearly we will rather think of
propositions as abstract syntax trees (AST).
Any two propositions and which have the same AST will
be considered syntactically identical and denoted .
If then and differ only in the presence of redundant
parentheses.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

159 OF 788

Q UIT

Abstract Syntax Trees


Abstract syntax trees are rooted directed trees (see definition
2.11)
Example 2.5 The AST of the formula ((p q) r).

q
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

160 OF 788

Q UIT

Subformulae
Definition 2.6 The set of subformulae of any formula is the
set SF () defined by induction on the structure of formulae as
follows:
SF ()
= {}
SF (>)
= {>}
SF (p)
= {p},
for each atom p
SF ()
= SF () {}
SF ( ) = SF () SF () { }, {, , , }

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

161 OF 788

Q UIT

Atoms in a Formula
Definition 2.7 The atoms of a formula is defined by induction
on the structure of formulae.
atoms()
= {}
atoms(>)
= {>}
atoms(p)
= {p},
for each atom p
atoms()
= atoms()
atoms( ) = atoms() atoms(), {, , , }

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

162 OF 788

Q UIT

Degree of a Formula
Definition 2.8 The degree of a formula is defined by induction
on the structure of formulae.
degree()
= 0
degree(>)
= 0
degree(p)
= 0,
for each atom p
degree()
= degree()
degree( ) = 1 + degree() + degree(), {, , , }

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

163 OF 788

Q UIT

Size of a Formula
Definition 2.9 The size of a formula is defined by induction on
the structure of formulae.
size()
= 1
size(>)
= 1
size(p)
= 1,
for each atom p
size()
= 1 + size()
size( ) = 1 + size() + size(), {, , , }

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

164 OF 788

Q UIT

Height of a Formula
Definition 2.10 The height of a formula is defined by induction
on the structure of formulae.
height()
= 0
height(>)
= 0
height(p)
= 0,
for each atom p
height()
= 1 + height()
height( ) = 1 + max(height(), height()), {, , , }
where max is the maximum of two numbers.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

165 OF 788

Q UIT

Exercise 2.1
1. Prove that the set P0 is countably infinite. Hint: Use the solution given in example 0.47.
2. Let T (P0) be the set of all abstract syntax trees of the language P0. Define a function AST :
P0 T (P0) which for any well-formed formula yields the corresponding unique abstract
syntax tree of the formula.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

166 OF 788

Q UIT

2.4. Rooted Trees

Definition 2.11
A directed graph is a pair hN, i consisting of a finite or a countably infinite set N of nodes
and a set N N of (directed) edges such that for any edge (s, t) (usually denoted
s t in infix notation), s is called the source and t the target of the edge. s is called a
predecessor of t and t is called a successor of s.
A (directed) path of length k 1 in a directed graph is a finite sequence of nodes n0, n1, . . . ,
nk1, nk such that ni ni+1 for each i {0, . . . , k 1}. In addition if nk = n0 the path is
called a cycle of length k, A cycle of length 1 is called a self-loop
A directed graph is called a directed acyclic graph (DAG) if it has no cycles.
An unordered (directed) tree is a directed acyclic graph such that there is at most one path
between any pair of nodes.
A (rooted directed) tree is a triple hN, , ri such that hN, i is an unordered (directed)
tree and r N is a distinguished node called the root of the tree and satisfying the following
the properties.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

167 OF 788

Q UIT

There exists a function ` : N N called the level such that `(r) = 0 and for any s t,
`(t) = `(s) + 1.
Every node in N {r} has a unique predecessor.
We will be primarily interested in rooted trees and we will simply refer to them as trees.
Notation. We will often represent a tree T specified only by a name and a root node r either as
r
-T %
or upside-down as
according to convenience.
.T &
r
Facts 2.12
Every node in N is source or a target of one or more edges,
The relation is irreflexive (i.e. there is no edge whose source and target are the same node).
The root node has no predecessor.
A leaf (node) is a node with no successor.
Definition 2.13 Let T = hN, , ri be a rooted tree.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

168 OF 788

Q UIT

T is also called a tree rooted at r.


T is infinite if N is an infinite set.
A path in T is a finite or (countably) infinite sequence r = n0 n1 n2 such that
(ni, ni+1) for each i 0.
A finite path r = n0 n1 n2 nm is said to have a length m 0. A path which is
not finite is said to be infinite.
A branch is a maximal path it is either infinite or is finite r = n0 n1 n2 nm
such that nm is a leaf.
The successors of a node s N is the set Succ(s) = {t N | s t} and predecessors of a
node t N is the set P red(t) = {s N | s t}.
+ is the transitive closure of the relation and is the reflexive-transitive closure of
.
S
The descendants of a node n N is the set Desc(n) = {n} sSucc(n) Desc(s) and Desc(n)
{n} is the set of proper descendants of n.
S
The ancestors of a node n is the set Ances(n) = {n} sP red(n) Ances(s) and the proper
ancestors of n is the set Ances(n) {n}.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

169 OF 788

Q UIT

A subtree of a rooted tree T = hN, , ri is a tree T 0 = hDesc(n), 0, ni rooted at a node


n Desc(r) such that s 0 t for s, t Desc(n) if and only if s t.
A rooted tree T = hN, , ri may be extended at a leaf n to another tree T 0 = hN 0, 0, ri
by an edge n 0 n0 provided n0 6 N , N 0 = N {n0} and n is a leaf node of T .
A rooted tree T = hN, , ri may be extended at the root r to another tree T 0 = hN 0, 0, r0i
by an edge r 0 r0 provided r0 6 N , N 0 = N {r0}. T 0 may be denoted
r0
-T %

r
or
.
r

.T &
r0
Two trees T0 = hN0, 0, r0i and T1 = hN1, 1, r1i may be joined together at a new node r
to form a new tree T = hN, , ri where N = N0 N1 {r}, =0 1 {r
r0, r r1}. T may be denoted
r
- T0 % - T1 %
. &
r0
r1
.
or
r0
r1
- %
r
. T0 & . T1 &

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

170 OF 788

Q UIT

T = hN, , ri is said to be finitely branching if for each n N , Succ(n) is a finite set.


Facts 2.14 In any rooted tree T = hN, , ri,
1. N = Desc(r)
2. Ances(n) = {s N | s n} for any n N .
3. Desc(n) = {t N | n t} for any n N .
4. A rooted tree is acyclic i.e. for all nodes n, n 6+ n.
Definition 2.15 Let T = hN, , ri be a tree rooted at node r N . A node n N is called
infinitary if Desc(n) is an infinite set otherwise it is called finitary.
Lemma 2.16 In a finitely branching tree, every infinitary node has an infinitary successor.
Proof: If not, then for some infinitary node n, Succ(n) is finite and for each s Succ(n), Desc(s)
S
is finite which implies Desc(n) = {n} sSucc(n) Desc(s) which is a finite union of finite sets.
Then Desc(n) would be finite.
QED

Lemma 2.17 (Konigs Lemma) Every finitely branching infinite tree has an infinite path.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

171 OF 788

Q UIT

Proof: Assume T = hN, , ri is a finitely branching infinite rooted tree which has no infinite
path. Clearly since N = Desc(r) is infinite, r is infinitary. r has an infinitary successor by lemma
2.16. Hence there exists a maximal path in T all of whose nodes are infinitary. This path has to be
infinite, otherwise there would be a last node in the path which is infinitary but has no successors,
which is impossible.
QED

Corollary 2.18 Every infinite tree is infinitely branching or finitely branching with at least one infinite path.

Corollary 2.19 (Contrapositive of Konigs Lemma) A finitely branching tree is finite if and only
if it has no infinite path.


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

172 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

173 OF 788

Q UIT

3. Lecture 3: Semantics of Propositional Logic

Lecture 3: Semantics of Propositional


Logic
Friday 29 July 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

174 OF 788

Q UIT

1. Semantics of Propositional Logic: 1


2. Semantics of Propositional Logic: 2
3. Models and Satisfiability
4. Example: Abstract Syntax trees
5. Tautology, Contradiction, Contingent

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

175 OF 788

Q UIT

Semantics of Propositional Logic: 1


Definition 3.1 A truth assignment is a function which assigns
to each atom a truth value.
: A {0, 1}
The truth value of a proposition is defined by induction on the
structure of propositions as a function
T J.K : P0 {0, 1}

df

We use = to denote equality by definition.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

176 OF 788

Q UIT

Semantics of Propositional Logic: 2


df

T JK = 0
df

T J>K = 1
df

T JpK = (p) for each atom p


df

T JK = T JK
df

T J K = T JK . T JK
df

T J K = T JK + T JK
df
T J K = T JK . T JK
df

T J K = T JK = T JK )
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

177 OF 788

Q UIT

Models and Satisfiability


Definition 3.2 A truth assignment is called a model of a formula (denoted ), if and only if T JK = 1. is said to
satisfy the formula .
Definition 3.3 A formula is satisfiable if it has a model. Otherwise it is said to be unsatisfiable. A set S of formulae is satisfiable if there is a model which satisfies every formula in S
(denoted S).
Fact 3.4 For any finite set S = {i | 1 i n} of formulae,
S if and only if 1 n.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

178 OF 788

Q UIT

Example: Abstract Syntax trees


In the following example we illustrate the evaluation of the truth
value of the proposition
(((p r) (p q)) (q r))
using the semantics to
.

((( (p) + (r)) = ( (p) . (q))).( (q) + (r)))

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

179 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

180 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

181 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

182 OF 788

Q UIT

(p)

H OME PAGE

(r)

JJ

(q)

(p)

(r)

(q)

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

183 OF 788

Q UIT

Tautology, Contradiction, Contingent


Definition 3.5 A proposition is said to be a
tautology or logically valid if it is true under all truth assignments.
contradiction or unsatisfiable if it is false under all truth assignments.
contingent if it is neither a tautology nor a contradiction
A formula is satisfiable if it is not a contradiction.
A formula is falsifiable if is not a tautology.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

184 OF 788

Q UIT

Exercise 3.1
1. Prove that for each truth assignment , the function T J.K is a homomorphism between the
.
algebras P0 = hP0, i and B = h{0, 1}, {, ., +, . , =}i.
2. Prove that if two truth assignments and 0 are exactly the same for elements in atoms() for
any formula , then if and only if 0 .
3. Any homomorphism h : A B from an algebra A to another algebra B (thus establishing a
1-1 correspondence between the signatures of the two algebras) induces an equivalence relation
on A . What is the nature of the equivalence relation = induced by T J.K for a truth assignment
?

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

185 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

186 OF 788

Q UIT

4. Lecture 4: Logical and Algebraic Concepts

Lecture 4: Logical and Algebraic


Concepts
Tuesday 02 August 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

187 OF 788

Q UIT

1. Logical Consequence: 1
2. Logical Consequence: 2
3. Other Theorems
4. Logical Implication
5. Implication & Equivalence
6. Logical Equivalence as a Congruence

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

188 OF 788

Q UIT

Logical Consequence: 1
Definition 4.1 A proposition P0 is called a logical consequence of a set P0 of formulas (denoted |= ) if any truth
assignment that satisfies all formulas of also satisfies .
When = then logical consequence reduces to logical validity.
|= denotes that is logically valid.
6|= denotes that is not a logical consequence of .
6|= denotes that is logically invalid.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

189 OF 788

Q UIT

Logical Consequence: 2
Theorem 4.2 Let = {i | 1 i n} be a finite set of propositions, and let be any proposition. Then |= if and only if
((. . . ((1 2) 3) . . . n) ) is a tautology.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

190 OF 788

Q UIT

Proof: ()Assume ((. . . ((1 2) 3) . . . n) ) is not a tautology. Then there exists a


truth assignment such that
T J((. . . ((1 2) 3) . . . n) )K
iff (T J(. . . ((1 2) 3) . . . n)K . T JK )
iff
(T J(. . . ((1 2) 3) . . . n)K )
iff
T J1K = . . . = T JnK

which contradicts the notion of logical consequence.

=
=
=
=

0
0
1 and T JK = 0
1 and T JK ) = 0

() Assume ((. . . ((1 2) 3) . . . n) ) is a tautology, and suppose 6|= . Then there


exists a truth assignment such that
T J1K = . . . = T JnK = 1 and T JK ) = 0
From the previous proof, we obtain
T J((. . . ((1 2) 3) . . . n) )K = 0

from which it follows that ((. . . ((1 2) 3) . . . n) ) is not a tautology, contradicting


our assumption.
QED

The following results may also be proved using the semantics of propositional logic.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

191 OF 788

Q UIT

Other Theorems
Theorem 4.3 Let = {i | 1 i n} be a finite set of propositions, and let be any proposition. Then
1. |= if and only if |= 1 (2 (n ) )
2. |= if and only if ((. . . ((1 2) 3) . . . n) ) is a
contradiction.
Corollary 4.4 A formula is a tautology iff is a contradiction
(unsatisfiable).


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

192 OF 788

Q UIT

Logical Implication
Definition 4.5 A formula logically implies another formula
(denoted ) iff |= . is called (logical) implication.
Definition 4.6 A formula is logically equivalent to another formula (denoted ) iff |= . is called (logical)
equivalence.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

193 OF 788

Q UIT

Implication & Equivalence


Fact 4.7
1. iff {} |= .
2. iff and .
3. is a preordering (reflexive and transitive) relation on P0.
4. is the kernel of i.e. = 1 and is hence indeed
an equivalence relation on P0.


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

194 OF 788

Q UIT

Logical Equivalence as a Congruence


Theorem 4.8 Logical equivalence is a congruence relation on
P0 i.e. if then
and
for each {, , , } and every formula we have




H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

195 OF 788

Q UIT

Exercise 4.1
1. Use the semantics of propositional logic to prove theorem 4.3 and corollary 4.4.
2. Prove the facts 4.7.
3. Prove that logical equivalence is indeed a congruence relation on P0.
4. For each truth assignment let = denote the equivalence defined in exercise 3.1. What is the
relationship between and = ?
5. We may define the notion of a precongruence for preorders analogously to the notion of congruence for equivalences, i.e. a preorder is a precongruence if it is preserved under each operator.
Is a precongruence on P0? If so prove it, otherwise identify the operators which preserve the
relation and for operators which do not preserve the relation give examples to show that
they are not preserved.
6. Prove that 1, , n |= if and only if for each i, 1 i n, 1, , i1, i+1, , n, |=
i.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

196 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

197 OF 788

Q UIT

5. Lecture 5: Identities and Normal Forms

Lecture 5: Identities and Normal


Forms
Friday 05 August 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

198 OF 788

Q UIT

1. Adequacy
2. Adequacy: Examples
3. Functional Completeness
4. Duality
5. Principle of Duality
6. Negation Normal Forms: 1
7. Negation Normal Forms: 2
8. Conjunctive Normal Forms
9. CNF

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

199 OF 788

Q UIT

Some identities

Negation

>

( )
( )
( )

( )

H OME PAGE

JJ

Identity
>
>
Zero

Idempotence

Commutativity
( )
Associativity ( )
( ) ( ) Distributivity ( )

De Morgan ( )
>
Simplification
>
Inversion
>

Absorption ( )

II

LCS

G O B ACK

F ULL S CREEN

( )
( ) ( )

C LOSE

200 OF 788

Q UIT

Adequacy
Some Other Important identities are:
( ) ( )

(5)

(6)

Definition 5.1 A set of operators O is said to be adequate


for propositional logic, if for every formula in P0 there is a logically equivalent formula using only the operators in O.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

201 OF 788

Q UIT

Adequacy: Examples
Example 5.2
1. From the identities (5) and (6) and the two Simplification identities it is clear that O = {, , } is an adequate set of operators for P0.
2. Further given that O = {, , } is adequate and using the
De Morgan identity and Negation, we have that
( ) ( )
and hence {, } is an adequate set.
3. We may use the other De Morgan identity
( ) ( )
to conclude that {, } is adequate.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

202 OF 788

Q UIT

Functional Completeness
It is quite possible that one could extend P0 with new operators
(perhaps 3-ary or 4-ary or indeed of any arity) and thus make
the language more expressive.
Definition 5.3 A set O of operators for propositional logic is
functionally complete (also called expressively adequate) if any
formula built up using the operators of O is logically equivalent
to a formula using operators only from .
Lemma 5.4 {, , } is a functionally complete set.
Proof

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

203 OF 788

Q UIT

Proof of lemma 5.4.


Proof: By the semantics of propositional logic, every operator of propositional logic corresponds
to an operator of the same arity on the boolean set {0, 1}. The proof follows from the construction
of truth tables in the boolean algebra B, since every truth table may be expressed using the boolean
operators {, ., +}.
a1 an
0
0 0
...
... ...
...
...
... ...
...
...
... ...
...
2n 1 1 1
bi = on(ai1 , , ain ).

Let on : 2n 2 be any n-ary operator on boolean values. Typically


b
there exists a truth table for the function on(a1, , an), which defines
b0
for each possible set of boolean values of the arguments the boolean
...
value of on(a1, , an) = b. This truth table consists of 2n rows and
...
n + 1 columns as shown below where b0, . . . , b2n1 2 (we have
...
numbered the rows by the decimal equivalent of the binary number
b2n1 that the bit-vector (a1, . . . , an) denotes in each case). For 0 i 2n,
1 j n, let aij 2 be the value assigned to variable aj such that
We may express the function as
X
Y
on(a1, , an) =
(
arj )
0r2n 1 1jn

where for each row r, and each j, 1 j n, arj = 1 if arj = 1 and arj = 0 otherwise. Similarly
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

204 OF 788

Q UIT

the product (


a
)
is
inverted
if
b
=
0
otherwise
(
r
1jn j
1jn aj ) = 1. Alternatively we have
X
Y
on(a1, , an) =
(
arj )
br =1,0r<2n arj =1,1jn

QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

205 OF 788

Q UIT

Duality
Definition 5.5
Two formulas and are called duals of each other if each
can be obtained from the other by simultaneously replacing
all occurrences of
by ,
by ,
by > and
> by
and are duals of each other and
> and are duals of each other
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

206 OF 788

Q UIT

Principle of Duality
Theorem 5.6 If atoms() = {p1, . . . , pn} and o(p1, . . . , pn)
then
o(p1, . . . , pn)
where o is the dual of o.
Proof: By structural induction and the use of the De Morgan
and Simplication laws.
QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

207 OF 788

Q UIT

Negation Normal Forms: 1


The adequacy and functional completeness of the set {, , }
may be used to build normal forms (or standard forms) by using
the logical equivalences as rewrite rules.
Definition 5.7
A literal is an atom (p A) or its negation (p for p A).
Atoms are called positive literals and their negations are
called negative literals.
A formula is in negation normal form if it is built up from literals
using only the operators and .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

208 OF 788

Q UIT

Negation Normal Forms: 2


Lemma 5.8 Every formula in P0 is logically equivalent to one in
negation normal form.
Proof: It suffices to consider only formulas containing the operators , and , and for every occurrence of negation to
push it inward using the De Morgan identities.
QED


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

209 OF 788

Q UIT

Conjunctive Normal Forms


Definition 5.9
A disjunction of literals is a formula of the form
_
1 2 m
i
1im

where m 0.
A conjunctive normal form is a formula of the form
1 2 n where j for each 1 j n is a disjunction of
literals.
We may analogously define a conjunction of literals and a disjunctive normal form (DNF).
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

210 OF 788

Q UIT

CNF
Theorem 5.10 Every formula in P0 is logically equivalent to a
conjunctive normal form.
Proof:
It suffices to consider only negation normal forms.
In each case use the distributive laws to distribute over
and use the negation law to remove multiple contiguous occurrences of negations.
QED


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

211 OF 788

Q UIT

Exercise 5.1
1. Prove that the following sets are adequate for P0.
(a) {, }
(b) {, }
2. Prove that {, } is not an adequate set.
3. Prove that if O then O or O.
4. Define BNFs to generate exactly
(a) the set N0 of negation normal forms
(b) the set C0 of conjunctive normal forms
(c) the set D0 of disjunctive normal forms.
5. Using principles of induction prove that
(a) C0 N0 P0,
(b) D0 N0 P0,
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

212 OF 788

Q UIT

6. Let o1(p1, . . . , pn) and o2(p1, . . . , pn) be formulas such that . Then prove that
o1(p1, . . . , pn) o2(p1, . . . , pn)
o1 (p1, . . . , pn) o2 (p1, . . . , pn)

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

213 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

214 OF 788

Q UIT

6. Lecture 6: Tautology Checking

Lecture 6: Tautology Checking


Tuesday 09 August 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

215 OF 788

Q UIT

1. Arguments
2. Arguments: 2
3. Validity & Falsification
4. Translation into propositional Logic
5. Atoms in Argument
6. The Representation
7. Propositional Rendering
8. The Strategy
9. Checking Tautology
10. Computing the CNF
11. Falsifying CNF

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

216 OF 788

Q UIT

Arguments
A typical informally stated argument might go as follows:
If prices rise, then the poor and the salaried class will be unhappy.
If taxes are increased then the businessmen will be unhappy.
If the poor and the salaried class or the businessmen are unhappy, the Government will not be
re-elected.
Inflation will rise if Government expenditure exceeds its revenue.
Government expenditure will exceed its revenue unless taxes are increased or the Government
resorts to deficit financing or takes a loan from the IMF to cover the deficit.
If the Government resorts to deficit financing then inflation will rise.
If inflation rises, the prices will also rise.
The Government will get reelected.
Therefore the Government will take a loan from the IMF.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

217 OF 788

Q UIT

Arguments: 2
A typical informally stated argument might go as follows:
If prices rise, then the poor and the salaried class will be unhappy.
If taxes are increased then the businessmen will be unhappy.
If

the poor and the salaried class are unhappy

or

the businessmen are unhappy,

the Government will not be re-elected.


Inflation will rise if Government expenditure exceeds its revenue.
Government expenditure will exceed its revenue

unless

taxes are increased

or

the Government resorts to deficit financing or takes a loan from the IMF to cover the deficit.
If the Government resorts to deficit financing then inflation will rise.
If inflation rises, the prices will also rise.
The Government will get reelected.
Therefore the Government will take a loan from the IMF.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

218 OF 788

Q UIT

Arguments in natural language


It turns out that the correctness or otherwise of most arguments depends entirely on the shapes of
the formulae concerned rather than their intrinsic meaning. Take the previous argument. Suppose
we uniformly replace the various atoms by say sentences from nursery rhymes as the following table
shows:
Prices rise
The poor and . . .
Taxes are increased
The businessmen will be unhappy
The Government will get re-elected
Inflation will rise
Government expenditure . . . revenue
The Government resorts . . .
The Government takes a loan . . . deficit

Mary has a little lamb


Little Bo-Peep loses her sheep
Jack and Jill go up the hill
Humpty-Dumpty sits on the wall
I am little teapot
Little Jack Horner sits in a corner
The boy stands on the burning deck
Wee Willie Winkie runs through the town
Eensy Weensy spider climbs up the water spout

Then we get the following ridiculous sounding argument

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

219 OF 788

Q UIT

If Mary has a little lamb, then Little Bo-Peep loses her sheep.
If Jack and Jill go up the hill, then Humpty-Dumpty sits on a wall.
If Little Bo-Peep loses her sheep or Humpty-Dumpty sits on a wall, then Little Miss Muffet sits on
a tuffet.
Little Jack Horner sits in a corner if the boy stands on the burning deck.
The boy stands on the burning deck unless Jack and Jill go up the hill or Wee Willie Winkie runs
through the town or Eensy Weensy spider climbs up the water spout
If Wee Willie Winkie runs through the town then Little Jack Horner sits in a corner
If Little Jack Horner sits in a corner then Mary has a little lamb.
Little Miss Muffet sits on a tuffet.
Therefore Eensy Weensy spider climbs up the water spout.
But if the original argument is logically valid then so is the new one, since logical validity depends
entirely on the so called connectives that make up the propositions and their effect on truth values.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

220 OF 788

Q UIT

Validity & Falsification


The validity of such arguments involves showing that the conclusion is a logical consequence of the hypotheses that precede it. The following alternatives exist:
1. Using a truth table.
2. Using theorem 4.2
3. Using one of the parts of theorem 4.3.
If the argument is not valid, then a falsifying assignment needs
to be also given.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

221 OF 788

Q UIT

Translation into propositional Logic


But even after translating the argument into a suitable propositional logic form, it would be quite impossible to verify the validity of the argument by truth table, since the number of atomic
propositions could be very large.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

222 OF 788

Q UIT

Atoms in Argument
The Argument

val
val
val
val
val
val
val
val
val

r i s e = ATOM "Prices rise" ;


pandsun = ATOM "The poor and ... will be unhappy" ;
t a x e s = ATOM "Taxes are increased" ;
busun = ATOM "The businessmen will be unhappy" ;
r e e l e c t = ATOM "The Government will be re-elected" ;
i n f l a t i o n = ATOM "Inflation will rise" ;
exceeds = ATOM "Government expenditure ... revenue" ;
d e f f i n = ATOM "The Government resorts ..." ;
i m f = ATOM "The Govt. takes a loan ... deficit" ;

In this case the the truth table would have 29 = 512 rows. Further, the truth table will use all the atoms, even the irrelevant
ones.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

223 OF 788

Q UIT

The Representation
d a t a t y p e Prop =
|
|
|
|
|

H OME PAGE

JJ

ATOM o f s t r i n g
NOT o f Prop
AND o f Prop Prop
OR o f Prop Prop
IMP o f Prop Prop
EQL o f Prop Prop

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

224 OF 788

Q UIT

Propositional Rendering
The Argument

val
val
val
val
val
val
val
val
val
val
val

H OME PAGE

Atoms in Argument

hyp1 = IMP ( r i s e , pandsun ) ;


hyp2 = IMP ( taxes , busun ) ;
hyp3 = IMP (OR ( pandsun , busun ) , NOT( r e e l e c t ) ) ;
hyp4 = IMP ( exceeds , i n f l a t i o n ) ;
hyp5 = IMP ( exceeds , NOT(OR( taxes , OR( d e f f i n , i m f ) ) ) ) ;
hyp6 = IMP ( d e f f i n , i n f l a t i o n ) ;
hyp7 = IMP ( i n f l a t i o n , r i s e ) ;
hyp8 = r e e l e c t ;
conc1 = i m f ;
H = [ hyp1 , hyp2 , . . . , hyp8 ] ;
Arg1 = (H, conc1 ) ;

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

225 OF 788

Q UIT

The Strategy
We need to either show that
Arg1 = IM P (bigAN D H, conc1)
is a tautology or can be falsified. Using theorem 4.2 for validity
v a l bigAND = l e f t R e d u c e (AND ) ;
f u n V a l i d ( ( H, P ) : Argument ) =
i f n u l l (H) then t a u t o l o g y ( P )
e l s e t a u t o l o g y ( IMP ( bigAND (H) , P ) )

and for falsification we use


f u n f a l s i f y A r g ( ( H, P ) : Argument ) =
i f n u l l (H) then f a l s i f y ( c n f ( P ) )
e l s e f a l s i f y ( c n f ( IMP ( bigAND (H) , P ) ) )

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

226 OF 788

Q UIT

Checking Tautology
Checking for tautology crucially involves finding falsifying truth
assignments for at last one of the conjuncts in the CNF of the
argument.
fun tautology2 (P) =
l e t va l Q = cnf (P ) ;
v a l LL = f a l s i f y (Q)
in
i f n u l l ( LL ) then ( t r u e , [ ] )
e l s e ( f a l s e , LL )
end

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

227 OF 788

Q UIT

Computing the CNF


1. Rewrite implications and equivalences
2. Convert to NNF by pushing negation inward
3. Distribute OR over AN D

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

228 OF 788

Q UIT

cnflistlist.sml

( ======================== THE SIGNATURE P r o p L o g i c ======================


s i g n a t u r e PropLogic =
sig
exception Atom exception
d a t a t y p e Prop =
ATOM o f s t r i n g
|
NOT o f P r o p
|
AND o f P r o p P r o p |
OR o f P r o p P r o p |
IMP o f P r o p P r o p |
EQL o f P r o p P r o p
t y p e Argument = P r o p l i s t P r o p
v a l show
: P r o p > u n i t
v a l showArg : Argument > u n i t
v a l f a l s i f y A r g : Argument > P r o p l i s t l i s t
val Valid
: Argument > b o o l P r o p l i s t l i s t
end ;
( P r o p o s i t i o n a l formulas )
======================== THE STRUCTURE PL ====================== )
( s t r u c t u r e PL : P r o p L o g i c = )
s t r u c t u r e PL = ( T h i s i s f o r d e b u g g i n g p u r p o s e s o n l y )
struct
d a t a t y p e Prop =

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

229 OF 788

Q UIT

ATOM o f s t r i n g
NOT o f P r o p
AND o f P r o p P r o p
OR o f P r o p P r o p
IMP o f P r o p P r o p
EQL o f P r o p P r o p

|
|
|
|
|

;
( P r o p o s i t i o n s t o CNFs )
exception Atom exception ;
f u n newatom ( s ) = i f s = "" t h e n r a i s e A t o m e x c e p t i o n
e l s e (ATOM s ) ;
f u n drawChar ( c , n ) =
i f n>0 t h e n ( p r i n t ( s t r ( c ) ) ; drawChar ( c , ( n 1 ) ) )
else ();
f u n show ( P ) =
let
f u n drawTabs ( n ) = drawChar ( # "\t" , n ) ;
f u n s h o w T r e e T a b s (ATOM a , n ) = ( drawTabs ( n ) ;
print (a );
p r i n t ( "\n" )
)
|
s h o w T r e e T a b s (NOT ( P ) , n ) = ( drawTabs ( n ) ; p r i n t ( "NOT" ) ;
s h o w T r e e T a b s ( P , n + 1)
)
|
s h o w T r e e T a b s (AND ( P , Q) , n ) =
( showTreeTabs ( P , n + 1 ) ;
drawTabs ( n ) ; p r i n t ( "AND\n" ) ;

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

230 OF 788

Q UIT

in

s h o w T r e e T a b s (Q, n + 1)
)
s h o w T r e e T a b s (OR ( P , Q) , n ) =
( showTreeTabs ( P , n + 1 ) ;
drawTabs ( n ) ; p r i n t ( "OR\n" ) ;
s h o w T r e e T a b s (Q, n + 1)
)
s h o w T r e e T a b s ( IMP ( P , Q) , n ) =
( showTreeTabs ( P , n + 1 ) ;
drawTabs ( n ) ; p r i n t ( "IMPLIES\n" ) ;
s h o w T r e e T a b s (Q, n + 1)
)
s h o w T r e e T a b s (EQL ( P , Q) , n ) =
( showTreeTabs ( P , n + 1 ) ;
drawTabs ( n ) ; p r i n t ( "IFF\n" ) ;
s h o w T r e e T a b s (Q, n + 1)
)

;
( p r i n t ( "\n" ) ; s h o w T r e e T a b s ( P , 0 ) ; p r i n t ( "\n" ) )

end
;

( The f u n c t i o n below e v a l u a t e s a f o r m u l a g i v e n a t r u t h a s s i g n m e n t .
The t r u t h a s s i g n m e n t i s g i v e n a s a l i s t o f a t o m s t h a t a r e t r u e
( a l l o t h e r atoms a r e f a l s e ) .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

231 OF 788

Q UIT

f u n l o o k u p ( x : Prop , [ ] ) = f a l s e
|
lookup ( x , h : : L)
= ( x = h ) o r e l s e lookup ( x , L)
;
fun
|
|
|
|
|
;

eval
eval
eval
eval
eval
eval

(ATOM a , L )
(NOT ( P ) , L )
(AND ( P , Q) , L )
(OR ( P , Q) , L )
( IMP ( P , Q) , L )
(EQL ( P , Q) , L )

=
=
=
=
=
=

l o o k u p (ATOM a , L )
i f eval (P , L) then f a l s e e l s e t r u e
e v a l ( P , L ) a n d a l s o e v a l (Q, L )
e v a l ( P , L ) o r e l s e e v a l (Q, L )
e v a l (OR (NOT ( P ) , Q) , L )
( e v a l ( P , L ) = e v a l (Q, L ) )

( We c o u l d a l s o w r i t e a t a u t o l o g y c h e c k e r w i t h o u t u s i n g t r u t h
a s s i g n m e n t s by f i r s t c o n v e r t i n g e v e r y t h i n g i n t o a n o r m a l form .
)
( F i r s t r e w r i t e i m p l i c a t i o n s and e q u i v a l e n c e s )
fun
|
|
|
|
|
;

H OME PAGE

rewrite
rewrite
rewrite
rewrite
rewrite
rewrite

JJ

(ATOM a )
(NOT ( P ) )
(AND ( P , Q ) )
(OR ( P , Q ) )
( IMP ( P , Q ) )
(EQL ( P , Q ) )

=
=
=
=
=
=

ATOM a
NOT ( r e w r i t e ( P ) )
AND ( r e w r i t e ( P ) , r e w r i t e (Q ) )
OR ( r e w r i t e ( P ) , r e w r i t e (Q ) )
OR (NOT ( r e w r i t e ( P ) ) , r e w r i t e (Q ) )
r e w r i t e (AND ( IMP ( P , Q) , IMP (Q, P ) ) )

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

232 OF 788

Q UIT

( C o n v e r t a l l f o r m u l a s n o t c o n t a i n i n g IMP o r EQL i n t o N e g a t i o n Normal


Form .
)
fun
|
|
|
|
|
|
;

nnf
nnf
nnf
nnf
nnf
nnf
nnf

(ATOM a )
(NOT (ATOM a ) )
(NOT (NOT ( P ) ) )
(AND ( P , Q ) )
(NOT (AND ( P , Q ) ) )
(OR ( P , Q ) )
(NOT (OR ( P , Q ) ) )

=
=
=
=
=
=
=

ATOM a
NOT (ATOM a )
nnf ( P )
AND ( n n f ( P ) , n n f (Q ) )
n n f (OR (NOT ( P ) , NOT (Q ) ) )
OR ( n n f ( P ) , n n f (Q ) )
n n f (AND (NOT ( P ) , NOT (Q ) ) )

( D i s t r i b u t e OR o v e r AND t o g e t a NNF i n t o CNF )


f u n d i s t O R ( P , AND (Q, R ) ) = AND ( d i s t O R ( P , Q) , d i s t O R ( P , R ) )
|
d i s t O R (AND (Q, R ) , P ) = AND ( d i s t O R (Q, P ) , d i s t O R ( R , P ) )
|
d i s t O R ( P , Q)
= OR ( P , Q)
( Now t h e CNF c a n be e a s i l y computed )
f u n c o n j o f d i s j (AND ( P , Q ) ) = AND ( c o n j o f d i s j ( P ) , c o n j o f d i s j (Q ) )
|
c o n j o f d i s j (OR ( P , Q ) ) = d i s t O R ( c o n j o f d i s j ( P ) , c o n j o f d i s j (Q ) )
|
conj of disj (P)
= P
;
fun cnf ( P ) = c o n j o f d i s j ( nnf ( r e w r i t e ( P ) ) ) ;

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

233 OF 788

Q UIT

( P r o p o s i t i o n s t o CNFs e n d s )
( CNFs t o l i s t s o f l i s t s o f l i t e r a l s )
( Convert a clause i n t o a l i s t of l i t e r a l s )
f u n f l a t t e n O R (OR (A, B ) ) = ( f l a t t e n O R A) @ ( f l a t t e n O R B)
| flattenOR C
= [C] ( a s s u m i n g C i s a l i t e r a l )
( C o n v e r t a CNF i n t o a l i s t o f l i s t s o f c l a u s e s )
f u n f l a t t e n A N D (AND (Q, R ) ) = ( f l a t t e n A N D Q) @ ( f l a t t e n A N D R)
| flattenAND ( P )
= [ flattenOR P ] ( assuming P i s a c l a u s e )
( S o r t t h e l i t L i s t L i s t u s i n g some o r d e r i n g and remove d u p l i c a t e s w h i l e s o r t i n g )
( D e f i n e an o r d e r i n g l i t L e s s on l i t e r a l s : )
f u n l i t L e s s (ATOM ( a ) , ATOM ( b ) )
=
| l i t L e s s (NOT(ATOM a ) , NOT(ATOM b ) ) =
( every negative l i t e r a l i s smaller
| l i t L e s s (NOT(ATOM a ) , ATOM ( b ) )
=
| l i t L e s s (ATOM ( a ) , NOT(ATOM b ) )
=

a < b ( l e x i c o g r a p h i c )
a < b
than every p o s i t i v e l i t e r a l )
true
false

( Extend t h e o r d e r i n g to l i s t s of l i t e r a l s )
fun c l a u s e L e s s ( [ ] , [ ] )
| clauseLess ([] ,
)
| clauseLess ( ,
[])

H OME PAGE

JJ

= false
= true
= false

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

234 OF 788

Q UIT

| c l a u s e L e s s ( h1 : : T1 , h2 : : T2 ) =
( l i t L e s s ( h1 , h2 ) ) o r e l s e
( ( h1=h2 ) a n d a l s o c l a u s e L e s s ( T1 , T2 ) )
( D e f i n e mergeSortRD t o remove d u p l i c a t e s a s s o r t i n g p r o c e e d s )
f u n mergeSortRD R [ ] = [ ]
| mergeSortRD R [ h ] = [ h ]
| mergeSortRD R L = ( can t s p l i t a l i s t u n l e s s i t h a s > 1 e l e m e n t )
l e t fun s p l i t [ ] = ( [ ] , [ ] )
| split [h] = ([h] , [])
| s p l i t ( h1 : : h2 : : t ) =
l e t val ( left , right ) = s p l i t t ;
i n ( h1 : : l e f t , h2 : : r i g h t )
end ;
val ( left , right ) = s p l i t L;
f u n mergeRD ( R , [ ] , [ ] ) = [ ]
| mergeRD ( R , [ ] , L2 ) = L2
| mergeRD ( R , L1 , [ ] ) = L1
| mergeRD ( R , ( L1 a s h1 : : t 1 ) , ( L2 a s h2 : : t 2 ) ) =
i f h1=h2 t h e n mergeRD ( R , t 1 , L2 ) ( remove a copy )
e l s e i f R( h1 , h2 ) t h e n h1 : : ( mergeRD ( R , t 1 , L2 ) )
e l s e h2 : : ( mergeRD ( R , L1 , t 2 ) ) ;
v a l s o r t e d L e f t = mergeSortRD R l e f t ;
v a l s o r t e d R i g h t = mergeSortRD R r i g h t ;
i n mergeRD ( R , s o r t e d L e f t , s o r t e d R i g h t )
end ;

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

235 OF 788

Q UIT

( Now s o r t t h e l i s t o f l i s t s o f l i t e r a l s r e m o v i n g d u p l i c a t e s )
f u n s o r t R D LL = ( F i r s t s o r t e a c h c l a u s e and t h e n t h e l i s t o f c l a u s e s )
l e t v a l s o r t e d C l a u s e s = map ( mergeSortRD l i t L e s s ) LL
i n mergeSortRD c l a u s e L e s s s o r t e d C l a u s e s
end ;
( P u t t i n g everything t o g e t h e r )
fun p r o p 2 l i s t l i s t P =
end ( s t r u c t ) ;

sortRD ( flattenAND ( cnf P ) )

open PL ;
( T e s t i n g p r o p 2 l i s t l i s t ====================================
val
god = ATOM T h e r e i s a God ;
v a l god = ATOM T h e r e i s a God : P r o p
val
o s c i e n t = ATOM God i s o m n i s c i e n t ;
val
o p o t e n t = ATOM God i s o m n i p o t e n t ;
val
e v i l = ATOM T h e r e i s E v i l ;
val
know = ATOM God knows t h e r e i s E v i l ;
val
p r e v e n t = ATOM God p r e v e n t s E v i l ;
val
val
val
val
val

H OME PAGE

hy1 = IMP ( god , AND ( o s c i e n t , o p o t e n t ) ) ;


hy2 = IMP ( o s c i e n t , know ) ;
hy3 = IMP ( o p o t e n t , p r e v e n t ) ;
hy4 = e v i l ;
c o n c = NOT ( god ) ;

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

236 OF 788

Q UIT

v a l o s c i e n t = ATOM God i s o m n i s c i e n t : P r o p
GC # 0 . 0 . 0 . 1 . 7 . 1 8 7 :
( 1 ms )
v a l o p o t e n t = ATOM God i s o m n i p o t e n t : P r o p
v a l e v i l = ATOM T h e r e i s E v i l : P r o p
v a l know = ATOM God knows t h e r e i s E v i l : P r o p
v a l p r e v e n t = ATOM God p r e v e n t s E v i l : P r o p
v a l hy1 = IMP (ATOM T h e r e i s a God ,AND (ATOM # ,ATOM # ) ) : P r o p
v a l hy2 = IMP (ATOM God i s o m n i s c i e n t ,ATOM God knows t h e r e i s E v i l ) : P r o p
v a l hy3 = IMP (ATOM God i s o m n i p o t e n t ,ATOM God p r e v e n t s E v i l ) : P r o p
v a l hy4 = ATOM T h e r e i s E v i l : P r o p
v a l c o n c = NOT (ATOM T h e r e i s a God ) : P r o p
p r o p 2 l i s t l i s t hy1 ;
val i t =
[ [ NOT (ATOM T h e r e i s a God ) ,ATOM God i s o m n i p o t e n t ] ,
[NOT (ATOM T h e r e i s a God ) ,ATOM God i s o m n i s c i e n t ] ] : P r o p l i s t l i s t
p r o p 2 l i s t l i s t hy2 ;
v a l i t = [ [ NOT (ATOM God i s o m n i s c i e n t ) ,ATOM God knows t h e r e i s E v i l ] ]
: Prop l i s t l i s t
v a l andhyp = AND ( hy1 , AND ( hy2 , AND( hy3 , hy4 ) ) ) ;
v a l andhyp = AND ( IMP (ATOM # ,AND # ) ,AND ( IMP # ,AND # ) ) : P r o p
p r o p 2 l i s t l i s t andhyp ;
val i t =
[ [ NOT (ATOM God i s o m n i p o t e n t ) ,ATOM God p r e v e n t s E v i l ] ,
[NOT (ATOM God i s o m n i s c i e n t ) ,ATOM God knows t h e r e i s E v i l ] ,
[NOT (ATOM T h e r e i s a God ) ,ATOM God i s o m n i p o t e n t ] ,
[NOT (ATOM T h e r e i s a God ) ,ATOM God i s o m n i s c i e n t ] ,
[ATOM T h e r e i s E v i l ] ] : P r o p l i s t l i s t

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

237 OF 788

Q UIT

v a l a = ATOM a ;
v a l a = ATOM a : P r o p
v a l b = ATOM b ;
v a l b = ATOM b : P r o p
v a l c = ATOM c ;
v a l c = ATOM c : P r o p
v a l one = IMP ( a , OR ( a , a ) ) ;
v a l one = IMP (ATOM a ,OR (ATOM # ,ATOM # ) ) : P r o p
v a l two = EQL( b , OR( b , NOT( b ) ) ) ;
v a l two = EQL (ATOM b ,OR (ATOM # ,NOT # ) ) : P r o p
v a l t h r e e = EQL(AND( a , a ) , OR(NOT( a ) , OR( a , NOT( a ) ) ) ) ;
GC # 0 . 0 . 0 . 1 . 8 . 2 2 1 :
( 1 ms )
v a l t h r e e = EQL (AND (ATOM # ,ATOM # ) ,OR (NOT # ,OR # ) ) : P r o p
val p2ll = p r o p 2 l i s t l i s t ;
v a l p 2 l l = f n : P r o p > P r o p l i s t l i s t
p 2 l l one ;
v a l i t = [ [ NOT (ATOM a ) ,ATOM a ] ] : P r o p l i s t l i s t
p 2 l l two ;
v a l i t = [ [ NOT (ATOM b ) ,ATOM b ] , [ATOM b ] ] : P r o p l i s t l i s t
p2ll three ;
v a l i t = [ [ NOT (ATOM a ) ,ATOM a ] , [ATOM a ] ] : P r o p l i s t l i s t
p 2 l l (OR( one , OR( two , t h r e e ) ) ) ;
val i t =
[ [ NOT (ATOM a ) ,NOT (ATOM b ) ,ATOM a ,ATOM b ] ,
[NOT (ATOM a ) ,ATOM a ,ATOM b ] ] : P r o p l i s t l i s t

=============================================================== )

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

238 OF 788

Q UIT

Falsifying CNF
1. Suffices to find a falsification of at least one conjunct
2. A conjunct in the CNF can be false iff all the disjuncts in it are
false.
3. A disjunct is false iff it does not contain a complementary
pair.
Wni
Vm
Assume the CNF is Q i=1 Di where each Di j=1 Lij
where the literals of Di = Pi Ni where Pi is the set of positive literals (atoms) and Ni consists of the atoms appearing as
negative literals.
Then Di is false iff Pi Ni = .
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

239 OF 788

Q UIT

tautology1.sml

s i g n a t u r e PropLogic =
sig
exception Atom exception
d a t a t y p e Prop =
ATOM o f s t r i n g
|
NOT o f P r o p
|
AND o f P r o p P r o p |
OR o f P r o p P r o p |
IMP o f P r o p P r o p |
EQL o f P r o p P r o p
t y p e Argument = P r o p l i s t P r o p
v a l show
: P r o p > u n i t
v a l showArg : Argument > u n i t
v a l f a l s i f y A r g : Argument > P r o p l i s t l i s t
val Valid
: Argument > b o o l P r o p l i s t l i s t
end ;
( P r o p o s i t i o n a l formulas )
s t r u c t u r e PL : P r o p L o g i c =
( s t r u c t u r e PL = ) ( T h i s i s f o r d e b u g g i n g p u r p o s e s o n l y )
struct
d a t a t y p e Prop =
ATOM o f s t r i n g

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

240 OF 788

Q UIT

NOT o f P r o p
AND o f P r o p P r o p
OR o f P r o p P r o p
IMP o f P r o p P r o p
EQL o f P r o p P r o p

|
|
|
|

;
exception Atom exception ;
f u n newatom ( s ) = i f s = "" t h e n r a i s e A t o m e x c e p t i o n
e l s e (ATOM s ) ;
f u n drawChar ( c , n ) =
i f n>0 t h e n ( p r i n t ( s t r ( c ) ) ; drawChar ( c , ( n 1 ) ) )
else ();
f u n show ( P ) =
let
f u n drawTabs ( n ) = drawChar ( # "\t" , n ) ;
f u n s h o w T r e e T a b s (ATOM a , n ) = ( drawTabs ( n ) ;
print (a );
p r i n t ( "\n" )
)
|
s h o w T r e e T a b s (NOT ( P ) , n ) = ( drawTabs ( n ) ; p r i n t ( "NOT" ) ;
s h o w T r e e T a b s ( P , n + 1)
)
|
s h o w T r e e T a b s (AND ( P , Q) , n ) =
( showTreeTabs ( P , n + 1 ) ;
drawTabs ( n ) ; p r i n t ( "AND\n" ) ;
s h o w T r e e T a b s (Q, n + 1)
)
|
s h o w T r e e T a b s (OR ( P , Q) , n ) =

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

241 OF 788

Q UIT

( showTreeTabs ( P , n + 1 ) ;
drawTabs ( n ) ; p r i n t ( "OR\n" ) ;
s h o w T r e e T a b s (Q, n + 1)
)
|

in

s h o w T r e e T a b s ( IMP ( P , Q) , n ) =
( showTreeTabs ( P , n + 1 ) ;
drawTabs ( n ) ; p r i n t ( "IMPLIES\n" ) ;
s h o w T r e e T a b s (Q, n + 1)
)
s h o w T r e e T a b s (EQL ( P , Q) , n ) =
( showTreeTabs ( P , n + 1 ) ;
drawTabs ( n ) ; p r i n t ( "IFF\n" ) ;
s h o w T r e e T a b s (Q, n + 1)
)

;
( p r i n t ( "\n" ) ; s h o w T r e e T a b s ( P , 0 ) ; p r i n t ( "\n" ) )

end
;
( The f u n c t i o n below e v a l u a t e s a f o r m u l a g i v e n a t r u t h a s s i g n m e n t .
The t r u t h a s s i g n m e n t i s g i v e n a s a l i s t o f a t o m s t h a t a r e a s s i g n e d
t r u e ( i m p l i c i t l y a l l o t h e r a t o m s a r e assume d t o h a v e b e e n
assigned false ).
)

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

242 OF 788

Q UIT

f u n l o o k u p ( x : Prop , [ ] ) = f a l s e
|
lookup ( x , h : : L) =
i f ( x = h ) then true
e l s e lookup ( x , L)
;
fun
|
|
|
|
|
;

eval
eval
eval
eval
eval
eval

( We
)

(ATOM a , L ) = l o o k u p (ATOM a , L )
(NOT ( P ) , L ) = i f e v a l ( P , L ) t h e n f a l s e e l s e t r u e
(AND ( P , Q) , L ) = e v a l ( P , L ) a n d a l s o e v a l (Q, L )
(OR ( P , Q) , L ) = e v a l ( P , L ) o r e l s e e v a l (Q, L )
( IMP ( P , Q) , L ) = e v a l (OR (NOT ( P ) , Q) , L )
(EQL ( P , Q) , L ) = ( e v a l ( P , L ) = e v a l (Q, L ) )

f i r s t c o n v e r t e v e r y p r o p o s i t i o n i n t o a n o r m a l form .

( F i r s t r e w r i t e i m p l i c a t i o n s and e q u i v a l e n c e s )
fun
|
|
|
|
|
;

H OME PAGE

rewrite
rewrite
rewrite
rewrite
rewrite
rewrite

JJ

(ATOM a )
(NOT ( P ) )
(AND ( P , Q ) )
(OR ( P , Q ) )
( IMP ( P , Q ) )
(EQL ( P , Q ) )

=
=
=
=

= ATOM a
= NOT ( r e w r i t e ( P ) )
AND ( r e w r i t e ( P ) , r e w r i t e (Q ) )
OR ( r e w r i t e ( P ) , r e w r i t e (Q ) )
OR (NOT ( r e w r i t e ( P ) ) , r e w r i t e (Q ) )
r e w r i t e (AND ( IMP ( P , Q) , IMP (Q, P ) ) )

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

243 OF 788

Q UIT

( C o n v e r t a l l f o r m u l a s n o t c o n t a i n i n g IMP o r EQL i n t o N e g a t i o n Normal


Form .
)
fun
|
|
|
|
|
|
;

nnf
nnf
nnf
nnf
nnf
nnf
nnf

(ATOM a )
= ATOM a
(NOT (ATOM a ) )
= NOT (ATOM a )
(NOT (NOT ( P ) ) )
= nnf ( P )
(AND ( P , Q ) )
= AND ( n n f ( P ) , n n f (Q ) )
(NOT (AND ( P , Q ) ) ) = n n f (OR (NOT ( P ) , NOT (Q ) ) )
(OR ( P , Q ) )
= OR ( n n f ( P ) , n n f (Q ) )
(NOT (OR ( P , Q ) ) ) = n n f (AND (NOT ( P ) , NOT (Q ) ) )

( D i s t r i b u t e OR o v e r AND t o g e t a NNF i n t o CNF )


f u n d i s t O R ( P , AND (Q, R ) ) = AND ( d i s t O R ( P , Q) , d i s t O R ( P , R ) )
|
d i s t O R (AND (Q, R ) , P ) = AND ( d i s t O R (Q, P ) , d i s t O R ( R , P ) )
|
d i s t O R ( P , Q)
= OR ( P , Q)
( Now t h e CNF c a n be e a s i l y computed )
f u n c o n j o f d i s j (AND ( P , Q ) ) = AND ( c o n j o f d i s j ( P ) , c o n j o f d i s j (Q ) )
|
c o n j o f d i s j (OR ( P , Q ) ) = d i s t O R ( c o n j o f d i s j ( P ) , c o n j o f d i s j (Q ) )
|
conj of disj (P)
= P
;
fun cnf ( P ) = c o n j o f d i s j ( nnf ( r e w r i t e ( P ) ) ) ;

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

244 OF 788

Q UIT

( A p r o p o s i t i o n i n CNF i s a t a u t o l o g y
iff
Every c o n j u n c t i s a t a u t o l o g y
iff
E v e r y d i s j u n c t i n e v e r y c o n j u n c t c o n t a i n s b o t h p o s i t i v e and n e g a t i v e
l i t e r a l s o f a t l e a s t one atom
So we c o n s t r u c t t h e l i s t o f a l l t h e p o s i t i v e and n e g a t i v e a t o m s i n e v e r y
d i s j u n c t t o c h e c k w h e t h e r t h e l i s t s a r e a l l e q u a l . We n e e d a b i n a r y
f u n c t i o n on l i s t s t o d e t e r m i n e w h e t h e r two l i s t s a r e d i s j o i n t
)
fun i s P r e s e n t ( a , [ ] ) = f a l s e
|
i s P r e s e n t ( a , b : : L) = ( a = b ) o r e l s e i s P r e s e n t ( a , L)
;
f u n d i s j o i n t ( [ ] , M) = t r u e
|
d i s j o i n t (L, [ ] ) = true
|
d i s j o i n t ( L a s a : : LL , M a s b : :MM) =
n o t ( i s P r e s e n t ( a , M) ) a n d a l s o
not ( i s P r e s e n t (b , L ) )
andalso
d i s j o i n t ( LL , MM)
;
( ABHISHEK : D e f i n i n g a t o t a l o r d e r i n g on a t o m s ( l e x i c o g r a p h i c
o r d e r i n g on u n d e r l y i n g s t r i n g s ) , and e x t e n d i n g i t t o a l i s t o f a t o m s .
)

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

245 OF 788

Q UIT

e x c e p t i o n notAtom ;
fun atomLess ( a , b ) = case ( a , b ) of
(ATOM( x ) , ATOM( y ) ) => x<y
| ( , )
=> r a i s e notAtom ;
fun l i s t L e s s ( a , b ) = case
( , [])
| ([] ,
)
| ( x : : lx , y : : l y )

(a ,
=>
=>
=>

b ) of
false
true
i f atomLess ( x , y ) then t r u e
e l s e i f atomLess ( y , x ) then f a l s e
e l s e l i s t L e s s ( lx , l y ) ;

( ABHISHEK : Once we h a v e a l i s t o f f a l s i f i e r s , we would want t o remove


any d u p l i c a t i o n , f i r s t l y o f a t o m s w i t h i n a f a l s i f i e r , and s e c o n d l y o f
f a l s i f i e r s themselves .
I n o r d e r t o do t h i s , we m a i n t a i n a l l l i s t s i n some s o r t e d o r d e r .
I n s t e a d o f s o r t i n g a l i s t w i t h a p o s s i b l y l a r g e number o f d u p l i c a t e s ,
we c h e c k f o r d u p l i c a t e s w h i l e i n s e r t i n g , and o m i t i n s e r t i o n i f a
previous instance is detected .
)
f u n merge l e s s ( [ ] , l 2 ) = l 2
|
merge l e s s ( l 1 , [ ] ) = l 1
|
merge l e s s ( x : : l 1 , y : : l 2 ) =
i f l e s s ( x , y ) t h e n x : : merge l e s s ( l 1 , y : : l 2 )

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

246 OF 788

Q UIT

e l s e i f l e s s ( y , x ) t h e n y : : merge l e s s ( x : : l 1 , l 2 )
e l s e merge l e s s ( x : : l 1 , l 2 ) ;
( ABHISHEK : Claim i s t h a t i f a l l l i s t s a r e b u i l t t h r o u g h t h e a b o v e
f u n c t i o n , t h e n t h e r e i s no n e e d t o s o r t o r remove d u p l i c a t e s .
Hence a l l @ o p e r a t i o n s h a v e b e e n r e p l a c e d by merge .
)
e x c e p t i o n not CNF ;
fun
|
|
|
;

positives
positives
positives
positives

(ATOM a )
= [ATOM a ]
(NOT (ATOM ) ) = [ ]
(OR ( P , Q ) )
= merge a t o m L e s s ( p o s i t i v e s ( P ) , p o s i t i v e s (Q ) )
(P)
= r a i s e not CNF

fun
|
|
|
;

negatives
negatives
negatives
negatives

=
(ATOM )
(NOT (ATOM a ) ) =
(OR ( P , Q ) )
=
(P)
=

[]
[ATOM a ]
merge a t o m L e s s ( n e g a t i v e s ( P ) , n e g a t i v e s (Q ) )
r a i s e not CNF

( Check w h e t h e r a f o r m u l a i n CNF i s a t a u t o l o g y )
f u n t a u t (AND ( P , Q ) ) = t a u t ( P ) a n d a l s o t a u t (Q)
|
t a u t ( P ) = ( i f i t i s n o t a c o n j u n c t i o n t h e n i t must be a d i s j u n c t )
not ( d i s j o i n t ( p o s i t i v e s (P ) , negatives (P ) ) )

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

247 OF 788

Q UIT

;
fun t a u t o l o g y 1 ( P ) =
l e t val Q = cnf (P)
in
t a u t (Q)
end
;
( The main p r o b l e m w i t h t h e a b o v e i s t h a t i t c h e c k s w h e t h e r a g i v e n
p r o p o s i t i o n i s a t a u t o l o g y , but whenever i t i s not , i t does not y i e l d
a f a l s i f y i n g t r u t h a s s i g n m e n t . We r e c t i f y t h i s p r o b l e m below .
)
(
F i r s t l y , a s i n t h e c a s e o f t h e f u n c t i o n l o o k u p , we w i l l assume a t r u t h
a s s i g n m e n t i s a l i s t o f a t o m s which a r e a s s i g n e d t h e t r u t h v a l u e t r u e
and t h a t any atom t h a t i s n o t p r e s e n t i n t h e l i s t h a s b e e n a s s i g n e d
false .
Assume Q i s a p r o p o s i t i o n i n CNF . Then i t i s o n l y n e c e s s a r y t o l i s t o u t
a l l t h e l i s t s of t r u t h a s s i g n m e n t s t h a t can f a l s i f y Q.
S u p p o s e Q i s i n CNF , b u t n o t n e c e s s a r i l y a t a u t o l o g y . F u r t h e r l e t
Q = AND ( D1 ,

. . . , Dn )

where e a c h Di i s a d i s j u n c t i o n o f l i t e r a l s . Each Di = P i + Ni where

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

248 OF 788

Q UIT

P i and Ni a r e t h e l i s t s o f a t o m s d e n o t i n g t h e p o s i t i v e and n e g a t i v e
literals respectively .
Q would be f a l s i f i e d i f a t l e a s t one o f t h e Di c a n be made f a l s e . Di
c a n be made f a l s e o n l y i f i t d o e s n o t c o n t a i n a c o m p l e m e n t a r y p a i r ,
i . e . t h e r e e x i s t s no atom a s u c h t h a t b o t h a and a o c c u r i n Di . Hence
f o r Di t o be f a l s i f i e d i t i s n e c e s s a r y t h a t t h e l i s t s P i and Ni a r e
d i s j o i n t ( i f t h e r e i s no atom common t o P i and Ni , t h e r e i s no
c o m p l e m e n t a r y p a i r i n Di .
S i n c e Di i s a d i s j u n c t i o n o f l i t e r a l s , i t c a n be f a l s i f i e d o n l y by
a s s i g n i n g e v e r y l i t e r a l i n Di t h e v a l u e f a l s e . T h i s c a n be done o n l y
by a s s i g n i n g a l l t h e a t o m s i n P i t h e v a l u e f a l s e and a l l t h e a t o m s
i n Ni t h e v a l u e t r u e .
I n o t h e r words , i f P i and Ni a r e d i s j o i n t , t h e n Ni i s a t r u t h
a s s i g n m e n t which f a l s i f i e s t h e p r o p o s i t i o n Q . We r e f e r t o Ni a s a
FALSIFIER o f Q .
T h e r e f o r e t h e FALSIFIERS o f Q a r e e x a c t l y t h e l i s t o f n e g a t i v e a t o m s
o f e a c h d i s j u n c t which d o e s n o t c o n t a i n a c o m p l e m e n t a r y p a i r . By
c h e c k i n g e a c h d i s j u n c t i n Q we may l i s t o u t ALL t h e p o s s i b l e
FALSIFIERS o f Q .
I f Q h a s no FALSIFIER t h e n no d i s j u n c t Di c a n be made f a l s e i . e . e v e r y
d i s j u n c t d o e s i n d e e d h a v e a compementary p a i r . We may t h e n c o n c l u d e
that Q is a tautology .
)

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

249 OF 788

Q UIT

( The f o l l o w i n g f u n c t i o n a s s u m e s Q i s i n CNF and o u t p u t s a l i s t o f l i s t


o f a t o m s t h a t c a n f a l s i f y Q . I f t h i s l i s t o f l i s t o f a t o m s i s empty t h e n
clearly Q is a tautology .
)
f u n f a l s i f y (Q) =
l e t f u n l i s t F a l s i f i e r s (AND (A, B ) ) =
merge l i s t L e s s ( l i s t F a l s i f i e r s (A) , l i s t F a l s i f i e r s (B ) )
|
l i s t F a l s i f i e r s (A) = ( Assume A i s a d i s j u n c t o f l i t e r a l s )
l e t v a l PLA = p o s i t i v e s (A) ( no u n i q r e q u i r e d )
v a l NLA = n e g a t i v e s (A)
in
i f d i s j o i n t ( PLA , NLA) t h e n [NLA]
else []
end
i n l i s t F a l s i f i e r s (Q)
end
;
fun t a u t o l o g y 2 ( P ) =
l e t val Q = cnf (P ) ;
v a l LL = f a l s i f y (Q)
in
i f n u l l ( LL ) t h e n ( t r u e , [ ] )
e l s e ( f a l s e , LL )
end
;
val tautology = tautology2 ;

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

250 OF 788

Q UIT

(
We may u s e t h e t a u t o l o g y c h e c k e r t o p r o v e v a r i o u s a r g u m e n t s
l o g i c a l l y v a l i d o r l o g i c a l l y i n v a l i d . An a r g u m e n t c o n s i s t s
o f a s e t o f p r o p o s i t i o n s c a l l e d t h e h y p o t h e s e s and a ( s i n g l e )
p r o p o s i t i o n c a l l e d t h e c o n c l u s i o n . L o o s e l y s p e a k i n g , an a r g u m e n t
i s s i m i l a r t o a t h e o r e m o f m a t h e m a t i c s . The a r g u m e n t
i s l o g i c a l l y v a l i d i f the conclusion i s a l o g i c a l consequence of
o f t h e h y p o t h e s e s . More a c c u r a t e l y , i f i n e v e r y t r u t h a s s i g n m e n t
which makes a l l t h e h y p o t h e s e s t r u e , t h e c o n c l u s i o n i s a l s o i n v a r i a b l y
t r u e then the argument i s l o g i c a l l y v a l i d .
S y m b o l i c a l l y i f H1 , . . . , Hm a r e p r o p o s i t i o n s and C i s a n o t h e r
p r o p o s i t i o n t h e n t h e a r g u m e n t ( { H1 , . . . , Hm} , C) i s l o g i c a l l y
v a l i d ( e q u i v a l e n t l y , C i s a l o g i c a l c o n s e q u e n c e o f {H1 , . . . , Hm} )
i f and o n l y i f t h e ( compound ) p r o p o s i t i o n
( H1 / \

...

/ \ Hm) => C

is a tautology .
An a r g u m e n t which i s n o t l o g i c a l l y v a l i d i s l o g i c a l l y
i n v a l i d . I n p a r t i c u l a r i f t h e r e e x i s t s a t r u t h a s s i g n m e n t u n d e r which
a l l the hypotheses are t r u e but the conclusion i s false , then the
argument i s i n v a l i d .
Any a r g u m e n t i s t r i v i a l l y l o g i c a l l y v a l i d i f t h e r e i s no t r u t h
a s s i g n m e n t u n d e r which e v e r y h y p o t h e s i s i s t r u e . I n o t h e r words ,

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

251 OF 788

Q UIT

i f t h e s e t o f h y p o t h e s e s i s an i n c o n s i s t e n t s e t t h e n r e g a r d l e s s
o f what t h e c o n c l u s i o n i s , t h e a r g u m e n t i s a l w a y s l o g i c a l l y v a l i d .
The s e t o f h y p o t h e s e s {H1 , . . . , Hm} i s i n c o n s i s t e n t i f and o n l y i f
( H1 / \ . . . / \ Hm) i s a c o n t r a d i c t i o n ( i t i s f a l s e f o r e v e r y t r u t h
assignment ) .

)
t y p e Argument = P r o p l i s t P r o p ;
f u n showArg (A: Argument ) =
l e t f u n p r i n t A r g (A: Argument a s ( [ ] , c ) ) =
( drawChar ( # "-" , 8 0 ) ; p r i n t ( "\n" ) ;
show ( c ) ; p r i n t ( "\n\n" )
)
|
p r i n t A r g (A: Argument a s ( p : : p l i s t , c ) ) =
( show ( p ) ; p r i n t ( "\n" ) ;
printArg ( plist , c )
)
i n ( p r i n t ( "\n\n" ) ; p r i n t A r g (A ) )
end
;
fun l e f t R e d u c e ( F ) =
l e t exception emptylist ;
fun l r ( [ ] ) = r a i s e e m p t y l i s t
|
lr ([ a ]) = a
|
l r ( a : : L) = F ( a , l r (L ) )

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

252 OF 788

Q UIT

in
lr
end
;
v a l bigAND = l e f t R e d u c e (AND ) ;
f u n V a l i d ( ( L , P ) : Argument ) =
i f n u l l (L) then tautology (P)
e l s e t a u t o l o g y ( IMP ( bigAND ( L ) , P ) )
;
f u n f a l s i f y A r g ( ( L , P ) : Argument ) =
i f n u l l (L) then f a l s i f y ( cnf (P ) )
e l s e f a l s i f y ( c n f ( IMP ( bigAND ( L ) , P ) ) )
;
end ( s t r u c t ) ;
( open PL ; )

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

253 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

254 OF 788

Q UIT

7. Lecture 7: Propositional Unsatisfiability

Lecture 7: Propositional
Unsatisfiability
Wednesday 10 August 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

255 OF 788

Q UIT

1. Tautology Checking
2. CNFs: Set of Sets of Literals
3. Propositional Resolution
4. Clean-up
5. The Resolution Method
6. The Algorithm
7. Resolution Examples: Biconditional
8. Resolution Examples: Exclusive-Or
9. Resolution Refutation: 1
10. Resolution Refutation: 2
11. Resolvent as Logical Consequence
12. Logical Consequence by Refutation

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

256 OF 788

Q UIT

Tautology Checking
1. Involves conversion of IMP (bigAND H, conc1) into CNF
which increases the size of the formula.
2. Involves checking falsifiability of the argument.
3. CNF can be obtained more easily for the formula (. . . ((1
2) 3) . . . n)
Convert each individual i and to CNF
and then append all the lists to obtain the required list.
4. More efficient to use theorem 4.3.2 if the technique involves
CNF.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

257 OF 788

Q UIT

CNFs: Set of Sets of Literals


Given a formula whose CNF is
^

i
1im

where for each i, 1 i m,


i

i,j

1jni

is a disjunction of literals, we will often write as a set of sets


of literals as follows:
= {{1,1, . . . , 1,n1 }, , {m,1, . . . , m,nm }}
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

258 OF 788

Q UIT

Note: For the sake of brevity we will abuse notation by identifying a clause (set of literals) with the
formula denoting their disjunction and a set of clauses with the formula denoting their conjunction.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

259 OF 788

Q UIT

Propositional Resolution
V

To show
V |= we show that is false by first transforming to a formula in CNF.
This CNF is represented as a set of sets of literals. Let be the
set of sets of literals.
1. Each set C is called a clause.
2. Each clause in represents a disjunction of literals.
3. The empty clause {} represents a contradiction.
4. The unsatisfiability of the set is shown by deriving the
empty clause.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

260 OF 788

Q UIT

Clean-up
Let be a finite set of clauses.
1. For all clauses C, C 0, if C C 0, then C 0 may be deleted from
without affecting logical equivalence.
2. Any clause containing complementary pairs of literals, may
be deleted from without affecting logical equivalence.
3. From any clause, duplicate occurrences of a literal may be
deleted without affecting logical equivalence.
The resulting clause set 0 is said to be clean.
^

H OME PAGE

JJ

LC L

II

LCS

C 00

G O B ACK

L0C 0 L

F ULL S CREEN

C LOSE

261 OF 788

Q UIT

The Resolution Method


For any clean set and an atom p let = {C | p C} and
= {C | p C}
Since is a clean set
= .
1.
2. However C and C may not be disjoint.
3. For each C and C , p 6 C and p 6 C.
The new set of clauses obtained after resolution
df

resolve(, p) = ( ( ))
{D | D = (C {p}) (C {p}), C , C }
is called the resolvent.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

262 OF 788

Q UIT

Lemma 7.1 If C1 = {1,i | 1 i m} and C2 = {2,j | 1 j n} are clauses such that


p C1 C2 and p C2 C1 and D = (C1 {p}) (C2 {p}). Then
1. C1 C2 D and
2. resolve preserves satisfiability, i.e. every truth assignment that satisfies both C1 and C2 also
satisfies D.
Proof: From the semantics of propositional logic it follows that for any truth assignment ,
C1 C2 if and only if C1 and C2. Hence we may prove both parts of the lemma by
considering an arbitrary truth assignment such that C1 C2. It suffices to show (for both
parts) that D. C1 implies that for some i0, 1 i0 m, T J1,i0 K = 1 and for some j0,
1 j0 n, T J2,j0 K = 1. Further since p and p are complementary, it is impossible that both
p 1,i0 and p 2,j0 hold simultaneously. Hence at least one of the two literals 1,i0 , 2,j0 is in
D. It followsX
therefore that
X
T JDK = (
T J1,iK )+(
T J2,j K ) = 1 if p 6 1,i0 and
1im

T JDK = (

1jn,j6=j0

1im,i6=i0

H OME PAGE

JJ

T J1,iK )+(
I

X
1jn

T J2,j K ) = 1 if p 6 2,0 and hence D.


II

LCS

G O B ACK

F ULL S CREEN

C LOSE

QED

263 OF 788

Q UIT

The Algorithm
Require: a clean set of clauses
1: while ({} 6 ) (p, p) do
2:
0 := resolve(, p)
3:
:= Clean-up(0)
4: end while
Note:
1. {} is the empty clause which represents the proposition (it
represents the disjunction of an empty set of literals).
2. The presence of the empty clause in a set of clauses also
indicates the unsatisfiability of the set of clauses.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

264 OF 788

Q UIT

Lemma 7.2 Let 1 = Clean-up(resolve(0)). Then


1. 0 1 and
2. if 0 is satisfiable then 1 is satisfiable.
Proof: The proof follows directly from the proof of lemma 7.1 and from problem 5 of exercise 4.1,
where it should have been shown that both and preserve logical implication.
QED

Corollary 7.3 If 1 and 0 are as in lemma 7.2 then if 1 is unsatisfiable then so is 0.
2

Theorem 7.4 Given a clean non-empty set 0 of non-empty clauses, the propositional resolution
algorithm terminates in at most |atoms(0)| iterations, deriving either an empty clause or a set of
non-empty clauses which are satisfied by every model of the original set 0.

Proof: Since in each iteration one atom and its negation are completely eliminated, |atoms(0)| is
the number of iterations possible. Further by applying lemma 7.2 to the result of each iteration we
get that satisfiability and logical implication are preserved.
QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

265 OF 788

Q UIT

7.1. Space Complexity of Propositional Resolution.

Assume n is the number of atoms of which is made up. After some iterations of resolution and
cleanup, assume there are k distinct atoms in the set of clauses on which resolution is applied. After
performing the cleanup procedure there could be at most 2k clauses with each clause containing at
most k literals. Assuming each literal occupies a unit of memory, the space requirement is given by
size() = 2k k literals.
For any complementary pair (p, p), it is possible that at most half of the 2k (i.e. 2k1) clauses
contain p and the other half contain p. This would be the worst-case scenario, as it yields the
maximum number of new clauses. Therefore in performing a single step of resolution over all
possible pairs of clauses to yield a new set 0 of clauses, a maximum of 2k1 2k1 unions of distinct
pairs of clauses needs to be performed. Before applying the clean-up procedure the space required
could be as high as 2k1 2k1 = 22(k1) > 2k k for k > 4. But since 0 is made up of at most (k 1)
atoms, size(0) 2k1(k 1), after clean-up the space requirement reduces to 2k1(k 1). Since
k n the maximum space required after the first application of resolution and before cleaning up
exceeds the space required for all other iterations and is bounded by 22(n1) = O(22n).

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

266 OF 788

Q UIT

7.2. Time Complexity of Propositional Resolution

Given a space of 2k k to represent the clauses containing at most k atoms, we require a time proportional to this amount of space in order to identify which clauses have to be resolved against a
particular complementary pair. After resolution we create a space of 22(k1) which has to be scanned
for the cleanup operations. Hence the amount of time required to perform a step of resolution and
the amount of time required to perform the cleanup are both proportional to 22(k1). Hence the total
time required for performing resolution followed by cleanup in n iterations (which is the maximum
possible) is given by
Pn 2k2
T (n)
k=1 2
which is clearly exponential.
Hence both the worst case time and space complexities are exponential in the number of atoms.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

267 OF 788

Q UIT

Resolution Examples: Biconditional


Example 7.5 Sometimes there may be more than one complementary pair of literals in the same pair of clauses. Consider
the biconditional operator () on atomic propositions p and q.
We have
p q (p q) (p q) {{p, q}, {p, q}}
Applying resolution on the pair of literals p and p we obtain the
clause set which after clean-up yields the empty set of clauses.
{{q, q}} {} >
There is really nothing more to this resolvent than that > is a
logical consequence of any proposition (including ).
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

268 OF 788

Q UIT

Resolution Examples: Exclusive-Or


Example 7.6 The exclusive-or operation is simply the negation of the biconditional operator . Hence we have
p q (p q) (p q) {{p, q}, {p, q}}
which on resolution on the pair (p, p) and subsequent cleanup again yields the empty set of clauses.
{{q, q}} {} >

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

269 OF 788

Q UIT

Resolution Refutation: 1
Example 7.7 Consider the simple logical consequence
p q |= p
which we prove by resolution refutation. The set of clauses representing the hypothesis and the negation of the conclusion is
{{p}, {q}, {p}}. Resolving on the pair (p, p) yields
{{}, {q}}
Notice that {} {{}, {q}}.
Since for any clause C 6= , C {}, the clean-up always reduces every set of clauses to {{}} whenever {} .
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

270 OF 788

Q UIT

Resolution Refutation: 2
Example 7.8 Consider the simple logical consequence
p q |= p q
which we prove by resolution refutation. Negating the conclusion yields p q {{p, q}, {p, q}}. The set of clauses representing the hypothesis and the negation of the conclusion is
{{p}, {q}, {p, q}, {p, q}} which after clean-up yields
{{p}, {q}, {p, q}}
Resolving on the pair (p, p) produces
{{q}, {q}}
and then on the pair (q, q) produces the empty clause {{}}.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

271 OF 788

Q UIT

Resolvent as Logical Consequence


The set of clauses resulting from any application of resolution
is a set of clauses that represents a logical consequence of the
original set of clauses
Example 7.9 We use resolution to prove
(p q) (p r) p q r
The set of clauses {{p, q}, {p, r}, {p}} may be resolved on the
pair (p, p) to yield the set
{{q}, {r}} q r
Note that we have resolved all occurrences of the complementary pair (p, p).
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

272 OF 788

Q UIT

Logical Consequence by Refutation


Example 7.10 In example 7.9 since we resolve all occurrences of the complementary pair (p, p), we could not
have proved that p q r is also a logical consequence of
(p q) (p r) p which it indeed is. We may use refutation
for this purpose by noting that (p q r) {p, q, r}. We
then resolve the set {{p, q}, {p, r}, {p}, {p, q, r}} on the pair
(p, p) to obtain the set {{q}, {r}, {q, r}} which may be resolved on the pairs (q, q) and (r, r) subsequently to yield the
empty clause.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

273 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

274 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

275 OF 788

Q UIT

8. Lecture 8: Analytic Tableaux

Lecture 8: Analytic Tableaux


Friday 12 August 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

276 OF 788

Q UIT

1. Against Resolution
2. The Analytic Tableau Method
3. Basic Tableaux Facts
4. Tableaux Rules
5. Structure of the Rules
6. Tableaux
7. Slim Tableaux

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

277 OF 788

Q UIT

Against Resolution
1. For any argument, it was still necessary to transform the argument into a mammoth formula in CNF in order to be able
to perform resolution.
2. The numbers of clauses and sizes of clauses could temporarily increase as a result of resolution.
3. Termination relied on the reduction of the number of atoms
at each step of resolution.
4. Resolution also requires a clean-up of the initial set of
clauses to work correctly.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

278 OF 788

Q UIT

The Analytic Tableau Method


1. Like resolution, the tableau method also checks for the unsatisfiability of a set of formulae.
2. Like resolution, each step of the method preserves satisfiability.
3. Unlike resolution
(a) There are no transformations of mammoth formulae into
a normal form (esp. the use of distributivity which can increase sizes of formulae).
(b) It works with the list of formulae [1, . . . , n, ] directly by
breaking up the formulae and building a tree called the
tableau
(c) It relies on the symmetry between truth and falsehood at a
semantic level to check for satisfiability or unsatisfiability.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

279 OF 788

Q UIT

Basic Tableaux Facts


Theorem 8.1 For any truth assignment , and formulae , ,
T JK = 1
T JK = 0
T JK = 0
T JK = 1
T J K = 1 T JK = 1 & T JK = 1
T J K = 0 T JK = 0
T JK = 0
T J K = 1 T JK = 1
T JK = 1
T J K = 0 T JK = 0 & T JK = 0
T J K = 1 T JK = 0
T JK = 1
T J K = 0 T JK = 1 & T JK = 0
T J K = 1 T JK = 1 = T JK
T J K = 0 T JK = 0 = T JK

H OME PAGE

JJ

II

LCS

G O B ACK

T JK = 0 = T JK
T JK = 1 = T JK


F ULL S CREEN

C LOSE

280 OF 788

Q UIT

Tableaux Rules

( )
.

( )
.

( )
.
.

( )
.
.


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

281 OF 788

Q UIT

Structure of the Rules


The tableaux rules are of two kinds:
Elongation rules Each of the rules , , and elongates the path without increasing the size of the tableau
(since the original formula to which a rule was applied may
be discarded)
Branching rules These are the rules , , , and
which lead to branching of the tableau.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

282 OF 788

Q UIT

Tableaux
1. A tableau is a tree where each path of the tableau represents
a conjunction of unbroken formulae.
2. Each application of the tableaux rules preserves satisfiability
of the conjunction of unbroken formulae in each path.
3. A path of the tableau is closed if it contains a complementary
pair (the conjunction of the formulae in the path is clearly
unsatisfiable).
4. The result of applying a tableau rule to an ancestor node has
to be distributed in all branches of its descendants.
5. A tableau is closed if every path in the tableau is closed signifying that the original set of formulae is unsatisfiable.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

283 OF 788

Q UIT

Slim Tableaux
1. Any formula which has been broken up by a tableau rule may
be discarded.
2. Any branch which has been closed may be discarded.
3. Any formula which dominates several branches of the
tableau creates multiple copies (one in each branch of its
descendants) when it is broken up.
By applying the elongation rules first the number of branches
over which elongation rules have to be replicated can be reduced

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

284 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

285 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

286 OF 788

Q UIT

9. Lecture 9: Consistency & Completeness

Lecture 9: Consistency &


Completeness
Wednesday 17 August 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

287 OF 788

Q UIT

1. Tableaux Rules: Restructuring


2. Tableaux Rules: 2
3. Tableau Proofs
4. Consistency
5. Unsatisfiability
6. Hintikka Sets
7. Hintikkas Lemma
8. Tableaux and Hintikka sets
9. Completeness

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

288 OF 788

Q UIT

Tableaux Rules: Restructuring


In general the elongation and branching rules of the tableau
look like this

Elongation.
Branching.

where and are subformulae of .


Let = {} where 6 be a set of formulae. It will
be convenient to use sets of formulae in the tableau rules. The
elongation and branching rules are rendered as follows respectively
{}
{}
Elongation.
Branching.
{, }
{} {}
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

289 OF 788

Q UIT

Tableaux Rules: 2
{, }
{}
.
.
{}
{}
{ }
{( )}
.
.
{, }
{} {}
{ }
{( )}
.
.
{, }
{} {}
{ }
{( )}
.
.
{, }
{} {}
{ }
.
{ } { }
{( )}
.
{ } { }
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

290 OF 788

Q UIT

Tableau Proofs
1. A tableau is a tree rooted at a node containing a set of
formulas
2. Each application of

an elongation rule 0 to a leaf of the tableau extends the

0
path to ,

a branching rule
to a leaf of the tableau extends the
0 00
tableau to two leaves 0 and 00.
3. A path of the tableau is closed if its leaf is {}.
4. The tableau is closed if every path is closed, otherwise the
the tableau is open.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

291 OF 788

Q UIT

Consistency
Definition 9.1 A set of formulas is consistent if it is satisfiable
i.e. there is a truth assignment under which every formula of
is true. Otherwise, it is inconsistent.
Fact 9.2 Every non-empty subset of a consistent set is also
consistent
Lemma 9.3 Each tableau rule preserves satisfiability in the following sense.

Elongation Rules 0 If the numerator is satisfiable then so is

the denominator 0.

Branching Rules (
) If the numerator is satisfiable then
0
00

at least one of the denominators 0 or 00 is satisfiable.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

292 OF 788

Q UIT

Proof outline of lemma 9.3


Proof: It may be shown that for any truth assignment ,

. if every formula in is true then every formula in 0 is also true under .


0

Branching Rules 0 00 . if every formula in is true under then every formula in 0 or every formula in 00 is true
|
under .
Elongation Rules

QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

293 OF 788

Q UIT

Unsatisfiability
Definition 9.4 A tableau is completed if no leaf in any path may
be extended.
Corollary 9.5 If is satisfiable then there exists a completed
tableau rooted at which has a satisfiable leaf.
Corollary 9.6 A set is unsatisfiable if there exists a closed
tableau rooted at .
Question. If a completed tableau rooted at is closed could there be
other completed tableaux rooted at which might be open?

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

294 OF 788

Q UIT

Hintikka Sets
Definition 9.7 A finite or infinite set is a Hintikka set if
1. 6 and for any p A, {p, p} 6 ,
2. If for {, , } then { 0, 0} ,
3. If for {, , , , } then { 0, 0}
6=
where 0 and 0 are defined by the following table
0 0
0
0

( )

( )

( )


( )
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

295 OF 788

Q UIT

Hintikkas Lemma
Lemma 9.8 Every Hintikka set is satisfiable.
Proof: Let be a Hintikka set. For any atom p, since {p, p} 6
, consider the following truth assignment .
1. (p) = 1 if p ,
2. (p) = 0 if p and
3. if {p, p} = then choose any value (say 1 for definiteness).
We may then show by induction on the degree of formulae in
that each formula in is satisfiable.
QED
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

296 OF 788

Q UIT

Tableaux and Hintikka sets


Theorem 9.9
Let[
0, 1 , n be an open path of a
completed tableau. Then
m is a Hintikka set.
0mn

Proof:
We may prove that each rule in Tableaux Rules: 2
creates a path for the construction of Hintikka sets.
QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

297 OF 788

Q UIT

Completeness
Theorem 9.10 Completeness of the Tableau Method
1. If is a tautology then every completed tableau rooted at
{} is closed.
2. Every tautology is provable by the tableau method.
Proof:
1. Suppose T is a completed tableau rooted at {} which is
open. Then by corollary 9.5 must be satisfiable and hence
cannot be a tautology. Hence T must be closed.
2. If is a tautology that cannot be proved by the tableau
method, there must exist a completed tableau rooted at {}
which has an open path. But that implies {} is satisfiable
which implies that is not a tautology.
H OME PAGE

JJ

QED
I

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

298 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

299 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

300 OF 788

Q UIT

10. Lecture 10: The Compactness Theorem

Lecture 10: The Compactness


Theorem
Friday 19 August 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

301 OF 788

Q UIT

1. Satisfiability of Infinite Sets


2. The Compactness Theorem
3. Inconsistency
4. Consequences of Compactness

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

302 OF 788

Q UIT

Satisfiability of Infinite Sets


From corollaries 9.5 and 9.6 we have
Corollary 10.1 A finite set is unsatisfiable iff there is a closed
tableau rooted at .

Corollary 10.2 If a finite set is satisfiable then every
nonempty subset of is satisfiable too.

Question 1. Suppose were a denumerable (countably infinite) set.
Under what conditions is satisfiable?
Question 2. Suppose every subset of a denumerable set is satisfiable. Then is necessarily satisfiable?
Question 3. Suppose that only all finite subsets of a denumerable set
are satisfiable. Then is satisfiable?
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

303 OF 788

Q UIT

The Compactness Theorem


Theorem 10.3 (The Compactness Theorem) A (countably) infinite set is satisfiable if all its nonempty finite subsets are satisfiable.
2

Corollary 10.4 Any (finite or infinite) set of formulae is satisfiable iff all its non-empty finite subsets are satisfiable.
Note:
If is a countably infinite set then it can be placed in 1-1
correspondence with the set N of naturals and hence there
is some enumeration of its formulae and each formula carries
an unique index from N.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

304 OF 788

Q UIT

Proof of the Compactness Theorem


Proof: Let be a countably infinite set of propositions. Then clearly may be enumerated in some
order, say
{0, 1, 2, . . .}
(7)
where each j has the unique index j 0. For each m 0, let m = {0, 1, 2, . . . , m}.
Claim. Every nonempty finite subset of is satisfiable iff for each m 0, m is satisfiable.
` () clearly holds since each m is a finite subset.
() Let =
6 f . Let k 0 be the index of the formula with the highest index in .
Clearly f k . Since the set k is satisfiable, by corollary 10.2, is also satisfiable.
a
Hence it suffices to prove that if each of the i, i 0, is satisfiable then is satisfiable.
Consider a tableau T0 rooted at 0 constructed using the tableau rules. Since 0 is satisfiable, T0
has one or more open paths. Extend each of the open paths with the formula 1 and continue the
tableau. The resulting tableau T1 is for the set 1 and it does not close either. Hence tableaux Tk for
each k may be extended to yield open tableaux Tk+1 for k+1.
Consider the final tableau T obtained by this process of extension. T is a finitely branching infinite
tree with at least one path that does not close. By Konigs Lemma 2.17 there is an infinite path. Let
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

305 OF 788

Q UIT

be the set of all formulae in this path. Since this path contains each of the formulae i , we
have and further is a Hintikka set. By Hintikkas lemma 9.8 this set must be satisfiable.
QED


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

306 OF 788

Q UIT

Inconsistency
Corollary 10.5 A set is inconsistent if some nonempty finite
subset of is unsatisfiable.
Proof: Follows from the compactness theorem 10.3 and its
corollary 10.4.
QED

Facts 10.6
1. Any superset of an inconsistent set is also inconsistent.
2. Any set containing a complementary pair is inconsistent.
3. (see table) If { 0, 0} is inconsistent then so is {}
where
4. (see table) If both { 0} and {0} are inconsistent then
so is {} where .
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

307 OF 788

Q UIT

Consequences of Compactness
Corollary 10.7 Given a finite or infinite set , and a formula
1. {} is inconsistent iff there exists = {i | 1 i
n} f , n 0, such that {} is inconsistent.
V
2. |= iff |= iff ( ) is a tautology, for some =
{i | 1 i n} f .
Hence
1. to show that an argument is valid it suffices to prove that the
conclusion follows from a finite subset of the hypotheses.
2. to show invalidity of an argument it suffices to find a finite
subset of the hypotheses which are inconsistent with the conclusion.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

308 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

309 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

310 OF 788

Q UIT

11. Lecture 11: Maximally Consistent Sets

Lecture 11: Maximally Consistent Sets


Tuesday 23 August 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

311 OF 788

Q UIT

1. Consistent Sets
2. Properties of Finite Character: 1
3. Properties of Finite Character: 2
4. Properties of Finite Character: 3
5. Maximally Consistent Sets
6. Lindenbaums Theorem

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

312 OF 788

Q UIT

Consistent Sets
Lemma 11.1 If is a consistent set then for any formula at
least one of the two sets 1 = {} or 0 = {} is
consistent.
2

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

313 OF 788

Q UIT

Proof of lemma 11.1


Proof: Suppose is consistent but both 0 and 1 are inconsistent. Then by compactness and by
definition 10.5 there must be consistent finite subsets 0, 1 f such that 00 = 0 {} and
01 = 1 {} are both inconsistent. Let 01 = 0 1. By facts 10.6.1 both 01 {} and
01 {} are inconsistent and hence unsatisfiable whereas 01 f is consistent. Hence there is
a truth assignment which satisfies 01, and such that
T JK = 0 = T JK
which is impossible.

H OME PAGE

JJ

QED

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

314 OF 788

Q UIT

Properties of Finite Character: 1


Definition 11.2 A property p of sets is called a property of finite
character if for any set S, S has the property p iff every finite
subset of S has the property p.
Notation: S p denotes the statement S has property p.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

315 OF 788

Q UIT

Properties of Finite Character: 2


Example 11.3
1. The property of a partially ordered set being totally ordered
is a property of finite character. That is, if hP, i is a partially
ordered set, then P is totally ordered (i.e. for every a, b P ,
a b or b a) iff every finite subset of P is totally ordered.
2. However the property of a totally ordered set hT, i being
well-ordered is not a property of finite character since every
finite subset of T is well-ordered, but T itself may not be wellordered (e.g. take the set of integers Z under the usual
relation).
3. By the corollary 10.4 to the compactness theorem, consistency/satisfiability is a property of finite character.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

316 OF 788

Q UIT

Properties of Finite Character: 3


Theorem 11.4 (Tukeys Lemma) For any denumerable universe
U and any property p of finite character of subsets of U , any set
S U such that S p can be extended to a maximal set S
such that S S U with S p.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

317 OF 788

Q UIT

Proof of Tukeys Lemma


Proof: Let S U be a set with S p. Since U is denumerable its elements can be enumerated in
some order
a1, a2, a3, . . .
(8)
Starting with S = S0 consider the sets Si+1, i 0

Si {ai+1} if Si {ai+1} p
Si+1 =
Si
otherwise
Clearly we have the infinite chain
S = S0 S1 S2
S
such that for each Si, Si p. Let S = i0 Si.
Claim. S p.
` Let T f S, then T f Si for some i 0. Since Si p, p is a property of finite character
and T f Si, T p. Hence every finite subset of S has property p. Therefore since p is a
property of finite character, S p.
a
Claim. S is maximal.
` Suppose there exists an element a U such that S {a} p. We know from the
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

318 OF 788

Q UIT

claim above that S p and from the construction of each Si, that Si p for each i 0.
Clearly a = aj+1 for some j 0 in the enumeration (8). Hence Sj {aj+1} p. But
Sj {aj+1} = Sj+1 S. Hence S = S {a} and S is maximal.
a


QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

319 OF 788

Q UIT

Maximally Consistent Sets


Definition 11.5 A set is a maximally consistent set if it is satisfiable and no proper superset of is consistent.
Corollary 11.6 For any maximally consistent set , and any
formula , either or but not both.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

320 OF 788

Q UIT

Lindenbaums Theorem
Theorem 11.7 (Lindenbaums Theorem) Every consistent set
can be extended to a maximally consistent set. More precisely
for every consistent there exists a maximally consistent set
.
Proof:
By definition 11.2 and corollary 10.4 consistency of
sets of formulae is a property of finite character in the universe
P0. From theorem 11.4 it follows that any set P0 may be
extended to a maximally consistent set .
QED


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

321 OF 788

Q UIT

Alternative Proof of Lindenbaums Theorem ab initio


Proof: Let be a consistent set. Since P0 is generated from a countably infinite set of atoms and
a finite set of operators, P0 is a countably infinite set (see problem 1 of exercise 2.1). Hence the
formulae of P0 can be enumerated in some order
1, 2, 3, . . .

(9)

Starting with = 0 consider the sets



i {i+1} if i {i+1} is consistent
i+1 =
i
otherwise
Clearly we have the infinite chain
= 0 1 2
S
such that each i is consistent. Let = i0 i.
Claim. is consistent.
` Let f , then since is finite, it must be the subset of some i. Since i is consistent,
so is . Hence every finite subset of is consistent. Therefore by the compactness theorem
is consistent.
a
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

322 OF 788

Q UIT

Claim. is maximal.
` Suppose there exists a formula such that {} is consistent. Clearly i+1 for
some i 0 in the enumeration (9). Since {i+1} is consistent, by fact 9.2 i {i+1}
{i+1} is also consistent. But then i+1 = i {i+1} and hence = {}.
Hence is maximal.
a
QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

323 OF 788

Q UIT

Exercise 11.1
1. Let hP, i be a finite partial order. Prove using Konigs lemma that every element of P lies
between a maximal element and a minimal element i.e. for each a P there exist a minimal
element l P and a maximal element u P such that l a u.
2. Prove that every maximally consistent set is a Hintikka set.
3. For any given consistent set of formulae, there may exist more than one maximally consistent
extension. Give examples of and such that there are two maximally consistent extensions,
and 0 with and 0.
4. (Tarskis theorem) For any set , of formulae, the set |= called the closure under logical consequence is defined as
|= = { P0 | |= , for some f }
Let M C () = { | is a maximally consistent extension of } be the set of all maximally
consistent extensions of . Prove that
\
|=
=

M C ()

for every consistent set .


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

324 OF 788

Q UIT

5. (Interpolation) For any finite set V f A, define TV = {V | V : V {, >}} and


for any formula such that V atoms() and any V TV , let V () denote the formula
obtained from by replacing all occurrences of each atom p V by the atom V (p). Further let
TV () = {V () | V TV }.
Let X, Y, Z f A be pairwise disjoint (finite) sets of atoms and let and be formulae such
that
atoms() X Y ,
atoms() Z Y and
|=
df W
df V
(a) Let = TX () and = TZ (). Then prove that
i. |=
ii. |=
iii. |=
(b) Prove that for any formula with atoms() Y , if |= and |= then |=
and |= . is called an interpolant of and .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

325 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

326 OF 788

Q UIT

12. Lecture 12: Formal Theories

Lecture 12: Formal Theories


Wednesday 24 August 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

327 OF 788

Q UIT

1. Introduction to Reasoning
2. Proof Systems: 1
3. Requirements of Proof Systems
4. Proof Systems: Desiderata
5. Formal Theories
6. Formal Language
7. Axioms and Inference Rules
8. Axiomatic Theories
9. Syntax and Decidability
10. A Hilbert-style Proof System
11. Rule Patterns

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

328 OF 788

Q UIT

Introduction to Reasoning
1. The methods discussed truth-table, tautology checking,
resolution and tableau are useful for automated deduction,
but
2. they do not reflect the process of reasoning employed by humans and used most often in mathematical proofs called deduction.
3. Deduction enables the proof of validity of arguments but seldom their invalidity.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

329 OF 788

Q UIT

Proof Systems: 1
A proof system for deduction
1. prohibits the use of meaning in drawing conclusions.
2. has a number of axioms (or axiom schemas) and a small
number of (finitary) inference rules.
3. Each proof is a finite tree where each node of the tree is either an assumption or an axiom or is obtained by patternmatching and substitution from the axioms and inference
rules.
4. Each proof can be checked manually or verified by machine
implementable algorithms.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

330 OF 788

Q UIT

Requirements of Proof Systems


Syntactic. Proof systems are purely syntactic and no use is
made of semantics in any proof.
Finitary. All axioms, axiom-schemas and rules of inference
must be expressible in a finitary manner.
Decidability. The correctness of any application of a rule of inference must be machine-verifiable.
Soundness. The system must allow the deduction of only valid
conclusions from the assumptions.
Completeness. The system must allow all valid truths to be deduced.
The semantics may be used to prove only the soundness and
completeness of the proof system.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

331 OF 788

Q UIT

Proof Systems: Desiderata


There are two conflicting desirable properties of proof systems.
Minimality. Inspired by Euclid and the controversy over the parallel postulate. Is there a minimal set of axioms and inference
rules from which all truths and only truths may be deduced?
Naturalness. Is there a natural intuitive set of axioms and rules from
which all truths and only truths may be deduced?

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

332 OF 788

Q UIT

Formal Theories
Definition 12.1 A formal theory T = hL, A , Ri consists of
Formal Language a formal language L.
Axioms a subset A of the language L.
Inference Rules a set R of inference rules.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

333 OF 788

Q UIT

Formal Language
1. An alphabet = X {(, )} consisting of a set X of variables a set of connectives each with a pre-defined arity and
grouping symbols.
2. L is defined inductively on .
3. The well-formed formulas or wffs of L are defined inductively
on the alphabet.
4. Membership of strings (from the alphabet) in L is decidable
i.e. there exists an algorithm to decide whether a given string
is a well-formed formula
Formal Theories

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

334 OF 788

Q UIT

Axioms and Inference Rules


Axioms A decidable subset of L.
Inference Rules A finite set of rules.
1. Each rule R of arity m 0 is a decidable relation
R Lm L i.e. there exists an algorithm which for any
1, . . . , m, can determine whether ((1, . . . , m), ) R
2. For each ((1, . . . , m), ) R, 1, . . . , m are called the
premises and a direct consequence by virtue of R.
X1 X m
3. Each such rule is presented in the form R.
Y
where the variables X1, , Xm, Y are the shapes of the
formulae allowed by the rule.
4. If m = 0, R is called an axiom schema
Formal Theories
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

335 OF 788

Q UIT

Axiomatic Theories
Definition 12.2
The axioms and rules of inference of a formal theory together
constitute a proof system for the set of wffs in the theory.
A formal theory is said to be axiomatic if there exists an algorithm to decide whether a given wff is an axiom.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

336 OF 788

Q UIT

Syntax and Decidability


1. The purely syntactic nature of a formal theory and all the
decidability constraints usually means that each axiom and
rule of inference is expressed in terms of syntactic patterns
obeying certain shape constraints.
2. Each application of an axiom (schema) or inference rule requires pattern-matching and substitution.
3. The notion of a deduction is not only syntactic but is verifiable
by an algorithm given the nature of the formal theory.
4. Further the deductions of a formal theory can be generated
by an algorithm (the set of theorems is recursively enumerable).
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

337 OF 788

Q UIT

A Hilbert-style Proof System


Definition 12.3 H0, the Hilbert-style proof system for Propositional logic consists of
The set L0 generated from A and {, }
The following three axiom schemas
S.

(X (Y Z)) ((X Y ) (X Z))

K.

N.

X (Y X)
(Y X) ((Y X) Y )
A single rule of inference modus ponens
X Y ,X
MP.
Y
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

338 OF 788

Q UIT

Rule Patterns
1. The axiom schema K states that for all (simultaneous) substitutions {/X, /Y } the formulae ( ) are all axioms
of the system.
2. The rules specify patterns and shapes of formulae. Thus
modus ponens specifies the relation
MP = {(( , ), ) | , L0}
and thus asserts that is a direct consequence of
and for all formulae and .
3. An application of the rule consists of identifying appropriate
substitutions of the variables X and Y by formulae in L0 to
yield a direct consequence by the same substitution.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

339 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

340 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

341 OF 788

Q UIT

13. Lecture 13: Proof Theory: Hilbert-style

Lecture 13: Proof Theory: Hilbert-style


Wednesday 26 August 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

342 OF 788

Q UIT

1. More About Formal Theories


2. An Example Proof
3. Formal Proofs
4. Provability and Formal Proofs
5. The Deduction Theorem
6. About Formal Proofs

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

343 OF 788

Q UIT

More About Formal Theories


The following properties follow easily from the definition of a
formal theory.
Theorem 13.1 Let and be finite sets of wffs in a theory T.
Monotonicity If and ` , then ` .
Compactness ` if and only if there is a finite subset
such that ` .
Substitutivity If ` and for each , ` , then ` .


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

344 OF 788

Q UIT

An Example Proof
We formally deduce for any formula using the proof
system H0. As is normal practice in mathematics the proof is
presented as a sequence of steps.
1. (( ) )

H OME PAGE

JJ

{/X, /Y }K

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

345 OF 788

Q UIT

An Example Proof
We formally deduce for any formula using the proof
system H0. As is normal practice in mathematics the proof is
presented as a sequence of steps.
1. (( ) )

{/X, /Y }K

2. ( (( ) )) (( ( )) ( ))
{/X, /Y , /Z}S

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

345 OF 788

Q UIT

An Example Proof
We formally deduce for any formula using the proof
system H0. As is normal practice in mathematics the proof is
presented as a sequence of steps.
1. (( ) )

{/X, /Y }K

2. ( (( ) )) (( ( )) ( ))
{/X, /Y , /Z}S
3. (( ( )) ( ))

H OME PAGE

JJ

II

{2, 1}MP

LCS

G O B ACK

F ULL S CREEN

C LOSE

345 OF 788

Q UIT

An Example Proof
We formally deduce for any formula using the proof
system H0. As is normal practice in mathematics the proof is
presented as a sequence of steps.
1. (( ) )

{/X, /Y }K

2. ( (( ) )) (( ( )) ( ))
{/X, /Y , /Z}S
3. (( ( )) ( ))

{2, 1}MP

4. ( ( ))

H OME PAGE

JJ

{/X, /Y }K

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

345 OF 788

Q UIT

An Example Proof
We formally deduce for any formula using the proof
system H0. As is normal practice in mathematics the proof is
presented as a sequence of steps.
1. (( ) )

{/X, /Y }K

2. ( (( ) )) (( ( )) ( ))
{/X, /Y , /Z}S
3. (( ( )) ( ))

{2, 1}MP

4. ( ( ))

{/X, /Y }K

5.

{3, 4}MP

where each step is justified as an instance of an axiom schema


or a rule.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

345 OF 788

Q UIT

However the proof is better written out as an upside-down proof


tree where
1. each node is a formula. The leaves are axioms (or empty in the
case of axiom schemas).
2. each internal node is an application of a rule of appropriate arity
applied to the appropriate target (definition 2.11) nodes in the tree.
3. The line-segments between the various levels on the tree show
how a node depends on the nodes in the immediately succeeding
level.
4. the root node is the final formula to be proven.
5. The labels on each line-segment separating a direct consequence
from its premise(s) also provide the justification.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

346 OF 788

Q UIT

The same proof may then be rendered as follows:

1
(( ) )
3

( (( ) )) (( ( )) ( ))
(( ( )) ( ))
5

( ( ))

where the justifications of each step are


1. {/X, /Y }K
2. {/X, /Y , /Z}S
3. {2, 1}MP
4. {/X, /Y }K
5. {3, 4}MP
Each node in this proof tree is said to be an instance of a rule or an axiom-schema.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

347 OF 788

Q UIT

Formal Proofs
Definition 13.2
A formal proof of a formula from a finite set of formulae
is a finite tree of formulae
rooted at the formula ,
the leaves are axioms or instances of axiom schemas or
members from .
each non-leaf node is a direct consequence of one or more
nodes at the succeeding level by virtue of application of
a rule of inference of the appropriate arity.
is said to be (formally) provable from in the proof system
H0 and denoted `H0 if there exists a formal proof of in
the system H0.
is a (formal) theorem if = and is denoted `H0

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

348 OF 788

Q UIT

Provability and Formal Proofs


Facts 13.3 Given any theory T = hL, A , Ri and a wff L,
1. If is an axiom or instance of an axiom-schema then `
and hence is a formal theorem.
2. If ` then all the leaf nodes in any proof tree of are either
axioms or instances of axiom-schemas.
3. If is an axiom or an instance of an axiom-schema then
` for any L.
4. For any , ` .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

349 OF 788

Q UIT

The Deduction Theorem


Notation Given a set and a formula , , ` denotes
{} `
Theorem 13.4 (The Deduction Theorem) For all f L0 and
formulae and , , ` if and only if ` .
2
The Deduction theorem justifies our usual notion of a direct
proof from the hypotheses of a conditional conclusion the antecedent of the conditional is added to the assumptions and the
consequent is proven.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

350 OF 788

Q UIT

Proof of The Deduction Theorem (theorem 13.4)


Proof:
(). Assume , ` . Then there exists a proof tree T rooted at with nodes
1, . . . , m . Then the following stronger claim proves the required result.
Claim. ` i for all i, 1 i m.
` By induction on k = `(1) `(i) in T (see definition 2.11 for `).
Basis. k = `(1)`(i) = 0. Then i is either a premise or an axiom. We have the following
cases to consider.
Case i . Then the claim follows from reflexivity and monotonicity (theorem 13.1).
Case i or i is an axiom. In either case there exists a subtree Ti (of T ) rooted at i
which may be used to construct the tree Ti 0 as follows. Assume there are i0 steps in the
proof of i.
- Ti %
i0
i
i0 + 2

i0 + 1

i ( i)
i

which proves the claim.


Induction Hypothesis (IH).
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

351 OF 788

Q UIT

` i for all i such that `(i) > l for some l `(m).


Induction Step. Since l is a non-leaf node it is neither an axiom nor a premise and must
have been obtained by virtue of the rule MP applied to its immediate successors say i
and j with i 6= j such that `(i), `(j ) > l. Without loss of generality we may assume
j i l .
By the induction hypothesis, we know ` i and ` j . Hence there exist
proof trees Ti 0 of i0 nodes rooted at i and Tj0 of j 0 nodes rooted at j
(i l ) respectively. We construct the tree Tl 0 rooted at l from Ti 0 and Tj0
as follows.

- Tj0 %
j0 + 1
j
(i l )
( (i l )) (( i) ( l ))
- Ti 0 %
0
0
0
j +2
j +i +2
(

)
i
i
l
j 0 + i0 + 3
l
where j 0 + 1 is an instance of S, and j 0 + 2 and j 0 + i0 + 3 are both applications of MP to
their respective immediate successors in the tree.
0

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

352 OF 788

Q UIT

a
(). Assume ` . Let T be a formal proof tree rooted at with m nodes for some
m > 0. By monotonicity (theorem 13.1) , ` is proven by the same tree. We may extend
T to the tree T 0 by adding a new (m + 1)-st leaf node and creating the (m + 2)-nd root node .
-T %
m

m+2
T 0 is a proof of , ` .

H OME PAGE

JJ

m+1

QED

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

353 OF 788

Q UIT

About Formal Proofs


Since a formal proof is a tree, it is acyclic (i.e. there is no
circularity in the proof).
Every formal proof is a finite tree i.e. a proof is a finitary
object.
Questions.
1. What if the set of assumptions is infinite?
2. Are there statements which have only infinite proofs and no
finite proof?

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

354 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

355 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

356 OF 788

Q UIT

14. Lecture 14: Derived Rules

Lecture 14: Derived Rules


Tuesday 30 Aug 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

357 OF 788

Q UIT

1. Simplifying Proofs
2. Derived Rules
3. The Sequent Form
4. Proof trees in sequent form
5. Transitivity of Conditional
6. Derived Double Negation Rules
7. Derived Operators
8. Rules for Derived Operators

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

358 OF 788

Q UIT

Simplifying Proofs
The deduction theorem allows movement of sub-formulae
between the set (sequence) of assumptions and the formula
to be proven.
Hence the set (sequence) of formulae which form the assumptions is an important part of the proof.
We use the notion of a sequent to formalize this movement
which may take place a any stage.
Definition 14.1 A sequent is a meta-formula of the form ` .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

359 OF 788

Q UIT

Derived Rules
By substitutivity (theorem 13.1) we may simplify our proofs by
incorporating theorems and meta-theorems as derived rules
of our proof system.
These rules may be presented in sequent form.
The proof of the reflexivity may be rendered in sequent form
by simply pre-pending each node in the tree with `.
The Deduction Theorem and its converse may be rendered
in sequent form as a derived rule.
Reflexivity may be expressed in sequent form as a derived
rule.
These derived rules may be directly invoked in later proofs.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

360 OF 788

Q UIT

The Sequent Form


Let be a sequence of formulae.
K.

S.

N.

` X (Y X)

` (Y X) ((Y X) Y )

` (X (Y Z)) ((X Y ) (X Z))

`XY
`X
MP.
`Y
R.
H OME PAGE

JJ

`XY
DT .
, X ` Y

` XX
J

II

LCS

G O B ACK

, X ` Y
DT .
`XY
F ULL S CREEN

C LOSE

361 OF 788

Q UIT

Proof trees in sequent form


Theorem 14.2 For all , and ,
( ) (( ) ( ))
Proof: Let 1 = , 2 = 1, and 3 = 2,
3 ` 3 `
MP
3 `
MP
2,
DT
DT 2
1
DT
QED
H OME PAGE

JJ

II

3 `
`
`
` ( ) ( )
` ( ) (( ) ( ))

LCS

G O B ACK

F ULL S CREEN

C LOSE

362 OF 788

Q UIT

Transitivity of Conditional
From theorem 14.2 we get a derived axiom schema
T.

` (X Y ) ((Y Z) (X Z))
But equivalently by applying the derived rule DT to T above
we also get a derived rule of inference which is often more convenient to use.
`XY
`Y Z
T.
`XZ

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

363 OF 788

Q UIT

Exercise 14.1
1. Prove that each of the axiom schemas in H0 represents a collection of tautologies.
2. Prove that Modus Ponens in sequent form preserves logical consequence i.e. if |= and
|= then |= .
3. Using the above prove that the proof system H0 is sound i.e. If `H0 then |= .
4. Find the fallacy in the following proof of theorem 14.2. Assume 1, 2 and 3 are as in the proof
of theorem 14.2.

3 `
DT
2 ` ( )
MP

H OME PAGE

JJ

S
2 ` ( ( )) (( ) ( )) 2 `
MP
2 ` ( ( )) ( )
2 `
DT
1 ` ( ) ( )
DT
` ( ) (( ) ( ))

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

364 OF 788

Q UIT

5. Prove the following derived rule of inference (You may use any of the derived rules of inference
in addition to the usual proof rules).

R2 .

` X (Y Z)
`Y
`XZ

6. Could we have consequently reordered our theorems by first proving R2 and then proving
T? Discuss whether there is anything fallacious in this approach.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

365 OF 788

Q UIT

Derived Double Negation Rules


` X
DNE.
`X

`X
DNI.
` X

The following proof trees yield proofs of the derived double


negation elimination and introduction rules respectively.
Alternatively we may regard them as derived axiom schemas
DNE .

H OME PAGE

JJ

DNI .

` X X

II

LCS

G O B ACK

F ULL S CREEN

` X X

C LOSE

366 OF 788

Q UIT

Proof of derived rule DNE and axiom schema DNE


Proof:
N
( ) (( ) ) R
K
R2
( )
( )
T

DT `


QED
Proof of derived rule DNI and axiom schema DNI
Proof:
K
( )
T

N
( ) (( ) ) DNE
MP
( )

DT `


QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

367 OF 788

Q UIT

Exercise 14.2
1. Prove the axiom schema
N0.

(Y X) (X Y )

A deduction theorem variant of this schema is also called the modus tollens rule or the contrapositive rule.
2. A variant of the system H0 is the system H00 obtained by replacing the schema N by N.
(a) Prove the axiom schema N in the system H00.
(b) Prove the double negation rules DNE and DNI in H00.
3. Prove the following axiom schemas in H0. In each case you are allowed to use any version of
the theorems previously proven.
(a) .
(b) N00.

H OME PAGE

JJ

X (X Y )

What can you conclude about the system H0 from your proof?

(X Y ) (Y X)
J

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

368 OF 788

Q UIT

(c) N2.

X (Y (X Y ))

(d) C.

Derive the proof by cases rule Cases.

, X ` Y
, X ` Y

(X Y ) ((X Y ) Y )
`Y
(e) Derive the proof by contradiction also called the indirect proof method rule I in the system
H0 .
, X ` Y
, X ` Y
I.
` X

4. Prove the derived axiom C2.

H OME PAGE

JJ

` (XX)X

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

369 OF 788

Q UIT

Derived Operators
df

>

for all

df

= ( )

for all

df

=
df

= ( )
df

= (( ) ( ))
Several other binary and other operators of varying arities may
be defined.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

370 OF 788

Q UIT

Rules for Derived Operators


Corresponding

to

each

derived

operator

defined

as

df

O(X1, . . . , Xn) = (X1, . . . , Xn) where is constructed only


from the set {, } we have the introduction and elimination
rules.
` O(X1, . . . , Xn)
OE.
` (X1, . . . , Xn)
` (X1, . . . , Xn)
OI.
` O(X1, . . . , Xn)

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

371 OF 788

Q UIT

Gentzens System
Natural Deduction

Gentzens Natural Deduction system is not a minimal system,


instead it is somewhat more natural in the sense that it has
explicit introduction and elimination rules for each operator.
We present sequent version of the system in the following.
Further there is some redundancy in the rules. Not all the
rules may actually be useful, but they possess a pleasing
symmetry.
However, it is necessary to prove both the soundness and
the completeness of the system.
We refer to the system as G0.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

372 OF 788

Q UIT

Natural Deduction: 1
Introduction
Elimination
` X X
`
I.
E.
`
`X
`>
> >I.
>E.
`>
` X X

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

373 OF 788

Q UIT

Natural Deduction: 2
Introduction
Elimination
, X `
, X `
I.
E.
` X
`X
`X
` X
I.
E.
` X
`X

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

374 OF 788

Q UIT

Natural Deduction: 3
Introduction

Elimination
` X Y
` XZ
` Y Z
`X
`Y
I1.
I2.
E.
`X Y
`X Y
`Z

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

375 OF 788

Q UIT

Natural Deduction: 4
Introduction
Elimination
` X
` Y
`X Y
`X Y
I.
E1.
E2.
`X Y
`X
`Y

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

376 OF 788

Q UIT

Natural Deduction: 5
Introduction

Elimination
` XY
` X
E.
`Y

, X ` Y
I.
`XY
` XY
` Y X
`XY
`XY
I.
E1.
E2.
`XY
`XY
`Y X

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

377 OF 788

Q UIT

Exercise 14.3
1. Prove the logical equivalences of P0 using the system H0.
2. Prove the non-obvious logical equivalences of P0 in the system G0.
3. Derive each of the rules of G0 from the system H0. You may use the rules OE and OI as and
when needed for each operator.
4. Derive the axiom schemas K, S and N in G0.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

378 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

379 OF 788

Q UIT

15. Lecture 15: The Hilbert System: Soundness

Lecture 15: The Hilbert System:


Soundness
Tuesday 06 September 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

380 OF 788

Q UIT

1. Formal Theory: Issues


2. Formal Theory: Incompleteness
3. Soundness of Formal Theories
4. Soundness of the Hilbert System
5. Soundness of the Hilbert System

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

381 OF 788

Q UIT

Formal Theory: Issues


The major questions concerning any formal theory are two-fold:
Soundness. Is the theory sound? Especially considering that we
may not have well-defined models in which to test the truth
or falsehood of statements.
Completeness. Is the theory complete? That is, is every fact
provable from the axioms and inference rules of the theory?

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

382 OF 788

Q UIT

Formal Theory: Incompleteness


Suppose a given formal theory is incomplete. There are several
possibilities.
Question 1. Can the theory be made complete by adding or
changing some axioms and inference rules (without making
the theory inconsistent)?
Question 2. Is the theory inherently incomplete? That is, is there
no way of achieving completeness by adding only a finite
number of new axioms and inference rules?

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

383 OF 788

Q UIT

Soundness of Formal Theories


Given that the proof theory may be the only finitary tool available to us in reasoning about some domain we need to define
the notion of consistency of the theory in terms of the prooftheoretic notions.
Definition 15.1 A formal theory is unsound if every wff is a theorem. Otherwise it is said to be sound.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

384 OF 788

Q UIT

Soundness of the Hilbert System


Lemma 15.2
1. Every instance of every axiom schema in H0 is a tautology.
2. The Modus Ponens rule MP preserves tautologousness.
2
A truth table technique would serve the purpose for H0 alone
but would not be possible when H0 is extended to H1.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

385 OF 788

Q UIT

Proof of lemma 15.2


Proof:
1. We prove the case of any instance of the axiom schema K. We need
to show that for all and , ( ) is a tautology. Suppose
it is not a tautology. Then there exists a truth assignment such
that T J ( )K = 0 which is possible only if T JK = 1
and T J K = 0 which in turn is possible only if T JK = 1
and T JK = 0 which is impossible. Hence there is no such truth
assignment. So ( ) must be a tautology.
A similar reasoning may be applied to the axiom schemas S and N.
2. Assume for some and that and are tautologies but
is not. It is easy to see that for any truth assignment , T JK = 0
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

386 OF 788

Q UIT

implies T JK = 0 contradicting the assumption that is a tautology.




QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

387 OF 788

Q UIT

Soundness of the Hilbert System


Theorem 15.3 Every formal theorem of H0 is a tautology.

The theorem follows by induction on the heights of proof trees,
since every leaf would be a tautology and every internal node
preserves tautologousness.
Corollary 15.4 The system H0 is sound.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

388 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

389 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

390 OF 788

Q UIT

16. Lecture 16: The Hilbert System: Completeness

Lecture 16: The Hilbert System:


Completeness
Wednesday 07 Sep 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

391 OF 788

Q UIT

1. Towards Completeness
2. Towards Truth-tables
3. The Truth-table Lemma
4. The Completeness Theorem

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

392 OF 788

Q UIT

Towards Completeness
1. By theorem 15.3 the only theorems of the system H0 are
tautologies.
2. By theorems 4.2 and 4.3 the question of completeness of H0
reduces to that of whether every tautology of P0 is provable in
H0.
3. If H0 is complete then by exercise 14.3.4, G0 is also complete.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

393 OF 788

Q UIT

Towards Truth-tables
1. Restricting ourselves to showing that every tautology is provable in H0 is sufficient.
2. But we proceed to show that every truth table can be simulated as a proof in H0, thereby capturing all of the semantic
features of the language P0 in its proof theory.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

394 OF 788

Q UIT

The Truth-table Lemma


Lemma 16.1 Let be a formula with atoms() {p1, . . . , pk }.
For each truth assignment ,
p1 , , pk `
where for each i, 1 i k,

pi if (pi) = 1

pi
pi otherwise
and

if T JK = 1
otherwise
2

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

395 OF 788

Q UIT

Proof of lemma 16.1


Proof: By induction on the number n of operators in . Let = {p1 , . . . , pk }.
Basis. n = 0. Then is an atom say, p1. The claim then trivially follows since p1 .
Induction Hypothesis (IH).
The claim holds for all wffs with less than n 0 occurrence of the operators.
Induction Step. Suppose is a wff with n operators. Then there are two cases to consider.
Case , where has less than n operators. Then by the induction hypothesis we have
- T1 %
have a proof tree
.
`
Subcase T JK = 1. Then T JK = 0 and and . Then we have the
following deduction.
- T1 %
`
`

DNI `
MP

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

396 OF 788

Q UIT

Subcase T JK = 0. Then T JK = 1 and and . By the induction


hypothesis we have ` .
Case . where each of and has less than n operators. By the induction hypothesis
- T2 %
- T1 %
and
. Here again we have three subscases.
there exist proof trees
`
`
Subcase T JK = 0. We have so tree T1 is

. We then have the proof tree

- T1 %
, T JK = 1 and
`

- T1 %
`
`

` ( )

MP
which proves the claim.

Subcase T JK = 1. Then and T JK = 1 and . Hence tree T2 is


- T2 %
. We may then construct the following proof tree to prove the claim.
`

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

397 OF 788

Q UIT

- T2 %
`
`

` ( )

MP

Subcase T JK = 1 and T JK = 0. Then and and T JK = 0 from which


- T1 %
we get ( ). By induction hypotheses we therefore have the trees
and
`
- T2 %
using which we construct the following proof tree to prove our claim.
`
N2

` ( ( ))

MP

- T1 %
`

` ( )
MP

- T2 %
`

` ( )


QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

398 OF 788

Q UIT

The Completeness Theorem


We are now ready to prove the completeness theorem by restricting it to all the tautologies of propositional logic.
Theorem 16.2 (The Completeness Theorem). Every tautology is
a formal theorem of H0.
2

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

399 OF 788

Q UIT

Proof of the Hilbert Completeness Theorem 16.2


Proof:
Let be a tautology expressed in the language L0 and let atoms() = {p1, . . . , pk }.
Since every row of the truth-table for assigns it a truth value 1 we have . Each bit-string
sk {0, 1}k indexes a row of the truth table containing 2k distinct rows. Let sk = {pi | 1
i k} denote the set of assumptions for the sk -th row of the truth table. By the truth table lemma
- Tsk %
(lemma 16.1), there exists a distinct proof tree,
for each such sk . For each bit-string
sk `
- Tsj10 %
- Tsj1 %
from the proof trees
sj {0, 1}j , 0 < j k, we construct the proof tree
sj1 `
sj10 `
- Tsj11 %
and
, where sj10 and sj11 are the two bit-strings of length j, which differ only in
sj11 `
the right-most bit.
Note that s0 =  is the empty string,  = and we need to construct the proof tree
the 2k distinct proof trees

- Tsk %
.
sk `

- Ts0 %
from
s0 `

Now consider any two proof trees whose indexes differ only in the rightmost bit. That is, for any

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

400 OF 788

Q UIT

sj1 {0, 1}j1, we have the proof trees


tree

- Tsj1 %
as follows.
sj1 `

- Tsj10 %
sj10 `
DT
sj1 ` pj
MP

- Tsj11 %
- Tsj10 %
and
. We construct the proof
sj11 `
sj10 `

- Tsj11 %
sj11 `
DT
sj1 ` pj
MP

sj1 ` (pj ) ((pj ) )


sj1 ` (pj )

sj1 `

We can thus eliminate the atom pj from the assumptions by applying the above proof procedure to
all pairs of proof trees whose assumptions differ only in the value of pj .
Thus the 2k proof trees are combined pairwise to produce 2k1 proof trees that are independent of
the atom pk . Proceeding in a like manner we may eliminate all the atoms one by one by using similar
- T %
proof constructions so that finally we obtain a single monolithic proof tree
where  = ,
 `
thus concluding the proof that the tautology is a formal theorem of H0.
QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

401 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

402 OF 788

Q UIT

17. Lecture 17: Introduction to Predicate Logic

Lecture 17: Introduction to Predicate


Logic
Friday 09 Sep 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

403 OF 788

Q UIT

1. Predicate Logic: Introduction-1


2. Predicate Logic: Introduction-2
3. Predicate Logic: Introduction-3
4. Predicate Logic: Symbols
5. Predicate Logic: Signatures
6. Predicate Logic: Syntax of Terms
7. Predicate Logic: Syntax of Formulae
8. Precedence Conventions
9. Predicates: Abstract Syntax Trees
10. Subterms
11. Variables in a Term
12. Bound Variables And Scope
13. Bound Variables And Scope: Example
14. Scope Trees
15. Free Variables
16. Bound Variables
17. Closure

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

404 OF 788

Q UIT

Predicate Logic: Introduction-1


Example 17.1 There are many kinds of arguments which cannot be proven in propositional logic and which require the notion
of quantifiers. The most famous one perhaps containing only
very basic and simple declarative statements is
All humans are mortal.
Socrates is a human.
Therefore Socrates is mortal.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

405 OF 788

Q UIT

Predicate Logic: Introduction-2


The validity of this argument does not depend on any propositional connectives since there are none. Hence it is not provable
in propositional logic.
However it is valid and its validity depends upon
the internal structure of the sentences,
the meaning of certain operative words and phrases such as
All
certain properties of objects e.g. mortal
the description of certain classes by their properties and
membership or other relations on these classes e.g. is a.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

406 OF 788

Q UIT

Predicate Logic: Introduction-3


1. The deeper relationships that exist between otherwise simple
propositions require parametrisation of propositions so that
the inter-relationships become clear.
2. Parametrised propositions are called predicates.
3. Each predicate specifies either a property (1-ary predicates)
or a relationship between objects (n-ary predicates).
4. The propositions of propositional logic are 0-ary predicates.
5. Mathematical theories are often about collections of infinite
objects whose relationships and inter-relationships are finite
expressions involving functions, relations and expressions involving them.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

407 OF 788

Q UIT

Predicate Logic: Symbols


V: a countably infinite collection of variable symbols;
x, y, z, . . . V.
F: a countably infinite collection of function symbols;
f , g, h, . . . F.
A: a countably infinite collection of atomic predicate symbols;
p, q, r, . . . A.
Grouping symbols: (, ), (, ), [, ].
All of the above sets are pairwise disjoint.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

408 OF 788

Q UIT

Predicate Logic: Signatures


Definition 17.2 A signature (or more accurately 1-sorted signature) is a denumerable (finite or countably infinite) collection
of strings of the form
f : sm s, m 0
or
p : sn , n 0
such that there is at most one string for each f F and each
p A. m and n are respectively the arity of f and p.
Here s is merely a symbol signifying a sort of elements. A generalization to many-sorted algebras would require the use of as
many such symbols s1, . . . , sm as there are sorts.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

409 OF 788

Q UIT

Predicate Logic: Syntax of Terms


Definition 17.3 Given a signature , the set T() of -terms is
defined inductively by the following grammar
s, t, u ::= x V | f (t1, . . . , tm)
where f : sm s and t1, . . . , tm T(). If m = 0 then f ()
is called a constant and simply written f . We usually use the
symbols a, b, c, . . . to denote constants.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

410 OF 788

Q UIT

Predicate Logic: Syntax of Formulae


Definition 17.4 Given a signature and the set T() of terms.
A -atomic formula or -atom is a string of the form
p(t1, . . . , tn) where p : sn . A() is the set of -atoms.
1 = 0 {x, x | x V}
The set of P1() of -formulas is defined inductively by the
following grammar.
, ::=
|
|
|
|
H OME PAGE

JJ

p(t1, . . . , tn) A()


( )
( )
x[]
II

LCS

G O B ACK

|
|
|
|
|

>
()
( )
( )
x[]

F ULL S CREEN

C LOSE

411 OF 788

Q UIT

Precedence Conventions
The operator precedence conventions are as before.
The two new operators are called the universal quantifier ()
and existential quantifier () respectively and are parameterised by variables.
The scope of the (variable in a) quantified formula is delimited
by the the matching pair of brackets ([ and ]).
If a formula is preceded by several quantifiers (e.g.
x[y[z[]]]) we collapse the scoping brackets where there
is no ambiguity (e.g xyz[]).
We will think of both -terms and -formulae as abstract syntax trees. The brackets delimiting the scope of a quantifed
variable then become redundant.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

412 OF 788

Q UIT

Predicates: Abstract Syntax Trees


Example 17.5 Let p, q and r be unary predicates. The firstorder logic formula x[p(x) x[q(x)]] r(x)

x
x

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

413 OF 788

Q UIT

Subterms
Definition 17.6 For each term t, ST (t) denotes the set of subterms of t (including t itself). The set of proper subterms of t is
the set ST (t) {t}.
t
c()
x
f (t1, . . . , tn)

H OME PAGE

JJ

depth
1
1
1+
M axni=1depth(ti)

II

LCS

size
1
1
1+
P

n
i=1 size(ti)

G O B ACK

F ULL S CREEN

ST
{t}
{t}
{t}
S

n
i=1 ST (ti)

C LOSE

414 OF 788

Q UIT

Variables in a Term
For any term t, V ar(t) denotes the set of all variables that occur in t. These functions may be defined by induction on the
structure of terms as follows.
Definition 17.7
t
c()
x
f (t1, . . . , tn)

H OME PAGE

JJ

II

V ar(t)

{x}
S

1in V ar(ti)

LCS

G O B ACK

F ULL S CREEN

C LOSE

415 OF 788

Q UIT

Bound Variables And Scope


Definition 17.8 In a formula of the form x[] the variable x is
said to be bound by the quantifier . The brackets [ ] delimit
the scope of the binding.
Q

Example 17.9 In the abstract syntax tree of the predicate


x[p(x) x[q(x)]] r(x)
the scopes of the various bindings are indicated by dashed
boxes. Notice that the red scope is a hole in the blue scope.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

416 OF 788

Q UIT

Bound Variables And Scope: Example

x
x

x
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

417 OF 788

Q UIT

Scope Trees
The abstract syntax tree also determines the scope of the individual bound variables.

x
x

x
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

418 OF 788

Q UIT

Free Variables
Definition 17.10 For any predicate the set of free variables
occurring in it (denoted F V ()) and the set of sub-formulae
(denoted SF () are defined by induction on the structure of
predicates.

F[
V ()
SF ()
Condition
p(t1, . . . , tn)
V ar(ti)
{p(t1, . . . , tn)}
1in

F V ()
{} SF ()
F V () F V () {o(, )} SF () o 0 {}
SF ()
F V () {x}
{ x[]} SF ()
{, }

x[]

JJ

H OME PAGE

II

LCS

o(, )

G O B ACK

F ULL S CREEN

C LOSE

419 OF 788

Q UIT

Bound Variables
Definition 17.11 If x[] is a sub-formula of some formula
then is said to be the scope of the quantifier x and every
free occurrence of the variable x in the formula is said to be
bound in the scope of the quantifier x in which it occurs.
Q

Notice that if x[] is a sub-formula of in the definition 17.11


then any x F V () is not a free variable of .
We may write (x1, . . . , xm) to indicate that F V ()
{x1, . . . , xm}.
Q

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

420 OF 788

Q UIT

Closure
Definition 17.12
1. A formula is called closed if F V () = .
2. The universal closure of (x1, . . . , xm) denoted ~[] is defined
as the formula x1, . . . , xm[].
3. The existential closure of (x1, . . . , xm) denoted ~[] is defined
as the formula x1, . . . , xm[].
4. A literal is an atomic formula or its negation. For any literal
will denote its negation.
,

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

421 OF 788

Q UIT

Exercise 17.1
1. Translate the following statements into first-order logic statements. (You may use the function
symbols that are normally used in mathematics, e.g. 0 for zero, = for equality, + for
addition etc.). The names x, y etc. stand for variables.
Every number has a unique successor.
Not every number has a predecessor.
The sum of any two odd numbers is even.
x is a prime.
There is no largest prime.
x is a divisor of y.
x and y are relatively prime.
Define the notion of greatest common divisor of two numbers as as a ternary predicate
gcd(x, y, z) in terms of the previous parts. In other words, gcd(x, y, z) stands for the statement

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

422 OF 788

Q UIT

z is the greatest common divisor of x and y


2. Symbolize the following arguments in first order logic You may assume in each case that the universe of discourse contains the various relations mentioned as predicates (and nothing more!).
There is a man whom all men despise. Therefore at least one man despises himself.
All hotels are expensive and depressing. Some hotels are shabby. Therefore some expensive
hotels are shabby.
Anyone who is loved loves everyone. No one loves Charlie Brown. Therefore no one loves
anyone.
Whoever visited the building was observed. Anyone who had observed Ajay, would have
remembered him. Nobody remembered Ajay. Therefore Ajay did not visit the building.
If all drugs are contaminated then all negligent technicians are scoundrels. If there are any
drugs that are contaminated then all drugs are contaminated and unsafe. All pesticides are
drugs. Only the negligent are absent-minded. Therefore if any technician is absent-minded,
then if some pesticides are contaminated, then he is a scoundrel.
Some criminal robbed the mansion. Whoever robbed the mansion broke in or had an accomplice among the servants. To break in one would have to smash the door or pick the lock.
Only an expert locksmith could have picked the lock. Had anyone smashed the door, he would
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

423 OF 788

Q UIT

have been heard. Nobody was heard. If the criminal who robbed the mansion managed to
fool the guard, he must have been a convincing actor. Nobody could rob the mansion unless
he fooled the guard. No criminal could be both an expert locksmith and a convincing actor.
Therefore some criminal had an accomplice among the servants.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

424 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

425 OF 788

Q UIT

18. Lecture 18: The Semantics of Predicate Logic

Lecture 18: The Semantics of


Predicate Logic
Wednesday 14 Sep 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

426 OF 788

Q UIT

1. Structures
2. Notes on Structures
3. Infix Convention
4. Expansions and Reducts
5. Valuations and Interpretations
6. Evaluating Terms
7. Coincidence Lemma for Terms
8. Variants
9. Variant Notation
10. Semantics of Formulae
11. Notes on the Semantics

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

427 OF 788

Q UIT

Structures
Given a signature , a -structure or -algebra A consists of
a non-empty set A = |A| called the domain (or carrier or
universe) of A,
a function f A : Am A for each m-ary function symbol
f (including symbols for each constant)
a relation pA An for each n-ary atomic predicate symbol
p and
(for completeness) a truth value pA 2 = {0, 1} for each
(0-ary) atomic proposition p .
When the -algebra is understood or is the only structure under
consideration, we omit the subscript A from the functions and
relations.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

428 OF 788

Q UIT

Notes on Structures
1. The domain has to be non-empty.
2. All functions are total.
3. One way to deal with partial functions (e.g. division on natural numbers) of arity m > 1 is to treat them as (m + 1)-ary
relations and define predicate symbols to represent them.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

429 OF 788

Q UIT

Infix Convention
If in particular structures, functions or relations are normally
written in infix form, then we use the infix form in the logical
language too.
Example 18.1 If N = hN; +; <i the set of natural numbers under
the binary operation of addition (+) and the binary relation lessthan (<) is the structure, then we write predicate formulae using
the corresponding symbols in the language in infix form. For
example, the formula
x[y[x < x + y]]
with the operation in infix form is more easily understood in
place of the more pedantic
x[y[< (x, +(x, y))]]
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

430 OF 788

Q UIT

Expansions and Reducts


Definition 18.2 Let be signatures. A -structure A is
called a reduct to an -structure B if for all f , p iff
|A| = |B|,
f A = f B for each f and
pA = pB for each p
B is also called an expansion of A and is denoted A  B

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

431 OF 788

Q UIT

Valuations and Interpretations


To be able to define the truth or falsehood of a predicate with
free variables, it is necessary to be able to first define a valuation for the variables.
Definition 18.3 Given a -structure A, a valuation is a function
vA : V |A| which assigns to each variable a unique value
in |A|.
Definition 18.4 Given a -structure A and a valuation
vA : V |A|, (A, vA) is called a -interpretation.
The subscript A is often omitted when the context makes clear
the structure that is being referred to.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

432 OF 788

Q UIT

Evaluating Terms
Definition 18.5 Given -interpretation (A, v) the value of a term
t in the interpretation is defined by induction on the structure of
the term.
df

VAJxKv

xV

= v(x),

df

VAJf (t1, . . . , tm)Kv = fA(VJt1Kv , . . . , VJtmKv ), f : sm s


Notational conventions.
1. If V ar(t) {x1, . . . , xm}, we sometimes write t(x1, . . . , xm) to
denote this fact.
2. The subscript A is often omitted when the context makes
clear the structure that is being referred to.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

433 OF 788

Q UIT

Coincidence Lemma for Terms


The following lemma may be easily proved by induction on the
structure of terms.
Lemma 18.6 Given two -interpretations (A, v) and (A, v 0), and
a term t, if v(x) = v 0(x) for each x V ar(t), then VJtKv = VJtKv0

Notational convention.
If t(x1, . . . , xm), v(x1) = a1, . . . , v(xm) = am for a1, . . . , am |A|
in some -interpretation (A, v), then we write tA(a1, . . . , am) instead of VJt(x1, . . . , xm)Kv , since only the values of the variables
occurring in t are needed to evaluate it.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

434 OF 788

Q UIT

Variants
Definition 18.7 Two valuations v, v 0 : V |A| are said to be
X-variants of each other (denoted v =\X v 0 for any X V if for
all y V X, v(y) = v 0(y), i.e. they differ from each other at most
in the values for variables from X.
Fact 18.8
1. For any X V and valuation v, v is an X-variant of itself i.e.
v =\X v.
2. =\X is an equivalence relation on valuations.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

435 OF 788

Q UIT

Variant Notation
Notation.
1. When X = {x} is a singleton we refer to v and v 0 as x-variants
and denote it by v =\x v 0.
2. If vx =\x v and vx(x) = a |A| we write vx = v[x := a].
3. If X = {x1, . . . , xn}, vX =\X v and vX (xi) = ai |A|, for each
i, 1 i n, then we write vX = v[x1 := a1, . . . , xn := an].

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

436 OF 788

Q UIT

Semantics of Formulae
Let (A, vA) be a -interpretation. Then T JKv is defined by
induction on the structure of . We omit the propositional connectives as being obvious and concentrate only on the other
constructs.

df
1 if (VAJt1KvA , . . . , VAJtnKvA ) pA
TAJp(t1, . . . , tn)KvA =
0 otherwise
df Q
0 = v }
TAJx[]KvA
= {TAJKv0 | vA
\x A
A
df P
0 = v }
TAJx[]KvA
= {TAJKv0 | vA
\x A
A

Definitions of

P Q
,

The subscript A is often omitted when the context makes clear


the structure that is being referred to.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

437 OF 788

Q UIT

Notes on the Semantics


1. Truth value is now evaluated under a valuation instead of a
truth assignment.
2. A valuation defines a truth assignment to parameterised propositions depending upon the values of the parameters.
0 is an x-variant of v } is nonempty
3. The set {TAJKv0 | vA
A
A
since vA is also an x-variant of itself.

4. The number of x-variants of v equals the cardinality of |A|.


5. Even though there may be infinitely many x-variants of a val0 is an x-variant of v } canuation vA, the set {TAJKv0 | vA
A
A
not have more than two elements. Hence the sum and product are both finitary.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

438 OF 788

Q UIT

Exercise 18.1
1. Define interpretations on universes of discourse containing at least 3 elements and give a valuation in which the following hold. Assume p and q are atomic predicate symbols of any positive
arity of your choice.
(a) (p x[q] x[p q])
(b) (x[p q] (x[p] q))
2. Prove that the following predicates have no models at all where p and q are atomic predicates
(of any positive arity).
(a) (p x[q] x[p q])
(b) ((x[p] q) x[p q])
3. Consider the universe of discourse to be the set of all nodes of graphs and let the atomic binary
predicate symbol e stand for the edge relation on nodes, i.e. e(x, y) stands for there is an edge
from x to y. Further let = stand for the usual identity relation on nodes. What properties on
graphs do the following first-order predicates define?
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

439 OF 788

Q UIT

(a) x[y[(x = y) e(x, y)]]


(b) x[y[e(x, y) (x = y)]]
(c) x[y[(x = y) (e(x, y) e(y, x))]]
(d) x[y[z[e(x, y) e(y, z) e(x, z)]]]

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

440 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

441 OF 788

Q UIT

19. Lecture 19: Substitutions

Lecture 19: Substitutions


Friday 16 September 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

442 OF 788

Q UIT

1. Coincidence Lemma for Formulae


2. Substitutions
3. Instantiation of Terms
4. The Substitution Lemma for Terms
5. Admissibility
6. Instantiations of Formulae
7. The Substitution Lemma for Formulae

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

443 OF 788

Q UIT

Coincidence Lemma for Formulae


The following lemma analogous to lemma 18.6 may be proved
by induction on the structure of formulae.
Lemma 19.1 Given two -interpretations (A, v) and (A, v 0),
and a formula , if v(x) = v 0(x) for each x F V (), then
T JKv = T JKv0 .
2

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

444 OF 788

Q UIT

Proof of The Coincidence Lemma for formulae (lemma 19.1)


Variant Notation

Semantics of Formulae

Proof: By induction on the structure of . However the interesting cases are those of atomic
predicates and quantified formulae.
Case p(t1, . . . , tn) where p is an n-ary predicate symbol. For each x F V (p(t1, . . . , tn)) =
[
V ar(ti) we have v(x) = v 0(x). Hence for each ti we have VJtiKv = VJtiKv0 from which we get

1in

T Jp(t1, . . . , tn)Kv = T Jp(t1, . . . , tn)Kv0 .


x[],

Case

{, }. Assume (x1, . . . , xn). We consider two cases.

Sub-case x 6 F V (). Then x 6 {x1, . . . , xn} and hence for every vx and vx0 which are x-variants of
v and v 0 respectively we have T J(x1, . . . , xn)Kvx = T J(x1, . . . , xn)Kvx0 from which we obtain
Q
Q
{T JKvx | vx =\x v} =
{T JKvx0 | vx0 =\x v 0}
and
P
P
{T JKvx | vx =\x v} =
{T JKvx0 | vx0 =\x v 0}
which implies T JKvx = T JKvx0 .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

445 OF 788

Q UIT

Sub-case x F V (). Then F V () = {x, x1, . . . , xn}. Let T (x) = {T JKvx | vx =\x v} and
T 0(x) = {T JKvx0 | vx0 =\x v 0}. Note that T (x), T 0(x) {{0}, {1}, {0, 1}}. Assume for some
J
Q P
{ , }, T JKvx 6= T JKvx0 . Then T (x) 6= T 0(x) which implies there exists a A = |A|
such that for vx = v[x := a] and vx0 = v 0[x := a], T JKvx 6= T JKvx0 . But this is impossible
since F V () = {x, x1, . . . , xn}, vx(x) = a = vx0 (x) and for each xi {x1, . . . , xn}, we have
vx(xi) = vx0 (xi). Hence T JKvx = T JKvx0 .
QED


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

446 OF 788

Q UIT

Substitutions
Definition 19.2
A substitution is a (total) function : V T() which is
almost everywhere the identity.
S1 (V) is the set of all substitutions.
is called a ground substitution if F V ((x)) = .
The domain of a substitution is the finite set dom() =
{x | x 6 (x)}. acts on the variables in dom().
Notes and notation.
Equivalently a substitution may be represented as a finite
(possibly empty) set = {s/x | (x) = s 6 x} containing
only the non-identical elements and their images under .
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

447 OF 788

Q UIT

Instantiation of Terms
Definition 19.3 Let be a substitution.
The application of to a term t T() is denoted t and
defined inductively as follows.
y
= y,
y 6 dom()
x
= (x),
x dom()
f (t1, . . . , tm) = f (t1, . . . , tm), f : sm s
t is called a (substitution) instance of t.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

448 OF 788

Q UIT

The Substitution Lemma for Terms


Lemma 19.4 Given a -interpretation (A, v), a term t and a
substitution {s/x}, let VJsKv = a |A|. Then
VJ{s/x}tKv = VJtKv[x:=a]
2

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

449 OF 788

Q UIT

Proof of The Substitution Lemma for Terms 19.4


Proof: By induction on the structure of t.
Case t x. Then {s/x}x s and we have VJ{s/x}tKv = VJsKv = a = VJtKv[x:=a].
Case t y 6 x. Then {s/x}y y and VJ{s/x}tKv = VJyKv = VJtKv[x:=a] since v(y) = v[x := a](y.
Case t f (t1, . . . , tm). Then
=
=
=
=
=

VJ{s/x}tKv
VJ{s/x}f (t1, . . . , tm)Kv
VJf ({s/x}t1, . . . , {s/x}tm)Kv
fA(VJ{s/x}t1Kv , . . . , VJ{s/x}tmKv )
fA(VJt1Kv[x:=a], . . . , VJtmKv[x:=a])
By the induction hypothesis
VJf (t1, . . . , tm)Kv[x:=a]


QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

450 OF 788

Q UIT

Admissibility
The occurrence of bound variables in formulae requires careful
handling when substitutions are applied to formulae. Intuitively,
an element s/x is admissible in a formula if the variables
of s remain free after instantiating the formula.
Definition 19.5 Let be a substitution
An element s/x is admissible in
p(t1, . . . , tn),
if it is admissible in ,
( ) if it is admissible in both and
x[],
y[] if x 6 y, y 6 F V (s) and s/x is admissible in .
Q
Q

is admissible in if every element of is admissible in .


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

451 OF 788

Q UIT

Instantiations of Formulae
Definition 19.6 Let be a substitution.
The application of to a formula P1() is denoted and
defined inductively as follows.

JJ

H OME PAGE

= p(t1 . . . , tn),
= (),
= ( ),
= x[0],

II

LCS

p : sn
{, , , }
0 = {(x)/x},

G O B ACK

F ULL S CREEN

C LOSE

p(t1, . . . , tn)

( )
x[]

{, }

452 OF 788

Q UIT

The Substitution Lemma for Formulae


Lemma 19.7 Given a -interpretation (A, v), a formula and
an admissible substitution {s/x}, let VJsKv = a |A|. Then
T J{s/x}Kv = T JKv[x:=a].
2

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

453 OF 788

Q UIT

Proof of The Substitution Lemma for Formulae 19.7


Proof: Case x 6 F V (). Then it trivially follows that {s/x} and T J{s/x}Kv = T JKvx for
all x-variants of v.
Case x F V (). We proceed by induction on the structure of .
Sub-case p(t1, . . . , tn). We have
T J{s/x}Kv
= T J{s/x}p(t1, . . . , tn)Kv
= T Jp({s/x}t1, . . . , {s/x}tn)Kv
= T Jp(t1, . . . , tn)Kv[x:=a]
By lemma 19.4

The sub-cases involving the propositional connectives are trivial and the only interesting cases left
are those of quantified formulae.
Sub-case y[]. Since x F V () clearly x 6 y and hence x F V (). Further since {s/x}
is admissible in , y 6 V ar(s). This implies that
Q

1. {s/x} is admissible in ,

H OME PAGE

JJ

y[{s/x}] and

2. {s/x}

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

454 OF 788

Q UIT

3. a = VJsKv = VJsKv[y:=b] for arbitrary b |A| since y 6 V ar(s).


By the induction hypothesis for any b |A| we have
T J{s/x}Kv[y:=b] = T JKv[y:=b][x:=a] = T JKv[x:=a][y:=b]

from which we get

{T J{s/x}Kvy | vy =\y v} = {T JKv[x:=a]y | v[x := a]y =\y v[x := a]}

which implies for any quantifier T J{s/x}Kv = T JKv[x:=a] regardless of the quantifier involved.
QED

Exercise 19.1
1. Let (A1, v1) be a 1-interpretation and (A2, v2) a 2-interpretation such that |A1| = |A2|. Let
= 1 2.
(a) Let t be a -term. Prove that if (A1, v1) and (A2, v2) agree on the symbols occurring in t,
then VA1 JtKv1 = VA2 JtKv2 .
(b) Let be a -formula. Prove that (A1, v1) and (A2, v2) agree on the symbols occurring in ,
then TA1 JKv1 = TA2 JKv2 .
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

455 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

456 OF 788

Q UIT

20. Lecture 20: Models, Satisfiability and Validity

Lecture 20: Models, Satisfiability and


Validity
Tuesday 20 September 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

457 OF 788

Q UIT

1. Satisfiability
2. Models and Consistency
3. Examples of Models:1
4. Examples of Models:2
5. Examples of Models:3
6. Logical Consequence
7. Validity
8. Validity of Sets of Formulae
9. Negations of Semantical Concepts

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

458 OF 788

Q UIT

Satisfiability
Definition 20.1 (Satisfaction).
A -interpretation (A, v) satisfies a -formula denoted
(A, v) if and only if T JKv = 1.

is said to be satisfiable in A if there is a valuation v such


that (A, v) .

A -formula is satisfiable if there exists a -interpretation


that satisfies it.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

459 OF 788

Q UIT

Models and Consistency


Definition 20.2 (Models).
A -structure A is a model (or more accurately a -model) of
a -formula P1() (denoted A ) if and only if for all
valuations v, (A, v) .
For a nonempty set of -formulas,
a -structure A is a -model of , (denoted A ) if and
only if it is a model of every formula in .
is said to be an axiom system for all models of .
is said to be consistent iff it has a -model.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

460 OF 788

Q UIT

Examples of Models:1
Example 20.3 Let = {0 : s, +1 : s s, = : s2, < : s2}, let
N = hN; 0, +1; =, <i
be the -structure where N is the set of naturals, +1 is the unary
successor function, = is the atomic binary equality predicate
and < is the binary less-than predicate. Let
df

df

1 = (+1(x) = 0)

2 = (+1(x) = +1(y)) (x = y)

df

df

3 = xy[y = +1(x)]

4 = x[(x = 0) y[x = +1(y)]]

We have N where = {1, 2, 3, 4}


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

461 OF 788

Q UIT

Examples of Models:2
Example 20.4 Let = {0 : s, + : s2 s, = : s2} and let Z
be the -structure
Z = hZ; 0, +; =i
where Z is the set of integers, 0 and + represent the integer
zero and the binary addition operation respectively, and = is the
atomic binary equality predicate. Z is a model of the following
set of formulae
df

associative = x, y, z[(x + y) + z = x + (y + z)]


df

identity = x[x + 0 = x]

(11)

df

rightinverse = xy[x + y = 0]
H OME PAGE

JJ

II

LCS

G O B ACK

(10)

(12)
F ULL S CREEN

C LOSE

462 OF 788

Q UIT

Examples of Models:3
Example 20.5 The set defined in the previous example is the
set of axioms which defines the notion of a group in algebra.
The addition of an extra axiom
df

commutative = x, y[x + y = y + x]

(13)

i.e. 0 = {commutative} excludes all non-commutative


groups from the models of the set 0.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

463 OF 788

Q UIT

Logical Consequence
Definition 20.6 A -formula is a logical consequence of a set
of -formulae, denoted |= , if and only if every model A
of is also a model of . If is empty then is said to be
logically valid (denoted |= ).
Example 20.7 Let be the signature in example 20.4 and let
df

the formula lef tinverse = xy[y + x = 0]. A typical proof in a


mathematics text that lef tinverse is a logical consequence of
the axioms of group theory (example 20.4) might go as follows.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

464 OF 788

Q UIT

Proof: Let x be any element. Then by axiom rightinverse there exists y such that
x+y =0

(14)

y+z =0

(15)

Again by rightinverse for some z we get


We then have
y+x =
=
=
=
=
=
=
=
QED

(y + x) + 0
(identity )
(y + x) + (y + z)
(15)
y + (x + (y + z)) (associative)
y + ((x + y) + z) (associative)
y + (0 + z)
(14)
(y + 0) + z
(associative)
y+z
(identity )
0
(15)


Effectively from the group axioms we have extracted fresh knowledge about groups in general
namely that, the existence of a right inverse for each element of the group implies the existence
of a left-inverse. In fact, by replacing the opening line of the proof by
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

465 OF 788

Q UIT

Let x and y be elements such that


we could claim that the following formula
df

lef trightinverse = x, y[(x + y = 0) (y + x = 0)]


is also a logical consequence of the group axioms.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

466 OF 788

Q UIT

Validity
Definition 20.8 (Validity). Let A be a -structure, and be
-formulae.
(A ). is valid in A if and only if A is a model of .
(A ). is valid in a class A of -structures if it is valid in
each structure A A.
( ). is (logically) valid if and only if every -structure is a
model of .
( ). is (logically) equivalent to if .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

467 OF 788

Q UIT

Validity of Sets of Formulae


Definition 20.9 (Validity of a set of formulae). Let be a set of
-formulae.
(A ). is valid in A if and only if A is a model of each
.
(A ). is valid in a class A of -structures if A for
each A A.
( ). is valid if and only if every -structure is a model of
each .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

468 OF 788

Q UIT

We have deviated in our meta-logical notation from standard textbooks. Notice from the definitions
of logical consequence, logical validity and validity of sets of formulae that |= if and only if for
every structure -structure A, A implies A . Most textbooks on first-order logic actually
use only one overloaded symbol |= for both concepts. However we have decided to keep them
separate since the concept of logical consequence involves sets of formulae of a formal language
whereas the other refers specifically to models.
Notice also that for any formula , both and |= denote that is (logically) valid. By extension,
therefore logical equivalence defined as may equally well be defined as |= .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

469 OF 788

Q UIT

Negations of Semantical Concepts


We use the symbols 6 , 6|=, 6 to denote the negations of the
corresponding relations.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

470 OF 788

Q UIT

Exercise 20.1
1. Prove that A is a model of iff A is a model of ~[].
2. Prove that |= iff ~[] |= ~[], where ~[] denotes the universal closure of each formula in
.
3. Prove that if and only if |= (i.e. |= ). Hence in most books on logic, the same symbol
|= is used for both logical consequence and for validity in models).
4. Prove that if and only if ~[].
5. Prove that is satisfiable in A if and only if ~[] is satisfiable in A.
6. Show that is valid for any formula .
7. In general every first-order logic formula which has a tautological shape in propositional
logic is a valid formula. Formalize this notion and prove it.
8. Prove that and are duals i.e. show that
(a) x[] x[]
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

471 OF 788

Q UIT

(b) x[] x[]


9. Let x[] SF () and y 6 F V (). Let 0 be obtained from by replacing x[] by
y[{y/x}]. Then and 0 are said to be -equivalent and denoted by 0. Prove that two
-equivalent formulae are equivalent.
Q

x[] is equvalent to .

10. If x 6 F V () then

11. Give examples of interpretations (A, v) to show that the following formulae are not valid.
(a) x[] x[]
(b) xy[(x, y)] yx[(x, y)]
12. Prove that for any binary predicate ,
x, y[(x, y) (y, x)] x, y[(x, y) (y, x)]
13. Prove that the following formulae are valid.
(a) x[(x) x[(x)]].
(b) xy[(x, y)] yx[(x, y)]
14. Prove that iff |= and |= .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

472 OF 788

Q UIT

15. A student claimed that the following definition is a stronger definition of logical consequence
than definition 20.6. Justify or refute his claim.
Definition 20.10 A -formula is a logical consequence of a set of -formulae, denoted
|=0 , if and only if for every interpretation (A, v), (A, v) for each implies
(A, v) .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

473 OF 788

Q UIT

20.1. Some Model Theory

When we consider the notion of a model, we come across various notions which express properties
of the models. For example, if < denotes an irreflexive ordering relation, then a sentence such as
xy[x < y] specifies that there is no greatest element in the ordering. Such a sentence therefore has
no finite models. Its negation however has only finite models. Another sentence such as xy[x = y]
in the language of first-order logic with equality has only singleton models.
If all models of a set of sentences are finite then there must be a finite bound on the size of the
models (i.e. the carrier set of the structure must be of a fixed finite cardinality). Otherwise, as the
following theorem shows there would also be infinite models. For instance as Enderton [3] states:
It is a priori conceivable that there might be some very subtle equation of group theory that
was true in every finite group but false in every infinite group.
But theorem 20.11 assures us that such a possibility does not exist.
Theorem 20.11 If a set of -formulae has arbitrarily large finite models, then it has an infinite
model.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

474 OF 788

Q UIT

Proof: Assume has arbirarily large finite models. Now consider the following formulae k for
each k 2,
df
2 = x1, x2[(x1 = x2)]
df

3 = x1, x2, x3[(x1 = x2) (x1 = x3) (x2 = x3)]


...
... ...
where each k states that there are at least k distinct elements in the model. Now consider the set
= {k | k 2}. By hypothesis, every finite subset of has a model. By the compactness
theorem therefore also has a model. However clearly no model of can be finite. Hence must
have an infinite model. This infinite model is also a model of since .
QED


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

475 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

476 OF 788

Q UIT

21. Lecture 21: Structures and Substructures

Lecture 21: Structures and


Substructures
Wednesday 21 Septemeber 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

477 OF 788

Q UIT

1. Satisfiability and Expansions


2. Distinguishability
3. Evaluations under Different Structures
4. Isomorphic Structures
5. The Isomorphism Lemma
6. Substructures
7. Substructure Examples
8. Quantifier-free Formulae
9. Lemma on Quantifier-free Formulae
10. Universal and Existential Formulae
11. The Substructure Lemma

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

478 OF 788

Q UIT

Satisfiability and Expansions


Our notions of satisfiability, consequence and validity are all
with respect to a specific signature.
Lemma 21.1 Let 1 2. For any set of 1-formulae, is
satisfiable with respect to 1 iff is satisfiable with respect to
2 .
Proof: Essentially the interpretations of the common symbols
should coincide, whereas the interpretations of the symbols in
2 1 may be arbitrary. It then follows from problem 1 of
exercise 19.1.
QED


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

479 OF 788

Q UIT

Distinguishability
Example 21.2 For = {= : s2, < : s2} consider the structures Z = hZ; ; =, <i and Q = hQ; ; =, <i where Z is the
set of integers, Q is the set of rational numbers, < are respectively the less-than relations on the two sets respectively. Now
consider the formula
df

density = x, z[x < z y[(x < y) (y < z)]


Clearly Q density whereas Z 6 density .
density distinguishes the two structures.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

480 OF 788

Q UIT

Evaluations under Different Structures


When evaluating terms and formulae under different structures
say A and B using valuations vA : V A and vB : V B
where A = |A| and B = |B| we use VA, TA and VB, TB respectively to distinguish the possibly different values and truth
values.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

481 OF 788

Q UIT

Isomorphic Structures
Example 21.3 Let = {0 : s, +1 : s s, = : s2, < : s2}.
Now consider the structures
N = hN; 0, +1; =, <i
2N = h2N; 0, +2; =, <i
where 2N is the set of even natural numbers, +1, +2 denote
the respective successor functions, < is the usual less-than
relation on both structures. The two structures are clearly isomorphic and there is an isomorphism which : N 2N such
that (n) = 2n which along with the inverse map 1(2n) = n
maps one structure exactly onto the other.
Isomorphic -structures cannot be distinguished by P1().
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

482 OF 788

Q UIT

The Isomorphism Lemma


Lemma 21.4 (The Isomorphism Lemma). If A and B are isomorphic -structures then for all formulae , A if and only
if B .
2

Corollary 21.5 If : A
= B then for any formula (x1, . . . , xn)
and any valuation vA, vB and values a1, . . . , an |A|,
(A, vA[x1 := a1 . . . , xn := an])
iff
(B, vB[x1 := (a1) . . . , xn := (an)])


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

483 OF 788

Q UIT

Proof of the Isomorphism Lemma 21.4


Proof:

1-1
B
Assume there is an isomorphism : A
= B. Since is an isomorphism, : A
onto
1-1

A also
is a bijection that preserves structure, where A = |A| and B = |B|. Hence 1 : B
onto
exists and preserves strucure. Further we have
1. (fA(a1, . . . , am)) = fB((a1), . . . , (am)) for every m-ary function fA,
2. 1(fB(b1, . . . , bm)) = fA( 1(b1), . . . , 1(bm)) for every m-ary function fB,
3. (a1, . . . , an) pA iff ((a1), . . . , (an)) pB for each n-ary relation pA.
4. (b1, . . . , bn) pB iff ( 1(b1), . . . , 1(bn)) pA for each n-ary relation pB.
Further for each vA : V A, vA : V B and for each vB : V B, 1 vB : V A.
For every formula , we may prove the stronger claims,
TAJKvA = TBJKvA
TBJKvB = TAJK1vB
The proof is by induction on the structure of and is left as an exercise to the interested reader.
QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

484 OF 788

Q UIT

The Isomorphism Lemma then raises the following interesting question which we will answer later.
Question. Are -structures which satisfy the same -formulae isomorphic?
But regardless of the answer to the above question the isomorphism lemma also brings the realization that for a any given set of -formulae there could be more than one model, in fact a class of
models, for a given nonempty set of -formulae. Our notions of validity may therefore include
the following besides those given in definition 20.8.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

485 OF 788

Q UIT

Substructures
Definition 21.6 A -structure A is a substructure of another structure B (denoted A B) if
=
6 |A| |B|,
for each f : sm s , fA = fB  |A|m,
for each p : sn , pA = pB |A|n.
where fB  |A|m denotes the restriction of fB to elements of
|A|m.
Facts 21.7 If A B, then
1. |A| is -closed, i.e. for each f : sm s and each
(a1, . . . , am) |A|m, fB(a1, . . . , am) |A|.
2. Conversely for each X |B|, such that X is -closed there
exists a unique -substructure X B.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

486 OF 788

Q UIT

Substructure Examples
Example 21.8
1. N = hN; 0, +; =i is a substructure of Z = hZ; 0, +; =i which in
turn is a substructure of Q = hQ; 0, +; =i which in turn is a
substructure of R = hR; 0, +; =i.
2. 2N = h2N; 0, +; =i is a substructure of N = hN; 0, +; =i.
3. However the odd numbers are not closed under addition and
hence they do not form a substructure of N under addition.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

487 OF 788

Q UIT

Quantifier-free Formulae
Definition 21.9 For any signature , the set QF 1() of
quantifier-free formulae is given by the following grammar
, ::=
|
|
|

H OME PAGE

JJ

p(t1, . . . , tn) A()


( )
( )

II

LCS

G O B ACK

|
|
|
|

>
()
( )
( )

F ULL S CREEN

C LOSE

488 OF 788

Q UIT

Lemma on Quantifier-free Formulae


Lemma 21.10 Let A B be -structures and let vA be any
valuation in A. Then for every -term t and every quantifierfree formula
VAJtKvA = VBJtKvA
TAJKvA = TBJKvA

Proof:
Use the Isomorphism lemma 21.4 on the common
subset of the two carrier sets using the identity isomorphism.
QED


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

489 OF 788

Q UIT

Universal and Existential Formulae


Definition 21.11 For any signature , the set 1() of {, } is defined inductively by the folformulae for each
lowing grammar
Q

, ::= QF 1()
| ( )
| ( )
|
x[]
Q

1() is the set of universal -formulae and 1() is the set of


existential -formulae.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

490 OF 788

Q UIT

The Substructure Lemma


Lemma 21.12 (The Substructure Lemma). Let A B be structures and let (x1, . . . , xn) 1(). Then for any valuations
vA, vB and a1, . . . , an A,
if
(B, vB[x1 := a1, , xn := an])
then (A, vA[x1 := a1, , xn := an])
Proof:
QED

H OME PAGE

JJ

By induction on the structure of universal formulae.




II

LCS

G O B ACK

F ULL S CREEN

C LOSE

491 OF 788

Q UIT

Exercise 21.1
1. Theorem 21.13 (The Homomorphism Theorem). Let $ : A B be a homomorphism from
a structure A into a structure B and let vA be a valuation.
(a) For any term t, VBJtK$vA = $(VAJtKvA )

(b) If $ is injective then for any quantifier-free formula , TBJK$vA = $(TAJKvA )


Prove theorem 21.13.

2. Prove that if $ is not surjective, the two structures may be distinguished by a formula.
3. In part 1b of theorem 21.13 why is the condition of injectivity necessary? (Hint. Let = be the
atomic binary equality predicate whose semantics is defined in an obvious fashion. Now show
that if $ is not injective then the two structures can be distinguished using equality.)
4. Prove that if $ is surjective but not necessarily injective, then in the absence of any predicate
from which equality or inequality of terms may be expressed or derived, part 1b of theorem 21.13
may be extended to quantified formulae.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

492 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

493 OF 788

Q UIT

22. Lecture 22: Predicate Logic: Proof Theory

Lecture 22: Predicate Logic: Proof


Theory
Friday 23 September 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

494 OF 788

Q UIT

1. Proof Theory: First-Order Logic


2. Proof Rules: Hilbert-Style
3. The Mortality of Socrates
4. The Mortality of the Greeks
5. Faulty Proof:2
6. A Correct Proof
7. The Sequent Forms
8. The Case of Equality
9. Semantics of Equality
10. Axioms for Equality
11. Symmetry and Transitivity
12. Symmetry of Equality
13. Transitivity of Equality

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

495 OF 788

Q UIT

Proof Theory: First-Order Logic


1. A first-order proof system for a mathematical theory with signature consists of two parts
Logical Axioms and Rules These are extensions of existing
propositional proof systems to deal with quantification.
However, they are still parameterised on since the use
of terms and substitution is involved in them.
Non-logical axioms These are the axioms which define the
models to which they are applicable.
2. (First-order) Predicate Calculus: The first-order theory with
no non-logical axioms.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

496 OF 788

Q UIT

Proof Rules: Hilbert-Style


Definition 22.1 H1(), the Hilbert-style proof system for Predicate logic consists of
The set L1() generated from A and {, , }
The three logical axiom schemas K, S and N,
The two axiom schemas
E.

x[X] {t/x}X

, t x or {t/x} admissible in X

D.

x[X Y ] (X x[Y ])
The modus ponens (MP) rule and
{y/x}X
I.
, y x or y 6 F V (X)
x[X]
H OME PAGE

JJ

II

LCS

, x 6 F V (X)

G O B ACK

F ULL S CREEN

C LOSE

497 OF 788

Q UIT

Admissibility of Substitutions
Some explanations are perhaps in order regarding the side conditions attached to the axioms above.
E. The side condition t x allows the subsituted term to be the variable x, which is not surprising. But this is explicitly mentioned only because the side condition {t/x} admissible in X
does not include the possibility of replacing x by itself.
But more important is the side condition {t/x} admissible in X. If this condition were not
present then we could have the following situation which would be clearly unsound.
df

Let p(x, y) be a binary predicate and let (x) = y[p(x, y)].


Now clearly {y/x} is not admissible in (x). If the condition of admissibility were absent then
we could have replaced the free variable x with y yielding the following instance of axiom
schema E
x[y[p(x, y)]] y[p(y, y)]

(16)

Now consider any model consisting of at least two distinct elements and let p(x, y) denote the
identity relation on the carrier set. Clearly in such a model while the antecedent x[y[p(x, y)]]
is clearly valid (true for each valuation), the consequent y[p(y, y)] would be invalid (false for
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

498 OF 788

Q UIT

certain valuations).
D. In this axiom schema if we were to relax the side-condition and allow the quantifier to be moved
in even if x F V (X) it would result in the following situation when X = (x) = Y .
x[(x) (x)] ((x) x[(x)])

(17)

Whereas the antecedent of the formula in (17) is logically valid, the truth of the consequent is
not guaranteed in any interpretation in which (x) is true only for some elements of the domain
and false for others.
I. The hypothesis of the rule asserts that a formula ( , x, ) holds when the free variable x is
replaced uniformly throughout the formula by any variable that does not occur free in . Then
clearly the formula holds for any arbitrary value that x may take, and hence the variable x may
be universally quantified.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

499 OF 788

Q UIT

The Mortality of Socrates


The Mortality of Socrates

A translation into predicate logic involves


including two unary atomic predicates h and m denoting
properties of objects (human and mortal respectively),
including a constant s (for Socrates).
x[h(x) m(x)], h(s) ` m(s)
x[h(x) m(x)]
E h(s) m(s)
h(s)
MP
m(s)
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

500 OF 788

Q UIT

The Mortality of the Greeks


All humans are mortal.
All Greeks are human.
Therefore all Greeks are mortal.
x[h(x) m(x)], x[g(x) h(x)] ` x[g(x) m(x)]
A faulty proof:
x[g(x) h(x)] x[h(x) m(x)]
T
x[g(x) m(x)]

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

501 OF 788

Q UIT

Faulty Proof:2
x[h(x) m(x)]
x[g(x) h(x)]
E h(z) m(z)
E g(y) h(y)
??
g(y) m(y)
I x[g(x) m(x)]

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

502 OF 788

Q UIT

A Correct Proof
x[g(x) h(x)]
x[h(x) m(x)]
E g(y) h(y)
E h(y) m(y)
T
g(y) m(y)
I x[g(x) m(x)]

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

503 OF 788

Q UIT

The Sequent Forms


The sequent forms of K, S, N, MP are as before. The
sequent forms of the quantification rules are as follows:
E.
D.

` x[X] {t/x}X

, t x or {t/x} admissible in X

` x[X Y ] (X x[Y ])

, x 6 F V (X)

` {y/x}X
I.
, y 6 F V (X) F V ()
` x[X]
Note that the variable y being quantified should not occur free
in any of the assumptions .
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

504 OF 788

Q UIT

The Case of Equality


1. In most algebraic formulations equality is a necessary binary
predicate of the signature.
2. In other cases where equality may not otherwise play a
prominent role, it becomes necessary because of one or
more of the following reasons.
(a) Syntactically distinct terms may represent the same value in
a structure either because of some axioms or because of
some identifications made in a valuation i.e. it is possible
that even though s 6 t, VAJsKvA = VAJtKvA . (see also
exercise 21.1).
(b) Two differently named entities are proven to be the same
entity (generally in proofs of uniqueness or in proofs by
contradiction).
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

505 OF 788

Q UIT

Generally in mathematics, if there are two named entities x and y and nothing is stated about the
relationship between them, we can neither assume they stand for distinct entities nor can we exclude
the possibility that they both stand for the same entity.
For instance, it becomes essential when speaking of models which contain at least two elements, to
make a first-order statement like xy[(x = y)] which states that there exist at least two distinct
objects.
Example 22.2 Consider any first-order theory of boolean algebra. If we allow for the possibility
that 1 = 0 every equation of boolean algebra would still be satsified and the boolean identities
would still continue to hold. But in addition we would also have 0 . 1 . 0. If we were to adopt
this as a model for truth, then every formula would be implied by every other formula and the whole
edifice of mathmatical logic as we know it would collapse to a triviality without the assumption that
the value 1 is distinct from the value 0.
On the other hand, it may so happen that one may define properties of objects and prove a theorem
stating in effect that if the two objects x and y both satisfy a certain property , then they are both
the same object. This is usually expressed as ((x) (y)) (x = y).
Example 22.3 The definition of injective functions in any standard mathematics text uses equality
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

506 OF 788

Q UIT

or inequality in its definition. A function f : A B is injective if for any two distinct elements
a, a0 such that a 6= a0, f (a) 6= f (a0). Alternatively, f is injective if f (a) = f (a0) implies a = a0.
The use of equality or inequality in all such situations is inescapable. Hence equality has a special
place in mathematics and logic and is usually required as a basic relation between named entities,
even when it is not primarily a relation of interest in the models that are being studied.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

507 OF 788

Q UIT

Semantics of Equality
The semantics of the binary infix atomic predicate = is defined
as follows:

df
1 if VAJsKvA =VAJtKvA
TAJs = tKvA =
0 otherwise
In the sequel we do not explicitly include equality in the signature, but assume that it is present as part of the language of
First-order Predicate Logic with Equality.
(First-order Predicate Calculus with Equality) The first-order
theory with no non-logical axioms except the axioms for equality.
H OME PAGE

JJ

II

LCS

G O BACK

F ULL S CREEN

C LOSE

508 OF 788

Q UIT

Axioms for Equality


Equality usually is a reflexive, symmetric, transitive and substitutive relation on structures. However the following axioms are
sufficient.

= R.
= S.

H OME PAGE

= C.

t=t

(s = t) ({s/x}u = {t/x}u)

(s = t) ({s/x}X {t/x}X)

JJ

II

LCS

G O B ACK

, {s/x}, {t/x} admissible in X

F ULL S CREEN

C LOSE

509 OF 788

Q UIT

Explanations.
=R This is the reflexivity axiom schema, which asserts that any term equals itself.
=C This is the congruence axiom schema and it asserts that equals may be substituted for equals in
any term context.
=S This is the substitutivity axiom schema which again asserts that the replacement of equals by
equals does not alter the truth value of formulae. However due to the presence of quantifiers and
bound variables one must ensure that the substitution of equals by equals does not result in the
capture of free variables of either s or t.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

510 OF 788

Q UIT

Symmetry and Transitivity


The rule of substitutivity (=S) is sufficiently powerful to force the
properties of symmetry and transitivity with the help of reflexivity and modus ponens.
` s=t
` t=u
` s=t
= Sym.
= T.
` t=s
` s=u

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

511 OF 788

Q UIT

Symmetry of Equality
Proof of derived rule =Sym
df

Let = {s = t} and Let = x = s. Then we have


{s/x} s = s
{t/x} t = s
` s = t =S ` s = t (s = s t = s)
MP
=R ` s = s

`
s
=
s

t
=
s
MP
` t=s

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

512 OF 788

Q UIT

Transitivity of Equality
Proof of derived rule =T
Let = {s = t, t = u} and s = x. Then
=S ` t = u (s = t s = u) ` t = u
MP
u
` s=t
MP ` s = t s =
` s=u

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

513 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

514 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

515 OF 788

Q UIT

23. Lecture 23: Predicate Logic: Proof Theory (Contd.)

Lecture 23: Predicate Logic: Proof


Theory (Contd.)
Tuesday 27 September 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

516 OF 788

Q UIT

1. Alpha Conversion
2. The Deduction Theorem for Predicate Calculus
3. Useful Corollaries
4. Soundness of Predicate Calculus
5. Soundness of The Hilbert System

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

517 OF 788

Q UIT

Alpha Conversion
Notation We use a` as an abbreviation for the two statements ` and ` .
Lemma 23.1 For every formula for which {y/x} is admissible
x[] a` y[{y/x}]
Proof: If {y/x} is admissible in then we may readily see that
{x/y} is also admissible in {y/x} since x 6 F V ({y/x}) and
{x/y}{y/x}
Further since x 6 F V (x[]) we have by axiom schema E
x[] i.e.
x[] {x/y}{y/x}
We then have the following proofs.
H OME PAGE

JJ

II

LCS

G O B ACK

QED
F ULL S CREEN


C LOSE

518 OF 788

Q UIT

Proof trees of x[] a` y[{y/x}]


MP

x[] ` x[]

x[] ` x[] {x/y}{y/x}


x[] ` {x/y}{y/x}
I
x[] ` y[{y/x}]

E
y[{y/x}] ` y[{y/x}]
y[{y/x}] ` y[{y/x}] {y/x}
MP
y[{y/x}] ` {y/x}
I
y[{y/x}] ` x[]

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

519 OF 788

Q UIT

The Deduction Theorem for Predicate


Calculus
Theorem 23.2 (The Deduction Theorem for Predicate Calculus).
Let f L1 and , L1.
1. (DT). If ` then , ` .
2. (DT). Let , ` .Then ` if no variable in F V ()
is generalized (by an application of I) in the proof.
2
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

520 OF 788

Q UIT

Proof of the Deduction Theorem for Predicate Calculus (theorem 23.2)


Proof:
1. (DT). The proof is identical to that of the corresponding propositional case.
2. (DT). Assume , ` . Then there exists a proof tree T rooted at with nodes 1, . . . , m
. Then the stronger claim that each step of the proof of i can be matched by a proof of i
is again proven here by induction on k = `(1) `(i). The proof proceeds in a manner similar
to the corresponding propositional case for all applications of the propositional axioms and the
inference rule (MP). We consider only the cases of quantification.
If j for 0 < j m is an axiom (including an instance of E or D) or j , then the proof
tree Tj0 rooted at j is constructed from the proof tree Tj rooted at j as follows.
- Tj %
j0
j
j0 + 2

j0 + 1

j ( j )
j

Suppose j was obtained by the application of the axiom schema I on some i such that `(i) >
`(j ). Then j x[i]. By the induction hypothesis there exists a proof tree Ti 0 rooted at

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

521 OF 788

Q UIT

i and such that no free free variable of has been generalized in the application. Further
x 6 F V (). We may now extend Ti 0 to a proof tree Tj0 as follows.
- Ti 0 %
i
i
0
i +1
x[ i]
i0 + 3
0

i0 + 2

x[ i] ( x[i])
x[i] j


QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

522 OF 788

Q UIT

Useful Corollaries
Corollary 23.3 If the proof of , ` involves no generalization
of any free variable of then ` .
Corollary 23.4 If is a closed formula and , ` then `
.
Corollary 23.5 If no free variable of = {1, . . . , m} is generalized in a proof of ` , then ` 1 m .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

523 OF 788

Q UIT

Soundness of Predicate Calculus


Proposition 23.6 Every wff of L1 which is an instance of a tautology of Propositional logic is a theorem of PC and may be
obtained using only the axiom schemas K, S, N and the rule
MP.

Theorem 23.7 (Consistency of Th(PC)). The theory PC is consistent i.e. the set Th(PC) of theorems of PC form a consistent
set.
2
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

524 OF 788

Q UIT

Proof of theorem 23.7


Proof: Define the erasure of a formula e() as the propositional formula obtained by deleting all
terms and all quantifiers and retaining only the atomic predicate symbols and propositional connectives. The function e may be defined by induction on the structure of the formula .
Claim 0. For each instance of the axioms of H1, the erasure of the formulae yields tautologies
(of propositional logic)
Claim 1. The erasure of each application of the rules of H1, preserves tautologous-ness, i.e. if
the erasure of the premises of a rule are all propositional tautologies then so is the erasure of the
conclusion.
Claim 2. The erasure of every formula in Th(PC) is a tautology.
If Th(PC) were inconsistent then Th(PC) = L1. In particular, there exist formulae ,
Th(PC). But then by the definition of erasure we have e() e() which contradicts Claim 2.
QED


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

525 OF 788

Q UIT

Soundness of The Hilbert System


Theorem 23.8 (Soundness of H1). Every theorem of H1 is logically valid.
2

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

526 OF 788

Q UIT

Proof of theorem 23.8


Proof: Here are some easily proven claims which hold for any interpretation of -formulae and
hence also hold for the predicate calculus.
Claim 1 Every instance of a (propositional) tautology is true for every interpretation.
Claim 2 All instances of the axioms E and D are logically valid.
Claim 3 The rules MP and I preserve logical validity i.e. if the premises of the rules are logically
valid formulae under every -interpretation then so are the conclusions.
It then follows by induction on the structure of the proof tree that every theorem is logically valid.
QED

Exercise 23.1
1. Prove the arguments in Problem 2 of exercise 17.1 using the system H1.
2. Prove the conclusions of Problem 2 in exercise 25.1 using only the proof rules of H1.
3. Let SF (). If 0 is obtained from by replacing zero or more occurrences of by 0. Then
prove the following.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

527 OF 788

Q UIT

(a) ~[ 0] ` 0
(b) 0 ` 0
(c) We also have the derived rule of inference .

` 0
`

which is the only rule that


` 0
allows the use of a rule that applies to proper sub-formulae of a formula.

4. If and are formulae such that x 6 F V (), then the following are theorems of H1 (x[] is
an abbreviation of x[]).
(a) ` x[] and hence ` x[]
(b) ` x[] and hence by rule I ` x[]
(c) ` x[ ] ( x[])
(d) ` x[ ] (x[] )

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

528 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

529 OF 788

Q UIT

24. Lecture 24: Existential Quantification

Lecture 24: Existential Quantification


Wednesday 28 September 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

530 OF 788

Q UIT

1. Existential Generalisation
2. Existential Elimination
3. Remarks on Existential Elimination
4. Restrictions on Existential Elimination
5. Equivalence of Proofs

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

531 OF 788

Q UIT

Existential Generalisation
Existential quantification is the derived operator defined by
df

x[] = x[]
We then have the rules
` {t/x}
I.
, {t/x} admissible in
` x[]
` x[]
E.
, a 6 F V () F V (x[]) is fresh
` {a/x}
I is a derived rule
However E is not a derived rule in the Hilbert-System.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

532 OF 788

Q UIT

Proof of Derived rule I


Assuming {t/x} is admissible in we have

E
` x[] {t/x}
MP

DNI
` {t/x} {t/x}
T

` (x[] {t/x}) ({t/x} x[


` {t/x} x[]

` {t/x} x[]

Assuming ` {t/x}, the last step gives

MP

H OME PAGE

JJ

` {t/x} x[]
` {t/x}
` x[] x[]

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

533 OF 788

Q UIT

Existential Elimination
Existential generalisation from a constant introduced somehow
into the proof is very common in mathematics.
Example 24.1 Consider a purported proof of
x[ ], x[] ` x[]
where x may be a free variable of both and . The standard
practice is to assume the existence of some constant symbol
a and proceed with it to eventually generalize.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

534 OF 788

Q UIT

Let = {x[ ], x[]}.


A `E x[] proof is as follows.
A proof using E
` x[ ]
E
` {a/x}( ) {a/x} {a/x}
MP
` {a/x}
I
` x[]

` x[]
` {a/x}

Unless the same constant symbol is used both in the application of E and E the proof will
not go through. Here is a proof not involving the use of the constant (which is reminiscent of a
proof by contradiction) which assumes there is no value for x which will make true. Let =
{x[], x[]}

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

535 OF 788

Q UIT

` x[]
` x[]
E `
E `
(( ) )
I
` ( )
I
` x[( )]
DT
x[] ` x[] x[( )]
Note that the application of DT is correct since no free variable of has been generalised in the
proof so far. We may now proceed as follows. First from rule N we get

x[] ` (x[] x[( )]) (x[( )] x[])

An application of MP then yields


DT

H OME PAGE

JJ

x[] ` x[( )] x[]


x[], x[( )] x[ ] ` x[] x[]

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

536 OF 788

Q UIT

Remarks on Existential Elimination


1. E is not a derived rule.
2. Proofs which utilize E are denoted `E.
3. There are some restrictions on the use of rules in `E proofs.
4. Proofs involving existential formulae which utilize E are
likely to be more direct and intuitively simpler than proofs
which avoid all uses of E even for existential formulae.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

537 OF 788

Q UIT

Restrictions on Existential Elimination


Definition 24.2 A proof `E is correct provided
1. Each application of E should use a fresh constant symbol
not used previously in the proof.
2. If constant symbol a (earlier introduced by an application
of E to a formula y[]) appears in a formula {a/x} in a
proof, then z[{a/x}] cannot be deduced for any variable
z F V (y[]) F V ({a/x}) (by applying I to {a/x}).
3. A formula {a/x}, where a is a constant symbol and x
F V () can only be generalised to x[].

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

538 OF 788

Q UIT

Equivalence of Proofs
Theorem 24.3 (Existential-Elimination Elimination Theorem).
If `E is a correct proof then ` provided no constants
introduced in the proof `E occur in . i.e. if is provable
from by use of the E rule then is provable from without
making use of the E rule.
2
However this theorem is not applicable if does contain any of
the constants introduced by the proof `E .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

539 OF 788

Q UIT

Proof of theorem 24.3


Proof: Let T rooted at `E be a correct proof which involves one or more applications of rule
-T %
E. Assume there are k applications of rule E in
.
`E
Claim 1. For each i, 1 i k there exist proof trees
- Ti 0 %
, {a1/y1}1, , {ai1/yi1}i1 ` yi[i]
which are completely free from any application of rule E and
-Ti%
, {a1/y1}1, , {ai/yi}i `E
which have (k i) applications of rule E.
Proof of claim 1. Starting from the highest level of T there exists a subtree
- T1 %
` y1[1]
E
`E {a1/y1}1
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

540 OF 788

Q UIT

- T1 %
does not involve any application of rule E. For i = 1, this is also
` y1[1]
- T10 %
the required tree
.
` y1[1]
such that the proof

By adding the formula {a1/y1}1 to the set of assumptions and removing the subtree

- T1 %
` y1[1]

-T1%
from T we get a proof tree
in which there are only k 1 applications of rule
, {a1/y1}1 `E
E and , {a1/y1}1 `E {a1/y1}1 is a leaf node of T 1.
Starting with T 1 we again remove the next application of rule E viz.
- T2 %
, {a1/y1}1 ` y2[2]
E
, {a1/y1}1 `E {a2/y2}2
to obtain

H OME PAGE

JJ

-T2%
, {a1/y1}1, {a2/y2}2 `E
J

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

541 OF 788

Q UIT

It is again clear that

- T2 %
, {a1/y1}1 ` y2[2]
does not involve any application of rule E and is the required tree
- T20 %
, {a1/y1}1 ` y2[2]
Proceeding in this fashion we get proof trees
-Ti%
, {a1/y1}1, {ai/yi}i `E
in which there are exactly k i applications of rule E and for i = k we get
-Tk%
, {a1/y1}1, {ak /yk }k `
which is completely free from all applications of rule E.
Further it is also clear that for each i, 1 i k there exist proof trees
- Ti 0 %
, {a1/y1}1, {ai1/yi1}i1 ` yi[i]
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

542 OF 788

Q UIT

which are also completely free from any application of rule E.


End of proof of claim 1
S

By part 2 of definition 24.2 no variable z 1ik F V (yi[i]) is generalized anywhere in the


proof of `E . Hence the conditions for the application of DT hold.
By DT we get
, {a1/y1}1, . . . , {ak1/yk1}k1 ` {ak /yk }k

(18)

Since the original proof is correct by definition 24.2, there is no occurrence of any of the constants
ai, 1 i k, in . Further the proof (18) does not utilise the constant ak as anything more than
a symbol. It also does not generalise on ak anywhere within the proof. Clearly then replacing this
constant ak by a fresh variable symbol zk (which occurs nowhere in any of the proofs including
proof (18)) does not affect the correctness of the proof.
Take a fresh variable zk which does not occur anywhere in the proof (18) and replace all occurrences
of ak by zk to obtain proof (19).
, {a1/y1}1, . . . , {ak1/yk1}k1 ` {zk /yk }k
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

(19)
543 OF 788

Q UIT

Proof (19) may now be extended as follows.


I

, {a1/y1}1, . . . , {ak1/yk1}k1 ` {zk /yk }k


, {a1/y1}1, . . . , {ak1/yk1}k1 ` zk [{zk /yk }k ]

which is again a correct proof.


Applying exercise 23.1.4d to the last step gives us
, {a1/y1}1, . . . , {ak1/yk1}k1 ` yk [k ]
By claim 1 we know there exists a proof of
, {a1/y1}1, . . . , {ak1/yk1}k1 ` yk [k ]
which is completely free of any application of rule E. By applying rule MP we therefore get
, {a1/y1}1, . . . , {ak1/yk1}k1 `
By a similar process we may eliminate each of the constants ak1 down to a1 to eventually obtain a
proof ` .


QED
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

544 OF 788

Q UIT

Exercise 24.1
1. Use the method outlined in the proof of theorem 24.3 to transform the proof `E x[] of
example 24.1 to one without the use of rule E.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

545 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

546 OF 788

Q UIT

25. Lecture 25: Normal Forms

Lecture 25: Normal Forms


Friday 30 September 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

547 OF 788

Q UIT

1. Natural Deduction: 6
2. Moving Quantifiers
3. Quantifier Movement
4. More on Quantifier Movement
5. Prenex Normal Forms
6. The Prenex Normal Form Theorem
7. Prenex Conjunctive Normal Form
8. The Herbrand Algebra
9. Terms in a Herbrand Algebra
10. Herbrand Interpretations
11. Herbrand Models
12. Ground Quantifier-free Formulae

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

548 OF 788

Q UIT

Natural Deduction: 6
The introduction and elimination rules for the propositional operators along with the rules I, E, I and E comprise the system G1.
Introduction
Elimination
` {t/x}X
` x[X]
I.
E.
` x[X]
` {t/x}X
{t/x} admissible in X
` {t/x}X
` x[]
I.
E.
` x[X]
` {a/x}
a 6 F V () F V (x[]) is fresh

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

549 OF 788

Q UIT

Exercise 25.1
1. Prove the arguments in Problem 2 of exercise 17.1 using Natural Deduction.
2. There have been frequent complaints that Logic (of any order) is cold-blooded of the first order.
Lets dispel this notion. Consider the following premises.
All the world loves a lover. Romeo loves Juliet.
Now prove the following conclusions using Natural Deduction.
(a) Therefore I love you.
(b) Therefore Love loves Love.11
(c) Therefore if I love you, then you love me.
(d) Therefore you love yourself.
(e) Therefore everyone loves everyone.
11 This

H OME PAGE

is of course a dirty trick!

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

550 OF 788

Q UIT

3. Refer to the premises in Problem 2 above. Which of the conclusions becomes invalid if the
premise Romeo loves Juliet is removed? Further, does it follow that love is an equivalence
relation?

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

551 OF 788

Q UIT

Moving Quantifiers
Notation.

1. x denotes a sequence of quantifiers


Q

i {, }, for 1 i m.

where m 0 and each

m xm

1 x1 2 x2 . . .

2. For any quantifier


{, },
denotes its dual That is, if
= , then = and if = then = .
Q

JJ

II

H OME PAGE

LCS

G O B ACK

F ULL S CREEN

C LOSE

552 OF 788

Q UIT

Quantifier Movement
Lemma 25.1 Let z 6 F V () F V () {x1, . . . , xn}. Then the
following logical equivalences hold for 0 {, }.
0
0
1. x y[]
x y[]
0
0
2. x[ y[] ] x z[{z/y} ]
0

0
3. x[ y[]] x z[ {z/y}]
Q

Q Q
Q Q
Q Q

Q
Q
Q Q
Q Q

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

553 OF 788

Q UIT

More on Quantifier Movement


We may use the above lemma to obtain prenexing rules for the
propositional connectives and as well, as shown in the
following corollary. However, note the change of quantifier that
marks the transformation of in the last equivalence.
Q
Q
Q
Q

0z[{z/y} ]

Q
Q
Q
Q

Corollary 25.2
0
4. x[ y[] ]

5. x[ 0y[]]

6. x[ 0y[]]
0
7. x[ y[] ]

0z[ {z/y}}]
0z[ {z/y}}]
0z[{z/y} ]

Q Q
Q
Q
Q
Q
Q Q


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

554 OF 788

Q UIT

Exercise 25.2
1. Prove lemma 25.1.
2. Prove corollary 25.2.
Having obtained the above results we are now ready to prove the Prenex normal form theorem. But first lets define the
form precisely.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

555 OF 788

Q UIT

Prenex Normal Forms


Definition 25.3 The set PN F 1() of prenex normal forms is
generated by the grammar
, ::= QF 1() | x[] | x[]
A formula is in prenex normal form if all the quantifiers occur
ring in the formula appear as a prefix x (called the prenex)
of a body that is quantifier-free and consists only of atomic
predicates with propositional connectives.
Q

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

556 OF 788

Q UIT

The Prenex Normal Form Theorem


Theorem 25.4 (Prenex Normal Forms). For any formula there
exists a logically equivalent formula in prenex normal form
(PNF).
2

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

557 OF 788

Q UIT

Proof of theorem 25.4


Proof: Given a formula we go through the following steps.
1. Replace all subformulas of the form by subformulas
( ) ( )
respectively to yield a new formula 0 which is free of all occurrences of the connective .
2. Use -conversion to obtain unique names for all bound and free variables12.
3. Now proceed by induction on the structure of 0 by systematically applying the results obtained
from lemma 25.1 and corollary 25.2. This would yield a formula in prenex normal form.


QED
12 That

H OME PAGE

is, ensure that no two quantifiers use the same bound variable and no variable occurs both free and bound in the formula.

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

558 OF 788

Q UIT

Prenex Conjunctive Normal Form


Given a formula in prenex normal form, its body consists entirely of propositional connectives atomic predicates. By theorem 5.10 every propositional form may be converted into CNF.
We may apply the same method to the body of a formula in
PNF to obtain a Prenex Conjunctive Normal Form (PCNF). So
we have
Corollary 25.5 (PCNF). For any formula there exists a logically equivalent formula in prenex conjunctive normal form
(PCNF).

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

559 OF 788

Q UIT

The Herbrand Algebra


Definition 25.6 Let be a signature containing at least one
constant symbol a. A term t T() is said to be ground if
V ar(t) = . T0() T() is the set of ground terms (also called
the Herbrand Universe). A literal p(t1, . . . , tn) or p(t1, . . . , tn)
containing no variables is called a ground literal.
Definition 25.7 A -algebra H() where has at least one
constant symbol, is called a Herbrand algebra iff |H()| =
T0().

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

560 OF 788

Q UIT

Terms in a Herbrand Algebra


In a Herbrand algebra H()
every function symbol represents itself. That is for each f :
sm s , f H() = f
a valuation is simply a function vH() : V T0()
However the predicate symbols require to be associated with
relations on ground terms in some way.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

561 OF 788

Q UIT

Herbrand Interpretations
Lemma 25.8 Given a Herbrand interpretation (H, vH) where for
each variable x, v(x) = sx T0(). For any term t with V ar(t) =
{x1, . . . , xk }
VHJtKvH = {sx1 /x1, . . . , sxk /xk }t

That is every valuation defines a substitution of variables by


ground terms.
Here valuations represent merely substitutions on terms.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

562 OF 788

Q UIT

Herbrand Models
Definition 25.9 A Herbrand model of a set of -formulae is
merely a valuation vH such that every formula in is true under
the substitution defined by vH  F V ().

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

563 OF 788

Q UIT

Ground Quantifier-free Formulae


Theorem 25.10 Let be a signature containing at least one
constant and let = {1, . . . , k } be a nonempty set of ground
literals. Then
^
1.
i has a model iff does not contain a complementary
1ik

2.

pair.
^

i is never logically valid

1ik

3.

i always has a model

1ik

4.

i is logically valid iff it has a complementary pair.

1ik
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

564 OF 788

Q UIT

Proof of theorem 25.10


Proof:
1. Clearly if contains a complementary pair it does not have a model. Conversely assume it does
not contain a complementary pair. We may define a Herbrand algebra H as follows: For each
atomic predicate symbol p : sn define pH = {(t1, . . . , tn) T0() | p(t1, . . . , tn) }
Clearly H i for each i since if i p(t1, . . . , tn) and then p(t1, . . . , tn) and
(t1, . . . , tn) pH . On the other hand if i p(t1, . . . , tn) then p(t1, . . . , tn) 6 and hence
(t1, . . . , tn) 6 pH otherwise it would contradict
^the assumption that contains no complementary pair. Hence H i for each i. Hence
i has a model.
1ik

2.

i cannot be valid since from the previous part we know that i has a model, where i is

1ik

the complement of i.
_
3.
i has a model because i has a model.
1ik

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

565 OF 788

Q UIT

4.

i is valid iff

1ik

i has no model iff = {i | 1 i k} contains a complementary

1ik

pair iff contains a complementary pair.


QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

566 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

567 OF 788

Q UIT

26. Lecture 26: Skolemization

Lecture 26: Skolemization


Tuesday 04 Oct 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

568 OF 788

Q UIT

1. Skolemization
2. Skolem Normal Forms
3. SCNF
4. Ground Instance
5. Herbrands Theorem
6. The Herbrand Tree of Interpretations
7. Compactness of Sets of Ground Formulae
8. Compactness of Closed Formulae
9. The Lowenheim-Skolem Theorem

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

569 OF 788

Q UIT

Skolemization
Theorem 26.1 (Skolem Normal Form Theorem.) Let

xy[] where x = x1, . . . , xn and y are all distinct variables


and does not contain any occurrence of any of the quantifiers xi. Let g = {g : sn s} be an expansion of the
signature . Then

0
1. every model of x[{g(x1, . . . , xn)/y}] is a model of .
Q

2. every model of can be expanded to a model of 0.


Corollary 26.2 Let and 0 be as in theorem 26.1. Then

1. there exists a model of iff there exists a model of 0.


2. is unsatisfiable iff 0 is unsatisfiable.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

570 OF 788

Q UIT

Proof of theorem 26.1


Proof: We first of all note that {g(x1, . . . , xn)/y} is admissible in .
1. We have
|= 0
and hence for every g -model B 0, B holds too.
2. Conversely for every -structure A, such that A , for each (a1, . . . , an) An there exists at
least one element a |A| such that
T JKv[x1:=a1,...,xn:=an][y:=a] = 1

Define a function g which for each n-tuple (a1, . . . , an) |An| provides a single element a |A|
such that
T JKv[x1:=a1,...,xn:=an][y:=a] = 1
Then clearly for every (a1, . . . , an) |An| we have

T JKv[x1:=a1,...,xn:=an][y:=gA(a1,...,an)] = 1

Now let A  B where B is a g -algebra with g B = g. It is then clear that for every valuation vB,
T J{g(x1, . . . , xn)/y}KvB = 1

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

571 OF 788

Q UIT

and hence B 0.


QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

572 OF 788

Q UIT

Skolem Normal Forms


Definition 26.3
1. The set SN F 1() of Skolem normal forms is the set of universal closures of quantifier-free formulae. The quantifier-free
formula is called the body of the SNF.
2. A formula is in Skolem conjunctive normal form (SCNF) if it
is a SNF whose body is in CNF. SCN F 1() is the set of formulae in SCNF.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

573 OF 788

Q UIT

SCNF
Theorem 26.4 For every sentence (closed formula) P1()
there is an algorithm sko to construct a closed universal formula
SCN F 1() such that has a model iff has a model.
2

Definition 26.5
1. The function g in theorem 26.1 is called a Skolem function

2. The process of constructing the function g in theorem 26.1 is


called Skolemization.
3. and sko() are said to be equi-satisfiable.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

574 OF 788

Q UIT

Proof of theorem 26.4


Proof: The procedure may be briefly outlined as follows.
1. Clearly if is a closed formula, by theorem 25.5 we can construct a logically equivalent formula
0 PCN F 1().
2. If there is no existential quantifier 0 then the formula 0 is in SCNF. Otherwise Skolemize the
left-most occurrence of an existential quantifer to obtain a formula 1.
3. 1 has one existential quantifier less than 0. Perform step 2 on 1.
Each execution of step 2 of the above procedure results in a formula which satisfies the conclusions
of theorem 26.1.

QED
Exercise 26.1
1. Prove that |= 0 in theorem 26.1.
2. Prove that ` 0 in theorem 26.1.
3. Skolemization does not produce a SNF that is unique upto logical equivalence. Construct an

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

575 OF 788

Q UIT

example of a formula which has two (or even more) different SNFS, 0, 00 such that
6 0 6 00 6

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

576 OF 788

Q UIT

Ground Instance
Definition 26.6 Let be a signature containing at least
one constant and let be a nonempty set of closed
universal -formulae.
For any ~[] where
QF 1(), the ground-instances of denoted g() is the set
{{t1/x1, ,[
tn/xn} | F V () = {x1, . . . , xn}, t1, . . . , tn T0()}
and g() =
g().

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

577 OF 788

Q UIT

Herbrands Theorem
Theorem 26.7 (Herbrands Theorem). Let and be as in
definition 26.6. Then the following statements are equivalent.
1. has a model.
2. has a Herbrand model.
3. g() has a model.
4. g() has a Herbrand model.
2
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

578 OF 788

Q UIT

Proof of theorem 26.7


Proof: Clearly the following implications are trivial.
Statement 2: has a Herbrand model Statement 1: has a model

Statement 4: g() has a Herbrand model Statement 3: g() has a model


It suffices therefore to prove only the following claim.
Claim. Statement 3 Statement 2.
Proof of claim. Let A g(). We define a Herbrand interpretation H as follows. For each p : sn
let
pH = {(t1, . . . , tn) T0() | A p(t1, . . . , tn)}
In particular if p is an atomic proposition then pH = pA. With this construction exactly the same
atomic formulae are valid in both A and H. This result may be extended by structural induction
to arbitrary universally closed quantifier-free formulae. It is then easy to see that if A g() then
H .
QED


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

579 OF 788

Q UIT

The Herbrand Tree of Interpretations


Let be a signature containing at least one constant symbol.
Let P0, P1, P2, . . . be an enumeration of all the ground atomic formulae of P1(). The Herbrand Tree of interpretations is the infinite tree shown schematically below. Each infinite path (called
a Herbrand Base) of the tree represents a Herbrand interpretation.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

580 OF 788

Q UIT

P0

P0
P1

P1

P2

P2

P2

P1

P1

P2

P2

P2

P2

P2

Figure 8: The Herbrand tree of interpretations

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

581 OF 788

Q UIT

Compactness of Sets of Ground


Formulae
Lemma 26.8 (Compactness of a set of closed quantifier-free formulae). Let be a (finite or infinite) set of ground quantifier-free
formulae. Then has a model iff every finite subset of has a
model.
2

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

582 OF 788

Q UIT

Proof of lemma 26.8


Proof: () Clearly if has a model then every finite subset of also has a model.
() Assume every finite subset of has a model but itself does not have a model. By theorem
26.7 each finite subset of has a Herbrand model. We identify each path in the Herbrand tree
with a valuation v . Then since does not have a model, it does not have a Herbrand model. Hence
for every path there exists a formula such that (H, v ) 6 . In fact there exists a finite
point ` in each path at which (H, v ) 6 since is made up of only a finite number of ground
atoms.
Claim. { | (H, v ) 6 } is a finite set.
Proof of claim.
Consider the tree TH obtained from the Herbrand tree such that from each path the subtree rooted
at ` + 1 has been removed. Hence TH is a finitely branching tree with only finite-length paths.
Hence by (the contra-positive of) Konigs lemma (lemma 2.17: any finitely-branching tree with only
finite-length paths must be finite) TH must be a finite tree where each path 0 is an initial segment of
an infinite path from the Herbrand tree of interpretations. The leaf-nodes of each of these paths 0
determines a formula that is not satisfied. Clearly then the set consisting of these formulae viz.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

583 OF 788

Q UIT

{ | (H, v ) 6 } is then a finite set.


End of proof of claim.
It is clear that the finite set { | (H, v ) 6 } is a finite subset of that does not possess a
Herbrand model, contradicting the assumption that all finite subsets of possess a Herbrand model.
QED


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

584 OF 788

Q UIT

Compactness of Closed Formulae


Theorem 26.9 (Compactness of closed formulae) A set of
closed -formulae has a model iff every finite subset of has
a model.
2

Corollary 26.10 (Finite Unsatisfiability). A set of closed formulae is unsatisfiable iff there is a non-empty finite unsatisfiable subset of .


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

585 OF 788

Q UIT

Proof of theorem 26.9


Proof: () is trivial.
() Assume does not possess a model but every finite subset of has a model. Transform each
formula into SNF. Since has no model sko() = {sko() | } has no model either (by
theorem 26.4). By Herbrands theorem (theorem 26.7) the set g(sko()) also does not possess a
model. By lemma 26.8 we can find a finite subset of g(sko()) which does not have a Herbrand
model. This finite set is a subset of a finite subset of that does not possess a model. Hence there is
a finite subset of which does not have model, contradicting the assumption that every finite subset
of has a model.
QED


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

586 OF 788

Q UIT


The Lowenheim-Skolem
Theorem
Theorem 26.11 (The Lowenheim-Skolem Theorem). If a set
of closed formulae has a model, then it has a model with a
domain which is at most countable.
Proof:
Assume has a model. Then sko() has a model
too. By theorem 26.7 sko() has a Herbrand model. Since a
Herbrand model has a domain which is at most countable and
since every model of sko() is also a model of , it follows that
has a model with at most a countable domain. QED


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

587 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

588 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

589 OF 788

Q UIT

27. Lecture 27: Substitutions and Instantiations

Lecture 27: Substitutions and


Instantiations
Tuesday 11 October 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

590 OF 788

Q UIT

1. Substitutions Revisited
2. Some Simple Facts
3. Ground Substitutions
4. Composition of Substitutions
5. Substitutions: A Monoid

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

591 OF 788

Q UIT

Substitutions Revisited
We have defined substitutions and instantiations earlier. In light

of the Lowenheim-Skolem
theorem 26.11, we
1. require more powerful operations on syntactic substitutions
to exploit the construction of Herbrand models,
2. need to extend the theory of substitutions to include a composition operator for substitutions.
3. need to give a programing interpretation to First-order logic.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

592 OF 788

Q UIT

Some Simple Facts


Definition 27.1
1. 1 is the empty or identity substitution which replaces no variable when applied to any term and dom(1) = = ran(1).
2. S(V ) is the class of all substitutions over a set of variables
V for a given signature .
Fact 27.2 Let be a substitution and t a term. Then
1. depth(t) depth(t)
2. size(t) size(t).

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

593 OF 788

Q UIT

Ground Substitutions
Definition 27.3
= {ti/xi | ti 6 xi, 1 i n} is a ground substitution if each
ti, 1 i n, is a ground term.
A term u is called an instance of a term t if there exists a
substitution such that u t.
u is a ground instance of t if u is an instance of t and is ground.
u is a common instance of two or more terms t1, . . . , tn if there
exist substitutions 1, . . . , n such that
u 1t1 ntn
Terms t and u are called variants of each other if there exist
substitutions and such that t u and u = t.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

594 OF 788

Q UIT

Composing Substitutions
We will often require to perform substitutions in sequence i.e. it may be necessary to first apply a substitution on a
term t yielding a term t to which another substitution may be applied to yield a term (t). We would like to answer
the question of how to define a single substitution such that for every term u,
(u) u

(20)

Then is the composition of with . Before presenting the formal definition of composition we try to understand
how such a composition must be defined to ensure that equation (20) holds. Let = {s1 /x1 , , sk /xk } and =
{t1 /y1 , , tm /ym }. We have dom() = X = {x1 , , xk } and dom( ) = Y = {y1 , , ym }. The effect of on
any term u is to replace each free occurrence of each variable xi by the term si simultaneously for 1 i k. The
terms si could contain (free) variables drawn from X and Y . It could also happen that some of the terms si may simply
be variables themselves. Consider a single variable xi . If si z for some variable z, then u would simply have z
occurring free in all those positions of u where xi occurs free. Of course, free occurrences of xi could be present in u
because of some other variable substitution (say si0 /xi0 for some i0 6= i). Hence it is clear that all free occurrences of any
x X in t are due to the application of the substitution . Further, for any yj Y , we have the following possibilities.
1. Case yj Y X and yj F V (u). All such free occurrences of yj in u will be present in the same positions in u
as well. The effect of would be to replace them all with tj .
2. Case yj Y X and yj 6 F V (u). New free occurrences may arise due to the substitution . The effect of the
application of will replace all of them by tj .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

595 OF 788

Q UIT

3. Case yj xi for some xi X. In this case the only free occurrences of yj possible are those which occur after
applying .
To summarise
1. Case 1 requires to be applied separately.
2. The effect of on cases 2 and 3 may be captured by applying to the range of . Once that is done one may even
remove the element tj /yj from the substitution, since it would have no effect.
3. Further all elements such that si xi are removed from , since we are interested in specifying the substitution as
a finite set of non-identical replacements.
With this understanding we are ready to tackle our definition of composition.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

596 OF 788

Q UIT

Composition of Substitutions
Definition 27.4 Given substitutions = {s1/x1, , sk /xk } and
= {t1/y1, , tm/ym}, their composition is a new substitution such that
= { si/xi | 1 i k, si 6 xi}{tj /yj | 1 j m, yj 6 dom()}

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

597 OF 788

Q UIT

Substitutions: A Monoid
Lemma 27.5 Given substitutions , , and a term t, we have
1. 1 = 1 =
2. ( )t (t)
3. ( ) = ( )
2

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

598 OF 788

Q UIT

Proof of lemma 27.5


Proof: We assume = {s1/x1, , sk /xk } and = {t1/y1, , tm/ym} and = as in
definition 27.4. Then
1. Trivial.
2. We prove this by induction on the structure of terms. The case of constants is trivial. The
induction case will also follow once the cases of simple variables has been proven. So we
simply prove this case for simple variables. For any variable x we have the following cases.
Case x 6 dom(). Then clearly (x) x and (x) x. Since the first component of the
union in the definition of does not apply, we have x x.
Case x xi dom() for some i, 1 i m. In this case xi si and since xi si we have
(xi) si.
3. For any term t we have from the previous proof
( ( ))t (( )t) ( (t)) ( )(t) (( ) )t


QED
Exercise 27.1
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

599 OF 788

Q UIT

1. Let u t. Give examples of t, u and such that F V (t) 6= , u is ground but is not a ground
substitution.
2. Prove that for any substitutions and , = iff dom() dom( ) = and dom( )
S
tran() F V (t) =
3. A substitution is called idempotent if = . Now complete the statement of the following
lemma and prove it.
Lemma 27.6 A substitution = {ti/xi | 1 i m} for some m 0 is idempotent iff
dom() .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

600 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

601 OF 788

Q UIT

28. Lecture 28: Unification

Lecture 28: Unification


Wednesday 12 October 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

602 OF 788

Q UIT

1. Unifiability
2. Unification Examples:1
3. Unification Examples:2
4. Generality of Unifiers
5. Generality: Facts
6. Most General Unifiers
7. More on Positions
8. Disagreement Set
9. Example: Disagreement 1
10. Example: Occurs Check
11. Example: Disagreement 3
12. Example: Disagreement 4
13. Disagreement and Unifiability
14. The Unification Theorem

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

603 OF 788

Q UIT

Syntactic unification is the problem of finding substitutions so as to make two or more terms
syntactically identical. It may be thought of as a special form of equation solving where one attempts
to find solutions to the problem s t by finding suitable instances of the variables in the two terms
in order to make the two terms look identical. The solution of such an equation on essentially
uninterpreted terms is a substitution and the process of finding this solution is called unification. As
in normal equation solving the substitution is to be applied to all the terms that have to be unified.
Moreover as in equation solving, it is possible that no solution exists. A set consisting of two or
more terms is said to be unifiable if such a substitution exists.
We will use words like occurrence, sub-term, depth, size quite liberally. In the light of
the presence of several occurrences of operators, free variables and bound variables (including different bound variable occurrences signifying different variables but possessing the same name e.g.
(x[(xx)] x[(xx)])) in a term, it is useful to define a unique position for each symbol in a term t.
For any term t we have a set of strings P os(t) N which is the set of positions occurring in t.
Further for each p P os(t), there is a unique symbol occurring at that position denoted by pos(p, t).
Definition 28.1

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

604 OF 788

Q UIT

t
c
x
o(t1, . . . , tn)

depth
1
1
1 + M axni=1depth(ti)

size
1
1
Pn
1 + i=1 size(ti)

ST
{t}
{t}
Sn
{t} i=1 ST (ti)

pos
{}
{}
Sn
{} i=1 i.pos(ti)

The functions given in the table above are defined by induction on the structure of term t.  is the
empty word on strings, . is the catenation operator on strings and i.pos(ti) = {i.p | p pos(ti)}.
s v t iff s ST (t) is the subterm relation on terms. s is a proper subterm of t (denoted s @ t)
iff s v t and s 6 t.
For any t, the subterm at position p pos(t) is denoted t|p and defined by induction on p as
follows: t| t, and for t o(t1, . . . , tn), t|i.p0 ti|p if p = i.p0 pos(t)
For any term t and any position p pos(t), sym(p, t) yields the symbol at position p in the term
t.
The position  is called the root position and the symbol at the root position is called the
root symbol. Hence rootsym(t) = sym(, t) and for any position p pos(t), sym(p, t) =
rootsym(t|p).

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

605 OF 788

Q UIT

The set of occurrences of a symbol V in a term is defined as the set Occ(, t) of positions
in which that symbol occurs i.e. Occ(, t) = {p pos(t) | sym(p, t) = }.
Facts 28.2 For any term t and positions p, q pos(t), t|q @ t|p iff p q.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

606 OF 788

Q UIT

Unifiability
Definition 28.3 A nonempty finite set of terms {ti | 1 i n},
n > 1 is said to be unifiable if there exists a substitution such
that
t1 t2 tn
is called a unifier of {ti | 1 i n}

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

607 OF 788

Q UIT

Unification Examples:1
Example 28.4 Let f and g be distinct binary operators and
x, y, v, w V .
1. The terms f (x, y) and f (v, w) may be unified by the substitution = {x/v, y/w} since f (v, w) f (x, y) f (x, y). They
may also be unified by 1 = {v/x, w/y}.
2. Let r, s, t be any three terms.
Then f (x, y)
and f (v, w) may be unified by the substitution
= {g(s, t)/v, f (r, r)/w, g(s, t)/x, f (r, r)/y}.
3. The terms f (x, y) and f (y, x) may be unified by = {x/y}
since f (x, y) f (x, x) f (y, x).
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

608 OF 788

Q UIT

Unification Examples:2
Example 28.5 Let f and g be distinct binary operators.
1. The terms f (x, y) and g(x, y) cannot be unified by any substitution.
2. The terms f (x, y) and f (y, x) cannot be unified by =
{x/y, y/x} since f (x, y) f (y, x) and f (y, x) f (x, y).
Hence f (x, y) 6 f (y, x).

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

609 OF 788

Q UIT

The following facts are easy to prove and may be used without any mention of them in the sequel.
Fact 28.6 Let s and t be any two terms and let p pos = pos(s) pos(t). Then
1. If s|p t|p for any position p pos then for all positions p, q pos, p  q implies s|q t|q .
2. If rootsym(s|p) = o1 6 o2 = rootsym(t|p) then s and t are not unifiable under any substitution.
3. If s and t are unifiable then for every position p pos, rootsym(s|p) 6 rootsym(t|p) implies at
least one of the symbols is a variable i.e. {rootsym(s|p), rootsym(t|p)} V 6=
Exercise 28.1
1. Generalize the fact 28.6 to nonempty finite sets of terms.
2. Construct an example to show that the converse of fact 28.6.3 does not hold.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

610 OF 788

Q UIT

Generality of Unifiers
There is a certain sense in which may be regarded as being
more general than in example 28.4.
Definition 28.7
A substitution is at least as general as another substitution
(denoted & ) if there exists a substitution such that
= .
if & & .
is strictly more general than (denoted  ) if & and
6& .
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

611 OF 788

Q UIT

Generality: Facts
Fact 28.8
1. & is a preordering relation on S(V ) i.e. it is a reflexive and
transitive relation.
2.  is an irreflexive and transitive relation on S(V ).
3. is an equivalence relation on S(V ).

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

612 OF 788

Q UIT

Most General Unifiers


Definition 28.9 Let T = {ti | 1 i n} be a unifiable set
of terms. A substitution is called a most general unifier (mgu)
of T if for each unifier of T , there exists a substitution such
that = .
Fact 28.10
1. If a set of terms T is unifiable then it has a mgu.
2. If and are both mgus of a set T then .
3. If and are both mgus of a set T then there exist (purevariable) substitutions , 1 : V V such that =
and = 1
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

613 OF 788

Q UIT

More on Positions
For any nonempty set of terms T , we have
\
P os(T ) =
{pos(t)} =
6
tT

and for any position p P os(T ),


T |p = {t|p | t T }
and
rootsym(T |p) = {rootsym(t|p) | t T }

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

614 OF 788

Q UIT

Disagreement Set
Definition 28.11 Given a set T (|T | > 1) of terms (also viewed
as a set of abstract syntax trees), the disagreement set of T is
defined as the set T |q of subterms rooted at some position q
such that
1. not all the terms in T |q have the same root symbol and
2. for every p q, |rootsym(T |p)| = 1, where is the properprefix relation on strings.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

615 OF 788

Q UIT

We have seen that pos(t) for any term t is partially ordered by the relation which inverts the proper
sub-term ordering on ST (t) (Fact 28.2). For the purpose of specifying the unification algorithm, it
is useful to define a total order < on the positions of terms which is consistent with . Intuitively if
u = o(t1, t2 . . . , tn) we would like to specify recursively that
the root position u precedes the root positions of all the subterms t1, . . . , tn. (which is taken care
of by the prefix ordering on positions) i.e.  < i for all 1 i n
for each i, j such that 1 i < j n, the position of the root of ti precedes that of tj in the total
ordering.
If i < j, then the position of the root of any proper subterm of ti precedes the position of any
subterm of tj (including the root).
Definition 28.12 For any positions p, q pos(t), p < q iff one of the following conditions holds.
p =  6= q or
(p = i.p0, q = i.q 0 and p0 < q 0) or
(p = i.p0, q = j.q 0 and i < j).

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

616 OF 788

Q UIT

If all operators in are always used in prefix form then each term may also be regarded as a string
in ( {(, )}). The ordering < on pos(t) simply becomes the left-to-right ordering of symbols in
the well-formed terms of T(V ) represented as strings.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

617 OF 788

Q UIT

Algorithm: Computing a Disagreement Set


Require: |T | > 1 {At least two different terms}
df

1:

2:

D ISAGREEMENT
(T ) = D ISAGREE(T, , P os(T ) {}) where
T
P os(T ) = tT P os(t) {At least  P os(T )} and
df

3:

4:

5:

6:

7:

8:

9:

10:

H OME PAGE

D ISAGREE(T, p, P ) =
if |rootsym(T |p)| = 1 then
if P 6= then
let p0 = M in(P ); P 0 = P {p0} in
D ISAGREE(T, p0, P 0)
end let
else {There is no disagreement}
return fail
JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

618 OF 788

Q UIT

11:

12:

13:

14:

end if
else {A disagreement has been found at position p}
return T |p
end if

The function M in used in the algorithm above is the minimum position with respect to the total
ordering < on positions (definition 28.12) in a term.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

619 OF 788

Q UIT

Example: Disagreement 1
Example 28.13 Consider the set of terms
S1 = {f (a, x, h(g(z))), f (z, h(y), h(y))}
where a is a constant, f is a ternary operator and g and h are
unary operators. In this case, reading the terms from left to
right we get a disagreement set D1 = {a, z}. On the other
hand, reading from right to left we obtain the disagreement set
D10 = {g(z), y} which requires going down one level deeper.
The algorithm however will compute the leftmost disagreement
D1 always.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

620 OF 788

Q UIT

Example: Occurs Check


Example 28.14 Consider the set
S2 = {f (g(z), x, h(g(z))), f (z, h(y), h(y))}
The disagreement set {g(z), z} is such that S2 is not unifiable,
because for any substitution of z can never be syntactically
identical with g(z). This is an example of the notorious occurs
check problem. Hence S2 is not unifiable.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

621 OF 788

Q UIT

Example: Disagreement 3
Example 28.15 Consider the set
S3 = {f (a, x, h(g(z))), f (b, h(y), h(y))}
where a and b are both constant symbols. Here a disagreement
set is D3 = {a, b}. Again it is clear that S3 is not unifiable.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

622 OF 788

Q UIT

Example: Disagreement 4
Example 28.16 Consider the set
S4 = {f (h(z), x, h(g(z))), f (g(x), h(y), h(y))}
Here we have a disagreement set D4 = {h(z), g(x)}. Since
h(z) cannot be unified with g(x) under any substitution of free
variables, S4 is not unifiable.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

623 OF 788

Q UIT

Disagreement and Unifiability


Fact 28.17 If S 0 is the disagreement set of S then
1. S is unifiable implies S 0 is unifiable.
2. If S is unifiable and 0 is a mgu of S 0 then there exists a mgu
of S such that 0 & .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

624 OF 788

Q UIT

The above facts reduce the problem of finding a unifier if it exists, to that of systematically finding
disagreement sets and unifying them.
Finding a unifier for a disagreement set is a pre-requisite for finding a unifier for the original set of
terms. A disagreement set consists of subterms of the original set of terms at a particular position
such that at least two distinct (sub-)terms exist in the set. Further a disagreement set is unifiable
only if there is at most one non-variable term in it. By choosing a substitution {t/x} where both t
and x are terms in the disagreement set satisfying the condition x 6 F V (t), there is a possibility of
unifying the disagreement set. The algorithm constructs a sequence of singleton substitutions whose
composition yields a most general unifier if it exists.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

625 OF 788

Q UIT

Algorithm: Unification
Require: S f T(V ) and |S| > 1
Ensure: If S is not unifiable then fail else S(V ) : |S| = 1
and is a mgu of S
df

1:

U NIFY(S) = PARTIAL U NIFY(1, S) where


df

2:

3:

4:

5:

6:

7:

H OME PAGE

PARTIAL U NIFY(, S) =
let T = S in
if |T | = 1 then
return { is a mgu of S}
else {There is a position at which at least two terms are different}
let D = D ISAGREEMENT(T ) in

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

626 OF 788

Q UIT

8:

9:

10:

11:

12:

13:

14:

15:

16:

H OME PAGE

if x D V : t T [x 6 F V (t)] then
Choose t T : x 6 F V (t)
PARTIAL U NIFY({t/x} , S)
{T = S |{t/x}T | < |T |}
{|({t/x} )S| < |S| |S|}
else {Occurs check fails so S is not unifiable}
return fail
end if
end let
end if
end let

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

627 OF 788

Q UIT

Example 28.18 Consider the set S = S1 in example 28.13. Starting with 0 = 1 we go through the
following steps to obtain a unifier of S.
i
0
1
2
3

i
0
1
2
3

i S
0 S
1 S
2 S
3 S

=1
= {a/z} 0
= {h(y)/x} 1
= {g(z)/y} 2

Di
= {f (a, x, h(g(z))), f (z, h(y), h(y)}
D0
= {f (a, x, h(g(z))), f (a, h(y), h(y)}
D1
= {f (a, h(y), h(g(z))), f (a, h(y), h(y)} D2
= {f (a, h(g(z)), h(g(z))}
D3

= {a, z}
= {x, h(y)}
= {g(z), y}
=

Hence the required unifier is 3 = {g(z)/y} {h(y)/x} {a/z} 1 = {a/z, h(g(z))/x, g(z)/y}.
Example 28.19 Let S = {f (y, z, w), f (g(x, x), g(y, y), g(z, z))} where f is a ternary operator and
g is a binary operator. An attempt to apply the algorithm yields the following sequence of substitutions: 1 = {g(x, x)/y} from which we get 1S = {f (g(x, x), z, w), f (g(x, x), g(g(x, x), g(x, x)), g(z, z))}
and then 2 = {g(g(x, x), g(x, x))/z} which yields
2S = {f (g(x, x), g(g(x, x), g(x, x)), w),
f (g(x, x), g(g(x, x), g(x, x)), g(g(g(x, x), g(x, x)), g(g(x, x), g(x, x))))} and finally
3 = {g(g(g(x, x), g(x, x)), g(g(x, x), g(x, x)))/w} 2

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

628 OF 788

Q UIT

Hence in general there are pathological cases which make the algorithm very expensive to run,
having a complexity that is exponential in the length of the input i.e. to unify the set
{f (x1, . . . , xn), f (g(x0, x0), , g(xn1, xn1))}
would require a substitution that has 2k 1 occurrences of the symbol g in the substitution of the
variable xk .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

629 OF 788

Q UIT

The Unification Theorem


Theorem 28.20 (The Unification Theorem) The unification algorithm terminates satisfying its postcondition (If S is not unifiable
then fail else S(V ) : |S| = 1 and is a mgu of S) for
any set of terms satisfying its preconditions (S f T(V ) and
|S| > 1).
2

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

630 OF 788

Q UIT

Proof of theorem 28.20


Proof:
Claim. Termination
S
` Let V0 = sS F V (s) be the (finite) set of free variables occurring in S. With each execution of line 8 in the unification algorithm either it terminates because it fails or a substitution
{t/x} such that x 6 F V (t) is generated with k+1 = {t/x} k , we have k+1S has one
variable less than k S. Since V0 is finite the algorithm must terminate.
a
Claim. If S is not unifiable then it terminates returning fail.
` Trivial.

Claim. If S is unifiable then it terminates returning a most general unifier


` Let be any unifier of S, and let 1 = 0, 1, , k = be the sequence of substitutions
generated by the algorithm. We prove by induction that for every i, there exists a substitution
i such that = i i.
Basis. For i = 0 clearly 0 = .
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

631 OF 788

Q UIT

Induction Hypothesis (IH).


Assume for some j, 0 j < k, there exists j such that = j j .
Induction Step. Clearly since j S is not a singleton, a disagreement set Dj will be found for
j S. Since = j j is a unifier of S, clearly j must unify Dj , which means there exists
a variable x and a term t with x 6 F V (t) such that j unifies Dj which in effect implies
j x = j t. Without loss of generality we may assume {t/x} is the chosen substitution so
that j+1 = {t/x} j . Now define j+1 = j {j x/x}.
Case x dom(j ). Then j = {j x/x} j+1 = {j t/x} j+1. Since x 6 F V (t), we
have j = {j+1t/x} j+1 = j+1 {t/x} by the definition of composition. Finally from
= j j we get = j+1 {t/x} j = j+1 j+1.
Case x 6 dom(j ). Then j = j+1 and each element of Dj is a variable and j = j+1
{t/x}. Thus = j j = j+1 {t/x} j = j+1 j+1 as required.
Since for any unifier of S there exists k such that = k k , k must be a mgu of S.

a
QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

632 OF 788

Q UIT

Exercise 28.2
1. Generalize the facts 28.6 to a set S of terms where |S| 2.
2. Identify the relationships among the different substitutions , 1, , , and 1 in examples
28.4 and 28.5
3. Let D be the disagreement set of S.
(a) Can |D| be different from |S|? Justify your answer.
(b) If S = D then under what conditions is S unifiable?
(c) If S 6= D then what can you say about the depths of terms in D as compared to the depths of
terms in S?
4. Construct an example of a set S of terms with disagreement set D in which there exist a variable
x and a term t such that x F V (t) and yet the set S is unifiable.
5. Prove that if S is unifiable then the mgu computed by the unification algorithm is idempotent.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

633 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

634 OF 788

Q UIT

29. Lecture 29: Resolution in FOL

Lecture 29: Resolution in FOL


Friday 14 October 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

635 OF 788

Q UIT

1. Recapitulation
2. SCNFs and Models
3. SCNFs and Unsatisfiability
4. Representing SCNFs
5. Clauses: Terminology
6. Clauses: Ground Instances
7. Facts about Clauses
8. Clauses: Models
9. Clauses: Herbrands Theorem
10. Resolution in FOL

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

636 OF 788

Q UIT

Recapitulation
1. For any set {} (where may or may not be empty) of
closed -formulae |= iff {} is unsatisfiable.
2. A non-empty set of closed -formulae is unsatisfiable iff it
contains a non-empty finite unsatisfiable subset.
3. A set of closed -formulae has a model iff it has a Herbrand
model
4. A non-empty finite set
V of closed -formulae is unsatisfiable
iff the formula is unsatisfiable.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

637 OF 788

Q UIT

SCNFs and Models


1. A closed -formula has a model iff the universally closed
-formula sko() has a model.
2. Every closed -formula may be transformed into an equisatisfiable (universally closed) formula in SCNF.
3. A universally closed -formula in SNF has model iff g()
the ground-instances (see definition 26.6) of has a model.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

638 OF 788

Q UIT

SCNFs and Unsatisfiability


1. A closed -formula and the (universally closed) -formula
sko() are equi-unsatisfiable.
2. A universally closed -formula in SNF is unsatisfiable iff
g() is unsatisfiable.
3. Since g() consists of only closed formulae, g() is unsatisfiable iff there is a finite subset of g() which is unsatisfiable.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

639 OF 788

Q UIT

Representing SCNFs
Definition 29.1 Let the SCNF sko() be represented by a set
sko() = {Ci | 1 i m}
such that
sko() ~[

Ci ]

1im

where each (quantifier-free) conjunct Ci, 1 i m,


_
Ci
j
1jni

is called a clause and is represented by a set


Ci = {j | 1 j ni}
of literals.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

640 OF 788

Q UIT

Clauses: Terminology
Definition 29.2
1. A clause is a finite set of literals.
2. The empty clause is the empty set of literals ({}).
3. A ground clause is a clause with no occurrences of variables.
4. For any substitution , and clause C = {j | 1 j n},
C = {j | 1 j n}.
Compare with clauses in propositional logic

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

641 OF 788

Q UIT

Clauses: Ground Instances


Definition 29.3
1. The set of ground instances of a clause C is the set
g(C) = {C | is a ground substitution }
2. For any set S = {Ci | 1 i m} of clauses, the set of
ground instances of S is the set
[
g(S) =
g(C)
CS

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

642 OF 788

Q UIT

Facts about Clauses


Lemma 29.4 Let {Ci | 1 i m} be a set of clauses. Then
^
^
~[
~[Ci]
Ci ]
1im

1im

Proof: Follows from the semantics of and or alternatively


from corollary 25.2.
QED

Notice that even if there are free variables common between
two clauses, this lemma holds, mainly because of the fact that
there are no existential quantifiers. For example
x[p(x) q(x)] x[p(x)] y[q(y)] x, y[p(x) q(y)]

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

643 OF 788

Q UIT

Clauses: Models
Definition 29.5
1. A structure A is a model of a
clause C = {j | 1 j n} (denoted A C) iff n > 0
W
~
and A [ 1jn j ].
a set S of clauses (denoted A S) if it is a model of every
clause in S.
2. S |= C iff every model of S is also a model of C.
Note: An empty clause has no models.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

644 OF 788

Q UIT

Clauses: Herbrands Theorem


Proposition 29.6
1. A set S of clauses possesses a model iff every finite subset
of S possesses a model.
2. A set S of clauses is unsatisfiable iff there is a finite subset
S 0 f S of clauses which is unsatisfiable iff g(S 0) does not
possess a model.


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

645 OF 788

Q UIT

Resolution in FOL
Compare with resolution in propositional logic

Let S be a set of clauses, Ci, Cj S with i 6= j, F V (Ci)


F V (Cj ) = and p an atomic predicate symbol such that
Ci = C 0 {p(s~i0 ) | 1 i0 mi} and Cj = C 0 {p(t~j 0 ) | 1
i
j 0 mj }

L = {p(s~i0 ) | 1 i0 mi} {p(t~j 0 ) | 1 j 0 mj } is a set of


unifiable literals.
= U NIFY(L) is an mgu of L
0 = (C 0 C 0 ) = (C 0) (C 0 ) is called the resolvent of C
Cij
i
i
j
i
j
and Cj .

S
Res1
0 }
(S {Ci, Cj }) {Cij
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

646 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

647 OF 788

Q UIT

30. Lecture 30: More on Resolution in FOL

Lecture 30: More on Resolution in


FOL
Tuesday 18 October 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

648 OF 788

Q UIT

1. Standardizing Variables Apart


2. Factoring
3. Example: 1
4. Example: 2
5. Refutation

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

649 OF 788

Q UIT

Standardizing Variables Apart


1. The free variables of distinct clauses must be disjoint and variables should be renamed if necessary.
Example 30.1 Let S = {C1, C2} where
C1 = {p(x)}
C2 = {p(f (x))}
S represents the set of closed formulae
{x[p(x)], x[p(f (x))]}
which is clearly unsatisfiable. However the empty clause
cannot be derived (because of the occurs check) unless x is
renamed in one of the clauses.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

650 OF 788

Q UIT

Factoring
2. Unlike in the case of propositional resolution it should be possible to eliminate several literals at once
Example 30.2 Consider the set S = {C1, C2} where
C1 = {p(x), p(y)}
C2 = {p(u), p(v)}
S is clearly unsatisfiable but by removing only one literal at a
time with the substitution {x/u} yields the new clause
0 = {p(y), p(v)}
C12

from which the empty clause cannot be derived.


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

651 OF 788

Q UIT

Example: 1
Example 30.3 Consider the set S = {C1, C2} where
C1 = {q(x, y), q(y, z), q(x, z)}
x, y, z[(q(x, y) q(y, z)) q(x, z)]
which represents transitivity and
C2 = {q(u, v), q(v, u)}
u, v[q(u, v) q(v, u)]
which represents symmetry.
A logical consequence of these two properties is the property
derived below.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

652 OF 788

Q UIT

C1 = {q(x, y), q(y, z), q(x, z)}, {q(u, v), q(v, u)} = C2
= {z/u, y/v
0
{q(x, y), q(x, z), q(z, y)} = C12
0 = {q(x, y), q(z, y), q(x, z)}
C12
x, y, z[(q(x, y) q(z, y)) q(x, z)]

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

653 OF 788

Q UIT

Example: 2
Example 30.4 Suppose we need to prove that if a binary relation p is reflexive
df

pref lexive = x[p(x, x)]


and euclidean
df

peuclidean = x, y, z[(p(x, y) p(x, z)) p(y, z)]


then it is also symmetric
df

psymmetric = x, y[p(x, y) p(y, x)]

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

654 OF 788

Q UIT

After renaming bound variables and converting into SCNF to get the
clauses
C1 = {p(x, x)}
C2 = {p(u, v), p(u, w), p(v, w)}
The mgu = {x/u, x/w} yields the required clause
0 = {p(x, v), p(v, x)}
C12

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

655 OF 788

Q UIT

Refutation
Refutation in propositional logic

Example 30.5 We could also prove symmetry in example 30.4


by a refutation as follows. Taking the negation of the conclusion
we get
psymmetry

u, v[p(u, v) p(v, u)]


(Sko) p(a, b) p(b, a)

{{p(a, b)}, {p(b, a)}}


df

=
{C3, C4}
where a and b are skolem constants.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

656 OF 788

Q UIT

{C1 = {p(x, x)}, C2 = {p(u, v), p(u, w), p(v, w)}, C3 = {p(a, b)}, C4 = {p(b, a)}}
= {x/u, x/w}
0
{C12
= {p(x, v), p(v, x)}, C3 = {p(a, b)}, C4 = {p(b, a)}} 0
= {a/x, b/v}
0
{C124
= {p(a, b), }, C3 = {p(a, b)}, } 00
=1
{{}}

Alternatively a proof starting with the clauses C3 and C4 works too.


{C1 = {p(x, x)}, C2 = {p(u, v), p(u, w), p(v, w)}, C3 = {p(a, b)}, C4 = {p(b, a)}}
1 = {b/v, a/w}
0
= {p(u, b), p(u, a)}}
{C1 = {p(x, x)}, C3 = {p(a, b)}, C24
2 = {a/u}
0
{C1 = {p(x, x)}, C234
= {p(a, a)}}
3 = {a/x}
{{}}
Exercise 30.1
1. Prove the conclusion of example 30.3 by a refutation.
2. Are there any other unifiers by which symmetry may be proved in example 30.4?

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

657 OF 788

Q UIT

3. Try a refutation proof using = {x/u, x/w, x/v} as the first unifier in example 30.5. Why
doesnt it work?
4. Try a refutation proof using = {x/u, x/w, y/v} as the first unifier in example 30.5. Why does
it work?

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

658 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

659 OF 788

Q UIT

31. Lecture 31: Resolution: Soundness and Completeness

Lecture 31: Resolution: Soundness


and Completeness
Wednesday 19 October 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

660 OF 788

Q UIT

1. Soundness of FOL Resolution


2. Ground Clauses
3. The Lifting Lemma
4. Lifting Lemma: Figure
5. Completeness of Resolution Refutation: 1
6. Completeness of Resolution Refutation: 2
7. Completeness of Resolution Refutation: 3

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

661 OF 788

Q UIT

Soundness of FOL Resolution


0 obtained by resolving the
Lemma 31.1 The resolvent Cij
clauses Ci and Cj in the resolution method is a logical consequence of the set {Ci, Cj }.

The following theorem then follows.

Theorem 31.2 If S 0 is the set of clauses obtained by a single


application of the resolution rule Res1, then S |= S 0.

Corollary 31.3 If the empty clause is derivable from a set S of
clauses, then S is unsatisfiable.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

662 OF 788

Q UIT

Proof of lemma 31.1


Proof: Assume
Ci = Ci0 {p(s~i0 ) | 1 i0 mi},
Cj = Cj0 {p(t~j 0 ) | 1 j 0 mj },
F V (Ci) F V (Cj ) = and
L = {p(s~i0 ) | 1 i0 mi} {p(t~j 0 ) | 1 j 0 mj } is a set of unifiable literals.
Let A {Ci, Cj }. Therefore
A ~[

i]

(21)

j ]

(22)

i Ci

A ~[

_
i Cj

and for any substitution we have


_
A Ci
_
A Cj
H OME PAGE

JJ

II

LCS

G O B ACK

(23)
(24)
F ULL S CREEN

C LOSE

663 OF 788

Q UIT

If is a unifier of L and L = {} we get


_

({} Ci0)

(25)

_
A ({} Cj0 )

(26)

Let Ci0 = {i0 | 1 i0 k} and Cj0 = {j 0 | 1 j 0 l}. Then we have the following table
which shows a case analysis for the various values of k and l.
{} Ci0
k=0=l

k = 0, l > 0
k > 0, l = 0 (1 k )
k, l > 0
(1 k )

{} Cj0

(1 l )

(1 l )

Ci0 Cj0
{}
1 l
1 k
(1 k ) (1 l )

It is easy to see that in each case


{{} Ci0, {} Cj0 } |= Ci0 Cj0
(27)
W
It follows also from (21), (22) and (27) that A ~[ Cij0 ] and hence Cij0 is a logical consequence of
the set {Ci, Cj }.
QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

664 OF 788

Q UIT

Ground Clauses
Theorem 31.4 (Completeness of Resolution Refutation for
ground clauses). Let G be a set of ground clauses. If G does
not possess a model, the empty clause ({}) may be derived by
Res0.
Here Res0 is the propositional resolution rule given by

S
Res0
0 }
(S {Ci, Cj }) {Cij
0 = C 0 C 0 . Note that there is no substitution involved
where Cij
i
j
anywhere since all clauses are ground.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

665 OF 788

Q UIT

Proof of theorem 31.4.


Proof: Let G = {Ci | 1 i n, n > 0} be a set of n clauses. If {} G there is nothing to
prove. So assume {} 6 G. Consider the following measure
X
#G = (
|Ci|) n
1in

Clearly, #G = 0 iff every clause is made up of a single literal. We proceed to prove the theorem by
induction on #G.
^
Basis. #G = 0. Then each Ci = {i} and G
i and by theorem 25.10, G is unsatisfiable iff
1ik

it contains a complementary pair. Clearly by rule Res0 the resolvent of this complementary pair
is the empty clause.
Induction Hypothesis (IH).
For all k, 0 #G = k < m for some m > 0, if G does not possess a model, then the empty
clause is derivable from G.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

666 OF 788

Q UIT

Induction Step. Assume #G = m > 0. There must be at least one clause Ci which contains more
than one literal. So let Ci = {i} Di with i 6 Di 6= . Let Gi1 = (G {Ci}) {Di} and
Gi2 = (G {Ci}) {i}. Clearly #Gi1 < #G and #Gi2 < #G. Further if G does not have a
model then neither Gi1 nor Gi2 has a model (if either of them had a model then so would G since
W
Ci i Di). By the induction hypothesis,
1. there exists a resolution proof R1 from Gi1 which derives the empty clause and
2. there is another resolution proof R2 from Gi2 which also derives the empty clause.
Notice that since we are dealing only with ground literals, all resolvents are obtained by applying
the rule Res0.
Consider the proof R10 obtained from R1 by adding the literal i to Gi1 and performing exactly
the same sequence of resolutions.
Case 1. If the proof R1 did not involve the use of any of the literals from Di and the empty
clause was derived, then clearly the same sequence with i included would also derive the
empty clause and that completes the proof.
Case 2 On the other hand if one or more steps in proof R1 involved literals from Di then
the resulting proof R10 may derive the clause {i} in place of the empty clause. However
we do know that the empty clause is derived from Gi2 in proof R2. This implies there exist
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

667 OF 788

Q UIT

resolution steps in R2 involving the literal i which derive the empty clause. Therefore there
exists at least one clause containing the literal i in the set of final clauses obtained in R10 . By
applying the resolution steps of R2 which do not appear anywhere in R10 , the empty clause
would again be derived.


QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

668 OF 788

Q UIT

The Lifting Lemma


Lemma 31.5 (Lifting Lemma). (see figure) Let C1 and C2 be
clauses and let 1, 2, be substitutions such that
F V (C1) F V (C2) = ,
F V (1C1) F V (2C2) = and
0 is the resolvent of C and C via a substitution , by
C12
1 1
2 2
a single application of resolution.

Then there exists a resolvent C12 of C1 and C2 by a single application of resolution via a substitution and a substitution
0 C .
such that C12
12
2
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

669 OF 788

Q UIT

Lifting Lemma: Figure


C1

C1

C2

C2

lifted to

1C1

C12

2C2

0
C12

0
C12

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

670 OF 788

Q UIT

Proof of lemma 31.5


Proof: Let
C1 = C10 L1 where L1 = {i | 1 i m, m > 0}
C2 = C20 L2 where L2 = {j | 1 j n, n > 0}
0
= ((1C10 ) (2C20 )).
such that is a mgu of (1L1) (2L2) and C12

Since F V (C1) F V (C2) = , dom(1) dom(2) = and since F V (1C1) F V (2C2) = we


have F V (ran(1)) F V (ran(2)) = and hence 1C10 = (1 2)C10 and 2C20 = (1 2)C20 .
Since is a mgu of (1L1)(2L2) we have (1 2) is a unifier of L1 L2. If L1 L2 is unifiable,
then it has a most general unifier & (1 2) such that C12 = (C10 C20 ) is the resolvent of C1
and C2.
& (1 2) implies there exists a substitution such that
= (1 2)
and
0
C12
= ((C10 C20 )) = ( (1 2))(C10 C20 )

QED
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

671 OF 788

Q UIT

A superposed version of the figure is shown below.

C1

C2
12

1 C1

C12
12

2 C2

12

0
C12

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

672 OF 788

Q UIT

Completeness of Resolution
Refutation: 1
1. The lifting lemma helps us to use the completeness of resolution refutation for ground clauses and lift it to clauses with
variables.
2. By standardizing variables apart we may guarantee that the
conditions of disjointness of free variables between different
clauses (lemma 31.5) may be enforced.
3. Any set of clauses S = {Ci | 1 i m} represents the
conjunction of the universal closure of each clause.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

673 OF 788

Q UIT

Completeness of Resolution
Refutation: 2
1. The lifting lemma 31.5 guarantees that if the substitutions 1
and 2 are ground, then there exists a corresponding ground
substitution which produces the same effect after resolution.
2. By Herbrands theorem 26.7 a set is unsatisfiable iff a finite
subset of ground instances of is unsatisfiable.
3. To prove the completeness of resolution refutation it is sufficient to consider only the finite set of ground clauses from which
the empty clause {} may be derived.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

674 OF 788

Q UIT

Completeness of Resolution
Refutation: 3
Theorem 31.6 (Completeness of Resolution Refutation). If a set
of clauses is unsatisfiable then the empty clause is derivable
from .
2

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

675 OF 788

Q UIT

Proof of theorem 31.6


Proof: Without loss of generality we may assume that the variables in every clause are disjoint
from the variables occurring in any other clause.
By Herbrands theorem 26.7 there exists a finite set of ground clauses G = {gCi | 1 i m} f
g() such that G is unsatisfiable. Each gCi G is obtained by a substitution on some clause i.e.
gCi = iCi for some substitution i and some clause Ci . Further for i 6= j, dom(i)dom(j ) =
and since all the clauses in G are ground the disjointness conditions of the lifting lemma are
trivially satisfied.
Each application of rule Res0 in G may be lifted to finding a mgu of the appropriate clauses. This
fact may be proved by induction on the height of the resolution proof tree and we leave it as an
exercise to the interested reader. However the following diagram illustrates it for two steps of a
resolution proof tree.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

676 OF 788

Q UIT

C1

C3

C2
12

1C1

C4
34

C12
12

12

3 C3

2C2

C1234
1234

4 C4

34

1234

0
C12

C34
34
0
C34

1234

0
C1234

QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

677 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

678 OF 788

Q UIT

32. Lecture 32: Resolution and Tableaux

Lecture 32: Resolution and Tableaux


Tuesday 01 November 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

679 OF 788

Q UIT

1. FOL: Tableaux
2. FOL: Tableaux Rules
3. FOL Tableaux: Example 1
4. First-Order Tableaux
5. FOL Tableaux: Example 2

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

680 OF 788

Q UIT

FOL: Tableaux
1. The tableau method in principle is similar to
natural deduction in its use of syntactical decomposition,
resolution in using unsatisfiability to prove validity.
2. The tableau method for both propositional and predicate
logic has some advantages over resolution.
3. FOL resolution requires formulae to be converted into PCNF
and then SCNF before resolution may be applied.
4. As in the case of Natural Deduction the tableau method uses
the rules E and E to decompose quantified formulae along
with the same restrictions.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

681 OF 788

Q UIT

FOL: Tableaux Rules


Besides the usual tableau rules for the propositional connectives we have the following.
x[]
x[]
.
.
{t/x}
{a/x}
x[]
x[]
.
.
{a/x}
{t/x}
1. The restrictions on the use of a constant symbol a in both
rules . and . are the same as those for E in both H1 and
G1.
2. Since E holds for all terms t, the rules . and . may
have to be applied several times before unsatisfiability can
be proven.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

682 OF 788

Q UIT

FOL Tableaux: Example 1


Example 32.1 Let c be a constant symbol and f a unary function symbol. Then = {p(c), p(f (f (c))), x[p(x) p(f (x))]}
is unsatisfiable.
p(c)
p(f (f (c)))
x[p(x) p(f (x))]
p(c) p(f (c))
p(c)
p(f (c))
 p(f (c)) p(f (f (c)))
p(f (c)) p(f (f (c)))


Notice the two applications of rule E.  indicates a closed
path in the tableau.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

683 OF 788

Q UIT

First-Order Tableaux
1. Unlike propositional tableaux, any satisfiable set of quantified formulae can potentially yield an infinite tableau, since a
formula of the form x[] can have an infinite number of
instances.
2. For unsatisfiable sets, closed finite tableaux may be constructed by applying the following heuristics
Whenever possible apply propositional rules before applying quantifier rules
Apply rules . and . before applying . and . in order
to direct the proof towards a propositional contradiction.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

684 OF 788

Q UIT

FOL Tableaux: Example 2


We prove that x[p(x) q(x)] |= x[p(x)] x[q(x)]
1.
x[p(x) q(x)]
2. (x[p(x)] x[q(x)])
3.
x[p(x)]
( on 2.)
4.
x[q(x)]
( on 2.)
5.
q(a)
( on 4.)
6.
p(a)
( on 3.)
7.
p(a) q(a)
( on 1.)
8. p(a) ( on 7.)
9. q(a) ( on 7.)
11. 
(5., 9.)
10. 
(6., 8.)
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

685 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

686 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

687 OF 788

Q UIT

33. Lecture 33: Completeness of Tableaux Method

Lecture 33: Completeness of Tableaux


Method
Wednesday 02 November 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

688 OF 788

Q UIT

1. First-order Hintikka Sets


2. Hintikkas Lemma for FOL
3. First-order tableaux and Hintikka sets
4. Soundness of First-order Tableaux
5. Completeness of First-order Tableaux

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

689 OF 788

Q UIT

First-order Hintikka Sets


Definition 33.1 A finite or infinite set is a first-order Hintikka
set with respect to P1() if
1-3. is a (propositional) Hintikka set (definition 9.7) such
that all the atomic propositions are ground.
4.
x[] implies {t/x} ,
x[] implies {t/x}
for every t T0() (ground term).
5.
x[] implies {t/x} ,
x[] implies {t/x}
for at least one t T0() (ground term).
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

690 OF 788

Q UIT

Hintikkas Lemma for FOL


Lemma 33.2 If contains at least one constant symbol, then
every first-order Hintikka set with respect to P1() is satisfiable
in a Herbrand model.
Proof:
We define a Herbrand interpretation of the formulae as follows. For each n-ary atomic predicate symbol p,
p(t1, . . . , tn) for ground terms t1, . . . , tn is true if and only if
p(t1, . . . , tn) . By the definition of a Hintikka set we know
{p(t1, . . . , tn), p(t1, . . . , tn)} 6 . Hence all the atomic sentences in are satisfiable under any valuation vH. We may
then proceed to show by structural induction on each P1()
that implies H .
QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

691 OF 788

Q UIT

First-order tableaux and Hintikka sets


Lemma 33.3 If a tableau rooted at a closed formula has an
open path then the set of formulae on the path form a first-order
Hintikka set.
Proof: We may prove that each rule in Tableaux Rules and
FOL: Tableaux Rules creates a path for the construction of Hintikka sets.
QED


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

692 OF 788

Q UIT

Soundness of First-order Tableaux


Theorem 33.4 (Soundness of First-order Tableau Rules). If
there is a closed tableau rooted at a closed formula then |= .
Proof: Suppose there is a closed tableau rooted at . Then
every path in the tableau is closed because of the occurrence
of a complementary pair in the path. On the other hand if 6|= ,
i.e. is not valid, then is satisfiable, which implies that
there is an open path in the tableau rooted at , clearly a
contradiction.
QED


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

693 OF 788

Q UIT

Completeness of First-order Tableaux


Theorem 33.5 (Completeness of First-order Tableaux). If a
closed formula is valid, then there exists a closed tableau
rooted at .
Proof: If there is no closed tableau rooted at then there
exists at least one open path in each such tableau. The set of
formulae on this path form a Hintikka set and hence they are
all simultaneously satisfiable, which implies there is a Herbrand
model satisfying , in which case 6|= .
QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

694 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

695 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

696 OF 788

Q UIT

34. Lecture 34: Completeness of the Hilbert System

Lecture 34: Completeness of the


Hilbert System
Wednesday 09 November 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

697 OF 788

Q UIT

1. Deductive Consistency
2. Models of Deductively Consistent Sets
3. Deductive Completeness
4. The Completeness Theorem

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

698 OF 788

Q UIT

Deductive Consistency
Definition 34.1 A set L1() is deductively consistent iff
there does not exist a formula such that `H1 and
`H1 .
This definition is equivalent to other possible definitions such
as those given below which may all be derived from rule .
Lemma 34.2 The following statements are equivalent.
1. L1() is deductively consistent.
2. There does not exist a formula such that `H1 ( )
3. There exists a formula which is not provable.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

699 OF 788

Q UIT

34.1. Model-theoretic and Proof-theoretic Consistency

We have earlier defined the notion of consistency of a set of formulae in propositional logic (see
also lemma 11.1) leading to the notions of maximal consistency and Lindenbaums theorem which
enabled us to extend a consistent set of propositions to a maximally consistent one. Later we have
also defined the notion of consistency of sets of predicate logic formulae in definition 20.2. Notice
that definition 9.1 though worded differently, also states that a set of propositions is consistent only
if it has a model. The notion of a model in sentential logic however, refers to the existence of a
truth assignment under which all the sentences are true (simultaneously). Hence both in sentential
and predicate logic the notion of consistency refers to the existence of a model. These notions of
consistency are model-theoretic since they are intimately associated with the existence of a model.
We have reserved the term deductive consistency (definition 34.1) to a proof-theoretic notion obtained from deductions rather than models. A priori there is no reason to believe that the two notions
are equivalent unless we can prove that our deductive system is sound and complete. While soundness has been proven we need to prove completeness before claiming that the model-theoretic notion
of consistency and the proof-theoretic one are equivalent.
We need to carry our analogies between model-theory and proof theory a little further to the domain

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

700 OF 788

Q UIT

maximal consistent sets (indeed some of the proof ideas would be analogous too!) in order to be able
to prove the completeness of the system H1. We refer to such maximally consistent sets obtained
through deductions as being deductively complete. The main difference however, is that we restrict
ourselves to only closed formulae as will be evident soon.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

701 OF 788

Q UIT

Models of Deductively Consistent Sets


Lemma 34.3 If L1() has a model then it is deductively
consistent.
Proof:
Let A for each . If is not deductively
consistent, then there exists such that `H1 and `H1 .
However since H1 is sound it follows that A and A
which is a contradiction.
QED


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

702 OF 788

Q UIT

Deductive Completeness
Lemma 34.4 For any L1(), `H1 iff `H1 [] iff
{[]} is not deductively consistent.
2
We restrict our attention to only deductively consistent and
complete sets.
Definition 34.5 A (deductively consistent) set L1() is deductively complete iff for every closed formula , `H1 or
`H1 .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

703 OF 788

Q UIT

Proof of lemma 34.4


Proof:
`H1 iff `H1 [] is obvious from rules I and E.
() Suppose `H1 . Then by monotonicity (theorem 13.1) {[]} `H1 and hence
{[]} `H1 []. Further since {[]} `H1 [], it follows that {[]} is not
deductively consistent.
() Suppose {[]} is not deductively consistent. Then there exists a formula (by lemma
34.2) such that {[]} `H1 ( ). From `H1 and we obtain
{[]} `H1 []. By corollary 23.4 (Deduction theorem for closed formulae) we obtain
`H1 [] []. It follows from the derived axiom C2 that `H1 ([] []) []
from which we obtain `H1 [] by a single application of MP.


QED
Notes on proof of lemma 34.4.

1. The univeral closure is required in the lemma, because in general the inconsistency of {}
does not imply `H1 .
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

704 OF 788

Q UIT

Example 34.6 Let = {x[p(x)]} and p(x). Then {p(x)} is inconsistent. However, it is not possible to prove `H1 p(x).
2. Hence the maximally consistent sets of propositional logic translate into deductively complete
sets in FOL. And this maximal completeness can only be shown for closed formulae and not for
arbitrary formulae with free variables.
3. Clearly deductive completeness therefore is restricted to closed formulae.
The following is the proof-theoretic analogue of Lindenbaums theorem. Even the proof of the
theorem mirrors the alternative proof of Lindenbaums theorem.
Theorem 34.7 (The Extension Theorem) Every deductively consistent set may be extended to a
deductively complete set.
Proof: Let be a nonempty deductively consistent set of -formulae. For any enumeration of
closed -formulae
1, 2, 3, . . .
(28)

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

705 OF 788

Q UIT

define the chain of sets 0 1 2 starting with 0 = as follows:



i
if i `H1 i
i+1 =
i {i} otherwise
Claim. Each i is deductively consistent.
` By induction on i. For i = 0, 0 = is given to be deductively consistent. Assuming
i is deductively consistent, we have that if i+1 = it is obviously deductively consistent.
Otherwise i+1 = {i} and by lemma 34.4 since i 6`H1 i and is a closed formula,
i+1 must be deductively consistent.
a
[
Then =
i is the desired set.
i0

Claim. is deductively consistent.


` Suppose not. Then by lemma 34.2, for some formula , we have `H1 ( ).
However since such a proof is finite there exists a finite subset f , such that `H1
( ). Since is finite there exists a k 0 such that k which implies k `H1
( ) contradicting the previous claim that k is deductively consistent.
a
Claim. is deductively complete.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

706 OF 788

Q UIT

` For any arbitrary closed formula , occurs in the enumeration 28 at some position, say
m for some m 0. If m `H1 m then `H1 m. Otherwise m+1 = m {m}
and `H1 m. By definition 34.5 is deductively complete.
a
QED

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

707 OF 788

Q UIT

The Completeness Theorem


Theorem 34.8 (Godels Completeness Theorem). |= implies
`H1 . When = we have that all valid formulae of L1()
are theorems of H1.
2
Proof: Assume |= and suppose 6`H1 . Then by lemma
34.4 {[]} is deductively consistent and hence possesses
a model A. But that implies A but A 6 , which by definition means 6|= , a contradiction.
QED


H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

708 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

709 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

710 OF 788

Q UIT

35. Lecture 35: First-Order Theories

Lecture 35: First-Order Theories


Friday 11 November 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

711 OF 788

Q UIT

1. (Simple) Directed Graphs


2. (Simple) Undirected Graphs
3. Irreflexive Partial Orderings
4. Irreflexive Linear Orderings
5. (Reflexive) Preorders
6. (Reflexive) Partial Orderings
7. (Reflexive) Linear Orderings
8. Equivalence Relations
9. Peanos Postulates
10. The Theory of The Naturals
11. Notes and Explanations
12. Finite Models of Arithmetic
13. A Non-standard Model of Arithmetic
14. Z-Chains

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

712 OF 788

Q UIT

(Simple) Directed Graphs


= {; e : s2}

df

eirref lexivity = x[e(x, x)]


df

= {eirref lexivity }

DG

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

713 OF 788

Q UIT

(Simple) Undirected Graphs


= {; e : s2}

df

eirref lexivity = x[e(x, x)]


esymmetry

df

= x, y[e(x, y) e(y, x)]

df

= {eirref lexivity , esymmetry }

U G

df
0
Equivalently esymmetry = x, y[e(x, y) e(y, x)] (see exercise 20.1.12) may be used in place of esymmetry .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

714 OF 788

Q UIT

Irreflexive Partial Orderings


= {; <}

df

<irref lexivity = x[(x < x)]


df

<transitivity = x, y, z[((x < y) (y < z)) (x < z)]


df

= {<irref lexivity , <transitivity }

IP O

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

715 OF 788

Q UIT

Irreflexive Linear Orderings


= {; <}

df

<irref lexivity = x[(x < x)]


df

<transitivity = x, y, z[((x < y) (y < z)) (x < z)]


df

= x, y[(x < y) (x = y) (y < x)]

<trichotomy

df

= {<irref lexivity , <transitivity ,


<trichotomy }

ILO

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

716 OF 788

Q UIT

(Reflexive) Preorders
= {; : s2}

df

ref lexivity = x[x x]


df

transitivity = x, y, z[((x y) (y z)) (x z)]


df

= {ref lexivity , transitivity }

P re

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

717 OF 788

Q UIT

(Reflexive) Partial Orderings


= {; : s2}

df

= x[x x]

ref lexivity

df

= x, y, z[((x y) (y z)) (x z)]

transitivity

df

antisymmetry = x, y[((x y) (y x)) x = y]


df

= {ref lexivity , transitivity ,


antisymmetry }

P O

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

718 OF 788

Q UIT

(Reflexive) Linear Orderings


= {; : s2}

df

ref lexivity = x[x x]


df

transitivity = x, y, z[((x y) (y z)) (x z)]


df

dichotomy = x, y[(x y) (y x)]


df

= {ref lexivity , transitivity , dichotomy }

LO

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

719 OF 788

Q UIT

Equivalence Relations
= {; : s2}

df

ref lexivity = x[x x]


symmetry

df

= x, y[(x y) (y x)]

df

transitivity = x, y, z[((x y) (y z)) (x z)]


df

= {ref lexivity , symmetry , transitivity }

Equiv

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

720 OF 788

Q UIT

Peanos Postulates
P1. 0 is a natural number.
P2. If x is a natural number then x+1 (called the successor of x)
is a natural number.
P3. 0 6= x+1 for any natural number x.
P4. x+1 = y +1 implies x = y
P5. Let P be a property that may or may not hold of every natural number. If
Basis. 0 has the property P and
Induction Step. whenever a natural number x has the property P , x+1 also has the property P
then all natural numbers have the property P .
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

721 OF 788

Q UIT

The Theory of The Naturals


= {0 : s, +1 : s s; = : s2}

df

0notsuccessor = x[(x+1 = 0)]


+1injective

df

= xy[x+1 = y +1 x = y]

df

6=0successor = y[(y = 0) x[y = x+1]]


df

n
(+1)
(+1)ndistinct = x[(x
= x)]
df
(+1)distinct = {(+1)ndistinct | n > 0}
df
S
= {0notsuccessor , +1injective, 6=0successor }

(+1)distinct
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

722 OF 788

Q UIT

Notes and Explanations


n
(+1)
1. x
denotes the n-fold application of +1 to x.

2. 6=0successor says that every non-zero element must have


a predecessor.
3. NS = hN, S i is a model of the axioms S .
4. The infinite collection of axioms (+1)ndistinct is necessary
to obtain models that are countable.
5. The axioms (+1)distinct ensure that there are no finite
models of S .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

723 OF 788

Q UIT

Finite Models of Arithmetic


1. If the infinite collection (+1)distinct is replaced by a finite
collection for some m > 0 i.e.
(+1)m>n>0distinct = {(+1)ndistinct | m > n > 0}
then both finite and countable models are possible.
2. If in addition to (+1)m>n>0distinct we also include the axiom
df

m
(+1)
modulo m = x[x
= x]

we get models ZSm = hZm, S i for the integers modulo m


and there are no infinite models.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

724 OF 788

Q UIT

A Non-standard Model of Arithmetic


Consider the model NS = hN, S i of the axioms of number
theory.
We add a new element 00 6= 0.
n
(+1)
This implies adding an infinite number of new elements 0

one for each n > 0. For simplicity let us call these elements
10, 20, 30, . . .. Each of these new elements is different from every element in N.
Since 00 6= 0, it must have a predecessor say 10
which again leads to the addition of all the elements
20, 30, 30, . . . each of which is distinct and different from
all other elements. Let us call this set of elements Z0.
N0S = hN Z0, S i is a model of S and is said to be nonstandard.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

725 OF 788

Q UIT

Z-Chains
Z0 is called a Z-Chain.
N0S = hN Z0, S i is also a countable model of the axioms
S .
Further NS and N0S are not isomorphic
We could add a countable number of distinct Z-chains, Z00,
Z000, Z0000, etc. to obtain other distinct and mutually nonisomorphic models.
Each of the models obtained above is a also a countable
model of S .
Each of these models is also non-standard.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

726 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

727 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

728 OF 788

Q UIT

36. Lecture 36: Towards Logic Programming

Lecture 36: Towards Logic


Programming
Tuesday 15 November 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

729 OF 788

Q UIT

1. Reversing the Arrow


2. Horn Clauses
3. Goal clauses
4. Logic Programs
5. Sorting in Logic
6. Prolog: Selection Sort
7. Prolog: Merge Sort
8. Prolog: Quick Sort
9. Prolog: SEND+MORE=MONEY
10. Prolog: Naturals

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

730 OF 788

Q UIT

Reversing the Arrow


Let

df

=
Consider any clause C = {1, . . . , p} {1, . . . , n} where
i, 1 i p are positive literals and j , 1 j n are the
negative literals. Then we have
W
W
~
C [( 1ip i) ( 1jn j )]
W
V
~
[( 1ip i) ( 1jn j )]
V
W
~
[( 1jn j ) ( 1ip i)]
W
V
~
[( 1ip i) ( 1jn j )]
df

= 1 , . . . , p 1 , . . . , n

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

731 OF 788

Q UIT

Horn Clauses
Definition 36.1 Given a clause
df

C = 1, . . . , p 1, . . . , n
Then C is a Horn clause if 0 p 1.
C is called a
program clause or rule clause if p = 1,
fact or unit clause if p = 1 and n = 0,
goal clause or query if p = 0,
Each j is called a sub-goal of the goal clause.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

732 OF 788

Q UIT

Goal clauses
Given a goal clause
df

G =

1 , . . . , n
~[1 . . . n]
~[1 . . . n]

If ~y = F V (1 . . . n) then the goal is to prove that there


exists an assignment to ~y which makes 1 . . . n true.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

733 OF 788

Q UIT

Logic Programs
Definition 36.2 A logic program is a finite set of Horn clauses,
i.e. it is a set of rules P = {h1, . . . , hk }, k 0 with
hl l 1l , . . . , nl l , for 0 l k. l is called the head of
the rule and 1l , . . . , nl l is the body of the rule.
Given a logic program P and a goal clause G = {1, . . . , n} the
basic idea is to show that
P {G} is unsatisfiable
~[1 n] is a logical consequence of P
~[1 n] is a logical consequence of P

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

734 OF 788

Q UIT

Sorting in Logic
sort(x, y)
sorted(nil)
sorted(x.nil)
sorted(x.y.z)
lesseq(x, x)
lesseq(x, y)
perm(nil, nil)
perm(x.y, u.v)
delete(x, x.y, y)
delete(x, y.z, y.w)

H OME PAGE

JJ

II

perm(x, y), sorted(y)

lesseq(x, y), sorted(y.z)


x<y
delete(u, x.y, z), perm(z, v)
delete(x, z, w)
sort([2, 8, 1, 10, 4, 2], x)
LCS

G O B ACK

F ULL S CREEN

C LOSE

735 OF 788

Q UIT

Prolog: Selection Sort


s e l e c t S o r t ( X , Y ) : p e r m u t a t i o n ( X , Y ) ,
sorted (Y ) .
sorted ( [ ] ) .
s o r t e d (H . [ ] ) .
s o r t e d ( F . S . T ) : l e s s e q ( F , S ) ,
sorted (S. T ) .
l e s s e q ( F , S ) : F=S .
l e s s e q ( F , S ) : F<S .
permutation ( [ ] , [ ] ) .
p e r m u t a t i o n (H . T , F . R) : d e l e t e ( F , H . T , Z ) ,
permutation (Z , R) .
d e l e t e (H, H . T , T ) .
d e l e t e ( X , H . T , H . U): d e l e t e ( X , T , U ) .
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

736 OF 788

Q UIT

Prolog: Merge Sort


mergeSort ( [ ] , [ ] ) .
mergeSort (H . [ ] , H . [ ] ) .
mergeSort ( F . S . T , S a l l ) : s p l i t ( F . S . T , L e f t , R i g h t ) ,
mergeSort ( L e f t , S l e f t ) ,
mergeSort ( Right , S r i g h t ) ,
merge ( S l e f t , S r i g h t , S a l l ) .
split ([] , [] , []).
s p l i t (H . [ ] , H . [ ] , [ ] ) .
s p l i t ( F . S . T , F . U, S . V ) : s p l i t ( T , U, V ) .
merge ( [ ] , L , L ) .
merge ( L , [ ] , L ) .
merge ( F . B , H . T , F . U) : F=<H, merge ( B , H . T , U ) .
merge ( F . B , H . T , H . V ) : H<F , merge ( F . B , T , V ) .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

737 OF 788

Q UIT

Prolog: Quick Sort


quicksort ( [ ] , [ ] ) .
q u i c k s o r t (H . [ ] , H . [ ] ) .
q u i c k s o r t (H . T , S ) : p a r t i t i o n (H, T , L , G) ,
q u i c k s o r t ( L , Ls ) ,
q u i c k s o r t (G, Gs ) ,
append ( Ls , H . [ ] , Lsh ) ,
append ( Lsh , Gs , S ) .

p a r t i t i o n (M, [ ] , [ ] , [ ] ) .
p a r t i t i o n (M, H . T , H . Lesser , G r e a t e r ) : H=<M,
p a r t i t i o n (M, T , Lesser , G r e a t e r )
p a r t i t i o n (M, H . T , Lesser , H . G r e a t e r ) : M<H,
p a r t i t i o n (M, T , Lesser , G r e a t e r )
append ( [ ] , L , L ) .
append (H . T , L , H . A ) : append ( T , L , A ) .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

738 OF 788

Q UIT

Prolog: SEND+MORE=MONEY
smm :

L = [ S , E , N, D,M, O, R, Y ] ,
Digits = [0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9] ,
assign digits (L, Digits ) ,
M > 0, S > 0,
1000S + 100E + 10N + D +
1000M + 100O + 10R + E =:=
10000M + 1000O + 100N + 10E + Y ,
write (
) , w r i t e ( S ) , w r i t e ( E ) , w r i t e (N) , w r i t e (D) , n l ,
w r i t e ( + ) , w r i t e (M) , w r i t e (O) , w r i t e (R) , w r i t e ( E ) , n l ,
w r i t e ( ----- ) , n l ,
w r i t e ( = ) , w r i t e (M) , w r i t e (O) , w r i t e (N) , w r i t e ( E ) , w r i t e ( Y ) , n

s e l e c t (Z , [ Z |R] , R ) .
s e l e c t ( Z , [ Y | Zs ] , [ Y | Ys ] ) : s e l e c t ( Z , Zs , Ys ) .
List ).
assign digits ( [] ,
a s s i g n d i g i t s ( [ D| Ds ] , L i s t ): s e l e c t (D, L i s t , NewList ) ,
a s s i g n d i g i t s ( Ds , NewList ) .
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

739 OF 788

Q UIT

Prolog: Naturals
isnf (z ).
i s n f ( s ( X ) ) : i s n f ( X ) .
r e w r i t e ( X , X ) : i s n f ( X ) .
r e w r i t e ( s ( X ) , s ( Y ) ) : r e w r i t e ( X , Y ) , i s n f ( Y ) .
r e w r i t e ( a ( z , Y ) , Y ) : i s n f ( Y ) .
r e w r i t e ( a ( Y , z ) , Y ) : i s n f ( Y ) .
r e w r i t e ( a ( s ( X ) , Y ) , s ( Z ) ) : r e w r i t e ( a ( X , Y ) , Z ) .
r e w r i t e ( a ( X , s ( Y ) ) , s ( Z ) ) : r e w r i t e ( a ( X , Y ) , Z ) .
r e w r i t e ( a ( X , Y ) , Z ) : r e w r i t e ( X , U) , r e w r i t e ( Y , V ) , r e w r i t e ( a (U, V ) , Z ) .
even ( z ) .
even ( s ( s ( X ) ) ) : r e w r i t e ( X , Y ) , even ( Y ) .
odd ( X ) : n o t even ( X ) . % n e g a t i o n as f a i l u r e
/ rewrite (a(a( s ( z ) , s ( s ( z ) ) ) , a( s ( z ) , s ( s ( z ) ) ) ) , X) .
X = s ( s ( s ( s ( s ( s ( z ) ) ) ) ) ) /

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

740 OF 788

Q UIT

/ I m p l e m e n t i n g d o u b l e e n d e d q u e u e s t h r o u g h c o n s t r u c t o r s /
deq ( n u l l q ) .
deq ( f n q (A, D ) ) : i n t e g e r (A) , deq (D ) .
deq ( r n q ( B , D ) ) : i n t e g e r (B ) , deq (D ) .
n o n n u l l ( f n q (A, D ) ) : i n t e g e r (A) , deq (D ) .
n o n n u l l ( r n q ( B , D ) ) : i n t e g e r (B ) , deq (D ) .
deq ( f d q (D ) ) : n o n n u l l (D ) .
deq ( r d q (D ) ) : n o n n u l l (D ) .
nf ( nullq ) .
n f ( f n q (A, D ) ) : i n t e g e r (A) , n f (D ) .
r e w r i t e (D, D) : n f (D ) .
%i n d u c t i o n s t e p f o r n o r m a l f o r m s
r e w r i t e ( f n q (A, D) , f n q (A, E ) ) : i n t e g e r (A) , r e w r i t e (D, E ) .
% f o r a l l forms o t h e r than normal forms
r e w r i t e ( r n q ( B , n u l l q ) , f n q ( B , n u l l q ) ) : i n t e g e r (B ) . % b a s i s o f i n d u c t i o n
r e w r i t e ( r d q ( f n q (A, n u l l q ) ) , n u l l q ) . % b a s i s o f i n d u c t i o n
% r e w r i t e ( f d q ( f n q (A, n u l l q ) ) , n u l l q ) f o l l o w s from t h e more g e n e r a l r e w r i t e
r e w r i t e ( f d q ( f n q (A, D ) ) , E): i n t e g e r (A) , r e w r i t e (D, E ) . % f d q f o r a l l n o n n u l l
r e w r i t e ( r n q ( B , f n q (A, D ) ) , f n q (A, E ) ) : % f o r r n q on n o r m a l f o r m s
i n t e g e r (A) , i n t e g e r (B ) ,
r e w r i t e (D, F ) ,

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

741 OF 788

Q UIT

r e w r i t e ( rnq (B, F ) , E ) , nf (E ) .
r e w r i t e ( r n q ( B , D) , E ) : % f o r r n q on o t h e r f o r m s
i n t e g e r (B ) ,
r e w r i t e (D, F ) ,
r e w r i t e ( rnq (B, F ) , E ) .
r e w r i t e ( r d q ( f n q (A, D ) ) , f n q (A, E ) ) :
i n t e g e r (A) ,
r e w r i t e (D, F ) , n o n n u l l ( F ) ,
r e w r i t e ( rdq ( F ) , E ) .

% f o r r d q on n o r m a l f o r m s

r e w r i t e ( r d q (D) , E ) : % f o r r d q on o t h e r f o r m s
r e w r i t e (D, F ) , r e w r i t e ( r d q ( F ) , E ) .
% r e w r i t e ( r d q ( r n q ( B , D ) ) , D) f o l l o w s by i n d u c t i o n from t h e v a r i o u s r e w r i t e s a b o v e
f v ( f n q (A, D) , D): i n t e g e r (A) , deq (D ) . % v a l u e a t t h e f r o n t o f t h e d e q u e u e
r v ( f n q (A, n u l l q ) , B) : i n t e g e r (A) , A=B .
r v ( f n q (A, D) , B) : i n t e g e r (A) , r e w r i t e (D, E ) , r v ( E , B ) .
r v (D, B ) : r e w r i t e (D, E ) , r v ( E , B ) .
/ Testing
% R e s t o r i n g f i l e / u s r / l o c a l / l i b / Yap / s t a r t u p
YAP v e r s i o n Yap 5 . 1 . 1
? % r e c o n s u l t i n g / home / s a k / p r o l o g / d e q u e s . P . . .
% r e c o n s u l t e d / home / s a k / p r o l o g / d e q u e s . P i n module u s e r , 0 msec 4096 b y t e s
yes
? r e w r i t e ( f n q ( 2 , f n q ( 1 , n u l l q ) ) , X ) .

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

742 OF 788

Q UIT

X = fnq (2 , fnq (1 , n u l l q ) ) ?
yes
? r v ( f n q ( 1 , f n q ( 2 , n u l l q ) ) , B ) .
B = 2 ?
yes
? r v ( r n q ( 3 , f n q ( 1 , f n q ( 2 , n u l l q ) ) ) , B ) .
B = 3 ?
yes
? r e w r i t e ( r n q ( 4 , f d q ( f n q ( 1 , f n q ( 2 , r n q ( 3 , n u l l q ) ) ) ) ) , X ) .
X = fnq (2 , fnq (3 , fnq (4 , n u l l q ) ) ) ?
yes
? r v ( r n q ( 4 , f d q ( f n q ( 1 , f n q ( 2 , r n q ( 3 , n u l l q ) ) ) ) ) , B ) .
B = 4 ?
yes
? r v ( r d q ( r n q ( 4 , f d q ( f n q ( 1 , f n q ( 2 , r n q ( 3 , n u l l q ) ) ) ) ) ) , B ) .
B = 3 ?
yes
/

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

743 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

744 OF 788

Q UIT

37. Lecture 37: Verification of Imperative Programs

Lecture 37: Verification of Imperative


Programs
Wednesday 16 November 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

745 OF 788

Q UIT

1. The WHILE Programming Language


2. Programs As State Transformers
3. The Semantics of WHILE
4. Programs As Predicate Transformers
5. Correctness Assertions
6. Total Correctness of Programs
7. Examples: Factorial 1
8. Examples: Factorial 2

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

746 OF 788

Q UIT

The WHILE Programming Language


Let be any signature. Then the programming language
WH() is defined by the following BNF.
P , Q ::=  | x := t | P ; Q | [P ] |
?P : Q |
{?P }
where QF().

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

747 OF 788

Q UIT

Programs As State Transformers


A program is merely a state transformer which takes a valuation
0 .
vA of variables and yields another valuation vA
P
0
vA

vA

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

748 OF 788

Q UIT

The Semantics of WHILE


Let A be a -algebra. Let VA = {vA | vA : V |A|} be
the set of all valuations (also called states). The meaning of a
program P is given by MAJP K : VA VA
df

MAJKvA

= vA

df

MAJx := tKvA

= vA[x := VAJtKvA ]

df

MAJ[P ]KvA

MAJP ; QKvA

MAJ?P : QKvA
MAJ{?P }KvA
H OME PAGE

JJ

= MAJP KvA
df
= 
(MAJQK MAJP K)vA
df
MAJP KvA if TAJKvA = 1
=
 MAJQKvA if TAJKvA = 0
df
MAJP ; {?P }KvA if TAJKvA = 1
=
vA
if TAJKvA = 0
II

LCS

G O B ACK

F ULL S CREEN

C LOSE

749 OF 788

Q UIT

Programs As Predicate Transformers


We may also view a program as a transformer of properties.
Consider a predicate to represent a set of possible valuations
i.e. VA() = {vA | (A, vA) }. Then a program transforms
a state satisfying into a state satisfying some other predicate
.

v0

v
P

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

750 OF 788

Q UIT

Correctness Assertions
Definition 37.1 A partial correctness assertion (also called a
Hoare-triple) is a triple of the form {} P {} where is a
formula called the precondition, P is a program and is the
postcondition.
Definition 37.2
{} P {} holds in a state vA (denoted (A, vA) {} P {}),
0 implies (A, v 0 )
if (A, vA) and MAJP KvA = vA
A

{} P {} is valid in A, (denoted A |= {} P {}) if


(A, vA) {} P {} for every state vA.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

751 OF 788

Q UIT

Total Correctness of Programs


Definition 37.3 A total correctness assertion is a triple of the
form [] P [] where is a formula called the precondition, P is
a program and is the postcondition.
Definition 37.4
[] P [] holds in a state vA (denoted (A, vA) [] P []),
0 M JP K
0 and
if (A, vA) implies for some vA
=
v
v
A
A
A
0
(A, vA) .
[] P [] is valid in A, (denoted A |= {} P {}) if
(A, vA) [] P [] for every state vA.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

752 OF 788

Q UIT

Examples: Factorial 1
Let Z {! : s, +, , : s2 s; =, > : s2}.
df

Example 37.5 Let P1 = p := 1; {(x = 0)?[p := p x; x := x 1]}.


Let Z = hZ, i. Then
1. Z |= {x = x0} P1 {p = x0!}
2. However Z 6|= [x = x0] P1 [p = x0!] since P1 will not terminate
for negative values of x.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

753 OF 788

Q UIT

Examples: Factorial 2
df

Example 37.6 Let P2 = p := 1; {x > 0?[p := p x; x := x 1]}.


Let Z = hZ, i. Then
1. Z |= {x = x0 0} P {p = x0!}
2. Z |= [x = x0 0] P [p = x0!]
3. A
more
technically
complete
specification
Z |= [x = x0] P [(x0 0 p = x0!) (x0 < 0 p = 1)]

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

754 OF 788

is

Q UIT

Exercise 37.1
1. For any program P defined on a signature what do the following correctness formulae mean?
(a) {>} P {>}
(b) {>} P {}
(c) {} P {>}
(d) {} P {}
(e) [>] P [>]
(f) [>] P []
(g) [] P [>]
(h) [] P []
2. Which of the correctness formulae given in problem 1 are
(a) always valid?
(b) always unsatisfiable?

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

755 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

756 OF 788

Q UIT

38. Lecture 38: Verification of WHILE Programs

Lecture 38: Verification of WHILE


Programs
Friday 18 November 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

757 OF 788

Q UIT

1. Proof Rule: Epsilon


2. Proof Rule: Assignment
3. Proof Rule: Composition
4. Proof Rule: The Conditional
5. Proof Rule: The While Loop
6. The Consequence Rule
7. Proof Rules for Partial Correctness
8. Example: Factorial 1
9. Towards Total Correctness
10. Termination and Total Correctness
11. Example: Factorial 2
12. Notes on Example: Factorial
13. Example: Factorial 2 Made Complete
14. An Open Problem: Collatz

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

758 OF 788

Q UIT

Proof Rule: Epsilon

.

H OME PAGE

JJ

II

{}  {}

LCS

G O B ACK

F ULL S CREEN

C LOSE

759 OF 788

Q UIT

Proof Rule: Assignment

v0

v
x := t

:= .
H OME PAGE

JJ

{} x := t {}
I

II

LCS

( {t/x})
G O B ACK

F ULL S CREEN

C LOSE

760 OF 788

Q UIT

Proof Rule: Composition

P
v0

v 00

{} P {}
; . {} Q {}
{} P ; Q {}
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

761 OF 788

Q UIT

Proof Rule: The Conditional

Q

{ } P {}
? : . { } Q {}
{} ?P : Q {}
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

762 OF 788

Q UIT

Proof Rule: The While Loop


{ } P {}
{}.
{} {?P } { }
in the while rule is called the loop invariant.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

763 OF 788

Q UIT

The Consequence Rule

0
{0} P { 0}
.
0
{} P {}
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

764 OF 788

Q UIT

Proof Rules for Partial Correctness


.

{} P {}
:= .
[].
{{t/x}} x := t {}
{} [P ] {}

{}  {}

{ } P {}
{}.
{} {?P } { }
{} P {}
; . {} Q {}
{} P ; Q {}

{ } P {}
? : . { } Q {}
{} ?P : Q {}

0
{0} P { 0}
.
0
{} P {}

in the while rule is called the loop invariant.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

765 OF 788

Q UIT

Example: Factorial 1
{x = x0}
p := 1;
{x = x0 p = 1}
{(x0 = x) (x 0 p x! = x0!)}
{0 (x 0 p x! = x0!)} {}
{(x = 0)?
{0 (x 0) (p x! = x0!) (x = 0)}
{0 (x > 0) (p x! = x0!)}
[p := p x;
{0 (x > 0) (p (x 1)! = x0!)}
x := x 1]
{0 (x 0) (p x! = x0!)}
{}
}
{ (x = 0)}
{0 (x = 0) (p x! = x0!)}
{(x0 0 p = x0!)}
where 0 (x0 0)
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

766 OF 788

Q UIT

Towards Total Correctness


1. The only construct which may not terminate is the while loop.
2. Termination of the while loop: Define a measure called the
bound function, : Dom() W where
hW, <i is a well-ordered set (a set with no infinite descending sequences w > w0 > w00 > ) with a least element 0
such that w < 0 does not hold true for any w W .
Dom() is the tuple of possible values of the program variables (~v ).
Often hW, <i = hN, <i
(~v ) > 0 and (~v ) = 0
Each execution of the body of the loop decreases the value
of the bound function.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

767 OF 788

Q UIT

Termination and Total Correctness


!

[] P []
:=!
[]!
[{t/x}] x := t []
[] [P ] []

[]  []

[] P []
; ! [] Q []
[] P ; Q []

[ ] P []
? :! [ ] Q []
[] ?P : Q []

0
[0] P [ 0]
!
0
[] P []

[ (~v ) = b0 > 0] P [ (~v ) < b0]


{}!
[] {?P } [ ]
where
is a bound function and
is the loop invariant.
c.f. Proof Rules for Partial Correctness
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

768 OF 788

Q UIT

Example: Factorial 2
[x = x0]
p := 1;
[x = x0 p = 1]
[(x0 = x) (x 0 p x! = x0!) (x0 < 0 p = 1)]
[0 (x 0 p x! = x0!)] []
{x > 0?
[0 (x > 0) (p x! = x0!) (x, p) = x = 0 > 0]
[p := p x;
[0 (x > 0) (p (x 1)! = x0!)
(x, p) = x = 0 > 0]
x := x 1]
[0 (x 0) (p x! = x0!) (x, p) = x < 0 > 0] ]
[]
}
[0 (x = 0) (p x! = x0!) (x, p) = x = 0]
[(x0 0 p = x0!) (x0 < 0 p = 1)] []
where 0 (x0 0) (x0 < 0 p = 1)
c.f. Partial correctness proof
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

769 OF 788

Q UIT

Notes on Example: Factorial


The loop invariant is a conjunction of
0 whose truth is trivially unaffected by the changes in state
produced by the loop body, and
the formula (x 0 p x! = x0!) which
holds initially before control enters the loop,
holds after the condition has been checked,
fails to hold after the first command of the body has been
executed,
is restored at the end of the loop body, and
holds after exiting the loop
Notice the progress of the bound function which is completely
internal to the working of the loop and is never part of the
specification of the program.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

770 OF 788

Q UIT

Example: Factorial 2 Made Complete


A more complete proof including the use of the assignment clearly delineated is given
below.
[x = x0] [0]
[x = x0 1 = 1] [{1/p}1]
p := 1;
[x = x0 p = 1] [1]
[(x0 = x) (x 0 p x! = x0!) (x0 < 0 p = 1)]
[0 (x 0 p x! = x0!)] []
{x > 0?
[0 (x > 0) (p x! = x0!) (x, p) = x = 0 > 0] [01]
[{p x/p}1]
[p := p x;
[0 (x > 0) (p (x 1)! = x0!) (x, p) = x = 0 > 0] [1]
[{x 1/x}2]
x := x 1
[0 (x 0) (p x! = x0!) (x, p) = x < 0 > 0] [2]
]
[2]
[]
}
[ (x > 0) (x, p) = x = 0]
[0 (x = 0) (p x! = x0!) (x, p) = x = 0]
[(x0 0 p = x0!) (x0 < 0 p = 1)] []
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

771 OF 788

Q UIT

An Open Problem: Collatz


Consider the following specification where includes the div
and mod functions on positive integers.
Z |= [x > 0] Collatz [x = 1]
where
df

Collatz = {x > 1?[x mod 2 = 0?x := x div 2 : x := 3 x + 1]}

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

772 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

773 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

774 OF 788

Q UIT

39. Lecture 39: Concluding Remarks

Lecture 39: Concluding Remarks


Wednesday 07 December 2011

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

775 OF 788

Q UIT

1. Summary
2. The Limitations of Predicate Logic
3. Sortedness
4. Many-Sorted Logic: Symbols
5. Many-Sorted Signatures
6. Many-Sorted Signature: Terms
7. Many-Sorted Predicate Logic
8. Reductions

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

776 OF 788

Q UIT

Summary
1. A mathematical treatment of the essentials of reasoning
2. A rigorous treatment of First-order logic
3. Applications in logic and computer science
(a) some elementary theorem proving
(b) logic programming
(c) program verification
4. Some illustrations of the power of first-order logic
5. Some illustrations of the lack of distinguishability.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

777 OF 788

Q UIT

The Limitations of Predicate Logic


1. The property of well-orderings viz.
Every subset of a well-ordered set has a least element
cannot even be expressed in FOL. It requires the power of
second-order logic
2. Transitive closures are not expressible
3. Isomorphic models cannot be distinguished
4. The existence of non-standard models implies that not all
non-isomorphic models may be distinguished either.
5. The validity problem is undecidable.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

778 OF 788

Q UIT

Sortedness
A treatment that works mainly with a 1-sorted term algebra
often does not address the interesting problems of a mathematical theory e.g. the first-order theory of directed or undirected graphs.
To begin to address even the simplest problems of graph theory requires counting and the power of the first order theory
of numbers.
The problems of second-order logic (quantification over first
order properties) may be expressed in many-sorted first order logic by allowing the power set of a set to be included in
the universe of discourse of a many-sorted first order logic.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

779 OF 788

Q UIT

Many-Sorted Logic: Symbols


We have considered only a first-order logic of 1-sorted signatures. It is possible to extend it to a logic of a many-sorted signature (which is what most programming languages are based
on).
Definition 39.1 Given a finite nonempty set S of sorts with S =
{si | 1 i k}, a k-sorted logic consists of
A countable set Vi of variables of sort si for each si S.
F: a countably infinite collection of function symbols;
f , g, h, . . . F.
A: a countably infinite collection of atomic predicate symbols;
p, q, r, . . . A and
Quantifier symbols i and i for each sort si S.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

780 OF 788

Q UIT

Many-Sorted Signatures
Definition 39.2 Given a finite nonempty set S of sorts with S =
{si | 1 i k}, a S-sorted signature consists of a set of
strings of the form

f : si1 , si2 , . . . , sim si0 , m 0


for each f F,

p : si1 , si2 , . . . , sin , n 0


such that there is at most one string for each f F and each
p A.
A binary equality relation =i : si2 for some of the sorts si S.
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

781 OF 788

Q UIT

Many-Sorted Signature: Terms


Definition
39.3 Given a S-sorted signature , the set T() =
U
1ik Ti() of -terms is the disjoint union of the sets of terms
Ti() defined inductively such that every term is assigned a sort
from S.
s, t, u ::= xi Vi | f (t1, . . . , tm)
where f : si1 , si2 , . . . , sim si0 ,
each variable xi Vi is a term in Ti(), a fact usually denoted
x i : si ,
f (t1, . . . , tm) Ti0 (), a fact usually denoted f (t1, . . . , tm) :
si 0 .
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

782 OF 788

Q UIT

Many-Sorted Predicate Logic


The syntax of the logic is the obvious extension to the one
defined as before.
The semantics requires a S-sorted structure with a nonempty domain Ai for each sort.
The semantics is then a minor extension of the one for the
1-sorted case

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

783 OF 788

Q UIT

Reductions
Second-Order logic may simply be considered a 2-sorted
logic with predicates parameterised over both individuals and
sets of individuals.
An S-sorted Predicate Logic may be reduced to a 1-sorted
Predicate logic by introducing a fresh set of unary-predicates
is si (one for each sort si) to denote membership in a sort
and
replace every quantified formula of the form ixi[] by the
1-sorted formula x[is si(x) ] and recursively for each
quantifier,
replace every quantified formula of the form ixi[] by the 1sorted formula x[is si(x) ] and recursively for each quantifier,
H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

784 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

785 OF 788

Q UIT

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

786 OF 788

Q UIT

40. References

References
[1] I. M. Copi. Symbolic Logic. Macmillan, London, UK, 1979.
[2] H. D. Ebbinghaus, J. Flum, and W. Thomas. Mathematical Logic. Springer-Verlag, New York, USA, 1994.
[3] H. B. Enderton. A Mathematical Introduction to Logic. Elsevier India, New Delhi, India, 2001.
[4] M. Fitting. First-Order Logic and Automated Theorem Proving. Springer-Verlag, New York, USA, 1990.
[5] M. Huth and M. Ryan. Logic in Computer Science: Modelling and Reasoning about Systems. Cambridge University Press,
Cambridge, UK, 2000.
[6] John Kelly. The Essence of Logic. Prentice-Hall India, New Delhi, India, 1997.
[7] S. C. Kleene. Mathematical Logic. Dover Publications Inc., New York, USA, 1967.
[8] E. Mendelson. Introduction to Mathematical Logic. D. Van Nostrand Co. Inc., Princeton, New Jersey, USA, 1963.
[9] Anil Nerode and R. Shore. Logic for Applications. Springer-Verlag, New York, USA, 1993.
[10] R. M. Smullyan. First-Order Logic. Springer-Verlag, Berlin, Germany, 1968.
[11] V. Sperschneider and G. Antoniou. Logic: A Foundation for Computer Science. Addison-Wesley Publishing Company, Reading,
UK, 1991.

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

787 OF 788

Q UIT

Thank You!
Any Questions?

H OME PAGE

JJ

II

LCS

G O B ACK

F ULL S CREEN

C LOSE

788 OF 788

Q UIT

Anda mungkin juga menyukai