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()
object foo(me:t) = { after init { x(me) := me; assert false } } isolate iso_foo(me:t) = foo(me) with x(me) """ with im.Module(): iu.set_parameters({'mode':'induction','isolate':'iso_foo','show_compiled':'true'}) main_ui = new_ui() ui = main_ui.add(ivy_from_string(prog)) main_ui.tk.update_idletasks() main_ui.answer("OK") ui.check_safety_node(ui.node(0)) assert not ui.node(0).safe # ui.check_inductiveness() # # ui = ui.cti # cg = ui.current_concept_graph # cg.show_relation(cg.relation('link(X,Y)'),'+') # cg.gather() # main_ui.answer("OK") # cg.strengthen() # main_ui.answer("OK") # ui.check_inductiveness() # # cg.show_relation(cg.relation('semaphore'),'+') # cg.gather()
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()
from ivy.tk_ui import new_ui from ivy import ivy_utils as iu from ivy import ivy_check as ick prog = """#lang ivy1.5 type foo type bar individual x : foo # individual y : foo action a(z:foo,y:foo) = { x := y } object m(me:foo) = { after a { assert x = y | x = me } } export a """ with im.Module(): iu.set_parameters({"mode": "induction", "show_compiled": "true"}) ivy_from_string(prog, create_isolate=False) ick.check_module()
interpret t -> {0..1} instance baz(X:t) : bar """ ia.set_determinize(True) slv.set_use_native_enums(True) iso.set_interpret_all_sorts(True) with im.Module(): iu.set_parameters({ 'mode': 'induction', 'show_compiled': 'true', 'target': 'impl' }) ivy_from_string(prog, create_isolate=True) classname = 'foo' header, impl = i2c.module_to_cpp_class(classname) print header print impl # main_ui.answer("OK") # ui.check_inductiveness() # # ui = ui.cti # cg = ui.current_concept_graph # cg.show_relation(cg.relation('link(X,Y)'),'+') # cg.gather() # main_ui.answer("OK") # cg.strengthen() # main_ui.answer("OK")
} type t interpret t -> {0..1} instance baz(X:t) : bar """ ia.set_determinize(True) slv.set_use_native_enums(True) iso.set_interpret_all_sorts(True) with im.Module(): iu.set_parameters({'mode':'induction','show_compiled':'true','target':'impl'}) ivy_from_string(prog,create_isolate=True) classname = 'foo' header,impl = i2c.module_to_cpp_class(classname,classname) print header print impl # main_ui.answer("OK") # ui.check_inductiveness() # # ui = ui.cti # cg = ui.current_concept_graph # cg.show_relation(cg.relation('link(X,Y)'),'+') # cg.gather() # main_ui.answer("OK") # cg.strengthen() # main_ui.answer("OK")