first-order logic (fol) - uoacgi.di.uoa.gr/~ys02/siteai2008/fol2spp.pdf · teqnht nohmosÔnh m....

26
First-Order Logic (FOL) Ontological commitments of FOL: The world consists of objects i.e., things with individual identities. Objects have properties that distinguish them from other objects. Objects participate in relations with other objects. Some of these relations are functions. Relations hold or do not hold. These ontological commitments make FOL more powerful than PL. FOL is here to stay! FOL: Syntax The symbols of FOL (with equality) are the following: Parentheses: (, ). The logical connectives ¬, , , and . A countably infinite set of variables. This set will be denoted by V ars. Examples: x, y, v, ...

Upload: ngokhuong

Post on 30-Sep-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

First-Order Logic (FOL)

Ontological commitments of FOL:

• The world consists of objects i.e., things with individualidentities. Objects have properties that distinguish themfrom other objects.

• Objects participate in relations with other objects. Some ofthese relations are functions. Relations hold or do not hold.

These ontological commitments make FOL more powerful than PL.

FOL is here to stay!

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

FOL: Syntax

The symbols of FOL (with equality) are the following:

• Parentheses: (, ).

• The logical connectives ¬,∧,∨,⇒ and ⇔.

• A countably infinite set of variables. This set will be denotedby V ars.

Examples: x, y, v, . . .

Page 2: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

FOL: Syntax (cont’d)

• The quantifier symbols: ∀, ∃• A countably infinite set of constant symbols.

Examples: John, Mary, 5, 6, Ball, . . .

• The equality symbol: =

• Predicate symbols: For each positive integer n, some set(possibly empty) of symbols, called n-place predicate symbols.

Examples: Happy(.), Brother(., .), Arrives(., ., .), . . .

• Function symbols: For each positive integer n, some set(possibly empty) of symbols, called n-place function symbols.

Examples: FatherOf(.), Cosine(.), . . .

Logicians usually introduce only the connectives ¬ and ∨ and oneof the quantifiers.

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

FOL: Syntax (cont’d)

Terms are expressions of FOL that refer to objects. The set of allterms will be denoted by Terms.

The following BNF grammar gives the syntax of terms:

Term → ConstantSymbol | V ariable

| FunctionSymbol(Term, . . . , T erm)

Examples:John, x, FatherOf(John), WifeOf(FatherOf(x)), . . .

Page 3: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

FOL: Syntax (cont’d)

Atomic formulas are expressions of FOL that refer to simplefacts.

The following BNF grammar gives the syntax of atomic formulas:

AtomicFormula → Term = Term

| PredicateSymbol(Term, . . . , T erm)

Examples:John = ElderSonOf(FatherOf(John)), Happy(John),Lives(John, London), Arrives(John, Athens, Monday)

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

FOL: Syntax (cont’d)

Well-formed formulas (wffs) are the most complex kind ofexpressions in FOL. They can be used to refer to any complicated stateof affairs.

The following BNF grammar gives the syntax of wffs:

Wff → AtomicFormula | ( Wff ) | ¬ Wff

| Wff BinaryConnective Wff

| ( Quantifier V ariable ) Wff

Page 4: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

FOL: Syntax (cont’d)

Examples of wffs:

• ¬Loves(Tony, Mary)

• Loves(Tony, Paula) ∨ Loves(Tony, F iona)

• Loves(John, Paula) ∧ Loves(John, F iona)

• (∀x)(SportsCar(x) ∧HasDriven(Mike, x) ⇒ Likes(Mike, x))

• (∃x)(SportsCar(x) ∧Owns(John, x))

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Free Variables

The following recursive definition defines the notion of free variablesof a wff.

• If φ is an atomic formula, x occurs free in φ iff x is a symbol of φ.

• x occurs free in ¬φ iff x is a symbol of φ.

• x occurs free in φ ∧ ψ iff x is a symbol of φ or ψ. Similarly for theremaining binary connectives.

• x occurs free in (∀v)φ iff x is a symbol of φ and x is different thanv. Similarly for ∃.

The opposite of free is bound.

Definition. If no variable occurs free in the wff φ, then φ is asentence.

Page 5: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Free Variables (cont’d)

Examples:

