API for datalog - clojure-contrib v1.3 (in development)

by Jeffrey Straszheim

clojure-contrib is now deprecated

clojure-contrib is no longer being developed or maintained.

Rather than a single, monolithic, contributions library, Clojure now has a set of separate libraries for each unit of functionality. The libraries are in the Clojure GitHub organization at https://github.com/clojure. API documentation of the libraries can be found at https://clojure.github.io.

If you're looking for a specific function or namespace from the old clojure-contrib, see "Where Did Clojure.Contrib Go".


Full namespace name: clojure.contrib.datalog

Overview

A Clojure implementation of Datalog

Related documentation:
An Overview of Datalog

Public Variables and Functions



build-work-plan

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (build-work-plan rules query)
Given a list of rules and a query, build a work plan that can be
used to execute the query.
Source


run-work-plan

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (run-work-plan work-plan database query-bindings)
Given a work plan, a database, and some query bindings, run the
work plan and return the results.
Source

datalog.database






add-index

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (add-index db name key)
Adds an index to an empty relation named name
Source

add-relation

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (add-relation db name keys)
Adds a relation to the database
Source

add-tuple

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (add-tuple db rel-name tuple)
       (add-tuple rel tuple)
Two forms:

[db relation-name tuple] adds tuple to the named relation.  Returns
the new database.

[rel tuple] adds to the relation object.  Returns the new relation.
Source

add-tuples

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (add-tuples db & tupls)
Adds a collection of tuples to the db, as
(add-tuples db
   [:rel-name :key-1 1 :key-2 2]
   [:rel-name :key-1 2 :key-2 3])
Source

any-match?

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (any-match? db rn pt)
Finds if there are any matching records for the partial tuple
Source

database-counts

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (database-counts db)
Returns a map with the count of elements in each relation.
Source

database-merge

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (database-merge dbs)
Merges databases together
Source

database-merge-parallel

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (database-merge-parallel dbs)
Merges databases together in parallel
Source

datalog-relation

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (datalog-relation schema data indexes)
Creates a relation
Source

ensure-relation

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (ensure-relation db name keys indexes)
If the database lacks the named relation, add it
Source

get-relation

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (get-relation db rel-name)
Get a relation object by name
Source

make-database

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (make-database & commands)
Makes a database, like this
(make-database
  (relation :fred [:mary :sue])
  (index :fred :mary)
  (relation :sally [:jen :becky])
  (index :sally :jen)
  (index :sally :becky))
Source

merge-relations

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (merge-relations r1 r2)
Merges two relations
Source

remove-tuple

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (remove-tuple db rel-name tuple)
       (remove-tuple rel tuple)
Two forms:

[db relation-name tuple] removes the tuple from the named relation,
returns a new database.

[rel tuple] removes the tuple from the relation.  Returns the new
relation.
Source

replace-relation

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (replace-relation db rel-name rel)
Add or replace a fully constructed relation object to the database.
Source

select

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (select db rn pt)
finds all matching tuples to the partial tuple (pt) in the relation named (rn)
Source

datalog.literals






build-atom

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (build-atom f type)
Returns an unevaluated expression (to be used in a macro) of an
atom.
Source

build-seed-bindings

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (build-seed-bindings s)
Given a seed literal, already adorned and in magic form, convert
its bound constants to new variables.
Source

delta-literal

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (delta-literal l)
Given a literal l, return a delta version
Source

get-adorned-bindings

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (get-adorned-bindings pred)
Get the bindings from this adorned literal.
Source

get-base-predicate

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (get-base-predicate pred)
Get the base predicate from this predicate.
Source

literal-magic?

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (literal-magic? lit)
Is this literal magic?
Source

magic-literal

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (magic-literal l)
Create a magic version of this adorned predicate.
Source

negated-literal

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (negated-literal l)
Given a literal l, return a negated version
Source

negated?

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (negated? l)
Is this literal a negated literal?
Source

