def print_stacks(): for run_item in run_stack: print run_item, print ' ', for goal in goal_stack: print unparse(database.operators, goal, Scope()), print
def main(): query_str = ' '.join(sys.argv[1:]) if query_str == '': print 'Please enter a query on the command line (you might need quotes around it)' print 'E.g. qolog.py assert(prime(3)), assert(prime(5)), assert(prime(7)), findall(S, (prime(P), prime(Q), S is P*Q), B)' return db = Database() db.add_rules(LIST_RULES) db.add_rules(ARITHMETIC_RULES) goal, scope = parse(db.operators, query_str) print 'Proving:', unparse(db.operators, goal, scope) t0 = time.time() prove_interactively(goal, scope, db) print 'Ran for %0.2f seconds' % (time.time() - t0)
def __str__(self): return 'D(%s)/%d%s' % (unparse( self.database.operators, self.goal, Scope()), self.subgoal_count, '*' if self.end_of_gen else '')
def __str__(self): return 'B(%s)%s' % (unparse(self.database.operators, self.goal, Scope()), '*' if self.end_of_gen else '')
def bound_vars_str(database, bound_vars, scope): return ', '.join( '%s = %s' % (str(v), unparse(database.operators, t, scope)) for v, t in sorted(scope.var_mappings(bound_vars).items()))
def display_rule(term, database): arg = term.subterms[0].resolve() print unparse(database.operators, arg, Scope()), return [(True, set())]