Computing Family Relationships
I’m going to introduce you to Prolog by using the same example as the previous chapter: family relationships. But instead of writing them out in formal logical syntax, we’ll do it in Prolog, and we’ll see how you’d interact with the Prolog system. I’m using a free, open-source Prolog interpreter called SWI-Prolog,[9] but you can use that or any other Prolog system that runs on your computer.
In logic, you reason over objects, called atoms. In Prolog, an atom is any lowercase identifier, number, or quoted string. For example, mark, 23, and "q" are atoms. For an example, we’ll look at reasoning about family relationships, so the atoms will all be first names.
A variable in Prolog is a symbol that represents an ...
Get Good Math now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.