diff --git a/libraries/logicmoo_utils/prolog/logicmoo/util_varnames.pl b/libraries/logicmoo_utils/prolog/logicmoo/util_varnames.pl index 2f2af9357a..334fe1fd9e 100755 --- a/libraries/logicmoo_utils/prolog/logicmoo/util_varnames.pl +++ b/libraries/logicmoo_utils/prolog/logicmoo/util_varnames.pl @@ -28,7 +28,7 @@ dif_matrix/2, term_singleslots/2, term_singleslots/3, - term_singleslots/5, + term_singleslots/5, set_varname/2, set_varname/3, write_functor/2, @@ -67,7 +67,7 @@ no_varnaming/1, no_vars_needed/1, - + print_numbervars_maybe/1, print_numbervars/1, scan_for_varnames0/0, @@ -93,7 +93,7 @@ try_get_inner_vars/1, set_varname/2, try_save_vars/1, - + v_dif_rest/2, vmust/1, init_varname_stores/1, @@ -103,7 +103,7 @@ /** Utility LOGICMOO UTIL VARNAMES / Name Prolog variables (debugging) -This module holds utilities to access and change the names of prolog variables. +This module holds utilities to access and change the names of prolog variables. - @author Douglas R. Miles - @license LGPL */ @@ -156,15 +156,15 @@ get_clause_vars_copy/2, get_clause_vars_hb_int/2, imploded_copyvars/2, - locate_clause_ref/5, - + locate_clause_ref/5, + listing_vars_file/0, make_subterm_path/3, maybe_record_scanned_file/0, no_varnaming/1, without_varname_scan/1, no_vars_needed/1, - + print_numbervars_maybe/1, print_numbervars/1, read_source_file_vars/1, @@ -188,7 +188,7 @@ try_get_inner_vars/1, set_varname/2, try_save_vars/1, - + v_dif_rest/2, % name_variable/2, variable_name/2, vmust/1, @@ -237,7 +237,7 @@ % member_open(C, [B|A]) :- (nonvar(B),B=C) ; (nonvar(A),member_open(C, A)). -%= +%= %% source_variables_lwv( ?AllS) is det. % @@ -283,12 +283,12 @@ % Hook To [dom:attr_unify_hook/2] For Module Logicmoo_varnames. % Attr Unify Hook. % -vn:attr_unify_hook(X,Y):- ignore(quietly(must(vn_auh_0(X,Y)))). +vn:attr_unify_hook(X,Y):- ignore(quietly((vn_auh_0(X,Y)))). -vn_auh_0(_, Var):- cyclic_term(Var),!,fail. -vn_auh_0(Var,_):- cyclic_term(Var),!,fail. vn_auh_0(Name1, Var):- when_var_locked(What),!,(unify_name_based(Name1, Var)->true;call(What,Var)). vn_auh_0(Name1, Var):- var(Var),unify_name_based(Name1, Var),!. +vn_auh_0(_, Var):- cyclic_term(Var),!,fail. +%vn_auh_0(Var,_):- cyclic_term(Var),!,fail. vn_auh_0(_Form, _OtherValue):-!. @@ -339,11 +339,11 @@ % Portray Attribute Variable. % portray_attvar(Var) :- - write('{<'), + write('{<'), ((get_attr(Var,vn, VarName))->true;sformat(VarName,'~q',[Var])), - get_attrs(Var, Attr), - catch(writeq('??'(VarName,Attr)),_,'$attvar':portray_attrs(Attr, Var)), - write('>}'). + get_attrs(Var, Attr), + catch(writeq('??'(VarName,Attr)),_,'$attvar':portray_attrs(Attr, Var)), + write('>}'). */ @@ -353,14 +353,14 @@ % % % OFF :- system:use_module(library(when)). :- prolog_clause:multifile(( - unify_goal/5, % +Read, +Decomp, +M, +Pos, -Pos - unify_clause_hook/5, - make_varnames_hook/5, - open_source/2)). % +Input, -Stream + unify_goal/5, % +Read, +Decomp, +M, +Pos, -Pos + unify_clause_hook/5, + make_varnames_hook/5, + open_source/2)). % +Input, -Stream :- predicate_options(prolog_clause:clause_info/5, 5, - [ variable_names(-list) - ]). + [ variable_names(-list) + ]). % % % OFF :- system:use_module(library(prolog_source)). % % % OFF :- system:use_module(library(prolog_clause)). % read_term_at_line/6 @@ -916,7 +916,7 @@ save_clause_vars(M,H,MB,B,Vs,Why:_):-atom(Why),!,save_clause_vars(M,H,MB,B,Vs,Why). save_clause_vars(M,H,MB,B,Vs,Why):- fail, locate_clause_ref(M,H,MB,B,ClauseRef),clause_ref_vars(ClauseRef,Was), ((Was=Vs) -> fail ; save_to_clause_ref(ClauseRef,Vs,Why)),!. -save_clause_vars(_M,H,_MB,B,Vs,Why):- +save_clause_vars(_M,H,_MB,B,Vs,Why):- ain00(varname_cache:varname_info(H,B,Vs,Why)). @@ -1138,13 +1138,13 @@ % % Source Variables. % -source_variables(Vs):- +source_variables(Vs):- (prolog_load_context(variable_names,Vs2);Vs2=[]), execute_goal_vs(Vs1), append(Vs1,Vs2,Vs3),list_to_set(Vs3,Vs), (Vs\==Vs2 -> b_setval('$variable_names',Vs) ; true). -source_variables0(Vs):- +source_variables0(Vs):- (prolog_load_context(variable_names,Vs2);Vs2=[]), execute_goal_vs(Vs1), append(Vs1,Vs2,Vs3),list_to_set(Vs3,Vs). @@ -1219,7 +1219,7 @@ % Scan For Varnames. % scan_for_varnames:- thglobal:scanning_for_varnames_already,!. -scan_for_varnames:- %swc, +scan_for_varnames:- %swc, setup_call_cleanup( asserta(thglobal:scanning_for_varnames_already), scan_for_varnames0, @@ -1286,22 +1286,22 @@ read_source_vars(File,In):- Module = module(_), - repeat, - catch(prolog_read_source_term(In, Term, Expanded, [ variable_names(Vs), syntax_errors(error) , term_position(TermPos) ]), - E,(nop((dmsg(E))),fail)), + repeat, + catch(prolog_read_source_term(In, Term, Expanded, [ variable_names(Vs), syntax_errors(error) , term_position(TermPos) ]), + E,(nop((dmsg(E))),fail)), arg(1,Module,M), (Term = module(MM,_) -> (nb_setarg(1,Module,MM),fail); ((stream_position_data(line_count, TermPos, LineNo), - ignore(save_file_source_vars(mfl4(Vs,M,File,LineNo),Term,Vs)), - ( is_list(Expanded) - -> member(T, Expanded) - ; T = Expanded - ), - ( T == end_of_file - -> ! ; + ignore(save_file_source_vars(mfl4(Vs,M,File,LineNo),Term,Vs)), + ( is_list(Expanded) + -> member(T, Expanded) + ; T = Expanded + ), + ( T == end_of_file + -> ! ; ( T\==Term, save_file_source_vars(mfl4(Vs,M,File,LineNo),T,Vs), - fail))))). + fail))))). % new method @@ -1316,10 +1316,10 @@ read_source_file_vars_1(File):- once(current_prolog_flag(xref, Was);Was=false), locally(set_prolog_flag(xref, true), - setup_call_cleanup( - prolog_open_source(File, In), - read_source_vars(File,In), - (prolog_close_source(In), + setup_call_cleanup( + prolog_open_source(File, In), + read_source_vars(File,In), + (prolog_close_source(In), current_prolog_flag(xref, Was)))),!. diff --git a/prolog/metta_lang/metta_eval.pl b/prolog/metta_lang/metta_eval.pl index cf678c905f..ae5fa5f64f 100755 --- a/prolog/metta_lang/metta_eval.pl +++ b/prolog/metta_lang/metta_eval.pl @@ -121,7 +121,7 @@ % eval_20(Eq,RetType,Depth,Self,['quote',Eval],RetVal):- !, Eval = RetVal, check_returnval(Eq,RetType,RetVal). is_self_eval_l_fa('quote',_). %is_self_eval_l_fa('=',_):- nb_current(evaling_args,t). -is_self_eval_l_fa(':',_):- nb_current(evaling_args,t). +%is_self_eval_l_fa(':',_):- nb_current(evaling_args,t). is_self_eval_l_fa('Error',_). is_self_eval_l_fa('{...}',_). is_self_eval_l_fa('[...]',_). @@ -2325,8 +2325,6 @@ suggest_type(_RetType,_Bool). -naive_eval_args:- - false. eval_41(Eq,RetType,Depth,Self,[AE|More],Res):- naive_eval_args,!, maplist(must_eval_args(Eq,_,Depth,Self),More,Adjusted), @@ -2363,6 +2361,8 @@ if_or_else(eval_maybe_host_predicate(Eq,RetType,Depth,Self,PredDecl,Res), if_or_else(eval_maybe_host_function(Eq,RetType,Depth,Self,PredDecl,Res), fail))). + +naive_eval_args:- false_flag. eval_all_args:- naive_eval_args. fail_missed_defn:- true_flag. fail_on_constructor:- true_flag. @@ -2752,7 +2752,7 @@ light_eval(Eq,RetType,Depth,Self,B0,Y),!. eval_defn_failure(Eq,RetType,Depth,Self,X,Res):- if_trace(e,color_g_mesg('#773701',indentq2(Depth,defs_failed(X)))), - eval_constructor(Eq,RetType,Depth,Self,X,Res). + eval_constructor(Eq,RetType,Depth,Self,X,Res), \+ fail_missed_defn. diff --git a/prolog/metta_lang/metta_interp.pl b/prolog/metta_lang/metta_interp.pl index 7cbb2fed7e..c0f20cfc6c 100755 --- a/prolog/metta_lang/metta_interp.pl +++ b/prolog/metta_lang/metta_interp.pl @@ -52,7 +52,7 @@ */ %********************************************************************************************* -% PROGRAM FUNCTION: Interpret MeTTa code within the SWI-Prolog environment, enabling logical +% PROGRAM FUNCTION: Interpret MeTTa code within the SWI-Prolog environment, enabling logical % inference, runtime evaluation, and cross-language integration with Python and Rust. %********************************************************************************************* @@ -152,12 +152,12 @@ % - Facilitates maintainability and portability of the codebase. % - Supports dynamic pack management during runtime without requiring manual adjustments. % -:- (prolog_load_context(directory, Value); Value='.'), +:- (prolog_load_context(directory, Value); Value='.'), % Resolve the absolute path to the '../../libraries/' directory. absolute_file_name('../../libraries/', Dir, [relative_to(Value)]), % Build paths for specific libraries/packs. atom_concat(Dir, 'predicate_streams', PS), - atom_concat(Dir, 'logicmoo_utils', LU), + atom_concat(Dir, 'logicmoo_utils', LU), % Attach the base library directory with specified options. attach_packs(Dir, [duplicate(replace), search(first)]), % Attach the `predicate_streams` and `logicmoo_utils` packs. @@ -206,7 +206,7 @@ % This predicate is used as a guard condition in stream-related operations % to prevent unintended changes to Prolog's standard input, output, or error streams. -% It ensures that existing stream configurations remain intact, avoiding conflicts +% It ensures that existing stream configurations remain intact, avoiding conflicts % during operations that might otherwise alter stream properties. dont_change_streams:- true. @@ -236,8 +236,8 @@ % % Determines the root directory of the Mettalog project. % -% This predicate attempts to determine the root directory by first using the -% `user:is_metta_src_dir/1` dynamic predicate. If that is unavailable or fails, +% This predicate attempts to determine the root directory by first using the +% `user:is_metta_src_dir/1` dynamic predicate. If that is unavailable or fails, % it falls back to the `METTA_DIR` environment variable. % % @arg Dir The absolute path to the Mettalog root directory. @@ -261,7 +261,7 @@ % % Determines the library directory of the Mettalog project. % -% This predicate resolves the library directory relative to the Mettalog root +% This predicate resolves the library directory relative to the Mettalog root % directory using `metta_root_dir/1`. % % @arg Dir The absolute path to the Mettalog library directory. @@ -281,12 +281,12 @@ % % Determines the directory path for the Mettalog system. % -% This predicate tries multiple approaches to resolve the directory associated -% with Mettalog in a specific order. It prioritizes specific subdirectories, then +% This predicate tries multiple approaches to resolve the directory associated +% with Mettalog in a specific order. It prioritizes specific subdirectories, then % falls back to source, library, and root directories. % % The resolution strategy is as follows: -% 1. It attempts to resolve the directory as a subdirectory of the Mettalog library +% 1. It attempts to resolve the directory as a subdirectory of the Mettalog library % path, specifically './loaders/genome/'. % 2. Falls back to the directory specified by `is_metta_src_dir/1`. % 3. Further falls back to the Mettalog library directory. @@ -319,21 +319,21 @@ % The Prolog 'dynamic' enables runtime modification of predicate. :- dynamic user:file_search_path/2. % -% The `user:file_search_path/2` predicate allows associating logical aliases -% with specific directories, making it easier to reference files without +% The `user:file_search_path/2` predicate allows associating logical aliases +% with specific directories, making it easier to reference files without % hardcoding their paths. In this case: % -% - `library` is mapped to the Mettalog directory, enabling searches for +% - `library` is mapped to the Mettalog directory, enabling searches for % library files relative to the Mettalog root. -% - `mettalog` is also mapped to the Mettalog directory, likely to handle +% - `mettalog` is also mapped to the Mettalog directory, likely to handle % specific files related to the MettalogLog transpiler/interpreter. :- multifile user:file_search_path/2. user:file_search_path(library,Dir):- metta_dir(Dir). user:file_search_path(mettalog,Dir):- metta_dir(Dir). % -% This directive conditionally loads the `logicmoo_utils` library if the system -% is detected as Windows 64-bit. If the platform is not Windows 64-bit, the +% This directive conditionally loads the `logicmoo_utils` library if the system +% is detected as Windows 64-bit. If the platform is not Windows 64-bit, the % directive does nothing. % :- is_win64 -> ensure_loaded(library(logicmoo_utils)) ; true. @@ -342,9 +342,9 @@ % 'nodebug' disables specific debugging flags for various Mettalog-related modules. % -% These directives ensure that certain debugging categories (`metta(eval)`, -% `metta(exec)`, `metta(load)`, and `metta(prolog)`) are disabled by default. -% This reduces console output noise and improves runtime performance in +% These directives ensure that certain debugging categories (`metta(eval)`, +% `metta(exec)`, `metta(load)`, and `metta(prolog)`) are disabled by default. +% This reduces console output noise and improves runtime performance in % non-debugging environments. % :- nodebug(metta(eval)). @@ -353,11 +353,11 @@ :- nodebug(metta(prolog)). % -% This section declares several dynamic and multifile predicates used in the -% Mettalog system. These predicates support runtime updates, extensibility, and +% This section declares several dynamic and multifile predicates used in the +% Mettalog system. These predicates support runtime updates, extensibility, and % modular design. They cover various aspects of Mettalog functionality. % -% These predicates are marked as `dynamic` to allow runtime modifications +% These predicates are marked as `dynamic` to allow runtime modifications % and as `multifile` to enable contributions from multiple modules. % :- dynamic(function_arity/2). diff --git a/prolog/metta_lang/metta_testing.pl b/prolog/metta_lang/metta_testing.pl index e539fd45df..5ec723fabe 100755 --- a/prolog/metta_lang/metta_testing.pl +++ b/prolog/metta_lang/metta_testing.pl @@ -476,7 +476,7 @@ get_last_call_duration(Duration), DurationX1000 is Duration * 1000, % Write the detailed formatted log entry. - format(Stream,'| ~w | ~w |[~w](https://trueagi-io.github.io/metta-wam/~w#~w) | ~@ | ~@ | ~@ | ~w | ~w |~n', + format(Stream,'| ~w | ~w |[~w](https://logicmoo.github.io/metta-wam/~w#~w) | ~@ | ~@ | ~@ | ~w | ~w |~n', [TestName,PASS_FAIL,TestName,HTML_OUT,TestName, trim_gstring_bar_I(write_src_woi([P,C]),600), trim_gstring_bar_I(write_src_woi(G1),600), diff --git a/prolog/metta_lang/stdlib_mettalog.metta b/prolog/metta_lang/stdlib_mettalog.metta index 45bb95eb2b..99ac26de40 100644 --- a/prolog/metta_lang/stdlib_mettalog.metta +++ b/prolog/metta_lang/stdlib_mettalog.metta @@ -204,7 +204,7 @@ For example: (predicate-arity predicate-arity 2) (predicate-arity : 2) -(= (: $F P1) (predicate-arity $F 1)) +;; (= (: $F P1) (predicate-arity $F 1)) ;; Source Predicate and Function Types