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

Rec7 Sol

The document describes forward chaining for propositional logic and first-order logic. It provides pseudocode for forward chaining algorithms in both cases and discusses their similarities and differences. For propositional logic, the algorithm determines if a query proposition is entailed. For first-order logic, it determines if a query sentence is entailed. Both start from known facts and add conclusions of rules whose premises are satisfied. However, first-order logic handles objects, relations, and variable renaming. The document also notes inefficiencies in the presented first-order logic algorithm, such as expensive pattern matching and rechecking all rules on each iteration.

Uploaded by

usersome6
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)
28 views

Rec7 Sol

The document describes forward chaining for propositional logic and first-order logic. It provides pseudocode for forward chaining algorithms in both cases and discusses their similarities and differences. For propositional logic, the algorithm determines if a query proposition is entailed. For first-order logic, it determines if a query sentence is entailed. Both start from known facts and add conclusions of rules whose premises are satisfied. However, first-order logic handles objects, relations, and variable renaming. The document also notes inefficiencies in the presented first-order logic algorithm, such as expensive pattern matching and rechecking all rules on each iteration.

Uploaded by

usersome6
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/ 7

15-381: AI: Representation and Problem Solving Spring 2019

Recitation 7 March 1

1 Forward chaining
In this section, we will be proving a statement using forward chaining.

There is currently a war going on and the United States is desperate to round up all the criminals. We
want to determine whether Colonel West is a criminal. Let’s start with what we know.

We know that it is a crime for an American to sell weapons to hostile nations. The country Nono is
an enemy of America. Furthermore, we know that Nono has some missiles, all of which were sold to it by
Colonel West, who is American.

(a) Represent your knowledge base using first order logic. You can use the following function predicates:
American(x), Criminal(x), Hostile(x), Missile(x), Weapon(x), Enemy(x,y), Owns(x,y), Sells(x,y,z).

1. ∧ ∧ ∧ ⇒ Criminal(x)
2. Missile(x) ⇒
3. Missile(m)
4. Owns(nono, m)
5. Missile(x) ∧ ⇒ Sells(west, x, nono)
6. Enemy(x, america) ⇒
7.
8.

(b) Fill in the blanks below using your knowledge base to prove that Colonel West is a criminal.

(a) Represent your knowledge base using first order logic.


1. American(x) ∧ Weapon(y) ∧ Sells(x,y,z) ∧ Hostile(z) ⇒ Criminal(x)
2. Missile(x) ⇒ Weapon(x)
3. Missile(m)
4. Owns(nono, m)
5. Owns(nono, x) ∧ Missile(x) ⇒ Sells(west, x, nono)
6. Enemy(x, America) ⇒ Hostile(x)
7. American(west)
8. Enemy(nono, america)

(b) Fill in the blanks below using your knowledge base to prove that Colonel West is a criminal.

1
15-381: AI: Representation and Problem Solving Spring 2019

Recitation 7 March 1

sol.png

2
15-381: AI: Representation and Problem Solving Spring 2019

Recitation 7 March 1

2 Planning Tower of Hanoi


In the Tower of Hanoi problem, you are given n disks, each of a distinct size, and 3 rods, A, B and C. The
disks start off stacked on top of each other on rod A, stacked from largest being the lowest to smallest being
the highest in a “tower”, and the goal is to move that tower to the rod C. You can only move a disk to an
empty rod or on top of a larger disks, and disks may only have one other disk on its surface (they must be
stacked linearly).

(a) Assume we have 3 disks. Formulate the problem as a graph-planning problem, specifying instances,
operators, and start/goal states.

See provided sample code

(b) Draw the planning graph for the first 3 moves. You may use pictures instead of propositions.

3
15-381: AI: Representation and Problem Solving Spring 2019

Recitation 7 March 1

(c) Generalize the problem formulation for n disks.

See provided sample code

4
15-381: AI: Representation and Problem Solving Spring 2019

Recitation 7 March 1

3 Discussion-Based Questions
Let us consider forward-chaining in both a first-order logic and propositional logic setting. Find someone
sitting near you to talk through the following questions with, and take some time to look through the following
pseudocode snippets from the textbook.

Figure 1: Forward-chaining algorithm for propositional logic, from p. 258 of the course textbook.

Figure 2: Forward-chaining algorithm for first-order logic, from p. 332 of the course textbook.

(a) First things first, what are some similarities and distinctions between propositional logic and first order
logic?

5
15-381: AI: Representation and Problem Solving Spring 2019

Recitation 7 March 1

Propositional logic

• The world contains facts.


• Entailment in propositional logic can be computed by enumerating models

• Agents believe facts to be T/F/Unknown.

First Order logic

• The world contains facts, objects, and relations.

• Entailment in FOL is not easy. There are lots of models that need to be enumerated!
• Agents believe facts to be T/F/Unknown.

We can think of FOL as encompassing Propositional logic.

(b) Compare and contrast these two algorithms. At a high level, what similarities can you identify, and
where are there differences?

The forward-chaining algorithm PL-FC-ENTAILS?(KB,q) determines if a single proposition symbol q


(the query) is entailed by a knowledge base of definite clauses. It begins from known facts (positive
literals) in the knowledge base. If all the premises of an implication are known, then its conclusion
is added to the set of known facts. For example, if L1,1 and Breeze are known and (L1,1 ∧ Breeze)
=⇒ B1,1 is in the knowledge base, then B1,1 can be added. This process continues until the query q
is added or until no further inferences can be made.

FOL-FC-Ask(KB, α) works slightly differently. Starting from the known facts, it triggers all the rules
whose premises are satisfied, adding their conclusions to the known facts. The process repeats until the
query is answered (assuming that just one answer is required) or no new facts are added. Notice that
a fact is not “new” if it is just a renaming of a known fact. One sentence is a renaming of another if
they are identical except for the names of the variables. For example, Likes(x, IceCream) and Likes(y,
IceCream) are renamings of each other because they differ only in the choice of x or y; their meanings
are identical: everyone likes ice cream.

The forward chaining algorithm for propositional logic takes in a propositional symbol while the forward
chaining algorithm for FOL takes in a propositional sentence. With first order logic, you need to keep
track of fewer pieces of information.

(c) Now, consider the forward-chaining algorithm presented in Figure 2. It is designed to be conceptually
straightforward, but is rather inefficient. What inefficiencies can you identify in this code?

There are three possible sources of inefficiency.

(a) The “inner loop” of the algorithm involves finding all possible unifiers such that the premise of
a rule unifies with a suitable set of facts in the knowledge base. This is often called pattern
matching and can be very expensive.

(b) The algorithm rechecks every rule on every iteration to see whether its premises are satisfied,
even if very few additions are made to the knowledge base on each iteration.

6
15-381: AI: Representation and Problem Solving Spring 2019

Recitation 7 March 1

(c) The algorithm might generate many facts that are irrelevant to the goal.

Recall that this pseudocode was designed to be conceptually straightforward, and there are ways of
addressing these inefficiencies!

You might also like