Recently I have come to a simple version of toplevel query syntax for handling ZDD. One of new features is functional syntax. Example queries follows.
% ?- X<< pow([1,2]), Y << pow([a,b]), Z << X + Y, U<< card(Z). %@ X = 3, %@ Y = 5, %@ Z = U, U = 7.
pow(X) computes powerset of X.
X+Y does the union of X and Y.
card(X) does the cardinality of X.
V<<E unifies V with the value E.
1 is equivalent to this.
% ?- U << card(pow([1,2])+pow([a,b])). %@ U = 7.
Usual Prolog term can be used as subexpressions. like this,
% ?- U << card(pow(:append(numlist(1,2), numlist(3, 4)))). %@ U = 16.
:E is a pragma to indicate E to be evaluated in “the last argument as the output” mode.
3 is expanded to this prolog goals using state S explicit, which is hided in the functional syntax.
% ?- open_state(S), numlist(1,2, Ns), numlist(3,4, Ms), append(Ns, Ms, Is), % zdd_power(Is, P, S), card(P, U, S). %@ S = .., %@ Ns = [1, 2], %@ Ms = [3, 4], %@ Is = [1, 2, 3, 4], %@ P = 5, %@ U = 16.
For introducing the new syntax, I dropped completely using
shift/reset because of syntax simplicity.
I am reviewing codes in the main codes file zdd.pl. Some of codes is old enough even for me, the writer, to difficult to catch up with, which is as if someone inserted strange codes. However it’s a kind of hobby to solve these forgotten puzzle I made.