0% found this document useful (1 vote)
305 views

Logical Agents

“Logical AI: The idea is that an agent can represent knowledge of its world, its goals and the current situation by sentences in logic and decide what to do by inferring that a certain action or course of action is appropriate to achieve its goals.”

Uploaded by

Hussain Sajjad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
305 views

Logical Agents

“Logical AI: The idea is that an agent can represent knowledge of its world, its goals and the current situation by sentences in logic and decide what to do by inferring that a certain action or course of action is appropriate to achieve its goals.”

Uploaded by

Hussain Sajjad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 103

ARTIFICIAL INTELLIGENCE

LOGICAL AGENTS – KNOWLEDGE-BASED AGENTS


KNOWLEDGE-BASED AGENTS

 Logical AI
 The idea is that an agent can represent knowledge of its world, its goals
and the current situation by sentences in logic and decides what to do by
inferring that a certain action or course of action is appropriate to achieve
its goals.”
 John McCarthy in Concepts of logical AI, 2000
http://www.formal.standford.edu/jmc/concepts-ai/ concepts-ai.html
KNOWLEDGE-BASED AGENTS
Constraint satisfaction problems
“Low-level intelligence” Bayesian Networks

Reflex States Variables Logic

Search problems “High-Level Intelligence”


Markov decision processes
Adversarial games

Credit: Courtesy Percy Liang


KNOWLEDGE-BASED AGENTS

 Intelligent agents need knowledge about the world to choose good


actions/decisions.
 Knowledge = {sentences} in a knowledge representation language (formal
language)
 A sentence is an assertion about the world.
 A knowledge-base agent is composed of:
1. Knowledge base: domain-specific content
2. Inference mechanism: domain-independent algorithms
KNOWLEDGE-BASED AGENTS

 The agent must be able to:


 Represent states, actions, etc.
 Incorporate new percepts
 Update internal representation of the world
 Deduce hidden properties of the world
 Deduce appropriate actions
 Declarative approach to building an agent:
 Add new sentences: Tell it what it need to know
 Query what is known: Ask itself what to do – answer should follow from the KB
KNOWLEDGE-BASED AGENTS

 Agents can be viewed at the knowledge level


 i.e., what they know, regardless of how implemented
 Or at the implementation level
 i.e., data structures in KB and algorithms that manipulate them
KNOWLEDGE-BASED AGENTS
THE WUMPUS WORLD

Gregory Yob 1975


THE WUMPUS WORLD

 4 x 4 grid of rooms
 Squares adjacent to wumpus are smelly
 Squares adjacent to pit are breezy
 Glitter iff gold is in the same square
 Shooting kills wumpus if you are facing it
 Shooting uses up the only arrow
 Grabbing picks up gold if in same square
 Releasing drops the gold in same square
THE WUMPUS WORLD PEAS DESCRIPTION

 Performance measure
 gold +1000,
 death (eaten or falling in a pit) -1000
 -1 per action taken,
 -10 for using the arrow
 the games ends either when the agent dies or
comes out of the cave
THE WUMPUS WORLD PEAS DESCRIPTION

 Environment
 4 x 4 grid of rooms
 Agent starts in square [1,1] facing to the right
 Locations of the gold, and wampus are chosen
randomly with a uniform distribution from all
squares except [1,1]
 Each square other than the start can be a pit
with probability of 0.2
THE WUMPUS WORLD PEAS DESCRIPTION

 Sensors:
 Stench, Breeze, Glitter, Bump, Scream
 Represents as a 5-element list
 Example: [Stench, Breese, None, None, None]
 Actuators:
 Left turn, Right turn, Forward, Grab, Release,
Shoot
WUMPUS WORLD PROPERTIES

 Fully Observable
 No – only local perception
 Deterministic
 Yes – outcomes 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 A WUMPUS WORLD

