API for clojure.core.logic - A logic programming library based on miniKanren 0.8.9 (in development)


Full namespace name: clojure.core.logic

Overview





Types



AnswerCache

type

    Fields: [ansl anss _meta]
Protocols: clojure.core.logic.protocols/IAnswerCache
Interfaces: clojure.lang.ILookup, clojure.lang.IObj


Choice

type

    Fields: [a f]
Protocols: clojure.core.logic.protocols/IBind, clojure.core.logic.protocols/IMPlus, clojure.core.logic.protocols/ITake
Interfaces: clojure.lang.ILookup


ConstraintStore

type

    Fields: [km cm cid running]
Protocols: clojure.core.logic.protocols/IConstraintStore
Interfaces: clojure.lang.Counted, clojure.lang.ILookup


LCons

type

    Fields: [a d cache meta]
Protocols: clojure.core.logic.protocols/IBuildTerm, clojure.core.logic.protocols/IOccursCheckTerm, clojure.core.logic.protocols/IReifyTerm, clojure.core.logic.protocols/IUnifyTerms, clojure.core.logic.protocols/IWalkTerm, clojure.core.logic.protocols/LConsPrint, clojure.core.logic.protocols/LConsSeq
Interfaces: clojure.core.logic.protocols.ITreeTerm, clojure.lang.IObj


LVar

type

    Fields: [id unique name oname hash meta]
Protocols: clojure.core.logic.protocols/IBuildTerm, clojure.core.logic.protocols/IOccursCheckTerm, clojure.core.logic.protocols/IReifyTerm, clojure.core.logic.protocols/IUnifyTerms, clojure.core.logic.protocols/IWalkTerm
Interfaces: clojure.core.logic.protocols.IVar, clojure.lang.ILookup, clojure.lang.IObj


PMap

record

    Fields: []
Protocols: clojure.core.logic.protocols/IUnifyTerms, clojure.core.logic.protocols/IUnifyWithRecord, clojure.core.logic.protocols/IUninitialized
Interfaces: clojure.core.logic.protocols.INonStorable, clojure.lang.IHashEq, clojure.lang.IKeywordLookup, clojure.lang.ILookup, clojure.lang.IObj, clojure.lang.IPersistentMap, java.io.Serializable, java.util.Map


Pair

type

    Fields: [lhs rhs]
Protocols:
Interfaces: clojure.lang.Counted, clojure.lang.ILookup, clojure.lang.Indexed, java.util.Map$Entry


SubstValue

record

    Fields: [v doms eset]
Protocols:
Interfaces: clojure.lang.IHashEq, clojure.lang.IKeywordLookup, clojure.lang.ILookup, clojure.lang.IObj, clojure.lang.IPersistentMap, java.io.Serializable, java.util.Map


Substitutions

type

    Fields: [s vs ts cs cq cqs oc _meta]
Protocols: clojure.core.logic.protocols/IBind, clojure.core.logic.protocols/IMPlus, clojure.core.logic.protocols/ISubstitutions, clojure.core.logic.protocols/ISubstitutionsCLP, clojure.core.logic.protocols/ITake
Interfaces: clojure.lang.Associative, clojure.lang.Counted, clojure.lang.ILookup, clojure.lang.IObj, clojure.lang.IPersistentCollection


SuspendedStream

record

    Fields: [cache ansv* f]
Protocols: clojure.core.logic.protocols/ISuspendedStream
Interfaces: clojure.lang.IHashEq, clojure.lang.IKeywordLookup, clojure.lang.ILookup, clojure.lang.IObj, clojure.lang.IPersistentMap, java.io.Serializable, java.util.Map

Public Variables and Functions



!=

function
Usage: (!= u v)
Disequality constraint. Ensures that u and v will never
unify. u and v can be complex terms.
Source


->AnswerCache

function
Usage: (->AnswerCache ansl anss _meta)
Positional factory function for class clojure.core.logic.AnswerCache.
Source


->Choice

function
Usage: (->Choice a f)
Positional factory function for class clojure.core.logic.Choice.
Source


->ConstraintStore

function
Usage: (->ConstraintStore km cm cid running)
Positional factory function for class clojure.core.logic.ConstraintStore.
Source


