BeginPackage["Perm`"]

$ContextPath

$Context

Perm::usage = "Perm[5,2,3,1,4] means the permutation that maps 1->5, 2->2, 3->3, 4->1, 5->4.";

Begin["`private`"]

PermutationQ[σ_Perm] := Sort[List@@σ]===Range[Length[σ]]

σ_Perm ∘ τ_Perm /; Length[σ]==Length[τ] :=σ[[List@@τ]];

Perm /:(((σ_Perm))^(-1)) /; PermutationQ[σ]:= (
τ=σ;
Do[τ[[σ[[i]]]]=i, {i,Length[σ]}];
τ
)

End[]; EndPackage[]

See https://mathematica.stackexchange.com/questions/31302/how-do-i-create-a-package-from-an-existing-notebook

$ContextPath

$Context

((Perm[2,3,1])^(-1))

τ

Perm`private`τ