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.

{Reading /tmp/tmpWOH2Ap/len2.pl
}
{loaded in 3412.214 msec.}
{preprocessed for plai in 4.0 msec.}
{analyzed by plai using det with local-control off in 4.001 msec.}
{written file /tmp/tmpWOH2Ap/len2_det_co.pl}
:- module(_1,[len/2],[assertions]).

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

:- true pred len(A,B)
         : ( native_props:mshare([[B]]), ground([A]), gnd(A), term(B) )
        => ( ground([A,B]), rt10(A), rt12(B) )
         + ( is_det, mut_exclusive ).

len([],0).
len(Xs,s(N)) :-
        no(empty(Xs)),
        tail(Xs,Ys),
        len(Ys,N).

:- true pred tail(_1,Xs)
         : ( native_props:mshare([[Xs]]), var(Xs), ground([_1]), gnd(_1), term(Xs) )
        => ( ground([_1,Xs]), rt7(_1), gnd(Xs) )
         + ( is_det, mut_exclusive ).

tail([],[]).
tail([X|Xs],Xs).

empty([]).

:- true pred no(empty(_1))
         : ( ground([_1]), gnd(_1) )
        => ( ground([_1]), gnd(_1) )
         + ( is_det, mut_exclusive ).

no(X) :-
        call(X),
        !,
        failure(a).
no(_1).

:- true pred failure(a).

failure(b).


:- regtype rt11/1.

rt11([]).
rt11(A) :-
        gnd(A).
rt11([A|B]) :-
        gnd(A),
        rt11(B).


:- regtype rt10/1.

rt10([]).
rt10([A|B]) :-
        gnd(A),
        rt11(B).


:- regtype rt13/1.

rt13(0).
rt13(s(A)) :-
        rt13(A).


:- regtype rt12/1.

rt12(0).
rt12(s(A)) :-
        rt13(A).


:- regtype rt7/1.

rt7([]).
rt7([A|B]) :-
        gnd(A),
        gnd(B).