010'141 Engineering Mathematics II Lecture 20 The Predicate Calculus - PowerPoint PPT Presentation

1 / 38
About This Presentation
Title:

010'141 Engineering Mathematics II Lecture 20 The Predicate Calculus

Description:

'You can't fool all of the people all of the time' 15. Properties of quantifiers ... 'There's a person and a time where the person can't be fooled' 16. Equality ... – PowerPoint PPT presentation

Number of Views:41
Avg rating:3.0/5.0
Slides: 39
Provided by: scSn
Category:

less

Transcript and Presenter's Notes

Title: 010'141 Engineering Mathematics II Lecture 20 The Predicate Calculus


1
010.141 Engineering Mathematics IILecture 20The
Predicate Calculus
  • Bob McKay
  • School of Computer Science and Engineering
  • College of Engineering
  • Seoul National University

2
Outline
  • Why First Order Logic?
  • Syntax and semantics of First Order Logic
  • Using First Order Logic
  • Wumpus world in First Order Logic
  • Knowledge engineering in First Order Logic

3
Pros and cons of propositional logic
  • ? Propositional logic is declarative
  • ? Propositional logic allows partial/
    disjunctive/ negated/ implicational 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)
  • E.g., cannot say "pits cause breezes in adjacent
    squares
  • except by writing one sentence for each square

4
First-order logic
  • Propositional logic assumes the world consists of
    facts
  • First-order logic (like natural language) assumes
    the world contains
  • Objects people, houses, numbers, colors,
    baseball games, wars,
  • Relations red, round, prime, brother of, bigger
    than, part of, comes between,
  • Functions father of, best friend, one more than,
    plus,

5
Syntax of FOL Basic elements
  • Constants KingJohn, 2, SNU,...
  • Predicates Brother, Sibling, gt,...
  • (sibling means either brother or sister)
  • Functions Sqrt, LeftLegOf,...
  • Variables x, y, a, b,...
  • Connectives ?, ?, ?, ?, ?
  • Equality
  • (can be treated as just a special predicate)
  • Quantifiers ?, ?
  • Note we follow standard mathematical
    terminology, so constants have capitals,
    variables are lower case
  • This is the opposite convention to prolog

6
Atomic sentences
  • Atomic sentence predicate (term1,...,termn)
    or term1 term2
  • Term function (term1,...,termn)
    or constant or variable
  • E.g.,
  • Brother(KingJohn,RichardTheLionheart)
  • gt (Length(LeftLegOf(Richard)), Length(LeftLegOf(Ki
    ngJohn)))

7
Complex sentences
  • Complex sentences are made from atomic sentences
    using the same connectives as in the propositional
    calculus
  • ?S, S1 ? S2, S1 ? S2, S1 ? S2, S1 ? S2,
  • E.g.
  • Sibling(KingJohn,Richard)?
  • Sibling(Richard,KingJohn)
  • gt(1,2) ? (1,2)
  • gt(1,2) ? ? gt(1,2)
  • (just as in propositional calculus, they dont
    have to be true!)

8
Models in first-order logic
  • Sentences are true with respect to a model and an
    interpretation
  • Model contains objects (domain elements) and
    relations among them
  • Interpretation specifies meanings for
  • constant symbols ? objects
  • predicate symbols ? relations
  • function symbols ? functional relationships
  • An atomic sentence predicate(term1,...,termn) is
    true
  • iff the objects referred to by term1,...,termn
  • are in the relation referred to by predicate

9
Models for FOL Example
  • Please dont rely on this (or Russel and Norvig)
    for accurate English history

