Bounds.carry_limbs: def of bend-collections-laws-crypto@1.0.0.0 Import: import bend-collections-laws-crypto@1.0.0.0/proofs/crypto/secp256k1/bounds.bend as Bounds Lines 52-70 of bend-collections-laws-crypto@1.0.0.0/proofs/crypto/secp256k1/bounds.bend: https://jend.leeeet.dev/read.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/secp256k1/bounds.bend&start_line=52&end_line=70 import Base import bend-collections-laws-crypto@1.0.0.0/spec/lib/common.bend as C import bend-collections-laws-crypto@1.0.0.0/spec/crypto/secp256k1/field.bend as FS import bend-collections-laws-crypto@1.0.0.0/src/crypto/secp256k1/limbs.bend as L import bend-collections-laws-crypto@1.0.0.0/proofs/lib/logic.bend as Lg # the first j <= n limbs of a carry pass: exactly j limbs below 2^16 def carry_limbs(+one: Nat, +h1: {one == 1n : Nat}, n: Nat, j: Nat, xs: List<&2, Nat>, +u: Nat, +hj: {Nat.is_le(j, n) == True{} : Bool}) -> {FS.limbs16(one, j, L.take(j, L.carry(n, xs, u))) == True{} : Bool}: match n j xs: case 0n 0n Nil{}: {==} case 0n 0n x <> t: {==} case 0n 1n+i _: Empty.absurd({FS.limbs16(one, 1n+i, L.take(1n+i, L.carry(0n, xs, u))) == True{} : Bool}, Lg.false_true(hj)) case 1n+k 0n Nil{}: {==} case 1n+k 0n x <> t: {==} case 1n+ +k 1n+ +i Nil{}: +s = Nat.add(u, 0n) Lg.and_intro(Nat.is_lt(L.lo16(s), C.shift(16n, one)), FS.limbs16(one, i, L.take(i, L.carry(k, [], L.hi16(s)))), lo16_lt(one, h1, s), carry_limbs(one, h1, k, i, [], L.hi16(s), hj)) case 1n+ +k 1n+ +i +x <> +t: +s = Nat.add(u, x) Lg.and_intro(Nat.is_lt(L.lo16(s), C.shift(16n, one)), FS.limbs16(one, i, L.take(i, L.carry(k, t, L.hi16(s)))), lo16_lt(one, h1, s), carry_limbs(one, h1, k, i, t, L.hi16(s), hj)) 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=Empty.absurd https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List 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_le https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.is_lt https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/crypto/secp256k1/bounds.bend&name=lo16_lt https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/lib/logic.bend&name=and_intro https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/proofs/lib/logic.bend&name=false_true https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/spec/crypto/secp256k1/field.bend&name=limbs16 https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/spec/lib/common.bend&name=shift https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/src/crypto/secp256k1/limbs.bend&name=carry https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/src/crypto/secp256k1/limbs.bend&name=hi16 https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/src/crypto/secp256k1/limbs.bend&name=lo16 https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/src/crypto/secp256k1/limbs.bend&name=take