What does \+ mean in Prolog?
It’s the ‘not provable’ operator. It succeeds if its argument is not provable (and fails if its argument is provable).
It’s the ‘not provable’ operator. It succeeds if its argument is not provable (and fails if its argument is provable).
For each square, define X and Y variables that denote the upper left corner. These variable will have domains 1..10-L, where L is the length of the square. If you set the domain to 1..10, the squares may be placed partly outside your 10×10 rectangle. Then you can post constraints for each pair of rectangles … Read more
The most elaborate Prolog IDE I’m familiar with is the Eclipse-based IDE for Amzi! Prolog. This is a commercial product, but the IDE can be downloaded and used for free in the Student Edition. It might be ideal for a beginning Prolog programmer. Disclaimer: I may be biased because I supply a lot of free … Read more
The = “operator” in Prolog is actually a predicate (with infix notation) =/2 that succeeds when the two terms are unified. Thus X = 2 or 2 = X amount to the same thing, a goal to unify X with 2. The == “operator” differs in that it succeeds only if the two terms are … Read more
Well for one thing, the name should be more declarative, like equality_truth/2.
This is usually called maplist/3 and is part of the Prolog prologue. Note the different argument order! :- meta_predicate(maplist(2, ?, ?)). maplist(_C_2, [], []). maplist( C_2, [X|Xs], [Y|Ys]) :- call(C_2, X, Y), maplist( C_2, Xs, Ys). The different argument order permits you to easily nest several maplist-goals. ?- maplist(maplist(test),[[1,2],[3,4]],Rss). Rss = [[1,4],[9,16]]. maplist comes in … Read more
If you want to study termination properties in depth, programs using successor-arithmetics are an ideal study object: You know a priori what they should describe, so you can concentrate on the more technical details. You will need to understand several notions. Universal termination The easiest way to explain it, is to consider Goal, false. This … Read more
I would like to focus on one important general point I noticed when working with different interfaces for attributes variables: When designing an interface for attributed variables, an implementor should also keep in mind the following: Is it possible to take attributes into account when reasoning about simultaneous unifications, as in [X,Y] = [0,1]? This … Read more
In place of not(X = Y) you need to write \+ X = Y or X \= Y. But consider to use dif(X,Y) instead. dif/2 is present in B, SWI, YAP, SICStus. To see the difference: ?- X = b, dif(a, X). X = b. ?- X = b, \+ a = X. X = … Read more
TL;DR: Don’t. The cut prunes Prolog’s search tree. That is, given a pure Prolog program without cut and the same program with cuts the only difference is that the program with cuts might spend less time in fruitless branches, and thus is more efficient ; might have fewer answers ; it might also terminate whereas … Read more