def query(clause, args): """Executes a query and presents the answers.""" if args.verbose: print(formatting.comment("% query ") + "{}".format(clause)) # determine debugger debugger = None if args.debug: debugger = ReportingDebugger() # determine cache mechanism cache = {'none': caching.NoCache, 'dict': caching.DictCache}[args.cache]() # set up prover and execute query prover = logic.Prover(kb, debugger=debugger, cache=cache) for a in prover.ask(clause): print("{}.".format(a))
def retract_clause(clause, args): if args.verbose: print(formatting.comment("% retract ") + "{}".format(clause)) kb.retract_clause(clause)
def assert_clause(clause, args): if args.verbose: print(formatting.comment("% assert ") + "{}".format(clause)) kb.assert_clause(clause)