PROOF.un.borrow: def of bend-osdev-u32@0.1.0.0 Import: import bend-osdev-u32@0.1.0.0/PROOF.bend as PROOF Lines 624-636 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=624&end_line=636 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 + B = A + 2^n * C with s < 2^n: C is whether A < B def un.borrow(c: Bool, +n: Nat, +s: Nat, +a: Nat, +b: Nat, e: {Nat.add(s, b) == Nat.add(a, U.U32Nat.dbl(n, U.U32Nat.bit(c))) : Nat}, hs: {Nat.is_lt(s, U.U32Nat.dbl(n, 1n)) == True{} : Bool}) -> {Nat.is_lt(a, b) == c : Bool}: match c: case True{}: +k = U.U32Nat.dbl(n, 1n) +h1 = Equal.trans(Bool, Nat.is_lt(Nat.add(s, b), Nat.add(k, b)), Nat.is_lt(s, k), True{}, un.lt_add_r(s, k, b), hs) +h2 = un.lt_rw(Nat.add(s, b), Nat.add(a, k), Nat.add(k, b), e, h1) +h3 = un.lt_rw2(Nat.add(a, k), Nat.add(k, b), Nat.add(b, k), un.add_comm(k, b), h2) Equal.trans(Bool, Nat.is_lt(a, b), Nat.is_lt(Nat.add(a, k), Nat.add(b, k)), True{}, Equal.sym(Bool, Nat.is_lt(Nat.add(a, k), Nat.add(b, k)), Nat.is_lt(a, b), un.lt_add_r(a, b, k)), h3) case False{}: +ea = Equal.trans(Nat, Nat.add(s, b), Nat.add(a, U.U32Nat.dbl(n, 0n)), a, e, Equal.trans(Nat, Nat.add(a, U.U32Nat.dbl(n, 0n)), Nat.add(a, 0n), a, Equal.cong(Nat, Nat, v => Nat.add(a, v), U.U32Nat.dbl(n, 0n), 0n, Laws.dbl_zero(n)), un.add_zero(a))) %ea : {Nat.is_lt(_, b) == False{} : Bool} un.not_lt_add_l(s, b) Uses (16): 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_comm 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_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.lt_rw2 https://jend.leeeet.dev/definition.txt?path=bend-osdev-u32@0.1.0.0/PROOF.bend&name=un.not_lt_add_l 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