Chapter Four Knowledge 1 1

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 38

Chapter four

Knowledge based agents & logics


Knowledge and reasoning
• Representation of knowledge is central to the
field of AI
• Play crucial role in dealing with partially
observable environment (inferring for hidden
aspects of the environment)
• Understanding natural language also require
inferring hidden state
Knowledge-based agents
• Their central component is the knowledge
base (KB)
• KB
– Is a set of sentences (not as in natural language)
– Each sentence is expressed according to the syntax
of a language called knowledge representation
language
Building Process
• One can build KB agent simply by TELLing it what it needs to
know
• Two approaches to building
– Declarative = expressing the knowledge in a form of
sentences using representation language
– Procedural = encoding desired behaviors directly as
program code
• The combination of the to is critical to success
• In addition to TELLing, a learning mechanism can be provided
to the KB
• all this is done by theory and technology of logic
Case
• To understand the overall process, let’s consider
the following domain: The Wumpus World
– A cave
– Wumpus is a beast
– Agent can shoot and kill
– Some rooms contain pits
– Pits trap everyone who enters
their room
– Finding a heap of gold is wining
Cont..
• PEAS description
• Performance measure
– + 1000 for picking up the gold
– -1000 for falling into pit or being eaten by the
wumpus
– -1 for each action taken and
– -10 for using up the arrow
Cont..
• Environment
– 4x4 grid of rooms
– The agent always start in the square [1,1] facing
right
– The location of wumpus & gold is random (not in
[1,1])
…cont
• Actuators
– Can move forward
– Turn right and left by 90o
– The action grab allow to pick up object (in the
room the agent located)
– Shoot allow to fire and arrow straight (but the
agent has only one arrow)
…cont
• Sensors
– Perceive stench:- in the square containing wumpus & in
the directly (not diagonally) adjacent squares
– Perceive breeze:- in the square directly adjacent to a pit
– Perceive glitter:- in the square containing gold
– Perceive a bump:- when walk into a wall
– Perceive woeful scream:- when wumpus is killed
• Percept order:- Eg= if there is stench & breeze, but
no glitter, bump, or scream [stench, breeze, none,
none, none]
…cont
• The agent’s initial knowledge contain the rule
of the environment
– It knows that it is in [1,1] and that [1,1] is safe
– Its knowledge evolves as new percepts arrive and
actions are taken
…cont
• Scenario
– First percept [none, none, none, none, none]

– Hence, the agent can conclude that its neighboring squares


