First Order Logic FOL - PowerPoint PPT Presentation

1 / 47
About This Presentation
Title:

First Order Logic FOL

Description:

Objects: wheels, doors, engines, cars, Dave, Joe ... Taxonomic Properties: Car(car1), Person(Dave), Person(Joe) Relations return True or False ... – PowerPoint PPT presentation

Number of Views:104
Avg rating:5.0/5.0
Slides: 48
Provided by: paolopir
Category:
Tags: fol | first | logic | order

less

Transcript and Presenter's Notes

Title: First Order Logic FOL


1
First Order Logic (FOL)
  • Syntax
  • Semantics
  • Wumpus world example
  • Ontology (ont to be logica word) kinds
    of things one can talk about in the language

2
Why first-order logic?
  • We saw that propositional logic is limited
    because it only makes the ontological commitment
    that the world consists of facts.
  • Difficult to represent even simple worlds like
    the Wumpus world
  • e.g.,
  • dont go forward if the Wumpus is in front of
    you takes 64 rules.

3
First-order logic (FOL)
  • Ontological commitments
  • Objects wheels, doors, engines, cars, Dave, Joe
  • Relations Inside(car1, Dave), Beside(Dave, Joe)
  • Functions WeightOf(car1)
  • Properties IsOpen(door1), IsOn(engine1)
  • Taxonomic Properties Car(car1), Person(Dave),
    Person(Joe)
  • Relations return True or False
  • Functions return a single objects, otherwise they
    wouldnt be functions.
  • WeightOf(x) returns a single weight
  • BrotherOf(x) is not a function. You may have
    several brothers. But, NaturalMotherOf(x) is a
    function.

4
Semantics
  • There is a correspondence between
  • functions, which return values
  • predicates (or relations), which are true or
    false
  • Function fatherOf(Mary) Bill
  • Predicate fatherOfP(Mary, Bill)
  • The point is that every function can have a
    corresponding predicate associated with it.

5
Examples
  • One plus two equals three
  • Objects
  • Relations
  • Properties
  • Functions
  • Squares neighboring the Wumpus are smelly
  • Objects
  • Relations
  • Properties
  • Functions

6
Examples
  • One plus two equals three
  • Objects Numbers, one, two, three, one plus two
  • Relations equals(one, two)
  • Properties Integer(one)
  • Functions plus (one, two) returns one plus
    two , the object obtained by applying
    function plus to one and two
  • three is another name for this object)
  • Squares neighboring the Wumpus are smelly
  • Objects squares, Wumpus, square1,1, square1,2
  • Relations neighboring(square1,1, square1,2)
  • Properties smelly(square1,1)
  • Functions rt-neighborOf(square1,1) returns
    square1,2

7
FOL Syntax of basic elements
  • Constant symbols 1, 5, A, B, USC, JPL, Alex,
    Manos,
  • Predicate symbols gt, friend, student, colleague,
  • Function symbols , sqrt, schoolOf,
  • Variables x, y, z, next, first, last,
  • Connectives ?, ?, ?, ?
  • Quantifiers ?, ?
  • Equality

8
FOL Atomic sentences
  • AtomicSentence ? Predicate(Term, ) Term Term
  • Term ? Function(Term, ) Constant Variable
  • Examples
  • SchoolOf(Manos)
  • Colleague(TeacherOf(Alex,cs561), TeacherOf(Manos,
    cs571))
  • gt(( x y), x)

9
FOL Complex sentences
  • Sentence ? AtomicSentence Sentence
    Connective Sentence Quantifier Variable,
    Sentence ? Sentence (Sentence)
  • Examples
  • S1 ? S2, S1 ? S2, (S1 ? S2) ? S3, S1 ? S2, S1?
    S3
  • Colleague(Paolo, Maja) ? Colleague(Maja, Paolo)
    Student(Alex, Paolo) ? Teacher(Paolo, Alex)

10
Semantics of atomic sentences
  • Sentences in FOL are interpreted with respect to
    a model
  • Model contains objects and relations among them
  • Terms refer to objects (e.g., Door1, Alex,
    MotherOf(Paolo))
  • Constant symbols refer to objects
  • Predicate symbols refer to relations
  • Function symbols refer to functional Relations
  • An atomic sentence predicate(term1, , termn) is
    true iff the relation referred to by predicate
    holds between the objects referred to by term1,
    , termn

11
Example model
  • Objects John, James, Mary, Alex, Dan, Joe, Anne,
    Rich
  • Relation sets of tuples of objectsltJohn,
    Jamesgt, ltMary, Alexgt, ltMary, Jamesgt, ltDan,
    Joegt, ltAnne, Marygt, ltMary, Joegt,
  • E.g. Parent relation -- ltJohn, Jamesgt, ltMarry,
    Alexgt, ltMary, Jamesgtthen Parent(John, James)
    is true Parent(John, Mary) is false

