Artificial Intelligence: Logic agents

Preview:

DESCRIPTION

Artificial Intelligence: Logic agents. AI in the News. - PowerPoint PPT Presentation

Citation preview

Artificial Intelligence: Logic agents

April 22, 2023

AI in the NewsApril 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.'"

April 22, 2023

“Thinking Rationally”• Computational models of human “thought”

processes

• Computational models of human behavior

• Computational systems that “think” rationally

• Computational systems that behave rationally

April 22, 2023

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

April 22, 2023

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

April 22, 2023

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.

telltell askask

April 22, 2023

Generic KB-Based Agent

April 22, 2023

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

April 22, 2023

A Typical Wumpus World

WumpusWumpus

April 22, 2023

Wumpus World PEAS Description

April 22, 2023

Wumpus World Characterization

• Observable?• Deterministic?• Episodic?• Static?• Discrete?• Single-agent?

April 22, 2023

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.

April 22, 2023

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

April 22, 2023

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]

April 22, 2023

Exploring the Wumpus World

[2,2] move to [2,3][2,3] detect glitter , smell, breeze

THUS pick up goldTHUS pit in [3,3] or [2,4]

April 22, 2023

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

April 22, 2023

Entailment

• One thing follows from anotherKB |=

• KB entails sentence if and only if is true in worlds where KB is true. g. x+y=4 entails 4=x+y

• Entailment is a relationship between sentences that is based on semantics.

April 22, 2023

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

April 22, 2023

Wumpus world model

April 22, 2023

Wumpus world model

April 22, 2023

Wumpus world model

April 22, 2023

Wumpus world model

April 22, 2023

Wumpus world model

April 22, 2023

Wumpus world model

April 22, 2023

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

April 22, 2023

Schematic perspective

If KB is true in the real world, then any sentence derivedFrom KB by a sound inference procedure is also true in the real world.

April 22, 2023

Inference

• KB |-i

• Soundness: Inference procedure i is sound if whenever KB |-i , it is also true that KB |=

• Completeness: Inference procedure i is complete if whenever KB |= , it is also true that KB |-i

April 22, 2023

Validity and Inference

((P V H) ^ H) => P

P H P V H (P V H) ̂ H ((P V H) ̂ H) => P T T T F T T F T T T F T T F T F F F F T

April 22, 2023

Rules of Inference |- •

• Valid Rules of Inference:

– Modus Ponens– And-Elimination– And-Introduction– Or-Introduction– Double Negation– Unit Resolution– Resolution

April 22, 2023

Examples in Wumpus World• Modus Ponens: => , |-

(WumpusAhead ^ WumpusAlive) => Shoot, (WumpusAhead ^ WumpusAlive) |- Shoot

• And-Elimination: ^ |- (WumpusAhead ^ WumpusAlive) |- WumpusAlive

• Resolution: V , V |- V (WumpusDead V WumpusAhead), (WumpusAhead V Shoot) ` (WumpusDead V Shoot)

=>

^

V V V

April 22, 2023

Proof Using Rules of InferenceProve 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

April 22, 2023

Rules of Inference (continued)• And-Introduction

1, 2, …, n

1 ^ 2 ^ … ^ n

• Or-Introduction i1 V 2 V …i … V n

• Double Negation

• Unit Resolution (special case of resolution) V Alternatively: =>

April 22, 2023

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,2 V P2,1)R3: B1,2 (P1,1 V P1,3 V P2,2)

– “Square 1,1 has no breeze”, “Square 1,2 has a breeze”R4: B1,1

R5: B1,2

April 22, 2023

Inference in Wumpus World• Apply biconditional elimination to R2:

R6: (B1,1 => (P1,2 V P2,1)) ^ ((P1,2 V P2,1) => B1,1)• Apply AE to R6:

R7: ((P1,2 V P2,1) => B1,1)• Contrapositive of R7:

R8: (B1,1 => (P1,2 V P2,1))• Modus Ponens with R8 and R4 (B1,1):

R9: (P1,2 V P2,1)• de Morgan:

R10: P1,2 ^ P2,1

April 22, 2023

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

April 22, 2023

Full Resolution Rule Revisited

• Start with Unit Resolution Inference Rule:

• Full Resolution Rule is a generalization of this rule:

• For clauses of length two:

April 22, 2023

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 R3 followed by modus ponens with R5:R15: P1,1 V P1,3 V P2,2

• Resolve R15 and R13:R16: P1,1 V P1,3

• Resolve R16 and R1:R17: P1,3

April 22, 2023

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.

April 22, 2023

Conjunctive Normal Form• Conjunctive Normal Form is a

disjunction of literals.

• Example:

(A V B V C) ^ (B V D) ^ ( A) ^ (BVC)

clause

literals

April 22, 2023

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)

April 22, 2023

Resolution Algorithm

• To show KB |= , we show (KB ^ ) is unsatisfiable.

• This is a proof by contradiction.• First convert (KB ^ ) 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 )

– two clauses resolve to yield empty clause (KB entails )

April 22, 2023

Simple Inference in Wumpus World

• KB = R2 ^ R4 = (B1,1 (P1,2 V P2,1)) ^ B1,1

• Prove P1,2 by adding the negation P1,2 • Convert KB ^ P1,2 to CNF

PL-RESOLUTION algorithm

April 22, 2023

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)

April 22, 2023

Forward Chaining• Fire any rule whose premises are satisfied in

the KB.• Add its conclusion to the KB until query is

found.

April 22, 2023

Forward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Forward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Forward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Forward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Forward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Forward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Forward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Forward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Backward Chaining

• Motivation: Need goal-directed reasoning in order to keep from getting overwhelmed with irrelevant consequences

• Main idea:– Work backwards from query q – To prove q:

• Check if q is known already• Prove by backward chaining all premises of some

rule concluding q

April 22, 2023

Backward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Backward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Backward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Backward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Backward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Backward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Backward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Backward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Backward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Backward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Backward Chaining Example

P => QL ^ M => PB ^ L => MA ^ P => LA ^ B => LAB

April 22, 2023

Forward Chaining vs. Backward Chaining

• FC is data-driven—it may do lots of work irrelevant to the goal

• BC is goal-driven—appropriate for problem-solving

Recommended