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
3
votes
3 answers

Basic logic programming in Scala

I have a fun little problem where I'm presented with a logic clause like so: Rule 1. A, B and C are unique, and are numbers from 1 to 3 (so every number is used). Rule 2. B < 2 Rule 3. C > 2 Now (assuming this quick example I just came up with…
Dominic Bou-Samra
  • 14,799
  • 26
  • 100
  • 156
3
votes
1 answer

Community resources for the Maude Language

Where do I go for interactive help when learning the Maude Language? I've found books, tutorials, and webpages with excellent instruction. I can't find any sort of interaction such as an IRC channel, active mailing list, or stack exchange (There is…
MRocklin
  • 55,641
  • 23
  • 163
  • 235
3
votes
1 answer

What are good/established database backing strategies for logic programming in clojure

I'm having a hard time finding profound information on strategies to set up a (deductive) database for facts to be queried using a logic programming approach like core.logic. Most examples to be found deal with facts created in memory. A really…
nansen
  • 2,912
  • 1
  • 20
  • 33
2
votes
2 answers

Is it possible to express Prolog's cut in first order logic?

In conversations around Prolog's cut operator !/0, I have only ever heard it described in terms of choice points and Prolog's execution model. It also seems to me that cut was introduced to give more "imperative" control over the search procedure,…
jweightman
  • 328
  • 1
  • 12
2
votes
2 answers

Inductive proofs in theorem provers (Z3, Vampire, with TPTP syntax)

I am testing the inductive capabilities of some theorem provers (such as Z3, Alt-Ergo, Vampire etc.) using the TPTP syntax. To my surprise, none of them managed to demonstrate the following simple conjecture: tff(t1, type, (fun: $int > $int…
mateleco
  • 519
  • 7
  • 15
2
votes
1 answer

Route Inspection of Directed Graph in ASP

For the multidirected graph below I am trying to write an program that visits all edges at least once. For instance, in the below graph I am looking for an outcome similar to "edge(1,2), edge(2,3), edge(3,1), edge(1,2), edge(2,4), edge(4,5),…
2
votes
0 answers

Clauses in (lambda)prolog starting with a cut

I am reading the paper Implementing Type Theory in Higher Order Constraint Logic Programming, and on p7 I see the following lambda-prolog code: % KAM-like rules in CPS style whd1 (app M N) S Ks Kf :- !, Ks [] M [N|S]. whd1 (lam T F1) [N|NS] Ks Kf :-…
2
votes
1 answer

How to sum all rather than just distinct values in clingo?

The following code produces x(3) rather than x(4) because it adds 1 and 2 together even though 1 appears twice. What is the right way of obtaining total sums in clingo? p(0,1;1,1;2,2). x(X) :- X = #sum { Y: p(_,Y) }.
rudolfovic
  • 3,163
  • 2
  • 14
  • 38
2
votes
2 answers

How to define multiple penalties to minimise overall in clingo?

I am trying to use clingo to generate tournament player-room allocations: player(1..20). room(1..4). played(1..20, 0). rank(1..20, 1). played(1..20, 1..20, 0). 0 { used_room(R) } 1 :- room(R). 3 { game(P, R) } 4 :- used_room(R), player(P). :-…
rudolfovic
  • 3,163
  • 2
  • 14
  • 38
2
votes
2 answers

logic programming - find synonyms of a given word

Task is to write a program that can decide whether two words are synonyms or not. I have pairs of synonymous words, E.g.: [big large] [large huge] [small little] We can derive the synonymous relationship indirectly: if big is a synonym for…
Sharas
  • 860
  • 8
  • 18
2
votes
1 answer

Why does "disj" from miniKanren work in Scheme but not in Racket?

I was working with the minikanren library for Racket, but wanted to use the "disj" and "conj" operators. I want to be able to more explicitly declare whether I am using disj or conj for the sake of legibility rather than have to parse through a…
Flywheel
  • 57
  • 3
2
votes
1 answer

"Generating Numbers" Puzzle

I have come across the following puzzle and couldn't formulate a solution in Picat: You will generate 5-digit numbers, where each digit is in 1..5 and different from the others, with the constraint that any three adjacent digits used in one number…
mlg556
  • 419
  • 3
  • 13
2
votes
3 answers

Is "almost pure" Prolog expressive?

@false commented earlier: Yes, you can implement a Turing machine without dif/2. But you cannot even implement intersection or similar predicates. Suppose we do extend pure Prolog (Horn FOL + CWA + UNA) with call/N, dif/2, and (=)/3, to be used in…
2
votes
2 answers

NU-Prolog's and Gödel's logical and sound `if-then-else` extension

A paper about mercury says the following: The if-then-else and negation constructs in most variants of Prolog are non-logical and unsound: they can cause the system to compute answers which are inconsistent with the program viewed as a logical…
MWB
  • 11,740
  • 6
  • 46
  • 91
2
votes
2 answers

Is there any difference between an N-ary function in Curry and an N+1-ary relation in Prolog?

Curry, unlike its cousin Haskell, allows you to give multiple values to a function: foo 1 2 = 3 foo 1 2 = 4 and it does backtracking (or some other search) to explore the implications of such non-determinism. This makes it similar to Prolog…
MWB
  • 11,740
  • 6
  • 46
  • 91