Day 4 - Paul Egre

formulas of Γ. 2. Close any branch which contains a formula and its negation. If all branches are closed, stop. 3. If a formula has not been considered and has for ...
140KB taille 3 téléchargements 400 vues
Introduction to Logic

1

Where are we? 1. Preliminaries



2. Propositional Logic 3. Tree method for PL

√ √

4. First-order Predicate Logic



5. Tree Method for FOL 6. Expressiveness of FOL

EALING 2005

´ e P. Egr´

Introduction to Logic

2

5. Trees for FOL

EALING 2005

´ e P. Egr´

Introduction to Logic

3

The tree method for predicate logic We add to the branching rules for propositional connectives three rules for quantifiers. We use an infinite set of individual constants {a0 , a1 , ...}. a.

b.

¬∀xφ

¬∃xφ

∃x¬φ

∀x¬φ

∀xφ(x) φ(b)

c.

∃xφ(x)

: for every constant b already present on the branch. If there is no previous constant, use a0 . :for c a fresh constant, not already present on the tree

φ(c) EALING 2005

´ e P. Egr´

Introduction to Logic

4

Algorithm 1. To show whether Γ |= φ, (with Γ finite). Append ¬φ to the formulas of Γ. 2. Close any branch which contains a formula and its negation. If all branches are closed, stop. 3. If a formula has not been considered and has for main connective a propositional connective, apply the connective rule. Otherwise do 4. 4. If a formula ∃xφ(x) has not been considered, apply rule and go back to 3. Otherwise go to 5. 5. If a formula ∀xφ(x) has not been examined, apply the rule and go to 6. 6. Whenever a new formula or new constant appears on the tree, go back to stage 2. Otherwise, stop. EALING 2005

´ e P. Egr´

Introduction to Logic

5

Example 1 “If everyone is proud, then someone is proud” `? ∀xP (x) → ∃xP (x)

EALING 2005

´ e P. Egr´

Introduction to Logic

6

¬(∀xP (x) → ∃xP (x))

EALING 2005

´ e P. Egr´

Introduction to Logic

7

¬(∀xP (x) → ∃xP (x))



∀xP (x) ¬∃xP (x)

EALING 2005

´ e P. Egr´

Introduction to Logic

8

¬(∀xP (x) → ∃xP (x)) ∀xP (x) ¬∃xP (x)





∀x¬P (x)

EALING 2005

´ e P. Egr´

Introduction to Logic

9

¬(∀xP (x) → ∃xP (x)) ∀xP (x) ¬∃xP (x)





∀x¬P (x)

EALING 2005

´ e P. Egr´

Introduction to Logic

10

¬(∀xP (x) → ∃xP (x)) ∀xP (x) ¬∃xP (x)





∀x¬P (x) P (a0 )

EALING 2005

´ e P. Egr´

Introduction to Logic

11

¬(∀xP (x) → ∃xP (x)) ∀xP (x) ¬∃xP (x)





∀x¬P (x) P (a0 )

EALING 2005

´ e P. Egr´

Introduction to Logic

12

¬(∀xP (x) → ∃xP (x)) ∀xP (x) ¬∃xP (x)





∀x¬P (x) P (a0 ) ¬P (a0 )

EALING 2005

´ e P. Egr´

Introduction to Logic

13

¬(∀xP (x) → ∃xP (x)) ∀xP (x) ¬∃xP (x)





∀x¬P (x) P (a0 ) ¬P (a0 ) × • The algorithm stops and all branches are closed.

EALING 2005

´ e P. Egr´

Introduction to Logic

14

Example 2 “someone is cooking and reading, and someone is cooking and watching TV, so someone is reading and watching TV” ∃x(A(x) ∧ B(x)), ∃x(A(x) ∧ C(x)) `? ∃x(B(x) ∧ C(x)) ∃x(A(x) ∧ B(x)) ∃x(A(x) ∧ C(x)) ¬∃x(B(x) ∧ C(x))

EALING 2005

´ e P. Egr´

Introduction to Logic

15

∃x(A(x) ∧ B(x)) ∃x(A(x) ∧ C(x)) ¬∃x(B(x) ∧ C(x))



∀x¬(B(x) ∧ C(x))

EALING 2005

´ e P. Egr´

Introduction to Logic

