Questions tagged [logic-programming]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
34 views

Writing A Repeat Loop in Prolog But The Condition Does Not Update

I am attempting to write a small lexer here: lexer(InputString) :- string_chars(InputString, InputAsListOfAtomChars), maplist(atom_string, InputAsListOfAtomChars, InputAsListOfStringChars), ...
8SIXSector's user avatar
0 votes
0 answers
24 views

answer set programming with recursion

Questions are as follows: Points on the straight line, 1, 2, 3, 4, 5, the starting point is 1, can go to any point, but a point can only be reached once, output the path to visit all points. I ...
CodeNumb's user avatar
1 vote
0 answers
61 views

Infinite loop with `counto` relation in core.logic

I am interested in expressing the number of occurrences of an element in a list as a relational goal in Clojure's core.logic library. (Note that this question is not a duplicate of clojure core.logic ...
oper0's user avatar
  • 11
0 votes
1 answer
60 views

MiniKanren Racket multiplication for unary numbers

I am trying to implement multiplication for unary numbers in MiniKanren. So I have written the following code: #lang iracket/lang (require minikanren) (require minikanren/matche) (defrel (unaryo n) (...
 NAD 's user avatar
1 vote
1 answer
38 views

Minizinc: inconsistent constraint reformulation

I'm developing a Minizinc model and I ran into this issue: given this model enum req_type = {roads, rivers}; enum cities = {city1, city2, city3} array[cities, cities] of var bool: are_connected; % ...
Sassa's user avatar
  • 11
0 votes
0 answers
65 views

Using a list in pytholog

