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 3400.213 msec.}
{preprocessed for plai in 0.0 msec.}
{analyzed by plai using det with local-control off in 8.001 msec.}
{written file /tmp/tmp7joBne/flatten_det_co.pl}
:- module(_1,[flatten/2],[assertions]).

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

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

:- true pred flatten(A,B)
         : ( native_props:mshare([[B]]), ground([A]), gnd(A), term(B) )
        => ( ground([A,B]), rt7(A), rt9(B) )
         + ( is_det, mut_exclusive ).

flatten(atom(X),[X]).
flatten(cons(atom(X),U),[X|Y]) :-
        flatten(U,Y).
flatten(cons(cons(U,V),W),X) :-
        flatten(cons(U,cons(V,W)),X).


:- regtype rt8/1.

rt8(atom(A)) :-
        gnd(A).
rt8(cons(atom(A),B)) :-
        gnd(A),
        rt8(B).


:- regtype rt7/1.

rt7(atom(A)) :-
        gnd(A).
rt7(cons(atom(A),B)) :-
        gnd(A),
        rt8(B).


:- regtype rt10/1.

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


:- regtype rt9/1.

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