def always_assert_inductive_trace(self) -> None: for i, f in enumerate(self.fs[:-1]): for c in self.fs[i + 1].summary(): res = self.clause_implied_by_transitions_from_frame( f, c, Solver()) assert res is None, ("Non inductive trace:\n\t%s\n\t%s" % (c, f))
def always_assert_inductive_trace(self) -> None: for i, f in enumerate(self.fs[:-1]): with utils.LogTag(utils.logger, 'inductive-trace-assert', lvl=logging.DEBUG, i=str(i)): for p in self.automaton.phases(): for c in self.fs[i + 1].summary_of(p): res = self.clause_implied_by_transitions_from_frame( f, p, c, Solver()) assert res is None, ( "Non inductive trace:\n\t%s\n\t%s\n\t%s" % (p.name(), c, f))
def diagram_trace_to_explicitly_relaxed_trace(trace: RelaxedTrace, safety: Sequence[syntax.InvariantDecl]) -> None: relaxed_prog = relaxed_program(syntax.the_program) with syntax.prog_context(relaxed_prog): s = Solver() end_expr = syntax.Not(syntax.And(*(invd.expr for invd in safety))) with syntax.the_program.scope.n_states(1): end_expr.resolve(syntax.the_program.scope, syntax.BoolSort) trace_decl = diagram_trace_to_explicitly_relaxed_trace_decl(trace, end_expr) with syntax.the_program.scope.n_states(1): trace_decl.resolve(syntax.the_program.scope) print(trace_decl) res = bmc_trace(relaxed_prog, trace_decl, s, lambda slvr, ks: logic.check_solver(slvr, ks, minimize=True)) print(res) assert False
def __init__(self, master, **kwargs): self.puzzleGrid = SDKGrid("") self.solver = Solver.Solver() self.master = master master.geometry('450x500+0+0') top_title_header = Frame(self.master, width=450, height=25) top_title_header.pack() top_frame = Frame(self.master, width=450, height=500) top_frame.pack() #create input (entry) widgets and assign to SDKgrid for x in range(9): for y in range(9): input = Entry(top_frame, width=2, font=("Courier", 24), justify="center") self.puzzleGrid.get_cell_at_coords(x, y).entryBox = input input.grid(row=x, column=y) grid_to_label_spacer = Frame(width=450, height=10) grid_to_label_spacer.pack() #label for messages self.message = StringVar() self.message.set("LOAD or manually input a puzzle!") self.label_for_messages = Label(self.master, textvariable=self.message) self.label_for_messages.pack() #separate grid and buttons label_to_button_spacer = Frame(width=600, height=10) label_to_button_spacer.pack() #container for buttons bottom_frame = Frame(width=600, height=50) bottom_frame.pack() """Button Widgets""" solve_button = Button(bottom_frame, text="SOLVE", fg="blue", command=lambda: self.solve_button()) solve_button.pack(side=LEFT) step_button = Button(bottom_frame, text="STEP", fg="black", command=lambda: self.step_button()) step_button.pack(side=LEFT) populate_button = Button(bottom_frame, text="LOAD", fg="black", command=lambda: self.load()) populate_button.pack(side=LEFT) save_button = Button(bottom_frame, text="SAVE", fg="black", command=lambda: self.save()) save_button.pack(side=LEFT) quit_button = Button(bottom_frame, text="QUIT", fg="red", command=bottom_frame.quit) quit_button.pack(side=LEFT)
def main() -> None: resource.setrlimit( resource.RLIMIT_AS, (90 * 10**9, 90 * 10**9) ) # limit RAM usage to 45 GB # TODO: make this a command line argument # TODO: not sure if this is actually the right way to do this (also, what about child processes?) utils.args = parse_args(sys.argv[1:]) if utils.args.log_xml: fmt = '%(message)s' elif utils.args.log_time: fmt = '%(asctime)s %(filename)s:%(lineno)d: %(message)s' else: fmt = '%(filename)s:%(lineno)d: %(message)s' if 'json' in utils.args and utils.args.json: utils.args.log = 'critical' utils.logger.setLevel(getattr(logging, utils.args.log.upper(), None)) handler = logging.StreamHandler(stream=sys.stdout) handler.terminator = '' handler.setFormatter(MyFormatter(fmt)) logging.root.addHandler(handler) # utils.logger.addHandler(handler) with utils.LogTag(utils.logger, 'main', lvl=logging.INFO): if utils.args.print_cmdline: with utils.LogTag(utils.logger, 'options', lvl=logging.INFO): utils.logger.info(' '.join([sys.executable] + sys.argv)) utils.logger.info('Running mypyvy with the following options:') for k, v in sorted(vars(utils.args).items()): utils.logger.info(f' {k} = {v!r}') utils.logger.info('setting seed to %d' % utils.args.seed) z3.set_param('smt.random_seed', utils.args.seed) # utils.logger.info('enable z3 macro finder') # z3.set_param('smt.macro_finder', True) if utils.args.timeout is not None: utils.logger.info('setting z3 timeout to %s' % utils.args.timeout) z3.set_param('timeout', utils.args.timeout) pre_parse_error_count = utils.error_count with open(utils.args.filename) as f: prog = parse_program( f.read(), force_rebuild=utils.args.forbid_parser_rebuild, filename=utils.args.filename) if utils.error_count > pre_parse_error_count: utils.logger.always_print('program has syntax errors.') sys.exit(1) if utils.args.print_program_repr: utils.logger.always_print(repr(prog)) if utils.args.print_program: utils.logger.always_print(str(prog)) pre_resolve_error_count = utils.error_count prog.resolve() if utils.error_count > pre_resolve_error_count: utils.logger.always_print('program has resolution errors.') sys.exit(1) syntax.the_program = prog s = Solver() # initialize common keys s.get_translator(KEY_ONE) s.get_translator(KEY_NEW) s.get_translator(KEY_OLD) utils.args.main(s) utils.logger.info('total number of queries: %s' % s.nqueries) if utils.args.ipython: ipython(s) sys.exit(1 if utils.error_count > 0 else 0)
def main() -> None: # limit RAM usage to 45 GB # TODO: make this a command line argument # TODO: not sure if this is actually the right way to do this (also, what about child processes?) resource.setrlimit(resource.RLIMIT_AS, (90 * 10**9, 90 * 10**9)) utils.args = parse_args(sys.argv[1:]) if utils.args.log_xml: fmt = '%(message)s' elif utils.args.log_time: fmt = '%(asctime)s %(filename)s:%(lineno)d: %(message)s' else: fmt = '%(filename)s:%(lineno)d: %(message)s' if 'json' in utils.args and utils.args.json: utils.args.log = 'critical' utils.logger.setLevel(getattr(logging, utils.args.log.upper(), None)) handler = logging.StreamHandler(stream=sys.stdout) handler.terminator = '' handler.setFormatter(MyFormatter(fmt)) logging.root.addHandler(handler) if utils.args.print_cmdline: utils.logger.always_print(' '.join([sys.executable] + sys.argv)) utils.logger.info('Running mypyvy with the following options:') for k, v in sorted(vars(utils.args).items()): utils.logger.info(f' {k} = {v!r}') utils.logger.info('setting seed to %d' % utils.args.seed) z3.set_param('smt.random_seed', utils.args.seed) z3.set_param('sat.random_seed', utils.args.seed) # utils.logger.info('enable z3 macro finder') # z3.set_param('smt.macro_finder', True) if utils.args.timeout is not None: utils.logger.info('setting z3 timeout to %s' % utils.args.timeout) z3.set_param('timeout', utils.args.timeout) pre_parse_error_count = utils.error_count with open(utils.args.filename) as f: prog = parse_program(f.read(), forbid_rebuild=utils.args.forbid_parser_rebuild, filename=utils.args.filename) if utils.error_count > pre_parse_error_count: utils.logger.always_print('program has syntax errors.') utils.exit(1) if utils.args.print_program is not None: if utils.args.print_program == 'str': to_str: Callable[[Program], str] = str end = '\n' elif utils.args.print_program == 'repr': to_str = repr end = '\n' elif utils.args.print_program == 'faithful': to_str = syntax.faithful_print_prog end = '' elif utils.args.print_program == 'without-invariants': def p(prog: Program) -> str: return syntax.faithful_print_prog(prog, skip_invariants=True) to_str = p end = '' else: assert False utils.logger.always_print(to_str(prog), end=end) pre_typecheck_error_count = utils.error_count typechecker.typecheck_program(prog) if utils.error_count > pre_typecheck_error_count: utils.logger.always_print('program has resolution errors.') utils.exit(1) syntax.the_program = prog s = Solver(use_cvc4=utils.args.cvc4) utils.args.main(s) if utils.args.ipython: ipython(s) utils.exit(1 if utils.error_count > 0 else 0)