0% found this document useful (0 votes)
6 views

Module 3 PDF

Knowledge representation and reasoning (KRR) is a field of artificial intelligence focused on how machines can understand, reason, and interpret knowledge, contributing to intelligent behavior. It includes techniques such as logical representation, which encompasses propositional and predicate logics, enabling machines to draw conclusions based on defined rules. The document also discusses the limitations of propositional logic and introduces first-order logic as a more expressive alternative for representing complex statements and relationships.

Uploaded by

SHUBH SINGH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Module 3 PDF

Knowledge representation and reasoning (KRR) is a field of artificial intelligence focused on how machines can understand, reason, and interpret knowledge, contributing to intelligent behavior. It includes techniques such as logical representation, which encompasses propositional and predicate logics, enabling machines to draw conclusions based on defined rules. The document also discusses the limitations of propositional logic and introduces first-order logic as a more expressive alternative for representing complex statements and relationships.

Uploaded by

SHUBH SINGH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 106

Unit-3

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).

❑ We can describe Knowledge representation as following:


▪ concerned with AI agents thinking and how thinking contributes to
intelligent behavior of agents.
▪ representing information about the real world.
▪ Not just storing data into some database, but it also enables an
intelligent machine to learn from that knowledge and experiences
The relation between knowledge and
intelligence
AI knowledge cycle
▪ Perception
▪ Learning
▪ Knowledge Representation and Reasoning
▪ Planning
▪ Execution
Techniques of knowledge
representation
What is knowledge representation?
Logical Representation
❑ Logical representation is a language with some concrete rules which
deals with propositions.
❑ Logical representation means drawing a conclusion based on
various conditions.
❑ It consists of precisely defined syntax and semantics which supports
the sound inference.
❑ Syntax:
▪ Syntaxes are the rules which decide how we can construct legal
sentences in the logic.
❑ Semantics:
▪ Semantics are the rules by which we can interpret the sentence in
the logic.
Logical Representation

❑ Logical representation can be categorized into mainly two logics:


▪ Propositional Logics
▪ Predicate logics

❑ Advantages of logical representation:


▪ Enables us to do logical reasoning.
▪ basis for the programming languages.

❑ Disadvantages of logical Representation:


▪ Have some restrictions and are challenging to work with.
▪ may not be very natural, and inference may not be so efficient.
Propositional Logic
Propositional logic (PL)
❑ PL is the simplest form of logic where all the statements are made by
propositions.
❑ A proposition is a declarative statement which is either true or false.
❑ Example:
▪ It is Sunday.
▪ The Sun rises from West (False proposition)
▪ 3+3= 7(False proposition)
▪ 5 is a prime number.
Basic Facts about PL
❑ Propositional logic is also called Boolean logic as it works on 0 and 1.
❑ In propositional logic, we use symbolic variables to represent the logic,
and we can use any symbol for representing a proposition, such A, B, C,
P, Q, R, etc.
❑ Propositions can be either true or false, but it cannot be both.
❑ Propositional logic consists of an object, relations or function, and logical
connectives.
❑ These connectives are also called logical operators.
❑ The propositions and connectives are the basic elements of the
propositional logic.
❑ Connectives can be said as a logical operator which connects two
sentences.
❑ A proposition formula which is always true is called tautology, and it is
also called a valid sentence.
❑ A proposition formula which is always false is called Contradiction.
❑ Statements which are questions, commands, or opinions are not
propositions such as "Where is Rohini", "How are you", "What is your
name", are not propositions.
Syntax of propositional logic:
❑ The syntax of propositional logic defines the allowable sentences for
the knowledge representation. There are two types of Propositions.
❑ Atomic Propositions
▪ Atomic propositions are the simple propositions. It consists of a
single proposition symbol. These are the sentences which must be
either true or false.
❖ Example:
o 2+2 is 4, it is an atomic proposition as it is a true fact.
o "The Sun is cold" is also a proposition as it is a false fact.
❑ Compound propositions
▪ Compound propositions are constructed by combining simpler or
atomic propositions, using parenthesis and logical connectives.
❖ Example:
• "It is raining today, and street is wet."
• "Ankit is a doctor, and his clinic is in Mumbai."
Logical Connectives:
❑ Logical connectives are used to connect two simpler propositions or
representing a sentence logically. We can create compound
propositions with the help of logical connectives.

