Library(pac/zdd) can handle families of lists with extentionality as well as the standard families of sets. In fact, for each given family F of lists, a unique id integer i is given, written i → F, in such a way that with i → F, and j → G, 1 and 2 are equivalent.
Extentionality
- i = j
- F = G as sets of lists .
Wihtout going to details, let me use a sample predicate coalgebra_for_signature/5
, which I wrote yesterday in an half hour including comments, and its sample queries below.
I am not sure if there exists similar predicates to coalgebra_for_signature/5
in ordinal prolog programming, but I remember vaguely I saw an announcement somewhere on the net on such library without descriptions, and I have still no other relevant information.
Programming on families of lists with extentionaly is just an extention of the well-known cons-car-cdr
prgraming on binary cells in Lisp to that on families of lists as seen in the codes below.
I would be glad to find readers on this forum who shares interest with such extentionality programming in Prolog. IMO, Minoto’s zero suppress rule of ZDD could be generalized on families of ZDD(X) like ZDD(sets), ZDD(lists), ZDD(assignments), etc, though I did not mention explicitly so far, and I haven’t formalized yet precisely.
%! coalgebra_for_signature(+D, +Sgn, +As, -E, +S) is det.
% E is unified with the set of all functions from D
% to the set of signature terms over signature Sgn and
% with arguments in As.
% ?- zdd coalgebra_for_signature([x], [f/1], [x], E), psa(E).
%@ zid = 5
%@ [(x->f(x))]
%@ -------------------
%@ E = 5.
% ?- zdd coalgebra_for_signature([x,y], [f/1,g/2], [x,y,1], E), psa(E).
%@ zid = 373
%@ [(x->g(y,y)),(y->g(y,y))]
%@ [(x->g(y,y)),(y->g(y,x))]
%@ [(x->g(y,y)),(y->g(y,1))]
%@ [(x->g(y,y)),(y->g(x,y))]
%@ [(x->g(y,y)),(y->g(x,x))]
%@ [(x->g(y,y)),(y->g(x,1))]
%@ [(x->g(y,y)),(y->g(1,y))]
%@ [(x->g(y,y)),(y->g(1,x))]
%@ [(x->g(y,y)),(y->g(1,1))]
%@ [(x->g(y,y)),(y->f(y))]
%@ [(x->g(y,y)),(y->f(x))]
%@ [(x->g(y,y)),(y->f(1))]
%@ [(x->g(y,x)),(y->g(y,y))]
%@ [(x->g(y,x)),(y->g(y,x))]
%@ [(x->g(y,x)),(y->g(y,1))]
%@ [(x->g(y,x)),(y->g(x,y))]
%@ [(x->g(y,x)),(y->g(x,x))]
%@ [(x->g(y,x)),(y->g(x,1))]
%@ [(x->g(y,x)),(y->g(1,y))]
%@ [(x->g(y,x)),(y->g(1,x))]
%@ [(x->g(y,x)),(y->g(1,1))]
%@ [(x->g(y,x)),(y->f(y))]
<snip many lines>
%@ -------------------
%@ E = 373.
% ?- time((zdd coalgebra_for_signature([x,y,z,u,v], [f/2,g/2,h/2],
% [x,y,z,u,v,0,1], E), card(E, C))).
%@ % 12,546,674 inferences, 1.040 CPU in 1.062 seconds (98% CPU, 12068183 Lips)
%@ E = 173825,
%@ C = 68641485507.
coalgebra_for_signature(D, Sgn, As, E, S):-
signature(Sgn, As, T, S),
signature_map(D, T, E, S).
%
signature_map([], _, 1, _):-!.
signature_map([X|Xs], T, E, S):-
signature_map(Xs, T, E0, S),
extend_signature_map(X, T, E0, E, S).
%
extend_signature_map(_, 0, _, 0, _):-!.
extend_signature_map(_, 1, E, E, _):-!.
extend_signature_map(X, T, E, F, S):- cofact(T, t(A, L, _), S),
extend_signature_map(X, L, E, E0, S),
l_cons(X->A, E, E1, S),
zdd_join(E0, E1, F, S).
l_cons(_, 0, 0, _):-!.
l_cons(A, 1, U, S):-!, zdd_singleton(A, U, S).
l_cons(A, Y, U, S):- cofact(Y, t(B, L, R), S),
l_cons(A, L, L0, S),
l_append([A, B], R, R0, S),
zdd_join(L0, R0, U, S).
%
l_append([], X, X, _).
l_append([A|As], X, Y, S):-
l_append(As, X, X0, S),
cofact(Y, t(A, 0, X0), S).