Full-featured logic programming (AKA “Prolog”) embedded in/callable
from and supporting calls to Clojure. In the spirit of LogLisp, Lisp
Machine Prolog, and Franz Inc.’s Allegro Prolog, with some extra
goodies. Emphasis on expressive power and execution transparency,
supporting rapid prototyping, proof-of-concept development, and
outer-loop reasoning (i.e., not real fast, so far).
-
Clojure-based, Lispy (i.e., homoiconic) syntax, e.g., …
(do ;; Set up, clear knowledge base. (initialize-prolog) ;; Create unit assertion. (<- (has-subtype vertebrate mammal)) ;; Execute query. (? ?x ; Answer template (has-subtype vertebrate ?x) ; Goal. ) ) [mammal] ; Answer(s) in vector (perhaps empty).
-
Logical variable- (“?var”)-containing Clojure seqs (so, lists) and
vectors as “complex” terms—in assertion statements and answer templatesClojure calling predicates-
Truthiness check:
truthy?
?var-bearing term unification:evals-from?
Side effect:do
Hello"))) Hello [nil]Access to ?var bindings in Clojure calls—even within quoted
expressions> (do (<-- (male laban)) (? ?y (male ?x) (evals-from? ?y (list '?x)))) [(laban)]
Negation as failure:
not
Facilitated access to Clojure values (evals-from?
shorthand
->?
) in goals with Clojure-calling predicatesBuilt-in term [non-]matching predicates:same
,different
Built-in term inspection predicates:var
,ground
Built-in unconditional predicates:true
,false
Nestable built-in logical operators:
and
,or
,not
,if
“Cut” operator:first
> (do (initialize-prolog) (<- (sister laban rebecca)) (<- (sister rachel leah)) (? [?sibling ?sister] (first (sister ?sibling ?sister)))) [[laban rebecca]]
User-custom predicate transforms, supporting (e.g.)
varieties ofif
,cond
,optional
Full leashing of predicates, including operatorsSign Up to Our Newsletter
Be the first to know the latest updates
Whoops, you're not connected to Mailchimp. You need to enter a valid Mailchimp API key.
-
7 Comments
mark_l_watson
Very cool! I just cloned the repository, will play with it later.
BTW, Clojure was such a brilliant name (from Rich): Whenever I see a project starting with "Clo" I pay attention.
EDIT: had a chance to try it: a very cool resource!
anonzzzies
This is very nice, I played with it before and working on a similar idea in CL (I am one of those people who finds the uniformity of no syntax soothing).
sterlind
really happy to see something of a revival of interest for logic programming lately. it's an extremely powerful tool if you know when to reach for it.
winwang
This might unironically be a reason for me to finally try Clojure!
jan3024-2r
[flagged]
jdminhbg
Can anybody comment on when or why to choose this over core.logic?
cpdean
I absolutely love the aesthetic of a repo having a giant README.md