2020/3/15 Prolog-Puzzle-Assignment
23:59 100 pdf pl
Use PROLOG to solve a logic puzzle.
Use PROLOG to write down all the rules provided in the puzzle, and then use PROLOG to determine where to place the X’s and O’s in the logic puzzle.
All the puzzles are logic puzzles I downloaded from (
You can check the solutions to any puzzle by going to logic-puzzles.php#list ( and entering the puzzle ID. Our graders will be doing this to check your results and so you should do it too.
You will need to solve one of the “challenging” logic puzzles:
B924SH.pdf Q315GN.pdf V898TT.pdf Y074UR.pdf
For EXTRA CREDIT you may do the portion of the assignment in red. Solve one of the “fiendish” logic puzzles:
O498WI.pdf X775RR.pdf
A brute-force attempt to evaluate every possible solution will no longer be feasible for these puzzles, you will have to be clever in how you whittle down the solution space in order to solve these in minimal time.
You should be able to deduce the solutions to each logic puzzle using PROLOG. To do so, you will create a .pl file for the puzzle and enter all the rules provided with the puzzle. You should then be able to formulate queries to fill in the table.
It may be tedious to type in all those queries, but SWI-PROLOG lets you produce output from within the .pl file if you add something like this to the end:
ºÍ ÐÍÀà¼þÎÄ ¼þÎÄ´«ÉÏ·ÝÒ» ½»Ìá ·ÖµÃ Ç°Ö® £¬¶þÆÚÐÇ ¼äʱֹ½Ø

2020/3/15 Prolog-Puzzle-Assignment
:- forall((condition1(X), condition2(Y), …), (rule(X, Y, …)) )
where, of course, condition1(X) would be an expression and “rule” is a rule implementing some of the logic of the puzzle. In this case X and Y are temporary variable that can be used only within the forall.
It is also useful to use SWI’s implication “->” operator.
hypothesis -> conclusion
where hypothesis is a prolog predicate and conclusion is a statement that is true if conclusion is true. Many clues are worded this way.
Do not forget to use the member predicate as well. What To Submit:
The submission requirements have been updated — you are not responsible for the items in RED. Only the items in BLUE
1. You will submit a write-up, as a PDF
In order to make submission easier, this is all that is required as of Feb 28:
1. A PDF version of the complete source-code to your .pl file including comments. The PDF should include line numbers, and it can be generated by a variety of tools that are a short Google search away.
2. Your submission should indicate which rules of your .pl file are associated with which statement in the puzzle, indicate by repeating the prolog statements as comments in your .pl file
3. The solution as a table.
The solution is just a single table that you can check online using the link above in the problem description.
A good way to present this is as a comment showing the output of your prolog program, however you should make sure it
is formatted as a temple (the columns should line up).
No longer required
1. Your write-up will have two sections — one for the “challenging” puzzle and one for the
“fiendish” puzzle.
2. Each section will include a scanned in (or digitally edited) copy of the puzzle that has been
completely filled in. It must include the puzzle ID.
3. Each section will include the source-listing of a .pl file with all the rules of the logic puzzle.
Please make sure you include line-numbers and syntax highlighting to make these readable.

2020/3/15 Prolog-Puzzle-Assignment
4. Each section will include a listing of the interactive queries used to fill in the solution table. (It is possible to include these in the .pl file as well…)
5. Each section will also include a listing of the interactive querries for the entire grid. 2. You will submit the .pl file for the “challenging” puzzle.
3. You will sunmit the .pl file for the “feindish” puzzle.
A very small number of you may have attempted the feindish puzzle. The brute-force strategy will not work there, but some of you may have made some progress. I will adjust the rubric for the assignment so that the feindish puzzle is EXTRA CREDIT worth up to 20% of the problem set. You will be able to get partial credit.
Submits a PDF Writeup
Submits .pl for “challenging” puzzle
Submits .pl for “fiendish” puzzle
The “challenging” .pl file is correct
The writeup demonstrates that the .pl file for the puzle can be used to fill in the solution table and any other query on the grid.
The “fiendish” .pl file is correct
The writeup demonstrates that the .pl file for the puzle can be used to fill in the solution table and any other query on the grid.
120.0 120.0
·Ö ·Ö
·ÖµÃ ¼¶ µÈ

Leave a Reply

Your email address will not be published. Required fields are marked *