def complete_fill
bendtorch-core@0.1.0.0 · src/tensor/construction_PROOF.bend:326
import bendtorch-core@0.1.0.0/src/tensor/construction_PROOF.bend as ConstructionPROOF
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/construction_LAWS.bend as Laws
326def complete_fill(-shape: Shape.Shape, +values: List<&2, F32>, -original: Core.Tensor<shape>,
327 result: Result<&2, &1, Core.Error, Core.Tensor<shape>>,
328 -count: {Shape.logical_numel(Shape.dimensions(shape)) == List.length(&2, F32, values) : Nat},
329 -fill: FillMeaning(shape, original, values, 0n, result)) -> ElementsOutcome<shape, values, result>:
330 match result:
331 case Fail{error}:
332 ElementsOutcome{Unit{}}
333 case Done{tensor}:
334 ElementsOutcome{index => inside =>
335 {\{Tuple: mapping => frame =>
336 {\{Tuple: checked => observed =>
337 {\{ElementPoint: meaning => meaning} : ElementPoint<shape, values, tensor, index> ->
338 (Core.ObservationChecked(Core.Packed{shape, tensor}, index) &
339 ({Core.checked_observe(shape, tensor, index) == Laws.list_element(values, U32.to_nat(index)) : Maybe<&2, F32>} &
340 {Core.observe(shape, tensor, index) == Laws.list_element(values, U32.to_nat(index)) : Maybe<&2, F32>}))}(element_point(shape, values, tensor, index, checked, observed))
341 } :
342 (Core.ObservationChecked(Core.Packed{shape, tensor}, index) &
343 {Core.checked_observe(shape, tensor, index) == Laws.list_element(values, U32.to_nat(index)) : Maybe<&2, F32>}) ->
344 (Core.ObservationChecked(Core.Packed{shape, tensor}, index) &
345 ({Core.checked_observe(shape, tensor, index) == Laws.list_element(values, U32.to_nat(index)) : Maybe<&2, F32>} &
346 {Core.observe(shape, tensor, index) == Laws.list_element(values, U32.to_nat(index)) : Maybe<&2, F32>}))}(mapping(index)(U32.to_nat(index))({==})(
347 %count : Shape.LT(U32.to_nat(index), _)
348 inside))
349 } : (FillElements(shape, values, 0n, tensor) & FillFrame(shape, original, 0n, tensor)) ->
350 (Core.ObservationChecked(Core.Packed{shape, tensor}, index) &
351 ({Core.checked_observe(shape, tensor, index) == Laws.list_element(values, U32.to_nat(index)) : Maybe<&2, F32>} &
352 {Core.observe(shape, tensor, index) == Laws.list_element(values, U32.to_nat(index)) : Maybe<&2, F32>}))}(fill)}