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

UNIT-III

Knowledge and Reasoning


Knowledge Representation
• AI agents deal with knowledge (data)
• Facts: truths in relevant world, needed to represent
• Representation: facts to be represented in some formalism
• Levels of knowledge
• Knowledge level: at which facts are described
• Symbol level: knowledge level defined in terms of symbols
manipulated by programs
Choosing a Representation
• For certain problem solving techniques
• ‘Best’ representation already known
• Often a requirement of the technique
• Or a requirement of the programming language (e.g. Prolog)
• Examples
• First order theorem proving… first order logic
• Inductive logic programming… logic programs
• Neural networks learning… neural networks
• Some general representation schemes
• Suitable for many different (and new) AI applications
Some General Representations
1. Logical Representations
2. Production Rules
3. Semantic Networks
• Conceptual graphs, frames
4. Description Logics (see textbook)
Aspects of knowledge
• A knowledge representation language is defined by two aspects:
Syntax : The syntax of a language defines which configurations of
the components of the language constitute valid sentences.
Semantics : The semantics defines which facts in the world the
sentences refer to, and hence the statement about the world that each
sentence makes.
Approaches of knowledge representation
• Representational Adequacy – the ability to represent all the different kinds
of knowledge that might be needed in that domain.
• Inferential Adequacy – the ability to manipulate the representational
structures to derive new structures (corresponding to new knowledge)
from existing structures.
• Inferential Efficiency – the ability to incorporate additional information into
the knowledge structure which can be used to focus the attention of the
inference mechanisms in the most promising directions.
• Acquisitional Efficiency – the ability to acquire new information easily.
Ideally the agent should be able to control its own knowledge acquisition,
but direct insertion of information by a ‘knowledge engineer’ would be
acceptable. Finding a system that optimizes these for all possible domains
is not going to be feasible.
A KNOWLEDGE-BASED AGENT
• knowledge base or KB: set of representations of facts about the
world
• Sentence: Each individual representation(English and other natural
languages)
• knowledge representation language: The sentences are expressed in
a language
• fundamental requirement: TELL and ASK is that when one ASKS a
question of the knowledge base, the answer should be followed.
knowledge-based agent program
• The agent maintains a knowledge base, KB, which may initially contain some background knowledge
• Each time the agent program is called, it does two things
• First, it TELLS the knowledge base what it perceives.
• Second, it ASKS the knowledge base what action it should perform.

• MAKE-ACTION-QUERY takes a time as input and returns a sentence that is


suitable for asking what action should be performed at that time
• MAKE-PERCEPT-SENTENCE takes a percept and a time and returns a sentence representing the fact
knowledge-based agent levels
• The knowledge level or epistemological level: describe the agent by saying what
it knows.
example: an automated taxi might be said to know that the Golden Gate
Bridge links San Francisco and Marin County. If TELL and ASK work correctly, then
most of the time we can work at the knowledge level and not worry about
lower levels.
• The logical level is the level at which the knowledge is encoded into sentences.
example: the taxi might be described as having the logical sentence
Links(GGBridge, SF, Marin) in its knowledge base.
• The implementation level is the level that runs on the agent architecture.
It is the level at which there are physical representations of the sentences at
the logical level.
A sentence such as Links(GGBridge, SF, Marin) could be represented in the
KB by the string "Links (GGBridge, SF,Marin) " contained in a list of strings; or
by a "1" entry in a three-dimensional table indexed by road links and location pairs;
or by a complex set of pointers connecting machine addresses corresponding to the
individual symbols.
THE WUMPUS WORLD ENVIRONMENT
• wumpus world—that provides plenty of motivation for logical
reasoning.
• Wumpus was an early computer game, based on an agent who
explores a cave consisting of rooms connected by passageways.
• Wumpus- a beast that eats anyone who enters its room.
• some rooms contain bottomless pits that will trap anyone who
wanders into these rooms (except for the wumpus, who is too big to
fall in).
• mitigating feature of living in this environment is the occasional heap
of gold
Wumpus World-Specifying the environment
• Performance Measure
• Gold +1000, Death – 1000
• Step -1, Use arrow - fire
• Environment
• Square adjacent to the Wumpus are smelly
• Squares adjacent to the 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 the gold if in the same
square
• Releasing drops the gold in the same square
• Actuators
• Left turn, right turn, forward, grab, release,
shoot
• Sensors
• Breeze, glitter, and smell
• percepts
• [stench, a breeze, glitter, bump, scream]
Acting and reasoning in the wumpus world
[X] = Agent

