~/bend-docscommunity

decimal-proof.bend checks

raw source on the hub · import bend-kit-bytes@0.3.3.2/decimal-proof.bend as Decimal_proof

4 imports
import Base
import bend-kit-lemmas@0.1.5.1/lemmas.bend as Lemmas
import bend-mathlib@0.8.0.0/nat.bend as MNat
import ./bytes.bend as Bytes

Definitions

def quotient source · line 6 · raw

@+n:U32 -> U32

def divide source · line 9 · raw

@f:Nat -> @n:U32 -> U32

def divide_le source · line 16 · raw

@f:Nat -> @+a:U32 -> @+b:U32 -> @h:{U32.is_le(a, b) == True{} : Bool} -> {U32.is_le(divide(f, a), divide(f, b)) == True{} : Bool}

def ones source · line 31 · raw

@n:Nat -> Word(n)

def reject_true source · line 38 · raw

@b:Bool -> Type

def false_true source · line 45 · raw

@h:{False{} == True{} : Bool} -> Empty

def cmp_max_fin source · line 49 · raw

@t:Cmp -> @b:Bool -> @h:{Cmp.is_le(t) == True{} : Bool} -> {Cmp.is_le(Word.cmp.fin(b, True{}, t)) == True{} : Bool}

def word_le_ones source · line 62 · raw

@+n:Nat -> @w:Word(n) -> {Cmp.is_le(Word.cmp(n, w, ones(n))) == True{} : Bool}

def u32_le_max source · line 71 · raw

@n:U32 -> {U32.is_le(n, 4294967295) == True{} : Bool}

def divide_zero source · line 76 · raw

@+n:U32 -> {U32.is_le(divide(10n, n), 0) == True{} : Bool}

def zero_add_bound source · line 79 · raw

@+n:Nat -> @+m:Nat -> @h:0x78e347bf8d0582a322c01b02c727566f/nat.lt(n, m) -> 0x78e347bf8d0582a322c01b02c727566f/nat.lt(Nat.add(U32.to_nat(0), n), m)

def add_zero source · line 82 · raw

@+n:U32 -> {U32.add(0, n) == n : U32}

def small_quotient source · line 85 · raw

@+n:U32 -> @h:{U32.is_lt(n, 10) == True{} : Bool} -> {quotient(n) == 0 : U32}

def digit.if source · line 90 · raw

@ok:Bool -> @n:U32 -> Maybe<&2, U32>

def digit source · line 97 · raw

@+acc:U32 -> @+d:U32 -> Maybe<&2, U32>

def read source · line 101 · raw

@xs:List<&2, U32> -> @+acc:U32 -> Maybe<&2, U32>

def eq_refl source · line 109 · raw

@+n:U32 -> {U32.is_eq(n, n) == True{} : Bool}

def digit_step source · line 112 · raw

@+acc:U32 -> @+d:U32 -> @+n:U32 -> @e:{U32.add(U32.mul(acc, 10), d) == n : U32} -> @hd:{U32.is_lt(d, 10) == True{} : Bool} -> @hq:{quotient(n) == acc : U32} -> {digit(acc, d) == Some{n} : Maybe<&2, U32>}

def digit_zero source · line 122 · raw

@+n:U32 -> @+h:{U32.is_lt(n, 10) == True{} : Bool} -> {digit(0, n) == Some{n} : Maybe<&2, U32>}

def digit_rebuild.pair source · line 125 · raw

@+n:U32 -> @p:Pair({Nat.add(Nat.mul(U32.to_nat(quotient(n)), 10n), U32.to_nat(U32.mod(n, 10))) == U32.to_nat(n) : Nat}, 0x78e347bf8d0582a322c01b02c727566f/nat.lt(U32.to_nat(U32.mod(n, 10)), 10n)) -> {digit(quotient(n), U32.mod(n, 10)) == Some{n} : Maybe<&2, U32>}

def digit_rebuild source · line 132 · raw

@+n:U32 -> {digit(quotient(n), U32.mod(n, 10)) == Some{n} : Maybe<&2, U32>}

def text source · line 135 · raw

@f:Nat -> @+n:U32 -> @+tail:List<&2, U32> -> List<&2, U32>

def read_cons source · line 142 · raw

@+d:U32 -> @+tail:List<&2, U32> -> @+acc:U32 -> @+n:U32 -> @e:{digit(acc, d) == Some{n} : Maybe<&2, U32>} -> {read(d <> tail, acc) == read(tail, n) : Maybe<&2, U32>}

def text_roundtrip source · line 147 · raw

@+f:Nat -> @+n:U32 -> @+tail:List<&2, U32> -> @h:{divide(f, n) == 0 : U32} -> {read(text(f, n, tail), 0) == read(tail, n) : Maybe<&2, U32>}

def zero_of_le source · line 155 · raw

