twister/property

Module containing functions to test for properties of a given Permutation.

Note

These are something of an afterthought, and not the use case I wrote this library for; as such, take care when using them, since they’re not very well documented or extensively tested.

Values

pub fn bijection_for_length(perm: twister.Permutation) -> Int

Given a Permutation, check up to what length of input it is a bijection.

For a Permutation to be a bijection for a given length n, the internal List of indices must have a length at least n + 1, as well as contain all of the integers smaller than n at least once.

This way, it is guaranteed to be possible to reverse the permutation given its output; if those requirements are not satisfied, some elements of the original List that was permuted will be dropped, and not present in the output, making reversing the operation impossible.

pub fn get_fixed_points(perm: twister.Permutation) -> List(Int)

Given a Permutation, get which elements are unchanged.

That is, the elements of the list of indices where their index equals their value.

The output is a List of indices which do not change when a Permutation is performed.

Search Document