introduction to articial intelligence first-order logic

63
Introduction to Artificial Intelligence First-order Logic (Logic, Deduction, Knowledge Representation) Bernhard Beckert U NIVERSITÄT KOBLENZ -L ANDAU Winter Term 2004/2005 B. Beckert: KI für IM – p.1

Upload: others

Post on 23-Nov-2021

16 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Articial Intelligence First-order Logic

Introduction to Artificial Intelligence

First-order Logic

(Logic, Deduction, Knowledge Representation)

Bernhard Beckert

UNIVERSITÄT KOBLENZ-LANDAU

Winter Term 2004/2005

B. Beckert: KI für IM – p.1

Page 2: Introduction to Articial Intelligence First-order Logic

Outline

Why first-order logic?

Syntax and semantics of first-order logic

Fun with sentences

Wumpus world in first-order logic

B. Beckert: KI für IM – p.2

Page 3: Introduction to Articial Intelligence First-order Logic

Pros and Cons of Propositional Logic

Propositional logic is declarative:pieces of syntax correspond to facts

Propositional logic allows partial / disjunctive / negated information(unlike most data structures and databases)

Propositional logic is compositional:meaning of B1,1 ∧P1,2 is derived from meaning of B1,1 and of P1,2

Meaning in propositional logic is context-independent(unlike natural language, where meaning depends on context)

Propositional logic has very limited expressive power(unlike natural language)

Example:Cannot say “pits cause breezes in adjacent squares”except by writing one sentence for each square

B. Beckert: KI für IM – p.3

Page 4: Introduction to Articial Intelligence First-order Logic

Pros and Cons of Propositional Logic

Propositional logic is declarative:pieces of syntax correspond to facts

Propositional logic allows partial / disjunctive / negated information(unlike most data structures and databases)

Propositional logic is compositional:meaning of B1,1 ∧P1,2 is derived from meaning of B1,1 and of P1,2

Meaning in propositional logic is context-independent(unlike natural language, where meaning depends on context)

Propositional logic has very limited expressive power(unlike natural language)

Example:Cannot say “pits cause breezes in adjacent squares”except by writing one sentence for each square

B. Beckert: KI für IM – p.3

Page 5: Introduction to Articial Intelligence First-order Logic

Pros and Cons of Propositional Logic

Propositional logic is declarative:pieces of syntax correspond to facts

Propositional logic allows partial / disjunctive / negated information(unlike most data structures and databases)

Propositional logic is compositional:meaning of B1,1 ∧P1,2 is derived from meaning of B1,1 and of P1,2

Meaning in propositional logic is context-independent(unlike natural language, where meaning depends on context)

Propositional logic has very limited expressive power(unlike natural language)

Example:Cannot say “pits cause breezes in adjacent squares”except by writing one sentence for each square

B. Beckert: KI für IM – p.3

Page 6: Introduction to Articial Intelligence First-order Logic

Pros and Cons of Propositional Logic

Propositional logic is declarative:pieces of syntax correspond to facts

Propositional logic allows partial / disjunctive / negated information(unlike most data structures and databases)

Propositional logic is compositional:meaning of B1,1 ∧P1,2 is derived from meaning of B1,1 and of P1,2

Meaning in propositional logic is context-independent(unlike natural language, where meaning depends on context)

Propositional logic has very limited expressive power(unlike natural language)

Example:Cannot say “pits cause breezes in adjacent squares”except by writing one sentence for each square

B. Beckert: KI für IM – p.3

Page 7: Introduction to Articial Intelligence First-order Logic

Pros and Cons of Propositional Logic

Propositional logic is declarative:pieces of syntax correspond to facts

Propositional logic allows partial / disjunctive / negated information(unlike most data structures and databases)

Propositional logic is compositional:meaning of B1,1 ∧P1,2 is derived from meaning of B1,1 and of P1,2

Meaning in propositional logic is context-independent(unlike natural language, where meaning depends on context)

Propositional logic has very limited expressive power(unlike natural language)

