0% found this document useful (0 votes)
37 views70 pages

Sri Krishna Arts and Science Computer Technology: Course Coordinator Dr. V. S. Anita Sofia Prof. & Head

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 70

Sri Krishna Arts and Science

Computer Technology

19CTP14- Artificial Intelligence

Class: II M.Sc IT/CT

Classroom Code: 63srbvk

Course Coordinator
Dr. V. S. Anita Sofia
Prof. & Head
SKASC 1
Agenda
• Knowledge Engineering in First-order logic

• Inference in First-Order Logic

• Unification

• Resolution in FOL

• Forward Chaining and backward chaining


Knowledge Engineering in First-order logic

• The process of constructing a knowledge-base in first-order logic is


called as knowledge- engineering.

• In knowledge-engineering, someone who investigates a particular


domain, learns important concept of that domain, and generates a
formal representation of the objects, is known as knowledge engineer.

• This approach is mainly suitable for creating special-purpose


knowledge base.
The knowledge-engineering process
Identify the task
• The first step of the process is to identify the task, and for the digital circuit, there are
various reasoning tasks.

• At the first level or highest level, we will examine the functionality of the circuit:

• Does the circuit add properly?

• What will be the output of gate A2, if all the inputs are high?

• At the second level, we will examine the circuit structure details such as:

• Which gate is connected to the first input terminal?

• Does the circuit have feedback loops?


Assemble the relevant knowledge
• In the second step, will assemble the relevant knowledge which is required
for digital circuits. So for digital circuits, the following required knowledge:
• Logic circuits are made up of wires and gates.
• Signal flows through wires to the input terminal of the gate, and each
gate produces the corresponding output which flows further.
• In this logic circuit, there are four types of gates used: AND, OR, XOR,
and NOT.
• All these gates have one output terminal and two input terminals (except
NOT gate, it has one input terminal).
Decide on vocabulary
• The next step of the process is to select functions, predicate, and constants to
represent the circuits, terminals, signals, and gates.

• Firstly distinguish the gates from each other and from other objects.

• Each gate is represented as an object which is named by a constant, such


as, Gate(X1).

• The functionality of each gate is determined by its type, which is taken as


constants such as AND, OR, XOR, or NOT.

• Circuits will be identified by a predicate: Circuit (C1).


Decide on vocabulary
• For the terminal, we will use predicate: Terminal(x).

• For gate input, we will use the function In(1, X1) for denoting the first input
terminal of the gate, and for output terminal we will use Out (1, X1).

• The function Arity(c, i, j) is used to denote that circuit c has i input, j output.

• The connectivity between gates can be represented by


predicate Connect(Out(1, X1), In(1, X1)).

• We use a unary predicate On (t), which is true if the signal at a terminal is


on.
Encode general knowledge about the domain

• To encode the general knowledge about the


logic circuit, following rules are needed:

• If two terminals are connected then they have


the same input signal, it can be represented as:
∀  t1, t2 Terminal (t1) ∧ Terminal (t2) ∧ Connect (t1, t2) → Signal (t1) = Signal (t2).  
 
Encode general knowledge about the domain

• Signal at every terminal will have either value 0


or 1, it will be represented as:
∀  t Terminal (t) →Signal (t) = 1 ∨Signal (t) = 0.  

• Connect predicates are commutative:


∀  t1, t2 Connect(t1, t2)  →  Connect (t2, t1).       
Encode general knowledge about the domain

• Representation of types of gates:


∀  g Gate(g) ∧ r = Type(g) → r = OR ∨r = AND ∨r = XOR ∨r = NOT.   

• Output of AND gate will be zero if and only if


any of its input is zero.
∀  g Gate(g) ∧ Type(g) = AND →Signal (Out(1, g))= 0 ⇔  ∃n Signal (In(n, g))= 0.   
Encode general knowledge about the domain

• Output of OR gate is 1 if and only if any of its


