Chapter 4 - Knowledge and Reasoning (I)
Chapter 4 - Knowledge and Reasoning (I)
1
Knowledge Base Agent
Knowledge base agent is an agent that perform action using the
knowledge it has and reason about their action using its inference
procedure.
3
Knowledge Bases Agent
4
Example
Agent should incorporate new percept
For example,
1. Azieb get maried with melaku, they born two kids selam and solomon
2. This can be reflected by incorporating the new percepts
FACTS
1. female(azieb).
2. Age(azieb, 18).
3. Married(azieb, melaku).
4. male(melaku).
5. female(selam).
6. male(solomon).
7. parent(melaku,selam).
8. parent(azieb,selam).
9. parent(melaku,solomon).
10. parent(azieb,solomon).
11. age(melaku,26).
12. age(selam, 5).
13. age(solomon, 1).
RULE
1. married(X,Y):-maried(Y,X).
2. father(X,Y):-male(X),parent(X,Y).
3. mother(X,Y):-female(X),parent(X,Y).
4. wife(X,Y):-parent(X,Z),parent(Y,Z).
5. brother(X,Y):-male(X), parent(Z,X),parent(Z,Y).
6. sister(X,Y):-female(X), parent(Z,X),parent(Z,Y).
5
Example
The agent should deduce hidden portion of the world like azieb and selam
are beautiful.
If one asks questions like
?brother(aster,belay).
Married(melaku, azieb).
The system must respond correctly
Deduce appropriate action to query.
If one asks questions like
who is the sister of whom,
who is the father of belay,
who is the mother of Selam, etc
The system must respond correctly
Agent should update internal representation of the world.
For example, if died(melaku) is given we should modify any fact that
tells us about live history about melaku.
6
Knowledge representation
Knowledge representation refers to the technique how to express
the available facts and rules inside a computer so that agent will
use it to perform well.
Knowledge representation consists of:
Syntax (grammar): possible physical configuration that
constitute a sentence (fact or rule) inside the agent architecture.
For example one possible syntax rule may be every sentence must end
with full stop.
Semantics (concept): determine the facts in the world to which
the sentence refers
Without semantics a sentence is just a sequence of characters or binary
sequences
Semantic defines the meaning of the sentence
7
Knowledge representation
E.g., In the language of arithmetic
x+2 ≥ y is a sentence; x2+y > {} is not a sentence
x+2 ≥ y is true iff the number x+2 is not less than the number y
x+2 ≥ y is true in a world where x = 7, y = 1
x+2 ≥ y is false in a world where x = 0, y = 6
8
Logic
9
Types of Logic
In mathematics there are different kinds of logics.
Some of these according to order of their generality are
Prepositional logic
First order logic
Second order logic and more
First order logic can be used to design, represent or infer for any
environment in the real world.
10
Prepositional (Boolean) logic (PL)
Preposition is statement which is either true or false but not both at any
time.
A statement is a sentence which is either true or false.
PL uses declarative sentences only
PL doesn’t involve quantifiers.
Not all sentences are statement (interrogatives, imperatives and
exclamatory)
Preposition can be conditional or unconditional
Examples
Socrates is mortal (unconditional)
If the winter is severe, students will not succeed. (conditional)
All are the same iff their color is black (conditional)
In prepositional logic, symbols represent the whole preposition.
Examples:
M = Socrates is mortal
W = winter is sever
S = students will not succeed
11
Prepositional (Boolean) logic (PL)
Preposition symbols can be combined using Boolean connectives to
generate new preposition with complex meaning
Symbols involved in PL:
Logical constants (TRUE and FALSE)
Preposition symbols (also called atomic symbols) like M, W, S
Logical connectives
(negation),
(conjunction),
(disjunction),
(bi-implication or equivalence),
(implication) and parenthesis
12
Prepositional (Boolean) logic (PL)
Rules
Logical constants and propositional symbols are sentence by them selves
Wrapping parenthesis around a sentence yield a sentence like
(P V Q)
Literal are atomic symbols or negated atomic symbols
Complex sentence can be formed by combining simpler sentences with
logical connectors
PL connector priority
Priority of logical connectives from highest to lowest
parenthesis
Negation
Conjunction
Disjunction
Implication
Bi-implication
13
Types of sentence
Given a sentence α, this sentence according to the world considered can
be
Valid (tautology)
Invalid (contradiction)
Satisfiable (neither valid nor invalid)
Validity (tautology)
A sentence is valid iff it is true under any interpretations in all
possible world
14
Satisfiablility
A sentence is satisfiable iff there is some interpretation in some
world for which it is true.
Every valid sentence is satisfiable
Example: x+2 = 20
Every student of AI are in their class
A sentence which is not satisfiable is unsatisfiable (contradiction or
invalid).
15
Entailment
Entailment means that one thing follows from another:
It can be represented by ╞ symbol (double turnstyle)
KB ╞ α shows α can be entailed from KB
16
Inference Procedure
17
Inference Procedure property
The record of operation of a sound inference procedure is called
a proof
Soundness of an inference can be established through truth table.
For example and inference procedure that entails P from a KB
which consists of PQ & Q is not sound as shown bellow
P Q PQ Remark
2. And Elimination
3. And introduction
4. Or introduction
6. Unit resolution
19
7. Resolution
Normal Forms of Logical expression
There are different standard forms of expressing PL statement.
Some inference procedure require their knowledge base to be in one
of the normal forms to infer from it.
Hence, we need to convert the logical expression which are the
source of knowledge into the appropriate forms
Some of the normal forms are stated bellow
20
Normal Forms of Logical expression
Clausal normal form:
it is a set of one or more literals connected with the disjunction operator
(disjunction of literals).
It doesn’t allow negation marker except as a prefix to a symbol
Example ~P Q ~R is a clausal form
According to the definition a single symbol or negation of a symbol is in
clausal form
Conjunctive normal forms (CNF):
Simply defined as a sequences of one or more clauses connected by the
conjunction operator
Or it is conjunction of clauses
Or conjunction of disjunction of literals
Example (A B) (C D)
Note: connector is needed if we have two or more elementary unit to
connect to each other to form complex expression
This is the basis for the generalized resolution inference procedure
21
Normal Forms of Logical expression
Disjunctive normal form (DNF):
disjunction of conjunction of literals.
Example (A B) (C D)
22
Inference procedure and normal forms
The inference procedure that we have seen before are all sound
If KB is represented in CNF, the generalized resolution inference
procedure is complete
If KB is represented in Horn form, the generalized modes ponens
algorithm is complete
It can be proved that every sentence of human language can be
represented using logic as CNF. However, it is not possible in Horn form.
Therefore, CNF is a more powerful representation technique for
knowledge
But, Horn form representation of knowledge is easily understandable
and convenient. It also require polynomial time inference procedure
23
Modes Ponens
There are a set of already identified inference rules. These are:
1. Modes Ponens or implication elimination
2. And Elimination
3. And introduction
4. Or introduction
6. Unit resolution
7. Resolution
24
Generalized Resolution for PL
Given any two clauses A and B, if there are any literal P 1 in A which has a
F: P R S from A and C
G: Q M R S from F and B etc
25
Generalized Resolution for PL
Resolution can also be used to prove a sentence whether it is valid or
not.
That can be done using direct method or indirect method (refutation)
For example Given a KB consists of the sentences
A: P Q R
B: ~P R
C: ~Q
We need to prove R
Method One (Direct)
Entail D: Q R from A and B
Entail E: R from D and C
Note: in order to apply resolution for proving a theory, make sure first
all the knowledge is in its clausal form
26
Generalized Resolution for PL
Method Two (refutation)
Insert the negation of the statement as valid sentence
A: P Q R
B: ~P R
C: ~Q
D: ~ R
Find fallacy in the KB that will indicate the added statement is invalid
so that its negation is valid
Entail E: Q R from A and B
Entail F: R from C and E
Entail G: {} from D and F
An empty clause shows false. This proves the contradiction.
27
Generalized Resolution for PL
Method Two (refutation) Graphical representation
Insert the negation of the statement as valid sentence
A: P Q R
B: ~P R
C: ~Q
D: ~ R
28
Example: Resolution
Prove that r follows from:
(p q) (r s) - (1)
p~s - (2)
p q - (3)
Solution:
Clause (1) in Clausal form
~ (p q) (r s)
{~ p ~ q r s} - (1)
Clause (2) in Clausal form
{~ p ~ s} - (2)
Clause (3) in Clausal form
{p} - (3)
{q} - (4)
Assume not r which {~ r} in Clausal form - (5)
29
Example: Resolution
Using inference rules: from unit resolution rule of (1) and (5)
{~p ~ q s} - (6) (resolve r with ~r and get resolvent)
from unit resolution of (3) and (6)
{~ q s} - (7) (resolve p with ~p and get resolvent)
from (4) and (7)
{s} - (8) (resolve q with ~q and get resolvent)
from (2) and (8)
{~ p} - (9) (resolve p with ~p and get resolvent)
from (3) and (9)
{} - (10)
Therefore r follows from the original clauses
30
What rule is used for the conclusion?
32
Logical equivalence
33
Converting to CNF
Converting the following sentence to CNF:
a ~b↔c
≡ (a ~ b) ↔ c
Steps:
1. Remove Bi-implication
[(a ~ b) c] [c (a ~ b)]
2. Remove Implication
[~(a ~ b) c] [~c (a ~ b)]
3. Push Negations Inwards
[~a ~~b c] [~c (a ~ b)]
4. Eliminate Double Negations
[~a b c] [~c (a ~ b)]
5. Push Disjunctions into Conjunctions
[~a b c] [~c a] [~c ~ b]
34
Converting to CNF
35
Model
36
Complexity of prepositional inference
37