HN Books @HNBooksMonth

The best books of Hacker News.

Hacker News Comments on
Prolog Programming for Artificial Intelligence (4th Edition) (International Computer Science Series)

Ivan Bratko · 2 HN comments
HN Books has aggregated all Hacker News stories and comments that mention "Prolog Programming for Artificial Intelligence (4th Edition) (International Computer Science Series)" by Ivan Bratko.
View on Amazon [↗]
HN Books may receive an affiliate commission when you make purchases on sites after clicking through links on this page.
Amazon Summary
This best-selling guide to Prolog and Artificial Intelligence, which has been updated to include key developments in the field, concentrates on the art of using the basic mechanisms of Prolog to solve interesting AI problems. Combined approach to Prolog and AI allows flexibility for learning and teaching. Provides a thorough representation of AI, emphasizing practical techniques and Prolog implementations. Prolog programs for use in projects and research are available for download from the companion website http://www.pearsoned.co.uk/bratko
HN Books Rankings

Hacker News Stories and Comments

All the comments and stories posted to Hacker News that reference this book.
We're a pretty heavy user of Prolog for several systems. We use it for doing end of day allocations to prime brokers to determine the optimum allocations, basically a constraint solver.

I had it in the trading system for some time but I had to pull it out as I couldn't find a way to make its runtime deterministic enough. Most of the time it would be great and then on occasion I'd get 100 millisecond pauses:( I could never figure out if it was me doing something, the C bindings we were using or if Prolog just has a mind of its own:)

If anyone has any pointers on how to reason about the run time efficiency and performance of your prolog code I'd be willing to buy you a coffee!

http://www.amazon.com/Programming-Artificial-Intelligence-In...

Awesome book, can usually be found in any used university book store!

jamii
Depending on how you are using it, you could look into an actual constraint solver like Gecode or a more deterministic logic language like Dyna. The latter would probably require some implementation work - the only production-quality implementations I know of are proprietary.

http://www.gecode.org/

https://github.com/nwf/dyna

tluyben2
Which implementation are you using? Performance wise Mercury is a lot better than most Prolog implementations in our experience.
dmpk2k
I could never figure out if it was me doing something, the C bindings we were using or if Prolog just has a mind of its own

DTrace, my friend. If DTrace didn't point you in the right direction with a one-liner, I would have been surprised.

devbug
Do you happen to know any good resources for becoming a power-user of DTrace?
tom_mellior
> on occasion I'd get 100 millisecond pauses

As a first guess, this sounds like garbage collection pauses. Details of what to do about them depend on the particular implementation.

In SWI you can use the profiler to see if the garbage collector is in fact being called when you don't expect it. Then: (a) change the default (veeery low) garbage collector settings to use more memory before collection is triggered; (b) make sure you're not leaving unnecessary choice points around (listed as "redo" by the profiler, fix with correctly placed green cuts); (c) call garbage_collect/0 yourself at well-defined points when you're currently not doing low-latency stuff; (d) possibly (but I have no personal experience with this) turn off the garbage collector completely for certain sections of the code.

userbinator
change the default (veeery low) garbage collector settings to use more memory before collection is triggered

I'm not familiar with Prolog GC but in other systems, making GC less frequent just tends to cause each collection to take even longer, as more objects have been created between each pass.

tom_mellior
That is true as a general trend, but in my experience with SWI-Prolog the effect is not linear, and frequent small collections do cost more (in MY applications). For one thing, if you have long-lived data used throughout the program's whole lifetime, they will be visited on every collection without ever being freed. For another thing, if you have enough memory to fit all the data ever allocated by the program, you may not need to collect at all! Also, as mentioned in my previous comment, depending on the application there may be program parts where it is OK to trigger even a long-ish collection manually, while you want other parts to be fast and collection-free.

So, to reiterate: You are right in broad terms, but it all depends very much on the details of the application.

Sep 12, 2014 · craigching on Rethinking Prolog [pdf]
I just picked this up a couple of weeks ago:

http://www.amazon.com/Programming-Artificial-Intelligence-In...

Came highly recommended by David Nolen on his blog. Appears to have a good section on CLP.

EDIT: And completely agree with you on "The Art of Prolog", I have that too and have read most of it. Need to get back to finishing that up some day ;)

zura
Yes, Bratko's book is on my reading list but never got to it so far ;)
HN Books is an independent project and is not operated by Y Combinator or Amazon.com.
~ yaj@
;laksdfhjdhksalkfj more things
yahnd.com ~ Privacy Policy ~
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.