Chapter Nine - PowerPoint PPT Presentation

1 / 55
About This Presentation
Title:

Chapter Nine

Description:

The illustration requires two iterations to establish that West is a criminal. Forward Chaining ... in a top-down fashion. Fig. 9.6 a simple backtracking ... – PowerPoint PPT presentation

Number of Views:45
Avg rating:3.0/5.0
Slides: 56
Provided by: willia201
Category:
Tags: chapter | nine

less

Transcript and Presenter's Notes

Title: Chapter Nine


1
Chapter Nine
  • Inference In First-Order Logic

2
Propositional vs. First-Order Inference
  • We first examine rules that permit the conversion
    of sentences involving quantifiers to sentences
    that have no quantifiers
  • That is, we can convert sentences in first-order
    logic to sentences of propositional logic
  • We can then use the inference algorithms
    introduced in Chapter Seven

3
Inference Rules For Quantifiers
  • Rule of Universal Instantiation we can infer
    any sentence obtained by replacing any variable
    with a ground term
  • To express this formally, we use the following
    notation
  • Subst(v,g,?) the result of replacing every
    occurrence of variable v in sentence ? with
    ground term g

4
Inference Rules For Quantifiers
  • ?v ? entails Subst(v,g,?) for every ground term
    g
  • The rule for existential quantification is
    somewhat more complicated
  • It requires the introduction of a new constant
    that is not currently in the KB
  • Called a Skolem constant

5
Inference Rules For Quantifiers
  • ?v ? entails Subst(v,k,?) where k is a Skolem
    constant
  • A subtle difference between universal
    instantiation and existential instantiation
  • Universal instantiation can be applied repeatedly
    to a given sentence
  • Existential instantiation is used once, and then
    the sentence is deleted

6
Inference Rules For Quantifiers
  • The KB obtained using existential instantiation
    is not logically equivalent to the original, but
    it is inferentially equivalent
  • The resulting KB is satisfiable if and only if
    the original KB is satisfiable

7
Propositionalization
  • Process of converting a first-order KB to a KB of
    propostions
  • First, we apply Skolemization to remove all
    existentially quantified variables
  • Then replace each sentence involving universal
    quantification with the set of sentences
    representing all possible ground term
    substitutions

8
Propositionalization
  • It might seem that we have a complete decision
    procedure for entailment
  • The possible occurrence of function symbols in
    the KB creates a problem
  • Let F be a function of arity one and let C be a
    constant symbol
  • An infinite family of ground terms can be
    generated F(C), F(F(C)), F(F(F(C))),

9
Propositionalization
  • The original KB may involve a finite number of
    sentences, but propositionalization can lead to a
    KB with infinitely many sentences
  • The inference algorithms for propositional logic
    may not terminate for such KBs
  • But all is not lost!

10
Propositionalization
  • Herbrand (1930) proved that for any sentence
    entailed by the original, first-order KB, there
    is a proof of the sentence involving a finite
    subset of the subset of the propositionalized KB
  • We can proceed iteratively
  • First, try to infer a sentence using only
    constant symbols

11
Propositionalization
  • Then try using the KB with single function
    applications, F(C) for every function symbol F
    and constant symbol C
  • Then use the KB with ground terms of the form
    F(F(C)) and so on until the sentence is inferred
  • This approach is complete any entailed sentence
    can be proved

12
Propositionalization
  • But if the sentence is not entailed, the
    procedure does not terminate!
  • Turing (1930) and Church (1936) independently
    established that this is inevitable

13
Propositionalization
  • Entailment in first-order logic is semi-decidable
    algorithms exist that establish the entailment
    of sentences that are inferred from a KB
  • But no algorithm exists that is able to establish
    that every sentence that is not inferred by the
    KB is not entailed by a KB

14
Unification And Lifting
  • Consider the sentences?x King(x) ? Greedy(x) ?
    Evil(x)King(John)Greedy(John)
  • We should be able to infer Evil(John)
  • Propositionalization would apply all possible
    instantiations to the first sentence
  • But here we need only one ? x/John

15
Unification And Lifting
  • But suppose instead we have?x King(x) ?
    Greedy(x) ? Evil(x)King(John)?y Greedy(y)
  • In this case, the substitution ?
    x/John,y/John will yield what is needed
  • Rather surprisingly, both cases are captured in a
    single inference rule

