+ All Categories
Home > Documents > 09 Inference

09 Inference

Date post: 26-Feb-2018
Category:
Upload: raedadobeadobe
View: 221 times
Download: 0 times
Share this document with a friend

of 33

Transcript
  • 7/25/2019 09 Inference

    1/33

    Artificial Intelligence

    Inference in First-Order Logic

    Readings: Chapter 9 of Russell &

    Norvig.

  • 7/25/2019 09 Inference

    2/33

  • 7/25/2019 09 Inference

    3/33

    Universal instantiation (UI)

    Every instantiation of a universally quantified sentence isentailed by it:

    v

    SUBST({v/g}, )

    for any variablev and ground termg

    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(Fathe...

  • 7/25/2019 09 Inference

    4/33

    Existential instantiation (EI)

    For any sentence, variablev, and constant symbolkthat does not appear elsewhere in the knowledge base:

    v SUBST({v/k}, )

    E.g., x Crown(x) OnHead(x,John)yields

    Crown(C1) OnHead(C1,John)

    providedC1 is a new constant symbol, called a Skolemconstant.

  • 7/25/2019 09 Inference

    5/33

    UI versus EI

    Fromxy(y+x=y)we obtain

    y+a=y

    From x y(y+x=y)we obtain

    y+e=y

    providedeis a new constant symbol.

    UI can be applied several times to addnew sentences;

    the new KB is logically equivalent to the old.EI can be applied once toreplacethe existentialsentence; the new KB isnotequivalent to the old, but is

    satisfiable iff the old KB was satisfiable.

  • 7/25/2019 09 Inference

    6/33

    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 inall possibleways, we have

    King(John) Greedy(John) = Evil(John)

    King(Richard) Greedy(Richard) = Evil(Richard)

    King(John)

    Greedy(John)

    Brother(Richard, J ohn)

    The new KB is propositionalized: proposition symbols are

  • 7/25/2019 09 Inference

    7/33

    Reduction to Propositional Inference

    Claim: a ground sentence is entailed by new KB iffentailed by original KB.

    Claim: every FOL KB can be propositionalized so as to

    preserve entailment.Idea: propositionalize KB and query, apply resolution,return result.

    Problem: with function symbols, ground terms areinfinitely many, e.g.,Father(Father(Father(John))).

    Theorem: Herbrand (1930). If a sentenceis entailed

    by an FOL KB, it is entailed by afinitesubset of thepropositional KB.

    Idea: Forn= 0 to, create a propositional KB by

    instantiating with depth-nterms see ifis entailed bythis KB.

    Problem: works if is entailed, loo s ifis not entailed

  • 7/25/2019 09 Inference

    8/33

  • 7/25/2019 09 Inference

    9/33

    Unification

    We can get the inference immediately if we can find asubstitution such thatKing(x)andGreedy(x)matchKing(John)andGreedy(y). That is,={x/John, y/John}works

    UNIFY(, ) =if =

    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)

  • 7/25/2019 09 Inference

    10/33

    Unification

    We can get the inference immediately if we can find asubstitution such thatKing(x)andGreedy(x)matchKing(John)andGreedy(y). That is,={x/John, y/John}works

    UNIFY(, ) =if =

    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)

  • 7/25/2019 09 Inference

    11/33

    Unification

    We can get the inference immediately if we can find asubstitution such thatKing(x)andGreedy(x)matchKing(John)andGreedy(y). That is,={x/John, y/John}works

    UNIFY(, ) =if =

    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)

  • 7/25/2019 09 Inference

    12/33

    Unification

    We can get the inference immediately if we can find asubstitution such thatKing(x)andGreedy(x)matchKing(John)andGreedy(y). That is,={x/John, y/John}works

    UNIFY(, ) =if =

    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)) {y/John, x/M other(J

    Knows(John,x) Knows(x,OJ)

  • 7/25/2019 09 Inference

    13/33

    Unification

    We can get the inference immediately if we can find asubstitution such thatKing(x)andGreedy(x)matchKing(John)andGreedy(y). That is,={x/John, y/John}works.

    UNIFY(, ) =if =

    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)) {y/John, x/M other(J

    Knows(John,x) Knows(x,OJ) fail

    Standardizing apart eliminates overlap of variables, e.g.,Knows(z17, OJ)

  • 7/25/2019 09 Inference

    14/33

    Conversion to CNF

    Everyone who loves all animals is loved by someone:

    x [ y Animal(y) = Loves(x, y)] = [ y Loves(y, x)]

    1. Eliminate biconditionals and implications

    x [ y Animal(y) Loves(x, y)] [ y Loves(y, x)]

    2. Moveinwards: x, p x p, x, p x p:

    x [ y (Animal(y) Loves(x, y))] [ y Loves(y, x)]

    x [ y Animal(y) Loves(x, y)] [ y Loves(y, x)]

    x [ y Animal(y) Loves(x, y)] [ y Loves(y, x)]

  • 7/25/2019 09 Inference

    15/33

    Conversion to CNF contd.

    3. Standardize variables: each quantifier should use adifferent one

    x [ y Animal(y) Loves(x, y)] [ z Loves(z, x)]

    4. Skolemize: a more general form of existentialinstantiation. Each existential variable is replaced by aSkolem function of the enclosing universally quantified

    variables:

    x [Animal(F(x)) Loves(x, F(x))] Loves(G(x), x)

  • 7/25/2019 09 Inference

    16/33

    Conversion to CNF contd.

    5. Drop universal quantifiers:[Animal(F(x)) Loves(x, F(x))] Loves(G(x), x)

    6. Distributeover:[Animal(F(x))Loves(G(x), x)][Loves(x, F(x))Loves(G(x), x

    G li d M d P (GMP)

  • 7/25/2019 09 Inference

    17/33

    Generalized Modus Ponens (GMP)

    p1, p2

    , . . . , pn, (p1p2 . . .pnq)

    q wherepi

    =pi

    p1 isKing(John) p1 isKing(x)

    p2 isGreedy(y) p2 isGreedy(x)

    is{x/John, y/John} qisEvil(x)

    qisEvil(John)

    GMP used with KB of definite clauses (those clauseshavingexactlyone positive literal).

    All variables assumed universally quantified

    S d f GMP

  • 7/25/2019 09 Inference

    18/33

    Soundness of GMP

    Need to show that

    p1, . . . , pn

    , (p1 . . .pnq)|=q

    provided thatpi =pifor alli

    Lemma: For any definite clausep, we havep|=pby UI1. (p1. . .pnq)|= (p1. . .pnq))and

    (p1. . .pnq) = (p1. . .pnq)

    2. p1

    , . . . , pn

    |=p1

    . . .pn

    |=p1

    . . .pn

    3. From 1 and 2,qfollows by ordinary Modus Ponens

    R l ti

  • 7/25/2019 09 Inference

    19/33

    Resolution

    Full first-order version:1 k, m1 mn

    (1 i1i+1 k m1 mj1 mj+1

    where UNIFY(i, mj) = .

    For example,

    Rich(x) Unhappy(x)

    Rich(Ken)

    Unhappy(Ken)

    with={x/Ken}.

    S d f R l ti

  • 7/25/2019 09 Inference

    20/33

    Soundness of Resolution

    Need to show1 k, m1 mn|= c

    where c

    is(1 i1i+1 k m1 mj1mj+1 mn)and UNIFY(i, mj) = .

    This is true because

    1. 1 k |= (1 k)by UI,

    2. m1 mn|= (m1 mn)by UI, and

    3. (1 k)and(m1 mn)imply cbypropositional resolution.

    Using Resol tion

  • 7/25/2019 09 Inference

    21/33

    Using Resolution

    1. ObtainCN F(KB )

    2. Apply resolution steps to the CNF

    3. If the empty clause is generated, thenKB |=.

    Theorem: Resolution is a refutationally complete inferencesystem forKB|=.

    Example Knowledge Base

  • 7/25/2019 09 Inference

    22/33

    Example Knowledge Base

    The law says that it is a crime for an American to sellweapons to hostile nations. The country Nono, an enemy ofAmerica, has some missiles, and all of its missiles were

    sold to it by Colonel West, who is American.

    Prove that Col. West is a criminal

    Example Knowledge Base contd

  • 7/25/2019 09 Inference

    23/33

    Example Knowledge Base contd.

    . . .it is a crime for an American to sell weapons to hostilenations:

    Example Knowledge Base contd

  • 7/25/2019 09 Inference

    24/33

    Example Knowledge Base contd.

    . . .it is a crime for an American to sell weapons to hostilenations:

    American(x) Weapon(y) Sells(x,y,z)Hostile(z) =

    Criminal(x)Nono. . .has some missiles

    Example Knowledge Base contd

  • 7/25/2019 09 Inference

    25/33

    Example Knowledge Base contd.

    . . .it is a crime for an American to sell weapons to hostilenations:

    American(x) Weapon(y) Sells(x,y,z)Hostile(z) =

    Criminal(x)Nono. . .has some missiles, i.e., x Owns(Nono,x) M issile(x):

    Owns(Nono,M1)andMissile(M1). . .all of its missiles were sold to it by Colonel West

    Example Knowledge Base contd

  • 7/25/2019 09 Inference

    26/33

    Example Knowledge Base contd.

    . . .it is a crime for an American to sell weapons to hostilenations:

    American(x) Weapon(y) Sells(x,y,z)Hostile(z) =

    Criminal(x)Nono. . .has some missiles, i.e., x Owns(Nono,x) M issile(x):

    Owns(Nono,M1)andMissile(M1). . .all of its missiles were sold to it by Colonel West

    x M issile(x) Owns(Nono,x) = Sells(West,x,Nono)Missiles are weapons:

    Example Knowledge Base contd

  • 7/25/2019 09 Inference

    27/33

    Example Knowledge Base contd.

    . . .it is a crime for an American to sell weapons to hostile

    nations:

    American(x) Weapon(y) Sells(x,y,z)Hostile(z) =

    Criminal(x)Nono. . .has some missiles, i.e., x Owns(Nono,x) M issile(x):

    Owns(Nono,M1)andMissile(M1). . .all of its missiles were sold to it by Colonel West

    x M issile(x) Owns(Nono,x) = Sells(West,x,Nono)Missiles are weapons:

    Missile(x)Weapon(x)An enemy of America counts as hostile:

    Example Knowledge Base contd

  • 7/25/2019 09 Inference

    28/33

    Example Knowledge Base contd.

    . . .it is a crime for an American to sell weapons to hostile

    nations:

    American(x) Weapon(y) Sells(x,y,z)Hostile(z) =

    Criminal(x)Nono. . .has some missiles, i.e., x Owns(Nono,x) M issile(x):

    Owns(Nono,M1)andMissile(M1). . .all of its missiles were sold to it by Colonel West

    x M issile(x) Owns(Nono,x) = Sells(West,x,Nono)Missiles are weapons:

    Missile(x)Weapon(x)An enemy of America counts as hostile:

    Resolution Proof: Definite Clauses

  • 7/25/2019 09 Inference

    29/33

    Resolution Proof: Definite Clauses

    American(West)

    Missile(M1)

    Missile(M1)

    Owns(Nono,M1)

    Enemy(Nono,America) Enemy(Nono,America)

    Criminal(x)Hostile(z)L

    Sells(x,y,z)L

    Weapon(y)L

    American(x)L > > > >

    Weapon(x)Missile(x)L >

    Sells(West,x,Nono)Missile(x)L

    Owns(Nono,x)L> >

    Hostile(x)Enemy(x,America)L >

    Sells(West,y,z)L

    Weapon(y)L

    American(West)L > >

    Hostile(z)L>

    Sells(West,y,z)L

    Weapon(y)L >

    Hostile(z)L>

    Sells(West,y,z)L>

    Hostile(z)L>L

    Missile(y)

    Hostile(z)L>L

    Sells(West,M1,z)

    > > LHostile(Nono)

    LOwns(Nono,M1)

    LMissile(M1)

    > LHostile(Nono)

    LOwns(Nono,M1)

    LHostile(Nono)

    Criminal(West)L

    Logic programming

  • 7/25/2019 09 Inference

    30/33

    Logic programming

    Sound bite: computation as inference on logical KBs

    Logic programming Ordinary programming

    1. Identify problem Identify problem

    2. Assemble information Assemble information

    3. Tea break Figure out solution

    4. Encode information in KB Program solution

    5. Encode problem instance as facts Encode problem instance as data

    6. Ask queries Apply program to data

    7. Find false facts Debug procedural errors

    Should be easier to debugCapital(N ewY ork, U S)thanx:=x+ 2!

    Prolog Systems

  • 7/25/2019 09 Inference

    31/33

    Prolog Systems

    A resolution inference system on Horn clauses + bells & whistles

    Widely used in Europe, Japan (basis of 5th Generation project)

    Compilation techniques 60 million LIPS

    Program = set of defi nite clauses, which are of form:

    head :- literal1, . . . literaln.

    weapon(X) :- missile(X).

    Effi cient unifi cation by open coding

    Effi cient retrieval of matching clauses by direct linking

    Depth-fi rst, left-to-right backward chaining

    Built-in predicates for arithmetic etc., e.g.,X is Y*Z+3

    Closed-world assumption (negation as failure) e.g., given

    alive(X) :- not dead(X). alive(joe)succeeds if

    dead(joe) fails.

    Resolution Proof in Prolog

  • 7/25/2019 09 Inference

    32/33

    Resolution Proof in Prolog

    % it is a crime to sell weapons to hostile nations:

    criminal(X):-american(X),weapon(Y),sells(X,Y,Z),hostile(Z)

    % Nono ... has some missiles,

    owns(nono,m1).

    missile(m1).% all of its missiles were sold to it by Colonel West

    sells(west,X,nono) :- missile(X), owns(nono,X).

    % Missiles are weapons

    weapon(X) :- missile(X).

    % An enemy of America counts as hostile:

    hostile(X) :- enemy(X,america).

    % The country Nono, an enemy of America ...\alenemy(nono,america).

    % West, who is American ...\al

    american(west).

    ?- criminal(Who).

    Who = west.

    Prolog Examples

  • 7/25/2019 09 Inference

    33/33

    Prolog Examples

    Depth-first search from a start state X:

    dfs(X) :- goal(X).

    dfs(X) :- successor(X,S),dfs(S).

    No need to loop over S: successorsucceeds for eachAppending two lists to produce a third:

    append([],Y,Y).

    append([X|L],Y,[X|Z]) :- append(L,Y,Z).

    query: append(A,B,[1,2]) ?

    answers: A=[] B=[1,2]

    A=[1] B=[2]

    A=[1,2] B=[]


Recommended