❑ There are mainly five connectives, which are given as follows:


▪ Negation.
▪ Conjunction.
▪ Disjunction.
▪ Implication.
▪ Biconditional
Logical Connectives:
❑ Negation: A sentence such as ¬ P is called negation of P. A literal can be
either Positive literal or negative literal.
❑ Conjunction: A sentence which has ∧ connective such as, P ∧ Q is called
a conjunction.
• Example: Rohan is intelligent and hardworking.
• It can be written as, P= Rohan is intelligent, Q= Rohan is hardworking. →
P∧ Q.
❑ Disjunction: A sentence which has ∨ connective, such as P ∨ Q. is called
disjunction, where P and Q are the propositions.
▪ Example: "Ritika is a doctor or Engineer", Here P= Ritika is Doctor. Q=
Ritika is Engineer, so we can write it as P ∨ Q.
❑ Implication: A sentence such as P → Q, is called an implication.
Implications are also known as if-then rules.
o Example: If it is raining, then the street is wet.
▪ Let P= It is raining, and Q= Street is wet, so it is represented as P → Q
❑ Biconditional: A sentence such as P⇔ Q is a Biconditional sentence.
▪ Example: If I am breathing, then I am alive.
▪ P= I am breathing, Q= I am alive, it can be represented as P ⇔ Q.
Summary of Propositional Logic
Connectives:
Truth Tables: Truth values of propositions in all
possible scenarios
Truth Tables:
Truth table with three propositions:
Precedence of connectives:
❑ Just like arithmetic operators, there is a precedence order for propositional
connectors or logical operators.
❑ This order should be followed while evaluating a propositional problem.
❑ Following is the list of the precedence order for operators:
Logical equivalence:
❑ Logical equivalence is one of the features of propositional logic. Two
propositions are said to be logically equivalent if and only if the columns in
the truth table are identical to each other.
❑ Let's take two propositions A and B, so for logical equivalence, we can
write it as A⇔B. In below truth table we can see that column for ¬A∨ B and
A→B, are identical hence A is Equivalent to B
Properties of Operators:
❑ Commutativity:
▪ P∧ Q= Q ∧ P, or
▪ P ∨ Q = Q ∨ P.
❑ Associativity:
▪ (P ∧ Q) ∧ R= P ∧ (Q ∧ R),
▪ (P ∨ Q) ∨ R= P ∨ (Q ∨ R)
❑ Identity element:
▪ P ∧ True = P,
▪ P ∨ True= True.
❑ Distributive:
▪ P∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
▪ P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).
❑ DE Morgan's Law:
▪ ¬ (P ∧ Q) = (¬P) ∨ (¬Q)
▪ ¬ (P ∨ Q) = (¬ P) ∧ (¬Q).
❑ Double-negation elimination:
▪ ¬ (¬P) = P.
Limitations of Propositional logic:
❑ We cannot represent relations like ALL, some, or none
with propositional logic. Example:
All the girls are intelligent.
Some apples are sweet.

❑ Propositional logic has limited expressive power.

❑ In propositional logic, we cannot describe statements


in terms of their properties or logical relationships.
Propositional Logic Rules of
Inference
Inference and its Rules
❑ Inference:
▪ In artificial intelligence, we need intelligent computers which can
create new logic from old logic or by evidence, so generating
the conclusions from evidence and facts is termed as Inference.

❑ Inference rules:
▪ Inference rules are the templates for generating valid arguments.

▪ Inference rules are applied to derive proofs in artificial


intelligence, and the proof is a sequence of the conclusion that
leads to the desired goal.

▪ In inference rules, the implication among all the connectives


plays an important role.
Inference and its Rules
❑ Following are some terminologies related to inference rules:
Implication: It is one of the logical connectives which can be
represented as P → Q. It is a Boolean expression.
Converse: The converse of implication, which means the right-
hand side proposition goes to the left-hand side and vice-
versa. It can be written as Q → P.
Contrapositive: The negation of converse is termed as
contrapositive, and it can be represented as ¬ Q → ¬ P.
Inverse: The negation of implication is called inverse. It can be
represented as ¬ P → ¬ Q.
P → Q is equivalent to ¬ Q → ¬ P and vice
versa

