The missing puzzle piece for your understanding, is how Prolog works. Prolog is declarative programming language, the program logic is expressed in terms of relations, represented as facts and rules. A computation is initiated by running a query over these relations.