def below

bendtorch-core@0.1.0.0 · src/tensor/contracts/matmul_parallel_proof.bend:293

import bendtorch-core@0.1.0.0/src/tensor/contracts/matmul_parallel_proof.bend as MatmulParallelProof
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/storage/model.bend as Model
import bendtorch-core@0.1.0.0/src/storage/LAWS.bend as StorageLaws
import bendtorch-core@0.1.0.0/src/shape/index_proofs.bend as Index
import bendtorch-core@0.1.0.0/src/storage/api.bend as Api

293# A subtree whose positions all lie below k is the same for k and 1 + k.
294def below(+span: Nat, +columns: Nat, +left: Shape.Shape, +left_fill: F32, +left_ops: List<&2, StorageLaws.Op>, +right: Shape.Shape, +right_fill: F32, +right_ops: List<&2, StorageLaws.Op>, +k: Nat, +depth: Nat, +b: Nat, +h: {Nat.is_le(Nat.add(Model.capacity(depth), b), k) == True{} : Bool}) ->
295  {out_spec(span, columns, left, left_fill, left_ops, right, right_fill, right_ops, k, depth, b) == out_spec(span, columns, left, left_fill, left_ops, right, right_fill, right_ops, 1n+k, depth, b) : Array<F32>}:
296  match depth:
297    case 0n:
298      +lower = below_true(b, k, h)
299      %Equal.sym(Bool, Nat.is_lt(b, k), True{}, lower) :
300        {ALeaf{out_leaf(span, columns, left, left_fill, left_ops, right, right_fill, right_ops, b, _)} == ALeaf{out_leaf(span, columns, left, left_fill, left_ops, right, right_fill, right_ops, b, Nat.is_lt(b, 1n+k))} : Array<F32>}
301      %Equal.sym(Bool, Nat.is_lt(b, 1n+k), True{}, lt_succ_right(b, k, lower)) :
302        {ALeaf{cell_word(span, columns, left, left_fill, left_ops, right, right_fill, right_ops, b)} == ALeaf{out_leaf(span, columns, left, left_fill, left_ops, right, right_fill, right_ops, b, _)} : Array<F32>}
303      {==}
304    case 1n+inner:
305      +c = Model.capacity(inner)
306      +high = Nat.add(c, b)
307      +nested = Equal.trans(Bool, Nat.is_le(Nat.add(c, high), k), Nat.is_le(Nat.add(Nat.add(c, c), b), k), True{},
308        Equal.cong(Nat, Bool, x => Nat.is_le(x, k), Nat.add(c, high), Nat.add(Nat.add(c, c), b), Index.add_assoc(c, c, b)), h)
309      +low_h = le_trans(high, Nat.add(c, high), k, le_add_cong(c, b, high, Api.le_add_left(c, b)), nested)
310      %Equal.sym(Array<F32>, out_spec(span, columns, left, left_fill, left_ops, right, right_fill, right_ops, k, inner, b), out_spec(span, columns, left, left_fill, left_ops, right, right_fill, right_ops, 1n+k, inner, b), below(span, columns, left, left_fill, left_ops, right, right_fill, right_ops, k, inner, b, low_h)) :
311        {ANode{_, out_spec(span, columns, left, left_fill, left_ops, right, right_fill, right_ops, k, inner, high)} == out_spec(span, columns, left, left_fill, left_ops, right, right_fill, right_ops, 1n+k, 1n+inner, b) : Array<F32>}
312      %Equal.sym(Array<F32>, out_spec(span, columns, left, left_fill, left_ops, right, right_fill, right_ops, k, inner, high), out_spec(span, columns, left, left_fill, left_ops, right, right_fill, right_ops, 1n+k, inner, high), below(span, columns, left, left_fill, left_ops, right, right_fill, right_ops, k, inner, high, nested)) :
313        {ANode{out_spec(span, columns, left, left_fill, left_ops, right, right_fill, right_ops, 1n+k, inner, b), _} == out_spec(span, columns, left, left_fill, left_ops, right, right_fill, right_ops, 1n+k, 1n+inner, b) : Array<F32>}
314      {==}

Uses (23)

Used by (1)