❑ From the above truth table, we can prove that P → Q is


equivalent to ¬ Q → ¬ P, and Q→ P is equivalent to ¬ P → ¬ Q
Types of Inference rules:
1. Modus Ponens
2. Modus Tollens
3. Hypothetical Syllogism
4. Disjunctive Syllogism
5. Addition
6. Simplification
7. Resolution
Modus Ponens
❑ The Modus Ponens rule is one of the most important rules of
inference, and it states that if P and P → Q is true, then we can
infer that Q will be true.

❑ 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",

❑ To represent the above statements, PL logic is not sufficient, so we


required some more powerful logic, such as first-order logic.
First-Order logic
❑ It is an extension to propositional logic.

❑ FOL is sufficiently expressive to represent the natural


language statements in a concise way.

❑ First-order
logic is also known as Predicate logic or
First-order predicate logic.

❑ First-orderlogic is a powerful language that develops


information about the objects in a more easy way and
can also express the relationship between those objects.
First-Order logic
❑ First-order logic (like natural language) does not only assume
that the world contains facts like propositional logic but also
assumes the following things in the world:
▪ Objects: A, B, people, numbers, colors, wars, theories,
squares, pits, wumpus, …
▪ Relations: It can be unary relation such as: red, round, is
adjacent, or n-any relation such as: the sister of, brother
of, has color, comes between
▪ Function: Father of, best friend, third inning of, end of, ...
Syntax of First-Order logic
❑ The syntax of FOL determines which collection of symbols is a logical
expression in first-order logic.
❑ The basic syntactic elements of first-order logic are symbols.
❑ We write statements in short-hand notation in FOL.
❑ Basic Elements of First-order logic:
Atomic and Compound
sentences

❑ Atomic sentences are the most basic sentences of first-order logic.


❑ These sentences are formed from a predicate symbol followed by a
parenthesis with a sequence of terms.
❑ We can represent atomic sentences as Predicate (term1, term2,
......, term n).
❑ Example:
▪ Ravi and Ajay are brothers: => Brothers(Ravi, Ajay).
▪ Chinky is a cat: => cat (Chinky).
❑ Complex sentences are made by combining atomic
sentences using connectives.

❑ First-order logic statements can be divided into


two parts:
▪ Subject: Subject is the main part of the statement.
▪ Predicate: A predicate can be defined as a relation,
which binds two atoms together in a statement.
❑ Consider the statement: "x is an integer.“.
▪ It consists of two parts, the first part x is the
subject of the statement and second part "is an
integer," is known as a predicate.
Quantifiers in First-order logic
❑ A quantifier is a language element which generates quantification,
and quantification specifies the quantity of specimen in the
universe of discourse.

❑ These are the symbols that permit to determine or identify the


range and scope of the variable in the logical expression.

❑ There are two types of quantifier:


❑ Universal Quantifier, (for all, everyone, everything)
❑ Existential quantifier, (for some, at least one).
Universal Quantifier
❑ Universal quantifier is a symbol of logical
representation, which specifies that the statement
within its range is true for everything or every instance
of a particular thing.
❑ The Universal quantifier is represented by a symbol ∀,
which resembles an inverted A.
❑ If x is a variable, then ∀x is read as:
▪ For all x
▪ For each x
▪ For every x.
Universal Quantifier
❑ Example:
❑ All man drink coffee.
❑ Let a variable x which refers to a man so all x can be represented in
UOD as below:

❑ ∀x man(x) → drink (x, coffee).


❑ It will be read as: There are all x where x is a man who drink coffee.
Existential Quantifier
❑ Existential quantifiers are the type of quantifiers, which
express that the statement within its scope is true for at
least one instance of something.
❑ It is denoted by the logical operator ∃, which resembles as
inverted E. When it is used with a predicate variable then
it is called as an existential quantifier.
❑ If x is a variable, then existential quantifier will be ∃x or
∃(x). And it will be read as:
▪ There exists a 'x.'
▪ For some 'x.'
▪ For at least one 'x.'
Example
❑ Some boys are intelligent.