• x is free in Brother(x, John) but not in

(∀x)(Cat(x) ⇒ Mammal(x)).

• y is free in

(∀x)(Friend(x, y) ⇒ Loves(x, y))

but not in

(∀x)(∀y)(Friend(x, y) ⇒ Loves(x, y)).

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

FOL: Semantics

The meaning of FOL formulas is provided by interpretations.

An interpretation is a mapping between symbols of FOL andobjects, functions or relations in the world. More precisely:

• An interpretation maps each constant symbol to an object inthe world.

Example: In one particular interpretation the symbol John

might refer to John Major, the British PM. In anotherinterpretation it might refer to the evil King John, king ofEngland from 1199 to 1216.

Page 6: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

FOL: Semantics (cont’d)

• An interpretation maps each predicate symbol to a relation inthe world.

Example: In one particular interpretation the symbolBrother(., .) might refer to the relation of brotherhood. In aworld with three objects, King John, John Major, and Richardthe Lionheart, the relation of brotherhood is defined by thefollowing set of tuples:

{ 〈King John, Richard the Lionheart〉,〈Richard the Lionheart, King John〉 }

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

FOL: Semantics (cont’d)

• An interpretation always maps the equality symbol to theidentity relation in the world. The identity relation is:

id = {〈o, o〉 : o is an object in the world}

• An interpretation maps each function symbol to a functionalrelation (or function) in the world.

Example: In one particular interpretation the symbolFatherOf(.) might refer to the relation of fatherhood.

Page 7: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

FOL: Formal Semantics

An interpretation I is a function which makes the followingassignments to the symbols of FOL:

1. I assigns to the quantifier symbol ∀ a non-empty set |I| calledthe universe or domain of I.

2. I assigns to each constant symbol c a member cI of theuniverse |I|.

3. I assigns to each n-place predicate symbol P an n-ary relationP I ⊆ |I|n; i.e., P I is a set of n-tuples of members of theuniverse.

4. I assigns to each n-place function symbol F an n-ary functionF I on |I|; i.e., F I : |I|n → |I|.

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Satisfaction

Definition. A variable assignment is a function s : V ars → |I|for some set of variables V ars and interpretation I.

Let φ be a wff of FOL, I an interpretation and s : V ars → |I| avariable assignment.

We will define what it means for I to satisfy φ with variableassignment s. This will be denoted by

|=I φ[s] or I |= φ[s].

Intuitively |=I φ[s] if and only if the state of affairs denoted by φ istrue according to I (where any variable x which occurs in φ, standsfor s(x) wherever it occurs free).

Page 8: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Satisfaction (cont’d)

The formal definition of satisfaction proceeds as follows:

Terms. We define the function

s : Terms → |I|from the set of all terms Terms into the universe |I|. This functionis an extension of s, and maps each FOL term to the object in theuniverse denoted by this term:

• For each variable x, s(x) = s(x).

• For each constant symbol c, s(c) = cI .

• If t1, . . . , tn are terms and F is an n-place function symbol, then

s(F (t1, . . . , tn)) = F I(s(t1), . . . , s(tn)).

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Satisfaction (cont’d)

Atomic formulas. The definition of satisfaction for atomicformulas is as follows:

• For atomic formulas involving the equality symbol,

|=I t1 = t2[s] iff s(t1) is identical to s(t2).

• For an n-place predicate symbol P ,

|=I P (t1, . . . , tn)[s] iff 〈s(t1), . . . , s(tn)〉 ∈ P I .

Page 9: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Satisfaction (cont’d)

Other wffs.

• |=I ¬φ[s] iff 6|=I φ[s] (i.e., iff |=I φ[s] is not the case).

• |=I (φ ∧ ψ)[s] iff |=I φ[s] and |=I ψ[s].

• |=I (φ ∨ ψ)[s] iff |=I φ[s] or |=I ψ[s].

• |=I (φ ⇒ ψ)[s] iff 6|=I φ[s] or |=I ψ[s].

• |=I (φ ⇔ ψ)[s] iff |=I φ[s] and |=I ψ[s], or 6|=I φ[s] and 6|=I ψ[s].

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Satisfaction (cont’d)

• |=I (∀x)φ [s] iff for all d ∈ |I|, we have |=I φ[s(x|d)].

