<Chapter><Heading> Miscellaneous functions </Heading>

This temporary chapter is dedicated to miscellaneous functions that are relevant to some
specific ongoing research questions.

<Section><Heading> Permutation Inclusion Set </Heading>

This section is dedicated to the search of the set of permutations which lay in between two permutations. Formally that is <M> I_{\pi,\rho} = \{\rho : \pi \leq \rho \sigma\} </M>.
<ManSection>
  <Func Name="InbetweenPermAutomaton" Arg="perm1, perm2"/>
  <Returns>An automaton which accepts the encoded permutations between <C>perm1</C> and <C>perm2</C> where, <C>perm2</C> is the subpermutation.</Returns>
  <Description>
    <C>InbetweenPermAutomaton</C> creates the intersection language between the language of all subpermutations of <C>perm1</C> and the language of superpermutations of <C>perm2</C>.
<!-- EXAMPLE !!!!!!!! -->
<Example><![CDATA[
	gap> InbetweenPermAutomaton([3,2,1,4,6,5],[1,2]);
	< deterministic automaton on 3 letters with 8 states >
	gap> Display(last);
	   |  1  2  3  4  5  6  7  8
	-----------------------------
	 a |  2  2  1  1  6  3  2  6
	 b |  2  2  4  2  2  4  5  5
	 c |  2  2  2  2  2  2  2  7
	Initial state:    [ 8 ]
	Accepting states: [ 1, 3 ]
	gap>  ]]></Example>
  </Description>
</ManSection>

<ManSection>
  <Func Name="InbetweenPermSet" Arg="perm1, perm2"/>
  <Returns>A list which contains the permutations between <C>perm1</C> and <C>perm2</C> where, <C>perm2</C> is the subpermutation.</Returns>
  <Description>
    Using <C>InbetweenPermAutomaton</C> we create the set of all permutations laying between the input permutations.
<!-- EXAMPLE !!!!!!!! -->
<Example><![CDATA[
gap> InbetweenPermSet([3,2,1,4,6,5],[1,2]);
[ [ 1, 2 ], [ 1, 2, 3 ], [ 1, 3, 2 ], [ 2, 1, 3 ], [ 1, 2, 4, 3 ],
  [ 2, 1, 3, 4 ], [ 2, 1, 4, 3 ], [ 3, 2, 1, 4 ], [ 2, 1, 3, 5, 4 ],
  [ 3, 2, 1, 4, 5 ], [ 3, 2, 1, 5, 4 ], [ 3, 2, 1, 4, 6, 5 ] ]
gap> ]]></Example>
  </Description>
</ManSection>

<ManSection>
  <Func Name="IsSubPerm" Arg="perm1, perm2"/>
  <Returns><C>true</C> if <C>perm2</C> is a subpermutation of <C>perm1</C>.</Returns>
  <Description>
      Creates the automaton accepting all subpermutations of <C>perm1</C> of the same rank or less, and checks whether the automaton accepts the rank encoding of <C>perm2</C>.
<!-- EXAMPLE !!!!!!!! -->
<Example><![CDATA[
gap> IsSubPerm([2,4,6,8,1,3,5,7],[2,3,1]);
true
gap> IsSubPerm([2,4,6,8,1,3,5,7],[3,2,1]);
false
gap> ]]></Example>
  </Description>
</ManSection>


</Section>

<Section><Heading> Automaton Manipulation </Heading>

<ManSection>
  <Func Name="LoopFreeAut" Arg="aut"/>
  <Returns>An automaton without any loops of length 1.</Returns>
  <Description>
    <C>LoopFreeAut</C> builds the subautomaton of <C>aut</C> that does not contain any loops of length 1, except for the sink state.
<!-- EXAMPLE !!!!!!!! -->
<Example><![CDATA[
gap> a:=Automaton("det",4,3,[[2,4,3,3],[4,4,1,4],[3,1,2,4]],[1],[2]);
< deterministic automaton on 3 letters with 4 states >
gap> Display(a);
   |  1  2  3  4
-----------------
 a |  2  4  3  3
 b |  4  4  1  4
 c |  3  1  2  4
Initial state:   [ 1 ]
Accepting state: [ 2 ]
gap> b:=LoopFreeAut(a);
< deterministic automaton on 3 letters with 5 states >
gap> Display(b);
   |  1  2  3  4  5
--------------------
 a |  2  4  5  3  5
 b |  4  4  1  5  5
 c |  3  1  2  5  5
Initial state:   [ 1 ]
Accepting state: [ 2 ]
gap> ]]></Example>
  </Description>
</ManSection>

<ManSection>
  <Func Name="LoopVertexFreeAut" Arg="aut"/>
  <Returns>An automaton without any vertices that had loops of length 1.</Returns>
  <Description>
    <C>LoopVertexFreeAut</C> builds the subautomaton that does not contain the vertices and transitions
    of vertices in <C>aut</C> that have loops of length 1. The function minimalises and determinises the
    automaton before returning it, which might change the numbering on the vertices, but the returned automaton
    is isomorphic to the subautomaton of <C>aut</C>.
<!-- EXAMPLE !!!!!!!! -->
<Example><![CDATA[
gap> a:=Automaton("det",4,3,[[2,4,3,3],[4,4,1,4],[3,1,2,4]],[1],[2]);
< deterministic automaton on 3 letters with 4 states >
gap> Display(a);
   |  1  2  3  4
-----------------
 a |  2  4  3  3
 b |  4  4  1  4
 c |  3  1  2  4
Initial state:   [ 1 ]
Accepting state: [ 2 ]
gap> b:=LoopVertexFreeAut(a);
< deterministic automaton on 3 letters with 3 states >
gap> Display(b);
   |  1  2  3
--------------
 a |  2  2  1
 b |  2  2  2
 c |  3  2  2
Initial state:   [ 3 ]
Accepting state: [ 1 ]
gap> ]]></Example>
  </Description>
</ManSection>


</Section>

</Chapter>
