A transparent revision on interface with ZDD library

I have simplified interfaces with ZDD library so that
hybrid expressions on ZDD and the usual Prolog term can be mixed with transparent way.
The idea is to restrict pragmas to three # , $, and : observing these three are enough. Also @ is allowed but, it only to decrease use of the quote $ symbol.

Due to this revision, now an old demo cgi Counting members of a ZDD is simplified. In fact the following lines are all this demo cgi needed.
Note that this cgi directly uses the zdd library main predicate zdd/1 without any additional prolog codes, which is a big difference from the old one.

Among other revisions, I spent some time for writing a foundation on ZDD using a coalgebra notion on a very simple operation, say F, which is defined roughly F(X)= A x X x X,
where A is well-founded linear countable ordered set (atoms). It might be a folklore, but I was interested in the relation between the F-colagebra of the set of families over A and the set of ZDD which is so called extentional, zero-suppressed, well-founded, and order-admissible, precise definition are in the note.

Simplified script.

<script>
ev({exp: "(peek(@command), herbrand_in_context, plain_zdd:zdd_demo)",
	area: "command",
	echo: false,
    });
</script>
zdd_demo(E, C):- call_with_time_limit(10, zdd((X<< E, card(X, C)))).

What follows is a updated cheat sheet for the next version of ZDD library; the current version pac-1.6.6. One of favorite queries is at the end of the list of sample queries, which has zdd term inside prolog arithmetic predicate plus/3, which is not allowed in the previous version so far.

