Unit 2
Unit 2
Faculty:
Dr. Sangeetha V
Assistant Professor
Department of CSE
Knowledge base
Inference Engine
Domain-independent algorithms
Tell facts
Ask for inference
◦ MAKE-PERCEPT-SENTENCE
generates a sentence, what the
agent perceived at the given
time.
◦ MAKE-ACTION-QUERY generates a
sentence to ask which action
should be done at the current
time.
◦ MAKE-ACTION-SENTENCE
generates a sentence which
asserts that the chosen action
was executed.
Example: Functions
Initial situation:
[Stench,Breeze,Glitter,None,None]
Disjunction: A sentence which has ∨ connective, such as P ∨ Q. is called disjunction, where P and Q are the proposit
Example: "Ritika is a doctor or Engineer",
Here P= Ritika is Doctor. Q= Ritika is Doctor, so we can write it as P ∨ Q.
Example : P ^ Q
Any sentences of the form α ⇒ β and α are given, then the sentence β can be inferred.
Example
"He studies very hard and he is the best boy in the class", P∧Q
Therefore − "He studies very hard” P
R - If there is a donut T T F F F T F F T
T F F T F F F F T
Premises P🡪Q T F F F F T F F T
R🡪Q F T T T T T T T T
~P ∧ R
F T T F T T F F T
_______
F F T T T F T F T
Conclusion Q
F F T F T T F F T
if KB |= α then KB ∧ β |= α
Clause : is
– A literal or
– Disjunction of two or more literals or
– The empty clause
Example: { } , P, P ∨ ¬Q ∨ R
Completeness: If KB |= Q then KB |- Q
◦ If Q is entailed by a set of sentences KB, then Q can be derived from KB using the rules of
inference.
◦ Hence, inference produces all entailments, or all valid sentences can be proved from the premises.
Example : ¬A ∨ ¬C ∨ D
Example :
Temperature/Symptoms( Rules)
Pinky is a cat
cat(x)
Department of Computer Science and Engineering 78
First Order logic
• First Order Logic (FOL) is a way of knowledge representation.
• It is an extension of PL
• It is also known as Predicate Logic.
• FOL is a collection of objects, their attributes and relations among them to represent knowledge.
• Objects: houses, numbers, theories, Ronald McDonald, colors, baseball games, wars, centuries . . .
• Relations: these can be unary relations or properties such as red, round, bogus, prime,multistoried . . .,
or more general n-ary relations such as brother of, bigger than, inside,part of, has color, occurred after,
owns, comes between, . . .
• Function: Father of, best friend, third inning of, end of, ......
Example : LeftLeg(John)
A variable is a term all by itself, and as such can also serve as the argument of a
function
2. X is an integer
integer(x)
• Existential Quantifier
8. “Some boys like cricket”
∃ x : boys(x) ∧ like (x, cricket)
Domains of
◦ Family relationships(The kinship domain)
◦ Wumpus world
The connectivity between gates can be represented by predicate Connect(Out(1, X1), In(1, X1)).
Department of Computer Science and Engineering 117
Knowledge engineering in first-order logic
4.Encode general knowledge about the domain
To encode the general knowledge about the logic circuit,
we need some following rules:
In circuit there are two XOR, two AND, and one OR gate so atomic sentences for these gates will be:
• Universal Instantiation
• Existential Instantiation
• Existential introduction
Example
Let's represent, P(c): "A byte contains 8 bits",
so for ∀ x P(x) "All bytes contain 8 bits.", it will also be true.
The UI rule state that we can infer any sentence P(c) by substituting a
ground term c (a constant within domain x) from ∀ x P(x) for any
object in the universe of discourse.
Example 1:
IF "Every person like ice-cream"=> ∀x P(x)
so we can infer that "John likes ice-cream" => P(c)
Example
Unification conditions
1. Predicate symbol must be same
2. Number of arguments in both expressions must be identical
3. If two similar variables present in same expression, then unification fails
Chicken is food
Chicken(x) 🡪 food(x)
~ killed (bill)
eats (bill, peanut )
~ killed (bill)
eats (bill, peanut )
165
ALGORITHM TO CONVERT TO CLAUSAL FORM
3. Standardize variables: rename all variables so that each quantifier has its
own unique variable name
Example:
∀ x : man(x) ∀ x : man(x)
∀ x : Happy(x) ∀ y : Happy(y)
∃ x : boys(x) ∃ z : boys(z)
166
ALGORITHM TO CONVERT TO CLAUSAL FORM
Skolem constants and functions
4. Skolemization
Eliminate existential quantifier and replace it by skolem constants
Example:
∃ x : Smile(x)
∃ y : Graduating(y )
After Skolemization
Smile(A)
Graduating(B)
167
ALGORITHM TO CONVERT TO CLAUSAL FORM
5. Drop or Remove universal quantifiers by
(1) moving them all to the left end;
(2) making the scope of each the entire sentence;
(3) dropping the “prefix” part Example:
∀ x : Smile(x)
∀ y : Graduating(y )
After Dropping
Smile(x)
Graduating(y) 168
ALGORITHM TO CONVERT TO CLAUSAL FORM
6. Apply distribute law / associative laws
(P ∧ Q) ∨ R ⇒ (P ∨ R) ∧ (Q ∨ R)
(P ∨ Q) ∨ R ⇒ (P ∨ Q ∨ R)
7. Split conjuncts into separate clauses
8. Standardize variables so each clause contains only variable names that do not
occur in any other clause
169
Resolution Refutation
• Resolution is a theorem proving technique that proceeds
by building refutation proofs, i.e., proofs by
contradictions.
• It was invented by a Mathematician John Alan Robinson in
the year 1965.
• Resolution is used, if there are various statements given,
and we need to prove a conclusion of those statements.
Hence Proved
Hence Proved
Theorem to proof :
Fido will die : die(fido).
2. dog(fido)
3. ∀ Y [animal(Y ) ⇒ die(Y )]
∀ Y ¬ animal(Y) ∨ die(Y)
¬ animal(Y) ∨ die(Y)
• dog(fido)
• animal(Y) ∨ die(Y)
• ¬ die(fido)
203
Department of Computer Science and Engineering 203
Fig. Answer extraction process on the “finding fido” problem.
Dog Fido goes wherever John goes. John is at library. Where is Fido?
204
Department of Computer Science and Engineering 204
Department of Computer Science and Engineering 205
Department of Computer Science and Engineering 206
Resolution Problem
All teachers are good. Anyone who is good and
intelligent will deliver excellent lecture. Mohan is an
intelligent teacher. Show that Mohan will deliver an
excellent lecture.