%sexpr_s2p(Fn,Nth,[S|TERM],PTERM):- (number(S); (atom(S),fail,atom_concat_or_rtrace(_,'Fn',S))),sexpr_s2p_arglist(Fn,Nth,[S|TERM],PTERM),!. %sexpr_s2p(Fn,Nth,[S],O):- is_ftVar(S),sexpr_s2p(Fn,Nth,S,Y),!,z_univ(Fn,Nth,O,[Y]),!. %sexpr_s2p(Fn,Nth,[S],O):- nonvar(S),sexpr_s2p(Fn,Nth,S,Y),!,z_univ(Fn,Nth,O,[Y]),!. %sexpr_s2p(Fn,Nth,[S|TERM],PTERM):- S==and,!,zalwayz((maplist(sexpr_s2p,TERM,PLIST),list_to_conjuncts(',',PLIST,PTERM))). % sexpr_s2p(Fn,Nth,[S|TERM],PTERM):- iz_va_relation(S),!,zalwayz((maplist(sexpr_s2p,TERM,PLIST),list_to_conjuncts(S,PLIST,PTERM))). %sexpr_s2p(Fn,Nth,[S|TERM],PTERM):- iz_relation_sexpr(S),zalwayz((sexpr_s2p_arglist(Fn,Nth,TERM,PLIST),PTERM =~ [S|PLIST])),!. %sexpr_s2p(Fn,Nth,STERM,PTERM):- STERM =~ [S|TERM],sexpr_s2p_arglist(Fn,Nth,TERM,PLIST),z_univ(Fn,Nth,PTERM,[S|PLIST]),!. sexpr_s2p(Fn,Nth,[S|STERM0],PTERM):- sexpr_s2p_pre_list(Fn,Nth,STERM0,STERM), sexpr_s2p_arglist(S,1,STERM,PLIST), z_univ(Fn,Nth,PTERM,[S|PLIST]),!. sexpr_s2p(_Fn,_Nth,VAR,VAR). expects_type(Fn,Nth,Type):- get_operator_typedef(Self,Fn,Params,RetType), nth0(Nth,[RetType|Params],Type),nonvar(Type). will_become_type(Type,S,P):- try_adjust_arg_types(=,_RetType,88,_Self,[Type],[S],[PS]),PS=P,!. will_become_type(Type,S,P):- is_ftVar(S),!,P=S. will_become_type(Type,S,P):- get_type(S,T),!, (is_subtype(T,Type)->S=P; P=coerce(Type,S)). will_become_type(_Type,S,P):-!,S=P. is_subtype(T,TT):- T=@=TT,!,T=TT. is_subtype(T,TT):- T=TT,!. iz_quoter('#BQ'):- iz_common_lisp. iz_quoter('#COMMA'):- iz_common_lisp. iz_quoter('quote'). iz_quoter(superpose). iz_fun_argz(list(_),_). iz_fun_argz(defmacro,2). iz_fun_argz(defun,2). iz_fun_argz(let,1). iz_fun_argz('let*',1). iz_fun_argz('member',2). %iz_fun_argz('let*',2). iz_fun_argz(F,1):- iz_quoter(F). z_functor(F):- \+ atom(F), !,fail. z_functor(F):- \+ atom_concat('?',_,F). z_functor(F):- \+ atom_concat('$',_,F). %z_univ(_Fn,1,S,S):-!. z_univ(_Fn,_,P,[F|ARGS]):- z_functor(F),is_list(ARGS),length(ARGS,A),l_arity_l(F,A),compound_name_arguments(P,F,ARGS),!. z_univ(_Fn,0,P,[F|ARGS]):- z_functor(F),is_list(ARGS),compound_name_arguments(P,F,ARGS),!. z_univ(_Fn,_Nth,P,[F|ARGS]):- z_functor(F),is_list(ARGS),compound_name_arguments(P,F,ARGS),!. z_univ(_Fn,_Nth,P,S):-P=S. l_arity_l(F,A):- clause_b(arity(F,A)). l_arity_l(function,1). l_arity_l(quote,1). l_arity_l('#BQ',1):- iz_common_lisp. l_arity_l(F,A):-current_predicate(F/A). l_arity_l(_,1). sexpr_s2p_arglist(_Fn,_,VAR,VAR):-is_ftVar(VAR),!. sexpr_s2p_arglist(Fn,Nth,[S|SList],[P|PList]):-sexpr_s2p(Fn,Nth,S,P), (Nth>0->Nth2 is Nth+1;Nth2=0),sexpr_s2p_arglist(Fn,Nth2,SList,PList),!. sexpr_s2p_arglist(Fn,Nth,S,P):-sexpr_s2p(Fn,Nth,S,P),!. sexpr_s2p_arglist(_Fn,_Nth,VAR,VAR). sexpr_s2p_pre_list(_Fn,_,STERM,STERM):- \+ compound(STERM), !. sexpr_s2p_pre_list(_Fn,_,STERM,STERM):- \+ is_list(STERM), !. % sexpr_s2p_pre_list(Fn,_,[S|STERM],[S|STERM]):- STERM == [], !.