Wolfram Research

Function Repository Resource:

PermutationInvolutionQ

Source Notebook

Test whether a permutation equals its inverse

Contributed by: Wolfram Staff

ResourceFunction["PermutationInvolutionQ"][p]

tests whether a permutation p equals its inverse.

Details and Options

In general, a function f is an involution if f(f(x))=x for all x in the domain of f. For a permutation p, that is equivalent to p=p-1. A permutation is easily seen to be involutive if and only if it is comprised entirely of cycles of lengths 1 or 2.

Examples

Basic Examples

A permutation involution with 1↔2, 3↔4:

In[1]:=
ResourceFunction["PermutationInvolutionQ"]@{2, 1, 4, 3}
Out[1]=

The permutation {2,3,1} is not an involution because 1↦2↦3≠1:

In[2]:=
ResourceFunction["PermutationInvolutionQ"]@{2, 3, 1}
Out[2]=

Scope

These are the 10 involutive permutation on four elements, shown compactly:

In[3]:=
Row /@ Select[Permutations@Range@4, ResourceFunction[
  "PermutationInvolutionQ"]]
Out[3]=

Resource History

License Information