12
Quantifiers
  • Expressing sentences about collections of objects
    without enumeration (naming individuals)
  • E.g., All Trojans are clever Someone in the
    class is sleeping
  • Universal quantification (for all) ?x R(x)
  • Existential quantification (there exists) ?x R(x)

13
Universal quantification (for all) ?
  • ? ltvariablesgt ltsentencegt
  • Every one in the cs561 class is smart ? x
    In(cs561, x) ? Smart(x)
  • ? P corresponds to the conjunction of
    instantiations of PIn(cs561, Manos) ?
    Smart(Manos) ? In(cs561, Dan) ? Smart(Dan) ?
    In(cs561, Bush) ? Smart(Bush)

14
Universal quantification (for all) ?
  • ? is a natural connective to use with ?
  • Common mistake to use ? in conjunction with ?
    e.g ? x In(cs561, x) ? Smart(x)means every
    one is in cs561 and everyone is smart

15
Existential quantification (there exists) ?
  • ? ltvariablesgt ltsentencegt
  • Someone in the cs561 class is smart ? x
    In(cs561, x) ? Smart(x)
  • ? P corresponds to the disjunction of
    instantiations of P(In(cs561, Manos) ?
    Smart(Manos)) ? (In(cs561, Dan) ? Smart(Dan)) ?
    (In(cs561, Bush) ? Smart(Bush))

16
Existential quantification (there exists) ?
  • ? is a natural connective to use with ?
  • Common mistake to use ? in conjunction with ?
    e.g ? x In(cs561, x) ? Smart(x)is true if
    there is anyone that is not in cs561!
  • (remember, false ? true is valid).

17
Properties of quantifiers
Not all by one person but each one at least by one
Proof?
18
Negation Laws for Quantified Statements
  • ? x P(x) ltgt ? x P(x)
  • ? x P(x) ltgt ? x P(x)

19
Informal Proof
  • In general we want to prove
  • ? x P(x) ltgt ? x P(x)
  • ? x P(x) ((? x P(x))) ((P(x1) P(x2)
    P(xn)) ) (P(x1) v P(x2) v v P(xn)) )
  • ? x P(x) P(x1) v P(x2) v v P(xn)
  • ? x P(x) (P(x1) v P(x2) v v P(xn))

20
Example sentences
  • Brothers are siblings .
  • Sibling is transitive.
  • Ones mother is ones siblings mother.
  • A first cousin is a child of a parents
    sibling.

21
Example sentences
  • Brothers are siblings ? x, y Brother(x, y) ?
    Sibling(x, y)
  • Sibling is transitive? x, y, z Sibling(x, y)
    ? Sibling(y, z) ? Sibling(x, z)
  • Ones mother is ones siblings mother? m, c
    Mother(m, c) ? Sibling(c, d) ? Mother(m, d)
  • A first cousin is a child of a parents
    sibling? c, d FirstCousin(c, d) ? ? p, ps
    Parent(p, d) ? Sibling(p, ps) ? Parent(ps, c)

22
Example sentences
  • Ones mother is ones siblings mother? m, c,d
    Mother(m, c) ? Sibling(c, d) ? Mother(m, d)
  • ? c,d ?m Mother(m, c) ? Sibling(c, d) ? Mother(m,
    d)

23
Translating English to FOL
  • Every gardener likes the sun.
  • ? x gardener(x) gt likes(x,Sun)
  • You can fool some of the people all of the time.
  • ? x ? t (person(x) time(t)) gt can-fool(x,t)

24
Translating English to FOL
  • You can fool all of the people some of the time.
  • ? x ? t (person(x) time(t)) gt
  • can-fool(x,t)
  • All purple mushrooms are poisonous.
  • ? x (mushroom(x) purple(x)) gt poisonous(x)

25
Translating English to FOL
  • No purple mushroom is poisonous.
  • (? x) purple(x) mushroom(x) poisonous(x)
  • or, equivalently,
  • (? x) (mushroom(x) purple(x)) gt poisonous(x)

26
Translating English to FOL
  • There are exactly two purple mushrooms.
  • (? x)(? y) mushroom(x) purple(x) mushroom(y)
    purple(y) (xy) (? z) (mushroom(z)
    purple(z)) gt ((xz) v (yz))
  • Deb is not tall.
  • tall(Deb)

27
Translating English to FOL
  • X is above Y if X is on directly on top of Y or
    else there is a pile of one or more other objects
    directly on top of one another starting with X
    and ending with Y.
  • (? x)(? y) above(x,y) ltgt (on(x,y) v (? z)
    (on(x,z) above(z,y)))

28
Equality
  • A sibling is another child of ones parents
  • ? x,y Sibling(x,y) ? (xy) ? ? p Parent(p, x)
    ? Parent(p, y)

