nominal-0.1.0.0: Binders and alpha-equivalence made easy

Safe HaskellNone
LanguageHaskell2010

Nominal.Permutation

Contents

Description

This module provides an efficient implementation of finitely supported permutations of atoms. Compositions and inverses can both be computed with O(n) Map lookup operations.

Synopsis

The monoid of permutations

newtype Perm Source #

The monoid of finitely supported permutations on atoms.

Constructors

Perm (Map Atom Atom) 

Instances

Eq Perm Source # 

Methods

(==) :: Perm -> Perm -> Bool #

(/=) :: Perm -> Perm -> Bool #

Show Perm Source # 

Methods

showsPrec :: Int -> Perm -> ShowS #

show :: Perm -> String #

showList :: [Perm] -> ShowS #

p_identity :: Perm Source #

The identity permutation. O(1).

p_composeR :: Perm -> Perm -> Perm Source #

Compose two permutations. O(m) where m is the size of the right permutation.

p_composeL :: Perm -> Perm -> Perm -> Perm Source #

Compose two permutations. O(n) where n is the size of the left permutation. This also requires the inverse of the right permutation as an input.

p_apply_atom :: Perm -> Atom -> Atom Source #

Apply a permutation to an atom. O(1).

p_swap :: Atom -> Atom -> Perm Source #

Swap a and b. O(1).

p_domain :: Perm -> [Atom] Source #

Return the domain of a permutation. O(n).

The group of permutations

data NominalPermutation Source #

The group of finitely supported permutations on atoms. This is an abstract type with no exposed structure.

Constructors

Permutation Perm Perm

Implementation note: If we used Perm directly, inverting a permutation would be O(n). We make inverting O(1) by storing a permutation together with its inverse. Because of laziness, the inverse will not be computed unless it is used.

type Permutation = NominalPermutation Source #

A type synonym.

perm_identity :: Permutation Source #

The identity permutation. O(1).

perm_composeR :: Permutation -> Permutation -> Permutation Source #

Compose two permutations. O(m) where m is the size of the right permutation.

perm_composeL :: Permutation -> Permutation -> Permutation Source #

Compose two permutations. O(n) where n is the size of the left permutation.

perm_invert :: Permutation -> Permutation Source #

Invert a permutation. O(1).

perm_apply_atom :: Permutation -> Atom -> Atom Source #

Apply a permutation to an atom. O(1).

perm_swap :: Atom -> Atom -> Permutation Source #

Swap a and b. O(1).

perm_swaps :: [(Atom, Atom)] -> Permutation Source #

Swap the given pairs of atoms.

perm_domain :: Permutation -> [Atom] Source #

The domain of a permutation. O(n).

perm_of_swaps :: [(Atom, Atom)] -> Permutation Source #

Make a permutation from a list of swaps. This is mostly useful for testing. O(n).

swaps_of_perm :: Permutation -> [(Atom, Atom)] Source #

Turn a permutation into a list of swaps. This is mostly useful for testing. O(n).