B = Breeze
G = Glitter, Gold
OK = Safe square
P = Pit
S = Stench
V = Visited
W = Wumpus

(a) The initial situation,


after percept [None, None, None, None, None].
Acting and reasoning in the wumpus world

(b) After one move, with percept


[None, Breeze, None, None, None].
Acting and reasoning in the wumpus world

After the third move,


with percept [Stench, None, None, None, None].
Acting and reasoning in the wumpus world

After the fifth move, with percept


[Stench, Breeze, Glitter, None, None].
• logic consists of the following
Logics
1. A formal system for describing states of affairs, consisting of
(a) the syntax of the language, which describes how to make sentences, and
(b) the semantics of the language, which states the systematic constraints on how
sentences relate to states of affairs.
2. The proof theory—a set of rules for deducing the entailments of a set of sentences.
• propositional logic- symbols represent whole propositions (facts)
Example: D might have the interpretation "the wumpus is dead." which may or may not be a
true proposition.
Proposition symbols can be combined using Boolean connectives to generate sentences with
more complex meanings.
• Ontological commitments have to do with the nature of reality.
• Epistemological commitments have to do with the possible states of knowledge an agent can have
using various types of logic.
Syntax
PROPOSITIONAL LOGIC
• symbols of prepositional logic are
the logical constants True and False
proposition symbols such as P and Q
the logical connectives A, V, ,=>, ¬ and parentheses ()
• All sentences are made by putting these symbols together using the following rules:
• The logical constants True and False are sentences by themselves.
• A prepositional symbol such as P or Q is a sentence by itself.
• Wrapping parentheses around a sentence yields a sentence, for example, (P A Q).
• sentence can be formed by combining simpler sentences with one of the five logical connectives:
1. A (and)-A sentence whose main connective is A, such as P A (Q V R), is called a conjunction (logic);
its parts are the conjuncts.
2. V (or)-A sentence using V, such as A V (P A Q), is a disjunction of the disjuncts A and (P A Q).
3. => (implies)-A sentence such as (PA Q) =>R is called an implication (or conditional). PREMISE- Its
premise or antecedent is P A Q, and its conclusion or consequent is R. Implications are also known as
rules or if-then statements.
4.  (equivalent)- The sentence (P A Q) & (Q A P) is an equivalence (also called a biconditional).
5. ¬ (not)- A sentence such as ¬ P is called the negation of P.
PROPOSITIONAL LOGIC
• Atomic sentences-propositional logic consist of a single symbol (e.g., P)
• Complex sentences-contain connectives or parentheses (e.g., P A Q)
• Literal- either an atomic sentences or a negated atomic sentence

• grammar is ambiguous-P A Q V R could be parsed as either (P A Q) V R or as P A (Q V R).


• to resolve the ambiguity-order of precedence for the operators,
(from highest to lowest): ¬, A, V, =>, and 
Eg:
the sentence is equivalent to the sentence
PROPOSITIONAL LOGIC
Semantics
interpretation of the proposition symbols and constants
specifying the meanings of the logical connectives
• The sentence True always has as its interpretation the way the world actually is
• The sentence False always has as its interpretation the way the world is not.
• truth table-logical function with two arguments needs a table with only four entries

Validity and inference


Truth tables can be used not only to define the connectives, but also to test for valid sentences
If the sentence is true in every row, then the sentence is valid
PROPOSITIONAL LOGIC
Premises => Conclusion
If every row is true, then the conclusion is entailed by the premises, which means that the fact
represented by the conclusion follows from the state of affairs represented by the premises.