10
Universal quantification
  • ?ltvariablesgt ltsentencegt
  • Says that ltsentencegt is true for all values of
    ltvariablesgt
  • Everyone at SNU is smart
  • ?x (At(x,SNU) ? Smart(x))
  • Formally, ?x P is true in a model m iff for every
    possible value of x as an object in the model, P
    is true
  • Roughly speaking, equivalent to the conjunction
    of instantiations of P
  • (since the model might be infinite, it might be
    an infinite conjunction)
  • At(KingJohn,SNU) ? Smart(KingJohn)
  • ? At(Richard,SNU) ? Smart(Richard)
  • ? At(SNU,SNU) ? Smart(SNU)
  • ? ...

11
A common mistake to avoid
  • English can be a little misleading
  • Maybe Korean too?
  • ? is the connective we most commonly use with ?
  • Common mistake
  • Using ? as the connective with ? when ? is
    intended
  • ?x (At(x,SNU) ? Smart(x))
  • means Everyone is at SNU and everyone is smart
  • (even the people who arent at SNU)

12
Existential quantification
  • ?ltvariablesgt ltsentencegt
  • (there is a way of making sentence true by
    substituting values for variables)
  • Someone at SNU is smart
  • ?x At(x,SNU) ? Smart(x)
  • Formally, ?x P is true in a model m iff P is true
    with x being some possible object in the model.
  • Roughly speaking, it can be seen as equivalent to
    the disjunction of instantiations of P
  • At(KingJohn,SNU) ? Smart(KingJohn)
  • ? At(Richard,SNU) ? Smart(Richard)
  • ? At(SNU,SNU) ? Smart(SNU)
  • ? ...

13
Another common mistake to avoid
  • Typically, ? is the commonest connective used
    with ?
  • Common mistake
  • using ? as the main connective with ?
  • ?x At(x,SNU) ? Smart(x)
  • is true if there is anyone, anywhere (not
    necessarily smart) who is not at SNU!

14
Properties of quantifiers
  • ?x ?y is the same as ?y ?x
  • ?x ?y is the same as ?y ?x
  • ?x ?y is not the same as ?y ?x
  • ?x ?t can_fool_at(x,t)
  • Some people can always be fooled (same people
    all the time)
  • ?t ?x can_fool_at(x,t)
  • Always, there is someone who can be fooled
    (maybe different people)
  • ?t ?x can_fool_at(x,t)
  • Sometimes you can fool everyone
  • ?x ?t can_fool_at(x,t)
  • Everyone has a time when they can be fooled
  • ??x ?t can_fool_at(x,t)
  • You cant fool all of the people all of the time

15
Properties of quantifiers
  • Quantifier duality each can be expressed using
    the other
  • ?x Likes(x,IceCream)?? ??x ?Likes(x,IceCream)
  • ?x Likes(x,Broccoli) ? ??x ?Likes(x,Broccoli)
  • ? x ? t ?can_fool_at(x,t)
  • Theres a person and a time where the person
    cant be fooled

16
Equality
  • term1 term2 is true under a given
    interpretation if and only if term1 and term2
    refer to the same object
  • E.g., definition of 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)

17
Using First Order Logic kinship
  • The kinship domain
  • Brothers are siblings
  • ?x,y Brother(x,y) ? Sibling(x,y)
  • One's mother is one's female parent
  • ?m,c (Mother(m,c) m) ? (Female(m) ?
    Parent(m,c))
  • Sibling is symmetric
  • ?x,y Sibling(x,y) ? Sibling(y,x)

