In Prolog, we talk about logical variables to mean identity between literals.
That is, a program is a set of rules that together establish what is true of our literals and that literals are not interpreted. We write rules, using variables to describe relationships about people, and trying to prove whether our request can become true, Prolog binds the variables according to the rules.
A list is just syntactic sugar for the binary relationship between the term (chapter) and (note the recursion here) list. Usually, when we talk about a database, we use facts (rules without a body, always true) that atomic literals relate.
So this tutorial probably expresses the task in other words than you are reporting, or it is somewhat misleading. In any case, you can store lists in your database as such:
mylist([a,b,c]).
and write your program as:
myprog(X) :- mylist(L), member(X, L).
Then you can request your program as:
?- myprog(X).
and Prolog, trying to prove myprog / 1, tries to prove mylist / 1 and member / 2 ... To prove mylist (L), the variable L is associated with [a, b, c].
NTN
source share