positive?

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (positive? l)
Is this a positive literal?
Source

project-literal

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (project-literal db lit bs)
       (project-literal db lit bs var?)
Project a stream of bindings onto a literal/relation. Returns a new
db.
Source

datalog.magic






adorn-query

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (adorn-query q)
Adorn a query
Source

adorn-rules-set

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (adorn-rules-set rs q)
Adorns the given rules-set for the given query.  (rs) is a
rules-set, (q) is an adorned query.
Source

build-partial-tuple

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (build-partial-tuple q bindings)
Given a query and a set of bindings, build a partial tuple needed
to extract the relation from the database.
Source

magic-transform

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (magic-transform rs)
       (magic-transform rs i-preds)
Return a magic transformation of an adorned rules-set (rs).  The
(i-preds) are the predicates of the intension database.  These
default to the predicates within the rules-set.
Source

seed-predicate-for-insertion

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (seed-predicate-for-insertion q)
Given a query, return the predicate to use for database insertion.
Source

seed-relation

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (seed-relation q)
Given a magic form of a query, give back the literal form of its seed
relation
Source

seed-rule

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (seed-rule q)
Given an adorned query, give back its seed rule
Source

datalog.rules






<-

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (<- hd & body)
Build a datalog rule.  Like this:

(<- (:head :x ?x :y ?y) (:body-1 :x ?x :y ?y) (:body-2 :z ?z) (not! :body-3 :x ?x) (if > ?y ?z))
Source

?-

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (?- & q)
Define a datalog query
Source

all-predicates

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (all-predicates rs)
Given a rules-set, return all defined predicates
Source

apply-rule

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (apply-rule db rule)
       (apply-rule db-1 db-2 rule)
Apply the rule against db-1, adding the results to the appropriate
relation in db-2.  The relation will be created if needed.
Source

compute-sip

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (compute-sip bindings i-preds rule)
Given a set of bound column names, return an adorned sip for this
rule.  A set of intensional predicates should be provided to
determine what should be adorned.
Source

display-query

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (display-query query)
Return a query in a readable format.
Source

display-rule

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (display-rule rule)
Return the rule in a readable format.
Source

is-safe?

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (is-safe? rule)
Is the rule safe according to the datalog protocol?
Source

make-rules-set

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (make-rules-set rs)
Given an existing set of rules, make it a 'rules-set' for
printing.
Source

non-base-rules

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (non-base-rules rs)
Return a collection of rules that depend, somehow, on other rules
Source

predicate-map

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (predicate-map rs)
Given a rules-set, return a map of rules keyed by their predicates.
Each value will be a set of rules.
Source

return-rule-data

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (return-rule-data rule)
Returns an untypted rule that will be fully printed
Source

rules-set

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (rules-set & rules)
Given a collection of rules return a rules set
Source

datalog.softstrat






build-soft-strat-work-plan

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (build-soft-strat-work-plan rs q)
Return a work plan for the given rules-set and query
Source

get-all-relations

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (get-all-relations ws)
Return a set of all relation names defined in this workplan
Source

datalog.util






is-query-var?

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (is-query-var? sym)
Is this a query variable: e.g. a symbol prefixed with ??
Source

is-var?

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (is-var? sym)
Is this a logic variable: e.g. a symbol prefixed with a ?
Source

keys-to-vals

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (keys-to-vals m ks)
Given a map and a collection of keys, return the collection of vals
Source

map-values

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (map-values f hash)
Like map, but works over the values of a hash map
Source

preduce

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (preduce f data)
Similar to merge-with, but the contents of each key are merged in
parallel using f.

f - a function of 2 arguments.
data - a collection of hashes.
Source

reverse-map

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (reverse-map m)
Reverse the keys/values of a map
Source

trace-datalog

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (trace-datalog & body)
If *test-datalog* is set to true, run the enclosed commands
Source
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.