Example:Cannot say “pits cause breezes in adjacent squares”except by writing one sentence for each square

B. Beckert: KI für IM – p.3

Page 8: Introduction to Articial Intelligence First-order Logic

First-order Logic

Propositional logic

Assumes that the world contains facts

First-order logic

Assumes that the world contains

Objectspeople, houses, numbers, theories, Donald Duck, colors, centuries, . . .

Relationsred, round, prime, multistoried, . . .

brother of, bigger than, part of, has color, occurred after, owns, . . .

Functions+, middle of, father of, one more than, beginning of, . . .

B. Beckert: KI für IM – p.4

Page 9: Introduction to Articial Intelligence First-order Logic

First-order Logic

Propositional logic

Assumes that the world contains facts

First-order logic

Assumes that the world contains

Objectspeople, houses, numbers, theories, Donald Duck, colors, centuries, . . .

Relationsred, round, prime, multistoried, . . .

brother of, bigger than, part of, has color, occurred after, owns, . . .

Functions+, middle of, father of, one more than, beginning of, . . .

B. Beckert: KI für IM – p.4

Page 10: Introduction to Articial Intelligence First-order Logic

First-order Logic

Propositional logic

Assumes that the world contains facts

First-order logic

Assumes that the world contains

Objectspeople, houses, numbers, theories, Donald Duck, colors, centuries, . . .

Relationsred, round, prime, multistoried, . . .

brother of, bigger than, part of, has color, occurred after, owns, . . .

Functions+, middle of, father of, one more than, beginning of, . . .

B. Beckert: KI für IM – p.4

Page 11: Introduction to Articial Intelligence First-order Logic

First-order Logic

Propositional logic

Assumes that the world contains facts

First-order logic

Assumes that the world contains

Objectspeople, houses, numbers, theories, Donald Duck, colors, centuries, . . .

Relationsred, round, prime, multistoried, . . .

brother of, bigger than, part of, has color, occurred after, owns, . . .

Functions+, middle of, father of, one more than, beginning of, . . .

B. Beckert: KI für IM – p.4

Page 12: Introduction to Articial Intelligence First-order Logic

Syntax of First-order Logic: Basic Elements

Symbols

Constants KingJohn, 2, Koblenz, C, . . .

Predicates Brother, >, =, . . .

Functions Sqrt, LeftLegOf , . . .

Variables x, y, a, b, . . .

Connectives ∧ ∨ ¬ ⇒ ⇔

Quantifiers ∀ ∃

Note

The equality predicate is always in the vocabularyIt is written in infix notation

B. Beckert: KI für IM – p.5

Page 13: Introduction to Articial Intelligence First-order Logic

Syntax of First-order Logic: Basic Elements

Symbols

Constants KingJohn, 2, Koblenz, C, . . .

Predicates Brother, >, =, . . .

Functions Sqrt, LeftLegOf , . . .

Variables x, y, a, b, . . .

Connectives ∧ ∨ ¬ ⇒ ⇔

Quantifiers ∀ ∃

Note

The equality predicate is always in the vocabularyIt is written in infix notation

B. Beckert: KI für IM – p.5

Page 14: Introduction to Articial Intelligence First-order Logic

Syntax of First-order Logic: Atomic Sentences

Atomic sentence

predicate ( term1, . . . , termn )

or

term1 = term2

Term

function ( term1, . . . , termn )

or

constant

or

variable

B. Beckert: KI für IM – p.6

Page 15: Introduction to Articial Intelligence First-order Logic

Syntax of First-order Logic: Atomic Sentences

Atomic sentence

predicate ( term1, . . . , termn )

or

term1 = term2

Term

function ( term1, . . . , termn )

or

constant

or

variable

B. Beckert: KI für IM – p.6

Page 16: Introduction to Articial Intelligence First-order Logic

Syntax of First-order Logic: Atomic Sentences

Example

Brother ( KingJohn, RichardTheLionheart )

B. Beckert: KI für IM – p.7

Page 17: Introduction to Articial Intelligence First-order Logic

Syntax of First-order Logic: Atomic Sentences

