1 import Base 2 import ../../../spec/lib/common.bend as C 3 import ../../../src/math/u64.bend as W 4 import ../../../src/math/w64.bend as X 5 import ../../../spec/math/random.bend as SRM 6 import ./uint64n.bend as UN 7 import ./bounded.bend as BD 8 import ./wrappers.bend as WR 9 10 # Entry point: `bend proofs/math/random/proof_draws.bend` checks the bounded and 11 # fixed-width draw clauses (Uint64n, Uint32, Int64, Int32, Uint32n, Intn, 12 # IntRange) of spec/math/random.bend, under the clause's name, for every input 13 # (and every source, relation and element type where the clause is a 14 # template). No holes, no axioms. The other clauses are checked by 15 # proofs/math/random/proof.bend, proofs/math/random/proof_pcg.bend, 16 # proofs/math/random/proof_float.bend, so each root only re-checks the lemma 17 # files it needs. 18 19 def Uint64n.value(~S: Data, ~next: S -> W.U64 & S, +s: S, +n: W.U64) -> SRM.Uint64n.value(~S, ~next, s, n): 20 UN.uint64n_value(~S, ~next, s, n) 21 22 def Uint64n.lt(~S: Data, ~next: S -> W.U64 & S, +s: S, +n: W.U64, +hn: {X.is_zero(n) == False{} : Bool}) -> SRM.Uint64n.lt(~S, ~next, s, n, hn): 23 BD.uint64n_lt(~S, ~next, s, n, hn) 24 25 def Uint32.value(~S: Data, ~next: S -> W.U64 & S, +s: S) -> SRM.Uint32.value(~S, ~next, s): 26 WR.uint32_value(~S, ~next, s) 27 28 def Int64.value(~S: Data, ~next: S -> W.U64 & S, +s: S) -> SRM.Int64.value(~S, ~next, s): 29 WR.int64_value(~S, ~next, s) 30 31 def Int32.value(~S: Data, ~next: S -> W.U64 & S, +s: S) -> SRM.Int32.value(~S, ~next, s): 32 WR.int32_value(~S, ~next, s) 33 34 def Uint32n.lt(~S: Data, ~next: S -> W.U64 & S, +s: S, +n: U32, +hn: {U32.is_zero(n) == False{} : Bool}) -> SRM.Uint32n.lt(~S, ~next, s, n, hn): 35 WR.uint32n_lt(~S, ~next, s, n, hn) 36 37 def Intn.lt(~S: Data, ~next: S -> W.U64 & S, +s: S, +n: Nat, +hn: {Nat.is_lt(0n, n) == True{} : Bool}, +hw: {C.fits(64n, n) == True{} : Bool}) -> SRM.Intn.lt(~S, ~next, s, n, hn, hw): 38 WR.intn_lt(~S, ~next, s, n, hn, hw) 39 40 def IntRange.bounds(~S: Data, ~next: S -> W.U64 & S, +s: S, +lo: Nat, +hi: Nat, +h: {Nat.is_lt(lo, hi) == True{} : Bool}, +hw: {C.fits(64n, Nat.sub(hi, lo)) == True{} : Bool}) -> SRM.IntRange.bounds(~S, ~next, s, lo, hi, h, hw): 41 WR.int_range_bounds(~S, ~next, s, lo, hi, h, hw)