What does HackerNews think of core.logic?

A logic programming library for Clojure & ClojureScript

Language: Clojure

Clojure has a Prolog library written for it called core.logic. I definitely didn't know Prolog well enough to make good use of all the esoteric function names but it seemed cool.

https://github.com/clojure/core.logic

I've actually seen this usage pattern in the practical usage of logic programming libraries. Common Lisp's Screamer [1], for instance, or Clojure's less-mature core.logic [2].

Though to be fair, both of these libraries are in Lisp languages, which inherently support the design pattern of slipping into/out-of DSLs.

[1] http://nikodemus.github.io/screamer/ [2] https://github.com/clojure/core.logic

I'm not a prolog or logic programming buff, but have you looked at something like Clojure's core.logic? https://github.com/clojure/core.logic
Probably doesn’t fit what you mean by mainstream, but even so: https://github.com/clojure/core.logic

> A logic programming library for Clojure & ClojureScript. core.logic offers Prolog-like relational programming, constraint logic programming, and nominal logic programming for Clojure.

Cool. This subject is on my list and will probably approach it through Clojure's Core.Logic (a logic library inspired by both prolog and miniKanren) [1]

1: https://github.com/clojure/core.logic

Very nice indeed! Fun to see this implementation in Clojure direct from SICP. Someday I hope somebody completes SICP in Clojure. AFAICT it's been attempted many times but none have finished.

Btw, miniKanren from Reasoned Schemer has long been available in Clojure as core.logic (with some minor differences). https://github.com/clojure/core.logic

I'm thrilled to see Prolog logic-engine concepts heavily contributing to Clojure's core.logic library[1].

Because Clojure plays so well with the JVM, having industry applications leveraging logic engines is becoming beautifully feasible.

[1] https://github.com/clojure/core.logic

PicoLisp[1] And Shen Lisp[2] have included one in their std lib, and maybe Prolog-like implements core.logic[3] and POP-11[4], many minikanrens[5].

[1] https://picolisp.com/wiki/?home

[2] http://shenlanguage.org/

[3] https://github.com/clojure/core.logic

[4] https://en.wikipedia.org/wiki/POP-11

[5] http://minikanren.org/

Practical logic programming in Clojure : https://github.com/clojure/core.logic

A modern logic programming language: https://github.com/mcsoto/cosmos

Barliman is written in miniKanren[0], a logic/relational programming system built by Daniel Friedman[1], Will Byrd[2] & Oleg Kiselyov[3]. There are implementations of miniKanren in languages other than Scheme, one of the prominent being Clojure[4].

To oversimplify, in the miniKanren world programs are written using relational logic, wherein there are "variables" and then certain "relationships" between the variables. That is the program specification. Now we can run the specification and allow miniKanren to generate one or more variables that satisfy the relations. Thus a miniKanren program can have more than one answers. One interesting side-effect of this kind of an abstraction is that programs can also be run backwards to generate more programs that satisfy certain relations. That's pretty much what's happening with Barliman.

[0] http://minikanren.org/ [1] https://en.wikipedia.org/wiki/Daniel_P._Friedman [2] http://webyrd.net/ [3] http://okmij.org/ftp/ [4] https://github.com/clojure/core.logic

Quick refs to logic programming and pattern matching in Clojure.

core.logic https://github.com/clojure/core.logic core.match https://github.com/clojure/core.match

It's part of the std lib. But yeah you're basically on the same page as me. Java doesn't have the ability to be extended in the ways that clojure or python can.

Python also allows for functional programming to a certain degree, but clojure is a lot more powerful when it comes to language extensions.

Threads as a library (for js environments) for clojure. https://github.com/clojure/core.async

Logic programming for clojure. https://github.com/clojure/core.logic

Declarative UI building, with dataflow semantics. http://reagent-project.github.io

Additionally immutability makes your life a lot easier. Parallel computing in clojure is a no brainer, you just change your map to pmap, and that's it.

Just a nitpick, but core.logic is a version of Kanren[0].

[0] https://github.com/clojure/core.logic

My somewhat neglected library Clearley (https://github.com/mthvedt/clearley) uses a macro system, that lets you write parsers that look a little like pattern-matching functions. To do this, you need to be able to introspect, bind and lookup symbols, and data structures containing symbols, at compile time. You can't do this in Haskell. Template Haskell doesn't help, since IIRC it doesn't support looking up symbols in the same file.

With Clojure, If you understand the JVM type system and performance, you can also write high performance DSLs using Clojure macros. https://github.com/clojure/core.logic allegedly is a project along these lines, but I haven't looked too much into it. It heavily uses Clojure protocols (which map to Java interfaces) for performance. I had been working on a code generator for Clearley, which sits neglected on my hard drive, but is able to perform just a little slower than unoptimized hand-written parsers. Since in Clojure compile/runtime separation is optional and off by default, you can use Clojure to generate Clojure code, making life a lot easier.

When I first learned about Prolog in AI class, the first thing that struct me was how beautiful Prolog/logic programming solutions are.

In non-declarative languages like Java, you have to build up the different pieces of computations, while you keep maintaining a mental picture of how the various pieces fit together.

In Prolog, you declare the entities and the relationships/constraints between them, and the system will build the solution for you through inference.

David Nolen has done some awesome work writing the core.logic[1] library, which makes those Prolog gooodies accessible to Clojure programmers.

-- [1] https://github.com/clojure/core.logic

is this a simplified implementation of what core.logic covers ? I was looking through that earlier today.

https://github.com/clojure/core.logic

https://github.com/clojure/core.logic/wiki/A-Core.logic-Prim...

its certainly not as easy to understand when you are starting off, but it would seem to have more rewards to work with core.logic since they've implemented a lot of classic logic programming.

or is there no overlap ?

If you go with Clojure, you could cover learning logic programming using the core.logic (https://github.com/clojure/core.logic) library instead of Prolog.