def project_left_index
bendtorch-core@0.1.0.0 · src/shape/boundary_proofs.bend:258
import bendtorch-core@0.1.0.0/src/shape/boundary_proofs.bend as BoundaryProofs
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/shape/coordinate_proofs.bend as Coordinates
import bendtorch-core@0.1.0.0/src/shape/projection_proofs.bend as Projection
import bendtorch-core@0.1.0.0/src/shape/flat.bend as Flat
import bendtorch-core@0.1.0.0/src/shape/LAWS.bend as Laws
258def project_left_index(+plan: Shape.BroadcastPlan, +map: Shape.Index<Shape.extents(Shape.left_shape(plan)), Shape.extents(Shape.right_shape(plan)), Shape.extents(Shape.output_shape(plan))>, +index: Shape.FlatIndex<Shape.output_shape(plan)>) -> {Some{Shape.index_value(Shape.left_shape(plan), Flat.project_left_index(plan, map, index))} == Laws.flatten_spec(Shape.extents(Shape.left_shape(plan)), Laws.project_left_coordinate(Shape.extents(Shape.left_shape(plan)), Shape.extents(Shape.right_shape(plan)), Shape.extents(Shape.output_shape(plan)), Shape.alignment(plan), Laws.fin_of(Shape.numel(Shape.extents(Shape.output_shape(plan))), Laws.position(Shape.output_shape(plan), index)))) : Maybe<&2, U32>}:
259 match map index:
260 case Shape.Indexed{+rows, +exact} Shape.FIndex{+value, +bound}:
261 +left = Shape.extents(Shape.left_shape(plan))
262 +right = Shape.extents(Shape.right_shape(plan))
263 +output = Shape.extents(Shape.output_shape(plan))
264 +fits = Coordinates.size_fits(Shape.output_shape(plan), value, bound)
265 +flat = Coordinates.fin_from(Shape.numel(output), value, fits)
266 +table = Shape.index_table(left, right, output)
267 +projected = Shape.row_major(Shape.extents(Shape.left_shape(plan)), Shape.project_left(left, right, output, Shape.alignment(plan), Shape.unflatten(output, flat)))
268 %Equal.sym(Maybe<&2, Shape.Fin(Shape.numel(output))>, Laws.fin_of(Shape.numel(output), value), Some{flat}, fin_of_from(Shape.numel(output), value, fits)) : {Some{U32.from_nat(Shape.walk_left(rows, value))} == Laws.flatten_spec(Shape.extents(Shape.left_shape(plan)), Laws.project_left_coordinate(left, right, output, Shape.alignment(plan), _)) : Maybe<&2, U32>}
269 %Equal.sym(List<&2, Shape.Row>, rows, table, exact) : {Some{U32.from_nat(Shape.walk_left(_, value))} == Some{U32.from_nat(projected)} : Maybe<&2, U32>}
270 %Coordinates.fin_from_value(Shape.numel(output), value, fits) : {Some{U32.from_nat(Shape.walk_left(table, _))} == Some{U32.from_nat(projected)} : Maybe<&2, U32>}
271 Equal.cong(Nat, Maybe<&2, U32>, flat => Some{U32.from_nat(flat)}, Shape.walk_left(table, Shape.Fin.value(Shape.numel(output), flat)), projected, Projection.walk_left_value(left, right, output, Shape.alignment(plan), flat))
272 case Shape.Unindexed{zero} Shape.FIndex{+value, bound}:
273 +left = Shape.extents(Shape.left_shape(plan))
274 +right = Shape.extents(Shape.right_shape(plan))
275 +output = Shape.extents(Shape.output_shape(plan))
276 Empty.absurd({Some{Shape.index_value(Shape.left_shape(plan), Flat.project_left_index(plan, Shape.Unindexed{zero}, Shape.FIndex{value, bound}))} == Laws.flatten_spec(Shape.extents(Shape.left_shape(plan)), Laws.project_left_coordinate(left, right, output, Shape.alignment(plan), Laws.fin_of(Shape.numel(output), value))) : Maybe<&2, U32>}, Flat.hollow(Shape.output_shape(plan), value, zero, bound))