The function s(x|d) is defined as follows:

s(x|d)(y) =

s(y) if y 6= x

d if y = x

• |=I (∃x)φ [s] iff there exists d ∈ |I| such that |=I φ[s(x|d)].

Page 10: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Example: the WW in FOL

Breeze Breeze

Breeze

BreezeBreeze

Stench

Stench

BreezePIT

PIT

PIT

1 2 3 4

1

2

3

4

START

Gold

Stench

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Example (cont’d)

If we want to formalize the WW in FOL, we can use the followingsymbols:

• Constant symbols:

Agent, Wumpus,Gold, Breeze, Stench,Rm11, Rm12, . . . , Rm44

• Function symbols:

– The unary function symbol NorthOf to denote the uniqueroom which is north of the room denoted by the argumentof the function. For example, the room north of room 11 isroom 21.

– The unary function symbols SouthOf, WestOf, EastOf

with similar meanings.

Page 11: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Example (cont’d)

• Predicate symbols:

– The binary predicate Location will be used to denote thelocation (i.e. room) of each object (agent, wumpus andgold).

– The binary predicate Percept will be used to denote thepercept (i.e., breeze or stench) in each room.

– The unary predicate Bottomless will be used to denote thata room contains a pit.

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Example (cont’d)

One could rightly object to having constant symbols R11, R12 tomodel the grid of rooms etc.

A better way to model the grid of rooms is to have a binaryfunction symbol Room(x, y) where x and y are the coordinates ofthe room.

Try this as an exercise!

Page 12: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Example (cont’d)

Let us now provide an interpretation I of the above symbols whichcorresponds to the previous picture:

• The universe of I is the objects we see in the picture:

|I| = {agent, wumpus, gold, breeze, stench, rm11, . . . , rm44}.

• I makes the following assignments to constant symbols:

AgentI = agent, WumpusI = wumpus, GoldI = gold,

BreezeI = breeze, StenchI = stench,

Rm11I = rm11, . . . , Rm44I = rm44

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Example (cont’d)

• I assigns to the unary function symbol NorthOf the functionNorthOf I : |I| → |I| which is defined as follows:

NorthOf I(rm11) = rm21,

NorthOf I(rm21) = rm22, . . . , NorthOf I(rm34) = rm44

• I assigns to the unary function symbolsSouthOf,WestOf, EastOf the function symbolsSouthOf I , WestOf I , EastOf I that are defined similarly withNorthOf I .

Page 13: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Example (cont’d)

• I assigns to the unary predicate symbol Bottomless thefollowing relation:

{〈rm13〉, 〈rm33〉, 〈rm44〉}

• I assigns to the binary predicate symbol Location the followingrelation:

{〈agent, rm11〉, 〈wumpus, rm31〉, 〈gold, rm32〉}

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Example (cont’d)

• I assigns to the binary predicate symbol Percept the following relation:

{〈rm12, breeze〉, 〈rm14, breeze〉, 〈rm21, stench〉, 〈rm23, breeze〉,〈rm32, breeze〉, 〈rm32, stench〉, 〈rm34, breeze〉, 〈rm41, stench〉,〈rm43, breeze〉}

Note: To describe interpretation I we used words like agent, breeze, etc.which start with a lowercase letter. These are not symbols of our FOLlanguage; they are just English words referring to what is in the picture.Instead, we could have drawn little pictures to describe the elements of theuniverse of the interpretation.

Page 14: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Example (cont’d)

We now give examples of satisfaction:

• |=I x = y[s] for any variable assignment s which maps x and y

to identical objects of the universe (e.g.,s(x) = s(y) = wumpus). Why?

Because if s(x) = s(y) = wumpus then s(x) = s(x) = wumpus

is identical to s(y) = s(y) = wumpus.

• |=I Agent = Agent[s] for any variable assignments s.

This is trivial.

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Example (cont’d)

• |=I Rm21 = NorthOf(Rm11)[s] for any variable assignment s.Why?

Because s(Rm21) = Rm21I = rm21 and

s(NorthOf(Rm11)) = NorthOf I(s(Rm11)) =

= NorthOf I(Rm11I) = NorthOf I(rm11) = rm21.

