Diving into logic programming
In Clojure, logic programming can be done using the
core.logic
library (https://github.com/clojure/core.logic/). This library is a port of miniKanren, which is a domain-specific language for logic programming. miniKanren defines a set of simple constructs for creating logical relations and generating results from them.
Note
miniKanren was originally implemented in the Scheme programming language. You can find out more about miniKanren at http://minikanren.org/.
A program written using logic programming can be thought of as a set of logical relations. Logical relations are the elementary building blocks of logic programming, just as functions are for functional programming. The terms relation and constraint are used interchangeably to refer to a logical relation. The core.logic
library is in fact an implementation of constraint-based logic programming.
A relation can be thought of as a function that returns a goal, and a goal can either be a success or a failure...