Questions tagged [logic-programming]

Logic Programming is a programming paradigm based on first order logic.

Logic programming is a programming paradigm which is largely based on formal logic. Any program written in a logic programming language is a set of sentences in logical form, expressing facts and rules about some problem domain. Major logic programming language families include Prolog, answer set programming (ASP) and Datalog.

231 questions
7
votes
2 answers

Herbrand universe and Least herbrand Model

I read the question asked in Herbrand universe, Herbrand Base and Herbrand Model of binary tree (prolog) and the answers given, but I have a slightly different question more like a confirmation and hopefully my confusion will be clarified. Let P be…
Plaix
  • 831
  • 3
  • 11
  • 20
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 '(() …
7
votes
2 answers

Goal ordering in Clojure's `core.logic`

The following Clojure code uses core.logic to solve the same logic problem with the same goals in two different orders. This choice of ordering causes one to finish quickly and the other to hang. (use `clojure.core.logic) ;; Runs quickly. …
MRocklin
  • 55,641
  • 23
  • 163
  • 235
6
votes
2 answers

Documentation for the Prolog dialect Prova

I would like to switch from SWI-Prolog to Prova - but it seems to be harder than expected: Predicates like succ() are not available and operations like Var1+Var2>Var3 do not work (obviously it has to be Var3
shink
  • 69
  • 1
6
votes
2 answers

Prolog: Failure driven loops

I used the following failure driven loop to list everything without using semicolons. happiness(fred,5). happiness(john,3). happiness(grace,2). someGoal(X) :- happiness(X,Y), write(Y), tab(4), fail. In query mode, I get this as expected ?-…
Zoran
  • 459
  • 1
  • 6
  • 19
6
votes
1 answer

Listing unique DAG parents with core.logic

Here's a (hopefully) simple logical program I've been stuck with for a while. I have a DAG represented by an edge relation in core.logic, when generating the list of parent nodes, I get duplicates when I have "diamond shapes" in the graph (I'm not…
6
votes
1 answer

Are there purely declarative, general purpose programming languages?

I've been researching declarative languages, and it seems like declarative is just an umbrella term for both logic and functional languages. Or am I wrong? Are there any general-purpose declarative programming languages that can't be classified as…
Matt
  • 5,553
  • 5
  • 24
  • 32
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
5 answers

What is the most elegant way to find 16-bit numbers which satisfy some conditions?

I need to find all triples of 16-bit numbers (x, y, z) (well, actually only bits which perfectly match up in different triples with bits on same positions), such that y | x = 0x49ab (y >> 2) ^ x = 0x530b (z >> 1) & y = 0x0883 (x << 2) | z =…
5
votes
3 answers

Does HiLog add anything that can not be done with "call" in Prolog?

The Wikipedia article for Prolog states: Higher-order programming style in Prolog was pioneered in HiLog and λProlog. The motivation for HiLog includes its ability to implement higher-order predicates like…
MWB
  • 11,740
  • 6
  • 46
  • 91
5
votes
2 answers

Does MiniKanren have the "not" operator?

Does MiniKanren have the "not" operator? For example, how would one represent Prolog's a :- b, not(c) a is true if b is true and c is not (Prolog uses negation as failure, i.e. not(c) is considered proven if c can not be proven) Prolog's not also…
MWB
  • 11,740
  • 6
  • 46
  • 91
5
votes
2 answers

How to implement fully-declarative Horn logic?

I would like to formalize some knowledge and execute queries in what may referred to as fully-declarative Horn logic (or, fully-declarative Prolog). Could anyone provide some guidelines on how to implement it? I briefly recap the fine description…
5
votes
4 answers

Multithreading in... functional languages? (Prolog)

When my friend started learning Prolog in school, I made fun of him for learning a useless language. However, he's showed me some stuff I never even knew possible; I want to know where this technique comes from. The technique is…
5
votes
0 answers

How does tabling improve efficiency?

I am curious about how tabling works to improve efficiency of Prolog programs. How is it implemented? Both explanation and references are welcome.
day
  • 2,292
  • 1
  • 20
  • 23
5
votes
1 answer

Extending core.logic to custom types

I'm experimenting with core.logic, and want to enable my own custom data type to participate in logic expressions: (deftype Expression [node vars] ....) Basically this represents a node in a mathematical expression tree, containing a node tree…
mikera
  • 105,238
  • 25
  • 256
  • 415
1 2
3
15 16