Advanced Artificial Intelligence Lecture 2: Logic - PowerPoint PPT Presentation

1 / 65
About This Presentation
Title:

Advanced Artificial Intelligence Lecture 2: Logic

Description:

... Giants won' and 'the Reds won' entails 'Either the Giants won or the Reds won' ... KB = Giants won and Reds won. a = Giants won. 7. Entailment and Model Checking ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 66
Provided by: scSn
Category:

less

Transcript and Presenter's Notes

Title: Advanced Artificial Intelligence Lecture 2: Logic


1
Advanced Artificial IntelligenceLecture 2 Logic
  • Bob McKay
  • School of Computer Science and Engineering
  • College of Engineering
  • Seoul National University

2
Outline
  • Propositional Logic
  • Propositional Deduction
  • Predicate Logic
  • Predicae Deduction

3
References
  • Russell, S Norvig, P Artificial Intelligence
    A Modern Approach, Prentice Hall
  • The library has edition 1, call number 006.3
    R917a
  • To buy, edition 2 (1995), ISBN 0137903952
  • Either is fine
  • Nilsson, NJ Artificial Intelligence A New
    Synthesis, Morgan Kaufmann, 1998, ISBN 1 55860
    535 5
  • Library call no 006.3 N599a
  • More detail than youll ever need
  • Leitsch, A The Resolution Calculus, Springer
    1997, ISBN 3 540 61882 1
  • Library call number 511.3 L537r

4
Logic in general
  • Logics are formal languages for representing
    information such that conclusions can be drawn
  • Syntax defines the sentences in the language
  • Semantics define the "meaning" of sentences
  • i.e., define truth of a sentence in a world
  • E.g., the language of arithmetic
  • x2 y is a sentence x2y gt is not a
    sentence
  • x2 y is true iff the number x2 is no less
    than the number y
  • x2 y is true in a world where x 7, y 1
  • x2 y is false in a world where x 0, y 6

5
Entailment
  • Entailment means that one thing follows from
    another
  • KB a
  • Knowledge base KB entails sentence a if and only
    if a is true in all worlds where KB is true
  • E.g., the KB containing the Giants won and the
    Reds won entails Either the Giants won or the
    Reds won
  • E.g., xy 4 entails 4 xy
  • Entailment is a relationship between sentences
    (i.e., syntax) that is based on semantics
    (meaning)

6
Models
  • Logicians think a lot about models
  • Mathematical worlds in which we can check truth
  • We say m is a model of a sentence a if a is true
    in m
  • M(a) is the set of all models of a
  • All the ways a can be true
  • So KB a means M(KB) ? M(a)
  • Ithat is, a is at least as true as KB is
  • E.g.
  • KB Giants won and Reds won
  • a Giants won

7
Entailment and Model Checking
  • Remember our definition
  • Knowledge base KB entails sentence a if and only
    if a is true in all worlds where KB is true
  • One way to check this is to actually construct
    all the possible words where KB is true, and
    check whether a is also true in all of them

8
Whats Wrong with Model Checking?
  • Model checking is expensive
  • If there are N boolean variables, then there are
    2N different models
  • Model checking cost is
  • Exponential in time
  • Linear in space
  • Can we do better?
  • Actually, well see later that the general answer
    is probably not
  • But model checking is exponential for all
    problems
  • Whether difficult or not
  • For many problems, we can do much better

9
Inference
  • Inference is the process of checking correctness
    by procedures that preserve truth
  • KB i a means
  • sentence a can be derived from KB by procedure i
  • Soundness i is sound means
  • whenever KB i a, it is also true that KB a
  • Completeness i is complete means
  • whenever KB a, it is also true that KB i a

10
Inference the cheat sheet
  • We will define a logic expressive enough to say
    many things of interest
  • Known as first-order logic
  • For which there is an inference method which is
  • Sound
  • Complete
  • That is, the method will answer any question
    whose answer follows from what is known by the KB
  • Sounds too good to be true?
  • The fly in the soup
  • The method might go on forever
  • That is, it cant tell us for sure if the
    question has a false answer
  • In fact, its possible to prove that no such
    method could exist
  • But first, we define a weaker logic
  • Propositional Logic