%% zdd_eval(+E, -V, +S) is det.
%   V is the value of an expression E with working on a state S.
%	x			x  (nummber, string, or list)
%
%	set(L)		{L}		a singleton family.
%	*(L)		<==>	set(L)
%	atom(a)		{{a}}   singleton family.
%	{a,b,..}	{a, b, c, ...} a family of sets a, b, ...
%	fos(list of lists)	a family of sets a, b, ...
%   +		join (union)
%	-		subtract
%	\		subtract
%	&		intersection
%	*		merge/multiply
%	merge   <===> *
%	//		quotient
%	/		remainder
%	prod	product
%	**		product
%	pow		powerset
%	power	<==> pow
%	sets	convert to a form of list of lists
%	cnf		CNF
%	dnf		DNF
%   cofact/3	cofact  (for tutorial purpose, to be dropped)
%   cofact/1	cofact  (for tutorial purpose), to be dropped)
%   fact/1		cofact  (for tutorial purpose), to be dropped)
%	$E		E (quote).
%   :E		eval E as a usual prolog term, but  keeping the state.
%	#E		eval E as a ZDD term with referering to the state
%   @E		call E without evaluating args depending on modes
%   E		evaluate args of E and then apply it.
%% All queries run as expectee. [2022/09/17]
%
% ?- zdd((X<<pow([a,b]), #card(X, C))).
% ?- zdd((X<<pow([a,b]), @card(X, C))).
% ?- zdd((X<<(pow([a,b])-pow([a])), @card(X, C))).
% ?- zdd((X<< a, psa(X))).
% ?- zdd((X<< atom(a), psa(X))).
% ?- zdd((X<< atom(a(1)), psa(X))).
% ?- zdd((X<< set(:(append([1,2],[3,4]))), psa(X))).
% ?- zdd((X<< +(:append([1,2],[3,4])), psa(X))).
% ?- zdd((X<< (a+b), psa(X))).
% ?- zdd((X<< ((a+b)*c), psa(X))).
% ?- zdd((X<< [a,b])).
% ?- zdd((X<< set(:(append([a,b],[c,d]))))).
% ?- zdd((X<< set([1]), Y<< (X+X), psa(X))).
% ?- zdd((X<< set([1]), psa(X))).
% ?- zdd((X<< set([]))).
% ?- zdd((X<< fos([]))).
% ?- zdd((X<< fos([[]]))).
% ?- zdd((X << {[a], [b], [c]}, psa(X))).
% ?- zdd((X << {[a], [b], [c]}, card(X, C))).
% ?- zdd((X<< pow(:append(numlist(1,3), numlist(4,5))), card(X, C))).
% ?- zdd((X<< set(:append(numlist(1,2), numlist(4,5))))).
% ?- zdd((X<< set(:append(:numlist(1,10), :numlist(11,20))))).
% ?- zdd((numlist(1,10,A), numlist(11,20, B), X<< pow( :append(A, B)),
%	card(X, C))).
% ?- zdd((X << pow(:(numlist(1,2))), card(X, C))).
% ?- zdd((X << pow([a,b]))).
% ?- zdd((X << *[a, b, c])).
% ?- zdd((X << (*[a, b, c] + *[1,2,3]), psa(X))).
% ?- zdd((C << card(pow([a,b,c,1,2,3])))).
% ?- zdd((C << card(pow(:append([a,b,c], [1,2,3]))))).
% ?- zdd((C << pow(:numlist(1, 3)))).
% ?- zdd((C << atom(a), psa(C))).
% ?- zdd((C << atom(a), psa(C))).
% ?- zdd((C << atom([a]), psa(C))).
% ?- zdd(((C<< pow(:charlist(a,b)), card(C, N)))).
% ?- zdd(((C<< pow(:atomlist($(a(1,10)))), card(C, N)))).
% ?- zdd(((C<< pow(@(atomlist(a(1,10)))), card(C, N)))).
% ?- zdd(((C<< pow(:charlist($a, $b)), card(C, N)))).
% ?- zdd(((C<< pow(:charlist(a, b)), card(C, N)))).
% ?- zdd((C<< pow(:charlist(a,b)), card(C, N))).
% ?- zdd((C<< pow(@(charlist(a,b))), card(C, N))).
% ?- zdd((C<< set(:charlist(a,z)))).
% ?- zdd((C<< :charlist(a,z))).
% ?- zdd((C<< charlist(a-b))).		% fail
% ?- zdd((U << *(:append([a], [b])))).
% ?- zdd((U << (#append([a], [b])))).  % ERROR
% ?- zdd((U << *(:append(:append([a], [b]), :append([c], [d]))), card(U, C))).
% ?- zdd((X << atom($(a-z)), card(X, C))).
% ?- zdd(C << card(pow(:numlist(0, 100)))).
% ?- zdd(C << card(pow(:(numlist(0, 100))))).
% ?- zdd((X << pow([a, b, c]), zdd_super_power([a, b], X, Y), psa(Y))).
% ?- zdd((U << (pow(:append([a], [b])) + pow(:append([c], [d]))), card(U, C))).
% ?- zdd((U << (pow(:append([a], [b])) + pow([1, 2])), card(U, C))).
% ?- zdd((U << (pow([a])+pow([b,c]) + pow(@charlist((a-z)))), card(U, C))).   % false
% ?- zdd((U << (pow([a])+pow([b,c]) + pow(:(charlist(a,z)))), card(U, C))).
% ?- zdd((U << (pow([a])*b*c), psa(U))).
% ?- zdd((U << (pow([a])*b*c))).
% ?- zdd((U << (pow([a])), psa(U))).
% ?- zdd((U << (pow([a])* b), psa(U))).
% ?- zdd((U << (pow([a])* b), psa(U))).
% ?- zdd((U << (a*b*c), psa(U))).
% ?- zdd((U << a, psa(U))).
% ?- zdd((U << a, ?(sets(U, S)))).
% ?- zdd((U << a, shift(sets(U, S)))).
% ?- zdd((U << (a+b), psa(U))).
% ?- zdd((U << (a*b+c*d), psa(U))).
% ?- zdd((U << ((a+b)*(c+d)), psa(U))).
% ?- zdd((U << ((a+b)*1), psa(U))).
% ?- zdd((U << ((a+1+b)*1*1*1), psa(U))).
% ?- zdd((U << ((a+1+b) / (a+b)), psa(U))).
% ?- zdd((U << ((a+1+b) / (a*b)), psa(U))).
% ?- zdd((U << (pow(:charlist(a, b)) mod (a+b)), psa(U))).
% ?- zdd((U << ((a+b+c)*(x+y+z)), psa(U))).
% ?- zdd((U << (atom(1)*(x+y+z)), psa(U))).
% ?- zdd((U << #(get_compare))).
% ?- zdd((U << *(:(append([a,b,c], [1,2,3]))))).
% ?- zdd((U << +(:(append([a,b,c], [1,2,3]))))).
% ?- zdd((U << +(:(append(:append([a,b,c], [x,y,z]), [1,2,3]))))).
% ?- zdd((U << card(pow(:(append(:append([a,b,c], [x,y,z]), [1,2,3])))))).
% ?- zdd((U << @(=(3)))).
% ?- zdd((U << :(=(3)))).
% ?- zdd((U << *([1,2,3]), psa(U))).
% ?- zdd((U << :plus(#(card(pow([a,b]))), #(card(pow([1,2])))))).