Example

Brother︸ ︷︷ ︸

predicate

( KingJohn︸ ︷︷ ︸

constant

, RichardTheLionheart︸ ︷︷ ︸

constant

)

B. Beckert: KI für IM – p.7

Page 18: Introduction to Articial Intelligence First-order Logic

Syntax of First-order Logic: Atomic Sentences

Example

Brother︸ ︷︷ ︸

predicate

( KingJohn︸ ︷︷ ︸

constant︸ ︷︷ ︸

term

, RichardTheLionheart︸ ︷︷ ︸

constant︸ ︷︷ ︸

term

)

B. Beckert: KI für IM – p.7

Page 19: Introduction to Articial Intelligence First-order Logic

Syntax of First-order Logic: Atomic Sentences

Example

Brother︸ ︷︷ ︸

predicate

( KingJohn︸ ︷︷ ︸

constant︸ ︷︷ ︸

term

, RichardTheLionheart︸ ︷︷ ︸

constant︸ ︷︷ ︸

term

)

︸ ︷︷ ︸

atomic sentence

B. Beckert: KI für IM – p.7

Page 20: Introduction to Articial Intelligence First-order Logic

Syntax of First-order Logic: Atomic Sentences

Example

> ( Length(LeftLegOf (Richard)), Length(LeftLegOf (KingJohn)) )

B. Beckert: KI für IM – p.8

Page 21: Introduction to Articial Intelligence First-order Logic

Syntax of First-order Logic: Atomic Sentences

Example

>︸ ︷︷ ︸

predicate

( Length︸ ︷︷ ︸

function

(LeftLegOf︸ ︷︷ ︸

function

(Richard︸ ︷︷ ︸

constant

)), Length︸ ︷︷ ︸

function

(LeftLegOf︸ ︷︷ ︸

function

(KingJohn︸ ︷︷ ︸

constant

)) )

B. Beckert: KI für IM – p.8

Page 22: Introduction to Articial Intelligence First-order Logic

Syntax of First-order Logic: Atomic Sentences

Example

>︸︷︷︸

predicate

( Length︸ ︷︷ ︸

function

(LeftLegOf︸ ︷︷ ︸

function

(Richard︸ ︷︷ ︸

constant

))

︸ ︷︷ ︸

term

, Length︸ ︷︷ ︸

function

(LeftLegOf︸ ︷︷ ︸

function

(KingJohn︸ ︷︷ ︸

constant

))

︸ ︷︷ ︸

term

)

B. Beckert: KI für IM – p.8

Page 23: Introduction to Articial Intelligence First-order Logic

Syntax of First-order Logic: Atomic Sentences

Example

>︸︷︷︸

predicate

( Length︸ ︷︷ ︸

function

(LeftLegOf︸ ︷︷ ︸

function

(Richard︸ ︷︷ ︸

constant

))

︸ ︷︷ ︸

term

, Length︸ ︷︷ ︸

function

(LeftLegOf︸ ︷︷ ︸

function

(KingJohn︸ ︷︷ ︸

constant

))

︸ ︷︷ ︸

term

)

︸ ︷︷ ︸

atomic sentence

B. Beckert: KI für IM – p.8

Page 24: Introduction to Articial Intelligence First-order Logic

Syntax of First-order Logic: Complex Sentences

Built from atomic sentences using connectives

¬S S1 ∧S2 S1 ∨S2 S1 ⇒ S2 S1 ⇔ S2

(as in propositional logic)

Example

B. Beckert: KI für IM – p.9

Page 25: Introduction to Articial Intelligence First-order Logic

Syntax of First-order Logic: Complex Sentences

Built from atomic sentences using connectives

¬S S1 ∧S2 S1 ∨S2 S1 ⇒ S2 S1 ⇔ S2

(as in propositional logic)

Example

Sibling( KingJohn,Richard ) ⇒ Sibling( Richard,KingJohn )

B. Beckert: KI für IM – p.9

Page 26: Introduction to Articial Intelligence First-order Logic

