def step_right_certificate
bendtorch-core@0.1.0.0 · src/tensor/core_PROOF.bend:549
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
549def step_right_certificate(+operation: Elementwise.Operation, +plan: Shape.BroadcastPlan, +index: U32,
550 -original_left: Core.Dynamic, -original_right: Core.Dynamic,
551 +left_index: U32, +right_index: U32, +left_value: F32,
552 -indices_exact: {Done{(left_index, right_index)} == Elementwise.input_indices(plan, index) : Result<&2, &1, Core.Error, U32 & U32>},
553 certificate: Core.DynamicRead<original_right, right_index>,
554 original_output: Core.Tensor<Shape.output_shape(plan)>,
555 left: Core.Dynamic,
556 -left_exact: {(left, Done{left_value}) == Core.read_dynamic(original_left, left_index) : Core.Dynamic & Result<&2, &2, Core.Error, F32>},
557 lift: @-result: Elementwise.Step<Shape.output_shape(plan)> ->
558 {result == Elementwise.step_right(operation, Shape.output_shape(plan), index, left, original_output, left_value,
559 Core.read_dynamic(original_right, right_index)) : Elementwise.Step<Shape.output_shape(plan)>} ->
560 {result == Elementwise.step(operation, plan, index, Elementwise.State{original_left, original_right, original_output}) : Elementwise.Step<Shape.output_shape(plan)>}) ->
561 Elementwise.StepCertificate<operation, plan, index, Elementwise.State{original_left, original_right, original_output}>:
562 Core.DynamicRead{right, result, exact} = certificate
563 match result:
564 case Fail{error}:
565 Elementwise.StepCertificate{Elementwise.Stop{left, right, error},
566 lift(Elementwise.Stop{left, right, error}, Equal.cong(Core.Dynamic & Result<&2, &2, Core.Error, F32>, Elementwise.Step<Shape.output_shape(plan)>,
567 pair => Elementwise.step_right(operation, Shape.output_shape(plan), index, left, original_output, left_value, pair),
568 (right, Fail{error}), Core.read_dynamic(original_right, right_index), exact)), Unit{}}
569 case Done{+right_value}:
570 step_write_certificate(operation, plan, index, original_left, original_right, original_output,
571 left_index, right_index, left_value, right_value, indices_exact,
572 Core.write_certificate(Shape.output_shape(plan), original_output, index, Elementwise.scalar(operation, left_value, right_value)), left, right, left_exact, exact,
573 result => equality => lift(result,
574 Equal.trans(Elementwise.Step<Shape.output_shape(plan)>, result,
575 Elementwise.step_right(operation, Shape.output_shape(plan), index, left, original_output, left_value, (right, Done{right_value})),
576 Elementwise.step_right(operation, Shape.output_shape(plan), index, left, original_output, left_value, Core.read_dynamic(original_right, right_index)), equality,
577 Equal.cong(Core.Dynamic & Result<&2, &2, Core.Error, F32>, Elementwise.Step<Shape.output_shape(plan)>,
578 pair => Elementwise.step_right(operation, Shape.output_shape(plan), index, left, original_output, left_value, pair),
579 (right, Done{right_value}), Core.read_dynamic(original_right, right_index), exact))))