❑ ∃x: boys(x) ∧ intelligent(x)


❑ It will be read as: There are some x where x is a boy who is
intelligent.
Points to remember
❑ The main connective for universal quantifier ∀ is
implication →.
❑ The main connective for existential quantifier ∃ is
and ∧.
❑ Properties of Quantifiers:
▪ In universal quantifier, ∀x∀y is similar to ∀y∀x.
▪ In Existential quantifier, ∃x∃y is similar to ∃y∃x.
▪ ∃x∀y is not similar to ∀y∃x.
Examples of FOL using quantifier
1. All birds fly.
In this question the predicate is "fly(bird)."
And since there are all birds who fly so it will be represented as
follows.
∀x bird(x) →fly(x).

1. Every man respects his parent.


In this question, the predicate is "respect(x, y)," where x=man, and
y= parent.
Since there is every man so will use ∀, and it will be represented as
follows:
∀x man(x) → respects (x, parent).
Examples of FOL using quantifier
3. Some boys play cricket.
In this question, the predicate is "play(x, y)," where x= boys, and y=
game. Since there are some boys so we will use ∃, and it will be
represented as:
∃x boys(x) → play(x, cricket).

4. All students do not like both Mathematics and Science.


In this question, the predicate is "like(x, y)," where x= student, and y=
subject.
Since there are not all students, so we will use ∀ with negation,
so following representation for this:
¬∀ (x) [ student(x) → like(x, Mathematics) ∧ like(x, Science)].
Inference in First-Order
Logic
Inference in FOL
❑ Inference in First-Order Logic is used to deduce new facts or sentences
from existing sentences.
❑ Before understanding the FOL inference rule, let's understand some
basic terminologies used in FOL
❑ Substitution:
▪ Substitution is a fundamental operation performed on terms and
formulas.
▪ It occurs in all inference systems in first-order logic.
▪ The substitution is complex in the presence of quantifiers in FOL.
▪ If we write F[a/x], so it refers to substitute a constant "a" in place of
variable "x".
Note: First-order logic is capable of expressing facts about some or all
objects in the universe.
Inference in FOL
❑ Equality:
▪ First-Order logic does not only use predicate and terms for making
atomic sentences but also uses another way, which is equality in
FOL.
▪ Sentence: Brother of John is Smith
▪ Brother(John, smith)
▪ Example: Brother (John) = Smith.
❑ As in the above example, the object referred by the Brother
(John) is similar to the object referred by Smith. The equality symbol
can also be used with negation to represent that two terms are not
the same objects.
▪ Example: ¬(x=y) which is equivalent to x ≠y.
FOL inference rules for quantifier
❑ As propositional logic we also have inference rules in
first-order logic, so following are some basic inference
rules in FOL:
▪ Universal Generalization

▪ 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).

❑ It can be represented as:

❑ This rule can be used if we want to show that every element has a
similar property.

❑ 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.
Universal Instantiation
❑ Universal instantiation is also called as universal elimination or
UI is a valid inference rule. It can be applied multiple times to
add new sentences.
❑ As per UI, we can infer any sentence obtained by substituting
a ground term for the variable.
❑ 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.
❑ It can be represented as:
Universal Instantiation
❑ Example 1:
▪ IF "Every person like ice-cream"=> ∀x P(x) so we can infer that
"John likes ice-cream" => P(c)
❑ Example: 2:
▪ Let's take a famous example.
▪ "All kings who are greedy are Evil."
▪ So let our knowledge base contains this detail as in the form of
FOL:
▪ ∀x king(x) ∧ greedy (x) → Evil (x),
▪ So from this information, we can infer any of the following
statements using Universal Instantiation:
▪ King(John) ∧ Greedy (John) → Evil (John),
▪ King(Richard) ∧ Greedy (Richard) → Evil (Richard),
▪ King(Father(John)) ∧ Greedy (Father(John)) → Evil (Father(John)),
Existential Instantiation
❑ Existential instantiation is also called as Existential Elimination, which
is a valid inference rule in first-order logic.
❑ It can be applied only once to replace the existential sentence.
❑ The new KB is not logically equivalent to old KB, but it will be
satisfiable if old KB was satisfiable.
❑ This rule states that one can infer P(c) from the formula given in the
form of ∃x P(x) for a new constant symbol c.
❑ The restriction with this rule is that c used in the rule must be a new
term for which P(c ) is true.
❑ It can be represented as:
Existential introduction
 An existential introduction is also known as an existential
