|
354 | 354 | if_t((Depth<1, trace_on_overflow), debug(metta(e))), |
355 | 355 |
|
356 | 356 | trace_eval(eval_10(Eq,RetType),e,Depth2,Self,X,M), |
357 | | - |
| 357 | + %ignore(find_term_cycles(M)), |
358 | 358 | ((M=@=XX;M==X;M=@=X) -> Y=M ; eval_03(Eq,RetType,Depth2,Self,M,Y)). |
359 | 359 |
|
360 | 360 | %eval_03(_Eq,RetType,_Depth2,_Self,M,Y):- RetType=='Atom',!,M=Y. |
| 361 | + |
| 362 | +%eval_03(_Eq,_RetType,_Dpth,_Self,X,Y):- check_term_depth(X,Y),!. |
| 363 | +eval_03(_Eq,_RetType,_Dpth,_Slf,X,Y):- self_eval(X),!,Y=X. |
| 364 | + |
361 | 365 | eval_03(Eq,RetType,Depth2,Self,M,Y):- eval_01(Eq,RetType,Depth2,Self,M,Y). |
362 | 366 |
|
363 | 367 | eval_02(Eq,RetType,Depth,Self,Y,YO):- var(Y),!,YO=Y,var_pass(Eq,RetType,Depth,Self,Y). |
|
397 | 401 | wont_need_substX(Y),!, |
398 | 402 | subst_args_there_real(Eq,RetType,Depth2,Self,Y,YO), |
399 | 403 | use_breakpoints(if_t(Y\=@=YO, |
400 | | - (if_tracemsg(unknown,wont_need_substX(Y)), |
401 | | - rtrace(subst_args_there_real(Eq,RetType,Depth2,Self,Y,YO)),break))). |
| 404 | + (debug_info(subst_args_there,wont_need_substX(Y)), |
| 405 | + (notrace,trace,(rtrace(subst_args_there_real(Eq,RetType,Depth2,Self,Y,YO)),break))))). |
402 | 406 |
|
403 | 407 | subst_args_there(Eq,RetType,Depth2,Self,Y,YO):- |
404 | 408 | subst_args_there_real(Eq,RetType,Depth2,Self,Y,YO), |
405 | 409 | use_breakpoints((if_t( \+ trust_wont_need_substX, |
406 | | - if_t(Y=@=YO, (if_tracemsg(unknown,subst_args_there_real(Y,YO)), |
407 | | - maybe_trace(unknown),rtrace(subst_args_there_real(Eq,RetType,Depth2,Self,Y,YO)),break))))). |
| 410 | + if_t(Y=@=YO, (debug_info(subst_args_there,subst_args_there_real(Y,YO)), |
| 411 | + maybe_trace(failures),rtrace(subst_args_there_real(Eq,RetType,Depth2,Self,Y,YO)),break))))). |
408 | 412 |
|
409 | 413 | subst_args_there_real(Eq,RetType,Depth2,Self,Y,YO):- !, |
410 | 414 | subst_once(subst_args(Eq,RetType,Depth2,Self,Y,YO)*->true;Y=YO). |
|
413 | 417 | subst_once(subst_args(Eq,RetType,Depth2,Self,Y,YO)), |
414 | 418 | %Y =YO, |
415 | 419 | notrace(if_t_else((wont_need_subst(Y),Y\=@=YO), |
416 | | - (write_src_uo(needed_subst_args(Y,YO)),bt,sleep(1.0)), |
| 420 | + (write_src_uo(needed_subst_args(Y,YO)),maybe_bt,sleep(1.0)), |
417 | 421 | nop(write_src_uo(unneeded_subst_args(Y))))). |
418 | 422 |
|
419 | 423 | wont_need_substX(List):- \+ is_list(List),!. |
|
595 | 599 | as_prolog_x(Depth,Self,X,XX), |
596 | 600 | eval_20(Eq,RetType,Depth,Self,XX,Y),sanity_check_eval(eval_20_not_list,Y). |
597 | 601 |
|
| 602 | + |
| 603 | +eval_args_alone(X):- var(X),!,fail. |
| 604 | +%eval_args_alone(X):- \+ callable(X), \+ py_is_callable(X). |
| 605 | +eval_args_alone(':'). |
| 606 | +eval_10(Eq,RetType,Depth,Self,[Fn|Args],Y):- fail, eval_args_alone(Fn), |
| 607 | + is_list(Args),!, |
| 608 | + Y=[Fn|RArgs], mapl_eval_args(Eq,RetType,Depth,Self,Args,RArgs). |
| 609 | + |
598 | 610 | eval_10(Eq,RetType,Depth,Self,[Sym|Args],Y):- \+ atom(Sym), !, |
599 | 611 | maplist(as_prolog_x(Depth,Self), [Sym|Args] , [ASym|Adjusted]), |
600 | 612 | eval_20(Eq,RetType,Depth,Self, [ASym|Adjusted], Y),sanity_check_eval(eval_20_not_atom,Y). |
|
1625 | 1637 | push_attributes(Var,Attrs):- |
1626 | 1638 | push_attributes_onto_var(Attrs,Var), ! . |
1627 | 1639 |
|
1628 | | -push_attributes_onto_var(Attrs,_):- var(Attrs),!,maybe_trace(unknown),break. % var(Var) |
| 1640 | +push_attributes_onto_var(Attrs,_):- var(Attrs),!,maybe_trace(push_attributes_onto_var),break. % var(Var) |
1629 | 1641 | %push_attributes_onto_var(Attrs,Var):- var(Attrs),var(Var),!. |
1630 | | -push_attributes_onto_var(_,Var):- nonvar(Var),!,maybe_trace(unknown),break. % var(Var) |
| 1642 | +push_attributes_onto_var(_,Var):- nonvar(Var),!,maybe_trace(push_attributes_onto_var),break. % var(Var) |
1631 | 1643 | push_attributes_onto_var([], _Var) :- !. |
1632 | 1644 | push_attributes_onto_var(att(Mod, Val, Rest), Var) :- |
1633 | 1645 | get_attr(Var, Mod, Existing), !, |
|
1795 | 1807 | eval_args(Eq,RetType,Depth,Self,Template,Res). |
1796 | 1808 | */ |
1797 | 1809 |
|
1798 | | -%metta_atom_iter(Eq,_Depth,_Slf,Other,[Equal,[F|H],B]):- Eq == Equal,!, % maybe_trace(unknown), |
| 1810 | +%metta_atom_iter(Eq,_Depth,_Slf,Other,[Equal,[F|H],B]):- Eq == Equal,!, % maybe_trace(depth), |
1799 | 1811 | % metta_eq_def(Eq,Other,[F|H],B). |
1800 | 1812 |
|
1801 | 1813 | /* |
1802 | | -metta_atom_iter(Eq,Depth,Self,Other,[Equal,[F|H],B]):- Eq == Equal,!, % maybe_trace(unknown), |
| 1814 | +metta_atom_iter(Eq,Depth,Self,Other,[Equal,[F|H],B]):- Eq == Equal,!, % maybe_trace(depth), |
1803 | 1815 | metta_eq_def(Eq,Other,[F|H],BB), |
1804 | 1816 | eval_sometimes(Eq,_RetType,Depth,Self,B,BB). |
1805 | 1817 | */ |
|
1837 | 1849 |
|
1838 | 1850 |
|
1839 | 1851 | metta_atom_iter_ref(Other,H,Ref):-clause(metta_atom_asserted(Other,H),true,Ref). |
1840 | | -%can_be_ok(A,B):- cant_be_ok(A,B),!,fbug(cant_be_ok(A,B)),trace. |
| 1852 | +%can_be_ok(A,B):- cant_be_ok(A,B),!,fbug(cant_be_ok(A,B)),maybe_trace(depth). |
1841 | 1853 | can_be_ok(_,_). |
1842 | 1854 |
|
1843 | 1855 | cant_be_ok(_,[Let|_]):- Let==let. |
|
2118 | 2130 | eval_20(_Eq,_RetType,_Depth,_Self,['decons-atom',OneArg],[H,T]):- !, must_unify(OneArg,[H|T]). |
2119 | 2131 | eval_20(_Eq,_RetType,_Depth,_Self,['cons-atom'|TwoArgs],[H|T]):-!, must_unify(TwoArgs,[H,T]). |
2120 | 2132 | % NEW |
2121 | | -eval_20(_Eq,_RetType,_Depth,_Self,['decons',OneArg],[H,T]):- !, must_unify(OneArg,[H|T]). |
2122 | | -eval_20(_Eq,_RetType,_Depth,_Self,['cons'|TwoArgs],[H|T]):-!, must_unify(TwoArgs,[H,T]). |
| 2133 | +eval_20(_Eq,_RetType,_Depth,_Self,['decons',OneArg],[H,T]):- fail, !, must_unify(OneArg,[H|T]). |
| 2134 | +eval_20(_Eq,_RetType,_Depth,_Self,['cons'|TwoArgs],[H|T]):- fail, !, must_unify(TwoArgs,[H,T]). |
2123 | 2135 |
|
2124 | 2136 | should_be(P1,Term):- call(P1,Term)-> true ; (debug_info(porting,hyperon_throws_error(should_be(P1,Term))),fail). |
2125 | 2137 |
|
|
2146 | 2158 | eval_10(Eq,RetType,Depth,Self,['unify',Arg1,Arg2|Args],Res):- is_metta_space(Arg1), !, |
2147 | 2159 | eval_args(Eq,RetType,Depth,Self,['match',Arg1,Arg2|Args],Res). |
2148 | 2160 | % 2) If Arg1 and Arg2 are nonvars and Arg1 is declared a `Container`, then use `container-unify` |
2149 | | -eval_10(Eq,RetType,Depth,Self,['unify',Arg1,Arg2|Args],Res):- nonvar(Arg1), nonvar(Arg2), get_type(Depth,Self,Arg1,'Container'),!, |
| 2161 | +eval_10(Eq,RetType,Depth,Self,['unify',Arg1,Arg2|Args],Res):- fail, nonvar(Arg1), nonvar(Arg2), get_type(Depth,Self,Arg1,'Container'),!, |
2150 | 2162 | eval_args(Eq,RetType,Depth,Self,['container-unify',Arg1,Arg2|Args],Res). |
2151 | 2163 | % 3) Otherwise, default to using `if-unify` for the unify operation. |
2152 | 2164 | eval_10(Eq,RetType,Depth,Self,['unify',Arg1,Arg2|Args],Res):- !, |
|
2158 | 2170 | ; (ElseL=[Else],eval_args(Eq,RetType,Depth,Self,Else,Res))). |
2159 | 2171 |
|
2160 | 2172 | eval_10(Eq,RetType,Depth,Self,['if-unify',X,Y,Then|ElseL],Res):- !, |
2161 | | - (if_or_else(X=Y,eval_args_true(Eq,'Bool',Depth,Self,['==',X,Y])) |
| 2173 | + (as_tf( \+ \+ unify_woc(X,Y),TF),if_or_else(TF,eval_args_true(Eq,'Bool',Depth,Self,['metta-unify',X,Y])) |
2162 | 2174 | *-> eval_args(Eq,RetType,Depth,Self,Then,Res) |
2163 | 2175 | ; (ElseL=[Else],eval_args(Eq,RetType,Depth,Self,Else,Res))). |
2164 | 2176 |
|
|
2467 | 2479 | if_or_else(get_type(Depth,Other,Val,Type),Type='%Undefined%'), %term_singletons(Type,[]), %Type\==[], Type\==Val,!, |
2468 | 2480 | do_expander(Eq,RetType,Type,TypeO). |
2469 | 2481 |
|
2470 | | -eval_20(Eq,RetType,Depth,Self,['length',L],Res):- !, eval_args(Eq,RetType,Depth,Self,L,LL), !, (is_list(LL)->length(LL,Res);Res=1). |
| 2482 | +%eval_20(Eq,RetType,Depth,Self,['length',L],Res):- !, eval_args(Eq,RetType,Depth,Self,L,LL), !, (is_list(LL)->length(LL,Res);Res=1). |
2471 | 2483 | eval_20(Eq,RetType,Depth,Self,['CountElement',L],Res):- !, eval_args(Eq,RetType,Depth,Self,L,LL), !, (is_list(LL)->length(LL,Res);Res=1). |
2472 | 2484 |
|
2473 | 2485 | eval_20(_Eq,_RetType,_Depth,_Self,['get-metatype',Val],TypeO):- !, |
|
0 commit comments