are safe (i.e., [1,2] &[2,1]
…cont
• Suppose the agent move to square [2,1]

• The agent detect breeze in [2,1]


– There must be a pit in [2,2] or [3,1]
– Can not be in [1,1] – rule of the game
…cont
• Therefore, there is only one ok - has not been
visited – square; [1,2]
• Accordingly, the agent turn around, go back to
[1,1] & then proceed to [1,2]
• The new percept = [stench, none, none, none, none]

• Stench in [1,2] means:


– Wumpus nearby, cannot be in [1,1]-rule
– Cannot be in [2,2]- would have detect it when in [2,1]
– Therefore can infer, the wumpus is in [1,3]
– Moreover, lack of breeze in [1,2]  no pit in [2,2] – it must be in [3,1]
Cont…
• We are able to reason like this, why don’t we
let the agent to do so.
– It is done by logical reasoning
– So let us discuss about logic
logic
• Logic forms the foundation to write the KB of knowledge
based agents
– Therefore, logic is the representation language for the KB
– Representational language specifies the allowed syntax and
semantics
• Syntax
– Representation language specifies all the sentence that are well
formed
• Example; in arithmetic
– X+y=4 is well-formed sentence, but
– X4y+= is not
– There are many syntax in logic
…cont
• Semantic
– Semantic of the language define the truth of each
sentence with respect to each model (possible
world)
– Example; in arithmetic semantic
• X+y=4 is true in a world where x=2 and y=2, but false in
a world x=1 and y=1
• In logic every sentence must be true or false –
there is no “in between”
….cont
• Models
– Are abstractions that fixes the truth or falsehood
of every relevant sentences
– Example; in x+y=4 (arithmetic)
• Possible models are just all the possible assignment of
numbers to the variable x & y (i.e., combination of
numbers 0-9)
• Each such assignment fixes the truth value of the
sentence
Logical Reasoning
• Involves the relation of logical entailment
between sentences
• Entailment is the idea that a sentence logically
follows from another sentence
– Example:
• α = all men are mortal, Mesay is a man
• ϐ = therefore, Mesay is…………
• Notation =
…cont
• Example; the wumpus world
– Consider the situation in the following figure
– Percept= nothing in [1,1]
– And breeze in [2,1]
– Interest = whether
– [1,2],[2,2] and [3,1] contains pit
– That is three squares
– Hence 23 = 8 possible models
• KB is false in models that contradict with what the agent
knows
– KB is false in any model in which [1,2] contains a pit, because no
breeze in [1,1]
….cont
• There are three models in which KB is true
• Consider two conclusions
– α1 = no pit in [1,2]
– α2 = no pit in [2,2]

• We can see that


– In every model KB is true, α1 is also true
– Hence KB entails α1
– Also in some models KB true, α2 is false
– Therefore, KB does not entail α2 (the agent cannot
conclude no pit in [2,2]
Entailment and inference
• Think of the set of all consequences of KB as a
haystack and of α as a needle
– Entailment is like the needle being in the haystack
– Inference is like finding it
• Formal notation; if an inference algorithm i
can drive α from KB, we write

• Pronounced as “α is derived from KB by i


Soundness and completeness
• Soundness
– An inference algorithm that drives only entailed
sentences is called sound
• Completeness
– An inference algorithm is complete if it can derive
any sentence that is entailed
• Note:- if KB is true the real world, then any
sentence derived from KB by a sound inference
procedure is true in the real world
Propositional Logic
• It is a very simple logic used to represent some
knowledge
• Syntax (allowable sentences)
– Atomic sentences
• Indivisible syntactic elements
• Consists of single propositional symbol
• Symbols stand for a proposition that can be true or false
• Use uppercase names for symbols
• Naming can be arbitrary like W1,3 to mean wumpus in the
square [1,3]
• Two propositional symbols with fixed meaning: True and
False
…cont
• Complex sentences
– Constructed from simpler sentences using logical
connectives
• Logical connectives
– Ʌ(and), V(or), →(implies) ↔(if and only if), ┐(not)
• Conjunction
– A sentence whose main connective is Ʌ
– Eg: P Ʌ Q
– P and Q are called conjucts
…cont
• Disjunction
– A sentence using V
– Eg: P V Q
– P V Q are called disjuncts
• Implication (conditional)
– A sentence using →
– Eg: P → Q
– P is called its premises or antecedent
– Q is called conclusion or consequent
• Biconditional
– A sentence like P ↔ Q
…cont
• Formal grammar
Semantics
• Defines the rules for determining the truth of a
sentence
• Computing the truth value of sentences
– True is always true and False is false
– The truth value of every other propositional symbol must
be specified directly
– The truth value for complex sentences can be obtained
from truth table
Example of KB using propositional logic
• For wumpus world
• Deal only with pits
• Vocabulary of propositional symbols
– For each I, j
– Let Pi,j be true if there is a pit in [i,j]
– Let Bi,j be true if there is a breeze in [i.j]
..cont
• The knowledge base sentences
– There is no pit in [1,1] = R1: ┐P1,1
– A square is breezy iff there is a pit in a neighboring
square (has to be stated for each square)
• R2: B1,1 ↔ (P1,2 V P2,1)
• R3: B2,1 ↔ (P1,1 V P2,2 V P3,1)
• The above sentences are true in all wumpus
world
…cont
• When we include the breeze percept for the
picture below
– R4: ┐B1,1
– R5: B2,1
First-Order Logic (FOL)
• Propositional logic is insufficient to represent
knowledge of complex environments
• Example; to state “ squares surrounding pits
are breezy
– We are forced to write B1,1 ↔ (P1,2 V P2,1) for each
squares separately
– Hence, we need more expressive language
• FOL is more expressive than propositional logic
..cont
• Major difference between the two is their
assumption about nature of reality
– Propositional logic assumes there are facts that
either hold or do not hold in the world. Each fact
can be in one of two states – true or false
– FOL assumes the world consists of objects with
certain relations that do or do not hold ( again
these can be in one of the two states)
…cont
• According to FOL the world can be considered as
containing the following components
• Objects: people, house, theories, colors,…
• Relations: can be unary (properties) such as red,
round,
– Or generally n-ary such as brother of, bigger than
• Functions: is a relations in which there is only
one value for a given input
– Such as father of, best friend, one more than
…cont
• Any assertion can be broken down to objects
and properties or relations
– Example: “one plus two equals three”
• Objects: one, two, three
• Relations: equals
• Function: plus
– “squares neighboring wumpus are smelly”
• Objects: wumpus, squares
• Property: smelly
• Relation: neighboring
FOL Syntax
• The basic syntactic elements are the symbols that
stands for objects, relations, and functions
• Therefore, there are three kinds of symbols
– Constant symbols = stand for objects
– Predicate symbols = stand for relations
– Function symbols = stand for functions
• Convention: these symbols start with uppercase
letter
• Propositional connectives (Ʌ(and), V(or), →(implies) ↔(if
and only if), ┐(not)) are used
….cont
• Example: Block-world
– Contains three blocks (block A, B & C)
– A block can be on another block or on the floor
– When a block has no block on it we say it is clear
…cont
• The interpretation and symbols are
SymbolWorld
A Bock A
B Block B constant symbols
C Bock C
Fl Floor
On on relation
Clear clear relation

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