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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access