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 4.0 msec.}
{analyzed by plai using det with local-control off in 8.001 msec.}
{written file /tmp/tmpX9sTB4/gopher1_det_co.pl}
:- module(_1,[gopher/2],[assertions]).

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

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

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

gopher(nil,L) :-
        !,
        eq(L,nil).
gopher(X,Y) :-
        head(X,nil),
        !,
        tail(X,T),
        eq(Y,cons(nil,T)).
gopher(X,Y) :-
        head(X,H),
        head(H,U),
        tail(H,V),
        tail(X,W),
        gopher(cons(U,cons(V,W)),Y).

:- true pred head(_2,_1)
         : ( native_props:mshare([[_2],[_1]]), var(_1), rt29(_2), term(_1) ).

:- true pred head(_1,nil)
         : ( native_props:mshare([[_1]]), rt28(_1) ).

:- true pred head(_2,_1)
         : ( native_props:mshare([[_2],[_1]]), var(_1), term(_2), term(_1) )
        => ( native_props:mshare([[_2],[_2,_1],[_1]]), rt19(_2), term(_1) )
         + ( is_det, mut_exclusive ).

:- true pred head(_2,_1)
         : ( native_props:mshare([[_1]]), var(_1), ground([_2]), gnd(_2), term(_1) )
        => ( native_props:mshare([[_1]]), ground([_2]), rt16(_2), term(_1) )
         + ( is_det, mut_exclusive ).

:- true pred head(_1,nil)
         : ( ground([_1]), gnd(_1) )
        => ( ground([_1]), rt6(_1) )
         + ( is_det, mut_exclusive ).

head([],_1).
head([X|_1],X).

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

:- true pred tail(_1,X)
         : ( native_props:mshare([[_1],[X]]), var(X), rt19(_1), term(X) )
        => ( native_props:mshare([[_1],[_1,X]]), rt23(_1), term(X) )
         + ( is_det, mut_exclusive ).

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

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

:- true pred eq(X,cons(nil,_1))
         : ( native_props:mshare([[X]]), ground([_1]), term(X), gnd(_1) )
        => ( ground([X,_1]), rt11(X), gnd(_1) )
         + ( is_det, mut_exclusive ).

:- true pred eq(X,nil)
         : ( native_props:mshare([[X]]), term(X) )
        => ( ground([X]), rt0(X) )
         + ( is_det, mut_exclusive ).

eq(X,X).


:- regtype rt12/1.

rt12([]).
rt12(nil).
rt12([A|B]) :-
        rt4(A),
        gnd(B).


:- regtype rt13/1.

rt13(nil).
rt13(cons(nil,A)) :-
        gnd(A).


:- regtype rt29/1.

rt29(cons(A,cons(B,C))) :-
        term(A),
        term(B),
        gnd(C).


:- regtype rt28/1.

rt28(cons(A,cons(B,C))) :-
        term(A),
        term(B),
        gnd(C).


:- regtype rt16/1.

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


:- regtype rt27/1.

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


:- regtype rt19/1.

rt19([]).
rt19([A|B]) :-
        term(A),
        term(B).


:- regtype rt23/1.

rt23([]).
rt23([A|B]) :-
        term(A),
        term(B).


:- regtype rt11/1.

rt11(cons(nil,A)) :-
        gnd(A).


:- regtype rt6/1.

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


:- regtype rt4/1.

rt4(nil).


:- regtype rt10/1.

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


:- regtype rt0/1.

rt0(nil).