Syntax of First-order Logic: Complex Sentences

Built from atomic sentences using connectives

¬S S1 ∧S2 S1 ∨S2 S1 ⇒ S2 S1 ⇔ S2

(as in propositional logic)

Example

Sibling︸ ︷︷ ︸

predicate

( KingJohn︸ ︷︷ ︸

term

,Richard︸ ︷︷ ︸

term

) ⇒ Sibling︸ ︷︷ ︸

predicate

( Richard︸ ︷︷ ︸

term

,KingJohn︸ ︷︷ ︸

term

)

B. Beckert: KI für IM – p.9

Page 27: Introduction to Articial Intelligence First-order Logic

Syntax of First-order Logic: Complex Sentences

Built from atomic sentences using connectives

¬S S1 ∧S2 S1 ∨S2 S1 ⇒ S2 S1 ⇔ S2

(as in propositional logic)

Example

Sibling︸ ︷︷ ︸

predicate

( KingJohn︸ ︷︷ ︸

term

,Richard︸ ︷︷ ︸

term

)

︸ ︷︷ ︸

atomic sentence

⇒ Sibling︸ ︷︷ ︸

predicate

( Richard︸ ︷︷ ︸

term

,KingJohn︸ ︷︷ ︸

term

)

︸ ︷︷ ︸

atomic sentence

B. Beckert: KI für IM – p.9

Page 28: Introduction to Articial Intelligence First-order Logic

Syntax of First-order Logic: Complex Sentences

Built from atomic sentences using connectives

¬S S1 ∧S2 S1 ∨S2 S1 ⇒ S2 S1 ⇔ S2

(as in propositional logic)

Example

Sibling︸ ︷︷ ︸

predicate

( KingJohn︸ ︷︷ ︸

term

,Richard︸ ︷︷ ︸

term

)

︸ ︷︷ ︸

atomic sentence

⇒ Sibling︸ ︷︷ ︸

predicate

( Richard︸ ︷︷ ︸

term

,KingJohn︸ ︷︷ ︸

term

)

︸ ︷︷ ︸

atomic sentence︸ ︷︷ ︸

complex sentence

B. Beckert: KI für IM – p.9

Page 29: Introduction to Articial Intelligence First-order Logic

Semantics in First-order Logic

Models of first-order logic

Sentences are true or false with respect to models, which consist of

– a domain (also called universe)– an interpretation

Domain

A non-empty (finite or infinite) set of arbitrary elements

Interpretation

Assigns to each

– constant symbol: a domain element

– predicate symbol: a relation on the domain (of appropriate arity)

– function symbol: a function on the domain (of appropriate arity)

B. Beckert: KI für IM – p.10

Page 30: Introduction to Articial Intelligence First-order Logic

Semantics in First-order Logic

Models of first-order logic

Sentences are true or false with respect to models, which consist of

– a domain (also called universe)– an interpretation

Domain

A non-empty (finite or infinite) set of arbitrary elements

Interpretation

Assigns to each

– constant symbol: a domain element

– predicate symbol: a relation on the domain (of appropriate arity)

– function symbol: a function on the domain (of appropriate arity)

B. Beckert: KI für IM – p.10

Page 31: Introduction to Articial Intelligence First-order Logic

Semantics in First-order Logic

Models of first-order logic

Sentences are true or false with respect to models, which consist of

– a domain (also called universe)– an interpretation

Domain

A non-empty (finite or infinite) set of arbitrary elements

Interpretation

Assigns to each

– constant symbol: a domain element

– predicate symbol: a relation on the domain (of appropriate arity)

– function symbol: a function on the domain (of appropriate arity)B. Beckert: KI für IM – p.10

Page 32: Introduction to Articial Intelligence First-order Logic

Semantics in First-order Logic

Definition

An atomic sentence

predicate ( term1, . . . , termn )

is true in a certain model (that consists of a domain and an interpretation)

iff

the domain elements that are the interpretations of term1, . . . , termn

are in the relation that is the interpretation of predicate

