library colibrilib.sbdd — module SNodemodule SNode552use colibrilib.bdd.Node553use mach.int.Int63554type snode = { n: Node.t; s: int63; scal: bool }555556use int.Int557
The snode nd shifted by off: a scalar snode (the sign of its node) is not moved
Valid (63ms) (colibri2)
560 let ghost function shift_snode (nd: snode) (off: int) : snode
561 requires { nd.scal \/ in_bounds (to_int nd.s - off) }
562 ensures { result.n = nd.n /\ result.scal = nd.scal }
563 ensures { not nd.scal -> to_int result.s = to_int nd.s - off }
564 ensures { nd.scal -> result = nd }
565 = if nd.scal then nd else { n = nd.n; s = of_int (to_int nd.s - off); scal = false }
566
567 use set.Set
The valuation of the snodes shifted by k
function shifted (sn: Set.set snode) (k: int) : Set.set snode = fun nd -> sn (shift_snode nd k)570
The shift of a snode does not fit in an int63
exception Overflow573Valid (225ms) (colibri2)574let shift_snode_checked (nd: snode) (off: int63) : snode575ensures { nd.scal \/ in_bounds (to_int nd.s - to_int off) }576ensures { result = shift_snode nd off }577raises { Overflow -> not nd.scal /\ not (in_bounds (to_int nd.s - to_int off)) }578= (* not a nested [if] without [else]: the OCaml extraction drops its [begin end] *)579let out = if nd.scal then false else if off >= 0 then nd.s < min_int + off else nd.s > max_int + off in581if out then raise Overflow;582if nd.scal then nd else { n = nd.n; s = nd.s - off; scal = false }583584end585