• |=I Rm21 = NorthOf(x)[s] for any variable assignment s suchthat s(x) = rm11. Why?

Because s(Rm21) = Rm21I = rm21 and

s(NorthOf(x)) = NorthOf I(s(x)) =

NorthOf I(s(x)) = NorthOf I(rm11) = rm21.

Page 15: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Example (cont’d)

• |=I Bottomless(x)[s] for any variable assignment s such thats(x) = rm13 or s(x) = rm33 or s(x) = rm44. Why?

Because if s(x) = rm13 then

〈s(x)〉 = 〈s(x)〉 = 〈rm13〉 ∈ BottomlessI .

Similarly, for the other cases.

• |=I Location(Agent, Rm11)[s] for any variable assignments s. Why?

Because

〈s(Agent), s(Rm11)〉 = 〈AgentI , Rm11I〉 = 〈agent, rm11〉 ∈ LocationI .

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Example (cont’d)

• |=I ¬Location(Gold, Rm44)[s] for any variable assignment s. Why?

Because

〈s(Gold), s(Rm44)〉 = 〈GoldI , Rm44I〉 = 〈gold, rm44〉 6∈ LocationI

therefore 6|=I Location(Gold, Rm44)[s] for any variable assignment s.

• |=I Location(Gold, Rm32) ∨ Location(Gold, Rm44)[s] for anyvariable assignment s. Why?

Because

〈s(Gold), s(Rm32)〉 = 〈GoldI , Rm32I〉 = 〈gold, rm32〉 ∈ LocationI

therefore |=I Location(Gold, Rm32)[s] for any variable assignment s.

Page 16: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Example (cont’d)

• |=I (∃x)Location(x,Rm11)[s] for any variable assignment s. Why?

Because

〈s(Agent), s(Rm11)〉 = 〈AgentI , Rm11I〉 = 〈agent, rm11〉 ∈ LocationI

thus |=I Location(x,Rm11)[s(x|agent)].

• 6|=I (∀x)Location(Wumpus, x)[s] for any variable assignment s.Why?

Because

〈s(Wumpus), s(Rm11)〉 = 〈WumpusI , Rm11I〉 =

〈wumpus, rm11〉 6∈ LocationI

thus 6|=I Location(Wumpus, x)[s(x|rm11)].

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Satisfaction (cont’d)

When we want to verify whether or not an interpretation satisfies awff φ with s, we do not really need all of the (infinite amount of)information that s gives us. All that matters are the values of thefunction s at the (finitely many) variables which occur free in s. Inparticular, if φ is a sentence, then s does not matter at all. This ismade formal by the following theorem.

Theorem. Let s1 and s2 be variable assignments from V ars into|I| which agree at all variables (if any) which occur free in the wffφ. Then

|=I φ[s1] iff |=I φ[s2].

Page 17: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Satisfaction (cont’d)

The previous theorem has the following corollary.

Corollary. Let φ be a sentence and I an interpretation. Then,either(a) I satisfies φ with every variable assignment s : V ars → |I|, or(b) I does not satisfy φ with any variable assignment.

The above corollary allows us to ignore variable assignmentswhenever we talk about satisfaction of sentences. Thus if φ is asentence and I an interpretation, we can just say that I satisfies(or does not satisfy) φ.

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Satisfiability

Definition. A formula φ is called satisfiable iff there exists aninterpretation I and variable assignment s such that |=I φ[s].Otherwise, the formula is called unsatisfiable.

Examples: The formulas

Location(Wumpus,Rm31), Location(Agent, Rm11), (∃x)R(y, x)

are satisfiable. The following formulas are unsatisfiable:

P (x) ∧ ¬P (x), (∀x)P (x) ∧ ¬P (A)

Can you write an algorithm which discovers whether a given wff issatisfiable?

Page 18: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Truth and Models

Definition. Let φ be a sentence and I an interpretation. If I

satisfies φ then we will say that φ is true in I or I is a model of φ.

Example: The interpretation I defined in the WW example is amodel of the following sentences:

Location(Wumpus, Rm31), Location(Agent, Rm11),

(∃x)Percept(Breeze, x)

Definition. An interpretation I is a model of a set of sentencesKB iff it is a model of every member of KB.

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Entailment