29
Higher-order logic?
  • First-order logic allows us to quantify over
    objects ( the first-order entities that exist in
    the world).
  • Higher-order logic also allows quantification
    over relations and functions.
  • e.g., two objects are equal iff all properties
    applied to them are equivalent
  • ? x,y (xy) ? (? p, p(x) ? p(y))
  • Higher-order logics are more expressive than
    first-order however, so far we have little
    understanding on how to effectively reason with
    sentences in higher-order logic.

30
Rememberpropositionallogic
31
Reminder
  • Ground term A term that does not contain a
    variable.
  • A constant symbol
  • A function applies to some ground term
  • x/a substitution/binding list

32
Proofs
33
Proofs
  • The three new inference rules for FOL (compared
    to propositional logic) are
  • Universal Elimination (UE) (also called
    Universal Instantiation)
  • for any sentence ?, variable x and ground term
    ?,
  • ?x ?
  • ?x/?
  • Existential Elimination (EE) (also called
    Existential Instantiation)
  • for any sentence ?, variable x and constant
    symbol k not in KB,
  • ?x ?
  • ?x/k
  • Existential Introduction (EI) (also called
    Existential Generalization)
  • for any sentence ?, variable x not in ? and
    ground term g in ?,
  • ?
  • ?x ?g/x

34
Proofs
  • The three new inference rules for FOL (compared
    to propositional logic) are
  • Universal Elimination (UE) (also called
    Universal Instantiation)
  • for any sentence ?, variable x and ground term
    ?,
  • ?x ? e.g., from ?x Likes(x, Candy) and
    x/Joe
  • ?x/? we can infer Likes(Joe, Candy)
  • Existential Elimination (EE) (also called
    Existential Instantiation)
  • for any sentence ?, variable x and constant
    symbol k not in KB,
  • ?x ? e.g., from ?x Kill(x, Victim) we can
    infer
  • ?x/k Kill(Murderer, Victim), if Murderer
    new symbol
  • Existential Introduction (EI) (also called
    Existential Generalization)
  • for any sentence ?, variable x not in ? and
    ground term g in ?,
  • ? e.g., from Likes(Joe, Candy) we can
    infer
  • ?x ?g/x ?x Likes(x, Candy)

35
A Simple Proof
  • Buffalo(Bob) Bob is a buffalo
  • Pig(Pat) Pat is a pig
  • ?x,y Buffalo(x) Pig(y) -gt Faster(x,y)
    Buffaloes outrun pigs.
  • Prove Faster(Bob,Pat) Bob outruns Pat.
  • Buffalo(Bob) Pig(Pat) -gt Faster(Bob,Pat)
    3,UE xBob,yPat
  • Buffalo(Bob) Pig(Pat) 1,2 Conjunction
  • Faster(Bob,Pat) 5,6 Modus Ponens QED!!

36
Another Proof (longer, but just as simple)
  • C(x) means x is in this class.
  • B(x) means x has read the book.
  • P(x) means x has passed the class.
  • ?x C(x) B(x) (Someone in the class has not
    read the book)
  • ?x C(x) -gt P(x) (Everyone in the class passes)
  • Prove ?x P(x) B(x) (Someone passed and didnt
    read the book)
  • C(a) B(a) 1, EE (a is the skolem constant
    must be new)
  • C(a) 4, And-Elimination (or simplification)
  • C(a) -gt P(a) 2, Universal Instantiation
  • P(a) 5,6 Modus Ponens
  • B(a) 4, And-Elimination (or simplification)
  • P(a) B(a) 7,8 Conjunction
  • ?x P(x) B(x) 9, Existential generalization
    QED!

37
More Inference Techniques
  • Remember ?x P(x) ltgt ?x P(x) ?x P(x) ltgt ?x
    P(x)
  • Say you are doing a proof 1. 2. 3. Prove ?x
    P(x) 4. ?x P(x) Proof by contradiction5. ?x
    P(x) 4, Equivalence6. P(a) 5, EE (a is
    skolem)7.
  • DO YOUR EES FIRST! THEN DO YOU YOUR UES.

38
Logical agents for the Wumpus world
Remember generic knowledge-based agent
  • TELL KB what was perceivedUses a KRL to insert
    new sentences, representations of facts, into KB
  • ASK KB what to do.Uses logical reasoning to
    examine actions and select best.

39
Using the FOL Knowledge Base
Set of solutions
40
Wumpus world, FOL Knowledge Base
41
Deducing hidden properties
42
Situation calculus
43
Describing actions
May result in too many frame axioms
44
Describing actions (contd)
45
Planning
46
Generating action sequences
empty plan
Recursively continue until it gets to empty plan

47
Summary
Write a Comment
User Comments (0)
About PowerShow.com