The truth value of a complex sentence in a modelis computed from the truth-values of its atomic sub-sentencesin the same way as in propositional logic

B. Beckert: KI für IM – p.11

Page 33: Introduction to Articial Intelligence First-order Logic

Semantics in First-order Logic

Definition

An atomic sentence

predicate ( term1, . . . , termn )

is true in a certain model (that consists of a domain and an interpretation)

iff

the domain elements that are the interpretations of term1, . . . , termn

are in the relation that is the interpretation of predicate

The truth value of a complex sentence in a modelis computed from the truth-values of its atomic sub-sentencesin the same way as in propositional logic

B. Beckert: KI für IM – p.11

Page 34: Introduction to Articial Intelligence First-order Logic

Models for First-order Logic: Example

Constants: KingJohn, Richard

Predicates: person, king, crown

Functions: brother, on_head, left_leg

B. Beckert: KI für IM – p.12

Page 35: Introduction to Articial Intelligence First-order Logic

Universal Quantification: Syntax

Syntax

∀ variables sentence

Example

“Everyone studying in Koblenz is smart:

∀ x︸︷︷︸

variables

(StudiesAt(x,Koblenz) ⇒ Smart(x))︸ ︷︷ ︸

sentence

B. Beckert: KI für IM – p.13

Page 36: Introduction to Articial Intelligence First-order Logic

Universal Quantification: Syntax

Syntax

∀ variables sentence

Example

“Everyone studying in Koblenz is smart:

∀ x︸︷︷︸

variables

(StudiesAt(x,Koblenz) ⇒ Smart(x))︸ ︷︷ ︸

sentence

B. Beckert: KI für IM – p.13

Page 37: Introduction to Articial Intelligence First-order Logic

Universal Quantification: Semantics

Semantics

∀xP is true in a model

iff

for all domain elements d in the model:P is true in the model when x is interpreted by d

Intuition

∀xP is roughly equivalent to the conjunction of all instances of P

Example ∀ x StudiesAt(x,Koblenz) ⇒ Smart(x) equivalent to:

StudiesAt(KingJohn,Koblenz) ⇒ Smart(KingJohn)

∧ StudiesAt(Richard,Koblenz) ⇒ Smart(Richard)

∧ StudiesAt(Koblenz,Koblenz) ⇒ Smart(Koblenz)

∧ . . .

B. Beckert: KI für IM – p.14

Page 38: Introduction to Articial Intelligence First-order Logic

Universal Quantification: Semantics

Semantics

∀xP is true in a model

iff

for all domain elements d in the model:P is true in the model when x is interpreted by d

Intuition

∀xP is roughly equivalent to the conjunction of all instances of P

Example ∀ x StudiesAt(x,Koblenz) ⇒ Smart(x) equivalent to:

StudiesAt(KingJohn,Koblenz) ⇒ Smart(KingJohn)

∧ StudiesAt(Richard,Koblenz) ⇒ Smart(Richard)

∧ StudiesAt(Koblenz,Koblenz) ⇒ Smart(Koblenz)

∧ . . .

B. Beckert: KI für IM – p.14

Page 39: Introduction to Articial Intelligence First-order Logic

Universal Quantification: Semantics

Semantics

∀xP is true in a model

iff

for all domain elements d in the model:P is true in the model when x is interpreted by d

Intuition

∀xP is roughly equivalent to the conjunction of all instances of P

Example ∀ x StudiesAt(x,Koblenz) ⇒ Smart(x) equivalent to:

StudiesAt(KingJohn,Koblenz) ⇒ Smart(KingJohn)

∧ StudiesAt(Richard,Koblenz) ⇒ Smart(Richard)

∧ StudiesAt(Koblenz,Koblenz) ⇒ Smart(Koblenz)

∧ . . .B. Beckert: KI für IM – p.14

Page 40: Introduction to Articial Intelligence First-order Logic

A Common Mistake to Avoid

Note

⇒ is the main connective with ∀

Common mistake

Using ∧ as the main connective with ∀

Example

Correct: ∀x(StudiesAt(x,Koblenz) ⇒ Smart(x))

