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 ...

3 answers

Prolog: How can I implement the sum of squares of two largest numbers out of three?

Exercise 1.3 of the book Structure and Interpretation of Computer Programs asks the following: Define a procedure that takes three numbers as arguments and returns the sum of the squares of the ...

1 answer

Can pyDatalog be used to check if all data dependencies are satisfied?

I am trying to use pyDatalog to determine if the dependencies for various features are satisfied. Some library (lA,lB,...) provides outputs (1,2,...) which are needed by features (fX,fY,...). For ...

1 answers | Apr 2 at 16:43 by kerblogglobel on Stack Overflow stackoverflow.com
0 answers

Product of two permutations (cycles) in Prolog

I would like to find the product of two permutations in Prolog (in cycle form) and I'm having problems with it (mostly because I can't even imagine, what it will look like). I thought about changing ...

1 answer

Enumerating binary trees in Prolog

I am trying to create Prolog rules to enumerate 'binary trees' in list form in Prolog. I am new to Prolog. A tree with 0 nodes is an empty list: [] A tree with 1 node is: [[],[]] A tree with 2 ...

1 answers | Mar 29 at 17:02 by 1026501 on Stack Overflow stackoverflow.com
2 answers

What are the main technical differences between Prolog and miniKanren, with respect to logic programming?

When I want to read up on logic programming I always stumble over two "main" ways to do it nowadays: miniKanren, a minilanguage introduced in The Reasoned Schemer and popular at the moment due to ...

3 answers

Prolog : Enumerate All Elements of Countably Infinite Results

Are there any prolog implementations that are able to enumerate all elements of countably infinite results? Let's consider to enumerate all pairs of natural numbers. If we enumerate pairs in order ...

3 answers | Feb 10 at 14:07 by egi on Stack Overflow stackoverflow.com
0 answers

Modelling recipes and available ingredients with constraint logic

Imagine I have a number of recipes for different dishes and a larder containing various ingredients in my kitchen. I want to construct a model using core.logic which will enable me to answer the ...

2 answers

Purity of Prolog predicates that use impure primitives

I know that var/1, nonvar/1 and !/0 are impure primitives, but does their use make every program that uses them impure? I wrote the following predicate plus/3 that behaves as if it were pure or at ...

0 answers

Proof of Correctness - Dependency Graph in Logic Program

I was trying to prove this. This is a logic program P = { a $\leftarrow$ b,c; g $\leftarrow$ a; f $\leftarrow$ k ; } Query= {g} Dependency Graph (G): ...

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 | Nov 25 '14 at 22:28 by blippy on Stack Overflow stackoverflow.com
1 answer

Loading a datalog program in a file into pyDatalog

I am trying to use the pyDatalog.load() method to load a small pyDatalog program. For example, I am loading the factorial sample from https://sites.google.com/site/pydatalog/ from pyDatalog import ...

1 answers | Nov 25 '14 at 22:27 by Andres on Stack Overflow stackoverflow.com
1 answer

pyDatalog: handling unbound variables in a custom predicate

I'm writing a pyDatalog program to analyse weather data from Weather Underground (just as a demo for myself and others in the company at the moment). I have written a custom predicate resolver which ...

1 answers | Nov 25 '14 at 22:27 by highfellow on Stack Overflow stackoverflow.com
1 answer

Using pyDatalog for constraint stores

Consider the following rules: pyDatalog.create_atoms('X') pyDatalog.create_atoms('Y') pyDatalog.create_atoms('a') pyDatalog.create_atoms('b') b(X,1) <= (X<0) b(X,Y) <= (X==1) & ...

1 answers | Nov 25 '14 at 22:27 by Andres on Stack Overflow stackoverflow.com
1 answer

Adding dynamical amount of numbers

Take a given database, e.g. input(80). input(30). input(25). input(90). Compute the amount of inputs above 50 times 100, constrained to only taking /1 input. e.g. %compute(?integer). compute(I). I ...

1 answers | Nov 24 '14 at 18:47 by user3711518 on Stack Overflow stackoverflow.com
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 '14 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

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 '14 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 '14 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 ...

3 answers | Aug 10 '14 at 16:39 by four_seasons on Stack Overflow stackoverflow.com
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 ...

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

2 answers | Jun 1 '14 at 23:41 by ivt on Stack Overflow stackoverflow.com
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 answers | May 15 '14 at 10:53 by MRocklin on Stack Overflow stackoverflow.com
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 '14 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 '14 at 15:49 by Bobby S on Stack Overflow stackoverflow.com
15 30 50 per page
1 2 3