def owned_preserved
bendtorch-core@0.1.0.0 · src/tensor/reduction_PROOF.bend:458
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/lifecycle.bend as Lifecycle
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
import bendtorch-core@0.1.0.0/src/storage/main.bend as Storage
import bendtorch-core@0.1.0.0/src/storage/model.bend as Model
458def owned_preserved(-shape: Shape.Shape, +depth: Nat, +length: Nat, -original: Array<F32>, -balanced: Model.Balanced(F32, depth, original),
459 -valid: {Storage.bounds(depth, length) == True{} : Bool},
460 -exact: {length == Shape.logical_numel(Shape.dimensions(shape)) : Nat},
461 pair: F32 & Array<F32>, -kept: Reduction.Fact<{Pair.snd(F32, Array<F32>, pair) == original : Array<F32>}>) ->
462 Fact<Laws.Preserved<shape, Core.TTensor{Storage.Owned{depth, length, original, balanced, valid}, exact},
463 Reduction.owned_sum(shape, depth, length, original, balanced, valid, exact, pair, kept)>>:
464 (value, retained) = pair
465 Fact{Laws.Preserved{other => Equal.cong(Array<F32>, Maybe<&2, F32>,
466 a => Lifecycle.observe_allowed(depth, length, a, other, Nat.is_lt(U32.to_nat(other), length)), retained, original,
467 {\{Reduction.Fact: p => p} : Reduction.Fact<({Pair.snd(F32, Array<F32>, (value, retained)) == original : Array<F32>})> -> {retained == original : Array<F32>}}(kept))}}