Hacker News new | ask | show | jobs
by overlords 2812 days ago
Rules engines are about forward chaining (fan-out of all implications) whereas prolog is backward chaining (querying an implication).

CHR (constraint handling rules) is a forward chaining system built into most prologs that has prolog like syntax, and so is a replacement for business rules engines.

So the choice of what to use is based on that (if you want forward chaining - business rules, or CHR of prolog), if you want backward chaining (similar to SQL) then prolog.

Prolog is more elegant than the business rules engines, and also has extra features (constraint programming with finite domains for example), that business rules don't have.

So in short, prolog is more comprehensive and more elegant but requires more expertise, busines rules are for "untrained" people to get working with relatively quickly.

2 comments

Building a forward chaining rule in Prolog is trivial. Here's an example in 25 lines

https://www.cse.unsw.edu.au/~billw/cs9414/notes/kr/rules/for...

Allows for rules such as

  iF
    problem_in_kitchen and no_water_from_outside
  then
    leak_in_kitchen.
I went from logic puzzles to Prolog and the CLPFD lib was a great help to achieve results even as novice.