“Everyone who studies at Koblenz is smart”

Wrong: ∀x(StudiesAt(x,Koblenz) ∧ Smart(x))

“Everyone studies at Koblenz and is smart”, i.e.,

“Everyone studies at Koblenz and everyone is smart”

B. Beckert: KI für IM – p.15

Page 41: Introduction to Articial Intelligence First-order Logic

A Common Mistake to Avoid

Note

⇒ is the main connective with ∀

Common mistake

Using ∧ as the main connective with ∀

Example

Correct: ∀x(StudiesAt(x,Koblenz) ⇒ Smart(x))

“Everyone who studies at Koblenz is smart”

Wrong: ∀x(StudiesAt(x,Koblenz) ∧ Smart(x))

“Everyone studies at Koblenz and is smart”, i.e.,

“Everyone studies at Koblenz and everyone is smart”

B. Beckert: KI für IM – p.15

Page 42: Introduction to Articial Intelligence First-order Logic

A Common Mistake to Avoid

Note

⇒ is the main connective with ∀

Common mistake

Using ∧ as the main connective with ∀

Example

Correct: ∀x(StudiesAt(x,Koblenz) ⇒ Smart(x))

“Everyone who studies at Koblenz is smart”

Wrong: ∀x(StudiesAt(x,Koblenz) ∧ Smart(x))

“Everyone studies at Koblenz and is smart”, i.e.,

“Everyone studies at Koblenz and everyone is smart”

B. Beckert: KI für IM – p.15

Page 43: Introduction to Articial Intelligence First-order Logic

Existential Quantification: Syntax

Syntax

∃ variables sentence

Example

“Someone studying in Landau is smart:

∃ x︸︷︷︸

variables

(StudiesAt(x,Landau)∧Smart(x))︸ ︷︷ ︸

sentence

B. Beckert: KI für IM – p.16

Page 44: Introduction to Articial Intelligence First-order Logic

Existential Quantification: Syntax

Syntax

∃ variables sentence

Example

“Someone studying in Landau is smart:

∃ x︸︷︷︸

variables

(StudiesAt(x,Landau)∧Smart(x))︸ ︷︷ ︸

sentence

B. Beckert: KI für IM – p.16

Page 45: Introduction to Articial Intelligence First-order Logic

Existential Quantification: Semantics

Semantics

∃xP is true in a model

iff

there is a domain element d in the model such that:P is true in the model when x is interpreted by d

Intuition

∃xP is roughly equivalent to the disjunction of all instances of P

Example ∃ x StudiesAt(x,Landau)∧Smart(x) equivalent to:

StudiesAt(KingJohn,Landau)∧Smart(KingJohn)

∨ StudiesAt(Richard,Landau)∧Smart(Richard)

∨ StudiesAt(Landau,Landau)∧Smart(Landau)

∨ . . .

B. Beckert: KI für IM – p.17

Page 46: Introduction to Articial Intelligence First-order Logic

Existential Quantification: Semantics

Semantics

∃xP is true in a model

iff

there is a domain element d in the model such that:P is true in the model when x is interpreted by d

Intuition

∃xP is roughly equivalent to the disjunction of all instances of P

Example ∃ x StudiesAt(x,Landau)∧Smart(x) equivalent to:

StudiesAt(KingJohn,Landau)∧Smart(KingJohn)

∨ StudiesAt(Richard,Landau)∧Smart(Richard)

∨ StudiesAt(Landau,Landau)∧Smart(Landau)

∨ . . .

B. Beckert: KI für IM – p.17

Page 47: Introduction to Articial Intelligence First-order Logic

Existential Quantification: Semantics

Semantics

∃xP is true in a model

iff

there is a domain element d in the model such that:P is true in the model when x is interpreted by d

Intuition

∃xP is roughly equivalent to the disjunction of all instances of P

Example ∃ x StudiesAt(x,Landau)∧Smart(x) equivalent to:

StudiesAt(KingJohn,Landau)∧Smart(KingJohn)