11
Propositional logic Syntax
  • Propositional logic is the simplest practical
    logic
  • The proposition symbols P1, P2 etc are sentences
  • If S is a sentence, (?S) is also (negation)
  • If S1 and S2 are sentences, (S1 ? S)) is also
    (conjunction)
  • If S1 and S2 are sentences, (S1 ? S2) is also
    (disjunction)
  • If S1 and S2 are sentences, S1 ? S2) is also
    (implication)
  • If S1 and S2 are sentences, S1 ? S2) is also
    (biconditional)
  • Since it often doesnt matter, in many cases we
    will leave out the brackets
  • In digital logic, you might have seen for ?, .
    for ?, for ?

12
Propositional logic Semantics
  • A model specifies true/false for each proposition
    symbol
  • E.g. P1,2 P2,2 P3,1
  • false true false
  • With three symbols, 8 possible models, can be
    enumerated automatically.
  • Rules for evaluating truth with respect to a
    model m
  • ?S is true iff S is false
  • S1 ? S2 is true iff S1 is true and S2 is
    true
  • S1 ? S2 is true iff S1is true or S2 is true
  • S1 ? S2 is true iff S1 is false or S2 is true
  • i.e., is false iff S1 is true and S2 is
    false
  • S1 ? S2 is true iff S1?S2 is true andS2?S1 is
    true
  • A simple recursive process evaluates any
    sentence, e.g.
  • ?P1,2 ? (P2,2 ? P3,1) true ? (true ? false)
    true ? true true

13
Truth tables for connectives
14
Truth tables for inference
15
Logical equivalence
  • Two sentences are logically equivalen means
  • They are true in the same models
  • a ß means
  • a ß and ß a

Some well-known equivalences
16
Validity
  • A sentence is valid means
  • it is true in all models,
  • True, A ??A, A ? A, (A ? (A ? B)) ? B
  • Validity is connected with inference in a very
    useful way
  • KB a if and only if (KB ? a) is valid
  • The Deduction Theorem

17
Satisfiability
  • A sentence is satisfiable means
  • it is true in some model
  • A? B, C
  • A sentence is unsatisfiable means
  • it is true in no models
  • A??A
  • Satisfiability is also connected to inference
  • KB a if and only if (KB ??a) is unsatisfiable

18
Inference Rules
  • Inference rules allow us to deduce new true
    sentences from previous ones. There are many
    possible sets, the set below are taken under fair
    dealing use from http//en.wikipedia.org/wiki/Prop
    ositional_logic
  • Double negative elimination
  • From the sentence f, we may infer f
  • Conjunction introduction
  • From any sentences f and ?, we may infer ( f ? ?
    ).
  • Conjunction elimination
  • From any sentence ( f ? ? ), we may infer f and ?
  • Disjunction introduction
  • From any sentence f, we may infer (f ? ?) and (?
    ? f), where ? is any sentence.

19
Inference Rules
  • Disjunction elimination
  • From sentences ( f ? ? ), ( f ? ? ), and ( ? ? ?
    ), we may infer ?.
  • Biconditional introduction
  • From sentences ( f ? ? ) and ( ? ? f ), we may
    infer ( f ? ? ).
  • Biconditional elimination
  • From the sentence ( f ? ? ), we may infer ( f ? ?
    ) and ( ? ? f ).
  • Modus ponens
  • From sentences f and ( f ? ? ), we may infer ?.
  • Conditional proof
  • If ? can be derived by assuming f, we can infer (
    f ? ? ).
  • Reductio ad absurdum
  • If we can derive both ? and ? by assuming f, we
    may infer f.

20
Example Proof
  • Prove (A ? (A ? B)) ? B
  • 1) Assume (A ? (A ? B))
  • 2) Deduce A
  • Conjunction Elimination from 1)
  • 3) Deduce A ? B
  • Conjunction Elimination from 1)
  • 4) Deduce B
  • Modus Ponens from 2) and 3)
  • 5) Deduce (A ? (A ? B)) ? B
  • Conditional Proof from 1) and 4)

21
Properties of our Inference Rules
  • Good
  • Sound
  • We cant derive invalid sentences
  • Complete
  • We will always be able to derive valid sentences
  • Readily used by people
  • People can readily use these rules to derive
    proofs
  • People are good at choosing the right rules to
    use
  • Not so good
  • Not so effective for automated use
  • Its not easy to get machines to choose the right
    rules to make a proof

