def bounded
bendtorch-core@0.1.0.0 · src/tensor/axis_algebra.bend:121
import bendtorch-core@0.1.0.0/src/tensor/axis_algebra.bend as AxisAlgebra
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/storage/arith.bend as Arith
import bendtorch-core@0.1.0.0/src/tensor/layout.bend as Layout
import bendtorch-core@0.1.0.0/src/tensor/axis_spec.bend as Axis
121def bounded(+axes: List<&2, U32>, +rank: U32) -> {Layout.bounded(axes, rank) == Axis.bounded(Shape.naturals(axes), U32.to_nat(rank)) : Bool}:
122 match axes:
123 case Nil{}:
124 {==}
125 case +head <> +tail:
126 %Arith.u32_lt(head, rank) : {Bool.and(_, Layout.bounded(tail, rank)) == Axis.bounded(Shape.naturals(head <> tail), U32.to_nat(rank)) : Bool}
127 %Equal.sym(Bool, Layout.bounded(tail, rank), Axis.bounded(Shape.naturals(tail), U32.to_nat(rank)), bounded(tail, rank)) :
128 {Bool.and(Nat.is_lt(U32.to_nat(head), U32.to_nat(rank)), _) == Axis.bounded(Shape.naturals(head <> tail), U32.to_nat(rank)) : Bool}
129 {==}