Definition. Let KB be a set of wffs, and φ a wff. Then KB entailsor logically implies φ, denoted by KB |= φ, iff for everyinterpretation I and every variable assignment s : V ars → |I| such thatI satisfies every member of KB with s, I also satisfies φ with s.

Examples:

{ Happy(John), (∀x)(Happy(x) ⇒ Laughs(x)) } |= Laughs(John)

{WellPaid(John), ¬WellPaid(John)∨Happy(John) } |= Happy(John)

Can you give an algorithm that discovers whether a set of wffs entail awff?

Page 19: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Validity and Equivalence

Definition. A wff φ is valid iff for every interpretation I andevery variable assignment s : V ars → |I|, I satisfies φ with s.

Examples: The formulas

P (A) ∨ ¬P (A), P (A) ⇒ P (A), (∀x)P (x) ⇒ (∃x)P (x)

are valid.

Can you write an algorithm which discovers whether a given wff isvalid?

Definition. Two formulas φ and ψ will be called logicallyequivalent, denoted by φ ≡ ψ, iff φ |= ψ and ψ |= φ.

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Satisfiability, Equivalence and Validity

In the following theorems, φ and ψ are arbitrary wffs.

Theorem. φ |= ψ iff φ ⇒ ψ is valid.

Proof.

“Only if”

Let I be an arbitrary interpretation and s an arbitrary variable assignments : V ars → |I|. We will prove that |=I (φ ⇒ ψ)[s].

We consider two cases depending on whether |=I φ[s] or not.

Let us first assume that |=I φ[s]. Since φ |= ψ, we have |=I ψ[s]. Thus,from the definition of satisfaction for implication, we have |=I (φ ⇒ ψ)[s].

Let us now assume that 6|=I φ[s]. From the definition of satisfaction forimplication, we can immediately conclude |=I (φ ⇒ ψ)[s].

Page 20: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Proof (cont’d)

“If”

Let I be an arbitrary interpretation and s an arbitrary variableassignment s : V ars → |I|.Let us also assume that |=I φ[s]. We will prove that |=I ψ[s].

Since φ ⇒ ψ is valid, we have |=I (φ ⇒ ψ)[s]. Since we also knowthat |=I φ[s], we must have |=I ψ[s].

Thus, from the definition of entailment, we have φ |= ψ.

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Satisfiability, Equivalence and Validity (cont’d)

Theorem. φ is unsatisfiable iff ¬φ is valid. Proof?

Theorem. φ ≡ ψ iff φ ⇔ ψ is valid. Proof?

Page 21: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Some Important Logical Equivalences

Let φ and ψ be wffs. Then:

1. ¬(φ ∧ ψ) ≡ ¬φ ∨ ¬ψ

2. ¬(φ ∨ ψ) ≡ ¬φ ∧ ¬ψ

3. φ ∧ ψ ≡ ¬(¬φ ∨ ¬ψ)

4. φ ∨ ψ ≡ ¬(¬φ ∧ ¬ψ)

5. φ ⇒ ψ ≡ ¬φ ∨ ψ

6. φ ⇔ ψ ≡ (φ ⇒ ψ) ∧ (ψ ⇒ φ)

Proofs?

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Proof of φ ⇒ ψ ≡ ¬φ ∨ ψ

Let us first prove thatφ ⇒ ψ |= ¬φ ∨ ψ.

Let I be an arbitrary interpretation and s an arbitrary variableassignment s : V ars → |I|.Let us assume that |=I (φ ⇒ ψ)[s]. We will prove that |=I (¬φ ∨ ψ)[s].

From the definition of satisfaction for implication, we have 6|=I φ[s] or|=I ψ[s].

If 6|=I φ[s] then, from the definition of satisfaction for negation, we have|=I ¬φ[s]. Thus, from the definition of satisfaction for disjunction, wehave |=I (¬φ ∨ ψ)[s].

If |=I ψ[s] then, from the definition of satisfaction for disjunction, wealso have |=I (¬φ ∨ ψ)[s].

Page 22: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Proof (cont’d)

Let us now prove that¬φ ∨ ψ |= φ ⇒ ψ.