22
Proof methods
  • Proof methods divide (roughly) into two kinds
  • Application of inference rules
  • Legitimate (sound) generation of new sentences
    from old
  • Like our method from last lecture
  • Proof a sequence of inference rule applications
  • We could use inference rules as steps in a
    standard search algorithm
  • Effective computer searches usually transform
    sentences into a normal form which is simpler for
    automated searching
  • Model checking
  • truth table enumeration (always exponential in n)
  • improved backtracking, e.g., Davis--Putnam-Logeman
    n-Loveland (DPLL)
  • heuristic search in model space (sound but
    incomplete)
  • e.g., min-conflicts-like hill-climbing
    algorithms

23
Proof methods for automated search
  • Our proof method from last lecture isnt very
    good for automated search
  • In essence, guessing the right combination of
    rules to use is a hard problem (even if humans do
    it well)
  • Its even harder for the predicate calculus (next
    lecture)
  • Well look at an alternative, resolution, which
    works well for automated search in both the
    propositional and predicate calculus
  • It requires sentences to be converted to a normal
    form
  • Conjunctive Normal Form (CNF)

24
Conjunctive Normal Form (CNF)
  • An atom means one of the variables of our
    language
  • (A, B, C,.)
  • A literal means either an atom or its negation
  • (A, B, C,.)
  • A clause means a disjunction (or) of literals
  • (A ? B ? C,.)
  • A CNF sentence means a conjunction (and) of
    clauses
  • (A ? ?B) ? (B ? ?C ? ?D)

25
Converting to CNF
  • Every propositional sentence can be
    (systematically) converted to CNF
  • First, replace all equivalences using
    biconditional elimination
  • (A ? B) (A ? B) ? (B ? A)
  • Next, replace all implications using implication
    elimination
  • (A ? B) (?A ? B)
  • Next, move all negations inwards towards atoms
    using de Morgans laws
  • ?(A ? B) (?A ? ?B)
  • ?(A ? B) (?A ? ?B)
  • And remove all multiple negations
  • ? ?A A
  • Now, always move conjunctions to the right using
    commutativity
  • (A ? B) (B ? A)
  • But at the same time, move disjunctions inside
    conjunctions when possible, using distributivity
  • (A ? (B ? C)) (A ? B) ? (A ? C)

26
Converting to CNF
  • The algorithm for converting to CNF finishes in a
    finite amount of time
  • If you wish, you can calculate the maximum time
    it will take to convert a formula of n symbols
  • The sentence it generates is logically equivalent
    to the original sentence
  • Ie it has the same models
  • In particular
  • If one of the sentences is valid, so is the other
  • If one of the sentences is unsatisfiable, so is
    the other

27
Representing in Clausal Form
  • A sentence in CNF consists of a conjunction of
    disjunctions of literals
  • Remember that we dont care about the order of
    conjunctions or disjunctions, or about
    repetitions
  • So we can just represent CNF as a set of sets
  • A, ?B,B, ?C, ?D
  • Instead of
  • (A ? ?B) ? (B ? ?C ? ?D)
  • We just have to remember that the outer set means
    conjunction, the inner one disjunction
  • This is known as clausal form
  • Its easier to explain the resolution method in
    clausal form

28
The Resolution Method
  • Resolution is the basic process used in the
    resolution method
  • There are a number of different (equivalent) ways
    of explaining it
  • Well use a different (slightly more general) one
    from the book
  • Suppose we want to prove A is valid
  • One way of doing this is to prove that ?A is
    unsatisfiable
  • So we start by converting ?A into clausal form
  • Lets take last lectures
  • (A ? (A ? B)) ? B
  • As an example

29
Clausal Form Conversion
  • ?((A ? (A ? B)) ? B)
  • ?(?(A ? (? A ? B)) ? B)
  • (? ?(A ? (? A ? B)) ? ? B)
  • (A ? (? A ? B)) ? ? B
  • A, ?A, B, ?B

30
The Resolution Method
  • The resolution method uses an operator called
    resolution
  • Resolution takes two clauses which have
    complementary literals
  • The same literal with opposite signs
  • X1, X2, Xn, Y and Z1, Z2, Zm, ?Y
  • And creates their resolvent by joining them
    together, deleting the complementary literals
  • X1, X2, Xn, Z1, Z2, Zm
  • You can add the resolvent to the original clause
    set without changing its validity

