Skip to main content
Filter by
Sorted by
Tagged with
151 votes
2 answers
26k views

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

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 ...
Profpatsch's user avatar
  • 5,028
84 votes
8 answers
19k views

Comparing SQL and Prolog

I've started learning Prolog and wondering about the theoretical difference from the SQL language. For example: both are declarative languages both support a fact-driven knowledge database both ...
user avatar
78 votes
10 answers
270k views

'if' in prolog?

Is there a way to do an if in prolog, e.g. if a variable is 0, then to do some actions (write text to the terminal). An else isn't even needed, but I can't find any documentation of if.
jreid9001's user avatar
  • 1,237
78 votes
7 answers
36k views

Difference between logic programming and functional programming

I have been reading many articles trying to understand the difference between functional and logic programming, but the only deduction I have been able to make so far is that logic programming defines ...
Heshan Perera's user avatar
69 votes
11 answers
16k views

Good beginners material on Prolog [closed]

I am looking for good beginners material on Prolog, both online and printed. I am not only interested in 'learning the language' but also in background and scientific information.
meelow's user avatar
  • 851
59 votes
5 answers
36k views

Haskell vs. Prolog comparison [closed]

What kind of problems is better solved in Prolog than in Haskell? What are the main differences between these two languages? Edit Is there a Haskell library (kind of a logical solver) that can mimic ...
danatel's user avatar
  • 4,972
57 votes
4 answers
2k views

Rearranging variable_names

How to write in a standard conforming manner avs_term_rearranged(AVs, T, AVsR) with given AVs and T such that AVsR is a permutation of AVs with the elements arranged in same order as their variables ...
false's user avatar
  • 10.3k
57 votes
2 answers
9k views

What is the difference between ' and " in Prolog?

I am new to Prolog and noticed that ' and " give different behavior, but am curious as to why. Specifically, when loading a file, ?- ['test1.pl']. works, while ?- ["test1.pl"]. doesn't.
astay13's user avatar
  • 6,917
47 votes
14 answers
33k views

What's a good Prolog IDE for Linux? [closed]

I need to write some Prolog programs for a class. Any recommendations?
Marcos Lara's user avatar
  • 1,883
47 votes
4 answers
60k views

Forward Chaining vs Backward Chaining

What is one good for that the other's not in practice? I understand the theory of what they do, but what are their limitations and capabilities in practical use? I'm considering Drools vs a java ...
gtrak's user avatar
  • 5,656
46 votes
8 answers
8k views

How does Prolog technically work? What's under the hood?

I want to learn more about the internals of Prolog and understand how this works. I know how to use it. But not how it works internally. What are the names of the algorithms and concepts used in ...
SecretService - not really's user avatar
46 votes
5 answers
15k views

Knowing when to use cut in prolog

I've took a course in which I learned some prolog. I couldn't figure out how / when to use cuts. Even though I get the general idea of cuts, I can't seem to use them properly. Can anyone explain it ...
matanc1's user avatar
  • 6,913
46 votes
3 answers
4k views

Definition of a path/trail/walk

Many predicates define some kind of an acyclic path built from edges defined via a binary relation, quite similarly to defining transitive closure. A generic definition is thus called for. Note that ...
false's user avatar
  • 10.3k
45 votes
5 answers
130k views

What is the logical 'not' in Prolog?

The problem that I face, is a bit trivial. I want to use logical not in Prolog, but it seems that not/1 is not the thing that I want: course(ai). course(pl). course(os). have(X,Y) :- course(X),...
Masood Delfarah's user avatar
45 votes
13 answers
11k views

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 ...
Sami's user avatar
  • 3,273
44 votes
6 answers
10k views

Tennis match scheduling

There are a limited number of players and a limited number of tennis courts. At each round, there can be at most as many matches as there are courts. Nobody plays 2 rounds without a break. Everyone ...
Ingdas's user avatar
  • 1,476
44 votes
4 answers
923 views

Attributed variables: library interfaces / implementations / portability

When I was skimming some prolog related questions recently, I stumbled upon this answer by @mat to question How to represent directed cyclic graph in Prolog with direct access to neighbour verticies . ...
repeat's user avatar
  • 18.7k
43 votes
7 answers
63k views

Prolog =:= operator

There are some special operators in Prolog, one of them is is, however, recently I came across the =:= operator and have no idea how it works. Can someone explain what this operator does, and also ...
nubela's user avatar
  • 17.2k
42 votes
2 answers
4k views

Prolog successor notation yields incomplete result and infinite loop

