December 2021
Beginner
840 pages
47h 29m
English
The following set of facts describes a binary tree (lines 2–3). A path predicate is also included that defines a path between two vertices, with two rules, to be either an edge from X to Y (line 6) or a path from X to Y (line 7) through some intermediate vertex Z such that there is an edge from X to Z and a path from Z to Y:
Notice that the comma in the body (i.e., right-hand side) of the rule on line 7 represents conjunction. Likewise, the :- in that rule represents implication. Thus, the rule path(X,Y) :- edge(X,Z), path(Z,Y) is the Prolog equivalent ...