def write_inv
bendtorch-core@0.1.0.0 · src/autograd/gradient_PROOF.bend:348
import bendtorch-core@0.1.0.0/src/autograd/gradient_PROOF.bend as GradientPROOF
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/autograd/gradient.bend as Gradient
348def write_inv(+shape: Shape.Shape, -original: Core.Tensor<shape>, -contribution: Core.Dynamic, +cursor: Nat,
349 -before: Core.Tensor<shape>, -read_owner: Core.Tensor<shape>, +index: U32, +accumulated: F32, +value: F32,
350 owner: Core.Dynamic, pair: Core.Tensor<shape> & Result<&2, &2, Core.Error, Unit>,
351 -exact: {U32.to_nat(index) == cursor : Nat},
352 -meaning: Core.CheckedUpdateMeaning(shape, read_owner, index, F32.add(accumulated, value), pair),
353 -inv: Inv(shape, original, contribution, cursor, before),
354 -read: {Core.checked_observe(shape, before, index) == Some{accumulated} : Maybe<&2, F32>},
355 -kept: @+position: U32 -> {Core.checked_observe(shape, read_owner, position) == Core.checked_observe(shape, before, position) : Maybe<&2, F32>},
356 -word: {Core.checked_observe_dynamic(contribution, index) == Some{value} : Maybe<&2, F32>}) ->
357 Holds<StepInv(shape, original, contribution, cursor, Gradient.step_write(shape, owner, pair))>:
358 (written, result) = pair
359 match result:
360 case Fail{error}:
361 Holds{Unit{}}
362 case Done{unit}:
363 Holds{other => inside => {\{Holds: proof => proof} :
364 Holds<{Core.checked_observe(shape, written, other) ==
365 partial(Nat.is_lt(U32.to_nat(other), 1n+cursor), Core.checked_observe(shape, original, other), Core.checked_observe_dynamic(contribution, other)) : Maybe<&2, F32>}> ->
366 {Core.checked_observe(shape, written, other) ==
367 partial(Nat.is_lt(U32.to_nat(other), 1n+cursor), Core.checked_observe(shape, original, other), Core.checked_observe_dynamic(contribution, other)) : Maybe<&2, F32>}}(
368 position_inv(shape, original, contribution, cursor, before, read_owner, written, index, accumulated, value, unit,
369 other, Shape.bool_case(Nat.is_eq(U32.to_nat(index), U32.to_nat(other))), inside, exact, meaning, inv, read, kept, word))}