∨ StudiesAt(Richard,Landau)∧Smart(Richard)

∨ StudiesAt(Landau,Landau)∧Smart(Landau)

∨ . . .B. Beckert: KI für IM – p.17

Page 48: Introduction to Articial Intelligence First-order Logic

Another Common Mistake to Avoid

Note

∧ is the main connective with ∃

Common mistake

Using ⇒ as the main connective with ∃

Example

Correct: ∃x(StudiesAt(x,Landau) ∧ Smart(x))

“There is someone who studies at Landau and is smart”

Wrong: ∃x(StudiesAt(x,Landau) ⇒ Smart(x))

“There is someone who, if he/she studies at Landau, is smart”

This is true if there is anyone not studying at Landau

B. Beckert: KI für IM – p.18

Page 49: Introduction to Articial Intelligence First-order Logic

Another Common Mistake to Avoid

Note

∧ is the main connective with ∃

Common mistake

Using ⇒ as the main connective with ∃

Example

Correct: ∃x(StudiesAt(x,Landau) ∧ Smart(x))

“There is someone who studies at Landau and is smart”

Wrong: ∃x(StudiesAt(x,Landau) ⇒ Smart(x))

“There is someone who, if he/she studies at Landau, is smart”

This is true if there is anyone not studying at Landau

B. Beckert: KI für IM – p.18

Page 50: Introduction to Articial Intelligence First-order Logic

Another Common Mistake to Avoid

Note

∧ is the main connective with ∃

Common mistake

Using ⇒ as the main connective with ∃

Example

Correct: ∃x(StudiesAt(x,Landau) ∧ Smart(x))

“There is someone who studies at Landau and is smart”

Wrong: ∃x(StudiesAt(x,Landau) ⇒ Smart(x))

“There is someone who, if he/she studies at Landau, is smart”

This is true if there is anyone not studying at Landau

B. Beckert: KI für IM – p.18

Page 51: Introduction to Articial Intelligence First-order Logic

Properties of Quantifiers

Quantifiers of same type commute

∀x∀y is the same as ∀y∀x

∃x∃y is the same as ∃y∃x

B. Beckert: KI für IM – p.19

Page 52: Introduction to Articial Intelligence First-order Logic

Properties of Quantifiers

Quantifiers of different type do NOT commute

∃x∀y is not the same as ∀y∃x

Example

∃x∀yLoves(x,y)“There is a person who loves everyone in the world”

∀y∃xLoves(x,y)“Everyone in the world is loved by at least one person”

(Both hopefully true but different)

B. Beckert: KI für IM – p.20

Page 53: Introduction to Articial Intelligence First-order Logic

Properties of Quantifiers

Quantifiers of different type do NOT commute

∃x∀y is not the same as ∀y∃x

Example

∀x∃yMother(x,y)“Everyone has a mother” (correct)

∃y∀xMother(x,y)“There is a person who is the mother of everyone” (wrong)

B. Beckert: KI für IM – p.21

Page 54: Introduction to Articial Intelligence First-order Logic

Properties of Quantifiers

Quantifier duality

∀xLikes(x, IceCream) is the same as ¬∃x¬Likes(x, IceCream)

∃xLikes(x,Broccoli) is the same as ¬∀x¬Likes(x,Broccoli)

B. Beckert: KI für IM – p.22

Page 55: Introduction to Articial Intelligence First-order Logic

Fun with Sentences

“Brothers are siblings”

∀x,y (Brother(x,y) ⇒ Sibling(x,y))

“Sibling” is symmetric

∀x,y (Sibling(x,y) ⇔ Sibling(y,x))

“One’s mother is one’s female parent”

∀x,y (Mother(x,y) ⇔ (Female(x)∧Parent(x,y)))

“A first cousin is a child of a parent’s sibling”

∀x,y (FirstCousin(x,y)⇔∃p, ps (Parent(p,x)∧Sibling(ps, p)∧Parent(ps,y)))

B. Beckert: KI für IM – p.23

Page 56: Introduction to Articial Intelligence First-order Logic

Fun with Sentences

