Ciao Preprocessor (integrated Alpha version)
 | This is an alpha distribution, meant only for testing. Please do let us 
 | know at ciaopp-bugclip.dia.fi.upm.es any problems you may have.

{loaded in 3368.211 msec.}
{preprocessed for plai in 0.0 msec.}
{analyzed by plai using det with local-control off in 4.001 msec.}
{written file /tmp/tmpIiGiQt/countstack_det_co.pl}
:- module(_1,[countstack/2],[assertions]).

:- entry countstack(A,B)
         : ground(A).

:- true pred countstack(push(_1,push(_2,_3)),B)
         : ( native_props:mshare([[B]]), ground([_1,_2,_3]), term(B), gnd(_1), gnd(_2), gnd(_3) )
         + fails.

:- true pred countstack(A,B)
         : ( native_props:mshare([[B]]), ground([A]), gnd(A), term(B) )
        => ( ground([A,B]), rt4(A), rt1(B) )
         + ( is_det, mut_exclusive ).

countstack(empty,0).
countstack(push(nil,T),X) :-
        countstack(T,X).
countstack(push(cons(U,V),T),s(X)) :-
        countstack(push(U,push(V,T)),X).


:- regtype rt5/1.

rt5(empty).
rt5(push(nil,A)) :-
        rt5(A).


:- regtype rt4/1.

rt4(empty).
rt4(push(nil,A)) :-
        rt5(A).


:- regtype rt1/1.

rt1(0).