Skip to content

Commit

Permalink
really using stdlib_mettalog
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSPoon committed Aug 23, 2024
1 parent 48d83b4 commit 12d58c8
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 21 deletions.
11 changes: 9 additions & 2 deletions hyperon-wam.vpj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
Name="Other Files"
Filters=""></Folder>
</CustomFolders>
<List Name="RTE">
</List>
<Files AutoFolders="DirectoryView">
<Folder Name="t:/">
<Folder Name="root">
Expand Down Expand Up @@ -116,6 +118,13 @@
Excludes=".git/;*.metta.html;*.bak;build/;.*/;*~*/"
L="1"/>
</Folder>
<Folder Name="library">
<F
N="library/*.*"
Recurse="1"
Excludes=".git/;*.metta.html;*.bak;build/;/;*~*/"
L="1"/>
</Folder>
<Folder Name="reports">
<Folder Name="BY_DATE">
<F
Expand Down Expand Up @@ -201,6 +210,4 @@
Recurse="1"
Excludes=".git/;*.metta.html;*.bak;build/;.*/;*~*/"/>
</Files>
<List Name="RTE">
</List>
</Project>
1 change: 1 addition & 0 deletions hyperon-wam.vpw
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
<Project File="hyperon-wam.vpj"/>
<Project File="../../../../logicmoo_workspace.vpj"/>
<Project File="../../arcprize/PrologARC.vpj"/>
<Project File="Test-files.vpj"/>
</Projects>
</Workspace>
16 changes: 9 additions & 7 deletions src/canary/metta_corelib.pl
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,20 @@

metta_atom_corelib_types( [:, 'Error', [->, 'Atom', 'Atom', 'ErrorType']]).

metta_atom_corelib_types( [:, 'add-atom', [->, 'Space', 'Atom', [->]]]).
metta_atom_corelib_types( [:, 'add-atom', [->, 'hyperon::space::DynSpace', 'Atom', [->]]]).
metta_atom_corelib_types( [:, 'car-atom', [->, 'Expression', 'Atom']]).
metta_atom_corelib_types( [:, 'cdr-atom', [->, 'Expression', 'Expression']]).
metta_atom_corelib_types( [:, 'filter-atom', [->, 'Expression', 'Variable', 'Atom', 'Expression']]).
metta_atom_corelib_types( [:, 'foldl-atom', [->, 'Expression', 'Atom', 'Variable', 'Variable', 'Atom', 'Atom']]).
metta_atom_corelib_types( [:, 'get-atoms', [->, 'Space', 'Atom']]).
metta_atom_corelib_types( [:, 'get-atoms', [->, 'hyperon::space::DynSpace', 'Atom']]).
metta_atom_corelib_types( [:, 'if-decons', [->, 'Atom', 'Variable', 'Variable', 'Atom', 'Atom', 'Atom']]).
metta_atom_corelib_types( [:, 'if-empty', [->, 'Atom', 'Atom', 'Atom', 'Atom']]).
metta_atom_corelib_types( [:, 'if-error', [->, 'Atom', 'Atom', 'Atom', 'Atom']]).
metta_atom_corelib_types( [:, 'if-non-empty-expression', [->, 'Atom', 'Atom', 'Atom', 'Atom']]).
metta_atom_corelib_types( [:, 'if-not-reducible', [->, 'Atom', 'Atom', 'Atom', 'Atom']]).
metta_atom_corelib_types( [:, 'let*', [->, 'Expression', 'Atom', 'Atom']]).
metta_atom_corelib_types( [:, 'map-atom', [->, 'Expression', 'Variable', 'Atom', 'Expression']]).
metta_atom_corelib_types( [:, 'remove-atom', [->, 'Space', 'Atom', [->]]]).
metta_atom_corelib_types( [:, 'remove-atom', [->, 'hyperon::space::DynSpace', 'Atom', [->]]]).
metta_atom_corelib_types( [:, 'return-on-error', [->, 'Atom', 'Atom', 'Atom']]).
metta_atom_corelib_types( [:, and, [->, 'Bool', 'Bool', 'Bool']]).
metta_atom_corelib_types( [:, apply, [->, 'Atom', 'Variable', 'Atom', 'Atom']]).
Expand Down Expand Up @@ -285,12 +285,14 @@

