def fill_elements_advance

bendtorch-core@0.1.0.0 · src/tensor/construction_PROOF.bend:242

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/storage/arith.bend as Arith
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

242def fill_elements_advance(-shape: Shape.Shape, +value: F32, +rest: List<&2, F32>, +cursor: Nat,
243  -written: Core.Tensor<shape>, -tensor: Core.Tensor<shape>,
244  point: @+index: U32 -> @at: {U32.to_nat(index) == cursor : Nat} ->
245    Core.ObservationChecked(Core.Packed{shape, written}, index) &
246      {Core.checked_observe(shape, written, index) == Some{value} : Maybe<&2, F32>},
247  mapping: FillElements(shape, rest, 1n+cursor, tensor), frame: FillFrame(shape, written, 1n+cursor, tensor),
248  +index: U32, +offset: Nat, at: {U32.to_nat(index) == Nat.add(cursor, offset) : Nat},
249  inside: Shape.LT(offset, List.length(&2, F32, value <> rest))) ->
250  Core.ObservationChecked(Core.Packed{shape, tensor}, index) &
251    {Core.checked_observe(shape, tensor, index) == Laws.list_element(value <> rest, offset) : Maybe<&2, F32>}:
252  match offset:
253    case 0n:
254      fill_head(shape, written, tensor, cursor, value, point, frame, index,
255        Equal.trans(Nat, U32.to_nat(index), Nat.add(cursor, 0n), cursor, at, add_zero_right(cursor)))
256    case 1n+p:
257      mapping(index)(p)(Equal.trans(Nat, U32.to_nat(index), Nat.add(cursor, 1n+p), Nat.add(1n+cursor, p), at, Arith.add_succ(cursor, p)))(inside)

Uses (22)

Used by (1)