->LCons

function
Usage: (->LCons a d cache meta)
Positional factory function for class clojure.core.logic.LCons.
Source


->LVar

function
Usage: (->LVar id unique name oname hash meta)
Positional factory function for class clojure.core.logic.LVar.
Source


->PMap

function
Usage: (->PMap)
Positional factory function for class clojure.core.logic.PMap.
Source


->Pair

function
Usage: (->Pair lhs rhs)
Positional factory function for class clojure.core.logic.Pair.
Source


->SubstValue

function
Usage: (->SubstValue v doms eset)
Positional factory function for class clojure.core.logic.SubstValue.
Source


->Substitutions

function
Usage: (->Substitutions s vs ts cs cq cqs oc _meta)
Positional factory function for class clojure.core.logic.Substitutions.
Source


->SuspendedStream

function
Usage: (->SuspendedStream cache ansv* f)
Positional factory function for class clojure.core.logic.SuspendedStream.
Source


==

function
Usage: (== u v)
A goal that attempts to unify terms u and v.
Source


all

macro
Usage: (all)
       (all & goals)
Like fresh but does does not create logic variables.
Source


appendo

function
Usage: (appendo x y z)
A relation where x, y, and z are proper collections,
such that z is x appended to y
Source


conda

macro
Usage: (conda & clauses)
Soft cut. Once the head of a clause has succeeded
all other clauses will be ignored. Non-relational.
Source


conde

macro
Usage: (conde & clauses)
Logical disjunction of the clauses. The first goal in
a clause is considered the head of that clause. Interleaves the
execution of the clauses.
Source


condu

macro
Usage: (condu & clauses)
Committed choice. Once the head (first goal) of a clause
has succeeded, remaining goals of the clause will only
be run once. Non-relational.
Source


conjo

function
Usage: (conjo coll & args)
A constraint version of conj
Source


conso

function
Usage: (conso a d l)
A relation where l is a collection, such that a is the first of l
and d is the rest of l. If ground d must be bound to a proper tail.
Source


copy-term

function
Usage: (copy-term u v)
Copies a term u into v. Non-relational.
Source


defna

macro
Usage: (defna & rest)
Define a soft cut goal. See conda.
Source


defne

macro
Usage: (defne & rest)
Define a goal fn. Supports pattern matching. All
patterns will be tried. See conde.
Source


defnu

macro
Usage: (defnu & rest)
Define a committed choice goal. See condu.
Source


distincto

function
Usage: (distincto l)
A relation which guarantees no element of l will unify
with another element of l.
Source


emptyo

function
Usage: (emptyo a)
A relation where a is the empty list
Source


everyg

function
Usage: (everyg g coll)
A pseudo-relation that takes a coll and ensures that the goal g
succeeds on every element of the collection.
Source


fail

function
Usage: (fail a)
A goal that always fails.
Source


featurec

function
Usage: (featurec x fs)
Ensure that a map contains at least the key-value pairs
in the map fs. fs must be partially instantiated - that is,
it may contain values which are logic variables to support
feature extraction.
Source


firsto

function
Usage: (firsto l a)
A relation where l is a collection, such that a is the first of l
Source


fix-constraints

function
Usage: (fix-constraints a)
A goal to run the constraints in cq until it is empty. Of
course running a constraint may grow cq so this function
finds the fixpoint.
Source


fna

macro
Usage: (fna & rest)
Define an anonymous soft cut goal. See conda.
Source


fnc

macro
Usage: (fnc args & body)
Define an anonymous constraint that can be used with the unifier:

   (let [oddc (fnc [x] (odd? x))]

     (unifier {:a '?a} {:a 1} :when {'?a oddc})
       ;;=> {:a 1}

     (unifier {:a '?a} {:a 2} :when {'?a oddc})
       ;;=> nil
   )

Note, the constraint will not run until all arguments are fully ground.

Use defnc to define a constraint and assign a toplevel var.
Source


fne

macro
Usage: (fne & rest)
Define an anonymous goal fn. Supports pattern matching. All
patterns will be tried. See conde.
Source


fnu

