~/bend-docscommunity

proofs/u32_full_range.bend checks

raw source on the hub · import stelliferous@0.0.3.0/proofs/u32_full_range.bend as U32_full_range

Exact conversions over the complete U32 range. Tensor stride-zero extents may exceed the physical array capacity, so storage-capacity bounds are insufficient.

7 imports
import Base
import ./nat_order.bend as Order
import ./u32_successor.bend as U32Successor
import ./nat_to_u32_bounds.bend as Bounds
import ./word_encoding.bend as WordEncoding
import ./bounded_u32_arithmetic.bend as Arithmetic
import ./word_multiplication.bend as Multiplication

Definitions

def ones source · line 11 · raw

@width:Nat -> Word(width)

def equal_low_less source · line 16 · raw

@+comparison:Cmp -> {Cmp.is_lt(Word.cmp.fin(True{}, True{}, comparison)) == Cmp.is_lt(comparison) : Bool}

def finish_bounded source · line 22 · raw

@+bit:Bool -> @+comparison:Cmp -> @ordered:{Cmp.is_le(comparison) == True{} : Bool} -> {Cmp.is_le(Word.cmp.fin(bit, True{}, comparison)) == True{} : Bool}

def bounded source · line 32 · raw

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

def increment source · line 39 · raw

@+width:Nat -> @+word:Word(width) -> @below:{Cmp.is_lt(Word.cmp(width, word, ones(width))) == True{} : Bool} -> {Word.to_nat(width, Word.inc(width, word)) == 1n+Word.to_nat(width, word) : Nat}

def maximum source · line 53 · raw

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

def successor source · line 57 · raw

@+value:U32 -> @below:{U32.is_lt(value, 4294967295) == True{} : Bool} -> {U32.to_nat(U32.add(value, 1)) == 1n+U32.to_nat(value) : Nat}

def roundtrip source · line 64 · raw

@+value:Nat -> @+capacity:U32 -> @inside:{Nat.is_le(value, U32.to_nat(capacity)) == True{} : Bool} -> {U32.to_nat(U32.from_nat(value)) == value : Nat}

def add source · line 76 · raw

@+left:U32 -> @+right:U32 -> @+capacity:U32 -> @inside:{Nat.is_le(Nat.add(U32.to_nat(left), U32.to_nat(right)), U32.to_nat(capacity)) == True{} : Bool} -> {U32.to_nat(U32.add(left, right)) == Nat.add(U32.to_nat(left), U32.to_nat(right)) : Nat}

def subtract source · line 83 · raw

@+left:U32 -> @+right:U32 -> @+capacity:U32 -> @ordered:{Nat.is_le(U32.to_nat(right), U32.to_nat(left)) == True{} : Bool} -> @inside:{Nat.is_le(Nat.sub(U32.to_nat(left), U32.to_nat(right)), U32.to_nat(capacity)) == True{} : Bool} -> {U32.to_nat(U32.sub(left, right)) == Nat.sub(U32.to_nat(left), U32.to_nat(right)) : Nat}

def multiply source · line 91 · raw

@+left:U32 -> @+right:U32 -> @+capacity:U32 -> @inside:{Nat.is_le(Nat.mul(U32.to_nat(left), U32.to_nat(right)), U32.to_nat(capacity)) == True{} : Bool} -> {U32.to_nat(U32.mul(left, right)) == Nat.mul(U32.to_nat(left), U32.to_nat(right)) : Nat}

def interval_inside source · line 99 · raw

@+low:U32 -> @+high:U32 -> @+position:U32 -> @+lower:{U32.is_le(low, position) == True{} : Bool} -> @+upper:{U32.is_lt(position, high) == True{} : Bool} -> {Nat.is_lt(U32.to_nat(U32.sub(position, low)), U32.to_nat(U32.sub(high, low))) == True{} : Bool}

Subtracting a common interval origin preserves its strict upper bound.