Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6643205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:01:25+00:00 2026-05-26T00:01:25+00:00

Two related questions in one: Can Clojure’s core.logic module perform arithmetic, logical comparison, etc,

  • 0

Two related questions in one:

Can Clojure’s core.logic module perform arithmetic, logical comparison, etc, like ordinary Prolog? I am envisioning something like the following:

(defrel points person n) 
(fact :bob 2)
(fact :charlie 3)
(run* [q] (fresh [x y] 
   (points :bob x) 
   (points :charlie y) 
   (< x y) 
   (== q (+ x y))))

=> (5)

In this example, neither the logical comparison (< x y) nor the attempted binding of q to (+ x y) works. I suppose that this is because I’m working with LVars, not integers at this point, and I can’t make these comparisons because the symbols aren’t yet bound. But it works in prolog:

points(bob, 2).
points(charlie, 3).
?- points(bob, X), points(charlie, Y), Result is X + Y.

=> Result = 5.

In a similar vein, can I somehow use Clojure functions (which return booleans or other “truthy” values) as logic predicates? In other words, to use functions to tell Minikanren which terms unify or not. Something along the lines of:

(defmagic startswithhi-o [v]
  (.startsWith v "hi"))
(defrel person n)
(fact person "bob")
(fact person "hillary")
(run* [q] 
   (fresh [n]
     (person n)
     (startswithhi-o n)
     (== q n)))

=> ("hillary")

If I try things like this I get errors also complaining that the LVars aren’t bound. Is there a way to do this?

Lastly if anyone has read this far, I might as well ask: are there plans to incorporate probabilistic logic into core.logic, along the lines of:

http://dtai.cs.kuleuven.be/problog/ ?

I’m not holding my breath but it would be awesome!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:01:25+00:00Added an answer on May 26, 2026 at 12:01 am

    Non-relational arithmetic is possible via project.

    (run 1 [q]
       (fresh [x y]
            (== x 1)
            (== y 2)
            (project [x y]
                     (== q (+ x y)))))
    (3)
    

    I believe the Prolog example given is also non-relational.

    The second half of your question can also be solved via project, but you must be careful that you always input a ground value.

    (defn startwith [x]
        (project [x]
             (== true (.startsWith x "hi"))))
    

    PS: Hold your breath for Constraint Logic Programming to come to core.logic!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two related tables in my database: Page and Tag. One Page can
My question is related to the following two: Emacs - Multiple columns one buffer
Okay, these two related questions are in reference to Railscast #21 : I'm having
Here are two questions related to modifying the data source for strongly typed dataset
I'm narrowing in on an underlying problem related to two prior questions. Basically, I've
Here are two different questions but I think they are related. When using Git,
Two related questions: What are the maximum number of concurrent files that a web
This is actually two questions in one: First, when you write your XAML and
I have actually two questions but they are kind of related so here they
Two related questions: When you use [NSSet setWithArray:] , does it remove duplicate object

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.