16
Generalized Modus Ponens
  • Let pi, pi?, and q be atomic sentences and ? be a
    substitution for whichSubst(?, pi?) Subst(?,
    pi) for all i
  • Then p1?, p2?,, pn?, (p1 ? p2 ? ? pn ? q)
    logically entails Subst(?, q)
  • Generalized modus ponens is sound
  • Let p be a sentence in which all variables are
    universally quantified

17
Generalized Modus Ponens
  • Then by the rule of Universal Instantiation, it
    follows that for any substitution ?,p entails
    Subst(?, p)
  • From p1?, p2?,, pn? we can infer Subst(?, p1?),
    Subst(?, p2?),, Subst(?, pn?)
  • From (p1 ? p2 ? ? pn ? q) we can infer Subst(?,
    p1) ? Subst(?, p2) ? ? Subst(?, pn) ? Subst(?,
    q)

18
Generalized Modus Ponens
  • For the substitution ? satisfying Subst(?, pi?)
    Subst(?, pi) for all i, the first sentence
    matches the premise of the second
  • So Subst(?, q) follows by modus ponens
  • We say that generalized modus ponens is a lifted
    version of modus ponens
  • Well derive lifted versions of resolution,
    forward chaining, and backward chaining

19
Unification
  • To use generalized modus ponens, we need to find
    a substitution ? satisfying Subst(?, pi?)
    Subst(?, pi) for all i
  • The process is called unification
  • Algorithm Unify accepts two sentences p and q and
    returns a substitution ?, called a unifier, for
    which Subst(?, p) Subst(?, q), if such a
    substitution exists

20
Unification
  • Symbolically, Unify(p,q) ? where Subst(?, p)
    Subst(?, q)
  • Unify(Knows(John,x),Knows(John,Jane)) x/Jane
  • Unify(Knows(John,x),Knows(y,Bill))
    x/Bill,y/John
  • Unify(Knows(John,x),Knows(x,Bill)) fail
  • x cannot be simultaneously John and Bill

21
Unification
  • But the sentence Knows(John,x) means John knows
    everyone
  • So we should be able to infer Knows(John,Bill)
  • The problem arises because the two sentences use
    the same variable name
  • The problem can be resolved by standardizing apart

22
Standardizing Apart
  • Knows(John,x) has the same meaning as
    Knows(John,y)
  • Standardizing apart renames variables to avoid
    name clashes
  • One final issue there may be more than one
    unifier
  • Unifiers for Knows(Joe,x) and Knows(y,z) include
    y/Joe,x/z and y/Joe,x/Joe,z/Joe

23
Most General Unifier
  • The first unifier yields Knows(John,z)
  • The second yields Knows(John,John)
  • The second can be obtained from the first using
    the substitution z/John
  • We say that the first unifier generalizes the
    second
  • For any unifiable pair of expressions, there is a
    single most general unifier

24
Most General Unifier
  • Fig. 9.1 a recursive algorithm for computing
    the most general unifier
  • Each argument x or y may be a variable, a
    constant, a compound expression, or a list of
    expressions
  • Algorithm occur check examines whether its first
    argument, a variable, appears in its second
    argument, an arbitrary expression

25
Occur Check
  • If the variable appears in the expression, there
    is no consistent unifier, so Occur-Check? returns
    false
  • Occur-Check? causes the entire algorithm to have
    time complexity that is quadratic in the size of
    the expressions being matched
  • Many logic systems omit the occur check step, and
    may make unsound inferences

26
Forward Chaining
  • We can generalize forward chaining for
    propositional logic to first-order logic
  • Like forward chaining for propositional logic, it
    requires that the KB contains only definite
    clauses
  • First-order definite clause a disjunction of
    literals with exactly one positive literal

27
Forward Chaining
  • Literals in first-order logic may contain
    variables
  • The variables are assumed to be univer-sally
    quantified i.e., P(x) means ?x P(x)
  • As with propositional logic, each definite clause
    containing a negative literal is equivalent to an
    implication
  • One use represent Situation ? Action