A = Agent
B = Breeze
G = Gold
Ok = Safe square
P = Pit
S = Stench
V = Visited
W = Wumpus
EXPLORING A WUMPUS WORLD
EXPLORING A WUMPUS WORLD
EXPLORING A WUMPUS WORLD
EXPLORING A WUMPUS WORLD
EXPLORING A WUMPUS WORLD
EXPLORING A WUMPUS WORLD
EXPLORING A WUMPUS WORLD
LOGIC

 Knowledge Base: a set of sentences in a formal representation, Logic


 Logics: are formal languages for representing information such that conclusions can be
drawn
 Syntax: defines well-formed sentences in the language
 Semantics: define the truth or "meaning" of sentences in a world;
 Inference: a procedure to derive a new sentence from other ones
 Logical entailment: is a relationship between sentences. It means that a sentence
follows logically from other sentences
KB ╞ α
 Knowledge base KB entails sentence α if and only if α is true in all worlds where KB is true
PROPOSITIONAL LOGIC

 Propositional logic is the simplest logic – illustrates basic ideas


 Syntax of PL: defines the allowable sentences or propositions
 Definition (Proposition): a proposition is a declarative statement that’s
either True or False
 Atomic Proposition: single proposition symbol. Each symbol is a
proposition. Notation: upper case letters and may contain subscripts
 Compound Proposition: constructed from atomic propositions using
parentheses and logical connectives
ATOMIC PROPOSITION

 Examples of atomic propositions:


 2+2=4 is a true proposition
 W1;3 is a proposition. It is true if there is a Wumpus in [1,3]
 \If there is a stench in [1,2] then there is a Wumpus in [1,3]"
 is a proposition
 \How are you?" or \Hello!" are not propositions. In general,
 statement that are questions, commands, or opinions are not
 propositions.
COMPOUND PROPOSITION
Examples of compound/complex propositions:
Let p, p1, and p2 be propositions

 Negation: ¬p is also a proposition. We call a literal either an atomic proposition


or its negation. E.g., ¬W1;3 is a positive literal, and : ¬W1;3 is a negative literal.
TRUTH TABLES

 The semantics dene the rules to determine the truth of a sentence.


 Semantics can be specied by truth tables.
 Boolean values domain: T,F
 n-tuple: (x1; x2; …. ; xn)
 Operator on n-tuples : g(x1 = v1; x2 = v2; :::; xn = vn)
 Defination: A truth table denes an operator g on n- tuples by specifying a Boolean value
for each tuple.
 Number of rows in a truth table? R = 2n
BUILDING PROPOSITIONS
BUILDING PROPOSITIONS
BUILDING PROPOSITIONS
BUILDING PROPOSITIONS
BUILDING PROPOSITIONS
BUILDING PROPOSITIONS
PRECEDENCE OF OPERATORS

 Just like arithmetic operators, there is an operator precedence when evaluating logical operators as follows:
 1. Expressions in parentheses are processed (inside to outside)
 2. Negation
 3. AND
 4. OR
 5. Implication
 6. Bi conditional
 7. Left to right
 Use parentheses whenever you have any doubt!
BUILDING PROPOSITIONS
LOGICAL EQUIVALENCE

 Two propositions p and q are logically equivalent if and only if the columns in the truth table giving their truth values
agree.
 We write this as p ↔ q or p ≡ q.
PROPERTIES OF OPERATORS
TAUTOLOGY AND CONTRADICTION

 Tautology is a proposition which is always true


 Contradiction is a proposition which is always false
 Contingency is a proposition which is neither a tautology or a contradiction
CONTRAPOSITIVE, INVERSE, ETC.

 Given an implication p→q


 The converse is: q→p
 The contrapositive is: ¬q → ¬ p
 The inverse is: ¬p→¬q
CONTRAPOSITIVE, INVERSE, ETC.
INFERENCE (MODUS PONENS)
INFERENCE (MODUS PONENS)
INFERENCE (MODUS PONENS)

 Horn clauses: a proposition of the form:


 p1 ^ …….^ pn → q
 Modus Ponens deals with Horn clauses:
INFERENCE (MODUS TOLLENS)
INFERENCE (MODUS TOLLENS)
COMMON RULES
TRUTH TABLES FOR CONNECTIVES

 Summary:
