def flatten_done
bendtorch-core@0.1.0.0 · src/tensor/matmul_PROOF.bend:681
import bendtorch-core@0.1.0.0/src/tensor/matmul_PROOF.bend as MatmulPROOF
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/storage/arith.bend as Arith
681def flatten_done(+shape: Shape.Shape, +coordinates: List<&2, U32>,
682 result: Result<&2, &2, Shape.Error, Shape.FlatIndex<shape>>,
683 +fits: Coordinates.Fits(Shape.extents(shape), Shape.naturals(coordinates)),
684 same: {result == Shape.flatten_checked(shape, coordinates) : Result<&2, &2, Shape.Error, Shape.FlatIndex<shape>>}) ->
685 {Result.is_done(&2, &2, Shape.Error, Shape.FlatIndex<shape>, result) == True{} : Bool}:
686 match result:
687 case Fail{error}:
688 Empty.absurd({False{} == True{} : Bool}, Arith.clash(Equal.cong(Maybe<&2, U32>, Bool, value => Maybe.is_some(&2, U32, value), None{},
689 Some{U32.from_nat(Shape.row_major(Shape.extents(shape), Coordinates.coordinate_of(Shape.extents(shape), Shape.naturals(coordinates), fits)))},
690 Equal.trans(Maybe<&2, U32>, None{}, ShapeLaws.index_result(shape, Shape.flatten_checked(shape, coordinates)),
691 Some{U32.from_nat(Shape.row_major(Shape.extents(shape), Coordinates.coordinate_of(Shape.extents(shape), Shape.naturals(coordinates), fits)))},
692 Equal.cong(Result<&2, &2, Shape.Error, Shape.FlatIndex<shape>>, Maybe<&2, U32>, ShapeLaws.index_result(shape),
693 Fail{error}, Shape.flatten_checked(shape, coordinates), same),
694 %Boundary.decode_fit(Shape.extents(shape), Shape.naturals(coordinates), fits) :
695 {ShapeLaws.index_result(shape, Shape.flatten_checked(shape, coordinates)) == ShapeLaws.flatten_spec(Shape.extents(shape), _) : Maybe<&2, U32>}
696 ShapeLaws.flatten_checked_refines(shape, coordinates)))))
697 case Done{index}:
698 {==}