core-logic

simongray 2021-01-22T17:23:52.000800Z

I just read the chapter in the Joy of Clojure on core.logic and now I am hungry for more. Where can I find more written in that style?

simongray 2021-01-23T19:23:21.001700Z

Ah good point. Thanks!

simongray 2021-01-23T19:23:55.001900Z

I had forgotten about minikanren

michele mendel 2021-01-25T06:04:28.002100Z

I'm currently reading TRS, going through every example to learn this interesting topic, and also to learn the syntax. The differences are not always clear. https://github.com/clojure/core.logic/wiki/Differences-from-The-Reasoned-Schemer helps a little, but it's not enough. I found these two links to projects on Github 1. https://github.com/martintrojer/reasoned-schemer-core.logic (9 yo) 2. https://github.com/philoskim/reasoned-schemer-for-clojure (2 yo) Mine is here, but I've just started and I'm currently on chapter 2 https://github.com/michelemendel/the_reasoned_schemer

🙏 1
2021-01-25T09:48:49.002700Z

I’d definitely recommend TRS it’s a really, really great book. It might be worth bearing in mind that core.logic is an implementation based on the 2nd edition of the book not the 3rd edition though. This means the 2nd edition is marginally easier to port to core.logic than the 3rd; but the differences are pretty obvious — especially if you can find some of the many ports of examples from the book into core.logic. The 3rd edition is a small but significant improvement on the 2nd edition book though; especially if you wish to understand the ideas behind it; they also distilled the implementation to its essentials even further.

🙏 1
michele mendel 2021-01-25T10:39:16.003Z

Is there a 3rd edition? I couldn't find it.

simongray 2021-01-26T08:10:38.003300Z

@rickmoynihan Do you think I ought to read any of the other schemer books first?

michele mendel 2021-01-26T08:14:31.003500Z

FYI, I'm newish to relational programming myself, and haven't read the other schemer books (but I have one on my shelf). I wrote newish, since I have read books about Prolog, so the concept wasn't completely new to me.

2021-01-26T08:20:06.003700Z

@simongray Well the whole series is great! 🙂 However the little schemer is the most basic of the whole series. If you know clojure pretty well you don’t really need it. It’s really an introduction to lisp, recursion, functions; whilst the seasoned schemer goes into functions as values etc. The books aren’t really practical introductions to learning scheme as such; more about learning concepts of programming.

2021-01-26T08:29:40.003900Z

They’re great books; I have the little typer and little prover too. All the books in the series have a pretty whimsical style; you’ll often find yourself asking “why am I learning this?!“, or even “what am I learning here?!“. The books don’t ever really attempt to answer the why; they consciously provide no explanation of what you’re learning or how it can be applied in the real world. They squarely come at it from the angle of the socratic method, and making tiny steps one at a time to quite profound concepts that are presented as just being interesting for their own sake. Obviously all the concepts the books teach are fundamentally important to CS — though the books themselves are presented more like kids books; and though they’d be suitable for that market, they’re anything but — they cover some pretty mind bending stuff. When you go through the exercises you might be tempted to skip ahead, as you might feel like they’re labouring the point or going too slow… however I’d urge you not too, as it’s very easy to end up out of your depth, missing fundamental concepts if you do this.

🙏 1
2021-01-26T08:30:48.004100Z

I’d also done some Prolog before; but the books are still worthwhile.

michele mendel 2021-01-26T08:31:58.004300Z

@rickmoynihan Yesterday you mentioned the third edition of TRS, but I couldn't find it.

2021-01-26T08:32:37.004500Z

Oh sorry I mean’t second edition

2021-01-26T08:32:49.004700Z

I have a first edition and the second edition (latest)

2021-01-26T08:33:06.004900Z

core.logic is based off the first edition; my mistake.

michele mendel 2021-01-26T08:34:27.005100Z

Ok, that's interesting, since I'm working through the book. Do you know of any important differences?

2021-01-26T08:35:02.005400Z

Depends what you think is important 🙂 What edition do you have?

michele mendel 2021-01-26T08:35:14.005600Z

second

2021-01-26T08:35:56.005800Z

are you using a scheme minikanren implementation or core.logic?

michele mendel 2021-01-26T08:36:17.006Z

core.logic

2021-01-26T08:39:52.006200Z

So TRS (both editions) include a complete implementation in the final chapters / appendix. The implementations in the 1st and 2nd edition are different. (1st edition is minikanren, 2nd edition as I understand it is microkanren). So if you want to use the book to understand core.logic’s implementation (rather than the high level language) then there are important differences. If you want to understand logic programming in the abstract; there’s mainly just superficial differences you can gloss over.

michele mendel 2021-01-26T08:41:26.006400Z

Ok, so the main difference is in the implementation and less so in the syntax.

2021-01-26T08:46:09.006600Z

No I believe there are also some differences at the language level; they’re just pretty easy to find the equivalence for. See pages xv and xvi in TRS2.

2021-01-26T08:48:30.006800Z

I actually wrote to Dan and Will on the mailing list before purchasing the 2nd edition to find out what had changed. Dan emailed me privately but Will replied on the list with a pretty comprehensive reply… I meant to link it yesterday: https://groups.google.com/g/minikanren/c/fMKSBmOm_XM/m/V0K30F8lBwAJ

michele mendel 2021-01-26T08:51:16.007Z

Thanks, I will add your answer to my Github page (https://github.com/michelemendel/the_reasoned_schemer), if that's ok with you.

2021-01-26T08:57:15.007300Z

Yeah that’s fine, thanks. I’d maybe revise “important differences” in implementation to “notable differences” as overall I think TRS2 is still a very good place to understand core.logic, though it may depend on deep you go. core.logic is also already different from TRS1 of course ( https://github.com/clojure/core.logic/wiki/Differences-from-The-Reasoned-Schemer )

michele mendel 2021-01-26T09:02:10.007500Z

Noted, I'll change the text. I have been trying to figure out if core.logic is actively updated and actually used (and not abandoned). Do you have any understanding about this?

2021-01-26T09:17:43.007800Z

I actively use it

2021-01-26T09:17:48.008Z

as do others

2021-01-26T09:18:26.008200Z

It’s not abandoned. It’s still maintained, just very lightly.

2021-01-26T09:19:04.008400Z

IIRC it had a version 1.0.0 update recently (as did many core clojure libs)

2021-01-26T09:19:11.008600Z

though it was essentially just a version bump

2021-01-26T09:21:38.008900Z

it had a minor update for clojure 1.10 warnings in feb last year, and has had changes to the build infrastructure etc 6 days ago.

michele mendel 2021-01-26T09:22:15.009100Z

Good to know. I'm pretty new to the Clojure environment. Some time back, I had a bad experience with Overtone. I went for Supercollider direct instead.

2021-01-26T09:22:49.009300Z

I expect it won’t get any significant attention again though, aside from minor build gardening etc. It’s essentially done.

michele mendel 2021-01-26T09:28:07.009600Z

Thanks for your help

Jan K 2021-01-22T18:19:50.001500Z

"The Reasoned Schemer" has a different style but definitely worth checking out. https://github.com/clojure/core.logic/wiki/Differences-from-The-Reasoned-Schemer