Schelog objects are the same as Scheme objects. However, there are two subsets of these objects that are of special interest to Schelog: goals and predicates. We will first look at some simple goals. Section 2 will introduce predicates and ways of making complex goals using predicates.
A goal is an object whose truth or falsity we can check. A goal that turns out to be true is said to succeed. A goal that turns out to be false is said to fail.
Two simple goals that are provided in Schelog are:
%true %fail
The goal %true
succeeds. The goal %fail
always fails.
(The names of all Schelog primitive objects
start with %
. This is to avoid clashes with the names
of conventional Scheme objects of related meaning.
User-created objects in Schelog are not required to
follow this convention.)
A Schelog user can query a goal by wrapping it in a
%which
-form.
(%which () %true)
evaluates to ()
, indicating success, whereas:
(%which () %fail)
evaluates to #f
, indicating failure.
Note 1: The second subexpression of the %which
-form
is the empty list ()
. Later (sec 2.3),
we will see %which
es
with other lists as the second subform.
Note 2: The distinction between successful and failing goals
depends on Scheme’s distinguishing #f
from
()
. We will see later (sec 2.3.1)
what to do in Scheme dialects where #f
and ()
are
identical. For the moment, we will use the annotation
()true
to signal that ()
is being used as a true
value.
Henceforth, we will use the notation:
E =>F
to say that E
evaluates to F
. Thus,
(%which () %true) =>()true