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

Discussion about Abductive logic programming vs Answer Set Programming

I am looking to clarify the some things about abductive logic programming vs. Answer set programming. I with some classmates are creating a game. In this game there are "heroes" (special npcs). The heroes have goals and behaviors. (All of this is…
ssmoot
  • 31
  • 2
3
votes
1 answer

Prolog - ASP 'not' to Prolog negate

I have an example problem in Answer Set Programming (ASP). When I try to make the equivalent code in Prolog, I keep getting stuck with the not blocked. This is the ASP…
3
votes
1 answer

Invariant induction over horn-clauses with Z3py

I am currently using Z3py to to deduce some invariants which are encoded as a conjunction of horn-clauses whilst also providing a template for the invariant. I'm starting with a simple example first if you see the code snippet below. x = 0; while(x…
wrahman
  • 123
  • 1
  • 10
3
votes
0 answers

Best tool for a beginner in Constraint Logic Programming

I need to create a prototype application for production order scheduling for my university. I am still new to the topic of CLP and I am looking for an easy tool/environment/system that will let me define logic for few machines (i.e. 5-10) with their…
siobchan
  • 59
  • 4
3
votes
2 answers

Are regular expressions an example of logic programming?

I'm just wondering if regular expressions fit into the definition of what Logic Programming is. It is a set of rules which given a set of facts yields a result depending on how the query is asked. To me that sounds like it should fall under Logic…
user10628
  • 43
  • 2
3
votes
1 answer

WARMR algorithm in ALEPH (SWI-Prolog)

i am trying to use WARMR to find frequent relational patterns in my data; for this i am using ALEPH in SWI-Prolog. however, i am struggling to figure out how to do this and why my previous attempts did not work. i want to make a toy example work…
stas g
  • 1,503
  • 2
  • 10
  • 20
3
votes
1 answer

SWI Prolog pass a goal with non-zero arity through the command line arguments

SWI Prolog allows the execution of a goal before top level with non zero arity as follows swipl -s consultingfile.pl -g start however when a predicate with non zero arity is specified as follows swipl -s consultingfile.pl -g start(1) It gives an…
ant_1618
  • 1,861
  • 4
  • 17
  • 26
3
votes
1 answer

Finding similar sets with clojure's core.logic / minikanren

this is my first question on Stack Overflow. I’m new to logic programming and are trying to evaluate if it can be used to solve some matching problems I’m working on. Problem: Lets say we have a set A that looks like this. A = {1, 2, 3, 4} And then…
3
votes
1 answer

Relational Clausal Logic question: what is a Herbrand interpretation

I'm having a hard time coming to grips with relational clausal logic, and I'm not sure if this is the place to ask but it would be help me so much with revision if anyone could provide guidance with the following questions. Let P be the…
anotherstat
  • 93
  • 2
  • 5
3
votes
1 answer

Alloy constraint specification

I wrote the following code block in Alloy: one h: Human | h in s.start => { s'.currentCall = h.from } I want to pick one 'human' from a set of humans (s.start) and set a variable (s'.currentCall) equal to h.from. However I think this code is…
jvermeulen
  • 505
  • 1
  • 6
  • 14
3
votes
1 answer

PyDatalog: list of values in answer

In PyDatalog I have defined the following assertions: #stations assert_fact('station', 'A' ,'yellow') assert_fact('station', 'B' ,'yellow') assert_fact('station', 'C' ,'yellow') assert_fact('station', 'D' ,'yellow') #sections assert_fact('stretch',…
Ignasi
  • 77
  • 1
  • 9
3
votes
3 answers

Swapping consecutive items of a list in Prolog

I'm trying to write Prolog code that can swap two elements of a list, but only if they are consecutive to each other. That is, conseq_swap(d, e, [a, g, d, e, f], X). should give: X = [a, g, e, d, f]. (d and e are…
Velvet Ghost
  • 408
  • 1
  • 9
  • 27
3
votes
2 answers

Transforming recursion into tail recursion?

I am trying to write a predicate that recursively finds the nth power of some number [A^n = A * A^(n-1)] and uses the shortcut A^(2n) = A^n * A^n. Here is the solution so far. p(_,0,1):-!. p(A,N,R):-N mod…
ivt
  • 301
  • 3
  • 9
3
votes
0 answers

Examples of rewrite rule engine in Python?

Are there any existing projects within the Python ecosystem that use rewrite/production/transformation rules in way similar to Mathematica or Maude? Note that I'm referring to the logic programming concept, not the web server concept.
MRocklin
  • 55,641
  • 23
  • 163
  • 235
3
votes
4 answers

Prolog - what sort of sentences can't be expressed

I was wondering what sort of sentences can't you express in Prolog? I've been researching into logic programming in general and have learned that first-order logic is more expressive compared to definite clause logic (Horn clause) that Prolog is…
user1280446
  • 139
  • 1
  • 9