def cmul_rel

bend-collections-laws-math@1.0.0.0 · proofs/math/typed/u32int.bend:306

import bend-collections-laws-math@1.0.0.0/proofs/math/typed/u32int.bend as U32int
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/src/math/generic.bend as G
import bend-collections-laws-math@1.0.0.0/src/math/num.bend as NM
import bend-collections-laws-math@1.0.0.0/src/math/instances.bend as I
import bend-collections-laws-math@1.0.0.0/proofs/math/typed/u32laws.bend as LW

306def cmul_rel(+q: U32, +x: U32, +n: Nat, +hn: {Nat.mul(v(q), v(x)) == n : Nat}, +c: Bool, +hc: {C.fits(32n, n) == c : Bool}) -> {G.cmul(~U32, ~I.u32_op, ~I.u32_is, q, x) == G.fits(U32, Bool.not(c), of(n)) : Maybe<&2, U32>}:
307  match c:
308    case True{}:
309      +hmo = mo_of(q, x, n, hn, True{}, hc)
310      %Equal.sym(Bool, I.u32_is(NM.MulOver{q, x}), False{}, hmo) : {G.fits(U32, _, I.u32_op(NM.Mul{q, x})) == Some{of(n)} : Maybe<&2, U32>}
311      Equal.cong(U32, Maybe<&2, U32>, t => Some{t}, I.u32_op(NM.Mul{q, x}), of(n), as_of(I.u32_op(NM.Mul{q, x}), n, Equal.trans(Nat, v(I.u32_op(NM.Mul{q, x})), Nat.mul(v(q), v(x)), n, LW.ops_mul(q, x, hmo), hn)))
312    case False{}:
313      %Equal.sym(Bool, I.u32_is(NM.MulOver{q, x}), True{}, mo_of(q, x, n, hn, False{}, hc)) : {G.fits(U32, _, I.u32_op(NM.Mul{q, x})) == None{} : Maybe<&2, U32>}
314      {==}

Uses (21)

Used by (1)