Live data from Hacker News

The Power of Prolog

metalevel.at

71–80 of 162 posts

Re: The Power of Prolog

#71
This is a nice coincidence.

A few weeks back a guy at work gave away a box of old computer books, and I picked up several on Prolog and logic programming.

I've been reading through an ancient edition of "Programming Prolog", which is good, but I've had a hard time finding modern code samples. The code in the book mostly works, but I've seen some weird behavior that I suspect is due to language changes. It'll be nice to have these up-to-date examples using modern idioms.

Re: The Power of Prolog

#72
post #23

Earlier quoted context omitted.

I've shared this with anyone who will let me divert the conversation to Prolog. At work we have the Haskell folks, the Lispers who move everything towards Lisp, and I'm the one who moves every conversion towards Prolog, then I send the link to this. :-D

The older Lisp folks often have a Prolog integrated in their system...

And the Haskell folks have list application and filtering that is equivalent to the Prolog search algorithm.

Re: The Power of Prolog

#73
post #12
post #9

One of my favorite languages, pity that is has had even harder time than Lisp getting mainstream acceptance.

Let's face it, procedural is just plain easier to debug because you can more easily split it into digestible and dissect-able chunks: divide-and-conquer. Perhaps functional and logical CAN readily have such features, but nobody either figured how, or have not figured out how to explain how to do dissection to normal people. (This is sometimes a criticism of SQL also, but the added WITH clause helps break up big queri…

> you can more easily split it into digestible and dissect-able chunks: divide-and-conquer

Eh... What? It's procedural code that can change anything anywhere and thus can not be easily separated into independent pieces.

Re: The Power of Prolog

#74
post #19

Earlier quoted context omitted.

I've shared this with anyone who will let me divert the conversation to Prolog. At work we have the Haskell folks, the Lispers who move everything towards Lisp, and I'm the one who moves every conversion towards Prolog, then I send the link to this. :-D

Thank you for sharing this, I really appreciate you participating in this thread and this awesome anecdote! One related workplace anecdote that a former fellow student told me: He was working on a rule-based medical recommender system, and he recognized that Prolog was an excellent fit for this project. When he first suggested that the team switch to Prolog, they were very skeptical. But someone high up in the chain…

> My colleague told me that, a few months after that, the whole team regarded Prolog as the only viable solution to all further projects from then on!

Hm, there is such a thing as the right tool for the job. If all their jobs were very similar that makes sense, otherwise, not so much.

Are you aware of the fact that inside every Windows NT installation there was a Prolog engine to help with network configuration?

http://web.archive.org/web/20040603192757/research.microsoft...

Re: The Power of Prolog

#75
post #2

Thank you very much for the publicity, I greatly appreciate it! This book has been discussed on HN about one year ago: https://news.ycombinator.com/item?id=14045987 Since then, I have added the following new chapters: Prolog Business Cases: https://www.metalevel.at/prolog/business Sorting and Searching: https://www.metalevel.at/prolog/sorting Cryptography with Prolog: https://www.metalevel.at/prolog/cryptography Engi…

I think that reinforcement learning might be suitable in prolog. Do you have an opinion on that?

Re: The Power of Prolog

#76
post #63

Earlier quoted context omitted.

and correspondingly, a good Prolog programmer can write Prolog in any language. Limerick: "Some rascal wrote Pascal in Haskell."

>> and correspondingly, a good Prolog programmer can write Prolog in any language. And a really good one can even write it in Prolog.

And on a Prolog CPU developed with Prolog...

http://hps.ece.utexas.edu/pub/singhal_isca16.pdf

https://www.researchgate.net/publication/220760154_A_Prolog-...

Re: The Power of Prolog

#77
post #61

Earlier quoted context omitted.

In my experience, the trick is to let go of the imperative reading since it becomes too complex in the situations you mention. Instead, focus on declarative properties: Does your predicate (or DCG) succeed in cases it shouldn't ? Then your program is too general , and you need to add constraints . Or does your predicate fail in cases it should succeed ? In that case, at least one of the goals is too specific . You ca…

>> Instead, focus on declarative properties: Does your predicate (or DCG) succeed in cases it shouldn't? Then your program is too general, and you need to add constraints. Or does your predicate fail in cases it should succeed? In that case, at least one of the goals is too specific. You can use declarative debugging to find out which goals are responsible for the failure. That's good advice and I realise it articula…

