library colibrilib.bitwise_rules — module IntervalsThe known bits of the interval of a node in its bit–level term
module Intervals837use int.Int838use real.FromInt839use option.Option840use colibrilib.q.Real as Real841use colibrilib.known_bits.KnownBits842use colibrilib.zarith.Zbit843use colibrilib.zbit.ZbitInt844use colibrilib.bdd.Node845use colibrilib.ibdd.IBDD846use colibrilib.bddbitv.Export847use colibrilib.env.Env848use colibrilib.safe_bits.BitsSpec849use colibrilib.safe_bits.SafeBits850use colibrilib.sbdd.SNode851use colibrilib.spec.Defines852use list.List853use mach.int.Int63854use colibrilib.bddbitv.IBDDS as S855use colibrilib.bv_sem.Sem856use colibrilib.kb_interval.KbInterval as KI857use Term858use TermInterval859
The known bits of the interval of the node (Dom_genrelbitv.bitmask_of_interval)
Valid (101ms) (colibri2)let known_bits (d:env) (n:Node.t) : KnownBits.t863ensures { live d -> KnownBits.mem (ienv d n) result }864raises { Contradiction -> not live d }865= match interval d n with866| None -> KnownBits.top867| Some u ->868match KI.known_bits (use_domain d) u with869| Some k -> k870| None ->871{proof…}872assert { live d -> Real.is_integer (from_int (ienv d n)) };873{qed}874raise Contradiction875end876end877
The known bits of the interval of n in its term: n = u lor (l land n), on the unbounded integer term of n. Not on the term of its size: the size can come from the interval itself (TermSize.size), and then the equation is the term and says nothing to the term of n in the domain, which keeps the size of its type (a 12–bit i in [0;1023]: its two high bits stay unknown, and bvlshr i 2 too)
Valid (1.7s) (colibri2 10) (cvc4 3) (split_vc) (depth 1)let partial bits_of_interval (d:env) (n:Node.t) : unit886raises { Contradiction -> not live d }887raises { Unsupported -> false }888raises { Overflow -> false }889= let kb = known_bits d n in890if not (KnownBits.is_top kb) then begin891let x = monome_sized d n None in892try893let cu = int_cst kb.u in894let cl = int_cst kb.l in895let low = int_logand cl x in896let t = int_logor cu low in897let lemma ok (_:unit) : unit898requires { live d }899ensures { ienv d n = ivalue t (ienv d) }900= let en = ienv d n in901assert { ivalue x (ienv d) = en };902assert { ivalue cu (ienv d) = kb.u };903assert { ivalue cl (ienv d) = kb.l };904assert { ivalue low (ienv d) = Zbit.land kb.l en };905let v = Zbit.lor kb.u (Zbit.land kb.l en) in906assert { ivalue t (ienv d) = v };907assert { KnownBits.mem en kb };908let lemma b (i:int) : unit909requires { 0 <= i }910ensures { Zbit.bittest v i <-> Zbit.bittest en i }911= () in912Zbit.ext_bittest v en in913if not (same t x) then assume_equality d n t914with Unsupported -> () | Overflow -> () end915end916end917