First Order Logic

CS 540-2

Louis Oliphant

oliphant@cs.wisc.edu

Announcements

Read chapter 8 on First Order Logic and chapter 9 on Inference in FOL

HW 2 due next Tuesday – Get started now!

Drawbacks of Propositional Logic
(motivation for FOL)

Difficult to express large domains concisely

in FOL a single sentence can capture information about a set of things

Doesn't capture important concepts about the world

There is more than Truth/Falsehood in the world

FOL has objects and relations between objects

Difficult to express large domains
in propositional logic

Hunt the Wumpus

Squares adjacent to pits are breezy

Squares adjacent to the wumpus are stinky

P3,1  B2,1  B3,2  B4,1

You need to repeat a similar sentence for all possible locations of a pit.

It would be nice to write one sentence explaining that squares adjacent to pits are breezy.

Ontological Commitment

Propositional Logic only has Facts (sentences) that can be true, false, or unknown

FOL also has

objects

relationships between those objects and attributes of objects

What exists,

the model

What can be known

Syntax of FOL: The basics

Constants	KingJohn, 2, NUS,...

Predicates	Brother, >, =, ...

Functions	Sqrt, LeftLegOf, ...

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

Connectives	, , , , 

Quantifiers	, 

Objects

Relations between objects

attributes of objects

Refer to objects

Like in propositional logic

Allows speaking about groups of objects

 -- for all

 -- there exists

Terms: Referring to Objects

Constants refer to single, specific objects – names for objects

Richard, Crown, Five...

Functions are a mapping from objects to other objects – Just a complex name for an object

Head(Richard), Father(Richard), +(Three,Five)

You must be able to apply a function to all objects in the model

division NOT a function -- div(One,Zero) not defined

(fix the problem by setting div(X,Zero) to a special null object)

Predicates

Relationships Between objects (2 or more)

BrotherOf(John,Richard)

Between(John,Richard,Martha)

Married(Father(John),Mother(John))

Father(John)=Henry

Three < Five

Attributes of objects

Male(John)

Connectives

Connectives are the same as in propositional logic

, , , , 

Same syntax rules and meaning apply

Variables and Quantifiers

Variables refer to some object in the world

BrotherOf(x,Richard)  Happy(x)

Quantifiers allow variables to represent collections of objects

x (BrotherOf(x,Richard)  Happy(x))

x (BrotherOf(x,Richard)  Happy(x))

All variables should be quantified to make the logical sentence have a clear meaning

Connections between  and 

Consider the sentences:

x Likes(x,Parsnips)

x Likes(x,Parsnips)

Consider also:

x Likes(x,IceCream)

x Likes(x,IceCream)

You really don't need both quantifiers

You can convert between quantifiers

x P  x P	x P  x P

x P  x P	x P  x P

“Natural” Connections with Quantifiers

The “Natural” connective for  is 

“All kings are persons”

x King(x)  Person(x)

x King(x)  Person(x)

The “Natural” connective for  is 

“John has a crown on his head”

x Crown(x)  OnHead(x,John)

x Crown(x)  OnHead(x,John)

Converting Knowledge into FOL

Writing knowledge down in FOL is a skill

Its known as Knowledge Engineering

To convert an English sentence into a FOL sentence think about the following:

what are the constants

what are the relationships between objects

what are the attributes of the objects

How are relationships Quantified

Converting Knowledge into FOL

“Elmo is a monster.”

What is the constant? Elmo

What is the predicate? Is a monster

Answer: monster(Elmo)

“Tinky, Winky and Dipsy are teletubbies.”

“Tom, Louis or Mickey is not a mouse.”

Converting Knowledge into FOL

We can do this with relations:

“America bought Alaska from Russia.”

What are the constants? America, Alaska, Russia

What is the relation? bought

Answer: bought(America, Alaska, Russia)

“Warm is between cold and hot.”

“Louis and Becky are married.”

Converting Knowledge into FOL

Now let's think about quantifiers:

“Louis likes everything.”

What's the constant? Louis

Thing? just use a variable x

Everything? universal quantifier

Answer: x likes(Louis,x)

i.e. likes(Louis,IceCream)  likes(Louis,Becky)  likes(Louis,Armadillos)...

“Louis likes something.”

“Somebody likes Louis.”

Converting Knowledge into FOL

Multiple quantifiers:

“Somebody heard something.”

Answer: x,y heard(x,y)

“Everybody heard everything.”

“Somebody did not hear everything.”

Converting Knowledge into FOL

More complex relations:

“All stinky shoes are allowed.”

Answer: x shoe(x)  stinky(x)  allowed(x)

“No stinky shoes are allowed.”

x shoe(x)  stinky(x)  allowed(x)

 x shoe(x)  stinky(x)  allowed(x)

 x shoe(x)  stinky(x)  allowed(x) (?)

Converting Knowledge into FOL

Consider the following sentence:

“Every student who takes French passes it.”

Answer:x,y (student(x)  french_class(y)  takes(x,y)  passes(x,y))

Converting Knowledge into FOL

Try converting each of the following sentences into first order logic

“Everybody loves somebody”

“There is someone who is loved by everyone”

“Everybody has a father”

“Every smart person is happy”

“Only one person is president”

Converting Knowledge into FOL

“Everybody loves somebody”

meaning 1: xy Loves(x,y)

meaning 2: yx Loves(x,y)

Order of quantification is important when using mixed quantifiers!

“There is someone who is loved by everyone”

yx Loves(x,y)

“Everybody has a father”

method 1: create function Father(x)

method 2: xy FatherOf(y,x)

“Every smart person is happy”

x Smart(x)  Happy(x)

“Only one person is president”

x President(x)  y President(y)  y=x

Its tricky to get “exactly” or “at least” or “at most” sentences correct

Converting More Difficult Sentence

“There is a barber who shaves all men in town who do not shave themselves.”

“Politicians can fool some of the people all of the time, and they can fool all of the people some of the time, but they can't fool all of the people all of the time.”

“Any good amateur can beat some professional.”

“Some professionals can beat all amateurs.”

Converting Domains into FOL
(the natural number domain)

One constant: Zero

One function: S(x) – the successor of x

Natural Numbers are:

NatNum(Zero)

n NatNum(n)  NatNum(S(n))

Constraining successor function:

n Zero  S(n)

m,n m  n  S(m)  S(n)

Addition defined:

m NatNum(m)  +(0,m)=m

m,n NatNum(m)  NatNum(n)  +(S(m),n)=S(+(m,n))

All of number theory (multiplication, division, remainders, prime numbers, cryptography, ...) can be represented in FOL

Converting Domains into FOL

Identify The Task

Assemble the relevant knowledge

Decide on a vocabulary of predicates, functions, and constants – Ontology

Encode general knowledge about the domain

Encode a description of the specific problem instance

(Good example in book on electronic circuits domain)

Conclusions

Syntax and semantics of FOL

terms, predicates, connectives, and quantifiers

When to use which quantifiers

When to use which connectives

How to convert knowledge into FOL sentences

2005-09-15T11:39:48