Ejemplo n.º 1
0
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])
Ejemplo n.º 2
0
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"
Ejemplo n.º 3
0
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__()
Ejemplo n.º 4
0
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'
Ejemplo n.º 5
0
        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"

Ejemplo n.º 6
0
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