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 3356.209 msec.}
{preprocessed for plai in 0.0 msec.}
{analyzed by plai using det with local-control off in 100.005 msec.}
{written file /tmp/tmpRP77AW/psk09-distance_det_co.pl}
:- module(_1,[distance/5],[assertions]).

:- entry distance(A,B,C,D,E)
         : ( ground(A), ground(B), ground(C), ground(D) ).

:- true pred distance(A,B,C,D,E)
         : ( native_props:mshare([[E]]), ground([A,B,C,D]), gnd(A), gnd(B), gnd(C), gnd(D), term(E) )
        => ( ground([A,B,C,D,E]), rt9(A), rt10(B), rt11(C), rt12(D), rt13(E) )
         + ( is_det, mut_exclusive ).

:- true pred distance(A,B,C,D,E)
         : ( native_props:mshare([[E]]), var(E), ground([A,B,C,D]), num(A), num(B), num(C), num(D), term(E) )
        => ( ground([A,B,C,D,E]), rt4(A), rt5(B), rt6(C), rt7(D), rt8(E) )
         + ( is_det, mut_exclusive ).

distance(_1,_2,1,J,D) :-
        !,
        D is J-1+1.
distance(_1,M,I,M,D) :-
        !,
        D is M+I-2+1.
distance(N,M,N,J,D) :-
        !,
        D is N+2*M-J-2+1.
distance(N,M,I,1,D) :-
        !,
        D is 2*N+2*M-I-3+1.
distance(N,M,I,J,D) :-
        N1 is N-2,
        M1 is M-2,
        I1 is I-1,
        J1 is J-1,
        distance(N1,M1,I1,J1,D1),
        D is 2*N+2*M+D1-4.


:- regtype rt9/1.

rt9(A) :-
        gnd(A).


:- regtype rt10/1.

rt10(A) :-
        gnd(A).


:- regtype rt11/1.

rt11(A) :-
        num(A).
rt11(+A) :-
        rt11(A).
rt11(++A) :-
        arithexpression(A).
rt11(-A) :-
        rt11(A).
rt11(--A) :-
        arithexpression(A).
rt11(\A) :-
        arithexpression(A).
rt11(abs(A)) :-
        arithexpression(A).
rt11(atan(A)) :-
        arithexpression(A).
rt11(ceiling(A)) :-
        arithexpression(A).
rt11(cos(A)) :-
        arithexpression(A).
rt11(exp(A)) :-
        arithexpression(A).
rt11(float(A)) :-
        arithexpression(A).
rt11(float_fractional_part(A)) :-
        arithexpression(A).
rt11(float_integer_part(A)) :-
        arithexpression(A).
rt11(floor(A)) :-
        arithexpression(A).
rt11(integer(A)) :-
        arithexpression(A).
rt11(log(A)) :-
        arithexpression(A).
rt11(round(A)) :-
        arithexpression(A).
rt11(sign(A)) :-
        arithexpression(A).
rt11(sin(A)) :-
        arithexpression(A).
rt11(sqrt(A)) :-
        arithexpression(A).
rt11(truncate(A)) :-
        arithexpression(A).
rt11(A#B) :-
        arithexpression(A),
        arithexpression(B).
rt11(A*B) :-
        rt11(A),
        rt11(B).
rt11(A**B) :-
        arithexpression(A),
        arithexpression(B).
rt11(A+B) :-
        rt11(A),
        rt11(B).
rt11(A-B) :-
        rt11(A),
        rt11(B).
rt11(A/B) :-
        arithexpression(A),
        arithexpression(B).
rt11(A//B) :-
        arithexpression(A),
        arithexpression(B).
rt11(A/\B) :-
        arithexpression(A),
        arithexpression(B).
rt11(A<>B) :-
        arithexpression(A),
        arithexpression(B).
rt11(A\/B) :-
        arithexpression(A),
        arithexpression(B).
rt11(gcd(A,B)) :-
        intexpression(A),
        intexpression(B).
rt11(A mod B) :-
        arithexpression(A),
        arithexpression(B).
rt11(A rem B) :-
        arithexpression(A),
        arithexpression(B).
rt11([A]) :-
        arithexpression(A).


:- regtype rt12/1.

rt12(A) :-
        num(A).
rt12(+A) :-
        rt12(A).
rt12(++A) :-
        arithexpression(A).
rt12(-A) :-
        rt12(A).
rt12(--A) :-
        arithexpression(A).
rt12(\A) :-
        arithexpression(A).
rt12(abs(A)) :-
        arithexpression(A).
rt12(atan(A)) :-
        arithexpression(A).
rt12(ceiling(A)) :-
        arithexpression(A).
rt12(cos(A)) :-
        arithexpression(A).
rt12(exp(A)) :-
        arithexpression(A).
rt12(float(A)) :-
        arithexpression(A).
rt12(float_fractional_part(A)) :-
        arithexpression(A).
rt12(float_integer_part(A)) :-
        arithexpression(A).
rt12(floor(A)) :-
        arithexpression(A).
rt12(integer(A)) :-
        arithexpression(A).
rt12(log(A)) :-
        arithexpression(A).
rt12(round(A)) :-
        arithexpression(A).
rt12(sign(A)) :-
        arithexpression(A).
rt12(sin(A)) :-
        arithexpression(A).
rt12(sqrt(A)) :-
        arithexpression(A).
rt12(truncate(A)) :-
        arithexpression(A).
rt12(A#B) :-
        arithexpression(A),
        arithexpression(B).
rt12(A*B) :-
        rt12(A),
        rt12(B).
rt12(A**B) :-
        arithexpression(A),
        arithexpression(B).
rt12(A+B) :-
        rt12(A),
        rt12(B).
rt12(A-B) :-
        rt12(A),
        rt12(B).
rt12(A/B) :-
        arithexpression(A),
        arithexpression(B).
rt12(A//B) :-
        arithexpression(A),
        arithexpression(B).
rt12(A/\B) :-
        arithexpression(A),
        arithexpression(B).
rt12(A<>B) :-
        arithexpression(A),
        arithexpression(B).
rt12(A\/B) :-
        arithexpression(A),
        arithexpression(B).
rt12(gcd(A,B)) :-
        intexpression(A),
        intexpression(B).
rt12(A mod B) :-
        arithexpression(A),
        arithexpression(B).
rt12(A rem B) :-
        arithexpression(A),
        arithexpression(B).
rt12([A]) :-
        arithexpression(A).


:- regtype rt13/1.

rt13(A) :-
        num(A).


:- regtype rt4/1.

rt4(A) :-
        num(A).


:- regtype rt5/1.

rt5(A) :-
        num(A).


:- regtype rt6/1.

rt6(A) :-
        num(A).


:- regtype rt7/1.

rt7(A) :-
        num(A).


:- regtype rt8/1.

rt8(A) :-
        num(A).