Skip to content

Commit 345306c

Browse files
committed
100% on roman chainer (not the tests yet) and nils ai-dsl
1 parent a51585e commit 345306c

File tree

4 files changed

+28
-49
lines changed

4 files changed

+28
-49
lines changed

prolog/metta_lang/metta_eval.pl

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969

7070
%self_eval0(X):- var(X),!,fail.
7171
self_eval0(X):- \+ callable(X),!.
72-
self_eval0(X):- is_list(X),maplist(var,X),!.
7372
self_eval0(X):- is_valid_nb_state(X),!.
7473
%self_eval0(X):- string(X),!.
7574
%self_eval0(X):- number(X),!.
@@ -301,6 +300,8 @@
301300

302301
eval_args(Eq,RetType,Depth,Self,X,Y):- atom(Eq), ( Eq \== ('='), Eq \== ('match')) ,!,
303302
call(call,Eq,'=',RetType,Depth,Self,X,Y).
303+
304+
eval_args(_Eq,_RetType,_Dpth,_Slf,X,Y):- self_eval(X),!,Y=X.
304305
eval_args(Eq,RetType,Depth,Self,X,Y):-
305306
eval_00(Eq,RetType,Depth,Self,X,Y).
306307
%eval_ret(Eq,RetType,1000,Self,X,Y):- !,
@@ -355,14 +356,10 @@
355356
if_t((Depth<1, trace_on_overflow), debug(metta(e))),
356357

357358
trace_eval(eval_10(Eq,RetType),e,Depth2,Self,X,M),
358-
%ignore(find_term_cycles(M)),
359+
359360
((M=@=XX;M==X;M=@=X) -> Y=M ; eval_03(Eq,RetType,Depth2,Self,M,Y)).
360361

361362
%eval_03(_Eq,RetType,_Depth2,_Self,M,Y):- RetType=='Atom',!,M=Y.
362-
363-
%eval_03(_Eq,_RetType,_Dpth,_Self,X,Y):- check_term_depth(X,Y),!.
364-
eval_03(_Eq,_RetType,_Dpth,_Slf,X,Y):- self_eval(X),!,Y=X.
365-
366363
eval_03(Eq,RetType,Depth2,Self,M,Y):- eval_01(Eq,RetType,Depth2,Self,M,Y).
367364

368365
eval_02(Eq,RetType,Depth,Self,Y,YO):- var(Y),!,YO=Y,var_pass(Eq,RetType,Depth,Self,Y).
@@ -609,13 +606,6 @@
609606
is_list(Args),!,
610607
Y=[Fn|RArgs], mapl_eval_args(Eq,RetType,Depth,Self,Args,RArgs).
611608

612-
613-
% DMILES @ TODO make sure this isnt an implicit curry
614-
eval_10(Eq,RetType,Depth,Self,[V|VI],[V|VO]):- V==':',is_list(VI),!,
615-
mapl_eval_args(Eq,RetType,Depth,Self,VI,VO).
616-
eval_10(Eq,RetType,Depth,Self,[V|VI],VO):- is_list(V),V=[HV,_,_],HV==':',is_list(VI),!,
617-
mapl_eval_args(Eq,RetType,Depth,Self,[V|VI],VO).
618-
619609
eval_10(Eq,RetType,Depth,Self,[Sym|Args],Y):- \+ atom(Sym), !,
620610
maplist(as_prolog_x(Depth,Self), [Sym|Args] , [ASym|Adjusted]),
621611
eval_20(Eq,RetType,Depth,Self, [ASym|Adjusted], Y),sanity_check_eval(eval_20_not_atom,Y).
@@ -818,11 +808,6 @@
818808
((eval_args(Eq,_FRype,Depth,Self,V,VV), V\=@=VV)*-> true; VV = V),
819809
eval_args(Eq,RetType,Depth,Self,[VV|VI],VO).
820810

