average-ioi.pl

loading
details
attribute value
description
owner Johannes Waldmann
uploaded 2017-08-17 03:45:07.0
disk size 516 Bytes
downloadable true
type
attribute value
name no_type
processor id 1
description this is the default benchmark type for rejected benchmarks and benchmarks that are not associated with a type.
owning community none
loading contents
%query: average(i,o,i).
/* adapted from "Natural Termination" by Dershowitz and Hoot


  average(A,B,C) :- C is the average of natural numbers A and B

*/

average(0,0,0).
average(0,s(0),0).
average(0,s(s(0)),s(0)).

average(s(X),Y,Z) :- average(X,s(Y),Z).
average(X,s(s(s(Y))),s(Z)) :- average(s(X),Y,Z).


/*
    | ?- average(s(0),s(s(0)),Y).

    Y = s(0) ? ;


    | ?- average(A,B,s(0)).

    A = 0,
    B = s(s(0)) ? ;

    A = s(0),
    B = s(0) ? ;

    A = s(s(0)),
    B = 0 ? ;

    and then diverges

*/
popout

content may be truncated. 'popout' for larger text window.

actions get anonymous link download benchmark