28
Forward Chaining
  • Definite clauses are amenable to use with
    generalized modus ponens
  • Forward chaining can be implemented more
    efficiently than resolution
  • Not all KBs can be represented using only
    definite clauses, but many can
  • Book provides an illustration pp. 280282

29
An Illustration
  • it is a crime for an American to sell weapons
    to a hostile nation
  • American(x) ? Weapon(y) ? Sells(x,y,z) ?
    Hostile(z) ? Criminal(x)
  • Nono has some missiles.
  • Sentence ?x Owns(Nono,x) ? Missile(x) transformed
    using existential instantiation into
    Owns(Nono,M1), Missile(M1)

30
An Illustration
  • All of its missiles were sold to it by Colonel
    West.
  • Missile(x) ? Owns(Nono,x) ? Sells(West,x,Nono)
  • Missiles are weapons Missile(x) ? Weapon(x)
  • Enemy of America ? hostile Enemy(x,America) ?
    Hostile(x)

31
An Illustration
  • West, who is an American
  • American(West)
  • The country Nono, an enemy of America
  • Enemy(Nono,America)
  • An example of a datalog a set of first-order
    definite clauses with no function symbols

32
Forward Chaining
  • Fig. 9.3 A simple algorithm implementing
    forward chaining
  • Algorithm keeps track of the known facts
  • During each iteration, it attempts to satisfy the
    premise of each rule with the currently known
    facts
  • If a premise is satisfied, its conclusion is
    added to the set of known facts

33
Forward Chaining
  • Process continues until the query is answered or
    no new facts are added
  • A fact is not new if it is the renaming of a
    currently known fact
  • One fact is a renaming of another if they differ
    only in the names of variables
  • The illustration requires two iterations to
    establish that West is a criminal

34
Forward Chaining
  • Fig. 9.4 a proof tree for the illustration
  • Leaves the initial facts in the KB
  • Nodes of depth one facts added during the first
    iteration
  • Root fact added during second iteration
  • Algorithm would have stopped because we have
    inferred the query, but note that no further
    facts could have been added

35
Forward Chaining
  • As with forward chaining for propositional logic,
    the resulting KB is called a fixed point
  • Fixed points in first-order forward chaining may
    contain universally quantified literals
  • Forward chaining is sound every inference is
    the result of applying generalized modus ponens

36
Forward Chaining
  • Forward chaining is also complete for KBs that
    contain only definite clauses
  • It answers every query that is entailed by a KB
    of definite clauses
  • Proof for KBs with function symbols uses
    Herbrands theorem
  • Exhibits the same (unavoidable) problem as
    propositionalization semidecidability

37
Forward Chaining
  • Fig. 9.3 is presented for its simplicity
  • Not a very efficient implementation
  • The inner loop identifies all possible unifiers
    for which the premise of a rule unifies with a
    subset of the currently known facts
  • This pattern matching is difficult to do
    efficiently

38
Forward Chaining
  • Furthermore, the simple algorithm performs the
    same pattern matching during successive
    iterations
  • A final source of inefficiency is that it may
    waste time inferring facts that are irrelevant to
    answering the query
  • Backward chaining a family of algorithms that
    avoids drawing irrelevant conclusions

39
Backward Chaining
  • Works backward from the goal
  • Conceptually, it builds a proof tree similar to
    that produced by forward chaining
  • But the tree is constructed in a top-down fashion
  • Fig. 9.6 a simple backtracking algorithm
  • Maintains a list of goals (maintained as a stack)

40
Backward Chaining
  • List of goals initially contains the query
  • Also maintains a current substitution (initially
    empty)
  • The algorithm is recursive
  • Builds the tree in depth first order
  • Pops a goal from the stack and identifies every
    clause whose head unifies with the goal

41
Backward Chaining
  • For each such clause, makes a recursive call with
    the list obtained by pushing the body of the
    clause onto the stack
  • If the clause is a fact (empty body), the goal is
    satisfied, and nothing is pushed onto the stack
  • The substitution for a recursive call is built
    using composition

42
Backward Chaining
  • Composition of substitutions a function
    Compose(?1, ?2)
  • Subst(Compose(?1, ?2), p) Subst(?2,
    Subst(?1,p))
  • Fig. 9.7 The proof tree constructed using
    backward chaining
  • Nodes are added from top down, and left to right

