action a(x:obj.t) = { local y:obj.t { if some z:s. z = z { y := y } } } type s axiom forall X:s. X = X """ with im.Module(): iu.set_parameters({'ui':'cti','ext':'ext','show_compiled':'true'}) main_ui = new_ui() ui = main_ui.add(ivy_from_string(prog)) # 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") # ui.check_inductiveness() # # cg.show_relation(cg.relation('semaphore'),'+') # cg.gather() # main_ui.answer("View")
individual x(X:t) : t 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()
type foo type bar individual x:foo,y:bar function f(X:foo) : bar action a = { if some z:foo. f(z) = y minimizing z { x := z } } """ with im.Module(): iu.set_parameters({'ui': 'cti', 'ext': 'ext', 'show_compiled': 'true'}) main_ui = new_ui() ui = main_ui.add(ivy_from_string(prog)) # 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") # ui.check_inductiveness() # # cg.show_relation(cg.relation('semaphore'),'+') # cg.gather() # main_ui.answer("View")
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()
type foo type bar destructor f(X:foo) : bar individual x:foo,y:bar action a = { f(x) := y } """ with im.Module(): iu.set_parameters({'ui':'cti','ext':'ext'}) main_ui = new_ui() ui = main_ui.add(ivy_from_string(prog)) # 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") # ui.check_inductiveness() # # cg.show_relation(cg.relation('semaphore'),'+') # cg.gather() # main_ui.answer("View")
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 le(X : t, Y : t) axiom le(X,Y) & le(Y,Z) -> le(X,Z) axiom le(X,X) """ with ivy_module.Module(): iu.set_parameters({'ui': 'cti', 'ext': 'ext'}) main_ui = new_ui() ui = main_ui.add(ivy_from_string(prog)) # ui.mainloop()
} } private baz conjecture r -> x = me } instance inst(X:foo) : mod(X) isolate iso(me:foo) = inst(me) with inst(me).baz export inst.set_me """ with im.Module(): iu.set_parameters({'mode':'induction','diagnose':'true','show_compiled':'true'}) ivy_from_string(prog,create_isolate=False) ick.check_module() # 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") # ui.check_inductiveness() # # cg.show_relation(cg.relation('semaphore'),'+') # cg.gather()
} } 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()
call p.a; assert v = w } action c = { v := w } } object s = { action a = { assert v = w } execute a after p.a } isolate iso_q = q with s export q.b """ with im.Module(): iu.set_parameters({'mode': 'induction'}) ivy_from_string(prog, create_isolate=False) try: ick.check_module() except iu.IvyError as e: assert str( e ) == "error: Some assertions are not checked", "should have been an error"
from ivy import ivy_utils as iu prog = """#lang ivy1.6 type t type s1 = struct { foo : t, bar : t } type s2 = struct { baz : s1, bif : t } individual w : t individual v : s2 action a = { v.baz.foo := w } export a """ with im.Module(): iu.set_parameters({'show_compiled':'true'}) ivy_from_string(prog,create_isolate=False) print im.module.actions["a"].update(im.module,{})
} conjecture r -> x = me } instance inst(X:foo) : mod(X) axiom inst(X).r & inst(X).x = X isolate iso(me:foo) = inst(me) export inst.set_me """ with im.Module(): iu.set_parameters({"ui": "cti", "ext": "ext", "isolate": "iso", "show_compiled": "true"}) main_ui = new_ui() ui = main_ui.add(ivy_from_string(prog)) # 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") # ui.check_inductiveness() # # cg.show_relation(cg.relation('semaphore'),'+') # cg.gather() # main_ui.answer("View")
call p.a; assert v = w } action c = { v := w } } object s = { action a = { assert v = w } execute a after p.a } isolate iso_q = q with s export q.b """ with im.Module(): iu.set_parameters({'mode':'induction'}) ivy_from_string(prog,create_isolate=False) try: ick.check_module() except iu.IvyError as e: assert str(e) == "error: Some assertions are not checked","should have been an error"