This shows you the differences between two versions of the page.
Next revision | Previous revision Next revision Both sides next revision | ||
sc330_f2016:prolog1 [2016/08/16 18:32] dcostello created |
sc330_f2016:prolog1 [2018/10/19 21:47] morse |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====THIS LAB IS NOT FINALIZED, DO NOT USE=== | ||
- | ====Objective:==== | ||
- | *Gain experience with logic programming. | ||
- | *To become familiar with Prolog. | ||
- | *To Gain understanding of the declarative nature of prolog. | ||
- | ---- | + | ====Objective==== |
- | You will use the Prolog container for this Assignment. | + | * Gain experience with logic programming. |
+ | * Become familiar with Prolog. | ||
+ | * Gain understanding of the declarative nature of prolog. | ||
- | (The Prolog container isn't ready, ensure that you are using SWI-Prolog) | + | ====Installation==== |
- | ====Deliverables:==== | + | For this class, we use [[http://www.swi-prolog.org|SWI-Prolog]]. You can download binaries for a Windows or macOS system [[http://www.swi-prolog.org/download/stable|here]]. |
- | You will turn in two prolog programs(in separate files) that solve the following logic puzzles:\\ | + | |
- | *[[schoolsOut.png|School's Out!]] | + | |
- | *[[rosiesRoses.png|Rosie's Roses]]\\ | + | |
- | Your "main" function will be the predicate solve.\\ | + | Also, there is an unofficial tutorial for installation [[https://wwu-pi.github.io/tutorials/lectures/lsp/010_install_swi_prolog.html|here]]. |
- | To help you we've provided a [[smapleSolution.txt|sample solution]] to [[tie.png|It's a tie]], Use this as a model for your own solutions. | + | For Mac with [[http://brew.sh|Homebrew]] installed, you can do this command ([[http://stackoverflow.com/a/23904035/756329|info here]]): |
- | ====Notes:==== | + | <code>brew install swi-prolog</code> |
+ | |||
+ | For Ubuntu, you can do these commands: | ||
+ | |||
+ | <code> | ||
+ | sudo add-apt-repository ppa:swi-prolog/stable | ||
+ | sudo apt-get update | ||
+ | sudo apt-get install swi-prolog | ||
+ | </code> | ||
+ | ====Deliverables==== | ||
+ | |||
+ | You will turn in two prolog programs (in separate files) that solve the following logic puzzles: | ||
+ | |||
+ | *{{sc330_f2016:rosiesroses.png?linkonly|Rosie's Roses}} ({{sc330_f2016:rosies-roses-key.pdf?linkonly|Solution}}) | ||
+ | *{{sc330_f2016:schoolsout.png?linkonly|School's Out!}} ({{sc330_f2016:schools-out-key.pdf?linkonly|Solution}}) | ||
+ | |||
+ | To help you start, we've provided a [[smapleSolution.pl|sample solution]] to {{sc330_f2016:tie.png?linkonly|It's a tie}}. Use this as a model for your own Prolog solutions. | ||
+ | |||
+ | Note that there are links above to the solutions (not the Prolog code) for these two puzzles. We strong encourage taking a few minutes to solve these puzzles by hand so that you get a feel for how to solve them and the "facts" you're extracting from the clues in the puzzle. This will give you a better feel for what you need to encode in your Prolog solution as well helping you get a feel for what Prolog's trying to do under the hood. (And it's fun!) | ||
+ | |||
+ | ====Notes==== | ||
*Just copy and paste the all_different function. It simply checks to make sure each item in the list is unique. | *Just copy and paste the all_different function. It simply checks to make sure each item in the list is unique. | ||
- | *Check spelling errors. There is not such thing as misspelled atoms. So speigel and spiegel are both valid but different. | + | *Check spelling errors. There is no such thing as misspelled atoms. So speigel and spiegel are both valid but different. |
- | *Once you have a solution just check whether it satisfies each of the numbered rules in the problem. | + | *Once you have a solution, just check whether it satisfies each of the numbered rules in the problem. |
- | *These problems make extensive use of the "not operator, \+. | + | *These problems make extensive use of the "not" operator, \+. |
* \+ works as you expect when all variables are completely bound. | * \+ works as you expect when all variables are completely bound. | ||
* If E contains unbound variables, \+E will try to find bindings to that will make E true. If Successful \+ will fail. | * If E contains unbound variables, \+E will try to find bindings to that will make E true. If Successful \+ will fail. | ||
- | * This lab is taken from http://www.cis.upenn.edu/~matuszek/cis554-2015/Assignments/prolog-1-logic-puzzles.html there may be additional resources there. | + | * This lab is taken from [[http://www.cis.upenn.edu/~matuszek/cis554-2015/Assignments/prolog-1-logic-puzzles.html|this site]]. There may be additional resources there. |