Fork me on GitHub

miniKanren.org

Twitter: @miniKanren    Github: @miniKanren    Google Group: miniKanren    IRC: irc.freenode.net, #minikanren


Book | Implementations | Projects | Upcoming Talks | Talks | Interviews | Tutorials | Theses | Papers | Screencasts | Weekly Hangouts | Podcasts | Blogs | Contact

What is miniKanren?

miniKanren is an embedded Domain Specific Language for logic programming.

The core miniKanren language is very simple, with only three logical operators and one interface operator.

miniKanren has been implemented in a growing number of host languages, including Scheme, Racket, Clojure, Haskell, Python, and Ruby.

miniKanren is designed to be easily modified and extended; extensions include Constraint Logic Programming,
probabilistic logic programming, nominal logic programming, and tabling.

The Book

Daniel P. Friedman, William E. Byrd and Oleg Kiselyov
The Reasoned Schemer
The MIT Press, Cambridge, MA, 2005

source code from the book

The Reasoned Schemer front cover

Implementations

Scheme

miniKanren

microKanren
A minimal miniKanren implementation, as described in the 2013 Scheme Workshop paper.

alphaKanren
miniKanren extended with nominal logic programming, as described in the 2007 Scheme Workshop paper.

rKanren
miniKanren with guided search, as described in the 2013 Scheme Workshop paper.

slpKanren
Stochastic Logic Programs (SLP) style probabilistic logic programming in miniKanren.

sokuza-kanren
Oleg Kiselyov's minimal implementation of logic programming.

Racket

cKanren
miniKanren extended with Constraint Logic Programming (CLP); an improved version of the system described in the 2011 Scheme Workshop paper.

vanilla miniKanren Racket port

Clojure

core.logic

pldb (persistent logic database for clojure core.logic)

(core.logic cheatsheet, courtesy of Benjamin Peter)

async-mu-kanren

Common Lisp

cl-kanren-trs

Kanren-Fset (Fset collection library support for cl-kanren-trs)

Haskell

Molog

HaskellKanren (HK)

MiniKanrenT

featherweight

Scala

scalogno

minikanren-scala

Python

pykanren

pythological

LogPy

Adderall

Ruby

mini_kanren

micro_kanren

Lua

lua-ukanren

C#

csharp_ukanren

JavaScript

microJSKanren

lolkanren

jolic

uKanren

microKanren

CoffeeScript

Friebyrd

PHP

reasoned-php

php-microKanren

Erlang

erlKanren

lolkanren_erlang

mukanren

OCaml

minikanren-ocaml

Groovy

groovy-logic

Mímir experimental rules engine

mímirKanren

Elixir

ExKanren

Go

gologic

Projects using miniKanren or core.logic

core.logic

expresso
A clojure library for symbolic manipulation of Algebraic Expressions.
tutorial
blog post

webdriver-logic
Logic programming API for testing web applications using clj-webdriver.
Clojure/conj 2012 talk

damp.ekeko
Ekeko enables querying and manipulating an Eclipse workspace using applicative logic programs.
anouncement
screencast

damp.qwal
QWAL is a path expression library to allow querying graphlike structures using core.logic in Clojure.

damp.qwalkeko
Scrape and reason over Java projects stored on git.

