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

Problem Questions

The document provides examples of Forward and Backward Chaining, illustrating how to prove conclusions based on given facts and rules. It also discusses resolution problems, demonstrating how to derive contradictions from a set of facts to prove a goal. Additionally, it explains the process of finding the Most General Unifier (MGU) for terms in logic.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Problem Questions

The document provides examples of Forward and Backward Chaining, illustrating how to prove conclusions based on given facts and rules. It also discusses resolution problems, demonstrating how to derive contradictions from a set of facts to prove a goal. Additionally, it explains the process of finding the Most General Unifier (MGU) for terms in logic.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Forward and Backword Chaining problems:

Example 1:
Given Facts (Knowledge Base):
1. John owns a dog (John → owns(dog)).
2. Buddy is a dog (Buddy → dog).
3. Rule: If a person owns a dog, they love animals (If owns(person, dog),
then loves(person, animals)).
Goal:
Prove that John loves animals.

Forward Chaining (Data-driven approach):


1. Start with known facts:
o John owns a dog (John → owns(dog)).

o The rule tells us that if someone owns a dog, they love animals.

2. Apply the rule:


o Since John owns a dog, we can apply the rule: "If a person owns a
dog, they love animals."
3. Conclusion:
o Therefore, John loves animals.

Backward Chaining (Goal-driven approach):


1. Start with the goal:
o The goal is to prove that John loves animals.

2. Check the rule:


o Look at the rule: "If a person owns a dog, they love animals." To
prove that John loves animals, we need to verify if John owns a dog.
3. Check the fact:
o The fact tells us that John owns a dog.

4. Conclusion:
o Since John owns a dog, the rule applies, and we can conclude that
John loves animals.
Example 2:
Given Facts (Knowledge Base):
1. Alice owns a cat.
2. Fluffy is a cat.
3. Rule: If a person owns a cat, they care for cats.
4. Goal: Prove Alice cares for cats.
Forward Chaining (Data-driven approach):
1. Start with known facts:
o Alice owns a cat (Alice → owns(cat)).

o The rule tells us that if someone owns a cat, they care for cats.

2. Apply the rule:


o Since Alice owns a cat, apply the rule: "If a person owns a cat, they
care for cats."
3. Conclusion:
o Therefore, Alice cares for cats.

Backward Chaining (Goal-driven approach):


1. Start with the goal:
o The goal is to prove that Alice cares for cats.

2. Check the rule:


o Look at the rule: "If a person owns a cat, they care for cats." To
prove that Alice cares for cats, we need to verify if Alice owns a cat.
3. Check the fact:
o The fact tells us that Alice owns a cat.

4. Conclusion:
o Since Alice owns a cat, the rule applies, and we conclude that Alice
cares for cats.
Example 3:
Given Facts (Knowledge Base):
1. Tom owns a hamster.
2. Hammy is a hamster.
3. Rule: If a person owns a hamster, they clean the cage.
4. Goal: Prove Tom cleans the cage.
Forward Chaining (Data-driven approach):
1. Start with known facts:
o Tom owns a hamster (Tom → owns(hamster)).

o The rule tells us that if someone owns a hamster, they clean the
cage.
2. Apply the rule:
o Since Tom owns a hamster, apply the rule: "If a person owns a
hamster, they clean the cage."
3. Conclusion:
o Therefore, Tom cleans the cage.

Backward Chaining (Goal-driven approach):


1. Start with the goal:
o The goal is to prove that Tom cleans the cage.

2. Check the rule:


o Look at the rule: "If a person owns a hamster, they clean the cage."
To prove that Tom cleans the cage, we need to verify if Tom owns a
hamster.
3. Check the fact:
o The fact tells us that Tom owns a hamster.

4. Conclusion:
o Since Tom owns a hamster, the rule applies, and we conclude that
Tom cleans the cage.

Resolution Problems :
Example 1:
Given Facts (Knowledge Base):
1. All birds can fly.
2. Penguins are birds.
3. Some birds are penguins.
4. Tweety is a bird.
Goal: Prove that some birds cannot fly.
Step-by-step Process using Resolution:
1. Convert the facts into CNF:

∀x(Bird(x)→CanFly(x))\forall x (Bird(x) \rightarrow


o Fact 1 (All birds can fly):

CanFly(x))∀x(Bird(x)→CanFly(x))
In CNF:
¬Bird(x)∨CanFly(x)\neg Bird(x) \lor CanFly(x)¬Bird(x)∨CanFly(x)

∀x(Penguin(x)→Bird(x))\forall x (Penguin(x) \rightarrow


o Fact 2 (Penguins are birds):

Bird(x))∀x(Penguin(x)→Bird(x))
In CNF:
¬Penguin(x)∨Bird(x)\neg Penguin(x) \lor Bird(x)¬Penguin(x)∨Bird(x)

∃x(Penguin(x))\exists x (Penguin(x))∃x(Penguin(x))
o Fact 3 (Some birds are penguins):

