I have taken up Prolog course in my university. The coursework requires us to write prolog programs. I am able to write simple programs, however I am finding it little hard to digest the complex programs. Any suggestions how to proceed or how do I study this subject ? what is the approach to tackle this kind of course. Any help appreciated. Thanks.
-
3Can you give an example of a program you find hard to digest? Perhaps we can clarify the example and show how to analyze it. – Willem Van Onsem Mar 09 '17 at 18:41
-
As with learning any complex system. Start with small parts, learn them completely, and build up. Also trying to teach it to someone else helps. Try to see if you can answer every question for Prolog that comes up, and if you can't learn as you go. In a few weeks you should be able to start answering and if you answer wrong you should get feedback as to where you went wrong. – Guy Coder Mar 09 '17 at 18:52
-
@WillemVanOnsem. Map coloring , coloring a graph using no more than 4 colors. – lisa Mar 09 '17 at 18:58
-
2@lisa can you be more specific than that? Find the smallest program in Prolog you find to be difficult to understand and post it as an example in your question (edit your question to show the code), and point out where you're stuck in that example. Then we can be concrete in helping. You can also browse questions and responses on this site. In some cases (too few in my opinion, but some), there's some explanation given along with solutions that can help understand. I think you just need enough explained examples, and know that Prolog is about declaring facts and rules/relationships. – lurker Mar 09 '17 at 19:49
-
Also if you don't have a good Prolog textbook, I'd suggest getting one. There are a few that folks here recommend. Clocksin & Mellish, "Programming In Prolog" is a good starter book, and there are others that get deeper. – lurker Mar 09 '17 at 19:52
-
@GuyCoder this question is a _very_ poor fit over there - it would be quickly voted down and closed, see http://meta.softwareengineering.stackexchange.com/a/6488/ Recommended reading: **[What goes on Software Engineering (previously known as Programmers)? A guide for Stack Overflow](http://meta.softwareengineering.stackexchange.com/q/7182/31260)** – gnat Mar 09 '17 at 20:11
-
@gnat I was wondering why I had a hard time trying to figure out why I couldn't find the site. I actually had to look at my list of SE sites and then for the question I answered their to see which site to suggest. Never saw a site change a name like that. Thanks. – Guy Coder Mar 09 '17 at 20:18
-
1For book recommendations. I recommend [Bratko](http://www.worldcat.org/oclc/819198380). If you use the link I gave it should show you which libraries have it near you. Then possibly [Sterling and Shapiro](http://www.worldcat.org/oclc/959401462). And if you are nearing the end of your class and still like Prolog get [O'Keefe](http://www.worldcat.org/oclc/630590104) – Guy Coder Mar 09 '17 at 20:34
-
googling "map coloring prolog" brings up [this link](https://www.cpp.edu/~jrfisher/www/prolog_tutorial/2_1.html). If you need any clarifications with that, do ask a specific question please. – Will Ness Mar 11 '17 at 09:07
1 Answers
I write an answer (which is probably just rant) because I struggle with the same problems. If a question gets closed I think the answer still stays?
what is the approach to tackle this kind of course.
Like all courses, you collect all material that your teacher/instructor/professor gives and find the books they recommend. You do the exercises as the way they expect. Do not be clever with your solutions, be clever with finding what your instructor wants to see! Try to find old exams and study them; esp. if you can find graded exams (if you are lucky and "resourceful"... ask older students for help!)
Any suggestions how to proceed or how do I study this subject ?
It is difficult to learn Prolog. I try to learn it at University and the teacher says one thing. Then I pick up a book ("Sterling and Shapiro") and it says another thing. Then I go online and I find yet another two very different things ("Amzi Amazing Adventure" and "Learn Prolog Now!"). There is also "Expert systems in Prolog" (from the Amzi website) and it is still another thing. I come to StackOverflow and I find yet other answers that are NOWHERE in all the texts I have tried to read.
The best place to learn for me is the SWI-Prolog predicate documentation: this is outrageous, don't you think? At least it is consistent....
And then many of the answers here on Stackoverflow I have tried to learn from are talking about things that make no sense (to me), probably because I don't know Prolog, but how to learn it? And almost all questions are homework, and almost all answers to homework are like little lectures that talk about ISO and logic and pureness but no clear answers.
In conclusion: "Sterling and Shapiro" was at least complete, and not too strange; and SWI-Prolog has good predicate documentation and even code examples.
EDIT: nowhere nowhere in all texts do you read about modules, but how do you write big programs without module system? Even the C++ book by Stroustrup explains how to use headers and source files to maintain a bigger program. Again, you go and read the chapter on modules in the SWI-Prolog documentation.
EDIT2: I study "Computer Science" so I maybe know "programming" and "data structures" and "algorithms" and I understand what is "proof tree" and "backtracking" and such things. Prolog is just another language. So why is it so difficult to teach it and learn it? This is an open question. I don't want to ask it on Stackoverflow because it will be closed.
EDIT3: Because you have tagged "clpfd", there is yet another text:
https://www.metalevel.at/prolog
It shows many solutions with clp(fd) that I did not see in any other of the texts I cited. It is useful and consistent but again it is different from all other texts. Maybe if I read and study everything I can find I can give you a real answer.
But do you want to pass the course or learn Prolog? Do you want a good grade and minimum effort? You need to find answers to such questions first!