Lecture 2: First Order Logic

COMS E6998 Formal Verification of System Software
Fall 2018
Ronghui Gu

1. What is First Order Logic

1.1 v.s. Propositional Logic

1.2 Introduction of First Order Logic

First Order Logic := Propositional Logic + :

Example: Not all birds can fly

1.3 Syntax of FOL

Terms are strings:

Formulas are strings:

Two parameters to FOL: and

1.4 Substitution

Definition

Q: find the free and bound variables:

Barendreght convention: To avoid confusion, every bound variable will be distinct from any other bound variable and all the free variables.

Substitution: replace free variables with actual terms.

Definition is defined to be the formula we get by replacing all free occurrences of in with . Q A:= , what is ?

2 FOL Syntax Reasoning (Inference Rules)

2.1 Propositional rules

All propositional logic rules are rules of FO

2.2 Equality rules

Only consider “=”

Q: prove the following rules:

Proof of (=sym)
 
1. t1 = t2                    (Pre)
2. t1 = t1 := (x = t1)[t1/x]  (ref)
3. t2 = t1 := (x = t1)[t2/x]  (=e, 1, 2)
 
Qed

Q: Assume and , prove

Proof of
 
1. t1 = t2                                    (Pre)
2. t + t1 = t + t1 := (t + x = t + t1)[t1/x]  (ref)
3. t + t2 = t + t1 := (t + x = t + t1)[t2/x]  (=e, 1, 2)
 
Qed

Q: Prove

2.3 Quantification rules

Universal quantification elimination rule:

Proof of
 
1. P(t)               (Pre)
2. ∀x. P(x) → Q(x)    (Pre)
3. P(t) → Q(t)        (∀e, 2)
3. Q(t)               (→e, 1, 3)
 
Qed

Universal quantification introduction rule:

Existential introduction rule:

Existential elimination rule:

Proof
1. ∀y. ∃x. f(x) = g(y)  (Pre)
2. ∃x. f(x) = g(5)      (∀e, 1)
   -----------------------------------
3. | x0                 (Hyp)        |
4. | f(x0) = g(5)       (Hyp)        |
5. | g(5) = f(x0)       (=sym, 4)    |
6. | ∃x. g(5) = f(x)    (∃i, 5)      |
   -----------------------------------
7. ∃x. g(5) = f(x)      (∃e, 2, 3~6)
 
Qed

Q: Assume and , and assume

express and prove in FOL over and :
“Any natural number is smaller than some number”

Proof
   ------------------------------
1. | x0            (hypothesis) |
2. | x0 < S x0     (<S, 1)      |
3. | ∃y. x0 < y    (∃i, 2)      |
   ------------------------------
4. ∀x. ∃y. x < y   (∀i, 1~3)
 
Qed

Q: Prove

Proof
1. ∀x. Q(x) → R(x)    (Pre)
2. ∃y. P(y) ∧ Q(y)    (Pre)
   ---------------------------------
3. | x0               (Hyp)        |
4. | P(x0) ∧ Q(x0)    (Hyp)        |
5. | P(x0)            (∧e1, 4)     |
6. | Q(x0) → R(x0)    (∀e, 1, 3)   |
7. | Q(x0)            (∧e2, 4)     |
8. | R(x0)            (→e, 6, 7)   |
9. | P(x0) ∧ R(x0)    (∧i, 5, 8)   |
10.| ∃x. P(x) ∧ R(x)  (∃i, 9)      |
   ---------------------------------
11. ∃x. P(x) ∧ R(x)   (∃e, 2. 3~10)
 
Qed

Q:
Q:

3. Classical vs. Intuitionistic logic

Consider the formula

To prove this we need use rule and provide a term for which we can show

Classically this is a tautology:

using rule (also see truth table of implication).

However notice how we didn’t have to provide any concrete term in the second case to complete the proof of Let’s see this again:

Theorem There are irrational and for which is rational.
Proof We know that 2 is irrational (known theorem of arithmetic which we will not prove here).
Suppose is rational. Then pick and we’re done.
Otherwise is irrational. Pick and .

which is rational.

Correct but we never identified two definitely irrational numbers a and b. In fact knowing whether is rational is a difficult problem!

Riemann hypothesis Michael Atiyah, Proof by Contradiction

4. Semantics of FOL

Let be a list of formulas

4.1 Usefulness of semantics

Syntactic entailment is useful to show existence of proofs.
Semantic entailment is useful to show absence of proofs. How can we show that ?

How can we show that ?

4.2 Model

What should be the semantics of ?
It depends on the semantics of the parameters of FOL: the set of terms and predicates .

Definition A model of consists of the following:

Example Model Natural numbers:

A model may be:

Q: What is like if

4.3 Semantics of formulas

We will give semantics to closed formulas (no free variables) using the semantics of open formulas.

The semantics of means that for all values is true. However it’s not a valid syntax to have formulas containing semantic values from . We need to use environments.

Definition
is an environment if it is a function that maps syntactic variables to semantic values. (lookup tables)

Definition Given a model for a pair and given an environment , we define the satisfaction relation for each logical formula over the pair and as follows.

5. Results of FOL

Theorem (Soundness)
For a given , if then which means for any model of and any environment , we have .

Theorem (Strong soundness)
For a given , if then which means for any model of and any environment , if then .

This involves properties that are true in all models. How can we talk about properties of certain models (e.g., numbers with some standard predicates over them)?
A: Encode the necessary properties of these models in . can contain the axioms we want to hold in these models.

Peano Axioms
Terms: Axioms:

The Peano axioms can be augmented with other operations:

Gödel’s 1st incompleteness theorem

Theorem (Incompleteness) Any set of axioms which is consistent (no contradictions such as 0 = 1 are derivable) and contains “enough arithmetic” cannot be complete. That is, there are true facts φ about arithmetic for which .

Proof. Göedel gave a way to encode first-order logic itself in any axiomatisation containing Peano (or any other encoding of) natural numbers.
Hence for any such system he was able to write an encoding of the formula:

If then obviously the logic is inconsistent ().
If then obviously the logic is incomplete ( is true but not provable).

Gödel’s completeness theorem

Theorem (Completeness)
then .