def is_perm
import bendtorch@1.3.0.0/tensor.bend as Tensorimport Base
491# p is a permutation of the axes of a rank-n tensor
492def is_perm(+p: List<&2, Nat>, +n: Nat) -> Bool:
493 # bend-lint: disable-next bend-lint-rules/performance/eager_branch -- a shape predicate over a list of rank <= 4, once per operation; the types and LAWS.bend read its Bool form not-expected-because: a match would change the definition the proofs reduce, for no measurable gain
494 Bool.and(Nat.is_eq(List.length(&2, Nat, p), n), all_once(n, p, 0n))