generalization, which is a valid inference rule in first-order logic.
 This rule states that if there is some element c in the universe of
discourse which has a property P, then we can infer that there exists
something in the universe which has the property P.
❑ It can be represented as

❑ Example: Let's say that,


"Priyanka got good marks in English."
"Therefore, someone got good marks in English."
Unification
What is Unification?
❑ Unification is a process of making two different logical atomic
expressions identical by finding a substitution.

❑ Unification depends on the substitution process.

❑ 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).

❑ Example 1: Unify{King(x), King(John)}

❑ Let Ψ1 = King(x), Ψ2 = King(John), Substitution θ = {x/John} is a unifier


for these atoms and applying this substitution, and both expressions will
be identical.
Unification:
❑ Let's say there are two different expressions, P(x, y), and P(a, f(z)).

▪ In this example, we need to make both above statements identical to


each other. For this, we will perform the substitution.

▪ P(x, y) ......... (i)


P(a, f(z)) ......... (ii)

▪ 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:

▪ Predicate symbol must be same, atoms or expression with different


predicate symbol can never be unified.

▪ Number of Arguments in both expressions must be identical.

▪ Unification will fail if there are two similar variables present in the
same expression.
Example 1
❑ UNIFY(knows(Richard, x), knows(Richard, John))

Here, Ψ1 = knows(Richard, x), and Ψ2 = knows(Richard,


John)
S0 => { knows(Richard, x); knows(Richard, John)}
SUBST θ= {x/John}
S1 => { knows(Richard, John); knows(Richard,
John)}, Successfully Unified.
Unifier: {x/John}.
Example 2
❑ UNIFY(prime (11), prime(y))

Here, Ψ1 = {prime(11) , and Ψ2 = prime(y)}


S0 => {prime(11) , prime(y)}
SUBST θ= {Y/11}

S1 => {prime(11) , prime(11)} , Successfully unified.


Unifier: {Y/11}.
Example 3
❑ UNIFY{p(f(a), g(Y)) and p(X, X)}

Sol: S0 => Here, Ψ1 = p(f(a), g(Y)), and Ψ2 = p(X, X)


SUBST θ= {X/f(a)}
S1 => Ψ1 = p(f(a), g(Y)), and Ψ2 = p(f(a), f(a))
SUBST θ= {g(y)/f(a)}, Unification failed.

Unification is not possible for these expressions.


Example 4
❑ UNIFY{p(b, X, f(g(Z))) and p(Z, f(Y), f(Y))}

Here, Ψ1 = p(b, X, f(g(Z))) , and Ψ2 = p(Z, f(Y), f(Y))


S0 => { p(b, X, f(g(Z))); p(Z, f(Y), f(Y))}
SUBST θ={Z/b}

S1 => { p(b, X, f(g(b))); p(b, f(Y), f(Y))}


SUBST θ={X/f(Y)}

S2 => { p(b, f(Y), f(g(b))); p(b, f(Y), f(Y))}


SUBST θ= {Y/g(b)}

