was_asserted_space('&corelib'). was_asserted_space('&flybase'). /* was_asserted_space('&attentional_focus'). was_asserted_space('&belief_events'). was_asserted_space('&goal_events'). was_asserted_space('&tempset'). was_asserted_space('&concepts'). was_asserted_space('&belief_events'). */ is_asserted_space(X):- was_asserted_space(X). is_asserted_space(X):- \+ is_as_nb_space(X), \+ py_named_space(X),!. is_python_space_not_prolog(X):- \+ is_as_nb_space(X), \+ is_asserted_space(X). :- dynamic(is_python_space/1). :- dynamic(py_named_space/1). %py_named_space('&self'). %py_named_space('&vspace'). % Function to check if an atom is registered as a space name :- dynamic is_registered_space_name/1. is_as_nb_space('&nb'). is_as_nb_space(G):- is_valid_nb_space(G) -> true ; is_registered_space_name(G),nb_current(G,S),is_valid_nb_space(S). is_nb_space(G):- nonvar(G), is_as_nb_space(G). % ============================ % %%%% Pattern Matching % ============================ % Pattern Matching with an else branch %'match'(Environment, Pattern, Template, ElseBranch, Result):- % eval_args(['match', Environment, Pattern, Template, ElseBranch], Result). % Pattern Matching without an else branch 'match'(Environment, Pattern, Template, Result):- eval_args(['match', Environment, Pattern, Template], Result). %'match'(_Environment, Pattern, Template, Result):- callable(Pattern),!, call(Pattern),Result=Template. %'match'(_Environment, Pattern, Template, Result):- !, is_True(Pattern),Result=Template. 'new-space'(Space):- gensym('hyperon::space::DynSpace@_',Name), fetch_or_create_space(Name, Space). :- dynamic(is_python_space/1). % =============================== % MeTTa Python incoming interface % =============================== :- multifile(space_type_method/3). :- dynamic(space_type_method/3). space_type_method(is_as_nb_space,new_space,init_space). space_type_method(is_as_nb_space,clear_space,clear_nb_atoms). space_type_method(is_as_nb_space,add_atom,add_nb_atom). space_type_method(is_as_nb_space,remove_atom,remove_nb_atom). space_type_method(is_as_nb_space,replace_atom,replace_nb_atom). space_type_method(is_as_nb_space,atom_count,atom_nb_count). space_type_method(is_as_nb_space,get_atoms,get_nb_atoms). %space_type_method(is_as_nb_space,get_atoms,arg(1)). space_type_method(is_as_nb_space,atom_iter,atom_nb_iter). %space_type_method(is_as_nb_space,query,space_nb_query). % Clear all atoms from a space clear_nb_atoms(SpaceNameOrInstance) :- fetch_or_create_space(SpaceNameOrInstance, Space), nb_setarg(1, Space, []). % Add an atom to the space add_nb_atom(SpaceNameOrInstance, Atom) :- fetch_or_create_space(SpaceNameOrInstance, Space), arg(1, Space, Atoms), NewAtoms = [Atom | Atoms], nb_setarg(1, Space, NewAtoms). % Count atoms in a space atom_nb_count(SpaceNameOrInstance, Count) :- fetch_or_create_space(SpaceNameOrInstance, Space),