def prefix_extend

bendtorch-core@0.1.0.0 · src/tensor/core_PROOF.bend:799

import bendtorch-core@0.1.0.0/src/tensor/core_PROOF.bend as CorePROOF
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/elementwise.bend as Elementwise

799def prefix_extend(+operation: Elementwise.Operation, +plan: Shape.BroadcastPlan,
800  -original_left: Core.Dynamic, -original_right: Core.Dynamic, +cursor: Nat, +index: U32,
801  -before: Core.Tensor<Shape.output_shape(plan)>, -after: Core.Tensor<Shape.output_shape(plan)>,
802  -converted: {U32.to_nat(index) == cursor : Nat},
803  -prefix: Elementwise.PrefixInvariant(operation, plan, original_left, original_right, cursor, Core.Packed{Shape.output_shape(plan), before}),
804  -checked: Core.ObservationChecked(Core.Packed{Shape.output_shape(plan), after}, index),
805  -observed: {Core.observe(Shape.output_shape(plan), after, index) == Elementwise.expected(operation, plan, original_left, original_right, index) : Maybe<&2, F32>},
806  -frame: @+other: U32 -> @checked: Core.ObservationChecked(Core.Packed{Shape.output_shape(plan), before}, other) ->
807    @different: {Nat.is_eq(U32.to_nat(index), U32.to_nat(other)) == False{} : Bool} ->
808      Core.ObservationChecked(Core.Packed{Shape.output_shape(plan), after}, other) &
809        {Core.observe(Shape.output_shape(plan), after, other) == Core.observe(Shape.output_shape(plan), before, other) : Maybe<&2, F32>}) ->
810  PrefixModel<operation, plan, original_left, original_right, 1n+cursor, after>:
811  PrefixModel{other => bound =>
812    {\{Inl: earlier => prefix_previous(operation, plan, original_left, original_right, cursor, index, before, after, converted, prefix, frame, other, earlier);
813      Inr: equal => prefix_equal(operation, plan, original_left, original_right, cursor, index, after, converted, checked, observed, other, equal)} :
814      Either<Shape.LT(U32.to_nat(other), cursor), {U32.to_nat(other) == cursor : Nat}> ->
815        (Core.ObservationChecked(Core.Packed{Shape.output_shape(plan), after}, other) &
816          {Core.observe(Shape.output_shape(plan), after, other) == Elementwise.expected(operation, plan, original_left, original_right, other) : Maybe<&2, F32>})}(lt_previous_or_equal(U32.to_nat(other), cursor, bound))}

Uses (23)

Used by (1)