PROOF.un.carry: def of bend-osdev-u32@0.1.0.0 Import: import bend-osdev-u32@0.1.0.0/PROOF.bend as PROOF Lines 611-622 of bend-osdev-u32@0.1.0.0/PROOF.bend: https://jend.leeeet.dev/read.txt?path=bend-osdev-u32@0.1.0.0/PROOF.bend&start_line=611&end_line=622 import Base import bend-osdev-u32@0.1.0.0/u32.bend as U import bend-osdev-u32@0.1.0.0/LAWS.bend as Laws # s + 2^n * C = A + B with B < 2^n: C is whether s < A def un.carry(c: Bool, +n: Nat, +s: Nat, +a: Nat, +b: Nat, e: {Nat.add(s, U.U32Nat.dbl(n, U.U32Nat.bit(c))) == Nat.add(a, b) : Nat}, hb: {Nat.is_lt(b, U.U32Nat.dbl(n, 1n)) == True{} : Bool}) -> {Nat.is_lt(s, a) == c : Bool}: match c: case True{}: +k = U.U32Nat.dbl(n, 1n) +h1 = Equal.trans(Bool, Nat.is_lt(Nat.add(a, b), Nat.add(a, k)), Nat.is_lt(b, k), True{}, un.lt_add_l(a, b, k), hb) +h2 = un.lt_rw(Nat.add(a, b), Nat.add(s, k), Nat.add(a, k), Equal.sym(Nat, Nat.add(s, k), Nat.add(a, b), e), h1) Equal.trans(Bool, Nat.is_lt(s, a), Nat.is_lt(Nat.add(s, k), Nat.add(a, k)), True{}, Equal.sym(Bool, Nat.is_lt(Nat.add(s, k), Nat.add(a, k)), Nat.is_lt(s, a), un.lt_add_r(s, a, k)), h2) case False{}: +es = Equal.trans(Nat, s, Nat.add(s, 0n), Nat.add(a, b), Equal.sym(Nat, Nat.add(s, 0n), s, un.add_zero(s)), Equal.trans(Nat, Nat.add(s, 0n), Nat.add(s, U.U32Nat.dbl(n, 0n)), Nat.add(a, b), Equal.cong(Nat, Nat, v => Nat.add(s, v), 0n, U.U32Nat.dbl(n, 0n), Equal.sym(Nat, U.U32Nat.dbl(n, 0n), 0n, Laws.dbl_zero(n))), e)) %Equal.sym(Nat, s, Nat.add(a, b), es) : {Nat.is_lt(_, a) == False{} : Bool} un.not_lt_add(a, b) Uses (15): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Equal.cong https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Equal.sym https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Equal.trans https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.is_lt https://jend.leeeet.dev/definition.txt?path=bend-osdev-u32@0.1.0.0/LAWS.bend&name=dbl_zero https://jend.leeeet.dev/definition.txt?path=bend-osdev-u32@0.1.0.0/PROOF.bend&name=un.add_zero https://jend.leeeet.dev/definition.txt?path=bend-osdev-u32@0.1.0.0/PROOF.bend&name=un.lt_add_l https://jend.leeeet.dev/definition.txt?path=bend-osdev-u32@0.1.0.0/PROOF.bend&name=un.lt_add_r https://jend.leeeet.dev/definition.txt?path=bend-osdev-u32@0.1.0.0/PROOF.bend&name=un.lt_rw https://jend.leeeet.dev/definition.txt?path=bend-osdev-u32@0.1.0.0/PROOF.bend&name=un.not_lt_add https://jend.leeeet.dev/definition.txt?path=bend-osdev-u32@0.1.0.0/u32.bend&name=U32Nat.bit https://jend.leeeet.dev/definition.txt?path=bend-osdev-u32@0.1.0.0/u32.bend&name=U32Nat.dbl