- 1.1.0
This module defines bounded quantifiers, let expressions, and a multifile predicate to create new shorthand notations.
for_all/2 bounded universal quantifier with "in" domain and "where" conditions allowing shorthand/3 notations,
e.g. Array[Indices] notation for subscripted variables defined in library(arrays)
.
The "in" domain must be a finite (union) interval of integers or a list of values.
The "where" condition goal is supposed to be deterministic and just checked for satisfiability without constraining context's variables.
list_of/2 list of values satisfying "in" and "where" conditions.
exists/2 existential quantifier.
let/2 existential quantifier for variables bound to expressions allowing shorthand/3 notations.
apply_list/2, call_list/2, /3/4/5 conjunctive application of a goal on a list of arguments.
indent_term/1 just one example of use of quantifiers to pretty print the tree structure of a term.
?- for_all([I in 1..3, J in I+1..3], writeln((I,J))).
1,2
1,3
2,3
true.
?- for_all([I, J] in 1..3 where I<J, writeln((I,J))).
1,2
1,3
2,3
true.
The "where" condition is a test of satisfiability, not of entailment.
The example below illustrates the difference: X=Y is satisfiable for all X, Y hence the goal is executed for all X, Y,
while in the fourth query, the condition X==Y is always false hence no constraint is posted:
?- L=[A, B, C], for_all(X in L, X=1).
L = [1, 1, 1],
A = B, B = C, C = 1.
?- L=[A, B, C], for_all([X, Y] in L, X=Y).
L = [C, C, C],
A = B, B = C.
?- L=[A, B, C], for_all([X, Y] in L where X=Y, X=Y).
L = [C, C, C],
A = B, B = C.
?- L=[A, B, C], for_all([X, Y] in L where X==Y, X=Y).
L = [A, B, C].