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.
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 ...
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 ...
I've started learning Prolog and wondering about the theoretical difference from the SQL language.
both are declarative languages
both support a fact-driven knowledge database
What kind of problems is better solved in Prolog than in Haskell? What are the main differences between these two languages?
Is there a Haskell library (kind of a logical solver) that can mimic ...
Probably a stupid question, but I can't find any documentation anywhere for it. 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 ...
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 ...
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 .
I need to write some Prolog programs for a class.
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 ...
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 ...
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)) :-
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.
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 ...
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 ...
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 ...
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 ...
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 ...
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=...
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 ...
different(Xs, Ys) :-
different(Xs, Ys) :-
While this definition using member/2 and non_member/2 is almost1 perfect from ...
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:
have(X,Y) :- course(X),...
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 ...
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 ...
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 ...
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?
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.
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:
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, ...
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 ...
I'd like to write a predicate, descendo, which declares that the first given coordinate [y, x] is descending to the second given coordinate (imagine the board with [0, 0] at the left upper corner).
My SWI-Prolog knowledge base contains the following two facts:
Now if I pose the query
Why is f(a,b) both true and false? This ...
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 ...
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 ...
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 ...
I have come across an unfamiliar bit of Prolog syntax in Lee Naish's paper Higher-order logic programming in Prolog. Here is the first code sample from the paper:
% insertion sort (simple version)
I have an interest in playing and fuxing with prolog, I have installed the swi-prolog and added the repository, just in case anyone is interested on which one commands I used:
% sudo apt-add-...
Many systems provide a pure and efficient implementation of member/2. In particular, no choice point is left open for:
whereas, a naive implementation of member/2 produces ...
I was solving a puzzle in prolog the other day and realized that were I using another programming language, I would have made use of a hash table/dictionary, but as far as I know this isn't really ...
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.
I remember once reading that there were at least two other alternatives invented roughly at the same time as the WAM. Any pointers?
Right now, I'm learning how to interface SICStus Prolog with C code.
I would like to have/use/see a C implementation of "Hamming weight" of arbitrary-sized integers in SICStus Prolog version 4.
ABs = W.
W = 
; W = [a]
; W = [b]
; W = [a,a]
; W = [b,a]
; W = [a,b]
Is it possible to have lazy lists in Prolog? Something like the following:
ones([1 | Y]) :- ones(Y).
Although this obviously doesn't work as it's written.
As time goes by, it appears more and more like functional programming is having more of an effect on other programming languages. We're starting on Prolog in my AI class, and it seems like there are ...
I can't find any documentation on "not equal" sign in Visual Prolog. Please provide the right solution of this problem:
sister : (string Person, string Sister) nondeterm(o,o)....
I want to count the number of times a custom predicate is true.
For example, I have the following code:
X will return john, then if I press semicolon it ...
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???!!!
I was wondering, I am aware you can use assert to add facts or rules or whatever if you have declared the predicate to be -:dynamic, but this only allows the changes that are made to be kept in that ...
I know in Prolog you can do something like
% and so on
This will not iterate over every element in List; instead, it ...
There are some special operators in Prolog, one of them is "is", however, recently I came across the =:= operators, and I have no idea how it works.
Can someone explain what the operator does, and ...