def left_walk_bound
bendtorch-core@0.1.0.0 · src/tensor/contracts/broadcast_proof.bend:23
import bendtorch-core@0.1.0.0/src/tensor/contracts/broadcast_proof.bend as BroadcastProof
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/shape/flat.bend as Flat
import bendtorch-core@0.1.0.0/src/storage/arith.bend as Arith
import bendtorch-core@0.1.0.0/src/tensor/contracts/broadcast.bend as Broadcast
23def left_walk_bound(+plan: Shape.BroadcastPlan,
24 map: Shape.Index<Shape.extents(Shape.left_shape(plan)), Shape.extents(Shape.right_shape(plan)), Shape.extents(Shape.output_shape(plan))>,
25 +index: Nat, below: {Nat.is_lt(index, Shape.logical_numel(Shape.dimensions(Shape.output_shape(plan)))) == True{} : Bool}) ->
26 {Nat.is_lt(Broadcast.left_walk(Shape.extents(Shape.left_shape(plan)), Shape.extents(Shape.right_shape(plan)), Shape.extents(Shape.output_shape(plan)), map, index),
27 Shape.logical_numel(Shape.dimensions(Shape.left_shape(plan)))) == True{} : Bool}:
28 match map:
29 case Shape.Indexed{rows, exact}:
30 Equal.sym(Bool, True{}, Nat.is_lt(Shape.walk_left(rows, index), Shape.logical_numel(Shape.dimensions(Shape.left_shape(plan)))),
31 %Shape.elements_exact(Shape.left_shape(plan)) : {True{} == Nat.is_lt(Shape.walk_left(rows, index), _) : Bool}
32 Flat.left_bound(plan, rows, exact, index, output_inside(plan, index, below)))
33 case Shape.Unindexed{zero}:
34 Empty.absurd({Nat.is_lt(0n, Shape.logical_numel(Shape.dimensions(Shape.left_shape(plan)))) == True{} : Bool},
35 Arith.lt_zero(index,
36 %Equal.sym(Nat, 0n, Shape.numel(Shape.extents(Shape.output_shape(plan))), zero) : {Nat.is_lt(index, _) == True{} : Bool}
37 below))