5 ms·
A Primer on Logic Programming
- 2-718-281-828 3y agoaren't predicates in prolog always starting with a lower letter and only variables with a capital letter?
- gorkempacaci 3y agoYes. Also, in the ancestor predicate, the arrow should be in the other direction.
- maweki 3y agoYeah, we can't distinguish the arguments. Can't have a parent named X, I guess.
- aarroyoc 3y agoYou can, you just need to quote it in single quotes: 'X'.
- dannymi 3y agoJust a heads-up to the author: >Ancestor(X, Y) → Parent(X, Y) ∨ (Parent(X, Z) ∧ Ancestor(Z, Y)). That's a bug. The arrow needs to go to the left. Also, then, you can also opt to dispense with the disjunction and just use first-order logic normally. Ancestor(X, Y) ← Parent(X, Y). Ancestor(X, Y) ← Parent(X, Z) ∧ Ancestor(Z, Y).
- timClicks 3y agoIntroductions to Prolog seem to suffer the "draw the rest of the fucking owl" problem. There's a huge gap from the introductory examples to building real projects. What I would love to see more of is how to embed a prolog interpreter into a wider program, using the source program's data as the database, then prolog (or perhaps datalog) as an advanced query engine or rules engine.
- ralphc 3y agoTau Prolog embeds prolog into JavaScript. miniKanren embeds logic programming into Scheme. disclaimer, I haven't used either of these.