Questions tagged [reasoned-schemer]

The Reasoned Schemer is a book on logic programming written by Daniel P. Friedman, William E. Byrd, and Oleg Kiselyov. A related tag on SO is minikanren.

The Reasoned Schemer is a book on logic programming written by Daniel P. Friedman, William E. Byrd, and Oleg Kiselyov.

A related tag on SO is .

16 questions
33
votes
4 answers

conda, condi, conde, condu

I'm reading the Reasoned Schemer. I have some intuition about how conde works. However, I can't find a formal definition of what conde/conda/condu/condi do. I'm aware of https://www.cs.indiana.edu/~webyrd/ but that seems to have examples rather than…
user1383359
  • 2,673
  • 2
  • 25
  • 32
9
votes
4 answers

MiniKanren support by Dr Racket

I started studying miniKanren with the book "The Reasoned Schemer - second edition" and the DrRacket scheme environment. I installed the "faster-minikanren" package, but the first examples of the book with the command run* (for example, (run* q #f))…
Schemer
  • 137
  • 7
7
votes
1 answer

Clojure.logic difference with The Reasoned Schemer

I've been working through The Reasoned Schemer (TRS) using Clojure.logic and paying attention to the differences documented here. I reached frame 24 of Chapter 3, where TRS reports that (run 5 [x] (lolo '((a b) (c d) . x))) should produce '(() …
6
votes
2 answers

The Reasoned Schemer : Not understanding Exercise 57

On Exercise (or entry?) 57, I'm just not understanding how the logic flows. The question is that this: given (define teacupo (lambda (x) (conde ((= tea x ) #s) ((= cup x ) #s) (else #u)))) where '=' is actually the…
mpettis
  • 3,222
  • 4
  • 28
  • 35
5
votes
2 answers

Clarify search algorithms in different minikanren implementation

I am currently learning miniKanren by The Reasoned Schemer and Racket. I have three versions of minikanren implementation: The Reasoned Schemer, First Edition (MIT Press, 2005). I called it TRS1 https://github.com/miniKanren/TheReasonedSchemer PS.…
chansey
  • 1,266
  • 9
  • 20
5
votes
3 answers

miniKanren: How to define #s and #u?

In miniKanren, succeed can be defined as (define succeed (== #t #t)), and fail can be defined as (define fail (=== #t #f)). But what about #s and #u as short forms of succeed and fail, as they appear in The Reasoned Schemer? (define #s succeed)…
Flux
  • 9,805
  • 5
  • 46
  • 92
5
votes
1 answer

Why does 'The Reasoned Schemer' add an 'o' to the end of its functions?

In the reasoned schemer, they name standard lisp functions with an 'o' on the end, eg conso and appendo. My question is: Why does 'The Reasoned Schemer' add an 'o' to the end of its functions?
hawkeye
  • 34,745
  • 30
  • 150
  • 304
4
votes
1 answer

Is a "facts database" not a core feature of miniKanren?

I have been playing around with miniKanren, trying to understand it by converting very basic Prolog tutorials into it. I use Python habitually so I started with the LogPy library, which has since been forked and improved upon as a lib actually…
3
votes
1 answer

How to explain run 5 (x) g0 g1 in The Reasoned Schemer

I don't understand how the run n (x) g0 g1 ... to run through listo the listo is defined like this (define listo (lambda (l) (conde [(nullo l) #s)] [(pairo l) (fresh (d) (cdro l d) (listo d))] [else…
Hualin
  • 83
  • 6
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
2
votes
1 answer

Frame 2:26 - Why does conso have a strange cube?

In frame 26 we get the definition for cons0: (degree (conso a d p) (== `(,a ■ ,d) p)) The book hasn't mentioned yet what these black cubes are supposed to do. What does it mean? One hint is in frame 3-4 where it is mentioned that '(d a t e ■ s)…
Alper
  • 3,424
  • 4
  • 39
  • 45
1
vote
1 answer

Frame 6:8 - Why do we not get stuck in the recursion?

We get: (defrel (alwayso) (conde (#s) ((alwayso)))) (run 1 q (alwayso) #u) The book (2nd ed) says: "alwayso succeeds, followed by #u, which causes (alwayso) to be retried, which succeeds again". I still don't get the control flow.…
Alper
  • 3,424
  • 4
  • 39
  • 45
1
vote
2 answers

Frame 1:85 - Why does a conj2 of disj2 accumulate?

In 85 there is: (run* (x y) (teacupo x) (teacupo y)) which expands into: (run* (x y) (disj 2 (== 'tea x) (== 'cup x)) (disj 2 (== 'tea y) (== 'cup y))) So then how does conj2 accumulate the results to be ((tea tea) (tea…
Alper
  • 3,424
  • 4
  • 39
  • 45
1
vote
1 answer

Frame 1:26 - What does q unify with?

We have: (run* q (fresh (x) (== `(,x) q))) In this case `(,x) is a list where the refrence to the variable x isn't quoted. Does q unifies with a single element list? Is the result (_0) because q unifies with the fresh variable x…
Alper
  • 3,424
  • 4
  • 39
  • 45
1
vote
1 answer

Frame 1:33 - How do we unify two lists?

I don't think it's been written anywhere how this is supposed to work. We get: (run* q (== '( ((pea)) pod) `( ((pea)) ,q))) In the quasiquote form pea is quoted so remains the symbol and q is unquoted so refers to the variable in run.…
Alper
  • 3,424
  • 4
  • 39
  • 45
1
2