31
The Resolution Method (Cont)
  • Sometimes, the resolvent is bigger than the
    original clauses
  • But sometimes, its also smaller
  • Notice that as clauses get smaller, they are more
    difficult to satisfy
  • A is harder to satisfy than (A ? B ? C)
  • In the limit, it is consistent to regard the
    empty clause as unsatisfiable ( false)
  • (this requires proof, but its not hard)
  • So a clause set which contains the empty clause
    is a conjunction of clauses, one of which is
    unsatisfiable
  • So the clause set is also unsatisfiable
  • The resolution method uses repeated resolutions
    to try to derive the empty set

32
Resolution Example
  • Take our example
  • ?((A ? (A ? B)) ? B)
  • Which we converted to
  • A, ?A, B, ?B
  • We can resolve the first two clauses
  • A resolved with ?A, B gives B
  • Adding this to our clause set gives
  • A, ?A, B, ?B, B
  • And resolving the last two clauses
  • ?B and B gives

33
Resolution Example (continued)
  • So our new clause set is
  • A, ?A, B, ?B, B
  • Since is unsatisfiable, so is the whole clause
    set
  • So ?((A ? (A ? B)) ? B) is unsatisfiable
  • Which means ((A ? (A ? B)) ? B) is valid
  • Notice that there were fewer choices to make than
    in our previous proof
  • Theres only one rule to choose (resolution)
  • Our only choice is which (of possibly many)
    resolutions to choose

34
Properties of the Resolution Method
  • For the Propositional calculus, the resolution
    method is
  • Sound
  • It will never give incorrect answers
  • Complete
  • For any unsatisfiable clause set, the empty
    clause can be derived in finite time
  • In fact, in exponential time
  • Algorithmic
  • There is an algorithm to guarantee this
  • Relatively efficient
  • Proofs can be quite effective
  • Highly efficient for some sorts of formulas

35
Horn Clauses
  • A Horn Clause is a clause which has at most one
    positive literal
  • There are three cases
  • 1) No positive literal (generally not used much)
  • ? X1, ? X2, ? Xn (? X1 ? ? X2 ? ? ? Xn)
  • 2) No negative literal
  • X (X)
  • A fact
  • 3) General Case
  • ? X1, ? X2, ? Xn, Y (? X1 ? ? X2 ? ? ?
    Xn ? Y)
  • (X1 ? X2 ? ? Xn) ? Y
  • A rule

36
Horn Clauses and Resolution
  • Lets look at the sub-cases
  • 1) and 1) - Cant resolve (no positive literals)
  • 1) and 2) - only one way to do it (not very
    useful)
  • (? X1 ? ? X2 ? ? ? Xn), X1
  • _________________________
  • (? X2 ? ? ? Xn)
  • 1) and 3) - again only one choice (not very
    useful)
  • (? X1 ? ? X2 ? ? ? Xn), (Y1 ? Y2 ? ? Yn) ?
    X1
  • _________________________
  • (? X2 ? ? ? Xn ? ? Y1 ? ? Y2 ? ? ? Yn)

37
Horn Clauses and Resolution
  • 2) and 2) - Cant resolve (no negative literals)
  • 2) and 3) - only one way to do it
  • (Generalised Modus Ponens)
  • X1, (X1 ? X2 ? ? Xn) ? Y
  • _________________________
  • (X2 ? ? Xn) ? Y
  • 3) and 3) - Now there are two choices, lets take
    one
  • (X1 ? X2 ? ? Xn) ? Y1, (Y1 ? Y2 ? ? Yn) ?Z
  • _________________________
  • (X1 ? X2 ? ? Xn ? Y2 ? ? Yn) ?Z
  • In fact, we only need generalised modus ponens
    for Horn clause reasoning
  • Runs in Linear Time

38
First-order logic
  • Whereas propositional logic assumes the world
    contains 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,

39
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

40
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)))

41
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!)

42
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

43
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)
  • ? ...

44
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)
  • ? ...

45
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)
  • ?x ?t 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 fall all of the people all of the
    time
  • 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

46
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)

47
Universal instantiation (UI)
  • Every instantiation of a universally quantified
    sentence is entailed by it
  • ?v aSubst(v/g, a)
  • for any variable v and ground term g
  • E.g., ?x King(x) ? Greedy(x) ? Evil(x) yields
  • King(John) ? Greedy(John) ? Evil(John)
  • King(Richard) ? Greedy(Richard) ? Evil(Richard)
  • King(Father(John)) ? Greedy(Father(John)) ?
    Evil(Father(John))
  • .
  • .

