pptx

advertisement
Programming Assignment:
Planning
Goal: gaining familiarity with
theorem-proving technology
Goals for this homework
1. Learn how to use Prover9, a state-of-the-art
theorem prover for FOL
2. Brief introduction to a different style of
programming: logic programming
3. Practice converting a planning problem into
FOL using situation calculus conventions
Step 1: Install Prover9/Mace4
•
Download and install Prover9/Mace4 on some machine that you will be able to
use for a while. Lab machines will not have this, but if you don’t have access to
another machine, let me know, and I will try to get this installed for you on a lab
machine.
http://www.cs.unm.edu/~mccune/prover9/gui/v05.html
• Also, check out the documentation and examples.
Manual:
http://www.cs.unm.edu/~mccune/prover9/manual/2009-11A/
Examples:
http://www.cs.unm.edu/~mccune/prover9/examples/2009-11A/
I especially recommend the “Schubert Steamroller” example, which is fairly easy to
understand. Look for it under “Prover9 Miscellany”. Another one that is fairly easy to
understand is the “Trivial set theory problem”.
The Prover9/Mace4 GUI
Step 2: Run Prover9/Mace4 on an
Example Problem
1. Load the Assumptions and Goals from the Schubert Steamroller problem
http://www.cs.unm.edu/~mccune/prover9/examples/2009-11A/misc/steam.in
into Prover9/Mace4, either using the GUI or command line. I’ll explain things using
the GUI, so if you want to use the command line, you’ll need to look it up in the
manual.
2. Check to make sure the assumptions and goals are entered correctly by clicking
“Well Formed?” in the GUI.
3. In the GUI, on the right panel, you should see two Start buttons, one for Prover9
and one for Mace4. Prover9 tries to prove that the goals must logically follow from
the assumptions. Mace4 tries to find a counter-example.
Press each of the Start buttons, and record what happens in a text file called
“steamroller-output.txt”. Note that at least one of these will not succeed, so it may
take up to the given time limit (60 seconds by default).
Step 3: Run Prover9/Mace4 on a
Real Problem from Industry
One common use of theorem provers in software engineering is to verify that some
critical piece of code works correctly, or to search for a piece of code that satisfies the
input/output properties being looked for.
Your next task is to test Prover9 on this kind of industry task. We will take the problem
from the TPTP (Thousands of Problems for Theorem Provers):
http://www.cs.miami.edu/~tptp/
TPTP format isn’t directly compatible with Prover9, so we’ll use this converted version
of a TPTP problem:
http://www.cs.unm.edu/~mccune/prover9/examples/2009-11A/fof/SWC258+1.in
Copy and paste these axioms into the assumptions of Prover9, and run Prover9. Verify
that it can prove this. (Note: the “goals” should be empty; they have already been
included as “negative” assumptions.)
Copy the output proof from Prover9 into a text file called “swc258-output.txt”.
Step 4: Formulate your own problem
For this assignment, I will ask you to prove that
there is a solution to two games/puzzles, or find
a counter-example.
The main task is to formulate the puzzles in
situation calculus.
We’ll start with a simple one (next slide), and
then work up to a harder one.
Monkey and Bananas
Note: the problem is trivial for
humans, but actually somewhat hard
for monkeys and other animals.
Low
Med
High
Puzzle:
A monkey is in a room. Suspended
from the ceiling is a bunch
of bananas, beyond the monkey's
reach. However, in the room there
are also a crate and a stick. The
ceiling is just the right height so that a
monkey standing on a crate could
knock the bananas down with the
stick, if the crate is directly below the
bananas. The monkey knows how to
move left and right, climb up and
down, pick up things, pull things left
and right, and wave a stick in the air.
How can the monkey knock the
bananas down?
Left
Mid
Right
Monkey and Bananas
3.
Extra credit (optional, 1 point):
Examine the output of Prover9
to determine the exact sequence
of steps that Prover9 comes up
with for the plan. Save this plan
to a file called “monkeybananas-plan.txt”.
Med
Copy your axioms and goals into
Prover9, and have it prove that a
plan exists. (You may find that
you need to correct your axioms
to make this work.) Save the
output of Prover9 to “monkeybananas-output.txt”.
Low
2.
High
Your Job:
1. Formulate this domain in
Situation Calculus. Store your
set of axioms and goals in a file
called “monkey-bananas.txt”.
Left
Mid
Right
Step 5: Peg Solitaire: Triangle Version
Peg Solitaire consists of a board with some
pegs in it, where one of the pegs is missing.
The only action is a Jump action, which
moves one peg over top an adjacent peg,
and lands the first peg in an empty slot.
Initial Board for Triangle Peg Solitaire
The peg that was jumped over is removed
from the game.
The goal of the game is to remove all pegs
except one, and to have the final peg land
in the same spot as the initial hole.
A jump, with resulting board
The goal state:
Your task for Step 5
1.
Write a set of assumption and goal formulas that describe the Triangle Peg
Solitaire Game. Store them in a text file called “peg-solitaire.txt”.
Hint: To help with debugging your formulation of the problem, you may want to start with a
smaller board, and not require that the final peg land in the original open spot. If you can get that
to work, then work toward the full problem.
2.
Load these into Prover9/Mace4, and determine whether Triangle Peg Solver can
be solved. Save the results (outputs of Prover9 and Mace4) in a text file called
“peg-solitaire-output.txt”.
Note: Peg Solitaire is, in fact, solvable. However, the shortest solution takes 14 steps, with a fairly
big branching factor. I don’t know for sure whether Prover9 can actually find a solution. It’s fine to
determine that Prover9 can’t solve this, so long as you’re sure that you have formulated the
problem correctly. Just record the output saying that Prover9 couldn’t find a solution.
3.
Extra credit (optional, 1 point): inspect the output of Prover9 to determine the
exact sequence of steps that gets from the initial state to the goal state. Save the
steps you found in a file called “peg-solitaire-plan.txt”.
To turn in
You should turn in a single zip archive called <yourname>.zip. It should contain:
• steamroller-output.txt
• swc258-output.txt
• monkey-bananas.txt and monkey-bananasoutput.txt
• peg-solitaire.txt and peg-solitaire-output.txt
• If you did the extra credit, monkey-bananasplan.txt and/or peg-solitaire-plan.txt
Email or otherwise transfer this zip file to your TA.
Download