def digits_unflatten
bendtorch-core@0.1.0.0 · src/shape/coordinate_proofs.bend:103
import bendtorch-core@0.1.0.0/src/shape/coordinate_proofs.bend as CoordinateProofs
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/shape/index_proofs.bend as Index
103def digits_unflatten(+dims: List<&2, Nat>, +index: Shape.Fin(Shape.numel(dims))) -> {Shape.indices(dims, Shape.unflatten(dims, index)) == Shape.digits(dims, Shape.Fin.value(Shape.numel(dims), index)) : List<&2, Nat>}:
104 match dims:
105 case Nil{}:
106 match index:
107 case Shape.FZero{}:
108 {==}
109 case Shape.FNext{previous}:
110 match previous:
111 case +head <> +tail:
112 %Index.pack_unpack(head, Shape.numel(tail), index) : {Shape.indices(head <> tail, Shape.unflatten(head <> tail, index)) == Shape.digits(head <> tail, Shape.Fin.value(Shape.numel(head <> tail), _)) : List<&2, Nat>}
113 digits_step(head, tail, +index => digits_unflatten(tail, index), Shape.Fin.unpack(head, Shape.numel(tail), index))