Beispiel #1
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"
Beispiel #2
0
def main():
    import sys

    def usage():
        print "usage: \n  {} <file>.iev ".format(sys.argv[0])
        sys.exit(1)

    if len(sys.argv) != 2:
        usage()
        exit(1)
    fn = sys.argv[1]
    import chardet  # $ pip install chardet
    try:
        f = open(fn, 'r')
    except:
        print "not found: %s" % fn
        sys.exit(1)

    with iu.ErrorPrinter():
        with iu.SourceFile(fn):
            s = f.read()
            evs = ev.parse(s)
    global tk
    tk = Tix.Tk()
    RunSample(tk, evs)
    tk.mainloop()
def main():
    ivy_init.read_params()
    iu.set_parameters({'show_compiled':'true'})
    if len(sys.argv) != 2 or not sys.argv[1].endswith('ivy'):
        print "<bhavya> in ivy_show"
        usage()
    with im.Module():
        with utl.ErrorPrinter():
            ivy_init.source_file(sys.argv[1],ivy_init.open_read(sys.argv[1]),create_isolate=False)
            check_module()
Beispiel #4
0
def main():
    ivy_init.read_params()
    if len(sys.argv) != 2 or not sys.argv[1].endswith('ivy'):
        usage()
    with im.Module():
        with utl.ErrorPrinter():
            ivy_init.source_file(sys.argv[1],
                                 ivy_init.open_read(sys.argv[1]),
                                 create_isolate=False)
            check_module()
    print "OK"
Beispiel #5
0
def main():
    ivy.read_params()
    iu.set_parameters({'mode': 'induction'})
    if len(sys.argv) != 2 or not sys.argv[1].endswith('ivy'):
        usage()
    with im.Module():
        with utl.ErrorPrinter():
            ivy.source_file(sys.argv[1],
                            ivy.open_read(sys.argv[1]),
                            create_isolate=False)
            check_module()
    print "OK"
Beispiel #6
0
def main():
    ivy_init.read_params()
    if not sys.argv[1].endswith('ivy'):
        usage()
    for i in range(2, len(sys.argv)):
        st = sys.argv[i].split('=')
        instance[st[0]] = eval(st[1])

    with im.Module():
        with utl.ErrorPrinter():
            with iu.SourceFile(sys.argv[1]):
                decls = read_module(ivy_init.open_read(sys.argv[1]))
                translate(decls)
Beispiel #7
0
def main():
    import signal
    signal.signal(signal.SIGINT,signal.SIG_DFL)
    import ivy_alpha
    ivy_alpha.test_bottom = False # this prevents a useless SAT check
    ivy_init.read_params()
    if len(sys.argv) != 2 or not sys.argv[1].endswith('ivy'):
        usage()
    with im.Module():
        with utl.ErrorPrinter():
            ivy_init.source_file(sys.argv[1],ivy_init.open_read(sys.argv[1]),create_isolate=False)
            check_module()
    print "OK"
Beispiel #8
0
def main():
    ia.set_determinize(True)
    slv.set_use_native_enums(True)
    iso.set_interpret_all_sorts(True)
    with im.Module():
        ivy.ivy_init()

        classname = im.module.name
        with iu.ErrorPrinter():
            header, impl = module_to_cpp_class(classname)


#        print header
#        print impl
        f = open(classname + '.h', 'w')
        f.write(header)
        f.close()
        f = open(classname + '.cpp', 'w')
        f.write(impl)
        f.close()
Beispiel #9
0
    ag.states = []
    analyze_state_rec(ag, state)
    state.clauses.extend(clauses)
    ui.ui_main_loop(ag)


def eval_assert_rhs(rhs, domain):
    if not isinstance(rhs, act.RME):
        rhs = act.RME(log.And(), [], rhs)
    return itp.eval_state(rhs, act.ActionContext(domain))


if __name__ == "__main__":
    ag = ivy.ivy_init()
    ac = AC(ag.assertions, ag.actions, ag.domain)
    with utl.ErrorPrinter():
        for ass in ag.assertions:
            lhs = ass.args[0].rep
            rhs = ass.args[1]
            rhs_state = eval_assert_rhs(rhs, ag.domain)
            try:
                if lhs in ag.predicates:
                    with ac:
                        lhs_state = itp.eval_state(ag.predicates[lhs], ac)
                elif lhs in ag.actions:
                    with ac:
                        lhs_state = itp.eval_state(
                            act.entry(lg.Not(rhs_state.precond)), ac)
                        lhs_state = itp.apply_action(ass, lhs, ag.actions[lhs],
                                                     lhs_state)
                else:
Beispiel #10
0
interpret > -> >
interpret + -> +
interpret - -> -
interpret * -> *
"""

def parse_to_ivy(s):
    dm = dp.parse(s)
    im = ip.parse(preamble)
    with ModuleContext(dm,im):
        dm.to_ivy()
        print im
        return im

if __name__ == "__main__":
    with iu.ErrorPrinter():
        dm = dp.parse("""
            // a comment
            var x : bool;
            var y : object;
            method P(y:object) returns (x:object)
                modifies x;
                ensures x == y;
                {
                     x := y;
                     assume x == y;
                }""")
        im = ip.Ivy()
        with ModuleContext(dm,im):
            dm.to_ivy()
            print im