def get_json(): with ivy_module.Module(): with open(sys.argv[1]) as f: ivy_load_file(f) functions = [] for func in im.module.functions: functions.append(logic_to_obj(func)) # XXX hack #if sys.argv[1] == "examples/leader-election.ivy": # functions.append(["const", "<=", ["functionSort", [ # ["uninterpretedSort", "id"], # ["uninterpretedSort", "id"]], # ["booleanSort"]]]) axioms = [] for axiom in im.module.get_axioms(): #print axiom #print logic_to_obj(ivy_logic_utils.close_epr(axiom)) axioms.append(logic_to_obj(ivy_logic_utils.close_epr(axiom))) conjectures = [] for conj in im.module.conjs: for fmla in conj.fmlas: #print fmla #print logic_to_obj(ivy_logic_utils.close_epr(fmla)) conjectures.append( logic_to_obj(ivy_logic_utils.close_epr(fmla))) #conjectures.append(logic_to_obj(conj.formula)) templates = [] for template in im.module.labeled_templates: #print template #print template.formula templates.append(logic_to_obj(template.formula)) #template = ivy_logic_utils.formula_to_clauses(template) #or fmla in template.fmlas: # templates.append(logic_to_obj(fmla)) inits = [] for fmla in im.module.init_cond.fmlas: inits.append(logic_to_obj(ivy_logic_utils.close_epr(fmla))) actions = {} for name in im.module.actions: action = im.module.actions[name] actions[name] = action_to_obj(action) return json.dumps({ "sorts": im.module.sort_order, "functions": functions, "inits": inits, "axioms": axioms, "conjectures": conjectures, #[c for c in conjectures if not has_wildcard(c)], "templates": templates, #[c for c in conjectures if has_wildcard(c)], "actions": actions, })
def main(): global outFile import signal signal.signal(signal.SIGINT, signal.SIG_DFL) from ivy import ivy_alpha ivy_alpha.test_bottom = False # this prevents a useless SAT check ivy_init.read_params() if len(sys.argv) != 3 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) outFile = sys.argv[2] print_module() print "OK"
def error_location_test(self, filename, line, column): prog_filename = os.path.join(os.path.dirname(__file__), 'compile_errors', filename) def make_assertions(e): self.assertEquals(e.source_location.line, line) self.assertEquals(e.source_location.column, column) with im.Module(): try: ic.ivy_new(prog_filename) except iu.ErrorList as e: make_assertions(e.errors[0]) return except iu.IvyError as e: make_assertions(e) return self.assertTrue(False) # No errors, spike the test
import ivy.ivy_module as ivy_module from ivy.ivy_compiler import ivy_from_string from ivy.tk_ui import new_ui import ivy.ivy_utils as iu prog = """#lang ivy1.3 type t relation (X:t < Y:t) axiom X:t < Y:t & Y < Z -> X < Y individual x:t, y:t, z:t init x < y & y < z """ with ivy_module.Module(): main_ui = new_ui() ui = main_ui.add(ivy_from_string(prog)) cg = ui.view_state(ui.node(0)) cg.show_relation(cg.relation('X:t < Y'), '+') cg.split(cg.relation('=x'), cg.node('t')) cg.show_relation(cg.relation('=x'), '-') cg.split(cg.relation('=y'), cg.node('~=x')) cg.show_relation(cg.relation('=y'), '-') cg.split(cg.relation('=z'), cg.node('~=x', '~=y')) # ui.mainloop()
relation sent(X:packet) init ~sent(X) before intf.send { sent(x) := true } before intf.recv { assert sent(x) } } object protocol = { implement intf.send { call intf.recv(x) } } import intf.recv export intf.send """ with im.Module(): iu.set_parameters({'mode':'induction','show_compiled':'true'}) ivy_from_string(prog,create_isolate=False) ick.check_module()