def pal

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

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/spec/math/generic.bend as SG
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

316def pal(+xs: List<&2, U32>, +r: Maybe<&2, U32>, +n: Nat, +c: Bool, +hr: {r == G.fits(U32, Bool.not(c), of(n)) : Maybe<&2, U32>}, +hc: {C.fits(32n, n) == c : Bool}) -> {G.ok(U32, G.prod_go(~U32, ~I.u32_op, ~I.u32_is, xs, r)) == SG.prefix_fin(~U32, ~SG.u32_of, SG.prod_go(32n, vals(xs), n, c)) : Result<&2, &2, NM.NumError, U32>}:
317  match xs c:
318    case Nil{} True{}:
319      %Equal.sym(Maybe<&2, U32>, r, Some{of(n)}, hr) : {G.ok(U32, _) == Done{of(n)} : Result<&2, &2, NM.NumError, U32>}
320      {==}
321    case Nil{} False{}:
322      %Equal.sym(Maybe<&2, U32>, r, None{}, hr) : {G.ok(U32, _) == Fail{NM.Overflow{}} : Result<&2, &2, NM.NumError, U32>}
323      {==}
324    case Con{x, t} False{}:
325      %Equal.sym(Maybe<&2, U32>, r, None{}, hr) : {G.ok(U32, G.prod_go(~U32, ~I.u32_op, ~I.u32_is, Con{x, t}, _)) == Fail{NM.Overflow{}} : Result<&2, &2, NM.NumError, U32>}
326      {==}
327    case Con{+x, +t} True{}:
328      %Equal.sym(Maybe<&2, U32>, r, Some{of(n)}, hr) : {G.ok(U32, G.prod_go(~U32, ~I.u32_op, ~I.u32_is, Con{x, t}, _)) == SG.prefix_fin(~U32, ~SG.u32_of, SG.prod_go(32n, vals(t), Nat.mul(n, v(x)), C.fits(32n, Nat.mul(n, v(x))))) : Result<&2, &2, NM.NumError, U32>}
329      +hn = Equal.cong(Nat, Nat, z => Nat.mul(z, v(x)), v(of(n)), n, LW.vo(n, hc))
330      pal(t, G.cmul(~U32, ~I.u32_op, ~I.u32_is, of(n), x), Nat.mul(n, v(x)), C.fits(32n, Nat.mul(n, v(x))), cmul_rel(of(n), x, Nat.mul(n, v(x)), hn, C.fits(32n, Nat.mul(n, v(x))), {==}), {==})

Uses (26)

Used by (1)