Rec7 Sol
Rec7 Sol
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.
(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
(a) Assume we have 3 disks. Formulate the problem as a graph-planning problem, specifying instances,
operators, and start/goal states.
(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
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
• Entailment in FOL is not easy. There are lots of models that need to be enumerated!
• Agents believe facts to be T/F/Unknown.
(b) Compare and contrast these two algorithms. At a high level, what similarities can you identify, and
where are there differences?
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?
(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!