def lt_go

bend-collections-laws-math@1.0.0.0 · proofs/math/natural/bits.bend:70

import bend-collections-laws-math@1.0.0.0/proofs/math/natural/bits.bend as Bits
import Base
import bend-collections-laws-math@1.0.0.0/proofs/lib/nat.bend as N
import bend-collections-laws-math@1.0.0.0/proofs/lib/logic.bend as L
import bend-collections-laws-math@1.0.0.0/spec/lib/common.bend as SC
import bend-collections-laws-math@1.0.0.0/src/math/natural.bend as M

70def lt_go(fuel: Nat, +n: Nat, +hf: {Nat.is_le(n, fuel) == True{} : Bool}) -> {Nat.is_lt(n, SC.pow2(M.bit_length_go(fuel, n, 0n))) == True{} : Bool}:
71  match fuel n:
72    case 0n 0n:
73      {==}
74    case 0n 1n+np:
75      Empty.absurd({Nat.is_lt(1n+np, SC.pow2(M.bit_length_go(0n, 1n+np, 0n))) == True{} : Bool}, L.false_true(hf))
76    case 1n+f 0n:
77      {==}
78    case 1n+ +f 1n+ +np:
79      +h = Nat.div(1n+np, 2n)
80      +x = M.bit_length_go(f, h, 0n)
81      +ih = lt_go(f, h, half_fuel(np, f, hf))
82      %Equal.sym(Nat, M.bit_length_go(f, h, 1n), 1n+x, go_acc(f, h, 0n)) : {Nat.is_lt(1n+np, SC.pow2(_)) == True{} : Bool}
83      N.lt_le_trans(1n+np, Nat.double(1n+h), Nat.double(SC.pow2(x)), half_bound(np), N.double_le(1n+h, SC.pow2(x), N.lt_succ_le_succ(h, SC.pow2(x), ih)))

Uses (17)

Used by (1)