Professional Documents
Culture Documents
________________________________________________________________________________
___________________________________________________________________________
------------------------------------------
University Assignent-1 Session: Jan – April 2021
1(a). Assume in the database we have information that Bob is a diploma leaver,
his CGPA for semester 1 is 3.0, and he never made any education loans
before. Based on the rules shown in the figure above, use backward
chaining to determine whether Bob can get a loan or not. Clearly show your
steps. (10 Marks)
Fig. 1
2. Given the initial facts and set of rules as shown on the left:
1. Describe the forward chaining inference process based on cycles.
2. Describe the backward chaining inference process based on passes,
if the goal is K. If there is a conflict, always choose the rule with
smallest number.
(20 Marks)
Question 1:
Facts:
B = Foundation leaver
E = Application considered
H = Diploma leaver
Knowledge Base:
R1: A → C
R2: C AND D → E
R3: B OR H → D
R4: E AND F → G
1
Question 1(a):
Backward chaining to determine whether Bob can get loan or not.
Step-1: Search for the goal (G) in database or in the knowledge base for rule that concludes G.
H A F
A→C
C AND D → E
B OR H → D
Step-2: Search for E and F in database or in the knowledge base for rule that concludes E and F to
ultimately conclude G.
H A F
A→C
B OR H → D
E AND F → G
2
Step-3: Search for C and D in the database or rule that concludes C and D. Here, C is implied by A
and D is implied by the given H.
H A F
C AND D → E
E AND F → G
Step-4: Execute the rules identified from step-3 to step-1 in order to insert the required sub-goals
for the ultimate goal G.
H A F H A F
D C D C E
A→C A→C
C AND D → E C AND D → E
B OR H → D B OR H → D
E AND F → G E AND F → G
3
from step-1: For final goal G
H A F
D C E G
A→C
C AND D → E
B OR H → D
E AND F → G
Question 1(b):
Forward Chaining: Steps to determine whether Alice can get loan or not.
Step-1: The very first fact (B) is inferred first to acquire D from R3.
Database
B A F
Knowledge base
A→C
C AND D → E
B OR H → D
E AND F → G
4
Step-2: Fact A is inferred after B to insert C in the database from R1.
B A F
D C
A→C
C AND D → E
B OR H → D
E AND F → G
Step-3: C and D acquired from second and first steps respectively is inferred from R2 to obtain E.
B A F
D C E
A→C
C AND D → E
B OR H → D
E AND F → G
5
Step-4: Finally, in presence of facts F and E, the final goal G can be inferred from R4.
B A F
D C E G
A→C
C AND D → E
B OR H → D
E AND F → G
6
Question 2.
Facts:
A
C
Knowledge Base:
R1: F & H → K
R2: E & A → F
R3: E & B → H
R4: A & G → B
R5: B & D → H
R6: G & D → E
R7: A & B → D
R8: A & C → G
7
Question 2(a): Forward chaining inference process based on cycles.
A C G
F&H→K
E & A→ F
E&B→H
A&G→B
B&D→H
G&D→E
A& B→D
A&C→G
Cycle-2: From R4, B is inserted into the database from A and G obtained from first cycle.
A C G B
F&H→K
E& A→F
E&B→H
A&G→B
B&D→H
G&D→E
A&B→D
8
A& C→G
Cycle-3: Fact B inferred in cycle-2 is used with given fact A to infer D from R7.
A C G B D
F&H→K
E& A→F
E&B→H
A&G→B
B&D→H
G&D→E
A& B→D
A&C→G
Cycle-4: Fact D from third cycle with G is used to infer E using R6.
A C G B D E
F&H→K
E& A→F
E&B→H
A& G→B
B&D→H
G&D→E
A& B→D
A& C→G
9
Cycle-5: D is now used with B to infer the fact H from R5.
A C G B D E H
F&H→K
E& A→F
E&B→H
A&G→B
B&D→H
G&D→E
A& B→D
A&C→G
Cycle-6: E from fourth cycle with given fact A is used to insert fact F in the database.
A C G B D E H F
F&H→K
E & A→ F
E&B→H
A&G→B
B&D→H
G&D→E
A&B→D
A&C→G
10
Cycle-7: Finally, the end goal K is obtained by inferring the last remaining rule R1.
A C G B D E F H K
F&H→K
E& A→F
E&B→H
A&G→B
B&D→H
G&D→E
A&B→D
A&C→G
Question 2 (b): Backward chaining inference process based on passes, if the goal is K.
Pass-1 (Main-goal K): The main goal K is found to be inferred by two facts: A and C absent in the
database. Hence, F and H are the sub-goals for the ultimate goal K.
A C
F&H→K
E& A→F
E&B→H
A& G→B
B&D→H
G&D→E
A&B→D
A& C→G
11
Pass-2 (Sub-goal F): Inference engine examines the goal F and identifies E as its sub-goal from R2
because A is already present in the database.
A C
F&H→K
E & A→ F
E&B→H
A&G→B
B&D→H
G&D→E
A& B→D
A&C→G
Pass-3 (Sub-goal H): Inference engine examines the goal H and identifies E and B as its sub-goals
from R3.
A C
F&H→K
E & A→ F
E&B→H
A&G→B
B&D→H
G&D→E
A& B→D
A&C→G 12
Pass-4 (Sub-goal E): The goal E is examined by the inference engine which locates its rule in R6.
Here, it identifies facts G and D as its sub-goal to infer E.
A C
F&H→K
E & A→ F
E&B→H
A&G→B
B&D→H
G&D→E
A& B→D
A&C→G
Pass-5 (Sub-goal B): The goal B is examined by the inference engine which locates its rule in R4.
Here, it identifies fact G as its sub-goal to infer B.
A C
F&H→K
E & A→ F
E&B→H
A&G→B
B&D→H
G&D→E
A& B→D
A& C→G
13
Pass-6 (Sub-goal D): Goal D is identified to be inferred by R7 with rules A and B. Here, B is
recognized as the sub-goal for D.
A C
F&H→K
E & A→ F
E&B→H
A&G→B
B&D→H
G&D→E
A& B→D
A&C→G
Pass-7 (Sub-goal B): Sub-goal B for goal D is identified to be inferred form R4, hence the
inference engine identifies G as its sub-goal for goal B.
A C
F&H→K
E & A→ F
E&B→H
A&G→B
B&D→H
G&D→E
A& B→D
A&C→G
14
Pass-8 (Sub-goal G): Sub-goal G can be inserted into the database by inferring the facts A and C
from R8. Now, in the following passes previous sub-goals can be inferred to reach the ultimate goal
K.
A C G
F&H→K
E & A→ F
E&B→H
A&G→B
B&D→H
G&D→E
A& B→D
A&C→G
Pass-9 (Sub-goal B): Sub-goal B from pass-7 is inferred from facts A and G in the database.
A C G B
F&H→K
E & A→ F
E&B→H
A&G→B
B&D→H
G&D→E
A&B→D
A&C→G
15
Pass-10 (Sub-goal D): Sub-goal B from pass-7 is inferred from facts A and G in the database.
A C G B D
F&H→K
E& A→F
E&B→H
A&G→B
B&D→H
G&D→E
A& B→D
A&C→G
Pass-11 (Sub-goal E): Sub-goal E is inferred by the inference engine from facts G and D using R6.
A C G B D E
F&H→K
E& A→F
E&B→H
A& G→B
B&D→H
G&D→E
A& B→D
A& C→G
16
Pass-12 (Sub-goal H): Sub-goal H is inferred by the inference engine from facts E and B using R3.
A C G B D E H
F&H→K
E& A→F
E&B→H
A&G→B
B&D→H
G&D→E
A& B→D
A&C→G
Pass-13 (Sub-goal F): The final sub-goal F is inferred by the inference engine from facts E and A
using R2.
A C G B D E H F
F&H→K
E & A→ F
E&B→H
A&G→B
B&D→H
G&D→E
A&B→D
17
A&C→G
Pass-13 (Goal K): Finally, using facts F and H from pass-12 and 11 respectively, main goal G is
inferred by the inference engine from R1.
A C G B D E F H K
F&H→K
E& A→F
E&B→H
A&G→B
B&D→H
G&D→E
A&B→D
A&C→G
18