∃x(A(x) ∧ B(x))

16



∃x(A(x) ∧ C(x)) ¬∃x(B(x) ∧ C(x))



∀x¬(B(x) ∧ C(x)) A(a0 ) ∧ B(a0 )

EALING 2005

´ e P. Egr´

Introduction to Logic

∃x(A(x) ∧ B(x)) ∃x(A(x) ∧ C(x))

17

√ √

¬∃x(B(x) ∧ C(x))



∀x¬(B(x) ∧ C(x)) A(a0 ) ∧ B(a0 ) A(a1 ) ∧ C(a1 )

EALING 2005

´ e P. Egr´

Introduction to Logic

18

∃x(A(x) ∧ B(x)) ∃x(A(x) ∧ C(x))

√ √

¬∃x(B(x) ∧ C(x))



∀x¬(B(x) ∧ C(x)) √ A(a0 ) ∧ B(a0 ) A(a1 ) ∧ C(a1 ) A(a0 ) B(a0 )

EALING 2005

´ e P. Egr´

Introduction to Logic

19

∃x(A(x) ∧ B(x)) ∃x(A(x) ∧ C(x))

√ √

¬∃x(B(x) ∧ C(x))



∀x¬(B(x) ∧ C(x)) √ A(a0 ) ∧ B(a0 ) √ A(a1 ) ∧ C(a1 ) A(a0 ) B(a0 ) A(a1 ) C(a1 )

EALING 2005

´ e P. Egr´

Introduction to Logic

20

∃x(A(x) ∧ B(x)) ∃x(A(x) ∧ C(x))

√ √

¬∃x(B(x) ∧ C(x))



∀x¬(B(x) ∧ C(x)) √ A(a0 ) ∧ B(a0 ) √ A(a1 ) ∧ C(a1 ) A(a0 ) B(a0 ) A(a1 ) C(a1 )

EALING 2005

´ e P. Egr´

Introduction to Logic

21

∀x¬(B(x) ∧ C(x)) √ A(a0 ) ∧ B(a0 ) √ A(a1 ) ∧ C(a1 ) A(a0 ) B(a0 ) A(a1 ) C(a1 ) ¬(B(a0 ) ∧ C(a0 ))

EALING 2005

´ e P. Egr´

Introduction to Logic

22

∀x¬(B(x) ∧ C(x)) √ A(a0 ) ∧ B(a0 ) √ A(a1 ) ∧ C(a1 ) A(a0 ) B(a0 ) A(a1 ) C(a1 ) ¬(B(a0 ) ∧ C(a0 )) ¬(B(a1 ) ∧ C(a1 ))

EALING 2005

´ e P. Egr´

Introduction to Logic

23

∀x¬(B(x) ∧ C(x)) √ A(a0 ) ∧ B(a0 ) √ A(a1 ) ∧ C(a1 ) A(a0 ) B(a0 ) A(a1 ) C(a1 ) ¬(B(a0 ) ∧ C(a0 ))



¬(B(a1 ) ∧ C(a1 )) ¬B(a0 )

¬C(a0 )

×

EALING 2005

´ e P. Egr´

Introduction to Logic

24

A(a0 ) ∧ B(a0 ) A(a1 ) ∧ C(a1 )

√ √

A(a0 ) B(a0 ) A(a1 ) C(a1 ) ¬(B(a0 ) ∧ C(a0 )) ¬(B(a1 ) ∧ C(a1 )) ¬B(a0 )

√ √

¬C(a0 )

× ¬B(a1 )

¬C(a1 ) ×

EALING 2005

´ e P. Egr´

Introduction to Logic

25

• The algorithm stops, but there is an open branch. • Note that the open branch gives us a countermodel with two individuals a0 and a1 , in which a0 is A, B but not C, and a1 is A, C but not B. U = {a0 , a1 } AM = U B M = {a0 } C M = {a1 }

EALING 2005

´ e P. Egr´

Introduction to Logic

26

Example 3 “Everyone loves someone, so someone is loved by everyone” ∀x∃yL(x, y) `? ∃y∀xL(x, y) ∀x∃yL(x, y) ¬∃y∀xL(x, y) ∀y¬∀xL(x, y) ∀y∃x¬L(x, y)

EALING 2005

´ e P. Egr´

Introduction to Logic

27

Example 3 “Everyone loves someone, so someone is loved by everyone” ∀x∃yL(x, y) `? ∃y∀xL(x, y) ∀x∃yL(x, y) ¬∃y∀xL(x, y) ∀y¬∀xL(x, y) ∀y∃x¬L(x, y)

