예제 #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)
예제 #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})).")
예제 #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)
예제 #4
0
 def consult(self, filename: str):
     return pyxsb.pyxsb_command_string(f"consult('{filename}').")