48
Existential instantiation (EI)
  • For any sentence a, variable v, and constant
    symbol k that does not appear elsewhere in the
    knowledge base
  • ?v a
  • Subst(v/k, a)
  • E.g., ?x Crown(x) ? OnHead(x,John) yields
  • Crown(C1) ? OnHead(C1,John)
  • provided C1 is a new constant symbol, called a
    Skolem constant
  • (Easiest to think of this in terms of adding a
    new individual to the World it can have any
    relationships you like)
  • (There is a slight complication here
  • what about ? x (xJohn)?
  • Generates a new Skolem constant C2 which is
    not John, but is in every respect identical to
    John.
  • Even worse, you can make the statement that
    there is only one thing equal to John, and still
    have two things satisfy it!

49
Reduction to propositional inference
  • Suppose the KB contains just the following
  • ?x King(x) ? Greedy(x) ? Evil(x)
  • King(John)
  • Greedy(John)
  • Brother(Richard,John)
  • Instantiating the universal sentence in all
    possible ways, we have
  • King(John) ? Greedy(John) ? Evil(John)
  • King(Richard) ? Greedy(Richard) ? Evil(Richard)
  • King(John)
  • Greedy(John)
  • Brother(Richard,John)
  • The new KB is propositionalised proposition
    symbols are
  • King(John), Greedy(John), Evil(John),
    King(Richard), etc.

50
Reduction
  • Every first order KB can be propositionalised so
    as to preserve entailment
  • ( ground sentences are entailed by new KB iff
    entailed by original KB)
  • A ground sentence is one with no variables
  • Idea
  • propositionalise the KB
  • ask a query
  • apply resolution
  • return the result
  • Problem
  • with function symbols, there are infinitely many
    ground terms,
  • Father(Father(Father(John)))

51
Reduction contd.
  • Theorem Herbrand (1930) For first order logic
  • If a sentence a is entailed by a knowledge base
  • Then it is entailed by a finite subset of
    propositionalised KB
  • Idea For n 0 to 8 do
  • create a propositional KB by instantiating
    with depth-n terms
  • see if a is entailed by this KB
  • Problem works if a is entailed, loops if a is
    not entailed
  • Theorem Turing (1936), Church (1936) Entailment
    for FOL is
    semi-decidable
  • Algorithms exist that say yes to every entailed
    sentence
  • But no algorithm exists that also says no to
    every non-entailed sentence

52
Problems with propositionalisation
  • Propositionalisation generates many
    irrelevant-seeming sentences.
  • E.g., from
  • ?x King(x) ? Greedy(x) ? Evil(x)
  • King(John)
  • ?y Greedy(y)
  • Brother(Richard,John)
  • it seems obvious that Evil(John), but
    propositionalisation produces lots of facts such
    as Greedy(Richard) that seem irrelevant
  • With p k-ary predicates and n constants, there
    are pnk instantiations.

53
Unification
  • if we can find a substitution ? such that King(x)
    and Greedy(x) match King(John) and Greedy(y)
  • We dont need to generate all these irrelevant
    instances
  • We can generate the inference immediately
  • ? x/John,y/John does this
  • In general,
  • Unify(a,ß) ? if a? ß?
  • p q ?
  • Knows(John,x) Knows(John,Jane)
  • Knows(John,x) Knows(y,OJ)
  • Knows(John,x) Knows(y,Mother(y))
  • Knows(John,x) Knows(x,OJ)
  • Standardizing apart eliminates overlap of
    variables, e.g., Knows(z17,OJ)

54
Unification
  • if we can find a substitution ? such that King(x)
    and Greedy(x) match King(John) and Greedy(y)
  • We dont need to generate all these irrelevant
    instances
  • We can generate the inference immediately
  • ? x/John,y/John does this
  • In general,
  • Unify(a,ß) ? if a? ß?
  • p q ?
  • Knows(John,x) Knows(John,Jane) x/Jane
  • Knows(John,x) Knows(y,OJ)
  • Knows(John,x) Knows(y,Mother(y))
  • Knows(John,x) Knows(x,OJ)
  • Standardizing apart eliminates overlap of
    variables, e.g., Knows(z17,OJ)

55
Unification
  • if we can find a substitution ? such that King(x)
    and Greedy(x) match King(John) and Greedy(y)
  • We dont need to generate all these irrelevant
    instances
  • We can generate the inference immediately
  • ? x/John,y/John does this
  • In general,
  • Unify(a,ß) ? if a? ß?
  • p q ?
  • Knows(John,x) Knows(John,Jane) x/Jane
  • Knows(John,x) Knows(y,OJ) x/OJ, y/John
  • Knows(John,x) Knows(y,Mother(y))
  • Knows(John,x) Knows(x,OJ)
  • Standardizing apart eliminates overlap of
    variables, e.g., Knows(z17,OJ)

56
Unification
  • if we can find a substitution ? such that King(x)
    and Greedy(x) match King(John) and Greedy(y)
  • We dont need to generate all these irrelevant
    instances
  • We can generate the inference immediately
  • ? x/John,y/John does this
  • In general,
  • Unify(a,ß) ? if a? ß?
  • p q ?
  • Knows(John,x) Knows(John,Jane) x/Jane
  • Knows(John,x) Knows(y,OJ) x/OJ, y/John
  • Knows(John,x) Knows(y,Mother(y))
    x/Mother(John), y/John
  • Knows(John,x) Knows(x,OJ)
  • Standardizing apart eliminates overlap of
    variables, e.g., Knows(z17,OJ)

57
Unification
  • if we can find a substitution ? such that King(x)
    and Greedy(x) match King(John) and Greedy(y)
  • We dont need to generate all these irrelevant
    instances
  • We can generate the inference immediately
  • ? x/John,y/John does this
  • In general,
  • Unify(a,ß) ? if a? ß?
  • p q ?
  • Knows(John,x) Knows(John,Jane) x/Jane
  • Knows(John,x) Knows(y,OJ) x/OJ, y/John
  • Knows(John,x) Knows(y,Mother(y))
    x/Mother(John), y/John
  • Knows(John,x) Knows(x,OJ) fail
  • Standardizing apart eliminates overlap of
    variables, e.g., Knows(z17,OJ)

58
Unification
  • To unify Knows(John,x) and Knows(y,z),
  • ? y/John, x/z or ? y/John, x/John,
    z/John
  • The first unifier is more general than the
    second.
  • A unifier is a most general unifier (MGU) if no
    other unifier is more general
  • Theorem any two MGUs are equivalent in the sense
    that we can get one from the other just by
    renaming variables
  • We say the MGU is unique up to renaming of
    variables
  • Note that we dont guarantee an MGU exists
  • MGU y/John, x/z

59
The unification algorithm
60
The unification algorithm
61
Generalized Modus Ponens (GMP)
  • p1', p2', , pn', ( p1 ? p2 ? ? pn ?q)
  • q?
  • Example
  • p1' is King(John) p1 is King(x)
  • p2' is Greedy(y) p2 is Greedy(x)
  • ? is x/John,y/John q is Evil(x)
  • q ? is Evil(John)
  • GMP is used with KBs of definite clauses
  • exactly one positive literal
  • All variables assumed universally quantified

T is chosen so that pi'? pi ? for all i
62
Logic programming Prolog
  • Basic Idea Algorithm Logic Control
  • An algorithm can be expressed as logical
    relationships
  • Combined with a control strategy for determining
    the order of proofs attempted
  • Backward chaining proof strategy
  • Horn clauses some extensions
  • Especially, more than one positive literal
  • Un-soundly implemented negation

63
Prolog details
  • Program set of clauses
  • head - literal1, literaln.
  • criminal(X) - american(X), weapon(Y),
    sells(X,Y,Z), hostile(Z).
  • In a more standard predicate logic, this would be
    written
  • ?x,y,z (American(x) Weapon(y)
  • Sells(x,y,z) Hostile(z)
  • ? Criminal(x))

64
Prolog
  • Appending two lists to produce a third
  • append(,Y,Y).
  • append(XL,Y,XZ) - append(L,Y,Z).
  • In predicate calculus, we would write this as
  • ?x, Append(Empty, y, y)
  • ? x, y, z, l (append(l, y, z) ? append(join(x,
    l), y, join(x,z)) )
  • query append(A,B,1,2) ?
  • answers A B1,2
  • A1 B2
  • A1,2 B

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