Questions tagged [minikanren]

KANREN is a declarative logic programming system with first-class relations, embedded in a pure functional subset of Scheme. miniKANREN is a simplified subset of KANREN without many bells, whistles, and optimizations.

KANREN is a declarative logic programming system with first-class relations, embedded in a pure functional subset of Scheme. The system has a set-theoretical semantics, true unions, fair scheduling, first-class relations, lexically-scoped logical variables, depth-first and iterative deepening strategies. The system achieves high performance and expressivity without cuts.

Applications of the system range from expert systems to polymorphic type inference and overloading resolution, to model checking and theorem proving. The system can be used as a meta-logic system.

KANREN works on any computer platform for which a Scheme implementation exists (from PalmPilot and iPAQ to Unix/Linux/Winxx/Mac workstations and servers to MindLego bricks). The system can be compiled or interpreted. Being essentially a Scheme library, KANREN can interact with the user through any graphical or command-line interface provided by the host Scheme implementation.

miniKANREN is a simplified KANREN without many bells, whistles, and optimizations of the full system. The goal of the simplifications was to make miniKANREN easier to explain.

69 questions
3
votes
1 answer

python logic puzzle relationships

Attempting to use Logic to solve the following in python: from kanren import run, eq, membero, var, conde from kanren.constraints import neq, isinstanceo rules = (eq, (var(), var(), var(), var()), people), (membero, (4, x, ('Steve' ,…
3
votes
0 answers

How to implement minikanren 'appendo' in J/APL?

I've been trying hard to implement Minikanren in J,but after making good progress up to lazy streams, conjunction, disjunction, and equivalence constraints, I am now completely stuck on the appendo relation. Specifically, I'd like help (code, books,…
Raoul
  • 1,872
  • 3
  • 26
  • 48
3
votes
1 answer

Simple Prolog to Clojure core.logic

I've been playing with Prolog recently and getting my head around how to represent some tasks I want to do with it, which are largely about having a database of facts and doing simple queries on it, joining multiple facts together. But I want to use…
interstar
  • 26,048
  • 36
  • 112
  • 180
3
votes
1 answer

Correct use of logic languages as a tool

I'm interested in the "use the right tool for the job" philosophy in programming, and I have a problem I thought might be solvable with logic programming. I mean this in a naive way, because I haven't done any logic programming and am just setting…
3
votes
1 answer

Not understanding The Reasoned Schemer Chapter 5 frame 62

I am currently learning miniKanren by learning The Reasoned Schemer. And I am stuck in an exercise in Chapter 5 frame 62: (run* (x) (flatten_o (a) x)), why there are three lists in output?
Chen Wang
  • 771
  • 6
  • 8
3
votes
1 answer

Finding similar sets with clojure's core.logic / minikanren

this is my first question on Stack Overflow. I’m new to logic programming and are trying to evaluate if it can be used to solve some matching problems I’m working on. Problem: Lets say we have a set A that looks like this. A = {1, 2, 3, 4} And then…
3
votes
2 answers

MicroKanren - what are the terms?

Having a little trouble understanding the core terms of the MicroKanren DSL. Section 4 says: Terms of the language are defined by the unify operator. Here, terms of the language consist of variables, objects deemed identical under eqv?, and pairs…
naasking
  • 2,514
  • 1
  • 27
  • 32
3
votes
1 answer

How to match a map that contains lvars?

I am trying to use maps as my data structure and I initialize them to contain lvars to be assigned values later from other relations. This succeeds: (run 1 [q] (fresh [a b] (== q {:a 1 :b 2 :c b}) (featurec q {:a b}))) -> ({:a 1, :b 2, :c…
muhuk
  • 15,777
  • 9
  • 59
  • 98
2
votes
1 answer

Python Kanren Relationships

I am working abit with kanren for logical programming and it is completely new to me. I have understood how to maek relationships, but i want to make relationships with multiple features for example fitting this description: Define a relation food…
2
votes
1 answer

Why does "disj" from miniKanren work in Scheme but not in Racket?

I was working with the minikanren library for Racket, but wanted to use the "disj" and "conj" operators. I want to be able to more explicitly declare whether I am using disj or conj for the sake of legibility rather than have to parse through a…
Flywheel
  • 57
  • 3
2
votes
1 answer

clp(Z) vs. Kiselyov relational arithmetic

I am struggling to understand the difference in functionality between clp(Z) and another relational arithmetic system used in MiniKanren. In particular, clp(Z) apparently applies to bounded fields while Kiselyov et al. is described to apply to…
Raoul
  • 1,872
  • 3
  • 26
  • 48
2
votes
1 answer

Clojure core.logic : nafc and ground

I'm representing a simple data-base in Clojure's core.logic. There are two predicates : page(p) and link(p,q). page(p) represents the existence of pages in a wiki called p link(p,q) represents that page p contains a link to page q. I'm now trying…
interstar
  • 26,048
  • 36
  • 112
  • 180
2
votes
0 answers

In Racket's mini-kanren libraries, where is condi?

The mini-kanren language features four conditional operators: conda, conde, condi and condu (described here). There are two mini-kanren libraries available for Racket that I am aware of (both described here). Neither of them implements condi. My…
Jeffrey Benjamin Brown
  • 3,427
  • 2
  • 28
  • 40
2
votes
2 answers

All possible sublists scheme

I want to find all possible consecutive partitions of a lists: (a b c d) => (((a) (b c d)) ((a b) (c d)) ((a b c) (d)) ((a) (b c) (d)) ((a b c d)) ((a) (b) (c) (d))) What would be the easiest way to go about this? ideally without using…
2
votes
0 answers

miniKanren F# with FSLogic

Well I'm following a tutorial of miniKanren in scheme using FsLogic, but I just got stuck in this example (run 1 (q) (== '(lambda (x) x) '(lambda (x) x))) And I'm writing it in f# like this: run 1 (fun q -> (fun x -> x) *=* (fun x -> x) …
jjchiw
  • 4,375
  • 1
  • 29
  • 30