proofs/row_major_index.bend checks
raw source on the hub · import stelliferous@0.0.3.0/proofs/row_major_index.bend as Row_major_index
Mixed-radix NCHW indexing and its required bounds, on unbounded Nat.
7 imports
import Base import ./nat_order.bend as Order import ./nat_to_u32_bounds.bend as Bounds import ./natural_addition.bend as Addition import ./nat_division.bend as Division import ./word_encoding.bend as WordEncoding import ./boolean_logic.bend as Boolean
Laws
law in_bounds provedsource · line 169 · raw
@+input_channel_index:Nat -> @+input_channel_count:Nat -> @+height:Nat -> @+width:Nat -> @+iy:Nat -> @+ix:Nat -> @channel:{Nat.is_lt(input_channel_index, input_channel_count) == True{} : Bool} -> @row:{Nat.is_lt(iy, height) == True{} : Bool} -> @col:{Nat.is_lt(ix, width) == True{} : Bool} -> {Nat.is_lt(index(input_channel_index, height, width, iy, ix), Nat.mul(input_channel_count, Nat.mul(height, width))) == True{} : Bool}
Definitions
def multiply_zero_right source · line 10 · raw
@+value:Nat -> {Nat.mul(value, 0n) == 0n : Nat}
def add_swap source · line 15 · raw
@+a:Nat -> @+b:Nat -> @+tail:Nat -> {Nat.add(a, Nat.add(b, tail)) == Nat.add(b, Nat.add(a, tail)) : Nat}
def multiply_successor_right source · line 21 · raw
@+a:Nat -> @+b:Nat -> {Nat.mul(a, 1n+b) == Nat.add(a, Nat.mul(a, b)) : Nat}
def multiply_commutative source · line 29 · raw
@+a:Nat -> @+b:Nat -> {Nat.mul(a, b) == Nat.mul(b, a) : Nat}
def subtract_common_prefix source · line 36 · raw
@+prefix:Nat -> @+a:Nat -> @+b:Nat -> {Nat.sub(Nat.add(prefix, a), Nat.add(prefix, b)) == Nat.sub(a, b) : Nat}
def subtract_products source · line 41 · raw
@+a:Nat -> @+b:Nat -> @+factor:Nat -> {Nat.sub(Nat.mul(a, factor), Nat.mul(b, factor)) == Nat.mul(Nat.sub(a, b), factor) : Nat}
def left_factor_positive source · line 54 · raw
@+left:Nat -> @+right:Nat -> @positive:{Nat.is_lt(0n, Nat.mul(left, right)) == True{} : Bool} -> {Nat.is_lt(0n, left) == True{} : Bool}
def distrib source · line 59 · raw
@+a:Nat -> @+b:Nat -> @+c:Nat -> {Nat.mul(Nat.add(a, b), c) == Nat.add(Nat.mul(a, c), Nat.mul(b, c)) : Nat}
def assoc source · line 69 · raw
@+a:Nat -> @+b:Nat -> @+c:Nat -> {Nat.mul(Nat.mul(a, b), c) == Nat.mul(a, Nat.mul(b, c)) : Nat}
def right_distrib source · line 79 · raw
@+factor:Nat -> @+left:Nat -> @+right:Nat -> {Nat.mul(factor, Nat.add(left, right)) == Nat.add(Nat.mul(factor, left), Nat.mul(factor, right)) : Nat}
def mul_le source · line 87 · raw
@+a:Nat -> @+b:Nat -> @+c:Nat -> @h:{Nat.is_le(a, b) == True{} : Bool} -> {Nat.is_le(Nat.mul(a, c), Nat.mul(b, c)) == True{} : Bool}
def radix source · line 100 · raw
@+a:Nat -> @+limit:Nat -> @+b:Nat -> @+width:Nat -> @ab:{Nat.is_lt(a, limit) == True{} : Bool} -> @bw:{Nat.is_lt(b, width) == True{} : Bool} -> {Nat.is_lt(Nat.add(Nat.mul(a, width), b), Nat.mul(limit, width)) == True{} : Bool}
def cancel_multiply_lt source · line 107 · raw
@+left:Nat -> @+right:Nat -> @+factor:Nat -> @ordered:{Nat.is_lt(Nat.mul(left, factor), Nat.mul(right, factor)) == True{} : Bool} -> {Nat.is_lt(left, right) == True{} : Bool}
def row_inside source · line 118 · raw
@+row:Nat -> @+rows:Nat -> @+width:Nat -> @+column:Nat -> @inside:{Nat.is_lt(Nat.add(Nat.mul(row, width), column), Nat.mul(rows, width)) == True{} : Bool} -> {Nat.is_lt(row, rows) == True{} : Bool}
def multiply_lt source · line 122 · raw
@+left:Nat -> @+right:Nat -> @+factor:Nat -> @ordered:{Nat.is_lt(left, right) == True{} : Bool} -> @positive:{Nat.is_lt(0n, factor) == True{} : Bool} -> {Nat.is_lt(Nat.mul(left, factor), Nat.mul(right, factor)) == True{} : Bool}
def cancel_multiply_le source · line 127 · raw
@+left:Nat -> @+right:Nat -> @+factor:Nat -> @+positive:{Nat.is_lt(0n, factor) == True{} : Bool} -> @ordered:{Nat.is_le(Nat.mul(left, factor), Nat.mul(right, factor)) == True{} : Bool} -> {Nat.is_le(left, right) == True{} : Bool}
def same_remainder_le source · line 138 · raw
@+left:Nat -> @+right:Nat -> @+factor:Nat -> @+remainder:Nat -> @+positive:{Nat.is_lt(0n, factor) == True{} : Bool} -> {Nat.is_le(Nat.add(Nat.mul(left, factor), remainder), Nat.add(Nat.mul(right, factor), remainder)) == Nat.is_le(left, right) : Bool}
def same_remainder_lt source · line 146 · raw
@+left:Nat -> @+right:Nat -> @+factor:Nat -> @+remainder:Nat -> @+positive:{Nat.is_lt(0n, factor) == True{} : Bool} -> {Nat.is_lt(Nat.add(Nat.mul(left, factor), remainder), Nat.add(Nat.mul(right, factor), remainder)) == Nat.is_lt(left, right) : Bool}
def index source · line 154 · raw
@+input_channel_index:Nat -> @+height:Nat -> @+width:Nat -> @+iy:Nat -> @+ix:Nat -> Nat
def expanded source · line 157 · raw
@+input_channel_index:Nat -> @+height:Nat -> @+width:Nat -> @+iy:Nat -> @+ix:Nat -> {Nat.add(Nat.add(Nat.mul(Nat.mul(input_channel_index, height), width), Nat.mul(iy, width)), ix) == index(input_channel_index, height, width, iy, ix) : Nat}
def mixed source · line 163 · raw
@+input_channel_index:Nat -> @+height:Nat -> @+width:Nat -> @+iy:Nat -> @+ix:Nat -> {Nat.add(Nat.mul(Nat.add(Nat.mul(input_channel_index, height), iy), width), ix) == index(input_channel_index, height, width, iy, ix) : Nat}
def product_covers source · line 185 · raw
@+a:Nat -> @+b:Nat -> @positive:{Nat.is_lt(0n, b) == True{} : Bool} -> {Nat.is_le(a, Nat.mul(a, b)) == True{} : Bool}
def row_product source · line 198 · raw
@+input_channel_index:Nat -> @+input_channel_count:Nat -> @+height:Nat -> @+width:Nat -> @+cap:Nat -> @channel:{Nat.is_lt(input_channel_index, input_channel_count) == True{} : Bool} -> @positive:{Nat.is_lt(0n, width) == True{} : Bool} -> @bound:{Nat.is_le(Nat.mul(input_channel_count, Nat.mul(height, width)), cap) == True{} : Bool} -> {Nat.is_le(Nat.mul(input_channel_index, height), cap) == True{} : Bool}