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
2
votes
1 answer

How should I handle repeated updating in logical programming?

In particular I am trying to determine the best approach to solve the following type of problem: The example I am interested in is the find-s algorithm in Mitchell's Machine Learning book were it is applied to 4 training examples. The basic idea is…
2
votes
0 answers

Detecting Bigamy with minikanren

I am using the LogPy implementation of minikanren. I have some facts about marriages. from logpy import * marriedo=Relation() fact(marriedo,"Bob", "Jane") fact(marriedo,"Greg", "Anne") fact(marriedo,"Bob", "Susan") I can find out someones wife by…
Frames Catherine White
  • 27,368
  • 21
  • 87
  • 137
2
votes
1 answer

Why is this contradictory clojure.core.logic/featurec result being returned?

...and how can I avoid it? (run* [q] (featurec q {:a 1}) (featurec q {:a 2}))) returns ((_0 :- (clojure.core.logic/featurec _0 {:a 2}) (clojure.core.logic/featurec _0 {:a 1}))) which I understand to mean that the _0 map must contain at…
Robert Campbell
  • 6,848
  • 12
  • 63
  • 93
2
votes
0 answers

Why isn't featurec create a contradiction?

This is a contradiction: (run* [q] (== q true) (== q false)) -> () Because there can't be a q that is true and false at the same time. Shouldn't this be a contradiction as well? (run* [q] (featurec q {:k true}) (featurec q {:k false})) …
muhuk
  • 15,777
  • 9
  • 59
  • 98
2
votes
1 answer

Clojure core.logic CLP(FD) projecting FD variables

I'm working on a naive square-packing algorithm using Clojure's core.logic CLP(FD) library (core.logic version 0.8.3). Squares are represented like so: [[[x11 y11] [x12 y12]] [[x21 y21] [x22 y22] ...]] with each square represented as the…
1
vote
0 answers

How can I provide an imperative default for a relation in miniKanren?

(I am using CHICKEN Scheme's miniKanren, but I would appreciate portable answers!) Suppose I have some relation: (define (rel° x) (conde ((pred?° x)) ((== x (my-awesome-imperative-thing))))) The intention is that this relation can allow x…
Corbin
  • 1,530
  • 1
  • 9
  • 19
1
vote
0 answers

How can I gensym when writing a compiler in Kanren?

I'm writing a compiler from an esolang to WebAssembly, using CHICKEN Scheme's miniKanren. My compiler already works somewhat, but I'd like to extend it with support for named local registers and I'm not sure how to proceed. CHICKEN has a gensym with…
Corbin
  • 1,530
  • 1
  • 9
  • 19
1
vote
1 answer

Why does introducing numbero in minikanren cause the failure of valid unifications?

I am using Racket v8.5, with the packages for minikanren and minikanren/numbers required. Why does introducing the numbero constraint cause previously valid unifications to fail? > (run 1 (q) (
jpt4
  • 13
  • 2
1
vote
1 answer

Extracting finite domain lvars from a map

I want to put fresh lvars with a finite domain into a map, and establish a relationship between them in another part of my code. Consider the snippet below: (l/run 1 [q] (l/fresh [x y z a b c] (fd/in x y z (fd/interval 0 100))…
tsuki
  • 907
  • 4
  • 17
1
vote
1 answer

Non-termination when query variable is on a specific position

Consider this blog post where the author implements palindrome relation using reverso: (defn reverso [l r] (conde [(== l ()) (== r ())] [(fresh [la ld ldr] (conso la ld l) (appendo ldr (list la) r) (reverso ld…
tsuki
  • 907
  • 4
  • 17
1
vote
0 answers

Data to function: What data would have to be passed to minikanren to get eval?

There is a video where minikanren is used to go from data to programs. That is, given data, it generates the program that generates the data. So is it possible to generate a universal function such as eval? What data would have to be passed to it?
1
vote
2 answers

Writing vector-membero in minikanren

I'm trying to write a membero equivalent for miniKanren (1) that works on vectors. So far, I can't find a way to do it that doesn't involve observing whether a value is a logic variable or is partially instantiated. Any pointers? Currently, I've…
Nathan Ringo
  • 973
  • 2
  • 10
  • 30
1
vote
1 answer

Understanding termination in minikanren counting bits in a list

I began studying some minikanren and made up this example for counting 1-bits in a list. (define (count xs n) (conde [(== xs '()) (== n 0)] [(fresh (a b) (== xs (cons a b)) (conde [(== a 0) (count b n)] …
user9137
  • 165
  • 4
1
vote
3 answers

In logic programming, what is unnesting for?

The question The Reasoned Schemer describes how to use miniKanren, which resembles Prolog but is a library for Lisp-like languages. The book's "First Commandment" is this: To transform a function whose value is a Boolean into a function whose…
Jeffrey Benjamin Brown
  • 3,427
  • 2
  • 28
  • 40
1
vote
1 answer

How to use quote and unquote to more faithfully translate The Reasoned Schemer into Racket?

(Details of my miniKanren in Racket setup appear at the bottom[1].) The way quotes and unquotes work in The Reasoned Schemer appears not to match the way they work in Racket. For instance, verse 2 of chapter 2 suggests[2] the following function…
Jeffrey Benjamin Brown
  • 3,427
  • 2
  • 28
  • 40