That sounds like it could benefit from Design by Contract since it tells you in a lightweight way what a function will do. I actually submitted something like that to Lobste.rs recently when collecting all the implementations of contracts I could in various languages. Here's that one:

https://www.krin.gs/files/papers/krings_plspec_declare17.pdf

Re: The Power of Prolog

#78
post #75
post #2

Thank you very much for the publicity, I greatly appreciate it! This book has been discussed on HN about one year ago: https://news.ycombinator.com/item?id=14045987 Since then, I have added the following new chapters: Prolog Business Cases: https://www.metalevel.at/prolog/business Sorting and Searching: https://www.metalevel.at/prolog/sorting Cryptography with Prolog: https://www.metalevel.at/prolog/cryptography Engi…

I think that reinforcement learning might be suitable in prolog. Do you have an opinion on that?

In general, my opinion regarding machine learning and, in fact, also other tasks, is that Prolog is no less suitable to implement or teach these approaches than - for example - Python, which is currently often used in these areas. Dedicated libraries for machine learning are available and can be written for Prolog as well as for any other language, and Prolog of course also lets you easily interact with other programs via pipes and sockets.

So, yes, I agree: Prolog may well be suitable for this! In practice, for statistics-based methods, the core logic will likely be carried out by dedicated hardware which you may have to program in its own language. Prolog may still play a part also with such approaches, for example to generate test cases and correctness certificates, and as a rule-based safety measure to prevent certain situations from happening.

Re: The Power of Prolog

#79
The core ideas behind Prolog have the feel of something discovered rather than invented, and I bet we'll see significant new forms of it yet.

My first encounter with it was while taking a Principles of Programming Languages course that I hadn't been attending regularly... We had a test on Prolog four days out and I hadn't learned a bit yet. I found a couple books in the library—one of which was excellent—and was soon so absorbed by it that I learned everything I needed out of sheer interest and got a perfect score on the test.

Some six years later—the whole time not having touched Prolog or even thought about it that I can recall—I got an idea for a programming language. It would be an attempt to model 'schemas' in the human brain. Programs written in it were supposed to reflect human conceptual structure. Once you defined the concept for something, let's say a chair, you could ask it to generate instances. It was in part going to be a language designed from the ground up for procedural content generation.

There were some promising things about it (like a very concise/natural way of defining 'analogy'[0] and other aspects of thought), but ultimately, a couple years after coming up with the idea, I picked up a copy of The Art of Prolog and read the first few chapters (for general edification, and so that I'd be more aware if it were applicable to something I was working on). By that point, I felt pretty convinced that my language idea would only be superficially different from Prolog, and that most of the really interesting ideas were already captured by that language.

One up side to the project was that, after coming up with a pretty detailed plan for how the runtime would work, I decided to write this 'abstract visual debugger' to help me build it (the runtime would involve loads of complex data structure interactions that prior experience taught me were much easier to wrangle if visualized). It still seems like a promising project to me, and I work on it when I get free time. Video here: http://symbolflux.com/projects/avd

I also still have a bunch of random notes/ideas I took down about the language idea I had. Warning—I was pretty excited and they sound a bit like that ravings of a madman: http://symbolflux.com/IntellAgent-ideas.txt I also wrote an ANTLR grammar for it, but that's probably not as entertaining.

[0]

  Analogy: 
  +{original: Type, analogy: Type}
  -{
     
     Equivalence{Particularization{Generalization{original}}, analogy}
   }
Equivalence etc. are all relation constraints; the run-time would discover a value for 'analogy'. The idea is to generalize whatever the thing is ('increases generality of the attribute Types' —from my notes), fill in values of some params to particularize, and have the constraint held that the discovered analogy is Equivalent to the original (sharing the same structure, which had a definite meaning in the context of the language).

Re: The Power of Prolog

#80
post #23

Earlier quoted context omitted.

The older Lisp folks often have a Prolog integrated in their system...

Actual Prolog. Allegro ships a fully integrated Prolog as part of their product.

Now that you say that i think both Allegro and Lispworks both have that...neat!
Post reply on HN