“Brothers are siblings”

∀x,y (Brother(x,y) ⇒ Sibling(x,y))

“Sibling” is symmetric

∀x,y (Sibling(x,y) ⇔ Sibling(y,x))

“One’s mother is one’s female parent”

∀x,y (Mother(x,y) ⇔ (Female(x)∧Parent(x,y)))

“A first cousin is a child of a parent’s sibling”

∀x,y (FirstCousin(x,y)⇔∃p, ps (Parent(p,x)∧Sibling(ps, p)∧Parent(ps,y)))

B. Beckert: KI für IM – p.23

Page 57: Introduction to Articial Intelligence First-order Logic

Fun with Sentences

“Brothers are siblings”

∀x,y (Brother(x,y) ⇒ Sibling(x,y))

“Sibling” is symmetric

∀x,y (Sibling(x,y) ⇔ Sibling(y,x))

“One’s mother is one’s female parent”

∀x,y (Mother(x,y) ⇔ (Female(x)∧Parent(x,y)))

“A first cousin is a child of a parent’s sibling”

∀x,y (FirstCousin(x,y)⇔∃p, ps (Parent(p,x)∧Sibling(ps, p)∧Parent(ps,y)))

B. Beckert: KI für IM – p.23

Page 58: Introduction to Articial Intelligence First-order Logic

Fun with Sentences

“Brothers are siblings”

∀x,y (Brother(x,y) ⇒ Sibling(x,y))

“Sibling” is symmetric

∀x,y (Sibling(x,y) ⇔ Sibling(y,x))

“One’s mother is one’s female parent”

∀x,y (Mother(x,y) ⇔ (Female(x)∧Parent(x,y)))

“A first cousin is a child of a parent’s sibling”

∀x,y (FirstCousin(x,y) ⇔∃p, ps (Parent(p,x)∧Sibling(ps, p)∧Parent(ps,y)))

B. Beckert: KI für IM – p.23

Page 59: Introduction to Articial Intelligence First-order Logic

Equality

Semantics

term1 = term2 is true under a given interpretation

if and only if

term1 and term2 have the same interpretation

Examples

1 = 2 and ∀x×(Sqrt(x),Sqrt(x)) = x are satisfiable

2 = 2 is valid

B. Beckert: KI für IM – p.24

Page 60: Introduction to Articial Intelligence First-order Logic

Equality

Example

Definition of (full) sibling in terms of Parent

∀x,y Sibling(x,y) ⇔ (¬(x = y)∧

∃m, f (¬(m = f )∧

Parent(m,x)∧Parent( f ,x)∧

Parent(m,y)∧Parent( f ,y)))

B. Beckert: KI für IM – p.25

Page 61: Introduction to Articial Intelligence First-order Logic

Properties of First-order Logic

Important notions

– validity– satisfiability– unsatisfiablity– entailment

are defined for first-order logic in the same way as for propositional logic

Calculi

There are sound and complete calculi for first-order logic (e.g. resolution)

Whenever KB ` α, it is also true that KB |= α

Whenever KB |= α, it is also true that KB ` α

But these calculi CANNOT decide validity, entailment, etc.

B. Beckert: KI für IM – p.26

Page 62: Introduction to Articial Intelligence First-order Logic

Properties of First-order Logic

Important notions

– validity– satisfiability– unsatisfiablity– entailment

are defined for first-order logic in the same way as for propositional logic

Calculi

There are sound and complete calculi for first-order logic (e.g. resolution)

Whenever KB ` α, it is also true that KB |= α

Whenever KB |= α, it is also true that KB ` α

But these calculi CANNOT decide validity, entailment, etc.

B. Beckert: KI für IM – p.26

Page 63: Introduction to Articial Intelligence First-order Logic

Properties of First-order Logic

In propositional logic

Validity, satisfiability, unsatisfiablity are decidable

In first-order logic

The set of valid, and the set of unsatisfiable formulas are enumerable

The set of satisfiable formulas is NOT EVEN enumerable

B. Beckert: KI für IM – p.27