EALING 2005

´ e P. Egr´

Introduction to Logic

28

∃yL(a0 , y) ∃x¬L(x, a0 ) L(a0 , a1 ) ¬L(a2 , a0 ) ∃yL(a1 , y) ∃yL(a2 , y) ∃x¬L(x, a1 ) ∃x¬L(x, a2 ) L(a1 , a3 ) L(a2 , a4 ) ¬L(a5 , a1 ) ¬L(a6 , a2 ) .. . EALING 2005

´ e P. Egr´

Introduction to Logic

29

• The algorithm will continue indefinitely : no stop, and an infinite open branch. • However: it is us who can say (and prove) “the branch will be infinite” ; the algorithm has no way to tell. • This also suggests that, from the algorithm, we can construct an infinite model that satisfies ∀x∃yL(x, y), but falsifies ∃y∀xL(x, y).

EALING 2005

´ e P. Egr´

Introduction to Logic

30

Summary 1. The procedure terminates with all branches closed 2. The procedure terminates with some finite open branch 3. The procedure does not terminate (there is an infinite open branch).

EALING 2005

´ e P. Egr´

Introduction to Logic

31

Completeness Let us write : ` φ for : “the tree built from ¬φ closes”. We can prove that : Theorem (Completeness) : ` φ iff |= φ • (soundness) If a branch extension rule is applied to a satisfiable branch, one of the resulting branches is satisfiable. The interesting cases are the rules for ∀ and ∃. Clearly, if a branch containing ∀xφ(x) is satisfiable, so is the extension. If a branch containing ∃xφ(x) is satisfiable in a model M , then for some constant c, φ(c) is satisfied in M . What about φ(c) where c is a fresh constant? Then 0 M0 the model M in which c = cM is also a model of the branch.

EALING 2005

´ e P. Egr´

Introduction to Logic

32

• (completeness) If B is an open branch, extract a model MB by letting UB be the set of constants occurring on that branch. For P an n-ary predicate letter, set: (ai1 , ..., ain ) is in P M iff P (ai1 , ..., ain ) is a formula on B By induction, one can prove that if φ is on B, then MB |= φ, and if ¬φ is on B, then MB |= ¬φ. • So, if 0 φ, then MB , where B is an open branch, satisfies ¬φ, and so 2 φ.

EALING 2005

´ e P. Egr´

Introduction to Logic

33