S2 => { p(b, f(g(b)), f(g(b)); p(b, f(g(b)), f(g(b))}


Unified Successfully.
And Unifier = { b/Z, f(Y) /X , g(b) /Y}.
Example 5
 UNIFFY {p (X, X), and p (Z, f(Z))}

Here, Ψ1 = {p (X, X), and Ψ2 = p (Z, f(Z))


S0 => {p (X, X), p (Z, f(Z))}
SUBST θ= {Z/X}
S1 => {p (Z, Z), p (Z, f(Z))}
SUBST θ= {Z/f(Z)}, Unification Failed.
Hence, unification is not possible for these expressions.
Example 6
❑ UNIFY Q(a, g(X, a), f(Y)), Q(a, g(f(b), a), X)}

Here, Ψ1 = Q(a, g(x, a), f(y)), and Ψ2 = Q(a, g(f(b), a), x)


S0 => {Q(a, g(x, a), f(y)); Q(a, g(f(b), a), x)}
SUBST θ= {x/f(b)}
S1 => {Q(a, g(f(b), a), f(y)); Q(a, g(f(b), a), f(b))}

SUBST θ= {y/b}
S1 => {Q(a, g(f(b), a), f(b)); Q(a, g(f(b), a),
f(b))}, Successfully Unified.

Unifier: [a/a, x/f(b), y/b].


Resolution
Resolution in FOL
❑ 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 are given, and we


need to prove a conclusion of those statements.

❑ Unification is a key concept in proofs by resolutions. Resolution is a


single inference rule which can efficiently operate on
the conjunctive normal form.

❑ Conjunctive Normal Form: A sentence represented as a


conjunction of clauses is said to be conjunctive normal form or CNF.
The resolution inference rule:

❑ 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:

▪ [Animal (g(x) V Loves (f(x), x)] and [¬ Loves(a, b) V ¬Kills(a,


b)]
▪ Where two complimentary literals are: Loves (f(x), x) and ¬ Loves
(a, b).
▪ These literals can be unified with unifier θ= [a/f(x), and b/x] , and it
will generate a resolvent clause:
▪ [Animal (g(x) V ¬ Kills(f(x), x)].
Steps for Resolution
❑ Conversion of facts into first-order logic.

❑ Convert FOL statements into CNF

❑ Negate the statement which needs to prove (proof by


contradiction)
❑ Draw resolution graph (unification).

**** 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.

▪ Apple and vegetable are food

▪ Anyone anything eats and not killed is food.

▪ Anil eats peanuts and still alive

▪ Harry eats everything that Anil eats.

❑ Prove by resolution that:

▪ John likes peanuts.


Step-1: Conversion of Facts into FOL
❑ In the first step we will convert all the given statements into its first
order logic.
Step-2: Convert FOL statements into CNF
❑ Eliminate all implications (→) and rewrite

❑ Move negation (¬)inwards and rewrite

❑ Rename variables or standardize variables

❑ Eliminate existential instantiation quantifier by elimination.

❑ Drop Universal quantifiers.


Step-2:
❑ Eliminate all implications (→) and rewrite

▪ 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.

▪ In this step, we will eliminate existential quantifier ∃. But in this


example problem since there is no existential quantifier so all the
statements will remain same in this step.
Step-2:
❑ Drop Universal quantifiers.

Note: Statements "food(Apple) Λ food(vegetables)" and "eats (Anil, Peanuts)


Λ alive(Anil)" can be written in two separate statements.
Step-3: Negate the statement to be proved

❑ In this statement, we will apply negation to the conclusion


statements, which will be written as

i.e. ¬likes(John, Peanuts)


Step-4: Draw Resolution graph:
❑ Now in this step, we will solve the problem by resolution tree using
substitution.

❑ 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:

❑ The inference engine is a part of the expert system. Inference


engine commonly proceeds in two modes, which are:
▪ Forward chaining
▪ Backward chaining
Forward Chaining
❑ Forward chaining is also known as a forward deduction or forward
reasoning method when using an inference engine.

❑ Forward chaining is a form of reasoning which start with atomic


sentences in the knowledge base and applies inference rules
(Modus Ponens) in the forward direction to extract more data until a
goal is reached.

❑ The Forward-chaining algorithm starts from known facts, triggers all


rules whose premises are satisfied, and add their conclusion to the
known facts. This process repeats until the problem is solved.
Properties of Forward-Chaining:

▪ It is a down-up approach, as it moves from bottom to top.

▪ It is a process of making a conclusion based on known facts or


data, by starting from the initial state and reaches the goal state.

▪ Forward-chaining approach is also called as data-driven as we


reach to the goal using available data.

▪ Forward -chaining approach is commonly used in the expert


system, such as business, and production rule systems.
Example:

❑ Consider the following sentences:

a) John likes all kinds of food

b) Anything anyone eats and not killed is food.

c) Anil eats peanuts and is still alive.

d) Harry eats everything that Anil eats.

❑ Translate the above sentences into predicate logic & using FC and
BC prove that:

▪ John likes peanuts


Conversion of Facts into FOL
▪ ∀x food(x) → likes(John, x)