In CNF:
Penguin(a)Penguin(a)Penguin(a) (where a is a constant denoting a
penguin)
o Fact 4 (Tweety is a bird):
Bird(Tweety)Bird(Tweety)Bird(Tweety)
2. Negate the goal:
The goal is to prove that some birds cannot fly.

∀x(Bird(x)→CanFly(x))\forall x (Bird(x) \rightarrow


We negate it:

CanFly(x))∀x(Bird(x)→CanFly(x))
This is equivalent to:
¬Bird(x)∨CanFly(x)\neg Bird(x) \lor CanFly(x)¬Bird(x)∨CanFly(x) (which is
already in CNF form).
Now, we need to prove this negation leads to a contradiction.
3. Resolution:
Now we combine the clauses:

o From Fact 2: ¬Penguin(x)∨Bird(x)\neg Penguin(x) \lor


Bird(x)¬Penguin(x)∨Bird(x)

o From Fact 1: ¬Bird(x)∨CanFly(x)\neg Bird(x) \lor


CanFly(x)¬Bird(x)∨CanFly(x)
o From Fact 3: Penguin(a)Penguin(a)Penguin(a)

o From Fact 4: Bird(Tweety)Bird(Tweety)Bird(Tweety)

We resolve the clauses step by step:


o From Fact 3 and Fact 2, we resolve on
Penguin(a)Penguin(a)Penguin(a) to get:
Bird(a)Bird(a)Bird(a)
o Using Bird(a) in Fact 1, we resolve to get:
CanFly(a)CanFly(a)CanFly(a)
But this is a contradiction to our goal. Since we have derived CanFly(a), and a is
a penguin, this shows that some birds (like penguins) cannot fly, which proves
the goal.
Example 2:
Given Facts (Knowledge Base):
1. All dogs bark.
2. All animals that bark are mammals.
3. Fido is a dog.
4. Some animals are not mammals.
Goal: Prove that Fido is not a mammal.
Step-by-step Process using Resolution:
1. Convert the facts into CNF:

∀x(Dog(x)→Barks(x))\forall x (Dog(x) \rightarrow


o Fact 1 (All dogs bark):

Barks(x))∀x(Dog(x)→Barks(x))
In CNF:
¬Dog(x)∨Barks(x)\neg Dog(x) \lor Barks(x)¬Dog(x)∨Barks(x)

∀x(Barks(x)→Mammal(x))\forall x (Barks(x) \rightarrow


o Fact 2 (All animals that bark are mammals):

Mammal(x))∀x(Barks(x)→Mammal(x))
In CNF:
¬Barks(x)∨Mammal(x)\neg Barks(x) \lor
Mammal(x)¬Barks(x)∨Mammal(x)
o Fact 3 (Fido is a dog):
Dog(Fido)Dog(Fido)Dog(Fido)

∃x(¬Mammal(x))\exists x (\neg Mammal(x))∃x(¬Mammal(x))


o Fact 4 (Some animals are not mammals):

In CNF:
¬Mammal(a)\neg Mammal(a)¬Mammal(a) (where a is a constant
denoting a non-mammal)
2. Negate the goal:
The goal is to prove that Fido is not a mammal.
We negate it:
Mammal(Fido)Mammal(Fido)Mammal(Fido)
3. Resolution:
Now, we combine the clauses:
o From Fact 3: Dog(Fido)Dog(Fido)Dog(Fido)
o From Fact 1: ¬Dog(x)∨Barks(x)\neg Dog(x) \lor
Barks(x)¬Dog(x)∨Barks(x), which gives
Barks(Fido)Barks(Fido)Barks(Fido)

o From Fact 2: ¬Barks(x)∨Mammal(x)\neg Barks(x) \lor


Mammal(x)¬Barks(x)∨Mammal(x), which gives
Mammal(Fido)Mammal(Fido)Mammal(Fido)
But the negation of the goal says ¬Mammal(Fido)\neg
Mammal(Fido)¬Mammal(Fido), which leads to a contradiction with
Mammal(Fido)Mammal(Fido)Mammal(Fido).
Therefore, Fido is not a mammal, as we set out to prove.

Example 3:
Given Facts (Knowledge Base):
1. No humans are aliens.
2. All humans are mortal.
3. John is a human.
4. Some humans are philosophers.
Goal: Prove that no philosophers are aliens.
Step-by-step Process using Resolution:
1. Convert the facts into CNF:

∀x(Human(x)→¬Alien(x))\forall x (Human(x) \rightarrow \neg


o Fact 1 (No humans are aliens):

Alien(x))∀x(Human(x)→¬Alien(x))
In CNF:
¬Human(x)∨¬Alien(x)\neg Human(x) \lor \neg
Alien(x)¬Human(x)∨¬Alien(x)

∀x(Human(x)→Mortal(x))\forall x (Human(x) \rightarrow


o Fact 2 (All humans are mortal):

Mortal(x))∀x(Human(x)→Mortal(x))
In CNF:
¬Human(x)∨Mortal(x)\neg Human(x) \lor
Mortal(x)¬Human(x)∨Mortal(x)
o Fact 3 (John is a human):
Human(John)Human(John)Human(John)

