• Keine Ergebnisse gefunden

9. Predicate Logic

N/A
N/A
Protected

Academic year: 2021

Aktie "9. Predicate Logic"

Copied!
51
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Foundations of AI

9. Predicate Logic

Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

Wolfram Burgard & Luc De Raedt & Bernhard Nebel

(2)

Contents

• Motivation

• Syntax and Semantics

• Normal Forms

• Reduction to Propositional Logic:

Herbrand Expansion

• Resolution & Unification

• Closing Remarks

(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)

(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

(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.

(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.

(7)

Alternative Notation

~ ϕ ϕ

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

¬ϕ ϕ . ψ ϕ - ψ ϕ ⇒ ψ ϕ⇔ψ

x ϕ

x ϕ

Elsewhere Here

(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, …

(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

∈ [D

n

D]

• maps individual constants to elements of D:

a

I

∈ D

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

P

I

` D

n

Interpretation of ground terms:

(f f f f (t

1

,…,t

n

))

I

= f f f f

I

(t

1 I

,…,t

n I

) Satisfaction of ground atoms P(t

1

,…,t

n

):

I Ñ P(t

1

,…,t

n

) iff …t

1 I

,…,t

n I

€ ∈ P

I

(10)

Example (1)

Block(b) U

U U I U

Red(b) Ñ

Ñ Ñ I Ñ

D

= Red

I

{d

1

}

= Block

I

= c

I

d

2

= b

I

d

1

= a

I

{d

1

,…,d

n

| n > 1}

=

D

(11)

Example 2

Even(succ(2)) U

U U I U

Even(2) Ñ

Ñ Ñ I Ñ

{( 1 2 ),( 2 3 ), …}

= succ

I

{ 2, 4, 6, …}

= Even

I

§

§

§

§

= 2 2

I

= 1 1

I

{ 1, 2, 3 , …}

=

D

(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

(t

1 I,α

,…,t

n I,α

) (f f f f (t

1

,…,t

n

))

I,α

=

a

I

a

I,α

=

α (x ) x

I,α

=

Satisfiability of atomic formulae:

I , α Ñ Ñ Ñ Ñ P(t

1

,…,t

n

) iff …t

1 I,α

,…,t

n I,α

€ ∈ P

I

(13)

Example

Block(y) Ñ

Ñ Ñ I , α[ y/d

1

] Ñ

Red(x) Ñ

Ñ Ñ I , α Ñ

{(x d

1

),(y d

2

)}

α =

(14)

Semantics of PL1:

Satisfiability

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

I , α Ñ Ñ Ñ Ñ T I , α U U U U z

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

and all other propositional rules as well as

there exists a dD with I , α[ x/d] Ñ Ñ Ñ Ñ ϕ I , α Ñ Ñ Ñ Ñ ∃ x ϕ iff

for all dD, I , α[ x/d] Ñ Ñ Ñ Ñ ϕ I , α Ñ Ñ Ñ Ñ ∀ x ϕ iff

…t

1 I,α

,…,t

n I,α

€ ∈ P

I

iff

I , α Ñ Ñ Ñ Ñ P(t

1

,…,t

n

)

(15)

Example

{(x x d1), (y x 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,α ÑÑÑÑ ?

{ }

(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 Ñ Ñ Ñ Ñ ϕ

(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?

/

(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 ϕ :

∀ x

1

∀ x

2

∀ x3 … ∀ x

n

ϕ

(19)

Equivalences for the

Production of Prenex-Normal Form

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

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

∀x (ϕ - ψ) if x not free in ψ (∀xϕ) - ψ h

∀x¬ϕ

¬∃xϕ h

∃x¬ϕ

¬∀xϕ h

∃x (ϕ - ψ)

∃xϕ - ∃xψ h

∀x (ϕ . ψ)

∀xϕ . ∀xψ h

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

… and propositional logic equivalents

(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

(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.

(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 g

1

,g

2

,… do not appear in ϕ . Let

ϕ = ∀ x

1

… ∀ x

i

∃ y ψ , then ϕ is satisfiable iff

ϕ ’ = ∀ x

1

… ∀ x

i

ψ [y/g

i

(x

1

, …, x

i

)]

is satisfiable.

Example: ∀ x ∃ y [P(x) ⇒ Q(y)] ∀ x [P(x) ⇒ Q(g(x))]

(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(g

0

))

Note: This transformation is not an equivalence transformation; it only preserves satisfiability!

Note: … and is not unique.

Example: ∃ x (p(x)) . ∀ y (q(y))

(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.

(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.

(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.

(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 ... or

{ ,..., }

n n

n

n

x x l l

l l

l l

∀ ∨ ∨

∨ ∨

(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 of every closed formula ϕϕϕϕ .

Note: same remarks as for SNF

(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: ¥

´´´´

(30)

Propositional Resolution

C

1

∪ C

2

C

1

∪ { ´´´´ }, C

2

∪ { ¥ ´´´´ }

C

1

∪ C

2

is the resolvent of the parent clauses C

1

∪ { ´´´´ } and C

2

∪ { ´´´´ }. ´´´´ 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 ∆∆∆∆ }

(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))}

(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 v

i

t

i

(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 !

(34)

Composing substitutions

Composing substitutions s

1

and s

2

gives s

1

s

2

which is that substitution obtained by first applying s

2

to the terms in s

1

and

adding remaining term/vars pairs (not occurring in s

1

) to s

1

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))

(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

(36)

Unification

Unifying a set of expressions {w

i

}

Find substitution s such that Example

The most general unifier, the mgu, g of {w

i

} has the

property that if s is any unifier of {w

i

} then there exists a substitution s’ such that {w

i

}s={w

i

}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)

(37)

Subsumption lattice

(38)

Disagreement set

The disagreement set of a set of expressions {w

i

} is the set of

subterms { t

i

} of {w

i

} at the first position in {w

i

} for which the {w

i

} 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}

(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)}

(40)

Binary Resolution

[C

1

∪ C

2

]s C

1

∪ { ´´´´

1

}, C

2

∪ { ¥ ´´´´

2

}

where s=mgu( ´´´´

1

, ´´´´

2

), the most general unifier

[C

1

∪ C

2

]s is the resolvent of the parent clauses C

1

∪ { ´´´´

1

} and C

2

∪ { ¥ ´´´´

2

} C

1

∪ { ´´´´

1

} and C

2

∪ { ¥ ´´´´

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))}

(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

(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

(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 C

1

, C

2

, C

3

, …, C

n

= D such that

C

i

R( ∆ ∪ {C

1

, …, C

i-1

}), for 1 i n.

(44)

An example

¥

(45)

Another example

(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

(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

(48)

The general picture

(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=c

1

- x=c

2

- … - x=c

n

]

– Translation into finite propositional theory is possible.

(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}]

(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)

Referenzen

ÄHNLICHE DOKUMENTE

CONTINUITY OF TRANSLATION AND SEPARABLE INVARIANT SUBSPACES OF BANACH SPACES ASSOCIATED TO LOCALLY COMPACT GROUPS1. Colin Graham1, Anthony To—Ming Lau2,

While in the Cournot model subjects best respond to the opponent’s play in the very last period, players in a pure …ctitious-play model best respond to beliefs based on all

Give a classification (with proof) of the primes of this form, and then examine (in terms of the prime factors of n) which integers n are of this form.. Hand in solutions to

Handin Please submit this homework until Thursday, November 29, either via email to Philipp Schuster (philipp.schuster@uni-tuebingen.de) before 12:00, or on paper at the beginning

They have also shown that the transformation to linkless normal form involves only a singly-exponential blowup in concept size and that subsumption can be carried out in linear

If subjects have a consistent and stable theory of the mind of their opponents, then they should report similar beliefs and choose equivalent actions in different instances of the

The distribution of the arithmetic average of log-normal variables and exact pricing of the arithmetic Asian options: A simple,..

Mathematische Grundlagen der Informatik RWTH