▪ ∀x ∀y: eats(x, y) Λ ¬ killed(x) →


food(y)

▪ eats (Anil, Peanuts) Λ alive(Anil)

▪ ∀x: eats(Anil, x) → eats(Harry, x)

▪ ∀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)

eats (Anil, Peanuts) ¬ killed (Anil)

eats (Anil, Peanuts) alive (Anil)


Proof using Backward chaining:

likes(John, Peanuts)

food (Peanuts)

eats (x, y) ¬ killed (x)

eats (x, y) alive (x)

eats (Anil, Peanuts) alive(Anil)


Semantic Network Representation
❑ Alternative of predicate logic for knowledge representation.

❑ We can represent our knowledge in the form of graphical networks.

❑ This network consists of nodes representing objects and arcs which


describe the relationship between those objects.

❑ Semantic networks can categorize the objects in different forms and


can also link those objects.

❑ This representation consist of mainly two types of relations:


▪ IS-A relation (Inheritance)
▪ Kind-of-relation
Semantic Network Representation
❑ Statements:
▪ Jerry is a cat.
▪ Cat is a mammal.
▪ Jerry is owned by Priya.
▪ Jerry is white colored.
▪ All Mammals are animals.
Advantages of Semantic network:
▪ Semantic networks are a natural representation of knowledge.
▪ Semantic networks convey meaning in a transparent manner.
▪ These networks are simple, easily understandable and can be
extended.
Drawbacks in Semantic representation:
▪ Semantic networks take more computational time at runtime as we
need to traverse the complete network tree to answer some
questions.
▪ It might be possible in the worst case scenario that after traversing
the entire tree, we find that the solution does not exist in this
network.
▪ Semantic networks try to model human-like memory to store the
information, but in practice, it is not possible to build such a vast
semantic network.
▪ These types of representations are inadequate as they do not have
any equivalent quantifier, e.g., for all, for some, none, etc.
▪ Semantic networks do not have any standard definition for the link
names.
▪ These networks are not intelligent and depend on the creator of
the system.
Frame Representation
❑ Frame is a record like structure which consists of a collection of
attributes and its values to describe an entity in the world.
❑ Frame consists of a collection of slots and slot values.
❑ These slots may be of any type and sizes.
❑ Slots have names and values which are called facets.
❑ Frames are derived from semantic networks and later evolved into
our modern-day classes and objects.
❑ A single frame is not much useful. Frames system consist of a
collection of frames which are connected.
❑ In the frame, knowledge about an object or event can be stored in
the knowledge base.
❑ Applications: Natural language processing and machine vision
Frame Representation
❑ Example 1: frame representation for a book.

❑ Example 2: Suppose we are taking an entity, Peter. Peter is an Doctor as a


profession, and his age is 25 and not married. His weight is 78. So following is
the frame representation for this:
Frame Representation
❑ Advantages of frame representation:
▪ The frame knowledge representation makes the programming
easier by grouping the related data.
▪ The frame representation is comparably flexible and used by many
applications in AI.
▪ It is very easy to add slots for new attribute and relations.
▪ It is easy to include default data and to search for missing values.
▪ Frame representation is easy to understand and visualize.
❑ Disadvantages of frame representation:
▪ In frame system inference mechanism is not be easily processed.
▪ Inference mechanism cannot be smoothly proceeded by frame
representation.
▪ Frame representation has a much generalized approach.
Production Rules
❑ Production rules system consist of (condition, action) pairs which
mean "If condition then action". It has mainly three parts:
❖ The set of production rules
▪ Working Memory
▪ The recognize-act-cycle
❑ In production rules agent checks for the condition and if the
condition exists then production rule fires and corresponding action is
carried out.
❑ The condition part of the rule determines which rule may be applied
to a problem. And the action part carries out the associated
problem-solving steps. This complete process is called a recognize-
act cycle.
❑ The working memory contains the description of the current state of
problems-solving.
Production Rules
❑ Example:
▪ IF (at bus stop AND bus arrives) THEN action (get into the bus)

▪ IF (on the bus AND paid AND empty seat) THEN action (sit down).

▪ IF (on bus AND unpaid) THEN action (pay charges).

▪ 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.

You might also like