-
This is my attempt to summarize the advice I have been given through multiple questions here, mostly by @triska and @UWN. Feel free to correct anything I say here. When someone is first learning Prolog they should focus only on the parts in the pure monotonic core. These include The reason to restrict oneself to only these parts of Prolog is to deeply learn about termination (stop searching for more solutions), choicepoints (alternatives to consider), and supporting the most general queries (all arguments are variables). Ideal Prolog predicates have the following characteristics:
The focus at this stage of learning is not to write applications for others to use. It is on learning how to write good Prolog code. If this is not learned early on, developers are likely to undervalue the characteristics of good predicates. They will be more likely to implement custom predicates that have issues with termination and choice points, and do not support the most general query. Therefore they will not fully benefit from the strengths of Prolog. Prolog predicates can be divided into three categories, those that are always pure, those that can be pure when used in specific ways, and those that are never pure (and should be avoided). An example of the last category is the The following is a list of Prolog topics that should not be considered until the lessons above are learned:
When I give a talk on Prolog, I'm concerned that if I follow all of this advice then I will not tell the audience enough to pique their interest and make them want to learn Prolog. The list above includes topics I think are important to cover in order to make developers want to learn more about Prolog. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
As always when doing a presentation, knowing the audience is key... what you describe could work (or be suitable) for students taking a course in logic programming for a computer science degree. But for developers versed in other programming languages and curious about logic programming in general and Prolog in particular? I share your doubts. |
Beta Was this translation helpful? Give feedback.
-
This looks much better! clpz and DCGs, unfair enumeration, iterative deepening, the zebra puzzle (not that I think this is the best to start with), numbers (although best is still to start with successor arithmetics), lists and strings (that is "abc" = [a,b,c]), pairs, all fit into the pure, monotonic part too. So you can already write some non-trivial programs in particular with parsing and scheduling. Also note that taking this approach isn't that new. Books like The Art of Prolog of 1986 suggested it as well. The main difference is that in the meantime there are better reading techniques to understand unexpected success, failure, and non-termination. Mastery of these is important. And yes, interaction with the top level is key for this pure part. Other parts like the if-then-else And for side-effecting built-ins, like I/O and database manipulation. Of course you need them, but using them right from the very beginning will obstruct the essence of the language. (As minor remarks, note that terms are certainly part of the pure, monotonic core. And in a course there is no need for |
Beta Was this translation helpful? Give feedback.
-
In late 2022 I did a talk at my company too about Scryer Prolog. However, it wasn't an introduction to Prolog. Instead, I just went with Constraint Programming problems and how to solve them (as that is what I was more interested in at that time) using Scryer Prolog. I took a lot of examples from the book "Constraint Solving and Planning with Picat" but I translated the problems. You can see the slides here: https://docs.google.com/presentation/d/e/2PACX-1vSEIZq4s_DMe3ejtp_OQ7JQpXktbgeDQCaonArxkirCL7RB9u3ZPo1FvsHppncvrrecLJmV2qEJod5s/embed?start=false And a recording of that talk (in Spanish): https://www.youtube.com/watch?v=c_yP_kr7DxI |
Beta Was this translation helpful? Give feedback.
-
One additional point that may be worth knowing when teaching Prolog and strings which you mention: All recent Prolog systems (Scryer, Tau, Trealla and ichiban/prolog) set the Prolog flag I mention this also because I saw a post in which it is argued that using Scryer Prolog uses a very compact internal representation of strings, and DCGs allow very convenient reasoning about strings. It is clear that any potential string library for Scryer and other modern Prolog systems must be able to work on this representation of strings as lists of characters. |
Beta Was this translation helpful? Give feedback.
This looks much better!
clpz and DCGs, unfair enumeration, iterative deepening, the zebra puzzle (not that I think this is the best to start with), numbers (although best is still to start with successor arithmetics), lists and strings (that is "abc" = [a,b,c]), pairs, all fit into the pure, monotonic part too. So you can already write some non-trivial programs in particular with parsing and scheduling.
Also note that taking this approach isn't that new. Books like The Art of Prolog of 1986 suggested it as well. The main difference is that in the meantime there are better reading techniques to understand unexpected success, failure, and non-termination. Mastery of these is important. And …