def cells_length

bendtorch-core@0.1.0.0 · src/autograd/broadcast_pointwise_PROOF.bend:38

import bendtorch-core@0.1.0.0/src/autograd/broadcast_pointwise_PROOF.bend as BroadcastPointwisePROOF
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/storage/LAWS.bend as StorageLaws
import bendtorch-core@0.1.0.0/src/tensor/contracts/replayed.bend as Replayed
import bendtorch-core@0.1.0.0/src/tensor/contracts/broadcast.bend as PointwiseBroadcast
import bendtorch-core@0.1.0.0/src/autograd/reduce_fold_PROOF.bend as FoldProof
import bendtorch-core@0.1.0.0/src/autograd/broadcast_pointwise_LAWS.bend as Laws

38def cells_length(+plan: Shape.BroadcastPlan, +shape: Shape.Shape, +fill: F32, +ops: List<&2, StorageLaws.Op>, +count: Nat) ->
39  {List.length(&2, F32, Laws.cells(plan, shape, fill, ops, count)) == count : Nat}:
40  match count:
41    case 0n:
42      {==}
43    case 1n+previous:
44      +before = Laws.cells(plan, shape, fill, ops, previous)
45      +last = Replayed.value(shape, fill, ops, U32.from_nat(PointwiseBroadcast.left_map(plan, previous)))
46      Equal.trans(Nat, List.length(&2, F32, List.append(&2, F32, before, [last])), 1n+List.length(&2, F32, before), 1n+previous,
47        FoldProof.length_snoc(before, last),
48        Equal.cong(Nat, Nat, n => 1n+n, List.length(&2, F32, before), previous, cells_length(plan, shape, fill, ops, previous)))

Uses (15)

Used by (1)