@+n:U32 -> @h:{U32.is_le(n, 0) == True{} : Bool} -> {n == 0 : U32}

def roundtrip source · line 159 · raw

@+n:U32 -> {read(text(10n, n, []), 0) == Some{n} : Maybe<&2, U32>}

def count source · line 162 · raw

@f:Nat -> @+small:Bool -> @+n:U32 -> @+k:Nat -> Nat

def count_shift_step source · line 169 · raw

@small:Bool -> @+p:Nat -> @+n:U32 -> @+k:Nat -> @ih:{count(p, U32.is_lt(quotient(n), 10), quotient(n), 2n+k) == 1n+count(p, U32.is_lt(quotient(n), 10), quotient(n), 1n+k) : Nat} -> {count(1n+p, small, n, 1n+k) == 1n+count(1n+p, small, n, k) : Nat}

def count_shift source · line 178 · raw

@+f:Nat -> @+small:Bool -> @+n:U32 -> @+k:Nat -> {count(f, small, n, 1n+k) == 1n+count(f, small, n, k) : Nat}

def width_count_step source · line 185 · raw

@small:Bool -> @+p:Nat -> @+n:U32 -> @+k:Nat -> @ih:{0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.u32.width(p, U32.is_lt(quotient(n), 10), quotient(n), U32.from_nat(1n+k)) == U32.from_nat(count(p, U32.is_lt(quotient(n), 10), quotient(n), 1n+k)) : U32} -> {0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.u32.width(1n+p, small, n, U32.from_nat(k)) == U32.from_nat(count(1n+p, small, n, k)) : U32}

def width_count source · line 196 · raw

@+f:Nat -> @+small:Bool -> @+n:U32 -> @+k:Nat -> {0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.u32.width(f, small, n, U32.from_nat(k)) == U32.from_nat(count(f, small, n, k)) : U32}

def count_correct_step source · line 203 · raw

@small:Bool -> @+p:Nat -> @+n:U32 -> @+es:{small == U32.is_lt(n, 10) : Bool} -> @ih:{divide(count(p, U32.is_lt(quotient(n), 10), quotient(n), 1n), quotient(n)) == 0 : U32} -> {divide(count(1n+p, U32.is_lt(n, 10), n, 1n), n) == 0 : U32}

def count_correct source · line 216 · raw

@+f:Nat -> @+n:U32 -> @h:{divide(f, n) == 0 : U32} -> {divide(count(f, U32.is_lt(n, 10), n, 1n), n) == 0 : U32}

def count_bound_step source · line 224 · raw

@small:Bool -> @+p:Nat -> @+n:U32 -> @+k:Nat -> @ih:0x78e347bf8d0582a322c01b02c727566f/nat.le(count(p, U32.is_lt(quotient(n), 10), quotient(n), 1n+k), Nat.add(1n+k, p)) -> 0x78e347bf8d0582a322c01b02c727566f/nat.le(count(1n+p, small, n, k), Nat.add(k, 1n+p))

def count_bound source · line 235 · raw

@+f:Nat -> @+small:Bool -> @+n:U32 -> @+k:Nat -> 0x78e347bf8d0582a322c01b02c727566f/nat.le(count(f, small, n, k), Nat.add(k, f))

def eleven_bound source · line 243 · raw

@+m:Nat -> @h:0x78e347bf8d0582a322c01b02c727566f/nat.lt(U32.to_nat(11), m) -> 0x78e347bf8d0582a322c01b02c727566f/nat.lt(11n, m)

def width_value source · line 246 · raw

@+n:U32 -> {U32.to_nat(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.u32.width(10n, U32.is_lt(n, 10), n, 1)) == count(10n, U32.is_lt(n, 10), n, 1n) : Nat}

def width_correct source · line 252 · raw

@+n:U32 -> {divide(U32.to_nat(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.u32.width(10n, U32.is_lt(n, 10), n, 1)), n) == 0 : U32}

def width_roundtrip source · line 256 · raw

@+n:U32 -> {read(text(U32.to_nat(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.u32.width(10n, U32.is_lt(n, 10), n, 1)), n, []), 0) == Some{n} : Maybe<&2, U32>}

def text_append source · line 259 · raw

@+f:Nat -> @+n:U32 -> @+left:List<&2, U32> -> @+right:List<&2, U32> -> {text(f, n, List.append(&2, U32, left, right)) == List.append(&2, U32, text(f, n, left), right) : List<&2, U32>}

def text_tail source · line 267 · raw

@+f:Nat -> @+n:U32 -> @+tail:List<&2, U32> -> {text(f, n, tail) == List.append(&2, U32, text(f, n, []), tail) : List<&2, U32>}

def text_snoc source · line 271 · raw

@+p:Nat -> @+n:U32 -> {text(1n+p, n, []) == List.append(&2, U32, text(p, quotient(n), []), [U32.mod(n, 10)]) : List<&2, U32>}