I'm trying to define a knowledge base where a disease has a list of symptoms. Here's a snippet: import pytholog as pl diseases_kb = pl.KnowledgeBase() diseases_kb([ "disease(diabetes, [...
Elissa's user avatar
  • 1
3 votes
0 answers
86 views

Logic programming with multiple fact databases

I have to find a logically consistent subset of multiple fact sets (databases). Is there a logic programming language with built-in facilities to do this? If not, are there logic programming languages ...
Paul Jurczak's user avatar
  • 7,148
0 votes
0 answers
36 views

A question about the inner workings of ASP

I'm confused about the inner workings of ASP. Say I'm modelling a country's. For example, say we have city(london). city(manchester). city(leeds). city(newcastle). city(sheffield). road(a1). road(b1)....
Dan Öz's user avatar
  • 319
4 votes
2 answers
324 views

How does prolog resolution use proof by contradiction?

I'm learning prolog, and I'm confused by the claim that prolog uses proof by contradiction: The resolution proof process makes use of a technique that is known as reduction to the absurd: suppose ...
Joseph Garvin's user avatar
1 vote
1 answer
194 views

Shortest path in Answer Set Programming

I'm trying to find all the shortest path from one source node to all other destination node (so 1-3, 1-5, 1-4) with the relative cost for each shortest path. I've tried with this code node(1..5). ...
user16457964's user avatar
0 votes
0 answers
39 views

Value Semantics in Parallel Programming

What is the advantage of following value semantics while designing parallel programming?
Pankaj Chowdhury's user avatar
2 votes
2 answers
108 views

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 &...
jweightman's user avatar
1 vote
0 answers
32 views

How to eliminate circular solutions in unification?

I use the next unification lib. from unification import * x1 = var('x1') unify((x1, 1), x1) # {~x1: (~x1, 1)} Can you please suggest how to eliminate such circular solutions (~x1 references to ...
Oleg Dats's user avatar
  • 3,943
1 vote
1 answer
68 views

Why does introducing numbero in minikanren cause the failure of valid unifications?

I am using Racket v8.5, with the packages for minikanren and minikanren/numbers required. Why does introducing the numbero constraint cause previously valid unifications to fail? > (run 1 (q) (<...
jpt4's user avatar
  • 13
0 votes
1 answer
357 views

Clingo: Intersecting All Possible Optimal Solutions (ASP)

I want to find atoms, within a pre-defined set of atoms, that are in all possible optimal solutions of an ASP problem. I'll explain what i want to do. I have an optimization problem where multiple ...
J.Doe's user avatar
  • 21
1 vote
2 answers
179 views

Creating random CNF formulas prolog

For my thesis, I am looking at specific properties of knowledge bases and how this affects argumentation tree sizes. I need a sat solver in prolog which I already have, but I also need an algorithm ...
user avatar
1 vote
0 answers
131 views

Is it possible to insert a Clojure statement in the middle of a series of core.logic calls, "à la Prolog"?

Prolog mixes logic (fallible) goals, and (infallible) processes like write/2 or assert/1. Is it possible to do so with Clojure's core.logic? For example: (pldb/with-db myFacts (l/run* [x y] ...
Hugolin Bergier's user avatar
1 vote
1 answer
87 views

Optimizing difficulty with a level generator using Clingo

I’m making a puzzle level generator (sokoban) using Clingo and got stuck trying to create levels with a specific move limit. The idea is to use the move limit to control difficulty of a level. This is ...
jokke's user avatar
  • 65
7 votes
1 answer
209 views

Does the term "Functor" in Prolog have any relation to the term taken from Category Theory?

I started to learn Prolog and I just read that the atom at the beginning of an structure is usually called functor. I'm also familiar with the term functor from Category Theory and Functional ...
Gabriel Santana Paredes's user avatar
2 votes
2 answers
415 views

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 ...
mateleco's user avatar
  • 529
0 votes
1 answer
106 views

Trying to solve Lady or the Tiger in Alloy

I've been trying to solve the logic puzzle Lady or the Tiger in Alloy but got stuck. Right now I'm trying to solve the 4th puzzle which is on the 2nd day. It goes as following: There are a few rooms ...
Myrqz's user avatar
  • 51
1 vote
1 answer
87 views

Can this type of problem be easily expressed in logic programming paradigm?

For simplicity, this is a toy version of the actual problem: given a set of integers, find the longest sequence of consecutive numbers from that set. I looked at CLIPS and other expert systems, and ...
Paul Jurczak's user avatar
  • 7,148
2 votes
1 answer
133 views

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)...
john_ny's user avatar
  • 173
2 votes
0 answers
78 views

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 :- !...
Mike Shulman's user avatar
1 vote
1 answer
326 views

Negative optimization result in Answer Set Programming

I have written an ASP program with an optimization condition in the end. When I compile it, even though I get the correct result, in the summary I get a negative value for the optimization (i.e. -3). ...
john_ny's user avatar
  • 173
1 vote
1 answer
260 views

Spanning Trees in Answer Set Programming

For the undirected graph described below, I am trying to get its spanning trees and then separate its leaves from the internal nodes. Could you please help me with my code ? What I expect to see after ...
john_ny's user avatar
  • 173
1 vote
1 answer
97 views

Non-termination when query variable is on a specific position

Consider this blog post where the author implements palindrome relation using reverso: (defn reverso [l r] (conde [(== l ()) (== r ())] [(fresh [la ld ldr] (conso la ld l) (...
tsuki's user avatar
  • 907
1 vote
1 answer
406 views

Answer Set Programming - filtering from a large number of models

instance.lp node(1). node(2). node(3). node(4). node(5). node(6). edge(1,2). edge(2,1). edge(4,1). edge(2,3). edge(2,6). edge(3,4). edge(3,5). edge(5,6). edge(6,3). begin(4). I have this problem ...
cheshire's user avatar
  • 1,119
3 votes
1 answer
176 views

What is committed-choice logic programming language?

In the logic programming community, I have heard many people talk about "committed choice logic programming language", but I am not very clear about its definition. I searched the internet, ...
chansey's user avatar
  • 1,296
3 votes
1 answer
982 views

What's the difference between logic programming and answer set programming

I'm currently learning how to prove the unsatisfiability of first-order logic. I've learnd in my class that resolution is one way to solve the unsatisfiability problem, e.g., tools like Prolog achieve ...
Li Danyuan's user avatar
3 votes
1 answer
117 views

How do I translate Prolog's cuts to Curry?

Here's an algorithm in Curry which takes n and matches on two strings within edit distance n of each other. lev :: Eq a => Int -> [a] -> [a] -> () lev n (a : b) (a : c) = lev n b c lev n ...
Wheat Wizard's user avatar
  • 4,011
3 votes
2 answers
223 views

Are there elements of 'logic programming' in Java?

In recent years many elements of 'functional programming' have entered Java, in particular with Java 8. I have in mind lambda-expressions, functional interfaces, Java Generics, the Stream-interface, ...
Sebastian's user avatar
  • 435
1 vote
1 answer
234 views

Converting `appendo` relation from smt2 to python

Recently I am learning SMT solver. Although SMT solver is a new concept to me, it reminds me of logic programming, e.g. Prolog and minikanren. So I tried a classic example of logic programming in SMT ...
chansey's user avatar
  • 1,296
1 vote
1 answer
178 views

Why the disjunctive ASP program cannot return both disjunct predicates instance in an answer?

I am a newbie to ASP (Answer Set Programming). I tried the following program in clingo online version (reasoning mode = enumerate all) % instance member(dave). % encoding edu(X);rich(X) :- member(X). ...
chansey's user avatar
  • 1,296
1 vote
1 answer
327 views

How to replace constants terms from python API in clingo / gringo?

Suppose I have a the following file foo.lp: foo(x). Now when I run gringo -t -c x=1 foo.lp I obviously get: foo(1). Now I want to know how to achieve the same behavior as the -c command line option ...
user1747134's user avatar
  • 2,382
1 vote
1 answer
232 views

Event-Driven Programming Paradigm in Logic Programing

I need to write a paper on the Event-Driven Programming Paradigm in Logic Programing. I have been able to find a lot of information on Event-Driven Programming in Object-Oriented and Functional ...
ProgLog's user avatar
  • 35
1 vote
1 answer
457 views

Clingo: operation undefined

Adding the following rule to my code results in an error message (info: operation undefined (Max-Min)): rank_difference(Room, Deck, Diff) :- played(Room, Deck), Min = #min {Rank: seat(Player, ...
rudolfovic's user avatar
  • 3,173
0 votes
1 answer
255 views

Reducing the search space efficiently in clingo

I am struggling to scale a constraint problem (it breaks down for large values and / or if I try to optimise instead of just looking for any solution). I've taken some steps to break the search space ...
rudolfovic's user avatar
  • 3,173
0 votes
1 answer
190 views

Shorthand for multiple choice predicates in clingo

Right now I have a single choice predicate that defines my search space. #const nRounds = 3. #const nPlayers = 17. #const nSeats = nRounds * nPlayers. #const nRooms = 3. #const nDecks = 6. nSeats { ...
rudolfovic's user avatar
  • 3,173
2 votes
1 answer
481 views

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 = #...
rudolfovic's user avatar
  • 3,173
2 votes
2 answers
468 views

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 {...
rudolfovic's user avatar
  • 3,173
5 votes
2 answers
297 views

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 ...
chansey's user avatar
  • 1,296
0 votes
1 answer
296 views

Clingo program expected to be satisfiable

I am testing some programs involving arithmetics in Clingo 5.0.0 and I don't understand why the below program is unsatisfiable: #const v = 1. a(object1). a(object2). b(object3). value(object1,object2,...
Olivier's user avatar
  • 33
2 votes
2 answers
1k views

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 ...
Sharas's user avatar
  • 859
1 vote
2 answers
108 views

Look for algorithm/research area that determines facts that would make a Prolog query true given a Prolog program

I'm looking for research, algorithms or even terminology for this area of research that take a Prolog program and a query I want to be true and attempt to find the facts that would need to be asserted ...
Eric Zinda's user avatar
2 votes
1 answer
122 views

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 ...
Flywheel's user avatar
2 votes
1 answer
202 views

"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 ...
mlg556's user avatar
  • 419
1 vote
3 answers
501 views

Maximize the interval in clingo

I have the following clingo code that generates the search space, followed by constraints. {in(I,1..4)}=1 :- I=1..n. :- [constraint1] :- [constraint2] This code works. But I need clingo to find the ...
Saqib Ali's user avatar
  • 3,973
5 votes
5 answers
259 views

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 ...
Anonymix321's user avatar
3 votes
2 answers
303 views

Finding all nodes connected to a vertex in Prolog

I am curious about pathfinding algorithms, so I took a look at Dijkstra's. I'm using this video as a guide (and it's what I'm basing my graph on). Here is the graph I am working from: I now want to ...
Caspian Ahlberg's user avatar

1
2 3 4 5