News for hackers. Stuff that matters.
Re:The Power of Prolog by ahelwer on Thursday April 06, 2017 @12:44AM (#14047967)
It's pretty much Backtracking as a language. So stuff like N Queens, Einstein's Puzzle (the Englishman lives in the red house, the Swede in the blue house, etc.) and so on. Any time you want to write down the rules of a discrete system and ask questions about the properties of that system, Prolog is a great way to do it.

One practical application: it's very easy to write the logic for a network firewall in Prolog.

Re:The Power of Prolog by lacampbell on Thursday April 06, 2017 @12:58AM (#14048019)
ah! backtracking. combinatorial optimisation would be incredibly useful for me. if prolog is indeed backtracking as a language I definitely need to look into it.
Re:The Power of Prolog by tom_mellior on Thursday April 06, 2017 @03:30AM (#14048633)
It is indeed backtracking as a language, but you don't get optimization entirely for free. The backtracking part only means that you can write down a problem that has multiple solutions and get Prolog to enumerate those solutions using its default order.

If the set of solutions is small enough, you can enumerate all of them and pick out the best one, or have it enumerate them until you get one that is good enough. But if you need a smarter exploration of the search space, you will (in general) have to write that yourself.

Many implementations include an integer constraints library that will give you functionality similar to an ILP solver, which may or may not fit your domain.

Re:The Power of Prolog by bloaf on Thursday April 06, 2017 @12:44PM (#14052205)
Would it work well for algorithms like A*, or other quazi-AI problems that crop up in games?
Re:The Power of Prolog by tom_mellior on Thursday April 06, 2017 @02:44PM (#14053338)
Yes, but you shouldn't expect it to have much more magic support for this kind of algorithms than other languages.
Re:The Power of Prolog by insulanian on Thursday April 06, 2017 @03:41AM (#14048689)
Is it possible to do that kind of stuff (e.g. Einstein's Puzzle) in Haskell/OCaml/F# and how would one approach it?
Re:The Power of Prolog by tom_mellior on Thursday April 06, 2017 @04:48AM (#14048931)
Yes, it's possible. Most approaches use brute-force search, just like the simpler Prolog variants: http://rosettacode.org/wiki/Zebra_puzzle