input is 1:
∀  g Gate(g) ∧ Type(g) = OR → Signal (Out(1, g))= 1 ⇔  ∃n Signal (In(n, g))= 1  
 

• Output of XOR gate is 1 if and only if its inputs


are different:
∀  g Gate(g) ∧ Type(g) = XOR → Signal (Out(1, g)) = 1 ⇔  Signal (In(1, g)) ≠ Signal (In(2, g)).  
Encode general knowledge about the domain

• Output of NOT gate is invert of its input:


∀  g Gate(g) ∧ Type(g) = NOT →   Signal (In(1, g)) ≠ Signal (Out(1, g)).  

• All the gates in the above circuit have two


inputs and one output (except NOT gate).
∀  g Gate(g) ∧ Type(g) = NOT →   Arity(g, 1, 1)   
∀  g Gate(g) ∧ r =Type(g)  ∧ (r= AND ∨r= OR ∨r= XOR) →  Arity (g, 2, 1).
  
Encode general knowledge about the domain

• All gates are logic circuits

∀  g Gate(g) → Circuit (g).   
Encode a description of the problem instance

• Now we encode problem of circuit C1, firstly we categorize the circuit


and its gate components.

• This step is easy if ontology about the problem is already thought.

• This step involves the writing simple atomics sentences of instances of


concepts, which is known as ontology.

• For the given circuit C1, we can encode the problem instance in atomic
sentences
Encode a description of the problem instance

• The circuit there are two XOR, two AND, and


one OR gate so atomic sentences for these
gates will be:
For XOR gate: Type(x1)= XOR, Type(X2) = XOR  
For AND gate: Type(A1) = AND, Type(A2)= AND  
For OR gate: Type (O1) = OR.   
Pose queries to the inference procedure and get
answers

• In this step, we will find all the possible set of values of all
the terminal for the adder circuit.

• The first query will be:

• What should be the combination of input which would


generate the first output of circuit C1, as 0 and a second
output to be 1?
∃ i1, i2, i3 Signal (In(1, C1))=i1  ∧  Signal (In(2, C1))=i2  ∧ Signal (In(3, C1))= i3  
 ∧ Signal (Out(1, C1)) =0 ∧ Signal (Out(2, C1))=1  
Debug the knowledge base

• Debug the knowledge base, and this is the last step of the
complete process.

• In this step, we will try to debug the issues of knowledge


base.

• In the knowledge base, we may have omitted assertions like


1 ≠ 0.
Inference in First-Order Logic

• Inference in First-Order Logic is used to deduce


new facts or sentences from existing
sentences.
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".
Basic terminologies used 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.
• Equality symbols which specify that the two terms refer to the same object.
• 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

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

• In this rule, x must not appear as a free variable.

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

• The new KB is logically equivalent to the previous KB.

• 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)
Universal Instantiation
• 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 Instantiation
• Example:

• From the given sentence: ∃x Crown(x) ∧ OnHead(x, John),

• So we can infer: Crown(K) ∧ OnHead( K, John), as long as K does not


appear in the knowledge base.

• The above used K is a constant symbol, which is called Skolem constant.

• The Existential instantiation is a special case of Skolemization process.


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:

• "Priyanka got good marks in English.“


"Therefore, someone got good marks in English."
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).
Unification
• Example: Find the MGU for Unify{King(x), King(John)}

• Let Ψ1 = King(x), Ψ2 = King(John),

• Substitution θ = {John/x} is a unifier for these atoms and applying this substitution, and
both expressions will be identical.

• The UNIFY algorithm is used for unification, which takes two atomic sentences and returns
a unifier for those sentences (If any exist).

• Unification is a key component of all first-order inference algorithms.

• It returns fail if the expressions do not match with each other.

• The substitution variables are called Most General Unifier or MGU.

• E.g. Let's say there are two different expressions, P(x, y), and P(a, f(z)).
Unification
• 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.
Unification Algorithm
Step. 1: If Ψ1 or Ψ2 is a variable or constant, then:

