:-module(_,[pfxsum/2],[]). '$applied_packages'([prelude,nonpure,condcomp,assertions,regtypes,nativeprops,rtchecks_shallow,predefres(res_steps),resdefs,resdefs/resources_decl,basicmodes,argnames,expander]). :-add_clause_trans(expander_tr:expand_clause/4,9910). :-prop listnum/1+regtype. :-prop listnum(_A)+regtype. :-entry pfxsum(_A,_B):(listnum(_A),var(_B)). :-check calls pfxsum(A,B):(listnum(A),var(B)). :-true success pfxsum(A,B):(listnum(A),var(B))=>listnum(B). :-true pred pfxsum(A,B):(listnum(A),term(B))=>(listnum(A),listnum(B)). :-true pred pfxsum(A,B):(mshare([[B]]),var(B),ground([A]))=>ground([A,B]). :-checked calls pfxsum_i(A,B):(listnum(A),var(B)). :-checked success pfxsum_i(A,B):(listnum(A),var(B))=>listnum(B). :-true pred pfxsum_i(A,B):(listnum(A),term(B))=>(listnum(A),listnum(B)). :-true pred pfxsum_i(A,B):(mshare([[B]]),var(B),ground([A]))=>ground([A,B]). :-checked calls pfxsum_(A,B,C):(num(A),listnum(B),var(C)). :-checked success pfxsum_(A,B,C):(num(A),listnum(B),var(C))=>listnum(C). :-true pred pfxsum_(A,B,C):(num(A),listnum(B),term(C))=>(num(A),listnum(B),listnum(C)). :-true pred pfxsum_(A,B,C):(mshare([[C]]),var(C),ground([A,B]))=>ground([A,B,C]). listnum([]). listnum([X|Y]) :- num(X), listnum(Y). pfxsum(_1,_2) :- 'pfxsum$pre'(_1,_2), 'pfxsum$cls'(_1,_2). 'pfxsum$pre'(_1,_2) :- reify_check(listnum(_1),[_1],_3), reify_check(var(_2),[_2],_4), _5 is _3/\_4, _6 is _5, _7 is _5, _8 is _6\/_7, warn_if_false(_8,'CP'). 'pfxsum$cls'(A,B) :- pfxsum_i(A,B). pfxsum_i([],[]). pfxsum_i(X,Y) :- D=0, pfxsum_(D,X,Y). pfxsum_(_1,[],[]). pfxsum_(N,[X|Y],[X1|LL]) :- X1 is N+X, pfxsum_(X1,Y,LL).