Module 3 PDF
Module 3 PDF
KNOWLEDGE
REPRESENTATION
CSA2001
What is knowledge representation?
❑ Humans are best at understanding, reasoning, and interpreting
knowledge.
❑ But how machines do all these things comes under knowledge
representation and reasoning (KRR).
❑ Inference rules:
▪ Inference rules are the templates for generating valid arguments.
❑ Example:
▪ Statement-1: "If I am sleepy then I go to bed" ==> P→ Q.
▪ Statement-2: "I am sleepy" ==> P.
▪ Conclusion: "I go to bed." ==> Q.
▪ Hence, we can say that, if P→ Q is true and P is true then Q
will be true.
1
Modus Tollens
❑ The Modus Tollens rule state that if P→ Q is true and ¬ Q is
true, then ¬ P will also true.
❑ Example:
▪ Statement-1: "If I am sleepy then I go to bed" ==> P→ Q
▪ Statement-2: "I do not go to the bed."==> ~Q
▪ Statement-3: Which infers that "I am not sleepy" => ~P
Hypothetical Syllogism
❑ The Hypothetical Syllogism rule state that if P→R is true
whenever P→Q is true, and Q→R is true.
❑ Example:
▪ Statement-1: If you have my home key then you can unlock
my home. P→Q.
▪ Statement-2: If you can unlock my home then you can take
my money. Q→R.
▪ Conclusion: If you have my home key then you can take my
money. P→R
Disjunctive Syllogism
❑ The Disjunctive syllogism rule state that if P∨Q is true, and ¬P
is true, then Q will be true.
Example:
▪ Statement-1: Today is Sunday or Monday. ==>P∨Q
▪ Statement-2: Today is not Sunday. ==> ¬P
▪ Conclusion: Today is Monday. ==> Q
Addition
❑ The Addition rule is one the common inference rule, and it states
that If P is true, then P∨Q will be true.
Example:
▪ Statement: I have a vanilla ice-cream. ==> P.
▪ Statement-2: I have Chocolate ice-cream.
▪ Conclusion: I have vanilla or chocolate ice-cream. ==> (P∨Q)
Simplification
❑ The simplification rule state that if P∧ Q is true, then Q or
P will also be true.
First-Order Logic
Problems with PL
❑ In the topic of PL, we have seen that how to represent statements using
propositional logic.
❑ But unfortunately, in propositional logic, we can only represent the
facts, which are either true or false.
❑ PL is not sufficient to represent the complex sentences or natural
language statements. The propositional logic has very limited expressive
power.
❑ Consider the following sentence, which we cannot represent using PL
logic.
❑ Example:
▪ "Some humans are intelligent", or
▪ “All humans are intelligent",
❑ First-order
logic is also known as Predicate logic or
First-order predicate logic.
▪ Universal Instantiation
▪ Existential Instantiation
▪ Existential introduction
Universal Generalization
❑ Universal generalization is a valid inference rule which states that if
premise P(c) is true for any arbitrary element c in the universe of
discourse, then we can have a conclusion as ∀ x P(x).
❑ This rule can be used if we want to show that every element has a
similar property.
❑ It takes two literals as input and makes them identical using substitution.
❑ Let Ψ1 and Ψ2 be two atomic sentences and 𝜎 be a unifier such that, Ψ1𝜎 =
Ψ2𝜎, then it can be expressed as UNIFY(Ψ1, Ψ2).
▪ Substitute x with a, and y with f(z) in the first expression, and it will be
represented as a/x and f(z)/y.
▪ With both the substitutions, the first expression will be identical to the
second expression and the substitution set will be: [a/x, f(z)/y].
Conditions for Unification:
❑ Following are some basic conditions for unification:
▪ Unification will fail if there are two similar variables present in the
same expression.
Example 1
❑ UNIFY(knows(Richard, x), knows(Richard, John))
SUBST θ= {y/b}
S1 => {Q(a, g(f(b), a), f(b)); Q(a, g(f(b), a),
f(b))}, Successfully Unified.
❑ The resolution rule for first-order logic can resolve two clauses if they
contain complementary literals, which are assumed to be
standardized apart so that they share no variables.
❑ This rule is also called the binary resolution rule because it only
resolves exactly two literals.
The resolution inference rule:
❑ Example:
▪ We can resolve two clauses which are given below:
**** To better understand all the above steps, we will take an example
in which we will apply resolution.
Example:
▪ John likes all kind of food.
▪ Check A → B is equivalent to –A V B
❑
Step-2:
❑ Eliminate all implications (→) and rewrite
▪ Check A → B is equivalent to –A V B
Step-2:
❑ Eliminate all implications (→) and rewrite
Step-2:
❑ Move negation (¬)inwards and rewrite
DE Morgan's Law:
▪ ¬ (P ∧ Q) = (¬P) ∨ (¬Q)
▪ ¬ (P ∨ Q) = (¬ P) ∧ (¬Q).
Step-2:
❑ Move negation (¬)inwards and rewrite
Step-2:
❑ Rename variables or standardize variables
Step-2:
❑ Eliminate existential instantiation quantifier by elimination.
❑ Disjunctive Syllogism:
❑ Resolution:
Step-4: Draw Resolution graph:
❑ Now in this step, we will solve the problem by resolution tree using
substitution.
Explanation of Resolution graph:
❑ In the first step of resolution graph, ¬likes(John, Peanuts) , and likes(John,
x) get resolved(canceled) by substitution of {Peanuts/x}, and we are left with ¬
food(Peanuts)
❑ In the second step of the resolution graph, ¬ food(Peanuts) , and food(z) get
resolved (canceled) by substitution of { Peanuts/z}, and we are left with ¬ eats(y,
Peanuts) V killed(y) .
❑ In the third step of the resolution graph, ¬ eats(y, Peanuts) and eats (Anil,
Peanuts) get resolved by substitution {Anil/y}, and we are left with Killed(Anil) .
❑ In the fourth step of the resolution graph, Killed(Anil) and ¬ killed(k) get resolve
by substitution {Anil/k}, and we are left with ¬ alive(Anil) .
❑ In the last step of the resolution graph ¬ alive(Anil) and alive(Anil) get resolved.
Forward and Backward chaining
FC and BC in AI
❑ In artificial intelligence, forward and backward chaining is one of
the important topics, but before understanding forward and
backward chaining lets first understand Inference Engine.
❑ Inference engine:
❑ Translate the above sentences into predicate logic & using FC and
BC prove that:
▪ ∀x ¬ killed(x) → alive(x)
▪ ∀x alive(x) → ¬ killed(x)
❑ Needs to prove:
▪ likes(John, Peanuts).
▪ Proof using Forward chaining:
Modus
Ponens
likes(John, Peanuts)
food (Peanuts)
likes(John, Peanuts)
food (Peanuts)
▪ IF (on the bus AND paid AND empty seat) THEN action (sit down).
▪ IF (bus arrives at destination) THEN action (get down from the bus).
Production Rules
❑ Advantages of Production rule:
The production rules are expressed in natural language.
The production rules are highly modular, so we can easily remove,
add or modify an individual rule.
❑ Disadvantages of Production rule:
Production rule system does not exhibit any learning capabilities, as
it does not store the result of the problem for the future uses.
During the execution of the program, many rules may be active
hence rule-based production systems are inefficient.