Who Killed Prolog? (2010)
vanemden.wordpress.com
vanemden.wordpress.com
The abstraction isn't perfect, but it is decent enough for a first approximation. I'm guessing Fortran is similar. Imperitive languages of that era were used because they worked very closely with the actual actions of the CPU and gave a fine grained control over execution, allowing efficiencies. Since then, popular languages have all been improvements that take advantage of increased computing power to do interesting things.
Sometimes new paradigms rear up - eg, Clojure with its set-and-forget approach to values. That paradigm is sold on the basis that it is easier to reason about, debug and as a practical bonus faster in many cases than the alternative. This is a great reason to learn a new paradigm.
Prolog is an experiment, but has anyone found a domain for the paradigm of logic programming? I've used it, and I couldn't see any domain where it seemed to have an advantage. For AI in particular - the way the world is developing, it seems logic is a weak foundation for intelligence. At this point, given that we know humans do not use logic for their intelligence, it would be a little surprising if logic is the best way to approach that particular problem. In most domains, the error in your sensor overwhelms the existence of fact and the 'rules' are more what you'd call guidelines.
If I rule out AI, what field is Prolog especially suited for? It doesn't read like it has a natural advantage in debugability (quite the reverse imo), GUIs, stream processing, efficiency, etc. With a lack of a killer domain, why not implement it as an afterthought library in C or lisp, and keep the imperative languages we have so much research in?
Basically, the default state of Prolog is dead. It doesn't represent how humans want to think about programming, it doesn't represent how the computer implements programming and so if it doesn't have a domain where its paradigm is spot on perfect it isn't going to take hold. It is an interesting idea and might yet be useful, but someone will need to find a reason to justify it.
One example of a proof that Prolog is good at is solving games, such as solving a particular instance of tic tac toe, or 4-in-a-row. Beyond these toy examples, you can see a good fit in any application which needs to follow a procession of rules. These rules may be in a feeding/bleeding relationship — this is essentially constraint logic programming. The problem goes: given these constraints, does this statement fulfil the constraints? How can I make the statement fit the constraints? Which is the set of statements that fit these constraints?
I know of an industry application in German luxury cars, where the customer can order a car with a lot (a lot a lot) of different features, but some are mutually exclusive. If you have this particular leather seat, you can't have that particular heating unit or whatever. Now tell me if the customer selected a valid configuration, and if not, tell me what the valid configurations "next to" the desired one are.
Another application are DCGs (Definite Clause Grammar), which have the expressive power of regular expressions (EDIT: see below for a correction, it appears they're at least context-sensitive.) If you've done Monadic parsing, DCGs feel kinda similar. They're super-close to Phrase Structure Grammar rules, and used to be part of my linguistics curriculum (I hear it's all ML nowadays. Pity.)
Yes, Prolog fits niche domains. But if you find a domain, such as regular languages or a problem that can be solved by CLP, the elegance of logic programming can hardly be beat. It's really a joy to work with in the right domain. It's absolutely awful as a general purpose programming language, though — mostly because the debugging is so complex, it almost feels nondeterministic (it isn't, but there were many moments at 2 in the morning where I could've sworn it is.)
In principle, Prolog is great for searching for solutions of a formally posed problem. Think of it as a logic search engine. If your problem can be stated in logic, and the logic problem can be evaluated in a finite time, Prolog's your friend.
If not, you'll blow the stack.
DCGs have a lot more expressive power than regular expressions. They are at least context-sensitive (i.e., stronger than context-free grammars as well). But off the top of my head I don't see why they wouldn't be able to capture recursively enumerable languages (i.e., the languages of completely unrestricted grammars) as well.
> Think of it as a logic search engine.
Think of it as a logic search engine embedded in a general-purpose programming language, because that's what it is.
The trouble is that your program can become non-terminating in all but the regular case IIRC. Man it's been 10 years since I've done Prolog, so take what I say with a grain of salt.
as --> as, [a].
as --> [].
Prolog will recurse infinitely on the first rule.I think this is the whole problem. The Prolog language is not great as a general-purpose language, and the "logic search engine" doesn't need be so closely identified with a particular language. Prolog should be a library, not a language, and not the almost sole representative of a programming paradigm.
Not at all on topic, but this is the first time I've seen double repetition like that in the wild. Makes me wonder about examples of non-contrived buffalo sentences.
Whoa, "humans do not use logic for their intelligence"? Hold on there. How do we know that?
I suspect the line of reasoning is something like: if machine learning is massively successfully without a great deal of logic or deductive rules, then the human mind works similarly.
Which stems in turn from thinking the brain is just like a computer, and vice-versa, which is arguable (let alone lamentable).
Graphs?
SWI-Prolog even comes with an RDF triple store: http://www.swi-prolog.org/pldoc/man?section=semweb-rdfapi
Why aren't people using Prologs instead of graph databases like neo4j?
What an offensive statement.
Over two thousand years of fighting intuition-based judgements, and now that DL can merely tell a gorilla from a mouse (with 712 hours of training on 91 GPUs), it is best form of "intelligence" but Logic - a fundamental part of mathematics that helped us u.n.d.e.r.s.t.a.n.d the universe better - is a "weak foundation for intelligence?
is a baby able to tell a gorilla from a mouse after ~2 months of being awake ?
For instance, people will never accept that the AI of a car kills by accident, even thought human drivers kill a lot more etc. A system that makes life-or-death decisions but has no liability nor ethics is difficult to accept.
The article talks about expectations - unrealistic expectations even. People expect from AI that it makes clever decisions like humans and "no mistakes" like machines (scare quotes for bugs, failures etc.).
Now, I don't suggest that DL is useless. It is good at what it does, but contrary to what OP suggests, I don't see it as the sole or even main component of an AI system.
Still, logic systems are a lot closer to reasoning and understanding (if not for the machine itself, at least for its operators), in other words closer to intelligence than other systems.
DL are plain incapable of reflection/showing its workings.
I'm just asserting that the GP was probably considering a small subset of logic based systems and was incorrect in their assumptions.
It seems more like something I would want to embed as a DSL than something I would want to use for writing an entire program front to back.
This never went upstream for a couple of practical reasons:
(1) It wasn't much simpler than the C code. In fact once you've gone and explained to people how Prolog works they might as well have digested the C code.
(2) There wasn't a good, embeddable, widely-available Prolog "engine" we could use. As a result I wrote my own engine which only did the simplest sort of forward inference and so wasn't at all efficient.
why is that "new" paradigm associated with clojure?
Because Clojure plays so well with the JVM, having industry applications leveraging logic engines is becoming beautifully feasible.
Years ago, I thought of writing a science fiction story predicated on the idea that in the far future that the world would run on ancient software that was proved correct and made perfect by being debugged over the centuries.
Another examples: zlib, SWI-Prolog, most BLAS implementations, some GCC backends, Concord (heuristic-based TSP solver), most parts of algo based libraries (CGAL, Eigen, GMP, GSL etc...) (of course these libraries are implementing new features, but there are some parts of codebase that didn't receive any commit for years)...
I think good signals to tell a package is complete: (1) there are no known critical bugs (2) if we found a critical bug today, we're reasonably sure we will get a fix in reasonable amount of time (3) project and project goals are well-documented (4) everything documented as goal is implemented i.e. there is no on-going development happening.
https://twitter.com/stuarthalloway/status/102541111254678732...
Yet there is a list of very useful features discussed in the repository that does not advance very quickly, mostly due to David Nolen being busy with other great work (clojurescript, om, etc.) lately.
I’m a heavy user of core.logic in my personal project, and I would like to see the project gain more powers; I just didn’t /need/ them yet. I’m thinking on dedicating some time to it. Perhaps you can too!
Long ago I wrote something in Turbo Prolog. The algorithm, for configuring minicomputers, was easy. The drop-down menus were hell.
[1] O. Kiselyov, K. Kameyama, Rethinking Prolog. http://okmij.org/ftp/kakuritu/rethinking.pdf
[2] E. Barrett, C. F. Bolz, L. Tratt, Unipycation: A Case Study in Cross-Language Tracing. https://soft-dev.org/pubs/pdf/barrett_bolz_tratt__unipycatio...
I think one can just run a Prolog engine in Lisp these days, which would get one the best of both worlds. But I'm not a Prolog programmer, so … perhaps I'm incorrect.
I don't know how good those implementations are compared to dedicated Prolog environments, though.
https://www.gnu.org/software/gnuprologjava/
We can use that to run Common Lisp which can run Prolog. Lmao
But really which language is bigger is pointless to begin with.
I haven't tried it yet. I'd like to build some project in it.
Are you saying researchers belong to their university? Or are you saying once someone is a researcher they are no longer allowed to move to industry?
Also in my experience a lot of researchers are grad students, who move to industry on completion of their degree - does getting a job after graduating mean you were “poached”?
For people who know Haskell, such a type definition should look very familar:
data IntTree = Leaf | Branch Int IntTree IntTree
The mind-bending stuff starts when you see "function" definitions like choose x y = x
choose x y = y choose x y = x
choose x y = y
:-) That's mind bending if you don't know logic programming. So how can the above statement even make sense? You have to understand that a logic program will try all possible statements until it finds a match, or simply all possible statements if its job is to do an exhaustive search of the problem space.So in the choose function above, the execution algorithm (the runtime, as it were) would try to choose x first, and see if that yields a result that matches the query. It then chooses y. This may yield no, one, or many results, depending on the exact constraints of the search space.
If you posed the problem as choose 'a' 'b' then the answer would be 'a' if you're content with any solution (it gives you the first it finds), or ['a','b'] if you wanted all solutions.
Man, now I wanna go do some Prolog… pity there's nobody who's gonna pay me to do it, and I have to do PHP and JS.
History is not kind the the Japanese 5th generation project. My hunch is that Kai-fu's predictions will be more accurate than Edward's and Pamela's predictions.
I used to use Prolog a lot, now I just occasionally play with it. Contrasting to Lisp: until I started my current job 15 months ago (Python ML), Lisp was one of the cornerstones of my work and consulting business for 35 years.
Am I wrong in thinking that Coq for example can be considered a replacement of Prolog?
I don't know if you're right or wrong about that. But Coq is about as "dead" as Prolog is. That is, it isn't used very much for real-world programming. It doesn't look like it's going to become more alive very soon, either.
Even if Coq and Prolog can be considered as "in the same style/family", maybe the problem is that for most problems, most people just don't want to program that way?
Prolog is a programming language whose execution is based on certain logical principles.
Coq is a functional programming language, and and extra logic layer to prove things about programs written in its programming language.
If you will, Prolog uses logic at "run time", while Coq uses logic at "compile time". Different things (and very different logics).
I think Girard's ludics, among other goals, tried to unify these two views, although I know too little about it.
Finally, note Coq, like Haskell, models computation as proof normalization, although it's design goals are very different from Haskell.
http://web.archive.org/web/20040603192757/research.microsoft...
Dr Dobbs (bad formatting) http://www.drdobbs.com/cpp/extending-c-with-prolog/184409294
Prolog mentioned above, has been preserved on archive.org, but here for posterity... https://github.com/opless/small-prolog-walnut-creek-original
http://www.learnprolognow.org/lpnpage.php?pagetype=html&page...
Good fast tutorial for it.
Side-note: The tutorial calls the condition the 'body' and the resulting facts as 'head' took me awhile to absorb since my brain can't stop thinking of the common syntax: if(conditions){body}
Many people seem to like https://www.metalevel.at/prolog (featured here several times). Although I don't think it's very good from a didactic point of view, many disagree, and at least the author really knows what they are talking about.
I have a PDF of the fifth edition of "Programming in Prolog" by Clocksin and Mellish lying around here. I could swear it was available for free as open access for a while, though a very quick web search doesn't confirm this.
Thanks for the book suggestion. Quick duckduck for it gives me this pdf:
http://www2.cs.arizona.edu/classes/cs372/spring15/Programmin...