18
Using First Order Logic Sets
  • Defining Sets (Adjoin is a function that adds one
    thing to a set)
  • ?s Set(s) ? ((s ) ? (?x,s2 Set(s2) ? (s
    Adjoin(x,s2))
    )
  • ??x,s adjoin(x,s)
  • The empty set cannot be made by adjoining to
    existing sets
  • ?x,s x ? s ? s Adjoin(x,s)
  • ?x,s x ? s ? ?y,s2 (s adjoin(y,s2) ? (x y ?
    x ? s2))
  • ?s1,s2 s1 ? s2 ? (?x x ? s1 ? x ? s2)
  • ?s1,s2 (s1 s2) ? (s1 ? s2 ? s2 ? s1)
  • ?x,s1,s2 x ? (s1 ? s2) ? (x ? s1 ? x ? s2)
  • ?x,s1,s2 x ? (s1 ? s2) ? (x ? s1 ? x ? s2)

19
Interacting with 1st Order Knowledge
  • Answers to queries can now be more informative
  • Suppose a wumpus-world agent is using First Order
    Logic (FOL) in a Knowledge Base (KB).
  • It perceives a smell and a breeze (but no
    glitter) at t5
  • Tell(KB,Percept(Smell,Breeze,None,5))
  • Ask(KB,?a BestAction(a,5))
  • I.e., does the KB entail some best action at t5?
  • What we would like is an answer like
  • Answer Yes, a/Shoot ? substitution (binding
    list)

20
Interacting with 1st Order Knowledge
  • Given a sentence S and a substitution s,
  • Ss denotes the result of plugging s into S e.g.,
  • S Smarter(x,y)
  • s x/Hillary,y/Bill
  • Ss Smarter(Hillary,Bill)
  • Ask(KB,S) returns some/all s such that KB Ss

21
Knowledge base for wumpus world
  • Remember that the KB needs to handle different
    times
  • Need to model both how to infer the state of the
    World, and what to do about it
  • Perception
  • ?t,s,b Percept(s,b,Glitter,t) ? Glitter(t)
  • Reflex
  • ?t Glitter(t) ? BestAction(Grab,t)
  • This representation cant handle any history
    dependence
  • So infinite loops are likely
  • Requires the agent to build an internal model of
    the World

22
Situation Calculus
  • The World is a sequence of situations
  • snapshots, completely describing the World
  • Effect axioms describe the effect of different
    actions
  • ?x,s ? Holding(x, (Result(Release,s))
  • If an agent releases something, then in the next
    situation, it is not holding it
  • Frame axioms describe the actions which _dont_
    change particular predicates
  • This way, we need to have axioms for every
    combination of state predicates and actions
  • The Frame Problem
  • Once seen as a key weakness of FOL

23
Successor State Axioms
  • An alternative is to use successor state axioms
  • For each predicate, describe the ways in which it
    can change, and the ways in which it stays the
    same
  • ?a,x,s (Holding(x, (Result(a,s))
  • ? (aGrab ? Present(x,s) ? Portable(x)
  • v (Holding(x,s) ? a ? Release)
  • Substantially solve the frame problem
  • One successor state axiom is needed for each
  • way in which Holding can become or remain true
  • way it can become or remain false

24
Deducing hidden properties
  • Describing next-to relationships
  • ?x,y,a,b Adjacent(x,y,a,b) ?
  • a,b ? x1,y, x-1,y,x,y1,x,y-1
  • Properties of squares
  • ?s,t At(Agent,s,t) ? Breeze(t) ? Breezy

25
Deducing hidden properties
  • Squares are breezy near a pit
  • Diagnostic rule---infer cause from effect
  • ?s Breezy(s) ? ?r Adjacent(r,s) ? Pit(r)
  • Often used to model the pragmatic knowledge of
    experts
  • Causal rule---infer effect from cause
  • ?r Pit(r) ? ?s Adjacent(r,s) ? Breezy(s)
  • Model-based reasoning

26
Practical Difficulties with FOL
  • Frame Problem
  • Described previously
  • Ameliorated by successor state axioms
  • But still require two axioms for each state
    predicate
  • Most reasoning is about what stays the same
  • Completely avoiding the frame problem requires
  • Either special purpose logics
  • Higher order logics with special axioms
  • Axioms specify which state predicates are
    affected by which action predicates

27
Practical Difficulties with FOL
  • Qualification Problem
  • Difficult to describe all the ways in which a
    particular action might fail to work
  • Ramification Problem
  • Difficult to describe all the consequences of a
    given action

28
Knowledge engineering in FOL
  • Identify the task
  • Assemble the relevant knowledge
  • Decide on a vocabulary of predicates, functions,
    and constants
  • Encode general knowledge about the domain
  • Encode a description of the specific problem
    instance
  • Pose queries to the inference procedure and get
    answers
  • Debug the knowledge base

29
The electronic circuits domain
  • One-bit full adder

30
The electronic circuits domain
  • Identify the task
  • Does the circuit actually add properly? (circuit
    verification)
  • Assemble the relevant knowledge
  • Composed of wires and gates Types of gates (AND,
    OR, XOR, NOT)
  • Irrelevant size, shape, color, cost of gates
  • Decide on a representation language
  • Alternatives
  • Type(X1) XOR
  • Type(X1, XOR)
  • XOR(X1)

31
The electronic circuits domain
  • Encode general knowledge of the domain
  • ?t1,t2 Connected(t1, t2) ? Signal(t1)
    Signal(t2)
  • ?t Signal(t) 1 ? Signal(t) 0
  • 1 ? 0
  • ?t1,t2 Connected(t1, t2) ? Connected(t2, t1)
  • ?g Type(g) OR ? Signal(Out(1,g)) 1 ? ?n
    Signal(In(n,g)) 1

32
The electronic circuits domain
  • Encode general knowledge of the domain (cont.)
  • ?g Type(g) AND ? Signal(Out(1,g)) 0 ? ?n
    Signal(In(n,g)) 0
  • ?g Type(g) XOR ? Signal(Out(1,g)) 1 ?
    Signal(In(1,g)) ? Signal(In(2,g))
  • ?g Type(g) NOT ? Signal(Out(1,g)) ?
    Signal(In(1,g))

33
The electronic circuits domain
  • Encode the specific problem instance
  • Type(X1) XOR Type(X2) XOR
  • Type(A1) AND Type(A2) AND
  • Type(O1) OR

34
The electronic circuits domain
  • Encode the specific problem instance(cont.)
  • Connected(Out(1,X1),In(1,X2)) Connected(In(1,C1),I
    n(1,X1))
  • Connected(Out(1,X1),In(2,A2)) Connected(In(1,C1),I
    n(1,A1))
  • Connected(Out(1,A2),In(1,O1)) Connected(In(2,C1),
    In(2,X1))
  • Connected(Out(1,A1),In(2,O1)) Connected(In(2,C1),
    In(2,A1))
  • Connected(Out(1,X2),Out(1,C1)) Connected(In(3,C1)
    ,In(2,X2))
  • Connected(Out(1,O1),Out(2,C1)) Connected(In(3,C1)
    ,In(1,A2))

35
The electronic circuits domain
  • Pose queries to the inference procedure
  • What are the possible sets of values of all the
    terminals for the adder circuit?
  • ?i1,i2,i3,o1,o2 Signal(In(1,C1)) i1 ?
    Signal(In(2,C1)) i2 ? Signal(In(3,C1)) i3
    ? Signal(Out(1,C1)) o1 ? Signal(Out(2,C1))
    o2
  • Debug the knowledge base
  • Its easy to accidentally leave out assertions
    like 1 ? 0

36
Summary
  • First-order logic
  • objects and relations are semantic primitives
  • syntax constants, functions, predicates,
    equality, quantifiers
  • Increased expressive power
  • Sufficient to define wumpus world
  • Practical difficulties in describing and
    reasoning about the World
  • Especially about things that dont change or
    change systematically
  • The World stays the same unless something
    specifically changes it
  • Things that are attached to other things usually
    move with them
  • A need for reasoning about default behaviours

37
Summary
  • Why First Order Logic?
  • Syntax and semantics of First Order Logic
  • Using First Order Logic
  • Wumpus world in First Order Logic
  • Knowledge engineering in First Order Logic

38
?????
Write a Comment
User Comments (0)
About PowerShow.com