  
  [1X5 [33X[0;0YSome functions involving automata[133X[101X
  
  [33X[0;0YThis  chapter  describes  some  functions involving automata. It starts with
  functions   to   obtain   equivalent   automata  of  other  type.  Then  the
  minimalization is considered.[133X
  
  
  [1X5.1 [33X[0;0YFrom one type to another[133X[101X
  
  [33X[0;0YRecall  that  two automata are said to be equivalent when they recognize the
  same  language.  Next  we have functions which have as input automata of one
  type and as output equivalent automata of another type.[133X
  
  [1X5.1-1 EpsilonToNFA[101X
  
  [29X[2XEpsilonToNFA[102X( [3XA[103X ) [32X function
  
  [33X[0;0Y[3XA[103X  is  an  automaton  with [22Xϵ[122X-transitions. Returns a NFA recognizing the same
  language.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xx:=RandomAutomaton("epsilon",3,2);;Display(x);[127X[104X
    [4X[28X   |  1          2          3[128X[104X
    [4X[28X------------------------------------[128X[104X
    [4X[28X a | [ 2 ]      [ 3 ]      [ 2 ][128X[104X
    [4X[28X b | [ 1, 2 ]   [ 1, 2 ]   [ 1, 3 ][128X[104X
    [4X[28X @ | [ 1, 2 ]   [ 1, 2 ]   [ 1, 2 ][128X[104X
    [4X[28XInitial states:   [ 2, 3 ][128X[104X
    [4X[28XAccepting states: [ 1, 2, 3 ][128X[104X
    [4X[25Xgap>[125X [27XDisplay(EpsilonToNFA(x));[127X[104X
    [4X[28X   |  1          2             3[128X[104X
    [4X[28X------------------------------------------[128X[104X
    [4X[28X a | [ 1, 2 ]   [ 1, 2, 3 ]   [ 1, 2 ][128X[104X
    [4X[28X b | [ 1, 2 ]   [ 1, 2 ]      [ 1, 2, 3 ][128X[104X
    [4X[28XInitial states:   [ 1, 2, 3 ][128X[104X
    [4X[28XAccepting states: [ 1, 2, 3 ][128X[104X
  [4X[32X[104X
  
  [1X5.1-2 EpsilonToNFASet[101X
  
  [29X[2XEpsilonToNFASet[102X( [3XA[103X ) [32X function
  
  [33X[0;0Y[3XA[103X  is  an  automaton  with [22Xϵ[122X-transitions. Returns a NFA recognizing the same
  language.  This  function  differs  from  [2XEpsilonToNFA[102X ([14X5.1-1[114X) in that it is
  faster  for  smaller automata, or automata with few epsilon transitions, but
  slower in the really hard cases.[133X
  
  [1X5.1-3 EpsilonCompactedAut[101X
  
  [29X[2XEpsilonCompactedAut[102X( [3XA[103X ) [32X function
  
  [33X[0;0Y[3XA[103X   is   an   automaton  with  [22Xϵ[122X-transitions.  Returns  an  [22Xϵ[122XNFA  with  each
  strongly-connected   component  of  the  epsilon-transitions  digraph  of  [3XA[103X
  identified with a single state and recognizing the same language.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xx:=RandomAutomaton("epsilon",3,2);;Display(x);[127X[104X
    [4X[28X   |  1          2          3[128X[104X
    [4X[28X------------------------------------[128X[104X
    [4X[28X a | [ 1, 2 ]   [ 1, 3 ]   [ 1, 2 ][128X[104X
    [4X[28X b | [ 1, 2 ]   [ 1, 2 ]   [ 2, 3 ][128X[104X
    [4X[28X @ |            [ 3 ]      [ 2 ][128X[104X
    [4X[28XInitial state:    [ 3 ][128X[104X
    [4X[28XAccepting states: [ 1, 3 ][128X[104X
    [4X[25Xgap>[125X [27XDisplay(EpsilonCompactedAut(x));[127X[104X
    [4X[28X   |  1          2[128X[104X
    [4X[28X-------------------------[128X[104X
    [4X[28X a | [ 1, 2 ]   [ 1, 2 ][128X[104X
    [4X[28X b | [ 1, 2 ]   [ 1, 2 ][128X[104X
    [4X[28X @ |[128X[104X
    [4X[28XInitial state:    [ 2 ][128X[104X
    [4X[28XAccepting states: [ 1, 2 ][128X[104X
  [4X[32X[104X
  
  [1X5.1-4 ReducedNFA[101X
  
  [29X[2XReducedNFA[102X( [3XA[103X ) [32X function
  
  [33X[0;0Y[3XA[103X  is  a non deterministic automaton (without [22Xϵ[122X-transitions). Returns an NFA
  accepting  the same language as its input but with possibly fewer states (it
  quotients  out  by  the smallest right-invariant partition of the states). A
  paper describing the algorithm is in preparation.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xx:=RandomAutomaton("nondet",5,2);;Display(x);[127X[104X
    [4X[28X   |  1             2                3             4             5[128X[104X
    [4X[28X----------------------------------------------------------------------[128X[104X
    [4X[28X a | [ 1, 5 ]      [ 1, 2, 4, 5 ]   [ 1, 3, 5 ]   [ 3, 4, 5 ]   [ 4 ][128X[104X
    [4X[28X b | [ 2, 3, 4 ]   [ 3 ]            [ 2, 3, 4 ]   [ 2, 4, 5 ]   [ 3 ][128X[104X
    [4X[28XInitial state:    [ 4 ][128X[104X
    [4X[28XAccepting states: [ 1, 3, 4, 5 ][128X[104X
    [4X[25Xgap>[125X [27XDisplay(ReducedNFA(x));[127X[104X
    [4X[28X   |  1             2                3       4[128X[104X
    [4X[28X--------------------------------------------------------[128X[104X
    [4X[28X a | [ 1, 3 ]      [ 1, 2, 3, 4 ]   [ 4 ]   [ 1, 3, 4 ][128X[104X
    [4X[28X b | [ 1, 2, 4 ]   [ 1 ]            [ 1 ]   [ 2, 3, 4 ][128X[104X
    [4X[28XInitial state:    [ 4 ][128X[104X
    [4X[28XAccepting states: [ 1, 3, 4 ][128X[104X
  [4X[32X[104X
  
  [1X5.1-5 NFAtoDFA[101X
  
  [29X[2XNFAtoDFA[102X( [3XA[103X ) [32X function
  
  [33X[0;0YGiven an NFA, these synonym functions, compute the equivalent DFA, using the
  powerset construction, according to the algorithm presented in the report of
  the AMoRE [MMPTV95] program. The returned automaton is dense deterministic[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xx:=RandomAutomaton("nondet",3,2);;Display(x);[127X[104X
    [4X[28X   |  1       2    3[128X[104X
    [4X[28X---------------------------[128X[104X
    [4X[28X a | [ 2 ]        [ 1, 3 ][128X[104X
    [4X[28X b |              [ 2, 3 ][128X[104X
    [4X[28XInitial states:   [ 1, 3 ][128X[104X
    [4X[28XAccepting states: [ 1, 2 ][128X[104X
    [4X[25Xgap>[125X [27XDisplay(NFAtoDFA(x));[127X[104X
    [4X[28X   |  1  2  3[128X[104X
    [4X[28X--------------[128X[104X
    [4X[28X a |  2  2  1[128X[104X
    [4X[28X b |  3  3  3[128X[104X
    [4X[28XInitial state:    [ 1 ][128X[104X
    [4X[28XAccepting states: [ 1, 2, 3 ][128X[104X
  [4X[32X[104X
  
  [1X5.1-6 FuseSymbolsAut[101X
  
  [29X[2XFuseSymbolsAut[102X( [3XA[103X, [3Xs1[103X, [3Xs2[103X ) [32X function
  
  [33X[0;0YGiven  an  automaton [3XA[103X and integers [3Xs1[103X and [3Xs2[103X which, returns an NFA obtained
  by replacing all transitions through [3Xs2[103X by transitions through [3Xs1[103X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xx:=RandomAutomaton("det",3,2);;Display(x);[127X[104X
    [4X[28X   |  1  2  3[128X[104X
    [4X[28X--------------[128X[104X
    [4X[28X a |  2  3[128X[104X
    [4X[28X b |     1[128X[104X
    [4X[28XInitial state:    [ 3 ][128X[104X
    [4X[28XAccepting states: [ 1, 2, 3 ][128X[104X
    [4X[25Xgap>[125X [27XDisplay(FuseSymbolsAut(x,1,2));[127X[104X
    [4X[28X   |  1       2          3[128X[104X
    [4X[28X---------------------------[128X[104X
    [4X[28X a | [ 2 ]   [ 1, 3 ][128X[104X
    [4X[28XInitial state:    [ 3 ][128X[104X
    [4X[28XAccepting states: [ 1, 2, 3 ][128X[104X
  [4X[32X[104X
  
  
  [1X5.2 [33X[0;0YMinimalization of an automaton[133X[101X
  
  [33X[0;0YThe  algorithm  used to minimalize a dense deterministic automaton (i.e., to
  compute a dense minimal automaton recognizing the same language) is based on
  an  algorithm  due  to Hopcroft (see [AHU74]). It is well known (see [HU69])
  that  it  suffices to reduce the automaton given and remove the inaccessible
  states.  Again,  the  documentation for the computer program AMoRE [MMPTV95]
  has been very useful.[133X
  
  [1X5.2-1 UsefulAutomaton[101X
  
  [29X[2XUsefulAutomaton[102X( [3XA[103X ) [32X function
  
  [33X[0;0YGiven  an  automaton  [3XA[103X  (deterministic or not), outputs a dense DFA [3XB[103X whose
  states are all reachable and such that [3XA[103X and [3XB[103X are equivalent.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xx:=RandomAutomaton("det",4,2);;Display(x);[127X[104X
    [4X[28X   |  1  2  3  4[128X[104X
    [4X[28X-----------------[128X[104X
    [4X[28X a |     3  4[128X[104X
    [4X[28X b |  1  4[128X[104X
    [4X[28XInitial state:    [ 3 ][128X[104X
    [4X[28XAccepting states: [ 2, 3, 4 ][128X[104X
    [4X[25Xgap>[125X [27XDisplay(UsefulAutomaton(x));[127X[104X
    [4X[28X   |  1  2  3[128X[104X
    [4X[28X--------------[128X[104X
    [4X[28X a |  2  3  3[128X[104X
    [4X[28X b |  3  3  3[128X[104X
    [4X[28XInitial state:    [ 1 ][128X[104X
    [4X[28XAccepting states: [ 1, 2 ][128X[104X
  [4X[32X[104X
  
  [1X5.2-2 MinimalizedAut[101X
  
  [29X[2XMinimalizedAut[102X( [3XA[103X ) [32X function
  
  [33X[0;0YReturns the minimal automaton equivalent to [3XA[103X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xx:=RandomAutomaton("det",4,2);;Display(x);[127X[104X
    [4X[28X   |  1  2  3  4[128X[104X
    [4X[28X-----------------[128X[104X
    [4X[28X a |     3  4[128X[104X
    [4X[28X b |  1  2  3[128X[104X
    [4X[28XInitial state:    [ 4 ][128X[104X
    [4X[28XAccepting states: [ 2, 3, 4 ][128X[104X
    [4X[25Xgap>[125X [27XDisplay(MinimalizedAut(x));[127X[104X
    [4X[28X   |  1  2[128X[104X
    [4X[28X-----------[128X[104X
    [4X[28X a |  2  2[128X[104X
    [4X[28X b |  2  2[128X[104X
    [4X[28XInitial state:   [ 1 ][128X[104X
    [4X[28XAccepting state: [ 1 ][128X[104X
  [4X[32X[104X
  
  [1X5.2-3  MinimalAutomaton[101X
  
  [29X[2X MinimalAutomaton[102X( [3XA[103X ) [32X attribute
  
  [33X[0;0YReturns  the minimal automaton equivalent to [3XA[103X, but stores it so that future
  computations of this automaton just return the stored automaton.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xx:=RandomAutomaton("det",4,2);;Display(x);[127X[104X
    [4X[28X   |  1  2  3  4[128X[104X
    [4X[28X-----------------[128X[104X
    [4X[28X a |     2  4[128X[104X
    [4X[28X b |     3  4[128X[104X
    [4X[28XInitial state:    [ 4 ][128X[104X
    [4X[28XAccepting states: [ 1, 2, 3 ][128X[104X
    [4X[25Xgap>[125X [27XDisplay(MinimalAutomaton(x));[127X[104X
    [4X[28X   |  1[128X[104X
    [4X[28X--------[128X[104X
    [4X[28X a |  1[128X[104X
    [4X[28X b |  1[128X[104X
    [4X[28XInitial state:   [ 1 ][128X[104X
    [4X[28XAccepting state:[128X[104X
  [4X[32X[104X
  
  [1X5.2-4 AccessibleStates[101X
  
  [29X[2XAccessibleStates[102X( [3Xaut[103X[, [3Xp[103X] ) [32X function
  
  [33X[0;0YComputes  the  list of states of the automaton [3Xaut[103X which are accessible from
  state  [3Xp[103X.  When [3Xp[103X is not given, returns the states which are accessible from
  any initial state.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xx:=RandomAutomaton("det",4,2);;Display(x);[127X[104X
    [4X[28X   |  1  2  3  4[128X[104X
    [4X[28X-----------------[128X[104X
    [4X[28X a |     1  2  4[128X[104X
    [4X[28X b |     2  4[128X[104X
    [4X[28XInitial state:    [ 2 ][128X[104X
    [4X[28XAccepting states: [ 1, 2, 3 ][128X[104X
    [4X[25Xgap>[125X [27XAccessibleStates(x,3);[127X[104X
    [4X[28X[ 1, 2, 3, 4 ][128X[104X
  [4X[32X[104X
  
  [1X5.2-5 AccessibleAutomaton[101X
  
  [29X[2XAccessibleAutomaton[102X( [3XA[103X ) [32X function
  
  [33X[0;0YIf  [3XA[103X  is  a  deterministic  automaton, not necessarily dense, an equivalent
  dense   deterministic   accessible  automaton  is  returned.  (The  function
  [10XUsefulAutomaton[110X is called.)[133X
  
  [33X[0;0YIf  [3XA[103X  is  not  deterministic  with  a  single  initial state, an equivalent
  accessible automaton is returned.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xx:=RandomAutomaton("det",4,2);;Display(x);[127X[104X
    [4X[28X   |  1  2  3  4[128X[104X
    [4X[28X-----------------[128X[104X
    [4X[28X a |  1  3[128X[104X
    [4X[28X b |  1  3  4[128X[104X
    [4X[28XInitial state:    [ 2 ][128X[104X
    [4X[28XAccepting states: [ 3, 4 ][128X[104X
    [4X[25Xgap>[125X [27XDisplay(AccessibleAutomaton(x));[127X[104X
    [4X[28X   |  1  2  3  4[128X[104X
    [4X[28X-----------------[128X[104X
    [4X[28X a |  2  4  4  4[128X[104X
    [4X[28X b |  2  3  4  4[128X[104X
    [4X[28XInitial state:    [ 1 ][128X[104X
    [4X[28XAccepting states: [ 2, 3 ][128X[104X
  [4X[32X[104X
  
  [1X5.2-6 IntersectionLanguage[101X
  
  [29X[2XIntersectionLanguage[102X( [3XA1[103X, [3XA2[103X ) [32X function
  [29X[2XIntersectionAutomaton[102X( [3XA1[103X, [3XA2[103X ) [32X function
  
  [33X[0;0YComputes  an  automaton  that  recognizes  the intersection of the languages
  given  (through  automata  or  rational  expressions by) [3XA1[103X and [3XA2[103X. When the
  arguments  are  deterministic automata, is the same as ProductAutomaton, but
  works  for  all  kinds of automata. Note that the language of the product of
  two automata is precisely the intersection of the languages of the automata.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xx:=RandomAutomaton("det",3,2);;Display(x);[127X[104X
    [4X[28X   |  1  2  3[128X[104X
    [4X[28X--------------[128X[104X
    [4X[28X a |  2  3[128X[104X
    [4X[28X b |     1[128X[104X
    [4X[28XInitial state:    [ 3 ][128X[104X
    [4X[28XAccepting states: [ 1, 2, 3 ][128X[104X
    [4X[25Xgap>[125X [27Xy:=RandomAutomaton("det",3,2);;Display(y);[127X[104X
    [4X[28X   |  1  2  3[128X[104X
    [4X[28X--------------[128X[104X
    [4X[28X a |     1[128X[104X
    [4X[28X b |  1  3[128X[104X
    [4X[28XInitial state:    [ 3 ][128X[104X
    [4X[28XAccepting states: [ 1, 3 ][128X[104X
    [4X[25Xgap>[125X [27XDisplay(IntersectionLanguage(x,y));[127X[104X
    [4X[28X   |  1  2[128X[104X
    [4X[28X-----------[128X[104X
    [4X[28X a |  2  2[128X[104X
    [4X[28X b |  2  2[128X[104X
    [4X[28XInitial state:   [ 1 ][128X[104X
    [4X[28XAccepting state: [ 1 ][128X[104X
  [4X[32X[104X
  
  [1X5.2-7 AutomatonAllPairsPaths[101X
  
  [29X[2XAutomatonAllPairsPaths[102X( [3XA[103X ) [32X function
  
  [33X[0;0YGiven  an  automaton  [3XA[103X,  with [10Xn[110X states, outputs a [10Xn[110X x [10Xn[110X matrix P, such that
  P[i][j] is the list of simple paths from state i to state j in [3XA[103X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xa:=RandomAutomaton("det",3,2);[127X[104X
    [4X[28X< deterministic automaton on 2 letters with 3 states >[128X[104X
    [4X[25Xgap>[125X [27XAutomatonAllPairsPaths(a);[127X[104X
    [4X[28X[ [ [ [ 1, 1 ] ], [  ], [  ] ], [ [ [ 2, 1 ] ], [ [ 2, 2 ] ], [  ] ],[128X[104X
    [4X[28X  [ [ [ 3, 2, 1 ] ], [ [ 3, 2 ] ], [ [ 3, 3 ] ] ] ][128X[104X
    [4X[25Xgap>[125X [27XDisplay(a);[127X[104X
    [4X[28X   |  1  2  3[128X[104X
    [4X[28X--------------[128X[104X
    [4X[28X a |     1  2[128X[104X
    [4X[28X b |  1  2  3[128X[104X
    [4X[28XInitial state:    [ 3 ][128X[104X
    [4X[28XAccepting states: [ 1, 2 ][128X[104X
  [4X[32X[104X
  
