times2.pl

loading
details
attribute value
description
owner Johannes Waldmann
uploaded 2017-08-17 03:45:07.0
disk size 426 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: times(i,i,o).

/* yet another multiplication example inspired from term rewriting */

even(0,true).
even(s(0),false).
even(s(s(X)),B) :- even(X,B).
half(0,0).
half(s(s(X)),s(Y)) :- half(X,Y).
plus(0,Y,Y).
plus(s(X),Y,s(Z)) :- plus(X,Y,Z).
times(0,Y,0).
times(s(X),Y,Z) :- even(s(X),B), if(B,s(X),Y,Z).
if(true,s(X),Y,Z) :- half(s(X),X1), times(X1,Y,Y1), plus(Y1,Y1,Z).
if(false,s(X),Y,Z) :- times(X,Y,U), plus(Y,U,Z).
popout

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

actions get anonymous link download benchmark