WUMPUS WORLD KB

 Let's build the KB for the reduced Wumpus world.


WUMPUS WORLD KB
WUMPUS WORLD KB
ENTAILMENT AND INFERENCE

 Semantics: Determine entailment by Model Checking, that is enumerate all models and show that the
sentence α must hold in all models.

 Syntax: Determine entailment by Theorem Proving, that is apply rules of inference to KB to build a proof of
α without enumerating and checking all models.

 But how are entailment and inference related?


SOUNDNESS & COMPLETENESS
VALIDITY & SATISABILITY
DETERMINING ENTAILMENT

 Given a Knowledge Base (KB) (set of sentences in PL), given a query α output whether KB entails α
noted:

 We will see two ways of doing proofs in PL:


 Model checking enumerate the models (truth table enumeration, exponential).
 Application of inference rules (proof checking/theorem proving): Syntactic derivations with rules like Modus
Ponens (Backward chaining and forward chaining). A proof is a sequence of inference rule applications.
MODEL CHECKING

 Truth Table for inference


 Model: assignment T/F to every propositional symbol.
 Check that α is true in every model in which KB is true.
MODEL CHECKING
 Truth Table for inference
 Model: assignment T/F to every propositional symbol.
 Check that α is true in every model in which KB is true.
INFERENCE: WUMPUS WORLD
INFERENCE AS A SEARCH PROBLEM

 Initial state: The initial KB


 Actions: all inference rules applied to all sentences that match
 the top of the inference rule
 Results: add the sentence in the bottom half of the inference
 rule
 Goal: a state containing the sentence we are trying to prove.
THEOREM PROVING

 Search for proofs is a more ancient way than enumerating models (We can ignore irrelevant
information)
 Truth tables have an exponential number of models.
 The idea of inference is to repeat applying inference rules to the KB.
 Inference can be applied whenever suitable premises are found in the KB.
 Inference is sound. How about completeness?
THEOREM PROVING

 Two ways to ensure completeness:


 Proof by resolution: use powerful inference rules (resolution rule)

 Forward or Backward chaining: use of modus ponens on a restricted form of propositions (Horn
clauses)
 Resolution: ONE single inference rule
 Invented by Robinson, 1965
 Resolution + Search = complete inference algorithm.
PROOF BY RESOLUTION
PROOF BY RESOLUTION
PROOF BY RESOLUTION
CONVERSION TO CNF
CONVERSION TO CNF
CONVERSION TO CNF
CONVERSION TO CNF
RESOLUTION ALGORITHM
RESOLUTION EXAMPLE
FORWARD/BACKWARD CHAINING
FORWARD CHAINING
FORWARD CHAINING EXAMPLE
FORWARD CHAINING EXAMPLE
FORWARD CHAINING EXAMPLE
FORWARD CHAINING EXAMPLE
FORWARD CHAINING EXAMPLE
FORWARD CHAINING EXAMPLE
FORWARD CHAINING EXAMPLE
FORWARD CHAINING EXAMPLE
BACKWARD CHAINING
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
FORWARD VS BACKWARD

 Forward chaining:
 Data-driven, automatic, unconscious processing,
 May do lots of work that is irrelevant to the goal

 Backward chaining:
 Goal-driven, appropriate for problem-solving,

 Complexity of BC can be much less than linear in size of KB


PROPOSITIONAL LOGIC
PROPOSITIONAL LOGIC
PROPOSITIONAL LOGIC

 Limits of PL?
 1. PL is not expressive enough to describe all the world around us. It can't express
information about different object and the relation between objects.
 2. PL is not compact. It can't express a fact for a set of objects without
enumerating all of them which is sometimes impossible.
 Example: We have a vacuum cleaner (Roomba) to clean a 10x10 squares
in the classroom. Use PL to express information about the squares.
PROPOSITIONAL LOGIC
FIRST ORDER LOGIC
FIRST ORDER LOGIC
FIRST ORDER LOGIC
FIRST ORDER LOGIC
SUMMARY
SUMMARY
JOHN MCCARTHY
CREDIT

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy