Foundations of AI 9. Predicate Logic Syntax and Semantics, Normal - - PowerPoint PPT Presentation

foundations of ai
SMART_READER_LITE
LIVE PREVIEW

Foundations of AI 9. Predicate Logic Syntax and Semantics, Normal - - PowerPoint PPT Presentation

Foundations of AI 9. Predicate Logic Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution Wolfram Burgard & Luc De Raedt & Bernhard Nebel 1 Contents Motivation Syntax and Semantics Normal Forms


slide-1
SLIDE 1

1

Foundations of AI

  • 9. Predicate Logic

Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

Wolfram Burgard & Luc De Raedt & Bernhard Nebel

slide-2
SLIDE 2

2

Contents

  • Motivation
  • Syntax and Semantics
  • Normal Forms
  • Reduction to Propositional Logic:

Herbrand Expansion

  • Resolution & Unification
  • Closing Remarks
slide-3
SLIDE 3

3

Motivation

We can already do a lot with propositional logic. It is, however, annoying that there is no structure in the atomic propositions. Example: “All blocks are red” “There is a block A” It should follow that “A is red” But propositional logic cannot handle this. Idea: We introduce individual variables, predicates, functions, … . First-Order Predicate Logic (PL1)

slide-4
SLIDE 4

4

The Alphabet of First-Order Predicate Logic

Symbols:

  • Operators: ¬, , ., ∀, ∃, =
  • Variables: x,x1,x2,…,x’,x’’,…,y,…,z,…
  • Brackets: ( ) [ ] { }
  • Function symbols (e.g. weight( ), color( ))
  • Predicate symbols (e.g. block( ), red( ))
  • Predicate and function symbols have an arity (number of arguments).

0-ary predicate: propositional logic atoms 0-ary function: constant

  • We suppose a countable set of predicates and functions of any arity.
  • “=“ is usually not considered a predicate, but a logical symbol
slide-5
SLIDE 5

5

The Grammar of First-Order Predicate Logic (1)

Terms (represent objects): 1. Every variable is a term. 2. If t1,t2,…,tn are terms and f is an n-ary function, then f f f f (t1,t2,…,tn) is also a term. Terms without variables: ground terms. Atomic Formulae (represent statements about objects) 1. If t1,t2,…,tn are terms and P is an n-ary predicate, then P(t1,t2,…,tn) is an atomic formula. 2. If t1 and t2 are terms, then t1 = t2 is an atomic formula. Atomic formulae without variables: ground atoms.

slide-6
SLIDE 6

6

The Grammar of First-Order Predicate Logic (2)

Formulae:

  • 1. Every atomic formula is a formula.
  • 2. If ϕ and ψ are formulae and x is a variable, then

¬ϕ, ϕ.ψ, ϕψ, ϕ⇒ψ, ϕ⇔ψ, ∃xϕ and ∀xϕ are also formulae. ∀, ∃ are as strongly binding as ¬. Propositional logic is part of the PL1 language:

  • 1. Atomic formulae: only 0-ary predicates
  • 2. Neither variables nor quantifiers.
slide-7
SLIDE 7

7

Alternative Notation

ϕ ϕ&ψ ϕ•ψ ϕ,ψ ϕ|ψ ϕ;ψ ϕ+ψ ϕ→ψ ϕqψ ϕ↔ψ ϕ≡ψ (∀x )ϕ . x ϕ (∃x )ϕ x ϕ ¬ϕ ϕ.ψ ϕψ ϕ⇒ψ ϕ⇔ψ ∀x ϕ ∃x ϕ

Elsewhere Here

slide-8
SLIDE 8

8

Meaning of PL1-Formulae

Our example: ∀x[Block(x)⇒Red(x)],Block(a) For all objects x: If x is a block, then x is red and a is a block. Generally:

  • Terms are interpreted as objects.
  • Universally-quantified variables denote all objects in the

universe.

  • Existentially-quantified variables represent one of the objects

in the universe (made true by the quantified expression).

  • Predicates represent subsets of the universe.

Similar to propositional logic, we define interpretations, satisfiability, models, validity, …

slide-9
SLIDE 9

9

Semantics of PL1-Logic

Interpretation: I = …D,•I€ where D is an arbitrary, non- empty set and •I is a function that

  • maps n-ary function symbols to functions over D:

f I ∈ [Dn D]

  • maps individual constants to elements of D:

aI ∈ D

  • maps n-ary predicate symbols to relations over D:

PI ` Dn Interpretation of ground terms: (f f f f (t1,…,tn))I = f f f f I(t1

I,…,tn I)

Satisfaction of ground atoms P(t1,…,tn): I Ñ P(t1,…,tn) iff …t1

I,…,tn I€ ∈ PI

slide-10
SLIDE 10

10

Example (1)

Block(b)

  • I

Red(b) Ñ Ñ Ñ Ñ I D = RedI {d1} = BlockI … = cI d2 = bI d1 = aI {d1,…,dn | n > 1} = D

slide-11
SLIDE 11

11

Example 2

Even(succ(2))

  • I

Even(2) Ñ Ñ Ñ Ñ I {(12),(23), …} = succI {2, 4, 6, …} = EvenI

  • 2

= 2I 1 = 1I {1, 2, 3, …} = D

slide-12
SLIDE 12

12

Semantics of PL1: Variable Assignment

Set of all variables V. Function α: VD Notation: α[x/d] is the same as α up to point x. For x : α[x/d](x) = d. Interpretation of terms under I, α:

f f f f I(t1

I,α,…,tn I,α)

=

(f f f f (t1,…,tn))I,α aI

=

aI,α α(x )

=

xI,α

Satisfiability of atomic formulae:

I,α Ñ

Ñ Ñ Ñ P(t1,…,tn) iff …t1

I,α,…,tn I,α € ∈ PI

slide-13
SLIDE 13

13

Example

Block(y) Ñ Ñ Ñ Ñ I,α[y/d1] Red(x) Ñ Ñ Ñ Ñ I,α {(xd1),(y d2)} = α

slide-14
SLIDE 14

14

Semantics of PL1: Satisfiability

A formula ϕ is satisfied by an interpretation I and a variable assignment α, i.e. I,α Ñ Ñ Ñ Ñ ϕ: I,α Ñ Ñ Ñ Ñ T I,α

  • z

I,α Ñ Ñ Ñ Ñ ¬ ¬ ¬ ¬ϕ iff I,α

  • ϕ

… and all other propositional rules as well as there exists a d ∈ D with I,α[x/d] Ñ Ñ Ñ Ñ ϕ iff I,α Ñ Ñ Ñ Ñ ∃x ϕ for all d ∈ D, I,α[x/d] Ñ Ñ Ñ Ñ ϕ iff I,α Ñ Ñ Ñ Ñ ∀x ϕ …t1

I,α,…,tn I,α€ ∈ P I

iff I,α Ñ Ñ Ñ Ñ P(t1,…,tn)

slide-15
SLIDE 15

15

Example

{(x d1), (y d2)} = = = = α D = RedI {d1} = BlockI d2 = bI d1 = aI {d1,…,dn | n > 1} = D Block(a), Block(b) ∀x (Block(x) ⇒ Red(x)) = Questions: 1. I,α Ñ Ñ Ñ Ñ Block(b) ¬Block(b)? 2. I,α Ñ Ñ Ñ Ñ Block(x) ⇒ (Block(x) ¬Block(y))? 3. I,α Ñ Ñ Ñ Ñ Block(a) . Block(b)? 4. I,α Ñ Ñ Ñ Ñ ∀x (Block(x) ⇒ Red(x))? 5. I,α Ñ Ñ Ñ Ñ ?

{ }

slide-16
SLIDE 16

16

Free and Bound Variables

∀x[R( y , z ) . ∃y{¬P(y,x) R(y, z )}] Boxed appearances of y and z are free. All other appearances of x,y,z are bound. Formulae with no free variables are called closed formulae or

  • sentences. We form theories from closed formulae.

Note: With closed formulae, the concepts logical equivalence, satisfiability, and implication, etc. are not dependent on the variable assignment α (i.e. we can always ignore all variable assignments). With closed formulae, α can be left out on the left side of the model relationship symbol:

I Ñ Ñ Ñ Ñ ϕ

slide-17
SLIDE 17

17

Terminology

An interpretation I is called a model of ϕ under α if I,α Ñ Ñ Ñ Ñ ϕ A PL1 formula ϕ can, as in propositional logic, be satisfiable, unsatisfiable, falsifiable, or valid. Analogously, two formulae are logically equivalent (ϕ≡ψ), if for all I,α : I,α Ñ Ñ Ñ Ñ ϕ iff I,α Ñ Ñ Ñ Ñ ψ Note: P(x) ≡ P(y)! Logical Implication is also analogous to propositional logic. Question: How can we define derivation? /

slide-18
SLIDE 18

18

Prenex Normal Form

Because of the quantifiers, we cannot produce the CNF form of a formula directly. First step: Produce the prenex normal form quantifier prefix + (quantifier-free) Matrix ϕ: ∀x1 ∀x2 ∀x3 … ∀xn ϕ

slide-19
SLIDE 19

19

Equivalences for the Production of Prenex-Normal Form

∃x (ϕ ψ) if x not free in ψ

h

(∃xϕ) ψ ∃x (ϕ . ψ) if x not free in ψ

h

(∃xϕ) . ψ ∀x (ϕ ψ) if x not free in ψ

h

(∀xϕ) ψ ∀x¬ϕ

h

¬∃xϕ ∃x¬ϕ

h

¬∀xϕ ∃x (ϕ ψ)

h

∃xϕ ∃xψ ∀x (ϕ . ψ)

h

∀xϕ . ∀xψ ∀x (ϕ . ψ) if x not free in ψ

h

(∀xϕ) . ψ

… and propositional logic equivalents

slide-20
SLIDE 20

20

Production of Prenex Normal Form

  • 1. Eliminate ⇒ and ⇔
  • 2. Move ¬ inwards
  • 3. Move quantifiers outwards

Example: ¬∀x[(∀x P(x)) ⇒ Q(x)] ¬∀x[¬(∀x P(x)) Q(x)] ∃x [(∀x P(x)) . ¬Q(x)] and now? Solution: Renaming of variables ϕ[x/t] comes from ϕ, in which all free appearances of x in ϕ are replaced by the term t. Lemma: Let y be a variable that does not appear in ϕ. Then it holds that ∀xϕ h ∀yϕ[x/y] and ∃xϕ h ∃yϕ[x/y]. Theorem: There exists an algorithm that calculates the prenex normal form of any formula.

slide-21
SLIDE 21

21

Derivation in PL1

Why is prenex normal form useful? Unfortunately, there is no simple law as in propositional logic that allows us to determine satisfiability or general validity (by transformation into DNF or CNF). But: We can reduce the satisfiability problem in predicate logic to the satisfiability problem in propositional logic. In general, however, this produces a very large number of propositional formulae (perhaps infinitely many) Then: Apply resolution.

slide-22
SLIDE 22

22

Skolemization

Idea: Elimination of existential quantifiers by applying a function that produces the “right” element. Theorem (Skolem Normal Form): Let ϕ be a closed formula in prenex normal form such that all quantified variables are pair-wise distinct and the function symbols g1,g2,… do not appear in ϕ. Let ϕ = ∀x1 … ∀xi ∃yψ, then ϕ is satisfiable iff ϕ’ = ∀x1 … ∀xi ψ[y/gi(x1, …, xi)] is satisfiable. Example: ∀x ∃y [P(x) ⇒ Q(y)] ∀x [P(x) ⇒ Q(g(x))]

slide-23
SLIDE 23

23

Skolem Normal Form

Skolem Normal Form: Prenex normal form without existential quantifiers. Notation: ϕ* is the SNF of ϕ. Theorem: It is possible to calculate the skolem normal form of every closed formula ϕ ϕ ϕ ϕ. Example: ∃x ((∀x P(x)) . ¬Q(x)) develops as follows: ∃y ((∀x P(x)) . ¬Q(y)) ∃y (∀x (P(x) . ¬Q(y))) ∀x (P(x) . ¬Q(g0)) Note: This transformation is not an equivalence transformation; it only preserves satisfiability! Note: … and is not unique. Example: ∃x (p(x)) . ∀y (q(y))

slide-24
SLIDE 24

24

Ground Terms & Herbrand Expansion

The set of ground terms (or Herbrand Universe) over a set of SNF formulae θ* is the (infinite) set of all ground terms formed from the symbols of θ* (in case there is no constant symbol, one is added). This set is denoted by D(θ*) The Herbrand expansion E(θ*) is the instantiation of the Matrix ψi of all formulae in θ* through all terms t ∈D(θ*): E(θ*)={ψi[x1/t1,…, xn/tn] | (∀ x1,…, xnψi) ∈ θ*, tj ∈D(θ*)} Theorem (Herbrand): Let θ* be a set of formulae in SNF. Then θ* is satisfiable iff E(θ*) is satisfiable. Note: If D(θ*) and θ* are finite, then the Herbrand expansion is finite finite propositional logic theory. Note: This is used heavily in AI and works well most of the time!

slide-25
SLIDE 25

25

Infinite Propositional Logic Theories

Can a finite proof exist when the set is infinite? Theorem (compactness of propositional logic): A (countable) set of formulae of propositional logic is satisfiable if and only if every finite subset is satisfiable. Corollary: A (countable) set of formulae in propositional logic is unsatisfiable if and only if a finite subset is unsatisfiable. Corollary: (compactness of PL1): A (countable) set of formulae in predicate logic is satisfiable if and only if every finite subset is satisfiable.

slide-26
SLIDE 26

26

Recursive Enumeration and Decidability

We can construct a semi-decision procedure for validity, i.e. we can give a (rather inefficient) algorithm that enumerates all valid formulae step by step. Theorem: The set of valid (and unsatisfiable) formulae in PL1 is recursively enumerable. What about satisfiable formulae? Theorem (undecidability of PL1): It is undecidable, whether a formula of PL1 is valid. (Proof by reduction from PCP) Corollary: The set of satisfiable formulae in PL1 is not recursively enumerable. In other words: If a formula is valid, we can effectively confirm this fact. Otherwise, we can end up in an infinite loop.

slide-27
SLIDE 27

27

Derivation in PL1

Clausal Form instead of Herbrand Expansion Clauses are universally quantified disjunctions of literals; all variables are universally quantified 1 1 1 1

( ,..., )( ... ) written as ...

  • r

{ ,..., }

n n n n

x x l l l l l l ∀ ∨ ∨ ∨ ∨

slide-28
SLIDE 28

28

Production of Clausal Form from SNF

Skolem Normal Form

quantifier prefix + (quantifier-free) Matrix ϕ:

∀x1 ∀x2 ∀x3 … ∀xn ϕ

  • 1. Put Matrix into CNF

– Use distribution rule

  • 2. Eliminate universal quantifiers
  • 3. Eliminate conjunction symbol
  • 4. Rename variables so that no variable appears in

more than one clause. Theorem: It is possible to calculate the clausal form

  • f every closed formula ϕ

ϕ ϕ ϕ. Note: same remarks as for SNF

slide-29
SLIDE 29

29

Clauses and Resolution

Assumption: All formulae in the KB are clauses. Equivalently, we can assume that the KB is a set of clauses. Due to commutativity, associativity, and idempotence of , clauses can also be understood as sets of literals. The empty set of literals is denoted by . Set of clauses: ∆ ∆ ∆ ∆ Set of literals: C, D Literal:

  • Negation of a literal:
slide-30
SLIDE 30

30

Propositional Resolution

C1 ∪ C2 C1 ∪ {

  • }, C2 ∪ {
  • }

C1 ∪ C2 is the resolvent of the parent clauses C1 ∪ {

  • } and C2 ∪ {
  • }.
  • and
  • are the resolution

literals. Example: {a,b,¬c} resolves with {a,d,c} to {a,b,d}. Note: The resolvent is not equivalent to the parent clauses, but it follows from them! Notation: R(∆ ∆ ∆ ∆) = ∆ ∆ ∆ ∆ ∪ {C | C is a resolvent of two clauses from ∆ ∆ ∆ ∆}

slide-31
SLIDE 31

31

What changes ?

Examples We need unification, a way to make literals identical Based on the notion of substitution, e.g. {x/A}

d d d {{Nat(s(A)),¬Nat(A)} ,{Nat(A)}} {Nat(s(A))} {{Nat(s(A)),¬Nat(x)} ,{Nat(A)}} {Nat(s(A))} {{Nat(s(x)),¬Nat(x)} ,{Nat(A)}} {Nat(s(A))}

slide-32
SLIDE 32

32

Substitutions

ϕ ϕ ϕ =

1 1

A { / ,..., / } substitutes variables for terms ( does NOT contain ) Applying a to an expression yields the expression substitutio which n sub is with all occurrenc st es o itution f

n n i i i i

s v t v t v t t v s s replaced by

i i

v t

slide-33
SLIDE 33

33

Substitution Examples

P(x,f(y),B) P(z,f(w),B) s={x/z,y/w} P(x,f(A),B) s={y/A} P(g(z),f(A),B) s={x/g(z),y/A} P(C,f(A),A) no substitution !

slide-34
SLIDE 34

34

Composing substitutions

Composing substitutions s1 and s2 gives s1 s2 which is that substitution obtained by first applying s2 to the terms in s1and adding remaining term/vars pairs (not occurring in s1) to s1 Apply to

{z/g(x,y)}{x/A,y/B,w/C,z/D}= {z/g(A,B),x/A,y/B,w/C}

P(x,y,z) P(A,B,g(A,B))  →

slide-35
SLIDE 35

35

Properties of substitutions

ϕ ϕ ϕ = = ≠

1 2 1 2 1 2 1 2 3 1 2 3 1 2 2 1

For a formula and substitutions , ( ) ( ) ( ) ( ) associativity not commutative s s s s s s s s s s s s s s s s Property

slide-36
SLIDE 36

36

Unification

Unifying a set of expressions {wi}

Find substitution s such that Example The most general unifier, the mgu, g of {wi} has the property that if s is any unifier of {wi} then there exists a substitution s’ such that {wi}s={wi}gs’ Property The common instance produced is unique up to alphabetic variants (variable renaming)

for all ,

i j

w s w s i j =

{P(x,f(y),B),P(x,f(B),B)} s={y/B,s/A} not the simplest unifier s={y/B} most general unifier (mgu)

slide-37
SLIDE 37

37

Subsumption lattice

slide-38
SLIDE 38

38

Disagreement set

The disagreement set of a set of expressions {wi} is the set of subterms { ti } of {wi} at the first position in {wi} for which the {wi} disagree

Example

{P(x,A,f(y)),P(w,B,z)} gives {x,w} {P(x,A,f(y)),P(x,B,z)} gives {A,B} {P(x,y,f(y)),P(x,B,z)} gives {y,B}

slide-39
SLIDE 39

39

Unification algorithm

{P(x,A, f(y)),P(w,B, z)} {P(x,A, f(y)),P(x,B, z)} {P(x,y,f(y)),P(x,B, z)}

( ) Initialize 0; Initialize ; Initialize {}; * If is a singleton, then output . Otherwise, continue. Let be the disagreement set of If there exists a var and Uni a term y f

k k k k k k k k

Terms k T Terms T D T v t σ σ ← = =

1 1

in D such that does not occur in , continue. Otherwise, exit with failure. { / }; { / }; 1; Goto *

k k k k k k k k k k k

v t v t T T v t k k σ σ

+ +

← ← ← +

{P(x,f(y),y),P(z,f(B),B)}

slide-40
SLIDE 40

40

Binary Resolution

[C1 ∪ C2]s C1 ∪ {

  • 1 }, C2 ∪ {
  • 2 }

where s=mgu(

  • 1 ,
  • 2 ), the most general unifier

[C1 ∪ C2]s is the resolvent of the parent clauses C1 ∪ {

  • 1 } and C2 ∪ {
  • 2 }

C1 ∪ {

  • 1 } and C2 ∪ {
  • 2 } do not share variables
  • 1 and
  • 2 are the resolution literals.

Examples:

– –

d d d {{Nat(s(A)),¬Nat(A)} ,{Nat(A)}} {Nat(s(A))} {{Nat(s(A)),¬Nat(x)} ,{Nat(A)}} {Nat(s(A))} {{Nat(s(x)),¬Nat(x)} ,{Nat(A)}} {Nat(s(A))}

slide-41
SLIDE 41

41

Some further examples

θ ∨ ∨ ¬ ∨ ∨ ¬ ∨ ∨ ¬ ∨ ¬ P(x) Q(f(x)) R(g(x)) Q(f(A)) P(x) Q(f(x)) R(g(y)) Q(f(A)) {A/x} P(A) R(g(y)) P(x) Q(x,y) P(A) R(B, z) Resolve and Standardizing the variables apart gives and Substitution = Resolvent Resolve and Stand θ ∨ ¬ {A/x} Q(A,y) R(B, z) ardizing the variables apart Substitution = and Resolvent

slide-42
SLIDE 42

42

Factoring

[C ∪

  • 1 ]s

C ∪ {

  • 1 } ∪ {
  • 2 }

where s=mgu(

  • 1 ,
  • 2 ), the most general unifier

– –

{{P(u),P(v)}, {¬P(x),¬P(y)} } |= but cannot be derived by binary resolution {P(u)}and {¬P(x)} whose resolvent is Needed because Factoring yields

slide-43
SLIDE 43

43

Derivations

Notation: R(∆ ∆ ∆ ∆) = ∆ ∆ ∆ ∆ ∪ {C | C is a resolvent or a factor of two clauses from ∆ ∆ ∆ ∆} We say D can be derived from ∆, i.e. ∆ d D, If there exist C1, C2, C3, …, Cn = D such that Ci ∈ R(∆ ∪ {C1, …, Ci-1}), for 1 ≤ i ≤ n.

slide-44
SLIDE 44

44

An example

slide-45
SLIDE 45

45

Another example

slide-46
SLIDE 46

46

Properties of resolution

Lemma (soundness) If ∆ d D, then ∆ ~ D. Lemma resolution is refutation-complete: ∆ is unsatisfiable implies ∆ d . Theorem: ∆ is unsatisfiable iff ∆ d . Technique : to prove that ∆ ~ c negate c and prove that ∆ ∪ {c} d

slide-47
SLIDE 47

47

The lifting lemma

Lemma Let C1 and C2 be two clauses with no shared variables, and let C1’ and C2’ be ground instances of C1 and C2. If C’ is a resolvent of C1’ and C2’, then there exists a clause such that (1) C is a resolvent of C1 and C2 (2) C’ is a ground instance of C Can be easily generalized to derivations

slide-48
SLIDE 48

48

The general picture

slide-49
SLIDE 49

49

Closing Remarks: Processing

  • PL1-Resolution: forms the basis of

– most state of the art theorem provers for PL1 – the programming language Prolog

  • only Horn clauses
  • considerably more efficient methods.

– not dealt with : search/resolution strategies

  • Finite theories: In applications, we often have to deal

with a fixed set of objects. Domain closure axiom: ∀x[x=c1 x=c2 … x=cn]

– Translation into finite propositional theory is possible.

slide-50
SLIDE 50

50

Closing Remarks: Possible Extensions

PL1 is definitely very expressive, but in some circumstances we would like more…

  • Second-Order Logic: Also over predicate quantifiers

∀x,y [(x=y) ⇔ {∀p[p(x) ⇔ p(y)]}] Validity is no longer semi-decidable (we have lost compactness)

  • Lambda Calculus: Definition of predicates, e.g.

λx,y[∃z P(x,z) . Q(z,y)] defines a new predicate of arity 2 Reducible to PL1 through Lambda-Reduction

  • Uniqueness quantifier: ∃!xϕ(x) – there is exactly one x …

→ Reduction to PL1: ∃x [ϕ(x) . ∀y {ϕ(y) ⇒ x = y}]

slide-51
SLIDE 51

51

Summary

  • PL1 makes it possible to structure statements, thereby giving us

considerably more expressive power than propositional logic.

  • Formulae consist of terms and atomic formulae, which,

together with connectors and quantifiers, can be put together to produce formulae.

  • Interpretations in PL1 consist of a universe and an

interpretation function.

  • The Herbrand Theory shows that satisfiability in PL1 can be

reduced to satisfiability in propositional logic (although infinite sets of formulae can arise under certain circumstances).

  • Resolution is refutation complete
  • Validity in PL1 is not decidable (it is only semi-decidable)