def checked_projection
bendtorch-core@0.1.0.0 · src/tensor/projection_PROOF.bend:34
import bendtorch-core@0.1.0.0/src/tensor/projection_PROOF.bend as ProjectionPROOF
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/shape/LAWS.bend as ShapeLaws
import bendtorch-core@0.1.0.0/src/shape/boundary_proofs.bend as Boundary
import bendtorch-core@0.1.0.0/src/shape/coordinate_proofs.bend as Coordinates
import bendtorch-core@0.1.0.0/src/tensor/elementwise.bend as Elementwise
import bendtorch-core@0.1.0.0/src/tensor/projection_LAWS.bend as Laws
34def checked_projection(+plan: Shape.BroadcastPlan, +position: Nat,
35 decision: Shape.BoolCase<Nat.is_lt(position, Shape.elements(Shape.output_shape(plan)))>) ->
36 {Laws.indices_result(Elementwise.flat_input_indices(plan,
37 Shape.flat_checked.finish(Shape.output_shape(plan), position, decision))) ==
38 Laws.offset_spec(plan, position) : Maybe<&1, U32 & U32>}:
39 match decision:
40 case Shape.BFalse{equal}:
41 %Boundary.fin_of_none(Shape.numel(Shape.extents(Shape.output_shape(plan))), position,
42 Coordinates.size_misses(Shape.output_shape(plan), position, equal)) :
43 {None{} == Laws.pair_offsets(
44 ShapeLaws.flatten_spec(Shape.extents(Shape.left_shape(plan)), ShapeLaws.project_left_coordinate(
45 Shape.extents(Shape.left_shape(plan)), Shape.extents(Shape.right_shape(plan)),
46 Shape.extents(Shape.output_shape(plan)), Shape.alignment(plan), _)),
47 ShapeLaws.flatten_spec(Shape.extents(Shape.right_shape(plan)), ShapeLaws.project_right_coordinate(
48 Shape.extents(Shape.left_shape(plan)), Shape.extents(Shape.right_shape(plan)),
49 Shape.extents(Shape.output_shape(plan)), Shape.alignment(plan), _))) : Maybe<&1, U32 & U32>}
50 {==}
51 case Shape.BTrue{equal}:
52 Laws.actual_flat_projection(plan, Shape.FIndex{position, equal})