#proto #relational #logic #language

nightly proto-vulcan

A miniKanren-family relational logic programming language embedded in Rust

2 releases

0.1.1 Sep 15, 2020
0.1.0 Sep 11, 2020

#247 in Embedded development


6.5K SLoC


A miniKanren-family relational logic programming language embedded in Rust.

In addition to core miniKanren language, proto-vulcan currently provides support for:

  • Disequality constraints CLP(Tree)
  • Finite-domain constraints CLP(FD)
  • Various operators: anyo, conda, condu, onceo, project
  • Writing goals in Rust embedded inline within proto-vulcan
  • User extension interface

The language is embedded into Rust with macros which parse the language syntax and convert it into Rust.


extern crate proto_vulcan;
use proto_vulcan::*;

fn main() {
    let query = proto_vulcan_query!(|q| {
        conde {
            q == 1,
            q == 2,
            q == 3,

    for result in query.run() {
        println!("q = {}", result.q);

The example program produces three solutions:

q = 1
q = 2
q = 3

New relations can be defined as Rust-functions using proto_vulcan!-macro.

use proto_vulcan::*;
use proto_vulcan::relation::emptyo;
use proto_vulcan::relation::conso;
use std::rc::Rc;

pub fn appendo<U: UserState>(l: &Rc<LTerm>, s: &Rc<LTerm>, ls: &Rc<LTerm>) -> Rc<dyn Goal<U>> {
    let s = Rc::clone(s);
        conde {
            [s == ls, emptyo(l)],
            |a, d, res| {
                conso(a, d, l),
                conso(a, res, ls),
                closure {
                    appendo(d, s, res)

More examples in documentation.


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~21K SLoC