821-
822-
% DMILES @ TODO make sure this isnt an implicit curry
823-
eval_20(Eq,RetType,Depth,Self,[V|VI],VO):- is_list(V),V=[HV,_,_],HV==':',is_list(VI),!,
824-
mapl_eval_args(Eq,RetType,Depth,Self,[V|VI],VO).
825-
826811
% DMILES @ TODO make sure this isnt an implicit curry
827812
eval_20(Eq,RetType,Depth,Self,[V|VI],VO):- \+ callable(V), is_list(VI),!,
828813
mapl_eval_args(Eq,RetType,Depth,Self,[V|VI],VO).
@@ -1029,7 +1014,6 @@
10291014

10301015

10311016
eval_until_eq(_Flags, Eq, XType, YType,_Dpth,_Slf,X,Y,TF):- X==Y,!,check_returnval(Eq,XType,X),check_returnval(Eq,YType,Y),TF='True'.
1032-
eval_until_eq(_Flags, Eq, XType, YType,_Dpth,_Slf,X,Y,TF):- X=@=Y,!,check_returnval(Eq,XType,X),check_returnval(Eq,YType,Y),TF='True'.
10331017
eval_until_eq(_Flags,_Eq,_XType,_YType,_Dpth,_Slf,X,Y,TF):- notrace(as_tf_nowarn(X=:=Y,TF)),!.
10341018
eval_until_eq(_Flags,_Eq,_XType,_YType,_Dpth,_Slf,X,Y,TF):- notrace(as_tf_nowarn('#='(X,Y),TF)),!.
10351019
%eval_until_eq(Flags,Eq,XType,YType,_Dpth,_Slf,X,Y,TF):- X\=@=Y,unify_woc(X,Y),!,check_returnval(Eq,XType,YType,Y,TF).
@@ -2193,9 +2177,10 @@
21932177
*/
21942178