peano
Using logic programming (Clojure's core.logic) for test data manipulation and generation.

kibit
kibit is a static code analyzer for Clojure which uses core.logic to search for patterns of code for which there might exist a more idiomatic function or macro.

parsing-packet-with-logic
A small experiment in parsing packets in a style similar to Erlang's <<...>> using core.logic.

maze.logic
Solving mazes using core.logic.

Janus: Consumer-driven Contracts and Mocks
Consumer-driven contracts using core.logic.

Monotony
Monotony is a solution to the problem of how to schedule things in a way that humans find intuitive.

QWAL
QWAL is a path expression library to allow querying graphlike structures using core.logic in Clojure.

FunnyQT
FunnyQT is a model querying and transformation library.

symbol
symbol is a compiler of a subset of Clojure syntax to C++.

guzheng
guzheng is a library for doing branch coverage analysis of Clojure code.

Adventure in Clojure core.logic
Text adventure game in core.logic.

The core.logic wiki also has links to projects using core.logic.

Upcoming Talks

William E. Byrd and Daniel P. Friedman
Program Synthesis Using miniKanren
Strange Loop, St. Louis, September 17, 2014.

Jason Hemann and Dan Friedman
Write the Other Half of Your Program: From Functional to Logic Programming
Strange Loop, St. Louis, September 18, 2014.

Recorded Talks

miniKanren

William E. Byrd
Relational Programming in miniKanren, Part 1 and Part 2
Logic Night
Lambda Lounge Utah, Sandy, UT, May 13, 2014.

Daniel P. Friedman and William E. Byrd
A Relational Exploration of the Chomsky Hierarchy
Strange Loop, St. Louis, September, 2013.

William E. Byrd and Daniel P. Friedman
Fun with Relational Interpreters in miniKanren
flatmap 2013, Oslo, Norway, May 14, 2013 (keynote).

William E. Byrd and Daniel P. Friedman
miniKanren Philosophy
Clojure/conj 2012, Raleigh, NC, November 16, 2012.
(Beware the pink tint!)

Daniel P. Friedman and William E. Byrd
Relational Programming in miniKanren
Strange Loop 2012, St. Louis, MO, September 24, 2012
source code

Daniel P. Friedman and William E. Byrd
miniKanren "untalk"
Clojure/conj 2011, Raleigh, NC, November 10, 2011.

core.logic

Nada Amin and William E. Byrd
From Greek to Clojure
Clojure/conj, Alexandria, VA, November 14, 2013
source code | slides

Craig Brozefsky
Core.logic and SQL Killed my ORM
Clojure/West 2013, Portland, OR, March 19th, 2013.

David Nolen
The Refined Clojurist
Clojure Exchange 2012, London, December 6, 2012

Daniel Gregoire
Web Testing with Logic Programming
Clojure/conj 2012, Raleigh, NC, November 17, 2012.
webdriver-logic project

Steve Miner
Challenges for Logic Programming
Clojure/conj 2012, Raleigh, NC, November 17, 2012.

Edmund Jackson
An Introduction to Logic Programming on the JVM with core.logic (Clojure)
FP Days 2012, Cambridge, October 25, 2012

David Nolen
core.logic: A tutorial reconstruction ("unsession")
Strange Loop 2012, St. Louis, MO, September 24, 2012

Edmund Jackson
core.logic.intro
EuroClojure 2012, London, May 24, 2012
source code

Ryan Senior
Practical core.logic
Clojure/West 2012, San Jose, March 17, 2012

Ambrose Bonnaire-Sergeant
Introduction to Logic Programming with Clojure
Clojure/conj 2011, Raleigh, NC, November 10, 2011.

ClojureScript & core.logic

Adam Solove
Constraint programming in the browser
(Talk focuses on the Cassowary constraint solver for GUI layout, but also discusses core.logic.)
JSConf US, Amelia Island, FL, May 31, 2013

Clojure/West miniKanren confo, Portland, OR, March 19, 2013 (associated with Clojure/West)

Gabriel Pickard
Logic programming in the wild (video not posted yet)

Ryan Senior
Intro to CLP with core.logic

Adam Foltzer
Molog: Typed Functional Logic Programming in Haskell
source code

David Nolen
The Architecture of core.logic

Nada Amin
core.logic.nominal (video not posted yet)
source code

William E. Byrd and Daniel P. Friedman
The Unreasonable Schemers (video not posted yet)
source code

Interviews

William E. Byrd
William Byrd on Logic and Relational Programming, miniKanren
Recorded by InfoQ at Code Mesh 2013, London, England, December, 2013

Written Tutorials

core.logic

Introduction to Logic Programming with Clojure

A Core.logic Primer

Logic Programming for the Social Web

Theses

PhD

William E. Byrd
Relational Programming in miniKanren: Techniques, Applications, and Implementations.
Indiana University, Bloomington, IN,
September 30, 2009.

Masters

Wheeler, Kaylen FJ
Representing Game Dialogue as Expressions in First-Order Logic
University of Western Ontario, London, Ontario, Canada, 2013.

Undergraduate Honors

Ramana Kumar
Mechanising Aspects of miniKanren in HOL
Australian National University, Canberra, Australian Capital Territory, Australia,
May 2010.

Papers

Erik Wennstrom
Tableau-Based Model Generation for Relational Syllogistic Logics.
In Proceedings of the 2014 International Symposium on Artificial Intelligence and Mathematics (ISAIM 2014), Fort Lauderdale, FL, January, 2014.

Jason Hemann and Daniel P. Friedman. 
microKanren: A Minimal Functional Core for Relational Programming.
In Proceedings of the 2013 Workshop on Scheme and Functional Programming (Scheme '13), Alexandria, VA, 2013.
Complete source code (Scheme)

Cameron Swords and Daniel P. Friedman. 
rKanren: Guided Search in miniKanren.
In Proceedings of the 2013 Workshop on Scheme and Functional Programming (Scheme '13), Alexandria, VA, 2013.
Complete source code (Scheme)

William E. Byrd, Eric Holk, and Daniel P. Friedman.
miniKanren, Live and Untagged: Quine Generation via Relational Interpreters (Programming Pearl).
To appear in the Proceedings of the 2012 Workshop on Scheme and Functional Programming, Copenhagen, Denmark, 2012.
Complete source code (Scheme)

Claire E. Alvis, Jeremiah J. Willcock, Kyle M. Carter, William E. Byrd, and Daniel P. Friedman. 
cKanren: miniKanren with Constraints.
In Proceedings of the 2011 Workshop on Scheme and Functional Programming (Scheme '11), Portland, OR, 2011.
Complete source code (R6RS Scheme)

Ramana Kumar and Michael Norrish
(Nominal) unification by recursive descent with triangular substitutions
In Proceedings of the First international conference on Interactive Theorem Proving (ITP'10),
Springer-Verlag Berlin, pp. 51-66, 2010.

Andrew W. Keep, Michael D. Adams, Lindsey Kuper, William E. Byrd, and Daniel P. Friedman.
A Pattern-matcher for miniKanren -or- How to Get into Trouble with CPS Macros.
In Proceedings of the 2009 Workshop on Scheme and Functional Programming,
Cal Poly Technical Report CPSLO-CSC-09-03, pp. 37-45, 2009.

Joseph P. Near, William E. Byrd and Daniel P. Friedman.
alphaleanTAP: A Declarative Theorem Prover for First-Order Classical Logic.
In Proceedings of the 24th International Conference on Logic Programming (ICLP 2008),
LNCS vol. 5366, Springer-Verlag, Heidelberg, pp. 238-252, 2008.
Complete source code--R6RS Scheme and Prolog (.zip file)

Oleg Kiselyov, William E. Byrd, Daniel P. Friedman and Chung-chieh Shan
Pure, declarative, and constructive arithmetic relations (declarative pearl).
In Proceedings of the 9th International Symposium on Functional and Logic Programming,
ed. Jacques Garrigue and Manuel Hermenegildo, pp. 64-80.
LNCS vol. 4989, Springer, 2008.

William E. Byrd and Daniel P. Friedman 
alphaKanren: A Fresh Name in Nominal Logic Programming.
In Proceedings of the 2007 Workshop on Scheme and Functional Programming,
Universite Laval Technical Report DIUL-RT-0701, pp. 79-90.
Authors' revised version (recommended)
Revised source code (R5RS Scheme)

William E. Byrd and Daniel P. Friedman
From Variadic Functions to Variadic Relations: A miniKanren Perspective.
In Proceedings of the 2006 Scheme and Functional Programming Workshop,
University of Chicago Technical Report TR-2006-06, 2006, pp. 105-117.

Oleg Kiselyov, Chung-chieh Shan, Daniel P. Friedman, and Amr Sabry
Backtracking, interleaving, and terminating monad transformers: (functional pearl).
In Proceedings of the 10th ACM SIGPLAN International Conference on Functional Programming (ICFP '05),
ACM Press, New York, pp. 192-203, 2005.

Screencasts

Thomas G. Kristensen

Composing music using core.logic and Overtone - The Composing Schemer
blog post
source code
January 2013.

Timothy Baldridge

Clojure Core.Logic With Custom Data Sources
October 25, 2013.

Bytecode Assembler in Core.Logic
related blog post
Dec 13, 2012.

Coen De Roover

Getting started querying an Eclipse workspace using Ekeko
ekeko project
August 14, 2012.

Weekly Google Hangout on Air

Upcoming Hangouts

To be announced.

Previous Hangouts

Hangout #13, Sunday, June 30.
Topic: Claire shows off a new macro for defining constraints using attributed variables, a new version of the matche pattern matching macro, and the implementation of templateo (declarative copy_term) (URL). Norman demos his code for solving nonogrids problems. Will talks about CPSing miniKanren programs.

Hangout #12, Sunday, June 23, 2013.
Topic: Gary shows off his CLP(FD) program to layout
2D figures; Will describes the new, apparently fixed templateo constraint, and explains how it is used in a relational term reducer for the untyped lambda-calculus.

Hangout #11, Sunday, June 9, 2013.
Topic: Unexpected memory usage in conde, and how to fix it in CLP(FD); meta-interpreters in miniKanren (code); what do you need to know to use miniKanren effectively?; Will's new book on miniKanren (in progress).

Hangout #10, Sunday, June 2, 2013.
Topic: We discuss CLP(Set) and declarative copy_term (a.k.a., templateo) (code). Lindsey shows off LVish (code). David poses a core.logic puzzle. Dan and Jason discuss miniC, a minimal miniKanren without macros. Will shows off a relational lambda calculus reducer (code).

Hangout #9, Sunday, May 19, 2013.
Topic: Will shows off a meta-circular interpreter for miniKanren (code), and describes the outline for a new book he is writing on relational programming (book).

Hangout #8, Sunday, May 5, 2013.
Topic: Dan and Jason show off a cool way to implement mutual recursion in an interpreter. Will and the gang then live-code a relational interpreter for general Deterministic Finite Automata (code).

Hangout #7, Sunday, April 28, 2013.
Topic: Translating simple Scheme functions to miniKanren using correctness-preserving transformations.

Hangout #6, Sunday, April 21, 2013.
Topic: Live coding/real-time solution of a simple problem solved by Michael. Also, Claire discusses new features of cKanren in Racket.

Hangout #5, Sunday, April 14, 2013.
Topic: Stump the Chump! Will partially translates miniKanren's unify function from Scheme into miniKanren (code). Also, discussion of extra-logical operators, and new miniKanren features in progress: CLP(Set), constraint handling rules, lazy constraints for recursion.

Hangout #4, Sunday, April 7, 2013.
Topic: Debugging miniKanren programs; Constraint Logic Programming over sets (based on the paper Sets and Constraint Logic Programming by Dovier, et al., 2000).

Hangout #3, Sunday, March 31, 2013.
Implementation of simplified miniKanren (source code).

Hangout #2, March 24, 2013.
Implementing disequality constraints, absento/presento constraints, miniKanren Confo at Clojure/West, relational CESK machine.

Hangout #1, March 10, 2013.
A little miniKanren history, what it means to be relational, a relational variant of copy-term, debugging miniKanren programs.

Podcasts

Mostly lazy... a Clojure podcast
Episode 9 with Kevin Lynagh and Paul deGrandis: web dev ennui, CRDTs, and core.logic
Recorded December 14th, 2012.

Blogs

David Nolen - dosync

STLC Redux: Part II
Logic Programming is Underrated
The Simply Typed Lambda Calculus in 20 Lines Redux

From David Nolen's old blog (courtesy of the Internet Archive's Wayback Machine):

Know Your Bounds
friendlier
sudoku
A Logic Programming Reading List
Logic Programming & JavaScript
core.logic & VPRI STEPS
Another Taste of cKanren
A Taste of cKanren
Simple Type Inference For The Simply Typed Lambda Calculus in ~20 Lines
Logos -> core.logic
Crazy Ideas
Fun
Spring Cleaning
Simple Constraints
~2.1ms
Tabling in Logos
Pattern Matching
Finally ... a clue
Performance Matters
Faster Unification
Logic Programming and Performance
A Short Break
Life Without Tail Call Optimization
Announcing Logos
A miniKanren introduction via Clojure

Clojure & lx

Another Logic Programming Reading List
lx in core.logic #3: Finite State Transducers
lx in core.logic #2: Jumps, Flexible Transitions and Parsing
Finite State Machines in core.logic

Timothy Baldridge - (apply clojure @life)

Bytecode Assembler in Core.Logic
Byte Packing with core.logic

Thomas G. Kristensen - Clojure/tgk

Parsing packets Erlang style using core.logic
The Composing Schemer
Finding cliques in graphs using core.logic
Maximum cliques algorithm in Clojure

Edmund Jackson - boss level

mini-Sudoku in mini-Kanren (in Clojure-"ish")
Logic Programming Part 3 (List Logic)
Logic Programming Part 2 (Building Blocks)
Logic Programming Part 1

clojure.com - Clojure/core (posts by Stuart Sierra)

Lojic Part Two
Lojic Part One

Jim Duey - A Clojure Story

Building Trees
Meta Machinations
Build An Arrow
Meta Machinations
Arrowed Core.logic
More Core.logic
Messin With Core.logic

Christophe Grand - Clojure and me

Fair conjunction: status report
The Reasoned Scheduler

Ryan Senior - Object Commando

The Magical Island of Kanren - core.logic Intro Part 1
Appendo the Great

Martin Trojer

Some core.logic graph code
cKanren time!
Replicating Datomic/Datalog queries with core.logic, take 2
Replicating Datomic/Datalog queries with core.logic, take 1
N-Queens with core.logic, take 2
N-Queens with core.logic, take 1

Atomic Object - Atomic Spin

miniKanren in Haskell
The First Time Programming Scared Me

Kris Jenkins

Solving Logic Puzzles With Clojure's Core Logic, Part Two
Solving Logic Puzzles With Clojure's Core Logic, Part One

Brian Taylor

PPfAI Chapter 2 (in Clojure Core.Logic)
PPfAI Chapter 1 in Clojure Core.Logic

Paul Callaghan - PragPub Magazine

Unification: It's Not Just for Prolog

Lindsey Kuper

Generating tautologies with miniKanren

Michael R. Bernstein

A Nice Feature in core.logic and Thoughts About A Data Structure

Julia Evans

Day 31: Binary trees with core.logic!

Maria Pacana

MiniKanren

Meikel Brandmeyer

A field trip into logic programming

Tassilo Horn

Using Clojure's core.logic with custom data structures

Cameron Swords

rKanren: Guided Search in miniKanren, Part 1

Tim Yates

Using Clojure and core.logic from Groovy

Peteris Erins

Temporal logic programming in Clojure core.logic

Malcolm Sparks

Transitive relations in core.logic

Alexander Zolotko

Getting my feet wet with Clojure's core.logic

Jamie Brandon

Search trees and core.logic

Sam Neubardt - coderwall

Find Elements in a Collection Using core.logic

JR Heard

Explorations in Clojure's core.logic

Contact

This site is maintained by Will Byrd: webyrd@gmail.com.

Thanks to Shantanu Kumar, Martin Trojer, and Gergely Nagy for improving the site by submitting a pull request.