This section lists, in ascii order, all the Schelog
primitives, with a brief explanation for each. Each entry is
identified
as either *procedure*, *macro*, *predicate*,
*goal*, or *flag*. (Note that predicates and goals are also
procedures. We nevertheless use the more specific names
because of their importance to Schelog programming.)

Following Prolog style, a predicate’s arity is also noted in
its title. Thus, `%<`

/2 means that `%<`

takes two
arguments. Variable-arity predicates use an asterisk
instead of a number, eg, `%and`

/*.

`%/=` /2 | [predicate] |

`%/=`

is the negation of `%=`

.
The goal `(%/= E1 E2)`

succeeds if `E1`

can not be unified
with `E2`

.

`%/==` /2 | [predicate] |

`%/==`

is the negation of `%==`

.
The goal `(%/== E1 E2)`

succeeds if `E1`

and `E2`

are not
identical.

`%<` /2 | [predicate] |

The goal `(%< E1 E2)`

succeeds if `E1`

and `E2`

are bound to
numbers and `E1`

is less than `E2`

.

`%<=` /2 | [predicate] |

The goal `(%<= E1 E2)`

succeeds if `E1`

and `E2`

are bound to
numbers and `E1`

is less than or equal to `E2`

.

`%=` /2 | [predicate] |

The goal `(%= E1 E2)`

succeeds if `E1`

can be unified with
`E2`

. Any resulting bindings for logic variables are kept.

`%=/=` /2 | [predicate] |

The goal `(%=/= E1 E2)`

succeeds if `E1`

and `E2`

are bound to
numbers and `E1`

is not equal to `E2`

.

`%=:=` /2 | [predicate] |

The goal `(%=:= E1 E2)`

succeeds if `E1`

and `E2`

are bound to
numbers and `E1`

is equal to `E2`

.

`%==` /2 | [predicate] |

The goal `(%== E1 E2)`

succeeds if `E1`

is *identical*
to `E2`

. They should be structurally equal. If containing
logic variables, they should have the same variables in the
same position. Unlike a `%=`

-call, this goal will not bind
any logic variables.

`%>` /2 | [predicate] |

The goal `(%> E1 E2)`

succeeds if `E1`

and `E2`

are bound to
numbers and `E1`

is greater than `E2`

.

`%>=` /2 | [predicate] |

The goal `(%>= E1 E2)`

succeeds if `E1`

and `E2`

are bound to
numbers and `E1`

is greater than or equal to `E2`

.

`%and` /* | [macro] |

The goal `(%and G ...)`

succeeds if all the goals
`G`

, ..., succeed.

`%append` /3 | [predicate] |

The goal `(%append E1 E2 E3)`

succeeds if `E3`

is unifiable
with the list obtained by appending `E1`

and `E2`

`%assert` | [macro] |

The form `(%assert Pname (V ...) C ...)`

adds the clauses
`C`

, ..., to the *end* of the predicate that is the value of
the Scheme variable `Pname`

. The variables `V`

, ..., are
local logic variables for `C`

, ...

`%assert‑a` | [macro] |

Like `%assert`

, but adds the new clauses to the *front*
of the existing predicate.

`%bag‑of` /3 | [predicate] |

The goal `(%bag‑of E1 G E2)`

unifies with `E2`

the *bag*
(multiset)
of all the
instantiations of `E1`

for which goal `G`

succeeds.

`%bag‑of‑1` /3 | [predicate] |

Similar to `%bag‑of`

, but fails if the bag is empty.

`%compound` /1 | [predicate] |

The goal `(%compound E)`

succeeds if `E`

is a non-atomic
structure, ie, a vector or a list.

`%constant` /1 | [predicate] |

The goal `(%compound E)`

succeeds if `E`

is an atomic
structure, ie, not a vector or a list.

`%copy` /2 | [predicate] |

The goal `(%copy F S)`

unifies with `S`

a copy of the
frozen structure in `F`

.

`%empty‑rel` /* | [predicate] |

The goal `(%empty‑rel E ...)`

always fails. The *value*
`%empty‑rel`

is used as a starting value for predicates
that can later be enhanced with `%assert`

and `%assert‑a`

.

`%fail` | [goal] |

The goal `%fail`

always fails.

`%free‑vars` | [macro] |

The form `(%free‑vars (V ...) G)`

identifies
the occurrences of the variables `V`

, ..., in goal
`G`

as free. It is used to avoid existential quantification
in calls to set predicates (`%bag‑of`

, `%set‑of`

, &c.).

`%freeze` /2 | [predicate] |

The goal `(%freeze S F)`

unifies with `F`

a new frozen
version of the structure in `S`

. Freezing implies that all
the unbound variables are preserved. `F`

can henceforth be
used as *bound* object with no fear of its variables
getting bound by unification.

`%if‑then‑else` /3 | [predicate] |

The goal `(%if‑then‑else G1 G2 G3)`

tries `G1`

first: if it
succeeds, tries `G2`

; if not, tries `G3`

.

`%is` /2 | [predicate] |

The goal `(%is E1 E2)`

unifies with `E1`

the result of
evaluating `E2`

as a Scheme expression. `E2`

may contain
logic variables, which are dereferenced automatically.
Fails if `E2`

contains unbound logic variables.
(Note: Unlike other Schelog predicates, `%is`

is implemented
as a macro and not a procedure.)

`%let` | [macro] |

The form `(%let (V ...) E ...)`

introduces `V`

, ..., as
lexically scoped logic variables to be used in `E`

, ...

`%melt` /2 | [predicate] |

The goal `(%melt F S)`

unifies `S`

with the thawed
(original) form of the frozen structure in `F`

.

`%melt‑new` /2 | [predicate] |

The goal `(%melt‑new F S)`

unifies `S`

with a thawed
*copy* of the frozen structure in `F`

. This means
new logic variables are used for unbound logic variables in
`F`

`%member` /2 | [predicate] |

The goal `(%member E1 E2)`

succeeds if `E1`

is a member
of the list in `E2`

.

`%nonvar` /1 | [predicate] |

`%nonvar`

is the negation of `%var`

.
The goal `(%nonvar E)`

succeeds if `E`

is completely
instantiated, ie, it has no unbound variable in it.

`%not` /1 | [predicate] |

The goal `(%not G)`

succeeds if `G`

fails.

`%more` | [procedure] |

The thunk `%more`

produces more instantiations of the
variables in the most recent `%which`

-form that satisfy the
goals in that `%which`

-form. If no more solutions can
be found, `%more`

returns `#f`

.

`%or` /* | [macro] |

The goal `(%or G ...)`

succeeds if one of `G`

, ..., tried
in that order, succeeds.

`%rel` | [macro] |

The form `(%rel (V ...) C ...)`

creates a predicate object.
Each clause `C`

is of the form `[(E ...) G ...]`

, signifying
that the goal created by applying the predicate object to
anything that matches `(E ...)`

is deemed to succeed if all
the goals `G`

, ..., can, in their turn, be shown to succeed.

`%repeat` /0 | [predicate] |

The goal `(%repeat)`

always succeeds (even on retries).
Used for failure-driven loops.

`*schelog‑use‑occurs‑check?*` | [flag] |

If the global flag
`*schelog‑use‑occurs‑check?*`

is false (the default),
Schelog’s unification will not use the occurs check.
If it is true, the occurs check is enabled.

`%set‑of` /3 | [predicate] |

The goal `(%set‑of E1 G E2)`

unifies with `E2`

the *set*
of all the
instantiations of `E1`

for which goal `G`

succeeds.

`%set‑of‑1` /3 | [predicate] |

Similar to `%set‑of`

, but fails if the set is empty.

`%true` | [goal] |

The goal `%true`

succeeds. Fails on retry.

`%var` /1 | [predicate] |

The goal `(%var E)`

succeeds if `E`

is not completely
instantiated, ie, it has at least one unbound variable in
it.

`%which` | [macro] |

The form `(%which (V ...) G ...)`

returns an instantiation
of the variables `V`

, ..., that satisfies all of `G`

,
... If `G`

, ..., cannot be satisfied, returns `#f`

.
Calling the thunk `%more`

produces more
instantiations, if available.

`_` (underscore) | [procedure] |

A thunk that produces a new logic variable. Can be
used in situations where we want a logic variable but
don’t want to name it. (`%let`

, in contrast, introduces new
lexical names for the logic variables it creates.)