43
Backward Chaining
  • Some nodes labeled with a substitution
  • Represents the union of the substitutions
    returned by the recursive calls
  • These substitutions are propagated in later
    recursive calls
  • Like forward chaining, backward chaining suffers
    from problems with repeated states and
    incompleteness

44
Logic Programming
  • Some of these problems can be circumvented using
    more complex algorithms
  • Backward chaining is used as the basis for logic
    programming
  • Approaches the ideal of the declarative approach
    to programming
  • Algorithm Logic Control

45
Prolog
  • The most widely used logic programming language
  • Prolog uses a nonstandard notation for expressing
    clauses
  • Variables are uppercase letters, constants are in
    lowercase
  • criminal(X) - american(X), weapon(Y),sells(X,Y,Z
    ), hostile(Z).

46
Prolog
  • Execution of a Prolog program uses depth-first
    backward chaining
  • Important clauses are checked in the order that
    they appear in the KB
  • Changing the order of the clauses may affect
    whether or not a query can be proved
  • That is, Prolog is incomplete

47
Resolution
  • Resolution as an inference procedure can be
    extended to first-order logic
  • We first define conjunctive normal form (CNF) for
    first-order logic
  • A conjunction of clauses, where each clause is a
    disjunction of literals
  • Literals may contain variables, which are assumed
    to be universally quantified

48
Resolution
  • Every sentence of first-order logic can be
    converted into an inferentially equivalent CNF
    sentence
  • A constructive proof is presented, similar to
    that for propositional logic
  • Illustrated using the sentence?x ?y Animal(y) ?
    Loves(x,y) ? ?y Loves(y,x)

49
Conjunctive Normal Form
  • Eliminate implications
  • ?x ?y Animal(y) ? Loves(x,y) ? ?y
    Loves(y,x)
  • Move inwards
  • ?x ?y (Animal(y) ? Loves(x,y)) ? ?y
    Loves(y,x)
  • ?x ?y Animal(y) ? Loves(x,y) ? ?y
    Loves(y,x)

50
Conjunctive Normal Form
  • ?x ?y Animal(y) ? Loves(x,y) ? ?y
    Loves(y,x)
  • Standardize variables
  • ?x ?y Animal(y) ? Loves(x,y) ? ?z
    Loves(z,x)
  • Skolemization requires some care
  • Cant simply use existential instantiation

51
Conjunctive Normal Form
  • ?x Animal(A) ? Loves(x,A)? Loves(z,B)
    conveys the wrong meaning
  • We need to use Skolem functions
  • ?x Animal(F(x)) ? Loves(x,F(x)) ?
    Loves(G(x),x)
  • Drop universal quantifiers
  • Animal(F(x)) ? Loves(x,F(x)) ?
    Loves(G(x),x)

52
Conjunctive Normal Form
  • Distribute ? over ?
  • Animal(F(x)) ? Loves(G(x),x) ?
    Loves(x,F(x)) ? Loves(G(x),x)
  • Now quite unreadable, but in a form suitable for
    resolution
  • The translation can be fully automated

53
Resolution Inference Rule
  • Two clauses can be resolved if they contain a
    pair of complementary literals
  • Let l1 ? l2 ? ? lk, and m1 ? m2 ? ? mn, be
    two clauses, with Unify(li,mj) ?
  • Then we can infer the clause Subst(?,l1 ??
    li1 ? li1 ?? lk ?m1 ?? mj1? mj1 ?? mn)
  • The above rule is called binary resolution

54
Resolution Inference Rule
  • Binary resolution by itself is not a complete
    inference procedure
  • Full resolution resolves subsets of literals
  • First-order factoring replace two literals that
    are unifiable with a single literal
  • Unifier is applied to the entire clause
  • Binary resolution together with factoring is a
    complete inference procedure

55
Resolution
  • Uses proof by contradiction
  • To show that a query ? is entailed by KB, we show
    that KB ? ? is unsatisfiable by deriving the
    empty clause
  • Fig. 9.11 a resolution proof that West is a
    criminal
Write a Comment
User Comments (0)
About PowerShow.com