a) If Ψ1 or Ψ2 are identical, then return NIL.

b) Else if Ψ1is a variable,

a. then if Ψ1 occurs in Ψ2, then return FAILURE

b. Else return { (Ψ2/ Ψ1)}.

c) Else if Ψ2 is a variable,

a. If Ψ2 occurs in Ψ1 then return FAILURE,

b. Else return {( Ψ1/ Ψ2)}.

d) Else return FAILURE.


Unification Algorithm
Step.2: If the initial Predicate symbol in Ψ1 and Ψ2 are not same, then return FAILURE.

Step. 3: IF Ψ1 and Ψ2 have a different number of arguments, then return FAILURE.

Step. 4: Set Substitution set(SUBST) to NIL.

Step. 5: For i=1 to the number of elements in Ψ1.

a) Call Unify function with the ith element of Ψ1 and ith element of Ψ2, and put the result into S.

b) If S = failure then returns Failure

c) If S ≠ NIL then do,

a. Apply S to the remainder of both L1 and L2.

b. SUBST= APPEND(S, SUBST).

Step.6: Return SUBST.


Implementation of the Algorithm
• Step.1: Initialize the substitution set to be empty.

• Step.2: Recursively unify atomic sentences:

• Check for Identical expression match.

• If one expression is a variable vi, and the other is a term ti which does not contain
variable vi, then:

• Substitute ti / vi in the existing substitutions

• Add ti /vi to the substitution setlist.

• If both the expressions are functions, then function name must be similar, and
the number of arguments must be the same in both the expression.
Implementation of the Algorithm
• For each pair of the following atomic sentences find the most general unifier
(If exist).

• 1. Find the MGU of {p(f(a), g(Y)) and p(X, X)}

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


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

• Unification is not possible for these expressions.


Implementation of the Algorithm
• 2. Find the MGU of {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 θ={b/Z}

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


SUBST θ={f(Y) /X}

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


SUBST θ= {g(b) /Y}

• 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}.


Implementation of the Algorithm
• 3. Find the MGU of {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 θ= {X/Z}
              S1 => {p (Z, Z), p (Z, f(Z))}
SUBST θ= {f(Z) / Z}, Unification Failed.

• Hence, unification is not possible for these expressions.


Implementation of the Algorithm
• 4. Find the MGU of UNIFY(prime (11), prime(y))

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


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

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


              Unifier: {11/y}.
Implementation of the Algorithm
• 5. Find the MGU of 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 θ= {f(b)/x}
S1 => {Q(a, g(f(b), a), f(y)); Q(a, g(f(b), a), f(b))}

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

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


Implementation of the Algorithm
• 6. 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 θ= {John/x}
S1 => { knows(Richard, John); knows(Richard,
John)}, Successfully Unified.
Unifier: {John/x}.
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
or clausal form.

• Clause: Disjunction of literals (an atomic sentence) is called a clause.

• It is also known as a unit clause.


The resolution inference rule

• The resolution rule for first-order logic is simply a


lifted version of the propositional rule.

• Resolution can resolve two clauses if they contain


complementary literals, which are assumed to be
standardized apart so that they share no variables.
The resolution inference rule

Where li and mj are complementary literals.


This rule is also called the binary resolution rule because it only resolves exactly
two literals.
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:
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).


Steps for Resolution
• Example:

• John likes all kind of food.

• Apple and vegetable are food

• Anything anyone 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.
Steps for Resolution

• Step-1: Conversion of
Facts into FOL

• In the first step we will


convert all the given
statements into its first order
logic.
Steps for Resolution
• Step-2: Conversion of FOL into CNF • ∀x ¬ food(x) V likes(John, x)

• In First order logic resolution, it is • food(Apple) Λ food(vegetables)

required to convert the FOL into CNF • ∀x ∀y ¬ [eats(x, y) Λ ¬ killed(x)] V food(y)