∃x(Philosopher(x))\exists x (Philosopher(x))∃x(Philosopher(x))
o Fact 4 (Some humans are philosophers):

In CNF:
Philosopher(a)Philosopher(a)Philosopher(a) (where a is a constant
denoting a philosopher)
2. Negate the goal:
The goal is to prove that no philosophers are aliens.

∃x(Philosopher(x)∧Alien(x))\exists x (Philosopher(x) \land


We negate it:

Alien(x))∃x(Philosopher(x)∧Alien(x))
In CNF:
Philosopher(a)∧Alien(a)Philosopher(a) \land
Alien(a)Philosopher(a)∧Alien(a)
3. Resolution:
Now, we combine the clauses:
o From Fact 4: Philosopher(a)Philosopher(a)Philosopher(a)

o From Fact 1: ¬Human(x)∨¬Alien(x)\neg Human(x) \lor \neg


Alien(x)¬Human(x)∨¬Alien(x), which gives ¬Alien(a)\neg
Alien(a)¬Alien(a)
Resolving these clauses, we find a contradiction. Since Alien(a) cannot be true,
we conclude that no philosophers are aliens, as required.

Finding Most General Unifier (MGU)


Example 1:
Find the MGU of the following terms:
 g(f(X),Y)g(f(X), Y)g(f(X),Y) and g(f(a),b)g(f(a), b)g(f(a),b)
Step-by-step solution:
1. Compare the two terms:
Both are functions g(…)g(\ldots)g(…). Let's compare the arguments:
o First argument: f(X)f(X)f(X) and f(a)f(a)f(a)

o Second argument: YYY and bbb

2. Unify the arguments one by one:


o First argument:
f(X)f(X)f(X) and f(a)f(a)f(a)
 Both are functions f(…)f(\ldots)f(…), so we compare their
inner arguments:
 We need to unify XXX and aaa, so we substitute XXX with
aaa.

 So, X↦aX \mapsto aX↦a.


o Second argument:
YYY and bbb
 YYY is a variable, and bbb is a constant. To make them equal,
we substitute YYY with bbb.

 So, Y↦bY \mapsto bY↦b.


Final Substitutions:

 X↦aX \mapsto aX↦a

 Y↦bY \mapsto bY↦b


MGU:
The Most General Unifier (MGU) is:

{X↦a,Y↦b}\{ X \mapsto a, Y \mapsto b \}{X↦a,Y↦b}

Example 2:
To find the Most General Unifier (MGU) for the two terms:
 J(b,X,f(g(Z)))J(b, X, f(g(Z)))J(b,X,f(g(Z)))
 J(Z,f(P),f(P))J(Z, f(P), f(P))J(Z,f(P),f(P))
Step-by-step procedure:
1. Compare the two terms:
Both expressions are predicates of the form J(…)J(\ldots)J(…), meaning the
functor JJJ is the same for both. We will compare the arguments of the predicates
position by position:
o Argument 1: bbb and ZZZ

o Argument 2: XXX and f(P)f(P)f(P)

o Argument 3: f(g(Z))f(g(Z))f(g(Z)) and f(P)f(P)f(P)

2. Start unifying the arguments one by one:


o First argument:
bbb and ZZZ
 Here, bbb is a constant, and ZZZ is a variable. To make these
two equal, we substitute ZZZ with bbb.

 So, Z↦bZ \mapsto bZ↦b.


o Second argument:
XXX and f(P)f(P)f(P)
 Here, XXX is a variable and f(P)f(P)f(P) is a function. To make
them equal, we must substitute XXX with f(P)f(P)f(P).

 So, X↦f(P)X \mapsto f(P)X↦f(P).


o Third argument:
f(g(Z))f(g(Z))f(g(Z)) and f(P)f(P)f(P)
 f(g(Z))f(g(Z))f(g(Z)) is a function, and f(P)f(P)f(P) is another
function. To unify them, the arguments inside the functions
must also be unified.
 So, we need to unify g(Z)g(Z)g(Z) and PPP.

 From the earlier unification step, we know that Z↦bZ \mapsto


bZ↦b. Therefore, we need to unify g(b)g(b)g(b) and PPP.
 To unify these, we substitute PPP with g(b)g(b)g(b).

 So, P↦g(b)P \mapsto g(b)P↦g(b).


Final Substitutions:

1. Z↦bZ \mapsto bZ↦b

2. X↦f(P)X \mapsto f(P)X↦f(P)

3. P↦g(b)P \mapsto g(b)P↦g(b)


MGU:
The Most General Unifier (MGU) is:

{Z↦b,X↦f(g(b)),P↦g(b)}\{ Z \mapsto b, X \mapsto f(g(b)), P \mapsto g(b) \}


{Z↦b,X↦f(g(b)),P↦g(b)}
This is the unification of the two terms J(b,X,f(g(Z)))J(b, X, f(g(Z)))J(b,X,f(g(Z)))
and J(Z,f(P),f(P))J(Z, f(P), f(P))J(Z,f(P),f(P)).

You might also like