Exemplo n.º 1
0
 def assertz(self, clause: Union[Atom, Clause]):
     if isinstance(clause, Atom):
         query = f"assertz({clause})."
         return pyxsb.pyxsb_command_string(query)
     else:
         query = f"assertz(({clause}))."
         return pyxsb.pyxsb_command_string(query)
Exemplo n.º 2
0
 def retract(self, clause: Union[Atom, Clause]):
     if isinstance(clause, Atom):
         return pyxsb.pyxsb_command_string(f"retract({clause}).")
     else:
         return pyxsb.pyxsb_command_string(f"retract(({clause})).")
Exemplo n.º 3
0
 def use_module(self, module: str, **kwargs):
     assert 'predicates' in kwargs, "XSB Prolog: need to specify which predicates to import from module"
     predicates = kwargs['predicates']
     command = f"use_module({module},[{','.join([x.get_name() + '/' + str(x.get_arity()) for x in predicates])}])."
     return pyxsb.pyxsb_command_string(command)
Exemplo n.º 4
0
 def consult(self, filename: str):
     return pyxsb.pyxsb_command_string(f"consult('{filename}').")