AGENTS THAT REASON LOGICALLY KNOWLEDGE-BASED AGENTS Two components: knowledge bse, nd n inference engine. Declrtive pproch to building n gent. We tell it wht it needs to know, nd It cn sk itself wht to do; nswers follow from the knowledge bse. Two views: Knowledge level or wht gents know Implementtion level or how the knowledge is ctully orgnized (dt structures nd lgorithms). A knowledge bsed gent must be ble to Represent sttes, ctions, etc. Incorporte new knowledge (percepts). Updte internl representtion of the world. Deduce unknown properties of the world. Deduce pproprite ctions. Our gents will use for ll of these (forml) logic, i.e., forml lnguges for representing informtion such tht conclusions cn be drwn. Syntx defines the sentences in lnguge Semntics defines the mening of the sentences,i.e., the mening of truth. Lnguge Ontologicl Commitment Epistemologicl Commitment (wht exists) (sttes of knowledge) Propositionl logic fcts true/flse/unknown First-order logic fcts, objects, reltions true/flse/unknown Temporl logic fcts, objects, reltions, time true/flse/unknown Probbility theory fcts degree of belief 0... 1 Fuzzy logic degree of truth degree of belief 0... 1 PROPOSITIONAL LOGIC/1 PROPOSITIONAL LOGIC/2 ENTAILMENT AND MODELS INFERENCE KB α: Knowledge bse KB entils sentence α iff α is true in ll the worlds in which KB is true. KB contining Reds won nd Expos won entils Either Reds or Expos won. m is model of sentence α if α is true in m. M(α) is the set of ll models of α. Then KB α iff M(KB) M(α). KB i α: sentence α cn be derived (inferred) from KB by procedure i. Soundness i is sound if, whenever KB i α it is lso true tht KB α. Completeness i is complete if, whenever KB α it is lso true tht KB i α. We will present eventully logic which is expressive enough (we cn sy lmost nything of interest using it), nd for which there exists complete nd sound inference procedure. KB = Reds won nd Expos won ; α = Expos won PROPOSITIONAL LOGIC/3 PROPOSITIONAL LOGIC/4
PROPOSITIONAL LOGIC The simplest logic illustrtes bsic ides Syntx: An elementry proposition is symbol (bstrct sense) If S is sentence, S (\+S) is sentence If S 1 nd S 2 re sentences, S 1 S 2 (S1, S2) is sentence If S 1 nd S 2 re sentences, S 1 S 2 (S1; S2) is sentence If S 1 nd S 2 re sentences, S 1 S 2 (S2 :- S1) is sentence If S 1 nd S 2 re sentences, S 1 S 2 is sentence Nothing else is sentence. Semntics: A model specifies the true/flse vlue for ech propositionl symbol. There re rules to specify truth vlues of compound propositions with respect to model m: S is true iff S is flse S 1 S 2 is true iff both S 1 nd S 2 re true S 1 S 2 is true iff S 1 is true or S 2 is true S 1 S 2 is true iff S 1 is flse or S 2 is true i.e., is flse iff S 1 is true nd S 2 is flse S 1 S 2 is true iff S 1 S 2 is true nd S 2 S 1 is true INFERENCE BY ENUMERATION Let α = A B nd KB = (A C) (B C) Is it the cse tht KB = α? Check ll possible models α must be true wherever KB is true: A B C A C B C KB α Flse Flse Flse Flse True Flse Flse Flse Flse True True Flse Flse Flse Flse True Flse Flse True Flse True Flse True True True True True True True Flse Flse True True True True True Flse True True Flse Flse True True True Flse True True True True True True True True True True True Other inference procedures use syntctic opertions on sentences, expressed in stndrdized forms. PROPOSITIONAL LOGIC/5 PROPOSITIONAL LOGIC/6 INFERENCE BY ENUMERATION NORMAL FORMS Let α = A B nd KB = (A C) (B C) Is it the cse tht KB = α? Check ll possible models α must be true wherever KB is true: A B C A C B C KB α Flse Flse Flse Flse True Flse Flse Flse Flse True True Flse Flse Flse Flse True Flse Flse True Flse True Flse True True True True True True True Flse Flse True True True True True Flse True True Flse Flse True True True Flse True True True True True True True True True True True Other inference procedures use syntctic opertions on sentences, expressed in stndrdized forms. Literl : propositionl symbol, or propositionl symbol negted. De Morgn rules : For ny propositions S 1 nd S 2, (S 1 S 2 ) is logiclly equivlent to S 1 S 2, nd (S 1 S 2 ) is equivlent to S 1 S 2. In ddition, ( S 1 ) is equivlent to S 1, nd both nd re ssocitive nd distributive with respect to ech other. Disjunctive norml form (DNF) (universl): Disjunction of conjunctions of literls. E.g., (A B) (A C) (A D) ( B C) ( B D) Conjunctive norml form (CNF), or clusl form (universl): conjunction of disjunctions of literls }{{} cluses E.g., (A B) (B C D) (E D) Horn Form (restricted): conjunction of Horn cluses, i.e., cluses with t most one positive (non-negted) literl. Also written s conjunction of implictions: A :- B. [nd] B :- C, D. [nd] E :- D. PROPOSITIONAL LOGIC/6 PROPOSITIONAL LOGIC/7
CLAUSAL FORM Any sentence (or KB) cn be trnsformed into set of cluses (clusl form). (( b) (c (d (f e)))) 1. Eliminte nd : α β is chnged to α β, nd α β is equivlent to (α β) (β α). ((( b) ( b )) ( c ( (d ( f e))))) 2. Apply De Morgn rules to move ll the negtions in, nd remove double negtions. (( b) ( b )) ( c ( (d ( f e)))) ( ( b) ( b )) ( c ( (d ( f e)))) (( b) (b )) (c (d ( f e))) 3. Use the distributedness, ssocitivity nd commuttivity to move the s out: α (β γ) becomes (α β) (α γ). (( (b )) ( b (b ))) c d ( f e) ( b) ( ) ( b b) ( b ) c d ( f e) ( b) ( b ) c d ( f e) 4. Clusl form is more conveniently represented s set of cluses: { ( b), ( b ), c, d, ( f e)} VALIDITY AND SATISFIABILITY A sentence is vlid (or tutology) if it is true in ll models, e.g., A A A A (A (A B)) B Vlidity is connected to inference vi the Deduction Theorem: KB α iff (KB α) is vlid. A sentence is stisfible if it is true in some model A B A sentence is unstisfible if it is true in no models A A Stisfibility is connected to inference vi the following: KB = α if nd only if (KB α) is unstisfible. I.e., prove α by reductio d bsurdum. C PROPOSITIONAL LOGIC/8 PROPOSITIONAL LOGIC/9 PROOF METHODS THE WUMPUS WORLD Model checking truth tble enumertion (sound nd complete for propositionl), or heuristic serch in model spce (sound but incomplete). Appliction of inference rules sound (legitimte) genertion of new sentences from old Proof = sequence of inference rule pplictions Cn use inference rules s opertors in stndrd serch lgorithm. Inference rules Resolution (complete for propositionl logic) Modus ponens (For Horn cluses, complete for Horn KBs) α 1,...,α n, Cn be used with forwrd chining or bckwrd chining. α 1 α n β β Percepts Breeze, Glitter, Smell Actions Left turn, Right turn, Forwrd, Grb, Relese, Shoot Gols Get gold bck to strt without entering pit or wumpus squre Environment Squres djcent to wumpus re smelly Squres djcent to pit re breezy Glitter iff gold is in the sme squre Shooting kills the wumpus if you re fcing it Shooting uses up the only rrow Grbbing picks up the gold if in the sme squre Relesing drops the gold in the sme squre PROPOSITIONAL LOGIC/10 PROPOSITIONAL LOGIC/11
THE WUMPUS WORLD (CONT D) THE WUMPUS WORLD (CONT D) Knowledge bse: Knowledge bse: Fcts: () S 1,1 (b) S 2,1 (c) S 1,2 Fcts: () S 1,1 (b) S 2,1 (c) S 1,2 Resolution: Resolution: THE WUMPUS WORLD (CONT D) CONTROL STRATEGIES FOR RESOLUTION W 1,3 12 Resolution itself is sound nd complete (in fct, refuttion-complete). Knowledge bse: Fcts: () S 1,1 (b) S 2,1 (c) S 1,2 S 1,2 W 1,2 W 2,2 W 1,1 S 1,2 S 1,1 W 2,2 W 1,1 S 1,2 W 2,2 W 1,1 6 S 1,2 S 2,1 W 1,1 S 1,2 W 1,1 S 1,2 S 1,1 S 1,2 2 b 1 c Typiclly t ech step there re mny pirs of prent cluses tht could be resolved. A control strtegy is policy for prioritizing which resolutions to perform next. A control strtegy is complete if its use preserves (refuttion-)completeness, i.e. if contrdiction exists, it cn be found while respecting the strtegy. Input resolution: t lest one prent of ech resolution step must be in the originl KB, or prt of the negted gol. Very efficient, but lso incomplete (but complete for Horn cluses). Unit resolution: t lest one prent of ech resolution step must be unit cluse, i.e., single literl. The conclusion is lwys shorter thn its prent, hence it is gurnteed to finish in bounded time. It is however incomplete (e.g., on { P Q, P Q, P Q, P Q }). Heuristic: For exmple, unit preference, the heuristic of prioritizing resolutions where one prent is unit cluse. PROPOSITIONAL LOGIC/13
INFERENCE WITH HORN CLAUSES AND/OR GRAPHS In prctice the full power of resolution is not needed q Rel-world knowledge bses usully contins only Horn cluses Convenient becuse Horn cluse hs the form p A 1 A 2 A n C which illustrtes logicl impliction (if ll the body is true then the hed C becomes true) m Modus ponens ( mode tht ffirms by ffirming ) is then used s inference rule Cn be used with vrious control lgorithms: forwrd chining or dt driven bckwrd chining or gol driven. b. l :-, b. l :-, p. m :- b, l. p :- l, m. q :- p. l b PROPOSITIONAL LOGIC/14 PROPOSITIONAL LOGIC/15