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.
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
One practical application: it's very easy to write the logic for a network firewall in Prolog.