Who uses logic programming?

I was in a class recently that had a session on logic programming, emphasizing Prolog. I was aware of Clojure having core.logic and so I looked into that one with its mini-kanren implementation. While I appreciate that there are major fields – NLP, AI – that make use of logic programming, it is equally striking how strange a methodology it is compared to conventional programming (e.g. goals, predicates, relations instead of functions, strange binding procedures, etc). Our toy project was to look at family relations (with facts like “father” and “mother,” then defining relations based on those facts like “sibling” and “cousin”) and throughout the effort I could only think how much easier this would be using regular maps and value checks.

Has anyone here worked productively in logic programming? What sorts of tasks does it facilitate more effectively than standard Clojure/functional programming?


I highly recommend the talk “The Most Beautiful Program Ever Written” by William Byrd for a dive into the beauty of logic programming.

Datomic’s Datalog implementation is a good first contact and can be explored here: http://www.learndatalogtoday.org/ In that sense, anyone using Datomic or really any relational database is already thinking in similar ways.

To me, functional programming is about respecting equality in one direction and logic programming about respecting equality in both directions. It seems very natural to express a domain mostly through its relations without picking a “direction”. You only ever state what is true about your domain. Constraint solvers and linear programming are very similar in that regard and immensely useful (e.g. in layouting algorithms). And after all, this is also how equations work in mathematics.

1 Like

Timoth Baldridge recently gave a talk about building a logic engine and he mentioned that he has built several of them for various projects, most recently at his current job at Cisco.


IIRC, he mentioned using them to efficiently do complex searches in both financial systems as queries across big datasets to identify possible malware.

1 Like

This is the main development content of the next version of my project—
Financial Analysis Expert System. :slightly_smiling_face:


What I always wondered about core.logic is: how do you estimate the complexity of the task? like, on a database, I check for indexes, define plan hints… so I know a query will take milliseconds and not hours for a full table scan. But with core.logic?

Made a game in prolog at university, bet never used it since.

The video link doesn’t work for me, maybe a mis-paste?

Hm, it works for me. Is anyone else having this problem? If so, which browser are you using?

If the link continues to not work, you can search youtube for “Den of Clojure Build Your Own Logic Engine”

Interesting, it works now, using the same browser. Thanks for the title!

We use clara rules for keeping a tangled web of government policy rules manageable.


Recommend the video talks linked in their pages for explaining the value props of using a logic engine. Even Mr Hickey himself recommended logic programming /prolog over raw Clojure for implementing business rules in many scenarios in “Simple Made Easy” :slight_smile:


Another essential logic programming resource is " The Reasoned Schemer" https://mitpress.mit.edu/books/reasoned-schemer

1 Like

That’s the one that clojure.core.logic is based on. I’ve been trying to
compare it to Prolog.

Brian Hurlow notifications@clojureverse.org writes:

My company uses “Rules” in Datomic to express business logic. It really helps us declare relationships and access rules without writing tons of hard to maintain conditional code paths

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.