21952179
eval_10(Eq,RetType,Depth,Self,['if-unify',X,Y,Then|ElseL],Res):- !,
2196-
(eval_args_true(Eq,'Bool',Depth,Self,['metta-unify',X,Y])
2197-
*-> eval_args(Eq,RetType,Depth,Self,Then,Res)
2198-
; (ElseL=[Else],eval_args(Eq,RetType,Depth,Self,Else,Res))).
2180+
%(eval_args_true(Eq,'Bool',Depth,Self,['metta-unify',X,Y])
2181+
(as_tf( \+ \+ unify_woc(X,Y),TF),if_or_else((TF=='True',X=Y),eval_args_true(Eq,'Bool',Depth,Self,['metta-unify',X,Y]))
2182+
*-> eval_args(Eq,RetType,Depth,Self,Then,Res)
2183+
; (ElseL=[Else],eval_args(Eq,RetType,Depth,Self,Else,Res))).
21992184

22002185

22012186

@@ -3510,7 +3495,7 @@
35103495
*/
35113496
%eval_40(Eq,RetType,_Dpth,_Slf,['==',X,Y],Res):- !, subst_args(Eq,RetType,_Dpth,_Slf,['==',X,Y],Res).
35123497

3513-
eval_20(_Eq,_RetType,_Depth,_Self,['==', X,Y],TF):- X=@=Y, X\==Y, !,TF='False'.
3498+
%eval_20(_Eq,_RetType,_Depth,_Self,['==', X,Y],TF):- X=@=Y, X\==Y, !,TF='False'.
35143499
eval_20(_Eq,_RetType,_Depth,_Self,['==', X,Y],TF):- copy_term(X+Y,XX+YY,_),XX=@=YY,XX\==YY, !,TF='False'.
35153500
eval_20(_Eq,_RetType,_Depth,_Self,['==', X,Y],TF):- (var(X) , var(Y)), !, as_tf(X==Y,TF),!.
35163501
eval_40(_Eq,_RetType,_Depth,_Self,['==', X,Y],TF):- (var(X) , var(Y)), !, as_tf(X==Y,TF),!.
@@ -3519,7 +3504,7 @@
35193504
woc((ignore(get_operator_typedef(Self,'metta-unify',2,[XType,YType],RetType)),
35203505
eval_until_eq_tf(['metta-unify',double_sided],Eq, XType, YType, Depth,Self, X, Y, TF))).
35213506

3522-
eval_20(Eq,RetType,Depth,Self,['==',X,Y],TF):- !,
3507+
eval_20(Eq,RetType,Depth,Self,['==',X,Y],TF):- fail, !,
35233508
ignore(get_operator_typedef(Self,'==',2,[XType,YType],RetType)),
35243509
eval_until_eq_tf(['==',dont_eval],Eq, XType, YType, Depth,Self, X, Y, TF).
35253510

prolog/metta_lang/metta_improve.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186

187187
eval_in(interp, X, Y):-
188188
peek_scope(Eq, RetType, Depth, Self),
189-
eval_09(Eq, RetType, Depth, Self, X, Y).
189+
woc(eval_10(Eq, RetType, Depth, Self, X, Y)).
190190
eval_in(compiler, X, Y):-
191191
transpile_eval(X, Y).
192192
eval_in(rust, X, Y):-

prolog/metta_lang/metta_interp.pl

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3974,7 +3974,7 @@
39743974
% ?- rtrace_on_error(writeln('Hello, World!')).
39753975
%
39763976

3977-
rtrace_on_error(G):- is_user_repl, !, call(G).
3977+
%rtrace_on_error(G):- is_user_repl, !, call(G).
39783978
rtrace_on_error(G):- !, call(G).
39793979
%rtrace_on_error(G):- catch(G,_,fail).
39803980
rtrace_on_error(G):-
@@ -4151,9 +4151,13 @@
41514151
% ?- load_hook1(my_load, '&corelib', '=', head, body).
41524152

41534153
% load_hook1(_Load, '&corelib', _Eq, _H, _B) :- !.
4154-
4155-
load_hook1(_Load, Self, [Eq,H,B]) :- Eq == '=', assertz_if_new(metta_function_asserted(Self,H,B)),fail.
4156-
4154+
load_hook1(Load, Self, Fact) :-
4155+
% Skip processing if the `metta_interp` flag is not set to `ready`.
4156+
% \+ is_metta_interp_ready,
4157+
% debug_info(assert_hooks,load_hook_not_ready(Load, Self, Fact)),
4158+
%fail,
4159+
!,
4160+
woc(load_hook_compiler(Load, Self, Fact)).
41574161

41584162
load_hook1(Load, Self, Fact) :-
41594163
% Ensure the Metta compiler is ready for use.
@@ -4162,13 +4166,6 @@
41624166
woc(load_hook_compiler(Load, Self, Fact)).
41634167
load_hook1(Load, Self, Fact):-
41644168
%debug_info(assert_hooks,not_use_metta_compiler(Load, Self, Fact)),
4165-
woc(load_hook_compiler(Load, Self, Fact)),!.
4166-
load_hook1(Load, Self, Fact) :-
4167-
% Skip processing if the `metta_interp` flag is not set to `ready`.
4168-
% \+ is_metta_interp_ready,
4169-
% debug_info(assert_hooks,load_hook_not_ready(Load, Self, Fact)),
4170-
%fail,
4171-
!,
41724169
woc(load_hook_compiler(Load, Self, Fact)).
41734170

41744171
metta_atom_asserted_hook(Self,Assertion):-
@@ -4453,15 +4450,6 @@
44534450
% @arg X The context or space.
44544451
% @arg Y The atom to check.
44554452
%
4456-
4457-
dont_bother(Atom):- Atom=@=[_, :, _].
4458-
dont_bother(Atom):- Atom=@=[=, [_, _], _]. % maybe
4459-
dont_bother(Atom):- Atom=@=[=, [_, _, _], _].
4460-
dont_bother(Atom):- Atom = [V1, [Colon, Thing, V2], V3], Colon==':', nonvar(Thing),maplist(var,[V1,V2,V3]).
4461-
4462-
metta_atom_added(_KB, Atom) :- dont_bother(Atom),!,fail.
4463-
metta_atom_added(X, [Eq,A,B]) :- Eq =='=', !, metta_function_asserted(X,A,B).
4464-
44654453
metta_atom_added(X, Y) :- nocut,
44664454
% Check if the atom was explicitly asserted.
44674455
metta_atom_asserted_ocw(X, Y).
@@ -4503,8 +4491,12 @@
45034491
transform_about(Fact, Rule, Cond), Cond=='True',!,
45044492
fact_store(KB, Rule, Fact, Cond).
45054493
*/
4494+
dont_bother(Atom):- Atom=@=[_, :, _].
4495+
dont_bother(Atom):- Atom=@=[=, [_, _, _], _].
4496+
dont_bother(Atom):- Atom=@=[=, [_, _], _]. % maybe
4497+
dont_bother(Atom):- Atom = [V1, [Colon, Thing, V2], V3], Colon==':', nonvar(Thing),maplist(var,[V1,V2,V3]).
45064498

4507-
metta_atom0(_KB, Atom) :- dont_bother(Atom),!,fail.
4499+
metta_atom0(_Inherit,_KB, Atom) :- dont_bother(Atom),!,fail.
45084500

45094501
% metta_atom([Superpose,ListOf], Atom) :- Superpose == 'superpose', is_list(ListOf), !, member(KB, ListOf), get_metta_atom_from(KB, Atom).
45104502
metta_atom0(_Inherit,Space, Atom) :- typed_list(Space, _, L), !, member(Atom, L).
@@ -4809,7 +4801,8 @@
48094801
% metta_eq_def(Eq,KB,H,B):- ignore(Eq = '='),metta_atom(KB,[Eq,H,B]).
48104802
metta_eq_def(Eq, KB, H, B) :-
48114803
ignore(Eq = '='),
4812-
metta_atom0(inherit([KB]),KB,[Eq, H, B]).
4804+
metta_atom0(inherit([KB]),KB,[EQ, H, B]),
4805+
EQ == Eq.
48134806

48144807
% Original commented-out code, retained as-is for potential future use:
48154808
% metta_defn(KB,Head,Body):- metta_eq_def(_Eq,KB,Head,Body).
@@ -5328,6 +5321,7 @@
53285321
toplevel_interp_only_symbol('compiled-info').
53295322
toplevel_interp_only_symbol('listing!').
53305323
toplevel_interp_only_symbol('eval-in-only!').
5324+
toplevel_interp_only_symbol('set-debug!').
53315325
toplevel_interp_only_symbol('repl!').
53325326
toplevel_interp_only_symbol('eval').
53335327
toplevel_interp_only_symbol('pragma!').
@@ -5670,7 +5664,7 @@
56705664
do_metta(From, comment(Load), Self, Expr, Out).
56715665
do_metta(From, comment(Load), Self, Cmt, Out) :-
56725666
% Write the comment and handle specific cases of MettaLog comments.
5673-
if_trace((loading;load),write_comment(Cmt)), !,
5667+
if_trace((loading;load,comment),write_comment(Cmt)), !,
56745668
ignore((symbolic(Cmt),
56755669
symbolic_list_concat([_, Src], 'MeTTaLog only: ', Cmt),
56765670
!,

prolog/metta_lang/stdlib_mettalog.metta

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2651,7 +2651,7 @@ For example:
26512651
(@param "List of values")
26522652
(@param "List of values")))
26532653
(@return "Union of sets based on predicate"))
2654-
(ALT= (union-atom-by $Pred $L1 $L2)
2654+
(= (union-atom-by $Pred $L1 $L2)
26552655
(collapse (union-by $Pred (superpose $L1) (superpose $L2))))
26562656
(: union-atom-by (-> Atom Expression Expression Expression))
26572657

0 commit comments

Comments
 (0)