macro
Usage: (fnu & rest)
Define an anonymous committed choice goal. See condu.
Source


fresh

macro
Usage: (fresh [& lvars] & goals)
Creates fresh variables. Goals occuring within form a logical
conjunction.
Source


is

macro
Usage: (is u v op)
Set the value of a var to value of another var with the operation
applied. Non-relational.
Source


lcons

function
Usage: (lcons a d)
Constructs a sequence a with an improper tail d if d is a logic variable.
Source


llist

macro
Usage: (llist f s)
       (llist f s & rest)
Constructs a sequence from 2 or more arguments, with the last argument as the
tail. The tail is improper if the last argument is a logic variable.
Source


log

macro
Usage: (log & s)
Goal for println
Source


lvaro

macro
Usage: (lvaro v)
A goal that succeeds if the argument is fresh. v must be a logic
variable. Non-relational.
Source


map->PMap

function
Usage: (map->PMap m#)
Factory function for class clojure.core.logic.PMap, taking a map of keywords to field values.
Source


map->SubstValue

function
Usage: (map->SubstValue m#)
Factory function for class clojure.core.logic.SubstValue, taking a map of keywords to field values.
Source


map->SuspendedStream

function
Usage: (map->SuspendedStream m#)
Factory function for class clojure.core.logic.SuspendedStream, taking a map of keywords to field values.
Source


master

function
Usage: (master argv cache)
Take the argument to the goal and check that we don't
have an alpha equivalent cached answer term in the cache.
If it doesn't already exist in the cache add the new
answer term.
Source


matcha

macro
Usage: (matcha xs & cs)
Define a soft cut pattern match. See conda.
Source


matche

macro
Usage: (matche xs & cs)
Pattern matching macro. All patterns will be tried.
See conde.
Source


matchu

macro
Usage: (matchu xs & cs)
Define a committed choice goal. See condu.
Source


member1o

function
Usage: (member1o x l)
Like membero but uses to disequality further constraining
the results. For example, if x and l are ground and x occurs
multiple times in l, member1o will succeed only once.
Source


membero

function
Usage: (membero x l)
A relation where l is a collection, such that l contains x.
Source


nafc

function
Usage: (nafc c & args)
EXPERIMENTAL: negation as failure constraint. All arguments to the goal c
must be ground. If some argument is not ground the execution of this constraint
will be delayed.
Source


nilo

function
Usage: (nilo a)
A relation where a is nil
Source


nonlvaro

macro
Usage: (nonlvaro v)
A goal that succeeds if the argument is not fresh. v must be a
logic variable. Non-relational.
Source


partial-map

function
Usage: (partial-map m)
Given map m, returns partial map that unifies with maps even if it
doesn't share all of the keys of that map.
Source


permuteo

function
Usage: (permuteo xl yl)
A relation that will permute xl into the yl. May not
terminate if xl is not ground.
Source


pred

macro
Usage: (pred v f)
Check a predicate against the value logic var. Non-relational.
Source


project

macro
Usage: (project [& vars] & goals)
Extract the values bound to the specified logic vars. Non-relational.
Source


rembero

function
Usage: (rembero x l o)
A relation between l and o where x is removed from
l exactly one time.
Source


resto

function
Usage: (resto l d)
A relation where l is a collection, such that d is the rest of l
Source


run

macro
Usage: (run n bindings & goals)
Executes goals until a maximum of n results are found.
Source


run*

macro
Usage: (run* bindings & goals)
Executes goals until results are exhausted.
Source


run-db

macro
Usage: (run-db n db bindings & goals)
Executes goals until a maximum of n results are found. Uses a specified logic database.
Source


run-db*

macro
Usage: (run-db* db bindings & goals)
Executes goals until results are exhausted. Uses a specified logic database.
Source


run-nc

macro
Usage: (run-nc n bindings & goals)
Executes goals until a maximum of n results are found. Does not
occurs-check.
Source


run-nc*

macro
Usage: (run-nc* & goals)
Executes goals until results are exhausted. Does not occurs-check.
Source


succeed

function
Usage: (succeed a)
A goal that always succeeds.
Source


tabled

macro
Usage: (tabled args & grest)
Macro for defining a tabled goal. Prefer ^:tabled with the
defne/a/u forms over using this directly.
Source


trace-lvars

macro
Usage: (trace-lvars title & lvars)
Goal for tracing the values of logic variables.
Source


trace-s

macro
Usage: (trace-s)
Goal that prints the current substitution
Source


waiting-stream-check

function
Usage: (waiting-stream-check w success-cont failure-cont)
Take a waiting stream, a success continuation, and a failure continuation.
If we don't find any ready suspended streams, invoke the failure continuation.
If we find a ready suspended stream calculate the remainder of the waiting
stream. If we've reached the fixpoint just call the thunk of the suspended
stream, otherwise call mplus on the result of the thunk and the remainder
of the waiting stream. Pass this result to the success contination.
Source

clojure.core.logic.arithmetic





Public Variables and Functions



<

macro
Usage: (< x y)
Goal for testing whether x is less than y. Non-relational.
Source


<=

macro
Usage: (<= x y)
Goal for testing whether x is less than or equal to y.
Non-relational.
Source


=

macro
Usage: (= x y)
Goal for testing whether x and y are equal. Non-relational.
Source


>

macro
Usage: (> x y)
Goal for testing whether x is greater than y. Non-relational.
Source


>=

macro
Usage: (>= x y)
Goal for testing whether x is greater than or equal to y.
Non-relational.
Source

clojure.core.logic.bench





Public Variables and Functions



all-connected-to-allo

function
Usage: (all-connected-to-allo l)
Collect all cliques in l. l must be bounded to ensure
termination.
Source


connected-to-allo

function
Usage: (connected-to-allo v vs)
Ensure that vertex v is connected to all vertices
vs.
Source

clojure.core.logic.fd





Types



FiniteDomain

type

    Fields: [s min max]
Protocols: IInterval, IIntervals, ISet, ISortedDomain, clojure.core.logic.protocols/IMemberCount, clojure.core.logic.protocols/IMergeDomains
Interfaces: clojure.lang.ILookup


IntervalFD

type

    Fields: [lb ub]
Protocols: IInterval, IIntervals, ISet, ISortedDomain, clojure.core.logic.protocols/IMemberCount, clojure.core.logic.protocols/IMergeDomains
Interfaces:


MultiIntervalFD

type

    Fields: [min max is]
Protocols: IInterval, IIntervals, ISet, ISortedDomain, clojure.core.logic.protocols/IMemberCount, clojure.core.logic.protocols/IMergeDomains
Interfaces: clojure.lang.ILookup

Public Variables and Functions



!=

function
Usage: (!= u v)
A finite domain constraint. u and v must not be equal. u and v
must eventually be given domains if vars.
Source


*

function
Usage: (* x y product)
A finite domain constraint for multiplication and
thus division. x, y & product must be eventually be given 
domains if vars.
Source


+

function
Usage: (+ x y sum)
A finite domain constraint for addition and subtraction.
x, y & sum must eventually be given domains if vars.
Source


->FiniteDomain

function
Usage: (->FiniteDomain s min max)
Positional factory function for class clojure.core.logic.fd.FiniteDomain.
Source


->IntervalFD

function
Usage: (->IntervalFD lb ub)
Positional factory function for class clojure.core.logic.fd.IntervalFD.
Source


->MultiIntervalFD

function
Usage: (->MultiIntervalFD min max is)
Positional factory function for class clojure.core.logic.fd.MultiIntervalFD.
Source


-distinctc

function
Usage: (-distinctc x y* n*)
The real *individual* distinct constraint. x is a var that now is bound to
a single value. y* were the non-singleton bound vars that existed at the
construction of the constraint. n* is the set of singleton domain values 
that existed at the construction of the constraint. We use categorize to 
determine the current non-singleton bound vars and singleton vlaues. if x
is in n* or the new singletons we have failed. If not we simply remove 
the value of x from the remaining non-singleton domains bound to vars.
Source


<

function
Usage: (< u v)
A finite domain constraint. u must be less than v. u and v
must eventually be given domains if vars.
Source


<=

function
Usage: (<= u v)
A finite domain constraint. u must be less than or equal to v.
u and v must eventually be given domains if vars.
Source


==

function
Usage: (== u v)
A finite domain constraint. u and v must be equal. u and v must
eventually be given domains if vars.
Source


>

function
Usage: (> u v)
A finite domain constraint. u must be greater than v. u and v
must eventually be given domains if vars.
Source


>=

function
Usage: (>= u v)
A finite domain constraint. u must be greater than or equal to v.
u and v must eventually be given domains if vars.
Source


bounded-listo

function
Usage: (bounded-listo l n)
Ensure that the list l never grows beyond bound n.
n must have been assigned a domain.
Source


distinct

function
Usage: (distinct v*)
A finite domain constraint that will guarantee that 
all vars that occur in v* will be unified with unique 
values. v* need not be ground. Any vars in v* should
eventually be given a domain.
Source


distinctc

function
Usage: (distinctc v*)
The real distinct constraint. v* can be seq of logic vars and
values or it can be a logic var itself. This constraint does not 
run until v* has become ground. When it has become ground we group
v* into a set of logic vars and a sorted set of known singleton 
values. We then construct the individual constraint for each var.
Source


dom

function
Usage: (dom x dom)
Assign a var x a domain.
Source


domain

function
Usage: (domain & args)
Construct a domain for assignment to a var. Arguments should 
be integers given in sorted order. domains may be more efficient 
than intervals when only a few values are possible.
Source


in

macro
Usage: (in & xs-and-dom)
Assign vars to domain. The domain must come last.
Source


interval

function
Usage: (interval ub)
       (interval lb ub)
Construct an interval for an assignment to a var. intervals may
be more efficient that the domain type when the range of possiblities
is large.
Source


process-dom

function
Usage: (process-dom x dom domp)
If x is a var we update its domain. If it's an integer
we check that it's a member of the given domain. dom is
then new domain, it should have already been calculated from
domp which was the previous domain.
Source

clojure.core.logic.nominal





Types



Nom

type

    Fields: [lvar]
Protocols: INomSwap, clojure.core.logic.protocols/IReifyTerm
Interfaces: clojure.core.logic.protocols.IBindable, clojure.lang.ILookup, clojure.lang.IObj


Tie

record

    Fields: [binding-nom body]
Protocols: INomSwap, clojure.core.logic.protocols/IConstrainTree, clojure.core.logic.protocols/IForceAnswerTerm, clojure.core.logic.protocols/IOccursCheckTerm, clojure.core.logic.protocols/IReifyTerm, clojure.core.logic.protocols/IUnifyTerms, clojure.core.logic.protocols/IWalkTerm
Interfaces: clojure.core.logic.protocols.ITreeTerm, clojure.lang.IHashEq, clojure.lang.IKeywordLookup, clojure.lang.ILookup, clojure.lang.IObj, clojure.lang.IPersistentMap, java.io.Serializable, java.util.Map

Public Variables and Functions



->Nom

function
Usage: (->Nom lvar)
Positional factory function for class clojure.core.logic.nominal.Nom.
Source


->Tie

function
Usage: (->Tie binding-nom body)
Positional factory function for class clojure.core.logic.nominal.Tie.
Source


fresh

macro
Usage: (fresh [& noms] & goals)
Creates fresh noms. Goals occuring within form a logical conjunction.
Source


map->Tie

function
Usage: (map->Tie m#)
Factory function for class clojure.core.logic.nominal.Tie, taking a map of keywords to field values.
Source

clojure.core.logic.unifier





Public Variables and Functions



prep

function
Usage: (prep expr)
Prep a quoted expression. All symbols preceded by ? will
be replaced with logic vars.
Source


unifier

function
Usage: (unifier ts)
       (unifier opts ts)
Return the unifier for terms ts. Will prep the terms.
Source


unifier*

function
Usage: (unifier* ts)
       (unifier* opts ts)
Return the unifier that unifies terms ts.
All terms in ts should prepped terms.
Source


unify

function
Usage: (unify ts)
       (unify opts ts)
Unify the terms ts returning a the value that represents their
unificaiton. Will prep the terms.
Source


unify*

function
Usage: (unify* ts)
       (unify* opts ts)
Unify the terms ts.
Source
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.