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
4
votes
3 answers

Is there a library/technique to collect statistics for optimal clause ordering in Prolog?

I'm writing a program where I need to see if strings match a particular pattern. Right now I've got this implemented in Prolog as a rule matchesPattern(S), with well over 20 different definition. I end up running all the binary strings up to a…
jmite
  • 8,171
  • 6
  • 40
  • 81
4
votes
1 answer

PROLOG rule returns only first match

I'm trying to implement a findall predicate in Prolog (yes I know it's built in, this is for an assignment). It is written as follows: my_findall(N,P,Pred,L) :- Pred, not(new(N,P)), !, assert(new(N,P)), my_findall(N1,P1,Pred,L1), L=[N,P,L1],…
Epsilon Vector
  • 1,459
  • 2
  • 15
  • 23
4
votes
4 answers

Logics in Prolog

How can I express next 3 sentences in Prolog? All summers are warm. If it not summer, then it is winter. Now it is winter.
user721588
4
votes
2 answers

SWI-Prolog Semantic Web Library and Python Interface

I want to write a Python web application that queries RDF triples using Prolog. I found pyswip for interfacing Python with SWI-Prolog, and I am currently looking into SWI-Prolog's RDF capabilities. I am wondering if anyone has tried this…
John Thompson
  • 1,674
  • 1
  • 20
  • 35
4
votes
2 answers

Prolog insert, modify and delete facts on a separated database text file

I have a prolog database file with lots of facts knowledge.pl. For example: father_of(joe,paul). father_of(joe,mary). mother_of(jane,paul). mother_of(jane,mary). male(paul). male(joe). female(mary). female(jane). % and so on. This file is consulted…
mll
  • 195
  • 2
  • 13
4
votes
2 answers

Guess who-like game in Prolog

I'm developing a Guess Who? game using Prolog. The mechanics of the game are very easy. A player (in this case, the human) chooses one person among many possible ones, and the other player (the computer) starts asking yes/no questions about some…
José Tomás Tocino
  • 9,873
  • 5
  • 44
  • 78
4
votes
2 answers

Prolog: pythagorean triple

I have this code that uses an upper bound variable N that is supposed to terminate for X and Y of the pythagorean triple. However it only freezes when it reaches the upper bound. Wasn't sure how to use the cut to stop the backtracking. Code…
RandellK02
  • 167
  • 1
  • 4
  • 17
4
votes
2 answers

Tree postorder traversal in Prolog

Tree traversal refers to the process of visiting each node in a tree data structure in a systematic way. The postorder traversal in the following image Sorted_binary_tree returns A, C, E, D, B, H, I, G, F (left, right, root). The Prolog code for…
Mark
  • 1,577
  • 16
  • 43
4
votes
2 answers

Forward chaining in YAP Prolog?

I need to use a forward chainer in certain Prolog problem. I would like to avoid to implement it my self from scratch with a vanilla meta-interpreter (but that is what I will have to do if no other option is available) since doing this with a…
Sergio
  • 8,532
  • 11
  • 52
  • 94
4
votes
1 answer

Prolog falling into infinite loop

I have two problems that have bugged me for hours. connected/2 is supposed to judge whether two people are connected or not; distance/3 is supposed to measure the kinship. But: I keep getting trues infinitely for the query connected(x,y); and I'm…
Kang Min Yoo
  • 805
  • 1
  • 9
  • 20
4
votes
1 answer

List of predicates in Prolog

Is it possible to define a list, that consists of predicates and how do I call the predicates. Also, is it possible to pass one predicate to another predicate (like passing atoms)? Example: pre1:- something. pre2(Predicate1, List):- …
Rob Fox
  • 5,355
  • 7
  • 37
  • 63
4
votes
1 answer

Prolog recursion grammar

at the moment I am having a problem with looping back to noun_phrase from np2. I was wondering if someone can help me loop back to noun_phrase. Here is some code: noun_phrase([X|T],(det(X), NP2),Rem):- det(X), …
DorkMonstuh
  • 819
  • 2
  • 19
  • 38
4
votes
2 answers

Why does Prolog crash in this simple example?

likes(tom,jerry). likes(mary,john). likes(mary,mary). likes(tom,mouse). likes(jerry,jerry). likes(jerry,cheese). likes(mary,fruit). likes(john,book). likes(mary,book). likes(tom,john). likes(john,X):-likes(X,john), X\=john. Hi there, above is a…
Max
  • 3,824
  • 8
  • 41
  • 62
4
votes
1 answer

How to go about a type checker in prolog?

So I am new to prolog and I am suppose to implement a type checker. How exactly should I go about it? This would be an example: String s; int i; i = s.length(); // OK (example given in the homework) When I asked the professor how things will be…
Andy
  • 10,553
  • 21
  • 75
  • 125
4
votes
2 answers

"Who is the barber" logic puzzle in Prolog

I'm reading Raymond Smullyan's "To mock a Mockingbird". In the book there is a puzzle that goes like this: Any resemblance between the Seville of this story and the famous Seville of Spain (which in fact there isn't) is purely coincidental.…
Jan Stolarek
  • 1,409
  • 1
  • 11
  • 21
1 2 3
99
100