as CNF form makes easier for • eats (Anil, Peanuts) Λ alive(Anil)

resolution proofs. • ∀x ¬ eats(Anil, x) V eats(Harry, x)

• Eliminate all implication (→) and • ∀x¬ [¬ killed(x) ] V alive(x)

rewrite • ∀x ¬ alive(x) V ¬ killed(x)

• likes(John, Peanuts).
Steps for Resolution
• Move negation (¬)inwards and rewrite • Rename variables or standardize variables

• ∀x ¬ food(x) V likes(John, x) • ∀x ¬ food(x) V likes(John, x)

• food(Apple) Λ food(vegetables) • food(Apple) Λ food(vegetables)

• ∀x ∀y ¬ eats(x, y) V killed(x) V food(y) • ∀y ∀z ¬ eats(y, z) V killed(y) V food(z)

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

• ∀x ¬ eats(Anil, x) V eats(Harry, x) • ∀w¬ eats(Anil, w) V eats(Harry, w)

• ∀x ¬killed(x) ] V alive(x) • ∀g ¬killed(g) ] V alive(g)

• ∀x ¬ alive(x) V ¬ killed(x) • ∀k ¬ alive(k) V ¬ killed(k)

• likes(John, Peanuts). • likes(John, Peanuts).


Steps for Resolution

• Eliminate existential instantiation quantifier by


elimination.
In this step, we will eliminate existential quantifier ∃, and this
process is known as Skolemization.

• But in this example problem since there is no existential


quantifier so all the statements will remain same in this step.
Steps for Resolution
• Drop Universal quantifiers.
In this step we will drop all universal quantifier since all the statements are not implicitly quantified so we don't
need it.

• ¬ food(x) V likes(John, x)

• food(Apple)

• food(vegetables)

• ¬ eats(y, z) V killed(y) V food(z)

• eats (Anil, Peanuts)

• alive(Anil)

• ¬ eats(Anil, w) V eats(Harry, w)

• killed(g) V alive(g)

• ¬ alive(k) V ¬ killed(k)

• likes(John, Peanuts).
Steps for Resolution
• Distribute conjunction ∧ over disjunction ¬.
This step will not make any change in this problem.

• Step-3: Negate the statement to be proved

• In this statement, we will apply negation to the


conclusion statements, which will be written as
¬likes(John, Peanuts)
Steps for 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 Chaining and backward chaining

• Inference engine:

• The inference engine is the component of the intelligent system in artificial


intelligence, which applies logical rules to the knowledge base to infer new
information from known facts.

• The first inference engine was part of the expert system. Inference engine
commonly proceeds in two modes, which are:
• Forward chaining
• Backward chaining
Forward Chaining and backward chaining

• Horn clause and definite clause are the forms of sentences,


which enables knowledge base to use a more restricted and
efficient inference algorithm.

• Logical inference algorithms use forward and backward


chaining approaches, which require KB in the form of
the first-order definite clause.
Forward Chaining and backward chaining

• Definite clause: A clause which is a disjunction of literals with exactly


one positive literal is known as a definite clause or strict horn clause.

• Horn clause: A clause which is a disjunction of literals with at most one


positive literal is known as horn clause. Hence all the definite clauses
are horn clauses.

• Example: (¬ p V ¬ q V k). It has only one positive literal k.

• It is equivalent to p ∧ q → k.
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 CLIPS, business, and production rule systems.
Forward Chaining
• Example:

• "As per the law, it is a crime for an American to sell weapons to hostile
nations. Country A, an enemy of America, has some missiles, and all
the missiles were sold to it by Robert, who is an American citizen."

• Prove that "Robert is criminal."

• To solve the above problem, first, we will convert all the above facts into
first-order definite clauses, and then we will use a forward-chaining
algorithm to reach the goal.
Facts Conversion into FOL
• It is a crime for an American to sell weapons to hostile nations. (Let's say p, q, and r are
variables)
American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p)       ...(1)

