def read_interpretation
bendtorch-core@0.1.0.0 · src/tensor/reduction_PROOF.bend:66
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/reduction_LAWS.bend as Laws
66def read_interpretation(+fuel: Nat, -shape: Shape.Shape, -original: Core.Tensor<shape>, +cursor: Nat, +accumulator: F32,
67 +head: F32, +values: List<&2, F32>, tensor: Core.Tensor<shape>, result: Result<&2, &2, Core.Error, F32>,
68 rec: @tensor: Core.Tensor<shape> -> @logical: Laws.LogicalValues(fuel, shape, tensor, 1n+cursor, values) ->
69 {Laws.loop_value(shape, Reduction.natural_sum_loop(fuel, shape, tensor, 1n+cursor, F32.add(accumulator, head))) ==
70 Some{Reduction.sequential_sum(values, F32.add(accumulator, head))} : Maybe<&2, F32>},
71 remaining: Laws.LogicalValues(fuel, shape, original, 1n+cursor, values),
72 meaning: {Core.result_value(result) == Some{head} : Maybe<&2, F32>},
73 -kept: @+other: U32 -> {Core.checked_observe(shape, tensor, other) == Core.checked_observe(shape, original, other) : Maybe<&2, F32>}) ->
74 {Laws.loop_value(shape, Reduction.read_step(shape,
75 tensor => value => Reduction.natural_sum_loop(fuel, shape, tensor, 1n+cursor, value), accumulator, (tensor, result))) ==
76 Some{Reduction.sequential_sum(head <> values, accumulator)} : Maybe<&2, F32>}:
77 match result:
78 case Fail{error}:
79 Empty.absurd({None{} == Some{Reduction.sequential_sum(head <> values, accumulator)} : Maybe<&2, F32>}, no_value(head, meaning))
80 case Done{+value}:
81 %Equal.sym(F32, value, head, some_injective(value, head, meaning)) :
82 {Laws.loop_value(shape, Reduction.natural_sum_loop(fuel, shape, tensor, 1n+cursor, F32.add(accumulator, _))) ==
83 Some{Reduction.sequential_sum(values, F32.add(accumulator, head))} : Maybe<&2, F32>}
84 %rec(tensor, logical_keeps(fuel, shape, original, tensor, 1n+cursor, values, remaining, kept)) :
85 {Laws.loop_value(shape, Reduction.natural_sum_loop(fuel, shape, tensor, 1n+cursor, F32.add(accumulator, head))) == _ : Maybe<&2, F32>}
86 {==}