Knowledge and Reasoning AAU
Knowledge and Reasoning AAU
Weeks 8 and 9
OBJECTIVES
To familiarize with knowledge based agents
To learn express knowledge in formal languages
2
KNOWLEDGE BASED AGENTS
KNOWLEDGE
Knowledge includes facts about the real world entities and the
relationship between them
Characteristics of Knowledge:
It is voluminous in nature and requires proper structuring.
It may be incomplete and imprecise.
It may keep on changing (dynamic).
Inference mechanism :
With the help of inference mechanism deduce new sentences and use
them to decide what action to take
Learning mechanism:
Adapt to changes in the environment by updating the relevant knowledge
9
The agent operates as follows:
1. It receives percepts from environment
2. It computes what action it should perform (by IE and
KB)
3. It performs the chosen action (some actions are simply
inserting inferred new facts into KB).
10
Example: An automated taxi might be said to know that the Abay Bridge
links Kebele10 and Kebele11
Logical Level.
The level at which the knowledge is encoded into sentences.
11
THE WUMPUS WORLD
Wumpus is an early computer game based on an agent who
explores a cave consisting of rooms. Somewhere in the cave is
the wumpus, a beast that eats anyone who enters its room. To
make matters worse, some rooms contain bottomless pits that
will trap anyone who wanders into these rooms. (except for the
wumpus, who is big to be trapped). The only good feature in
this environment is heap of gold. Like the vacuum world, the
wumpus world is a grid of squares surrounded by walls, where
each square can contain agents and objects.
12
PERCEPTS
In the square containing the wumpus, in the directly adjacent
squares(not diagonally) the agent will perceive a stench (unpleasant
smell)
In the squares directly adajcent to the pit, the agent will perceive a
Breeze (a gentle wind).
In the square where the gold is, the agent will perceive a glitter.
13
4
3
Stench
2
1 Breeze
1 2 3 4
Where is the Pit?
Where is the wumpus?
14
There is no stench or breeze in (1,1) adjacent squares are
safe
A cautious agent moves to a square that is safe
Assume moving to (2,1), there is a breeze, there must be a pit
either in (2,2), (3,1)
The pit can not be in (1,1) because we were already there.
15
`KNOWLEDGE REPRESENTATION,
REASONING AND LOGIC
KNOWLEDGE REPRESENTATION &
REASONING
Proof Theory: how we can draw new conclusions from existing statements in
the logic. It is a means of carrying our reasoning using a set of rules.
WHY FORMAL LANGUAGES (LOGIC) ?
23
NATURAL LANGUAGES
Natural languages are certainly expressive,
they help us for communication, not for representation.
A good way for a speaker to get a listener to come to know
something
Natural language also suffers from ambiguity.
Small dogs and cats
Dangerous men and locations
24
LOGICS
Logic is the science or art of reasoning
Concerned with what is true and how we know whether
something is true.
Two kinds of Logic
Propositional or Boolean Logic
First-order Logic
In both propositional and first order logic, a sentence represents a fact and
the agent either believes the sentence to be true, believes it to be false, or
is unable to conclude either way. These logics therefore have three
possible states of belief.
Systems using probability theory, on the other hand, can have any degree
of belief, ranging from 0(total disbelief) to 1 (total belief).
25
PROPOSITIONAL LOGIC
A very simple logic
26
FIRST ORDER LOGIC
Commits the representation of the world in terms of
objects and predicates on objects
Predicates
may be properties, relationships
Uses connectives and quantifiers
27
PROPOSITIONAL LOGIC
PROPOSITIONAL LOGIC
A simple language useful for showing key ideas and definitions
Syntax: PL allows facts about the world to be represented as
sentences formed from:
Logical constants: True, False
Proposition symbols (P, Q, R, …) are used to represent facts about the world:
e.g.: P = "It is hot“, Q = "It is humid“, R = "It is raining“
Logical connectives: not (), and ( or (), implies (), is equivalent, if and
only if ().
Parenthesis ( ): Used for grouping sentences and to specify order of precedence
(P (Q ((R))) vs. P (Q R)
Precedence order from highest to lowest is: , ,,,
The sentence P v Q R S is equivalent to ((P) v (Q R)) S
Binary operators are left associative: so P Q R is (P Q) R
Questions:
Is (P Q) R same as P (Q R) ?
Is (P Q) R same as P (Q R) ?
Is (P Q) R same as P (Q R) ?
PROPOSITIONAL LOGIC (PL)
A sentence is made by putting symbols together.
There are atomic and complex sentences.
Atomic sentences: consist of propositional symbol (e.g. P, Q, TRUE,
FALSE)
If S is a sentence, then S is a sentence (not or negation)
If S is a sentence, then so is (S)
Complex sentences are combined by using connectives or
parenthesis:
If S and T are sentences, then S T, (S T), (S T), (S T), and (S T) are
complex sentences, and are called conjunction, disjunction, implication, and
equivalent, respectively.
Examples: PL sentences for the “weather problem”:
“If it is hot and humid, then it is raining”: (P Q) R
“If it is humid, then it is hot” : Q P
“It is humid.”: Q
A better way: Ho=“It is hot”, Hu=“It is humid”, R=“It is raining”
EXAMPLE SENTENCES IN PL
Completeness: If KB |= Q then KB |- Q
A logic is complete if it is capable of proving all consequences that can be
represented in it.
If Q is entailed by a set of sentences KB, then Q can be derived from KB using
inference rules.
Hence, inference produces all entailments, or all valid sentences can be proved from the
premises.
A set of inference rules is complete if every entailed sentences can be obtained
by applying some finite
succession of these rules
Modus ponens alone is not complete,
e.g.: from A B and B, we cannot get A
SOUNDNESS
Soundness: If KB |- Q then KB |= Q
A logic is sound if it preserves truth (i.e. if a set of premises are all
true, any conclusion drawn from those premises must also be true).
If Q is derived from a set of sentences KB using a given set of rules of
inference, then Q is entailed by KB.
Hence, inference produces only real entailments, or any sentence that follows
deductively from the premises is valid.
We can proof soundness by constructing the truth table.
An inference rule is sound if it generates only entailed sentences
All inference rules previously given are sound
A ruleis sound if its conclusion is true whenever the premise is true.
E.g. modus ponens: { , }
The following rule: { , }
is unsound, which does not mean it is useless
EXAMPLES
From: Unit resolution vs. Modus ponens
Engine-Starts Car-OK
Engine-Starts Engine-Starts Car-OK
Infer: Car-OK
From:
Engine-Starts Flat-Tire Car-OK
Engine-Starts Empty-Gas-Tank Full Resolution
Infer: Empty-Gas-Tank Flat-Tire Car-OK
EXAMPLE
From: Resolution vs. Hypothetical syllogism
P Q ( P Q)
Q R ( Q R)
Infer: P R ( P R)
From:
Engine-Starts Flat-Tire Car-OK
Engine-Starts Flat-Tire
Infer: (Flat-Tire Flat-Tire) Car-OK True
Tautology/valid
FORMAL PROOFS
A proof is a sequence of steps followed to generate sentences, where
each sentence is
either a premise or a sentence/formula derived from earlier sentences (of the
proof) using some of the rules of inference.
The last step of the proof should deduce the formula (also called goal or query)
that we want to prove.
45
EXAMPLE 1
Construct formal proof of validity for the following problem:
If the investigation continues, then new evidence is brought to light.
If new evidence is brought to light, then several leading citizens are
implicated. If several leading citizens are implicated, then the
newspapers stop publicizing the case. If continuation of the
investigation implies that the newspapers stop publicizing the case,
then the bringing to light of new evidence implies that the
investigation continues. The investigation does not continue.
Therefore, new evidence is not brought to light.
1. CB
2. BI
3. IS
4. (C S) (B C)
5. C
6. CI 1,2 (Hypothetical Syllogism)
7. CS 6,3 (Hypothetical Syllogism)
8. IC 7,4 (Modus Ponens)
9. B 8,5 (Modus Tollens)
EXAMPLE 2
Deme is either intelligent or a good actor. If Deme is intelligent,
then he can count from 1 to 10. Deme can only count fom 1 to 2.
Therefore Deme is a good actor.
Represent using PL and proof the conclusion that Deme is a good actor or
not.
EXAMPLE 3
1. Battery-OK Bulbs-OK Headlights-Work
2. Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts
3. Engine-Starts Flat-Tire Car-OK
4. Headlights-Work
5. Battery-OK
6. Starter-OK
7. Empty-Gas-Tank
8. Car-OK
Represent the following problem and infer the third sentence from
the first two:
Every person is mortal.
Abebe is a person.
Therefore, Abebe is mortal.
InPL use propositional symbols to stand for all or part of each
sentence. Hence,
P = “person”; M = “mortal”; A = “Abebe”
So the above sentences are represented as:
P M, A P (Hypothesis). We can infer: A M
Although the third sentence is entailed by the first two, we need an
explicit symbol, A, to represent an individual, Abebe, who is a
member of the classes “person” and “mortal.”
To represent other individuals we must introduce separate symbols for each one,
which means for representing the fact that all individuals who are “people” are
also "mortal.”
PROPOSITIONAL LOGIC IS A WEAK LANGUAGE
PL cannot handle even a domain with small worlds. The problem is that there are
just too many propositions to handle since it only has one representational device:
the proposition
In PL world consists of just facts. It is hard to :
Identifyindividuals: E.g., Mary, 3
Describe properties of (or relations between) individuals. E.g. Belete is taller than
Gelaw
Generalize for a given universe. E.g., all triangles have 3 sides
Due to the ambiguity in natural languages there is a need to specify knowledge through
the use of formal languages
Formal languages give us a way to remove ambiguity and provide methods for automating
inference. PL is a first move in this direction
Inference: The process of deriving new sentences from old one
Sound inference: derives true conclusions given true premises.
Complete inference: derives all true conclusions from a set of premises.
A valid sentence is true in all worlds under all interpretations.
If an implication sentence can be shown to be valid, then
given its premise - its consequent can be derived.
Different logics make different commitments about what the world is made of and what
kind of beliefs we can have regarding the facts.
Logicsare useful for the commitments they do not make because lack of commitment gives the
knowledge base engineer more freedom.
PL commits only to the existence of facts that may or may not be the case in the world
being represented.
Using a simple syntax and semantic, it illustrates the process of inference.
PL quickly becomes impractical, even for very small worlds.