• Country A has some missiles. ?p Owns(A, p) ∧ Missile(p). It can be written in two definite
clauses by using Existential Instantiation, introducing new Constant T1.
Owns(A, T1)             ......(2)
Missile(T1)             .......(3)

• All of the missiles were sold to country A by Robert.


?p Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A)       ......(4)
Facts Conversion into FOL
• Missiles are weapons.
Missile(p) → Weapons (p)             .......(5)

• Enemy of America is known as hostile.


Enemy(p, America) →Hostile(p)             ........(6)

• Country A is an enemy of America.


Enemy (A, America)             .........(7)

• Robert is American
American(Robert).             ..........(8)
Backward Chaining

• Backward-chaining is also known as a backward deduction


or backward reasoning method when using an inference
engine.

• A backward chaining algorithm is a form of reasoning, which


starts with the goal and works backward, chaining through
rules to find known facts that support the goal.
Properties of backward chaining
• It is known as a top-down approach.

• Backward-chaining is based on modus ponens inference rule.

• In backward chaining, the goal is broken into sub-goal or sub-goals to prove the facts
true.

• It is called a goal-driven approach, as a list of goals decides which rules are selected
and used.

• Backward -chaining algorithm is used in game theory, automated theorem proving


tools, inference engines, proof assistants, and various AI applications.

• The backward-chaining method mostly used a depth-first search strategy for proof.


Backward Chaining
• Example:

• In backward-chaining, we will use the same above example, and will rewrite all the rules.

• American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p) ...(1)


Owns(A, T1)                 ........(2)

• Missile(T1)

• ?p Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A)           ......(4)

• Missile(p) → Weapons (p)                 .......(5)

• Enemy(p, America) →Hostile(p)                 ........(6)

• Enemy (A, America)                 .........(7)

• American(Robert).                 ..........(8)
Difference between backward chaining and forward chaining
S. No Forward Chaining Backward Chaining
1 Forward chaining starts from known facts and Backward chaining starts from the goal and works
applies inference rule to extract more data unit it backward through inference rules to find the required
reaches to the goal. facts that support the goal.
2 It is a bottom-up approach It is a top-down approach
3 Forward chaining is known as data-driven Backward chaining is known as goal-driven technique as
inference technique as we reach to the goal using we start from the goal and divide into sub-goal to extract
the available data. the facts.
4 Forward chaining reasoning applies a breadth-first Backward chaining reasoning applies a depth-first search
search strategy. strategy.
5 Forward chaining tests for all the available rules Backward chaining only tests for few required rules.
6 Forward chaining is suitable for the planning, Backward chaining is suitable for diagnostic, prescription,
monitoring, control, and interpretation application. and debugging application.
7 Forward chaining can generate an infinite number Backward chaining generates a finite number of possible
of possible conclusions. conclusions.
8 It operates in the forward direction. It operates in the backward direction.
9 Forward chaining is aimed for any conclusion. Backward chaining is only aimed for the required data.
Example: The Kinship Domain
• An example KB includes things like:

• Fact:

• “Elizabeth is the mother of Charles”

• “Charles is the father of William”

• Rules:

• One’s grandmother is the mother of one’s parent”

• Object: people

• Unary predicate: Male, Female

• Binary predicate: Son, Spouse, Wife, Husband, Grandparent, Grandchild, Cousin,


Aunt, and Uncle
• Function: Mother, Father
Example: The Kinship Domain
• One s mom is one s female parent

• Ɐm,c Mother( c)= m Female (m) ^ Parent(m,c)

• One s husband is one s male spouse

• Ɐw,h Husband(h,w) Male(h) ^ Spouse(h,w)

• Parent and child are inverse relations

• Ɐp,c Parent(p,c) Child(c,p)

• A grandparent is a parent of one’s parent

• Ɐg,c Grandparent(g,c) Ǝp Parent(g,p) ^ Parent(p,c)

You might also like