:- use_module(library(clpfd)).

domain(L, Min, Max) :-
        L ins Min..Max.

:- op(760,  yfx, #<=>).
:- op(750,  xfy, #=>).
:- op(750,  yfx, #<=).

X #<=> Y :- X #<==> Y.

X #=> Y :-  X #==> Y.

X #<= Y :-  X #<== Y.

count(Val,List,RelOp,Count)  :-
        maplist(to_c(Val), List, Bs),
        sum(Bs, RelOp, Count).

to_c(Val, X, B) :-
        X #= Val #<==> B.

minimum(Min, [V|Vs]) :-
        foldl(mymin, Vs, V, Min).

maximum(Min, [V|Vs]) :-
        foldl(mymax, Vs, V, Min).

mymin(X, Y, Min) :- Min #= min(X, Y).

mymax(X, Y, Max) :- Max #= max(X, Y).

table(Tuples, Table) :-
       tuples_in(Tuples, Table).


