def unflatten_done
bendtorch-core@0.1.0.0 · src/tensor/matmul_PROOF.bend:913
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/tensor/transform_PROOF.bend as TransformProof
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
913def unflatten_done(+shape: Shape.Shape, +index: U32, result: Result<&2, &2, Shape.Error, Shape.CheckedCoordinate<shape>>,
914 same: {result == Shape.unflatten_checked(shape, index) : Result<&2, &2, Shape.Error, Shape.CheckedCoordinate<shape>>},
915 +inside: {True{} == Nat.is_lt(U32.to_nat(index), Shape.elements(shape)) : Bool}) ->
916 {Result.is_done(&2, &2, Shape.Error, Shape.CheckedCoordinate<shape>, result) == True{} : Bool}:
917 match result:
918 case Fail{error}:
919 Empty.absurd({False{} == True{} : Bool}, Arith.clash(Equal.cong(Maybe<&2, List<&2, U32>>, Bool, value => Maybe.is_some(&2, List<&2, U32>, value), None{},
920 Some{Shape.words(Shape.indices(Shape.extents(shape), TransformProof.decoded_coordinate(shape, index, inside)))},
921 Equal.trans(Maybe<&2, List<&2, U32>>, None{}, ShapeLaws.coordinate_result(shape, Shape.unflatten_checked(shape, index)),
922 Some{Shape.words(Shape.indices(Shape.extents(shape), TransformProof.decoded_coordinate(shape, index, inside)))},
923 Equal.cong(Result<&2, &2, Shape.Error, Shape.CheckedCoordinate<shape>>, Maybe<&2, List<&2, U32>>, ShapeLaws.coordinate_result(shape), Fail{error}, Shape.unflatten_checked(shape, index), same),
924 %Boundary.fin_of_from(Shape.numel(Shape.extents(shape)), U32.to_nat(index), Coordinates.size_fits(shape, U32.to_nat(index), inside)) :
925 {ShapeLaws.coordinate_result(shape, Shape.unflatten_checked(shape, index)) == ShapeLaws.unflatten_spec(Shape.extents(shape), _) : Maybe<&2, List<&2, U32>>}
926 ShapeLaws.unflatten_checked_refines(shape, index)))))
927 case Done{coordinate}:
928 {==}