def right_walk_bound
bendtorch-core@0.1.0.0 · src/tensor/contracts/broadcast_proof.bend:39
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
39def right_walk_bound(+plan: Shape.BroadcastPlan,
40 map: Shape.Index<Shape.extents(Shape.left_shape(plan)), Shape.extents(Shape.right_shape(plan)), Shape.extents(Shape.output_shape(plan))>,
41 +index: Nat, below: {Nat.is_lt(index, Shape.logical_numel(Shape.dimensions(Shape.output_shape(plan)))) == True{} : Bool}) ->
42 {Nat.is_lt(Broadcast.right_walk(Shape.extents(Shape.left_shape(plan)), Shape.extents(Shape.right_shape(plan)), Shape.extents(Shape.output_shape(plan)), map, index),
43 Shape.logical_numel(Shape.dimensions(Shape.right_shape(plan)))) == True{} : Bool}:
44 match map:
45 case Shape.Indexed{rows, exact}:
46 Equal.sym(Bool, True{}, Nat.is_lt(Shape.walk_right(rows, index), Shape.logical_numel(Shape.dimensions(Shape.right_shape(plan)))),
47 %Shape.elements_exact(Shape.right_shape(plan)) : {True{} == Nat.is_lt(Shape.walk_right(rows, index), _) : Bool}
48 Flat.right_bound(plan, rows, exact, index, output_inside(plan, index, below)))
49 case Shape.Unindexed{zero}:
50 Empty.absurd({Nat.is_lt(0n, Shape.logical_numel(Shape.dimensions(Shape.right_shape(plan)))) == True{} : Bool},
51 Arith.lt_zero(index,
52 %Equal.sym(Nat, 0n, Shape.numel(Shape.extents(Shape.output_shape(plan))), zero) : {Nat.is_lt(index, _) == True{} : Bool}
53 below))