Questions tagged [prolog]

Prolog is the most commonly used logic programming language. It supports non-deterministic programming through chronological backtracking and pattern matching through unification. Do not use this tag like Prologue and Epilogue.

Prolog is the oldest and most popular logic programming language. Its built-in features include non-deterministic programming through backtracking and a powerful parser formalism called Definite Clause Grammars (DCG) . Modern variants often support some form of constraint programming. It is used for automated reasoning, deductive databases, planning and scheduling tasks, natural language processing, engines for web/business rules and is often used to introduce the declarative paradigm in school.

There is an ISO/IEC standard for Prolog .

Further efforts in harmonizing implementations can be found at Prolog Commons.

Prolog-related tags

Core language:

Modules:

Environment:

Arithmetics:

Puzzles:

Problems:

Implementations:

  1. SWI (free)
  2. SICStus (commercial)
  3. GNU (free)
  4. XSB (free)
  5. B (commercial, discontinued, now Picat)
  6. IF (commercial)
  7. Ciao (free)
  8. Minerva (commercial)
  9. ECLiPSe-CLP (free)
  10. Prolog IV (free)
  11. Tau (free)
  12. Scryer (free)
  13. C-Prolog
  14. trealla

free = allows commercial use without royality

Forums

Free Prolog Programming Books

Languages influenced by Prolog

Microsoft Guan

Historical Archive

Prolog and Logic Programming Historical Sources Archive

Useful links

13358 questions
44
votes
6 answers

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 plays a match against everyone else. Produce the…
Ingdas
  • 1,446
  • 1
  • 11
  • 21
43
votes
4 answers

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 . So far, my personal experience with attributed…
repeat
  • 18,496
  • 4
  • 54
  • 166
42
votes
2 answers

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)) :- sum(N,M,K). prod(0,M,0). prod(s(N), M, P) :- …
40
votes
1 answer

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,R) :- R is N*N. ?- map([3,5,-2], test, L). L =…
General_9
  • 2,249
  • 4
  • 28
  • 46
40
votes
10 answers

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. Are there any good libraries for logic programming…
AJ.
  • 27,586
  • 18
  • 84
  • 94
40
votes
7 answers

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 where can I find a predefined list of such special…
nubela
  • 1
  • 24
  • 75
  • 123
40
votes
6 answers

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 example on SO is this answer. All answers and all…
false
  • 10,264
  • 13
  • 101
  • 209
39
votes
2 answers

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 understand how this differs from ==. Follow up: That (see…
JohnS
  • 1,192
  • 1
  • 11
  • 22
39
votes
7 answers

Good IDE to get started with prolog

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: 1) Does Prolog use a compiler to compile the…
ant2009
  • 27,094
  • 154
  • 411
  • 609
38
votes
5 answers

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 that are actually supported by all Prolog systems.…
false
  • 10,264
  • 13
  • 101
  • 209
36
votes
5 answers

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 behind them doesn't really give me a solid…
cYn
  • 3,291
  • 6
  • 25
  • 43
36
votes
2 answers

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, Else_0) :- call(If_1, T), ( T == true ->…
Fatalize
  • 3,513
  • 15
  • 25
36
votes
3 answers

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
  • 28,823
  • 42
  • 111
  • 133
36
votes
5 answers

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=1..10, domain: 1..10 Where X is either 5,4,3 or 2.…
Sven
  • 1,133
  • 1
  • 11
  • 22
35
votes
3 answers

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 them, and also querying the resulting system for…
noncom
  • 4,962
  • 3
  • 42
  • 70