3 answers

Looking for a prolog interpreter

I am new to prolog and to try some logic programs I am looking for a nice prolog interpreter. Any suggestion?

3 answers | Nov 7 at 10:01 by Lahniep on Stack Overflow stackoverflow.com
0 answers

Using the “Prolog in Scala” to find available type class instances

Considering https://speakerdeck.com/folone/theres-a-prolog-in-your-scala, I would like to "abuse" the Scala type system to find all instances of e.g. CanBuildFrom that match a given criteria. Prolog ...

0 answers

What syntax core.logic matche, defne pattern matching constructs use?

Some of core.logic constructs (matcha, matche, matchu, defne, fne) use pattern matching expressions as body and can be used such as: (run* [q] (fresh [a o] (== a [1 2 3 4 5]) (matche [a] ...

1 answer

Why does creating a relationship in pyDatalog seem to give me the wrong answer?

I'm new to the concepts of Datalog, and I am exploring it through pyDatalog. I am experimenting with a unit measurement converter. So, given facts about how many inches there are in a meter, for ...

1 answers | Sep 13 at 16:57 by blippy on Stack Overflow stackoverflow.com
1 answer

Retrieve an answer from a list in prolog

Hello I am a beginner in Prolog and i have stuck in the following problem. Here it goes , I have a "database" which gives me information about the school schedule something like this : ...

1 answers | Aug 31 at 16:08 by stesioc on Stack Overflow stackoverflow.com
1 answer

Prolog Nim Game - Out of local stack error

I've been doing some Prolog lately. And I've read The Art Of Prolog book. They have a Nim game implementation there. So I've rewritten it to SWI-Prolog and everything seems fine except this Out of ...

1 answers | Aug 22 at 17:24 by Nazar Gargol on Stack Overflow stackoverflow.com
3 answers

implicit definition and tail recursion

Probably the most straightforward definition of the list reversal function in a functional language is (using Haskell-like pseudocode) rev [] = [] rev (x:xs) = (rev xs) ++ [x] However, every ...

3 answers

Prolog : Recurisve Function Branching & “Returning”

I was writing few recursive Prolog functions and ran into a certain point that I don't quite understand at the moment. For example, I wrote the function split that divides a list of integers into a ...

0 answers

Is the Prova implemented with a Prolog compiler or Prolog interpreter?

I am looking at the Java-written Prolog system, Prova. https://prova.ws/ But it is not clear about its implementation, a Prolog compiler or Prolog interpreter? I read the manual, but did not found an ...

1 answer

Logic programming - Is subset with only one function symbol Turing - complete?

If I have a subset of logic programming which contains only one function symbol, am I able to do everything? I think that I cannot but I am not sure at all. A programming language can do anything ...

10 answers

Can you do Logic Programming in Scala?

I read somewhere that Pattern Matching like that supported by the match/case feature in Scala was actually borrowed from Logic languages like Prolog. Can you use Scala to elegantly solve problems ...

13 answers

Embedded Prolog Interpreter/Compiler for Java

I'm working on an application in Java, that needs to do some complex logic rule deductions as part of its functionality. I'd like to code my logic deductions in Prolog or some other logic/constraint ...

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):-!. ...

1 answer

Turn a Maude expression into a String

Is there a way to turn a Maude expression into a string? I'm looking for the equivalent of Haskell's show.

1 answer

Modelling Constraint Logic Programs (for analysis)

Object-Oriented programs can be modelled by different models such as Automata, Process Algebras, Petri Nets or UML. Some of these models can be used to perform various kind of analysis to spot problem ...

1 answer

Prolog: predicate to check if elements of a list are present in a pre-defined list

I have a fact defined as: list([1,2,3,4,5]). Now, I want to write a predicate pred(X) which succeeds if all elements of X are present in the list. For example, pred([1,3,4,2]) should succeed, while ...

1 answers | Apr 29 at 22:34 by Tanay on Stack Overflow stackoverflow.com
2 answers

Prolog: X is the grandfather of Y

Assume that the following facts are already entered into the Prolog database: father(X, Y) // X is the father of Y mother(X, Y) // X is the mother of Y male(X) // X is a male ...

2 answers | Apr 25 at 15:49 by Bobby S on Stack Overflow stackoverflow.com
3 answers

Finding the predecessor and successor of an element in a list in Prolog

pred( b, [a,b,c], P ). % -> P = a succ( b, [a,b,c], S ). % -> S = c I am having a hard time translating idea from lisp to prolog. I did find out how to find the predecessor and successor in ...

1 answer

How to generate negative examples in inductive logic programming?

I am trying to learn rules of puzzles and board games by observing a human using inductive logic programming. I use PROGOL which is a program for ILP written in Prolog. While for some games it is able ...

2 answers

Concise Explanation of Core.logic

I want to use Clojure's Core.logic. However, I want to also understand how it works. Is there a concise explanation of it somewhere? (Like implementing a metacircular evaluator?) Thanks!

3 answers

how to stop prolog from examining impossible solutions infinitely?

suppose the following program: nat(0). nat(s(N)) :- nat(N). /* 0+b=b */ plus(0,B,B) :- nat(B). /* (a+1)+b = c iff a+(b+1)=c */ plus(s(A),B,C) :- plus(A,s(B),C). it works great for adding two ...

0 answers

Concurrent and Parallel Logic Programming

In the introduction to The Art of Prolog, Sterling and Shapiro defer a discussion of parallelism, concurrency, and logic programming to another book. My question is whether there is such a resource: ...

1 answer

Inference from generic situation S

I hope that someone can help me. Is it possible inference from a situation S different to s0 in Prolog? I have a s0 (initial situation) like this: isoven(oven). isoff(oven,s0). ison(X,do(a,S)):- ...

1 answers | Feb 2 at 22:10 by angelius on Stack Overflow stackoverflow.com
1 answer

Prolog - descending order list

I am trying to write a function - decListRange(X,List) which give a list in range [X-1:1] by descending order. For example - decListRange(9,List). Will give - List = [8,7,6,5,4,3,2,1]. I tried ...

1 answers | Feb 2 at 21:42 by URL87 on Stack Overflow stackoverflow.com
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 ...

2 answers | Feb 2 at 18:07 by Plaix on Stack Overflow stackoverflow.com
2 answers

How can I find the input from a list which yields the maximum result from some query in SWI-Prolog?

I'm just picking up Prolog now, so I'm unfamiliar with the normal way of doing most things. Essentially I have a rule which gives a value from an input: ScoreFromInput(Input, Score) :- ... And I ...

1 answer

Prolog: show a list contained within a list

I currently have the following facts defined in a Prolog program: hobbies([jarrod, [gaming, running, boxing]]). hobbies([james, [programming, gaming, drawing]]). What query could display a list of ...

1 answers | Jan 25 at 16:21 by jarrodparkes on Stack Overflow stackoverflow.com
4 answers

Logical equivalence in Prolog

I got two expressions to list all lists of bits using Prolog: bit(0). bit(1). bitlist1([]). bitlist1([B|Bs]) :- bit(B), bitlist1(Bs). bitlist2([]). bitlist2([B|Bs]) :- bitlist2(Bs), ...

4 answers | Jan 25 at 16:02 by SX. on Stack Overflow stackoverflow.com
1 answer

Why DLV finds an answer set rather than another, in this ASP example program?

I tried two simple programs in ASP(Answer Set Programming) and then i used the answer set solver DLV to find the answer sets (also referred as stable models); the programs are P1: b :- c. c. ...

1 answer

Answer set programming getting length of series as input

I am new at Answer Set Programming and trying to encode a problem into ASP. I think it is a simple question. Here is the code; events(1..3). sequence(A,B,C) :- events(A;B;C), A!=B, A!=C, B!=C. As ...

15 30 50 per page
1 2 3