Undecidability • So, FOL is complete: the tree method yields a sound and complete proof procedure for validity in FOL. But is FOL decidable? • Note that the tree method is not a decision method, but only a semi-decision method: if |= φ, then ` φ, ie the tree will eventually close. But if 2 φ, it can happen that the algorithm keeps on searching (remember example 3!). • This is not a specificity of this method, indeed: Theorem (Church 1936) : FOL is undecidable.

EALING 2005

´ e P. Egr´

Introduction to Logic

34

6. Limitations of FOL

EALING 2005

´ e P. Egr´

Introduction to Logic

35

Expressiveness • We know that FOL is more expressive than PL, but how expressive is it? • To answer this question, we need to know some general properties about FOL. • The compactness theorem, in particular, plays an essential role.

EALING 2005

´ e P. Egr´

Introduction to Logic

36

First-order logic with identity Consider FOL to which one adds a binary relation = expressing identity. In particular, if c and d are constants of the language, and M is a structure, then M |= c = d iff cM = dM . How much can one express with identity? Abbreviation: x 6= y for ¬(x = y) “there are at least two elements” : ∃x∃y(¬x = y) “there are at least three elements”: ∃x∃y∃z(x 6= y ∧ y 6= z ∧ z 6= x) V “there are at least n elements” λn := ∃x1 ∃x2 . . . ∃xn ( xi 6= xj ) i6=j

EALING 2005

´ e P. Egr´

Introduction to Logic

37

“there are at most two elements”: ∀x∀y∀z(x = y ∨ y = z ∨ x = z) W “there are at most n elements”: µn = ∀x0 ∀x1 ∀xn ( xi = xj ) i6=j

“there is exactly n elements” : there are at least n elements, and at most n elements: (λn ∧ µn )

EALING 2005

´ e P. Egr´

Introduction to Logic

38

Some stars are blue : ∃x(S(x) ∧ B(x)) (At least) two stars are blue : ∃x∃y(6= x = y ∧ S(x) ∧ S(y) ∧ B(x) ∧ B(y)) Can we express that: “infinitely many stars are blue”? • Consider the following theory (set of sentences): T = {λn ; n ≥ 2} “there is at least two elements” “there is at least three elements” .. . • T has only infinite models. Suppose it has a finite model M . Let k be the size of the domain. Since M satisfies all sentences of T , M |= λk+1 : contradiction. EALING 2005

´ e P. Egr´

Introduction to Logic

39

A finite number of Existential quantification: some Finite cardinality quantification : at least n, at most n, exactly n. Infinite cardinality: infinitely many (but note that we expressed it by means of an infinite set of sentences). What about “there is a finite number of”? This can’t be expressed in FOL ! Why? because FOL has compactness.

EALING 2005

´ e P. Egr´

Introduction to Logic

40

Compactness Consider the sentences: F : “there are finitely many elements” F1 : “there is at least one element” F2 : “there are at least two elements” F3 : “there are at least three elements” .. . Taken together, these sentences are inconsistent: they require both that there are finitely many elements, and they entail that there are infinitely many elements. However, every finite subset of these sentences is satisfiable (why?). EALING 2005

´ e P. Egr´

Introduction to Logic

41

Compactness • We know that each Fn is expressible in FOL by the sentence λn . If F (finiteness) were expressible by a sentence φ, then the set of sentences Γ = {λn ; n ≥ 2} ∪ {φ} would not be satisfiable, while every finite subset would be : so FOL would not be compact. However... • Theorem (Compactness) If every finite set of FO-sentences of a set Γ has a model, then Γ has a model. • Corollary : finiteness is not expressible in FOL.

EALING 2005

´ e P. Egr´

Introduction to Logic

42

Further examples • Some properties of relations can be expressed in FOL: R is reflexive : ∀xR(x, x) R is symmetric : ∀x∀y(R(x, y) → R(y, x)) • Others can’t be expressed. Example : Connectedness: “for any two points x and y, there is a path leading from x to y”, ie a set of points a1 , ..., an such that xRa1 Ra2 R...Ran Ry. Proof: show that the theory saying “x and y are connected, are distinct, and there is no path of length 1 between them, no path of length 2, ...”, is consistent (use compactness).

EALING 2005

´ e P. Egr´

Introduction to Logic

43

Most (1) There are more cats than dogs (2) Most dogs are nice Neither of the sentences can be expressed within FOL. Why not? The idea is: they involve quantification over sets, not only individuals. “there are more A than B”: the set of A has more elements than the set of B. “Most A are B” means : the set of A that are B has more elements than the set of A that are not B.

EALING 2005

´ e P. Egr´

Introduction to Logic

44

Restricted quantification Some A are B : [∃x : A(x)]B(x) All A are B : [∀x : A(x)]B(x) We can define these new expressions within FOL. [∃x : A(x)]B(x) ! ∃x(A(x) ∧ B(x)) [∀x : A(x)]B(x) ! ∀x(A(x) → B(x)]

EALING 2005

´ e P. Egr´

Introduction to Logic

45

Most again Introduce a new quantifier M x : “for most x in the domain” M xP (x) : “most individuals are P ” [M x : A(x)]B(x) is true in a structure if there are more individuals that are A and B than are A and ¬B. Imagine we work with only finite structures: • Show that [M x : A(x)]B(x) cannot be paraphrased as: (a) M x(A(x) → B(x)) (b) M x(A(x) ∧ B(x)) • Show that (a) gives a weaker reading, and that (b) gives a stronger reading. EALING 2005

´ e P. Egr´

Introduction to Logic

46

Beyond FOL How to go beyond these expressive limitations? Use a more powerful logic: like Second Order Logic (SOL), in which we can quantify over properties (sets) ! Problem : we lose some nice properties. Second-order logic, for instance, is not only undecidable, but even incomplete. It is also non-compact (since it can express finiteness of a domain).

EALING 2005

´ e P. Egr´