use_corelib_file:- using_corelib_file,!.
use_corelib_file:- asserta(using_corelib_file), fail.
use_corelib_file:- is_metta_dir(Dir), really_use_corelib_file(Dir,'corelib.metta'),!.
use_corelib_file:- is_metta_dir(Dir), really_use_corelib_file(Dir,'stdlib_mettalog.metta'),!.
use_corelib_file:- load_corelib_file.
load_corelib_file:- is_metta_src_dir(Dir), really_use_corelib_file(Dir,'corelib.metta'),!.
load_corelib_file:- is_metta_src_dir(Dir), really_use_corelib_file(Dir,'stdlib_mettalog.metta'),!.
% !(import! &corelib "src/canary/stdlib_mettalog.metta")
really_use_corelib_file(Dir,File):- absolute_file_name(File,Filename,[relative_to(Dir)]),
locally(nb_setval(may_use_fast_buffer,t),
include_metta_directory_file('&corelib',Dir,Filename)).
locally(nb_setval(may_use_fast_buffer,t),
locally(nb_setval(suspend_answers,true),
with_output_to(string(_),include_metta_directory_file('&corelib',Dir,Filename)))).

%:- initialization(use_corelib_file).

Expand Down
15 changes: 11 additions & 4 deletions src/canary/metta_interp.pl
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@

:- dynamic(is_answer_output_stream/2).
answer_output(Stream):- is_testing,original_user_output(Stream),!.
answer_output(Stream):- !,original_user_output(Stream),!.
answer_output(Stream):- is_answer_output_stream(_,Stream),!.
answer_output(Stream):- tmp_file('answers',File),
open(File,write,Stream,[encoding(utf8)]),
Expand Down Expand Up @@ -1067,9 +1068,13 @@
%metta_atom([Superpose,ListOf], Atom):- Superpose == 'superpose',is_list(ListOf),!,member(KB,ListOf),get_metta_atom_from(KB,Atom).
metta_atom(Space, Atom):- typed_list(Space,_,L),!, member(Atom,L).
metta_atom(KB, [F, A| List]):- KB=='&flybase',fb_pred_nr(F, Len),current_predicate(F/Len), length([A|List],Len),apply(F,[A|List]).
metta_atom(KB,Atom):- KB=='&corelib',!, metta_atom_corelib(Atom).
%metta_atom(KB,Atom):- KB=='&corelib',!, metta_atom_corelib(Atom).
metta_atom(KB,Atom):- metta_atom_in_file( KB,Atom).
metta_atom(KB,Atom):- metta_atom_asserted( KB,Atom).
metta_atom(KB,Atom):- KB \== '&corelib', !, should_inherit_from_corelib(Atom), metta_atom('&corelib',Atom).
should_inherit_from_corelib([H|_]):- nonvar(H),should_inherit_op_from_corelib(H).
should_inherit_op_from_corelib('=').
should_inherit_op_from_corelib(':').

metta_atom_asserted('&self','&corelib').
metta_atom_asserted('&self','&stdlib').
Expand All @@ -1093,13 +1098,15 @@
%metta_atom(KB,[F,A|List]):- metta_atom(KB,F,A,List), F \== '=',!.
is_metta_space(Space):- \+ \+ is_space_type(Space,_Test).

metta_eq_def(Eq,KB,Head,Body):- ignore(Eq = '='), metta_atom(KB,[Eq,Head,Body]).
metta_eq_def(Eq,KB,H,B):- ignore(Eq = '='),if_or_else(metta_atom(KB,[Eq,H,B]),metta_atom_corelib(KB,[Eq,H,B])).

