damp.ekeko.logic documentation

Auxiliary logic goals, most of which are currently non-relational.

contains|iteratorbased

(contains|iteratorbased ?c ?e)
Same as contains|memberbased/2, but uses iterators to obtain the elements of c.
It is therefore not implemented in terms of membero/2.

contains|memberbased

(contains|memberbased ?c ?e)
Relation between a collection (seq c) and one of its elements e.

equals

macro

(equals lvar exp)
Non-relational. Projects all logic variables on the right-hand side
that start with a question mark (e.g., ?x), evaluates the resulting
Clojure expression and unifies the result with the left hand-side. 

equals-without-exception

macro

(equals-without-exception lvar exp)
Like equals/2, but catches Exception thrown by exp.
Fails if an exception is thrown.

fails

macro

(fails goal)
Succeeds if argument fails. Implements negation as failure.

findall

macro

(findall var goal solutionseq)
Crude approximation of Prolog's findall.
To be improved.

Introduces the first argument as a fresh var
into the lexical scope of the second one. 

Unifies third argment with a clojure vector 
of bindings for the first argument (expected to be a var) 
found in all solutions to the second argument (expected to be a goal).

Examples:
- vector of members within each type declaration:
(ekeko*
  [?t ?members] 
  (ast :TypeDeclaration ?t)
  (findall ?name
           (child :bodyDeclarations ?t ?name)
           ?members))

 - empty vector for each type declaration:
 (ekeko*
   [?t ?nosolutions] 
   (ast :TypeDeclaration ?t)
   (findall ?x
            (all (== 1 2) (== 2 3))
            ?nosolutions))

one

(one g)
If g succeeds, succeeds once.

perform

macro

(perform exp)
Non-relational. Projects all logic variables on the right-hand side
that start with a question mark (e.g., ?x) and evaluates the resulting
Clojure expression.

See also: 
equals/2 if the value of the expression is needed.
suceeds/2 if the expressions should evaluate to true.

same-elements

(same-elements ?col1 ?col2)
Non-relational. Checks whether the two _fully ground_ collections contain the same elements (set equality).

succeeds

macro

(succeeds exp)
Non-relational. Projects all logic variables on the right-hand side
that start with a question mark (e.g., ?x) and verifies that 
the resulting Clojure expression evaluates to true.

succeeds-without-exception

macro

(succeeds-without-exception exp)
Like succeeds/2, but catches Exception thrown by exp.
Fails if an exception is thrown.

v+

macro

(v+ v)
Non-relational. Verifies that logic variable v is ground.

v-

macro

(v- v)
Non-relational. Verifies that logic variable v is not ground.