def rem_v
bend-collections-laws-math@1.0.0.0 · proofs/math/typed/f64modf.bend:26
import bend-collections-laws-math@1.0.0.0/proofs/math/typed/f64modf.bend as F64modf
import Base
import bend-collections-laws-math@1.0.0.0/spec/lib/common.bend as C
import bend-collections-laws-math@1.0.0.0/spec/math/w64.bend as SW
import bend-collections-laws-math@1.0.0.0/src/math/w64.bend as X
import bend-collections-laws-math@1.0.0.0/src/math/u64.bend as WU
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/proofs/lib/lemmas/proofs/nat_algebra.bend as NA
import bend-collections-laws-math@1.0.0.0/proofs/math/typed/width.bend as WW
import bend-collections-laws-math@1.0.0.0/proofs/math/typed/w64add.bend as WA
import bend-collections-laws-math@1.0.0.0/proofs/math/typed/w64sh.bend as SH
import bend-collections-laws-math@1.0.0.0/proofs/math/typed/f64light.bend as FL
import bend-collections-laws-math@1.0.0.0/proofs/math/typed/f64round.bend as FR
26
27def rem_v(+w: WU.U64, +k: Nat, +hb: {Nat.is_lt(k, 64n) == True{} : Bool}) -> {SW.value(X.sub(w, X.shl(X.shr(w, k), k))) == C.low(k, SW.value(w)) : Nat}:
28 +V = SW.value(w)
29 +q = X.shr(w, k)
30 +sq = X.shl(q, k)
31 +Hq = C.high(k, V)
32 +Lq = C.low(k, V)
33 +S = C.shift(k, Hq)
34 +hSV0 = L.subst(Nat, t => {Nat.is_le(S, t) == True{} : Bool}, Nat.add(S, Lq), Nat.add(Lq, S), NA.add_comm(S, Lq), N.le_add_right(S, Lq))
35 +hSV = L.subst(Nat, t => {Nat.is_le(S, t) == True{} : Bool}, Nat.add(Lq, S), V, Equal.sym(Nat, V, Nat.add(Lq, S), WW.low_high(k, V)), hSV0)
36 +hSf = SH.fits_lek(64n, S, V, hSV, FL.vb64(w))
37 +esl = Equal.trans(Nat, SW.value(sq), C.low(64n, S), S, Equal.trans(Nat, SW.value(sq), C.low(64n, C.shift(k, SW.value(q))), C.low(64n, S), SH.shl_value(q, k, hb), Equal.cong(Nat, Nat, t => C.low(64n, C.shift(k, t)), SW.value(q), Hq, SH.shr_value(w, k))), WW.low_fit(64n, S, hSf))
38 +hle = L.subst(Nat, t => {Nat.is_le(t, V) == True{} : Bool}, S, SW.value(sq), Equal.sym(Nat, SW.value(sq), S, esl), hSV)
39 +er1 = Equal.cong(Nat, Nat, t => Nat.sub(V, t), SW.value(sq), S, esl)
40 +er2 = Equal.cong(Nat, Nat, t => Nat.sub(t, S), V, Nat.add(Lq, S), WW.low_high(k, V))
41 Equal.trans(Nat, SW.value(X.sub(w, sq)), Nat.sub(V, SW.value(sq)), Lq, WA.sub_value(w, sq, hle), Equal.trans(Nat, Nat.sub(V, SW.value(sq)), Nat.sub(V, S), Lq, er1, Equal.trans(Nat, Nat.sub(V, S), Nat.sub(Nat.add(Lq, S), S), Lq, er2, FR.sub_add_l(Lq, S))))