660 likes | 834 Views
Artificial Intelligence: Logic agents. AI in the News.
E N D
AI in the News April 6, 2005: GIDEON - Global Infectious Disease and Epidemiology Network. Media review by Vincent J. Felitti. JAMA, the Journal of the American Medical Association ( Vol. 293, No. 13, pages 1674-1675; subscription req'd.). "GIDEON: The Global Infectious Disease and Epidemiology Network is a superbly designed expert system created to help physicians diagnose any infectious disease (337 recognized) in any country of the world (224 included). The program was created and has been progressively refined over more than a decade by a talented group of Americans, Canadians, and Israelis ============================================= December 13, 2004: WebMed dispenses advice to students. By Robyn Shelton. Orlando Sentinel. "The site -- 24/7 WebMed -- takes students through questions, judges the severity of their symptoms and offers guidance for what to do next. ... 'It's decision-support systems, or artificial intelligence in a way,' said Dr. Scott Gettings, DSHI medical director. 'The system learns about you as you flow through and answer questions and determines how ill you are.' It makes no attempt to go further and diagnose the patient's illness -- but gauges the seriousness of the symptoms. 'This is not intended to take the place of human interaction, but to augment it,' said Dr. Michael Deichen, associate director of clinical services at the UCF Student Health Center. 'It really just helps the students know with what urgency they should be evaluated.'"
“Thinking Rationally” • Computational models of human “thought” processes • Computational models of human behavior • Computational systems that “think” rationally • Computational systems that behave rationally
Logical Agents • Reflex agents find their way from Arad to Bucharest by dumb luck • Chess program calculates legal moves of its king, but doesn’t know that a piece cannot be on 2 different squares at the same time • Logic (Knowledge-Based) agents combine general knowledge with current percepts to infer hidden aspects of current state prior to selecting actions • Crucial in partially observable environments
Outline • Knowledge-based agents • Wumpus world • Logic in general • Propositional and first-order logic • Inference, validity, equivalence and satifiability • Reasoning patterns • Resolution • Forward/backward chaining
Knowledge Base Knowledge Base: set of sentences represented in a knowledge representation language and represents assertions about the world. Inference rule: when one ASKs questions of the KB, the answer should follow from what has been TELLed to the KB previously. tell ask
Abilities KB agent • Agent must be able to: • Represent states and actions, • Incorporate new percepts • Update internal representation of the world • Deduce hidden properties of the world • Deduce appropriate actions
A Typical Wumpus World Wumpus
Wumpus World Characterization • Observable? • Deterministic? • Episodic? • Static? • Discrete? • Single-agent?
Wumpus World Characterization • Observable? No, only local perception • Deterministic? Yes, outcome exactly specified • Episodic? No, sequential at the level of actions • Static? Yes, Wumpus and pits do not move • Discrete? Yes • Single-agent? Yes, Wumpus is essentially a natural feature.
Exploring the Wumpus World [1,1] The KB initially contains the rules of the environment. The first percept is [none, none,none,none,none], move to safe cell e.g. 2,1 [2,1] breeze which indicates that there is a pit in [2,2] or [3,1], return to [1,1] to try next safe cell
Exploring the Wumpus World [1,2] Stench in cell which means that wumpus is in [1,3] or [2,2] YET … not in [1,1] YET … not in [2,2] or stench would have been detected in [2,1] THUS … wumpus is in [1,3] THUS [2,2] is safe because of lack of breeze in [1,2] THUS pit in [1,3] move to next safe cell [2,2]
Exploring the Wumpus World [2,2] move to [2,3] [2,3] detect glitter , smell, breeze THUS pick up gold THUS pit in [3,3] or [2,4]
What is a logic? • A formal language • Syntax – what expressions are legal (well-formed) • Semantics – what legal expressions mean • in logic the truth of each sentence with respect to each possible world. • E.g the language of arithmetic • X+2 >= y is a sentence, x2+y is not a sentence • X+2 >= y is true in a world where x=7 and y =1 • X+2 >= y is false in a world where x=0 and y =6
Entailment • One thing follows from another KB |= • KB entails sentence if and only if is true in worlds where KB is true. • E.g. x+y=4 entails 4=x+y • Entailment is a relationship between sentences that is based on semantics.
Models • Logicians typically think in terms of models, which are formally structured worlds with respect to which truth can be evaluated. • m is a model of a sentence if is true in m • M() is the set of all models of
Logical inference • The notion of entailment can be used for logic inference. • Model checking (see wumpus example): enumerate all possible models and check whether is true. • If an algorithm only derives entailed sentences it is called sound or truth preserving. • Otherwise it just makes things up. i is sound if whenever KB |-i it is also true that KB|= • Completeness : the algorithm can derive any sentence that is entailed. i is complete if whenever KB |= it is also true that KB|-i
Schematic perspective If KB is true in the real world, then any sentence derived From KB by a sound inference procedure is also true in the real world.
Inference • KB |-i a • Soundness: Inference procedure i is sound if whenever KB |-i a, it is also true that KB |=a • Completeness: Inference procedure i is complete if whenever KB |=a, it is also true that KB |-i a
Validity and Inference ((P V H) ^ ØH) => P Ø P H ((P H) ØH) => P P H (P H) H V V ^ V ^ T T T F T T F T T T F T T F T F F F F T
Rules of Inference • a|-b • a b • Valid Rules of Inference: • Modus Ponens • And-Elimination • And-Introduction • Or-Introduction • Double Negation • Unit Resolution • Resolution
a=>ba b a ^ba aVbØbVg a Vg Examples in Wumpus World • Modus Ponens: a => b, a |- b(WumpusAhead ^ WumpusAlive) => Shoot, (WumpusAhead ^ WumpusAlive) |- Shoot • And-Elimination: a^b |- a(WumpusAhead ^ WumpusAlive) |- WumpusAlive • Resolution: aVb, ØbVg |- aVg(WumpusDead V WumpusAhead), (ØWumpusAhead V Shoot) ` (WumpusDead V Shoot)
Proof Using Rules of Inference Prove A => B, (A ^ B) => C, Therefore A => C • A => B |-ØA V B • A ^ B => C |- Ø(A ^ B) V C |- ØA VØB V C • So ØA V B resolves with ØA VØB V C deriving ØA V C • This is equivalent to A => C
Rules of Inference (continued) • And-Introductiona1, a2, …, an a1^a2^ … ^an • Or-Introductionai a1 Va2V …ai … Van • Double NegationØØa a • Unit Resolution (special case of resolution)aVb Alternatively: Øa=>bØb Øb a a
Wumpus World KB • Proposition Symbols for each i,j: • Let Pi,j be true if there is a pit in square i,j • Let Bi,j be true if there is a breeze in square i,j • Sentences in KB • “There is no pit in square 1,1”R1: ØP1,1 • “A square is breezy iff pit in a neighboring square”R2: B1,1 (P1,2V P2,1)R3: B1,2 (P1,1V P1,3V P2,2) • “Square 1,1 has no breeze”, “Square 1,2 has a breeze”R4: ØB1,1R5: B1,2
Inference in Wumpus World • Apply biconditional elimination to R2:R6: (B1,1 => (P1,2V P2,1)) ^ ((P1,2V P2,1) => B1,1) • Apply AE to R6:R7: ((P1,2V P2,1) => B1,1) • Contrapositive of R7:R8: (ØB1,1=>Ø(P1,2V P2,1)) • Modus Ponens with R8 and R4 (ØB1,1):R9: Ø(P1,2V P2,1) • de Morgan:R10: ØP1,2^ØP2,1
Searching for Proofs • Finding proofs is exactly like finding solutions to search problems. • Can search forward (forward chaining) to derive goal or search backward (backward chaining) from the goal. • Searching for proofs is not more efficient than enumerating models, but in many practical cases, it’s more efficient because we can ignore irrelevant propositions
Full Resolution Rule Revisited • Start with Unit Resolution Inference Rule: • Full Resolution Rule is a generalization of this rule: • For clauses of length two:
Resolution Applied to Wumpus World • At some point we determine the absence of a pit in square 2,2:R13: ØP2,2 • Biconditional elimination applied to R3followed by modus ponens with R5:R15: P1,1V P1,3V P2,2 • Resolve R15 and R13:R16: P1,1V P1,3 • Resolve R16 and R1:R17: P1,3
Resolution: Complete Inference Procedure • Any complete search algorithm, applying only the resolution rule, can derive any conclusion entailed by any knowledge base in propositional logic. • Refutation completeness: Resolution can always be used to either confirm or refute a sentence, but it cannot be used to enumerate true sentences.
literals clause Conjunctive Normal Form • Conjunctive Normal Form is a disjunction of literals. • Example:(A V B VØC) ^ (B V D) ^ (Ø A) ^ (BVC)
CNF Example Example: (A V B) (C => D) • Eliminate ((A V B) => (C => D)) ^ ((C => D) => (A V B) • Eliminate => (Ø (A V B) V (ØC V D)) ^ (Ø(ØC V D) V (A V B) ) • Drive in negations((ØA ^ØB) V (ØC V D)) ^ ((C ^ØD) V (A V B)) • Distribute(ØA VØC V D) ^ (ØB VØC V D) ^ (C V A V B) ^ (ØD V A V B)
Resolution Algorithm • To show KB |=a, we show (KB ^Øa) is unsatisfiable. • This is a proof by contradiction. • First convert (KB ^Øa) into CNF. • Then apply resolution rule to resulting clauses. • The process continues until: • there are no new clauses that can be added (KB does not entail a) • two clauses resolve to yield empty clause (KB entails a)
Simple Inference in Wumpus World • KB = R2^ R4 = (B1,1 (P1,2V P2,1)) ^ØB1,1 • Prove ØP1,2 by adding the negation P1,2 • Convert KB ^ P1,2 to CNF • PL-RESOLUTION algorithm
Horn Clauses • Real World KB’s are often a conjunction of Horn clauses • Horn clause = • proposition symbol; or • (conjunction of symbols) => symbol • Examples:C (B => A) (C ^ D => B)
Forward Chaining • Fire any rule whose premises are satisfied in the KB. • Add its conclusion to the KB until query is found.
Forward Chaining Example P => Q L ^ M => P B ^ L => M A ^ P => L A ^ B => L A B
Forward Chaining Example P => Q L ^ M => P B ^ L => M A ^ P => L A ^ B => L A B
Forward Chaining Example P => Q L ^ M => P B ^ L => M A ^ P => L A ^ B => L A B
Forward Chaining Example P => Q L ^ M => P B ^ L => M A ^ P => L A ^ B => L A B
Forward Chaining Example P => Q L ^ M => P B ^ L => M A ^ P => L A ^ B => L A B
Forward Chaining Example P => Q L ^ M => P B ^ L => M A ^ P => L A ^ B => L A B