def cursor_index_bounded

bendtorch-core@0.1.0.0 · src/tensor/permutation_mapping.bend:735

import bendtorch-core@0.1.0.0/src/tensor/permutation_mapping.bend as PermutationMapping
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/word_conversion.bend as WordConversion

735def cursor_index_bounded(+shape: Shape.Shape, +cursor: Nat, +inside: {True{} == Nat.is_lt(cursor, Shape.elements(shape)) : Bool}) ->
736  {True{} == U32.is_lt(U32.from_nat(cursor), Shape.count(shape)) : Bool}:
737  %Arith.u32_lt(U32.from_nat(cursor), Shape.count(shape)) : {True{} == _ : Bool}
738  %Equal.sym(Nat, U32.to_nat(Shape.count(shape)), Shape.elements(shape), WordConversion.shape_count_exact(shape)) :
739    {True{} == Nat.is_lt(U32.to_nat(U32.from_nat(cursor)), _) : Bool}
740  %Equal.sym(Nat, U32.to_nat(U32.from_nat(cursor)), cursor, cursor_word_exact(shape, cursor,
741    WordConversion.lt_le(cursor, Shape.elements(shape), Equal.sym(Bool, True{}, Nat.is_lt(cursor, Shape.elements(shape)), inside)))) :
742      {True{} == Nat.is_lt(_, Shape.elements(shape)) : Bool}
743  inside

Uses (14)

Used by (1)