metta_defn(KB,Head,Body):- metta_eq_def(_Eq,KB,Head,Body).
metta_type(KB,H,B):- if_or_else(metta_atom(KB,[':',H,B]),metta_atom_corelib([':',H,B])).
%metta_defn(KB,Head,Body):- metta_eq_def(_Eq,KB,Head,Body).
metta_defn(KB,H,B):- metta_eq_def('=',KB,H,B).
metta_type(KB,H,B):- metta_eq_def(':',KB,H,B).
%metta_type(S,H,B):- S == '&corelib', metta_atom_stdlib_types([':',H,B]).
%typed_list(Cmpd,Type,List):- compound(Cmpd), Cmpd\=[_|_], compound_name_arguments(Cmpd,Type,[List|_]),is_list(List).

metta_atom_corelib(KB,Atom):- KB\='&corelib',!,metta_atom('&corelib',Atom).

%maybe_xform(metta_atom(KB,[F,A|List]),metta_atom(KB,F,A,List)):- is_list(List),!.
maybe_xform(metta_eq_def(Eq,KB,Head,Body),metta_atom(KB,[Eq,Head,Body])).
Expand Down
13 changes: 7 additions & 6 deletions src/canary/metta_loader.pl
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,13 @@
set_exec_num(Filename,0))),
load_metta_file_stream_fast(Size,P2,Filename,Self,In)))).

% use_fast_buffer makes tmp .buffer.pl files that get around long load times
% use_fast_buffer makes tmp .buffer files that get around long load times
use_fast_buffer:- nb_current(may_use_fast_buffer,t).

:- dynamic(metta_file_buffer/5).
:- multifile(metta_file_buffer/5).


load_metta_file_stream_fast(_Size,_P2,Filename,Self,S):- fail,
symbolic_list_concat([_,_,_|_],'.',Filename),
\+ option_value(html,true),
Expand All @@ -576,12 +580,9 @@
accept_line(Self,I),
I==end_of_file,!.

:- dynamic(metta_file_buffer/5).
:- multifile(metta_file_buffer/5).

load_metta_file_stream_fast(_Size, _P2, Filename, Self, _In) :-
use_fast_buffer,
symbol_concat(Filename, '.buffer.pl', BufferFile),
symbol_concat(Filename, '.buffer~', BufferFile),
exists_file(BufferFile),
time_file(Filename, FileTime),
time_file(BufferFile, BufferFileTime),
Expand All @@ -592,7 +593,7 @@

load_metta_file_stream_fast(_Size,P2,Filename,Self,In):-
if_t(use_fast_buffer,
((symbol_concat(Filename, '.buffer.pl', BufferFile),
((symbol_concat(Filename, '.buffer~', BufferFile),
fbugio(creating(BufferFile)),
write_bf(BufferFile, ( :- dynamic(metta_file_buffer/5))),
write_bf(BufferFile, ( :- multifile(metta_file_buffer/5)))))),
Expand Down
6 changes: 4 additions & 2 deletions src/canary/stdlib_mettalog.metta
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
(: = (-> $t $t Atom))
;; Implemented from Interpreters

(: ALT= (-> Atom Atom Atom))

; Public MeTTa
(@doc ErrorType (@desc "Type of the atom which contains error"))
(: ErrorType Type)
Expand Down Expand Up @@ -660,7 +662,7 @@


;; Public MeTTa?
(:> Space Grounded)
(:> hyperon::space::DynSpace Grounded)

;; Public MeTTa
(@doc add-reduct
Expand All @@ -676,7 +678,7 @@
(@param "Atom to add")))
(@return "Unit atom"))

(: add-reduct-rust1 (-> Space %Undefined% (->)))
(: add-reduct-rust1 (-> hyperon::space::DynSpace %Undefined% (->)))
(= (add-reduct-minimal $dst $atom) (add-atom $dst $atom))
;; Public MeTTa
(: add-reduct (-> Grounded %Undefined% (->)))
Expand Down

0 comments on commit 12d58c8

Please sign in to comment.