def sum_loop_status
bendtorch-core@0.1.0.0 · src/tensor/reduction_PROOF.bend:790
import bendtorch-core@0.1.0.0/src/tensor/reduction_PROOF.bend as ReductionPROOF
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/reduction.bend as Reduction
import bendtorch-core@0.1.0.0/src/tensor/math_totality.bend as Totality
import bendtorch-core@0.1.0.0/src/storage/arith.bend as Arith
790def sum_loop_status(fuel: Nat, +shape: Shape.Shape, tensor: Core.Tensor<shape>, +cursor: Nat, +accumulator: F32,
791 -bound: Shape.LE(Nat.add(fuel, cursor), Shape.elements(shape))) ->
792 Totality.Status<Core.Error, Core.Tensor<shape> & F32, Reduction.natural_sum_loop(fuel, shape, tensor, cursor, accumulator)>:
793 match fuel:
794 case 0n:
795 Totality.Status{{==}}
796 case 1n+tail:
797 sum_decision_status(tail, shape, cursor, accumulator,
798 Shape.bool_case(Nat.is_eq(U32.to_nat(U32.from_nat(cursor)), cursor)),
799 tensor,
800 cursor_exact(tail, shape, cursor, bound),
801 %Equal.sym(Nat, U32.to_nat(U32.from_nat(cursor)), cursor, cursor_exact(tail, shape, cursor, bound)) : {Nat.is_lt(_, Shape.logical_numel(Shape.dimensions(shape))) == True{} : Bool}
802 %Shape.elements_exact(shape) : {Nat.is_lt(cursor, _) == True{} : Bool}
803 cursor_bounds(tail, cursor, Shape.elements(shape), bound),
804 tensor => value => sum_loop_status(tail, shape, tensor, 1n+cursor, value,
805 %Equal.sym(Nat, Nat.add(tail, 1n+cursor), 1n+Nat.add(tail, cursor), Arith.add_succ(tail, cursor)) : Shape.LE(_, Shape.elements(shape))
806 bound))