def project_right_index

bendtorch-core@0.1.0.0 · src/shape/boundary_proofs.bend:278

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

278def project_right_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.right_shape(plan), Flat.project_right_index(plan, map, index))} == Laws.flatten_spec(Shape.extents(Shape.right_shape(plan)), Laws.project_right_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>}:
279  match map index:
280    case Shape.Indexed{+rows, +exact} Shape.FIndex{+value, +bound}:
281      +left = Shape.extents(Shape.left_shape(plan))
282      +right = Shape.extents(Shape.right_shape(plan))
283      +output = Shape.extents(Shape.output_shape(plan))
284      +fits = Coordinates.size_fits(Shape.output_shape(plan), value, bound)
285      +flat = Coordinates.fin_from(Shape.numel(output), value, fits)
286      +table = Shape.index_table(left, right, output)
287      +projected = Shape.row_major(Shape.extents(Shape.right_shape(plan)), Shape.project_right(left, right, output, Shape.alignment(plan), Shape.unflatten(output, flat)))
288      %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_right(rows, value))} == Laws.flatten_spec(Shape.extents(Shape.right_shape(plan)), Laws.project_right_coordinate(left, right, output, Shape.alignment(plan), _)) : Maybe<&2, U32>}
289      %Equal.sym(List<&2, Shape.Row>, rows, table, exact) : {Some{U32.from_nat(Shape.walk_right(_, value))} == Some{U32.from_nat(projected)} : Maybe<&2, U32>}
290      %Coordinates.fin_from_value(Shape.numel(output), value, fits) : {Some{U32.from_nat(Shape.walk_right(table, _))} == Some{U32.from_nat(projected)} : Maybe<&2, U32>}
291      Equal.cong(Nat, Maybe<&2, U32>, flat => Some{U32.from_nat(flat)}, Shape.walk_right(table, Shape.Fin.value(Shape.numel(output), flat)), projected, Projection.walk_right_value(left, right, output, Shape.alignment(plan), flat))
292    case Shape.Unindexed{zero} Shape.FIndex{+value, bound}:
293      +left = Shape.extents(Shape.left_shape(plan))
294      +right = Shape.extents(Shape.right_shape(plan))
295      +output = Shape.extents(Shape.output_shape(plan))
296      Empty.absurd({Some{Shape.index_value(Shape.right_shape(plan), Flat.project_right_index(plan, Shape.Unindexed{zero}, Shape.FIndex{value, bound}))} == Laws.flatten_spec(Shape.extents(Shape.right_shape(plan)), Laws.project_right_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))

Uses (37)

Used by (1)