Sei sulla pagina 1di 10

PL & FOL EXAMPLES

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

Propositional logic is a weak language


Hard to identify individuals (e.g., Mary, 3)
Cant directly talk about properties of individuals or
relations between individuals (e.g., Bill is tall)
Generalizations, patterns, regularities cant easily be
represented (e.g., all triangles have 3 sides)
First-Order Logic (abbreviated FOL or FOPC) is expressive
enough to concisely represent this kind of information
FOL adds relations, variables, and quantifiers, e.g.,
Every elephant is gray: x (elephant(x) gray(x))
There is a white alligator: x (alligator(X) ^ white(X))

FOL Examples
Everyone likes McDonalds
x, likes(x, McDonalds)

Someone likes McDonalds


x, likes(x, McDonalds)

All children like McDonalds


x, child(x) likes(x, McDonalds)

Everyone likes McDonalds unless they are allergic to it


x, likes(x, McDonalds) allergic(x, McDonalds)
x, allergic (x, McDonalds) likes(x, McDonalds)

FOL Examples

All students are smart.


x ( Student(x) Smart(x) )
There exists a student.
x Student(x).
There exists a smart student.
x ( Student(x) Smart(x) )
Every student loves some student.
x ( Student(x) y ( Student(y) Loves(x,y) ))
Every student loves some other student.
x ( Student(x) y ( Student(y) (x = y) Loves(x,y) ))
There is a student who is loved by every other student.
x ( Student(x) y ( Student(y) (x = y) Loves(y,x) ))
Bill is a student.
Student(Bill)
Bill takes either Analysis or Geometry (but not both)
Takes(Bill, Analysis) Takes(Bill, Geometry)

FOL Examples

Bill takes Analysis or Geometry (or both).


Takes(Bill, Analysis) Takes(Bill, Geometry)
Bill takes Analysis and Geometry.
Takes(Bill, Analysis) Takes(Bill, Geometry)
Bill does not take Analysis.
Takes(Bill, Analysis).
No student loves Bill.
x ( Student(x) Loves(x, Bill) )
Bill has at least one sister.
x SisterOf(x,Bill)
Bill has no sister.
x SisterOf(x,Bill)
Bill has at most one sister.
x, y ( SisterOf(x, Bill) SisterOf(y, Bill) x = y )
Bill has exactly one sister.
x ( SisterOf(x, Bill) y ( SisterOf(y, Bill) x = y ))

FOL Examples

Bill has at least two sisters.


x, y ( SisterOf(x, Bill) SisterOf(y, Bill) (x = y) )
Every student takes at least one course.
x ( Student(x) y ( Course(y) Takes(x,y) ))
Only one student failed History.
x ( Student(x) Failed(x, History) y ( Student(y) Failed(y, History) x = y ))

No student failed Chemistry but at least one student failed History.


x ( Student(x) Failed(x, Chemistry) ) x ( Student(x) Failed(x, History) )

Every student who takes Analysis also takes Geometry.


x ( Student(x) Takes(x, Analysis) Takes(x, Geometry) )
No student can fool all the other students.
x ( Student(x) y ( Student(y) (x = y) Fools(x,y) ))

FOL To ENGLISH SENTENCE

x IsABunny(x) IsCute(x)
All bunnies are cute
x IsAStudent(x) IsTakingAI(x) IsCool(x)
Everyone student who is taking AI is cool
x IsABunny(x) IsAStudent(x) IsTakingAI(x) IsCute(x) IsCool(x)
Every bunny who is a student taking AI is cute and cool
x EatsRamen(x) IsHomeless(x) IsAGradStudent(x)
Everyone who eats ramen is either homeless or a graduate student
s h IsAStudent(s) IsTaking(s,AI) HomeworkFor(h,AI) Hates(s,h)
There is at least one student who doesnt hate (any of) the AI homework
a (IsACat(a) Rules(a)) (IsADog(a) Drools(a))
Cats rule and dogs drool
p time base isACaptain(captain) isABase(base) <(time, Now)
Owns(captain, base, time) Owns(CATS, base, Now)
All the bases that belonged to Captain now belong to CATS

EXAMPLE 2 PRACTICE
Convert the following English sentences into sentences of First-Order
Logic:

1. All cats are mammals.


2. No cat is a reptile.
3. All computer scientists like some operating system.
4. The only good extraterrestrial is a drunk extraterrestrial.
5. The Barber of Seville shaves all men who do not shave themselves.
6. There are at least two mountains in England.
7. No mountain is higher than itself.
8. There is exactly one coin in the box.
9. There are exactly two coins in the box.
10. The largest coin in the box is a quarter.
11. All students get good grades if they study.

Potrebbero piacerti anche