A reasoning system be able to draw conclusions that follow from the premises, regardless of the world to which
the sentences are intended to refer.
PROPOSITIONAL LOGIC
Models
• Any world in which a sentence is true under a particular interpretation is called a model of that
sentence under that interpretation.
Eg: In Wumpus world, "S1,2“means there is a stench in [1,2].
• A sentence “a” is entailed by a knowledge base KB if the models of KB are all models of “a”. If this is
the case, then whenever KB is true, a must also be true
• models are mathematical objects
PROPOSITIONAL LOGIC
Rules of inference for propositional logic
Inference rule- patterns of inferences that occur over and over again, and their soundness can be shown once
and for all
PROPOSITIONAL LOGIC
Complexity of prepositional inference
• Monotonicity-The use of inference rules to draw conclusions from a knowledge base relies implicitly
on a general property of certain logics.
• A logic is monotonic if when we add some new sentences to the knowledge base, all the sentences entailed
by the original KB are still entailed by the new larger knowledge base.

• property of monotonicity of a logic


if KB1 a then (KB1 U KB2 ) a

Horn sentences
A useful class of sentences for which a polynomial-time inference procedure exists
PI A P2 A ... A Pn => Q
• When Q is the constant False, we get a sentence that is equivalent to ¬ P1 V ... V ¬ Pn.
• When n = 1 and PI = True, we get True => Q, which is equivalent to the atomic sentence Q.
PROPOSITIONAL LOGIC-Wumpus world
The knowledge base

Translating knowledge into action


Predicate Logic (First Order Logic)
Predicate Logic Syntax
Predicate Logic Syntax
Predicate Logic
Predicate Logic
Predicate Logic-Reasoning
Predicate Logic-Resolution
Resolution is a procedure, which gains its efficiency from the fact that it operates on statements that have been
converted to a very convenient standard form
Resolution Algorithm
1. Convert all the statements of F to clause form
2. Negate P and convert the result to clause form
3. Repeat until either a contradiction is found
a) select two clauses, call them as parent clauses
b) resolve them together. Resolvent will be the disjunction of all the literals of both parent clauses
c) if the resolvent is empty, then a contradiction is found, if not then add it to the set of clauses
available to the procedure
Predicate Logic-Resolution proof
Unification
Unification and Lifting
UNIFY-is to take two atomic sentences p and q and return a substitution that would make p
and q look the same.
UNIFY (p, q) = Ɵ where SUBST(Ɵ,p) = SUBST(Ɵ,q)
Ɵ is called the unifier of the two sentences

Example: John hates everyone he knows


Knows(John,x) => Hates(John,x)

• Use the Modus Ponens inference rule to find out whom he hates
• Find those sentences in the knowledge base that unify with Knows(John, x), and then apply the
unifier to Hates(John, x)
• Knowledge base sentences:
Knows(John, Jane)
Knows(y, Leonid)
Knows(y, Mother(y))
Knows(x, Elizabeth)
• Unifying the antecedent of the rule against each of the sentences in the knowledge base
UNlFY(Knows(John,x), Knows( John, Jane)) - {x/Jane}
UNlFY(Knows(John, x), Knows(y, Leonid)) = {x/Leonid, y/John}
UNIFY(Knows(John,x), Knows(y,Mother (y))) = {y/John,x/Mother(John)}
UNlFY(Knows(John,x), Knows(x, Elizabeth)) =fail
Unification and Lifting
• The last unification fails because x cannot take on the value John and the value Elizabeth at the same time.
• we should be able to infer that John hates Elizabeth

standardizing apart
• Renaming the variables of one (or both) to avoid name clashes
UNlFY(Knows(John,x1), Knows(x2, Elizabeth)) = {x1 /Elizabeth, x2/John}

• UNIFY should return a substitution that makes the two arguments look the same.
UNlFY(Knows(John,x), Knows(y, z)) = {y/John,x/z}
Sample proof
1. American(x) A Weapon(y) A Nation(z) A Hostile(z) A Sells(x, z, y) => Criminal(x)
2. Owns(Nono,M1)
3. Missile(M1)
4. Owns(Nono, x) A Missile(x) => Sells(West, Nono, x)
5. Missile(x) => Weapon(x)
6. Enemy(x, America) => Hostile(x)
7. American(West)
8. Nation(Nono)
9. Enemy(Nono, America)
10. Nation(America)
Unification and Lifting
Proof using Modus Ponens:
Weapon(M1)
Hostile(Nono)
Sells(West,Nono,M1)
Criminal(West)

Forward chaining and Backward chaining


