<Chapter><Heading>From Automata to Networks</Heading>
It is not only important to see how a TPN can be interpreted as a finite state automaton. 
But also if an arbitrary automaton could represent the language of rank encoded permutations
of a TPN. Currently within <C>PatternClass</C> it is only possible to check whether 
deterministic automata are possible representatives of a TPN.
<Section><Heading>Functions</Heading>

<ManSection>
  <Func Name="IsStarClosed" Arg="aut"/>
  <Returns> <K>true</K> if the start and accept states in <C>aut</C> are one and the same state. </Returns>
  <Description>
    This has the consequence that the whole rational expression accepted by <C>aut</C> is always enclosed by the
    Kleene star.
<Example><![CDATA[
gap> x:=Automaton("det",4,2,[[3,4,2,4],[2,2,2,4]],[1],[2]);
< deterministic automaton on 2 letters with 4 states >
gap> IsStarClosed(x);                                      
false
gap> AutToRatExp(x);        
(a(aUb)Ub)b*
gap> y:=Automaton("det",3,2,[[3,2,1],[2,3,1]],[1],[1]);
< deterministic automaton on 2 letters with 3 states >
gap> IsStarClosed(y);
true
gap> AutToRatExp(y);
((ba*bUa)(aUb))*
gap> ]]></Example>
  </Description>
</ManSection>

<ManSection>
  <Func Name="Is2StarReplaceable" Arg="aut"/>
  <Returns> <K>true</K> if none of the states in the automaton <C>aut</C>, which 
  are not the initial state, have a transition to the initial state labelled with 
  the first letter of the alphabet. It also returns <C>true</C> if there is at least one 
  state <M>i \in Q</M> with the first two transitions from <M>i</M> being 
  <M>f(i,1)=1</M> and <M>f(i,2)=x</M>, where <M>x \in Q\setminus\{1\}</M> and 
  <M>f(x,1)=1</M>.</Returns>
  <Description>    
<Example><![CDATA[
gap> x:=Automaton("det",3,2,[[1,2,3],[2,2,3]],[1],[2]);
< deterministic automaton on 2 letters with 3 states >
gap> Is2StarReplaceable(x);
true
gap> y:=Automaton("det",4,2,[[4,1,1,2],[1,3,3,2]],[1],[1]);
< deterministic automaton on 2 letters with 4 states >
gap> Is2StarReplaceable(y);
true
gap> z:=Automaton("det",4,2,[[4,1,1,2],[1,4,2,2]],[1],[4]);
< deterministic automaton on 2 letters with 4 states >
gap> Is2StarReplaceable(z);
false
gap> ]]></Example>
  </Description>
</ManSection>

<ManSection>
  <Func Name="IsStratified" Arg="aut"/>
  <Returns><K>true</K> if <C>aut</C> has a specific "layered" form.</Returns>
  <Description>
    A formal description of the most basic stratified automaton is: <P/>
    <M>(S,Q,f,q_{0},A)</M> with 
    <M>S:=\{1,...,n\},\,\, Q:=\{1,...,m\},\,\, n&lt;m,\,\, q_{0}:=1,\,\, 
    A:=Q\setminus \{n+1\},\,\, f: Q \times S \rightarrow Q </M> and
    <M>n+1</M> is a sink state. <P/>
    If <M>i,j \in Q \setminus \{ n+1 \}</M>,with <M>i &lt; j</M>, and <M>i',j' \in S</M>, 
    <M>i=i',\,\, j=j'</M> then 
    <Display Mode="M">f(i,i')=i,\,\, f(i,j')=j,\,\, f(j,j')=j,\,\, f(j,i')=j-1 \,\, or \,\, n+1.</Display>
<Example><![CDATA[
gap> x:=Automaton("det",4,2,[[1,3,1,4],[2,2,4,4]],[1],[2]);
< deterministic automaton on 2 letters with 4 states >
gap> IsStratified(x);                                      
true
gap> y:=Automaton("det",4,2,[[1,3,2,4],[2,4,1,4]],[1],[2]);
< deterministic automaton on 2 letters with 4 states >
gap> IsStratified(y);                                      
false
gap> ]]></Example>
  </Description>
</ManSection>

<ManSection>
  <Func Name="IsPossibleGraphAut" Arg="aut"/>
  <Returns> <K>true</K> if <C>aut</C> returns <C>true</C> in <C>IsStratified</C>, <C>Is2StarReplaceable</C> and 
  <C>IsStarClosed</C>.</Returns>
  <Description>
    An automaton that fulfils the three functions above has the right form to be an automaton representing
    rank encoded permutations, which are output from a TPN.
<Example><![CDATA[
gap> x:=Automaton("det",2,2,[[1,2],[2,2]],[1],[1]);
< deterministic automaton on 2 letters with 2 states >
gap> IsPossibleGraphAut(x);
true
gap> y:=Automaton("det",2,2,[[1,2],[1,2]],[1],[1]);
< deterministic automaton on 2 letters with 2 states >
gap> IsPossibleGraphAut(y);                        
false
gap> IsStarClosed(y);
true
gap> Is2StarReplaceable(y);
true
gap> IsStratified(y);
false
gap> ]]></Example>
  </Description>
</ManSection>

</Section>

</Chapter>