I start to learn Prolog and first learnt about the successor notation. And this is where I find out about writing Peano axioms in Prolog. See page 12 of the PDF: sum(0, M, M). sum(s(N), M, s(K)) :- ...
Felastine's user avatar
  • 793
40 votes
2 answers
67k views

What is the difference between == and = in Prolog?

Can someone explain the difference between the == and the = operator in Prolog? I know that X = Y means X unifies with Y and is true if X already unifies with Y or can be made to, but I don't ...
JohnS's user avatar
  • 1,202
40 votes
1 answer
38k views

Prolog map procedure that applies predicate to list elements

How do you write a Prolog procedure map(List, PredName, Result) that applies the predicate PredName(Arg, Res) to the elements of List, and returns the result in the list Result? For example: test(N,...
General_9's user avatar
  • 2,309
40 votes
10 answers
20k views

Relational/Logic Programming in Python?

I'm a longtime python developer and recently have been introduced to Prolog. I love the concept of using relationship rules for certain kinds of tasks, and would like to add this to my repertoire. ...
AJ.'s user avatar
  • 28.1k
40 votes
6 answers
2k views

Reification of term equality/inequality

Pure Prolog programs that distinguish between the equality and inequality of terms in a clean manner suffer from execution inefficiencies ; even when all terms of relevance are ground. A recent ...
false's user avatar
  • 10.3k
38 votes
3 answers
57k views

What does \+ mean in Prolog?

I've seen some answers here that use it and I don't know what it means or how to use it. I's also hard to look for it via a search engine :)
Juanjo Conti's user avatar
  • 29.8k
38 votes
5 answers
806 views

Unification with STO detection

In ISO Prolog unification is defined only for those cases that are NSTO (not subject to occurs-check). The idea behind is to cover those cases of unifications that are mostly used in programs and ...
false's user avatar
  • 10.3k
38 votes
7 answers
44k views

Good IDE to get started with prolog [closed]

I need to start learning Prolog for my job. I haven't used Prolog before and my company needs to build a program that will use Prolog. So the program will be used commercially. So some questions: ...
ant2009's user avatar
  • 22.7k
36 votes
5 answers
13k views

Pattern Matching - Prolog vs. Haskell

This is not a homework question, rather an exam study guide question. What is the difference between pattern matching in Prolog Vs Haskell? I've done some research and reading up on the theories ...
cYn's user avatar
  • 3,361
36 votes
2 answers
17k views

Datalog vs CLIPS vs Prolog

As many programmers I studied Prolog in university, but only very little. I understand that Prolog and Datalog are closely related, but Datalog is simpler? Also, I believe that I read that Datalog ...
Eli Schneider's user avatar
36 votes
5 answers
4k views

Prolog Constraint Processing : Packing Squares

I'm trying to solve a constraint processing problem in prolog. I need to pack 4 squares of 5x5,4x4,3x3 and 2x2 in a grid of 10x10. They may not overlap. My variables look like this: Name: SqX(i), i=...
Sven's user avatar
  • 1,133
36 votes
2 answers
2k views

What use does if_/3 have?

The predicate if_/3 seems to be fairly popular among the few main contributors in the Prolog part of Stack Overflow. This predicate is implemented as such, courtesy of @false: if_(If_1, Then_0, ...
Fatalize's user avatar
  • 3,533
35 votes
8 answers
21k views

What are the best uses of Logic Programming?

By Logic Programming I mean the a sub-paradigm of declarative programming languages. Don't confuse this question with "What problems can you solve with if-then-else?" A language like Prolog is very ...
mbac32768's user avatar
  • 11.5k
35 votes
3 answers
42k views

Prolog count the number of times a predicate is true

I want to count the number of times a custom predicate is true. For example, I have the following code: is_man(john). is_man(alex). ?:-is_man(X). X will return john, then if I press semicolon it will ...
Victor Blaga's user avatar
  • 1,842
35 votes
2 answers
18k views

How to create a fact in SWI-Prolog?

I just want to create something like: like(x,y). I've been trying for a long time and am really frustrated, could anyone please tell me how to do it???!!!
Hope7's user avatar
  • 355
35 votes
3 answers
6k views

A graph DB vs a Prolog (or miniKanren)

Recently I have been looking into graph databases like Neo4j and into logic programming in Prolog and miniKanren. From what I have learned so far, both allow specifying facts and relations between ...
noncom's user avatar
  • 4,992
34 votes
2 answers
24k views

How do I include a .pl file in Prolog?

I'd like to include code from another source file. Does anyone know how to do that?
cody's user avatar
  • 6,821
34 votes
4 answers
76k views

Prolog - Arguments are not sufficiently instantiated

I am writing a little program which counts how many elements in a list are not numbers. Here is my code: not_number([],0). not_number([X|T],R):- not(number(X)), R1 is R+1, not_number(T,...
Eddwhis's user avatar
  • 1,154
34 votes
2 answers
32k views

Prolog: Clauses are not together in source-file

I have this piece of code: % Family tree female(pen). male(tom). male(bob). female(liz). female(pat). female(ann). male(jim). parent(pam, bob). parent(tom, bob). parent(tom, liz). parent(bob, ann). ...
intelis's user avatar
  • 7,998
33 votes
6 answers
42k views

Lisp and Prolog for Artificial Intelligence? [closed]

Now since i've taken a class 3 years ago in A.I. im clearly proficient enough to ask this question......just kidding just kidding ;) but seriously, what is it about these languages that make them so ...
user avatar
33 votes
2 answers
116k views

"Not equal" sign in Visual Prolog?

I can't find any documentation on "not equal" sign in Visual Prolog. Please provide the right solution of this problem: class predicates sister : (string Person, string Sister) ...
Egor's user avatar
  • 40.1k
33 votes
8 answers
1k views

different/2 - does a pure, determinate definition exist?

different(Xs, Ys) :- member(X, Xs), non_member(X, Ys). different(Xs, Ys) :- member(Y, Ys), non_member(Y, Xs). While this definition using member/2 and non_member/2 is almost1 perfect from ...
false's user avatar
  • 10.3k
33 votes
8 answers
1k views

How to define (and name) the corresponding safe term comparison predicates in ISO Prolog?

Standard term order (ISO/IEC 13211-1 7.2 Term order) is defined over all terms — including variables. While there are good uses for this — think of the implementation of setof/3, this makes many ...
false's user avatar
  • 10.3k
32 votes
3 answers
3k views

Alternatives to the WAM

I remember once reading that there were at least two other alternatives invented roughly at the same time as the WAM. Any pointers?
adamo's user avatar
  • 3,922
32 votes
4 answers
70k views

singleton variables in prolog

I was testing my new version of SWI prolog and keep coming across the error :singleton variable. Example: member(X,[X|T]). member(X,[X|T]) :- member(X,T). finds the member of a list such as : ...
Timothy Lawman's user avatar
31 votes
4 answers
42k views

Implement the member predicate as a one-liner

Interview question! This is how you normally define the member relation in Prolog: member(X, [X|_]). % member(X, [Head|Tail]) is true if X = Head % that is, if X is ...
Claudiu's user avatar
  • 228k
31 votes
1 answer
19k views

Prolog existence_error following Seven Languages in Seven Weeks

I'm just following the book Seven Languages in Seven Weeks. I've installed gprolog in my Mac machine using command port install gprolog-devel and run first prolog code. likes(wallace, cheese). likes(...
Hongseok Yoon's user avatar
31 votes
7 answers
21k views

Integrating Prolog with C# [closed]

Does anyone know of a nice (and preferably free) way to integrate Prolog and C#? Im looking to create a Prolog dll or similar to call from my managed code, and retrieve an answer once all the ...
TK.'s user avatar
  • 47.6k
30 votes
2 answers
150k views

Prolog "or" operator, query

I'm working on some prolog that I'm new to. I'm looking for an "or" operator registered(X, Y), Y=ct101, Y=ct102, Y=ct103. Here's my query. What I want to write is code that will: "return X, given ...
Eogcloud's user avatar
  • 1,365
30 votes
2 answers
13k views

Why is this prolog query both true and false?

My SWI-Prolog knowledge base contains the following two facts: f(a,b). f(a,c). Now if I pose the query ?- f(a,c). true. But ?- f(a,b). true ; false. Why is f(a,b) both true and false? This ...
del's user avatar
  • 301
30 votes
2 answers
1k views

Making "deterministic success" of Prolog goals explicit

The matter of deterministic success of some Prolog goal has turned up time and again in—at least—the following questions: Reification of term equality/inequality Intersection and union of ...
repeat's user avatar
  • 18.7k
29 votes
2 answers
119k views

How do I append lists in Prolog?

How do I append lists in Prolog? I've searched on the Internet and I found this (from http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/2_7.html) append([X|Y],Z,[X|W]) :- append(Y,Z,W). ...
Zik's user avatar
  • 1,576

1
2 3 4 5
270