Representing knowledge using rules
Types of representations
• A declarative representation is one in which knowledge is specified, but the use to which that knowledge
is to be put is not given
• A procedural representation is one in which the control information that is necessary to use the
knowledge is considered to be embedded in the knowledge itself. An interpreter is needed to understand the
instructions in the knowledge.

Logic programming

Working Strategy
Types of Knowledge
• Declarative Knowledge
• Description of notions, facts, and rules of the world

• E.g.
• For each lecture there is a specific time and place
• Only one lecture can take place at each time and place

• Descriptional knowledge, non procedural, independent of


targets and problem solving
Types of Knowledge
• Procedural Knowledge
• Description of procedures required to achieve targets
• Knowledge of the order in which actions must be performed
• Heuristic knowledge

• E.g.
• To construct the exams timetable, assign first the classes of the
first year
• To reach Athens faster, take the airplane

• It depends on the targets and problems


Representing knowledge using rules
Forward and backward reasoning
• Forward Reasoning
1.process starts from start state
2.Tree is constructed for different moves and intermediate states
3.based on selection of rule(left side), next level is generated
4.selection rule evaluated from left to right
5.process continued till reaching the goal
• Backward Reasoning
1.process starts from goal state
2.Tree is constructed for different moves and intermediate states
3.based on selection of rule(right side), next level is generated
4.selection rule evaluated from right to left
5.process continued till reaching the start state
Matching
Compare the current state with preconditions of the rules to generate new states.
• Example: ELIZA- AI program developed to simulate Psychology therapist
• Communication between ELIZA and user
Person: Men all are alike.
ELIZA: In what way?
Person: They're always bugging us about something or other.
Representing knowledge using rules
ELIZA: Can you think of specific example?
Person: Well, my boyfriend made me come here.
ELIZA: Your boyfriend made you come here.
Person: He says I'm depressed much of the time.
ELIZA: I am sorry to hear you are depressed.
Person: It's true. I am unhappy.
ELIZA: Do you think coming here will help you not to be unhappy?
Person: I need some help, that much seems certain.
ELIZA: What would it mean to you if you got some help?
Person: Perhaps I could learn to get along with my brother.
ELIZA: Tell me more about your family.

• ELIZA-like rules
(X me Y) → (X you Y)
(I remember X) → (Why do you remember X just now?)
(My {family-member} is Y) → (Who else in your family is Y?)
(X {family-member} Y) → (Tell me more about your family)
Semantic Nets
• Since the late 1950s dozens of different versions of semantic networks have been proposed, with various
terminologies and notations.
• The main ideas:
1.For representing knowledge in structures
2.The meaning of a concept comes from the ways it is connected to other concepts
3.Labelled nodes representing concepts are connected by labelled arcs representing relations
Example:
A semantic Network Making Distinctions
Semantic Nets
Types of reasoning
Commonsense reasoning
• one of the branches of AI that is concerned with simulating the human ability to make presumptions about the
type and essence of ordinary situations they encounter every day.
• These assumptions include judgments about the physical properties, purpose, intentions and behavior of
people and objects, as well as possible outcomes of their actions and interactions.
• A device that exhibits commonsense reasoning will be capable of predicting results and drawing conclusions
that are similar to human.

Hypothetical reasoning
• Derives an explanatory hypothesis from a given set of facts
• The inference result is a hypothesis that, if true, could explain the occurrence of the given facts
• Examples
Dendral, an expert system to construct 3D structure of chemical compounds
Fact: mass spectrometer data of the compound and its chemical formula
KB: chemistry, esp. strength of different types of bounds
Reasoning: form a hypothetical 3D structure that satisfies the chemical formula, and that would most
likely produce the given mass spectrum
Types of reasoning
Analogical Reasoning
• Analogical Reasoning involves understanding new problems, in terms of family of problems. It also involves
addressing new problems, but transferring knowledge of relationships from known problems across domains.
• It consists of five major phases, retrieval, mapping, transfer, evaluation, and storage.
• An analogical reasoning in general, the target form and the source case need not be from the same domain.
• map the conceptual relationship in the target problem to the conceptual relationships in the source case
• Try to transfer some of the relationships in the source case to the target problem
• Abstract those relationships and then transfer them to the target problem

You might also like