def check_module(): # If user specifies an isolate, check it. Else, if any isolates # are specificied in the file, check all, else check globally. isolate = ivy_compiler.isolate.get() if isolate != None: isolates = [isolate] else: isolates = sorted(list(im.module.isolates)) if len(isolates) == 0: isolates = [None] for isolate in isolates: if len(im.module.isolates[isolate].verified()) == 0: continue # skip if nothing to verify if isolate: print "Checking isolate {}...".format(isolate) with im.module.copy(): ivy_isolate.create_isolate(isolate) # ,ext='ext' ag = ivy_art.AnalysisGraph(initializer=ivy_alpha.alpha) with ivy_interp.EvalContext(check=False): check_conjectures('Initiation','These conjectures are false initially.',ag,ag.states[0]) for a in sorted(im.module.public_actions): print "trying {}...".format(a) ag.execute_action(a,prestate=ag.states[0]) cex = ag.check_bounded_safety(ag.states[-1]) if cex is not None: display_cex("safety failed",cex) check_conjectures('Consecution','These conjectures are not inductive.',ag,ag.states[-1])
def ivy_compile(decls, mod=None, create_isolate=True, **kwargs): mod = mod or im.module with mod.sig: check_instantiations(mod, decls) for name in decls.defined: mod.add_to_hierarchy(name) infer_parameters(decls.decls) with TopContext(collect_actions(decls.decls)): IvyDomainSetup(mod)(decls) IvyConjectureSetup(mod)(decls) IvyARGSetup(mod)(decls) mod.macros = decls.macros # progress properties are not state symbols -- remove from sig for p in mod.progress: remove_symbol(p.defines()) mod.type_check() # try instantiating all the actions to type check them for name, action in mod.actions.iteritems(): # print "checking: {} = {}".format(name,action) type_check_action(action, mod) if not hasattr(action, 'lineno'): print "no lineno: {}".format(name) assert hasattr(action, 'formal_params'), action # print "actions:" # for x,y in mod.actions.iteritems(): # print iu.pretty("action {} = {}".format(x,y)) if create_isolate: iso.create_isolate(isolate.get(), mod, **kwargs)
def main(): ivy.read_params() if len(sys.argv) != 2 or not sys.argv[1].endswith('ivy'): usage() with im.Module(): isolate = ivy_compiler.isolate.get() ivy.source_file(sys.argv[1],ivy.open_read(sys.argv[1]),create_isolate=False) # If user specifies an isolate, check it. Else, if any isolates # are specificied in the file, check all, else check globally. if isolate != None: isolates = [isolate] else: isolates = sorted(list(im.module.isolates)) if len(isolates) == 0: isolates = [None] for isolate in isolates: if len(im.module.isolates[isolate].verified()) == 0: continue # skip if nothing to verify with im.module.copy(): ivy_isolate.create_isolate(isolate,ext='ext') ag = ivy_art.AnalysisGraph(initializer=ivy_alpha.alpha) with utl.ErrorPrinter(): with ivy_interp.EvalContext(check=False): ag.execute_action('ext') cex = ag.check_bounded_safety(ag.states[-1]) if cex is not None: display_cex("safety failed",cex) print "OK"
def check_module(): # If user specifies an isolate, check it. Else, if any isolates # are specificied in the file, check all, else check globally. isolate = ivy_compiler.isolate.get() with im.module.copy(): ivy_isolate.create_isolate(isolate) # ,ext='ext'
def ivy_compile(decls,mod=None,create_isolate=True,**kwargs): mod = mod or im.module with mod.sig: check_instantiations(mod,decls) for name in decls.defined: mod.add_to_hierarchy(name) # infer_parameters(decls.decls) with TopContext(collect_actions(decls.decls)): IvyDomainSetup(mod)(decls) IvyConjectureSetup(mod)(decls) IvyARGSetup(mod)(decls) mod.macros = decls.macros # progress properties are not state symbols -- remove from sig for p in mod.progress: remove_symbol(p.defines()) mod.type_check() # try instantiating all the actions to type check them for name,action in mod.actions.iteritems(): # print "checking: {} = {}".format(name,action) type_check_action(action,mod) if not hasattr(action,'lineno'): print "no lineno: {}".format(name) assert hasattr(action,'formal_params'), action # print "actions:" # for x,y in mod.actions.iteritems(): # print iu.pretty("action {} = {}".format(x,y)) if create_isolate: iso.create_isolate(isolate.get(),mod,**kwargs) im.module.labeled_axioms.extend(im.module.labeled_props) im.module.theory_context().__enter__()
def main(): ivy.read_params() if len(sys.argv) != 2 or not sys.argv[1].endswith('ivy'): usage() with im.Module(): isolate = ivy_compiler.isolate.get() ivy.source_file(sys.argv[1], ivy.open_read(sys.argv[1]), create_isolate=False) # If user specifies an isolate, check it. Else, if any isolates # are specificied in the file, check all, else check globally. if isolate != None: isolates = [isolate] else: isolates = sorted(list(im.module.isolates)) if len(isolates) == 0: isolates = [None] for isolate in isolates: if len(im.module.isolates[isolate].verified()) == 0: continue # skip if nothing to verify with im.module.copy(): ivy_isolate.create_isolate(isolate, ext='ext') ag = ivy_art.AnalysisGraph(initializer=ivy_alpha.alpha) with utl.ErrorPrinter(): with ivy_interp.EvalContext(check=False): ag.execute_action('ext') cex = ag.check_bounded_safety(ag.states[-1]) if cex is not None: display_cex("safety failed", cex) print "OK"
def check_module(): # If user specifies an isolate, check it. Else, if any isolates # are specificied in the file, check all, else check globally. missing = [] isolate = ivy_compiler.isolate.get() if isolate != None: isolates = [isolate] else: isolates = sorted(list(im.module.isolates)) if len(isolates) == 0: isolates = [None] else: if coverage.get(): missing = ivy_isolate.check_isolate_completeness() if missing: raise iu.IvyError(None,"Some assertions are not checked") for isolate in isolates: if isolate != None and isolate in im.module.isolates: idef = im.module.isolates[isolate] if len(idef.verified()) == 0 or isinstance(idef,ivy_ast.TrustedIsolateDef): continue # skip if nothing to verify if isolate: print "\nIsolate {}:".format(isolate) with im.module.copy(): ivy_isolate.create_isolate(isolate) # ,ext='ext' if opt_trusted.get(): continue check_isolate() print '' if failures > 0: raise iu.IvyError(None,"failed checks: {}".format(failures))
def check_module(): # If user specifies an isolate, check it. Else, if any isolates # are specificied in the file, check all, else check globally. missing = [] isolate = ivy_compiler.isolate.get() if isolate != None: isolates = [isolate] else: isolates = sorted(list(im.module.isolates)) if len(isolates) == 0: isolates = [None] else: if coverage.get(): missing = ivy_isolate.check_isolate_completeness() if missing: raise iu.IvyError(None, "Some assertions are not checked") for isolate in isolates: if isolate != None and len( im.module.isolates[isolate].verified()) == 0: continue # skip if nothing to verify if isolate: print "Checking isolate {}...".format(isolate) with im.module.copy(): ivy_isolate.create_isolate(isolate) # ,ext='ext' check_properties() ag = ivy_art.AnalysisGraph(initializer=ivy_alpha.alpha) if im.module.initializers: cex = ag.check_bounded_safety(ag.states[0]) if cex is not None: display_cex("safety failed in initializer", cex) with ivy_interp.EvalContext(check=False): check_conjectures('Initiation', 'These conjectures are false initially.', ag, ag.states[0]) for a in sorted(im.module.public_actions): print "trying {}...".format(a) ag.execute_action(a, prestate=ag.states[0]) cex = ag.check_bounded_safety(ag.states[-1]) if cex is not None: display_cex("safety failed", cex) check_conjectures('Consecution', 'These conjectures are not inductive.', ag, ag.states[-1])
def print_module(): isolates = sorted(list(im.module.isolates)) if len(isolates) != 1: raise iu.IvyError( None, "Expected exactly one isolate, got %s" % len(isolates)) for isolate in isolates: if isolate != None and isolate in im.module.isolates: idef = im.module.isolates[isolate] if len(idef.verified()) == 0 or isinstance( idef, ivy_ast.TrustedIsolateDef): continue # skip if nothing to verify if isolate: print "\nPrinting isolate {}:".format(isolate) with im.module.copy(): ivy_isolate.create_isolate(isolate) # ,ext='ext' print_isolate()
def check_module(): # If user specifies an isolate, check it. Else, if any isolates # are specificied in the file, check all, else check globally. missing = [] isolate = ivy_compiler.isolate.get() if isolate != None: isolates = [isolate] else: isolates = sorted(list(im.module.isolates)) if len(isolates) == 0: isolates = [None] else: if coverage.get(): missing = ivy_isolate.check_isolate_completeness() if missing: raise iu.IvyError(None, "Some assertions are not checked") for isolate in isolates: if isolate != None and isolate in im.module.isolates: idef = im.module.isolates[isolate] if len(idef.verified()) == 0 or isinstance( idef, ivy_ast.TrustedIsolateDef): continue # skip if nothing to verify if isolate: print "Checking isolate {}...".format(isolate) with im.module.copy(): ivy_isolate.create_isolate(isolate) # ,ext='ext' if opt_trusted.get(): continue with im.module.theory_context(): check_properties() ag = ivy_art.AnalysisGraph(initializer=ivy_alpha.alpha) if im.module.initializers: cex = ag.check_bounded_safety(ag.states[0]) if cex is not None: display_cex("safety failed in initializer", cex) with ivy_interp.EvalContext(check=False): check_conjectures( 'Initiation', 'These conjectures are false initially.', ag, ag.states[0]) # show_assertions() for actname in get_checked_actions(): old_checked_assert = act.checked_assert.get() print "trying {}...".format(actname) assertions = find_assertions(actname) if act.checked_assert.get(): assertions = [ a for a in assertions if a.lineno == act.checked_assert.get() ] tried = set() for asn in assertions: if asn.lineno not in tried: tried.add(asn.lineno) act.checked_assert.value = asn.lineno print '{}: {}'.format(asn.lineno, asn) ag.execute_action(actname, prestate=ag.states[0]) cex = ag.check_bounded_safety(ag.states[-1], bound=1) if cex is not None: display_cex("safety failed", cex) print "checking consecution..." ag.execute_action(actname, prestate=ag.states[0], abstractor=ivy_alpha.alpha) check_conjectures( 'Consecution', 'These conjectures are not inductive.', ag, ag.states[-1]) act.checked_assert.value = old_checked_assert
usage() with im.Module(): isolate = ivy_compiler.isolate.get() ivy.source_file(sys.argv[1],ivy.open_read(sys.argv[1]),create_isolate=False) # If user specifies an isolate, check it. Else, if any isolates # are specificied in the file, check all, else check globally. if isolate != None: isolates = [isolate] else: isolates = sorted(list(im.module.isolates)) if len(isolates) == 0: isolates = [None] for isolate in isolates: if len(im.module.isolates[isolate].verified()) == 0: continue # skip if nothing to verify iu.dbg('isolate') with im.module.copy(): ivy_isolate.create_isolate(isolate) ag = ivy_art.AnalysisGraph(initializer=ivy_alpha.alpha) with utl.ErrorPrinter(): with ivy_interp.EvalContext(check=False): ag.execute_action('ext') cex = ag.check_bounded_safety(ag.states[-1]) if cex is not None: display_cex("safety failed",cex) print "OK"
def check_module(): # If user specifies an isolate, check it. Else, if any isolates # are specificied in the file, check all, else check globally. missing = [] isolate = ivy_compiler.isolate.get() if isolate != None: isolates = [isolate] else: isolates = sorted(list(im.module.isolates)) if len(isolates) == 0: isolates = [None] else: if coverage.get(): missing = ivy_isolate.check_isolate_completeness() if missing: raise iu.IvyError(None,"Some assertions are not checked") for isolate in isolates: if isolate != None and isolate in im.module.isolates: idef = im.module.isolates[isolate] if len(idef.verified()) == 0 or isinstance(idef,ivy_ast.TrustedIsolateDef): continue # skip if nothing to verify if isolate: print "Checking isolate {}...".format(isolate) with im.module.copy(): ivy_isolate.create_isolate(isolate) # ,ext='ext' if opt_trusted.get(): continue with im.module.theory_context(): check_properties() ag = ivy_art.AnalysisGraph(initializer=ivy_alpha.alpha) if im.module.initializers: cex = ag.check_bounded_safety(ag.states[0]) if cex is not None: display_cex("safety failed in initializer",cex) with ivy_interp.EvalContext(check=False): check_conjectures('Initiation','These conjectures are false initially.',ag,ag.states[0]) # show_assertions() for actname in get_checked_actions(): old_checked_assert = act.checked_assert.get() print "trying {}...".format(actname) assertions = find_assertions(actname) if act.checked_assert.get(): assertions = [a for a in assertions if a.lineno == act.checked_assert.get()] tried = set() for asn in assertions: if asn.lineno not in tried: tried.add(asn.lineno) act.checked_assert.value = asn.lineno print '{}: {}'.format(asn.lineno,asn) ag.execute_action(actname,prestate=ag.states[0]) cex = ag.check_bounded_safety(ag.states[-1],bound=1) if cex is not None: display_cex("safety failed",cex) print "checking consecution..." ag.execute_action(actname,prestate=ag.states[0],abstractor=ivy_alpha.alpha) check_conjectures('Consecution','These conjectures are not inductive.',ag,ag.states[-1]) act.checked_assert.value = old_checked_assert
def check_module(): # If user specifies an isolate, check it. Else, if any isolates # are specificied in the file, check all, else check globally. missing = [] isolate = ivy_compiler.isolate.get() if isolate != None: isolates = [isolate] else: isolates = sorted(list(im.module.isolates)) if len(isolates) == 0: isolates = [None] else: if coverage.get(): missing = ivy_isolate.check_isolate_completeness() if missing: raise iu.IvyError(None, "Some assertions are not checked") for isolate in isolates: if isolate is not None and isolate in im.module.isolates: idef = im.module.isolates[isolate] if len(idef.verified()) == 0 or isinstance( idef, ivy_ast.TrustedIsolateDef): continue # skip if nothing to verify if isolate: print "\nIsolate {}:".format(isolate) if isolate is not None and iu.compose_names( isolate, 'macro_finder') in im.module.attributes: save_macro_finder = islv.opt_macro_finder.get() if save_macro_finder: print "Turning off macro_finder" islv.set_macro_finder(False) with im.module.copy(): ivy_isolate.create_isolate(isolate) # ,ext='ext' if opt_trusted.get(): continue method_name = get_isolate_method(isolate) if method_name == 'mc': mc_isolate(isolate) elif method_name.startswith('bmc['): global some_bounded some_bounded = True _, prms = iu.parse_int_subscripts(method_name) if len(prms) != 1: raise IvyError( None, 'BMC method specifier should be bmc[<steps>]. Got "{}".' .format(method_name)) mc_isolate(isolate, lambda: ivy_bmc.check_isolate(prms[0])) else: check_isolate() if isolate is not None and iu.compose_names( isolate, 'macro_finder') in im.module.attributes: if save_macro_finder: print "Turning on macro_finder" islv.set_macro_finder(True) print '' if failures > 0: raise iu.IvyError(None, "failed checks: {}".format(failures)) if checked_action.get() and not checked_action_found: raise iu.IvyError( None, "{} is not an exported action of any isolate".format( checked_action.get())) cact = checked_action.get()