Let I be an arbitrary interpretation and s an arbitrary variableassignment s : V ars → |I|.Let us assume that |=I (¬φ ∨ ψ)[s]. We will prove that |=I (φ ⇒ ψ)[s].

From the definition of satisfaction for disjunction, we have |=I ¬φ[s] or|=I ψ[s]. We consider these two cases below.

If |=I ¬φ[s] then, from the definition of satisfaction for negation, wehave 6|=I φ[s]. Thus, from the definition of satisfaction for implication,we have |=I (φ ⇒ ψ)[s].

If |=I ψ[s] then we can immediately conclude |=I (φ ⇒ ψ)[s] from thedefinition of satisfaction for implication.

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Some Important Logical Equivalences (cont’d)

1. (∀x)φ ≡ ¬(∃x)¬φ

2. (∃x)φ ≡ ¬(∀x)¬φ

3. (∀x)¬φ ≡ ¬(∃x)φ

4. (∃x)¬φ ≡ ¬(∀x)φ

Proofs?

Page 23: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Some Important Logical Equivalences (cont’d)

1. (∃x)(φ ∨ ψ) ≡ (∃x)φ ∨ (∃x)ψ

2. (∃x)(φ ∧ ψ) |= (∃x)φ ∧ (∃x)ψ

3. (∀x)φ ∨ (∀x)ψ |= (∀x)(φ ∨ ψ)

4. (∀x)(φ ∧ ψ) ≡ (∀x)φ ∧ (∀x)ψ

Proofs?

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

One of the Proofs

Prove that

(∃x)(φ(x) ∧ ψ(x)) |= (∃x)φ(x) ∧ (∃x)ψ(x).

Proof: Let I be an interpretation and s a variable assignment suchthat

|=I (∃x)(φ(x) ∧ ψ(x))[s].

Then according to the definition of satisfaction for existentialstatements, there exists a d ∈ |I| such that

|=I (φ(x) ∧ ψ(x))[s(x|d)].

Then according to the definition of satisfaction for conjunctivestatements, we have

|=I φ(x)[s(x|d)]

Page 24: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

and|=I ψ(x)[s(x|d)].

Now from the definition of satisfaction for existential statementsagain, we have

|=I (∃x)φ(x)[s]

and|=I (∃x)ψ(x)[s].

Now from the definition of satisfaction for conjunctive statementswe have:

|=I (∃x)φ(x) ∧ (∃x)ψ(x)[s].

The proof is now finished.

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Representing Knowledge Using FOL

Definition. In knowledge representation, a domain is a sectionof the world about which we wish to express some knowledge.

• The domain of family relationships.

• The domain of sets.

• The wumpus domain.

• The domain of web resources (HTML pages, images, programsetc. on the WWW)

• ...

Page 25: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Knowledge Engineering

The process of knowledge-base construction is called knowledgeengineering.

A knowledge engineer is someone who investigates a particulardomain, determines what concepts are important in that domain,and creates a formal representation of the objects and relations inthat domain.

If you want to see how FOL can be applied to represent knowledgein various sophisticated application domains, see Chapter 10 of theAIMA book (we will not cover it in the course).

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Other Logics in Computer Science

FOL is certainly the most important logic in use today bycomputer scientists. But there are others too:

• Second-order logic

• Modal logic (with operators such as “possible” and “certain”)

• Temporal logic (with operators such as “in the past”, etc.)

• Logics of knowledge and belief

• Logics for databases

• ....

Page 26: First-Order Logic (FOL) - UoAcgi.di.uoa.gr/~ys02/siteAI2008/fol2spp.pdf · Teqnht NohmosÔnh M. Koumpar khc ’ & $ % FOL: Syntax (cont’d) † The quantifler symbols: 8;9 † A

Teqnht  NohmosÔnh M. Koumpar�khc'

&

$

%

Readings

Chapter 8 of AIMA: First-Order Logic

Other formal presentations of FOL can be found in:

1. Any mathematical logic textbook. Most of the formal materialin these notes is from:

H.B. Enderton, “A Mathematical Introduction to Logic”,Academic Press, 1972.

See the Web page of the course for more details.

2. M.R. Genesereth and N.J. Nilsson, “Logical Foundations ofArtificial Intelligence”, Morgan Kaufmann, 1987.