  
  [1X4 [33X[0;0YAutomata [13Xversus[113X[101X[1X rational expressions[133X[101X
  
  [33X[0;0YA  remarkable theorem due to Kleene shows that a language is recognized by a
  finite  automaton  precisely  when  it  may  be given by means of a rational
  expression, i.e. is a rational language.[133X
  
  [33X[0;0YAn  automaton  and a rational expression are said to be [13Xequivalent[113X when both
  represent  the  same  language.  In this chapter we describe functions to go
  from automata to equivalent rational expressions and [13Xvice-versa[113X.[133X
  
  
  [1X4.1 [33X[0;0YFrom automata to rational expressions[133X[101X
  
  [1X4.1-1 AutomatonToRatExp [101X
  
  [29X[2XAutomatonToRatExp [102X( [3XA[103X ) [32X function
  [29X[2XAutToRatExp[102X( [3XA[103X ) [32X function
  [29X[2XFAtoRatExp[102X( [3XA[103X ) [32X function
  
  [33X[0;0YFrom  a  finite  automaton,  [10XFAtoRatExp[110X,  [10XAutToRatExp[110X and [10XAutomatonToRatExp[110X,
  which  are  synonyms,  compute one equivalent rational expression, using the
  state elimination algorithm.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xx:=Automaton("det",4,2,[[ 0, 1, 2, 3 ],[ 0, 1, 2, 3 ]],[ 3 ],[ 1, 3, 4 ]);;[127X[104X
    [4X[25Xgap>[125X [27XFAtoRatExp(x);[127X[104X
    [4X[28X(aUb)(aUb)U@[128X[104X
    [4X[25Xgap>[125X [27Xaut:=Automaton("det",4,"xy",[[ 0, 1, 2, 3 ],[ 0, 1, 2, 3 ]],[ 3 ],[ 1, 3, 4 ]);;[127X[104X
    [4X[25Xgap>[125X [27XFAtoRatExp(aut);[127X[104X
    [4X[28X(xUy)(xUy)U@[128X[104X
  [4X[32X[104X
  
  
  [1X4.2 [33X[0;0YFrom rational expression to automata[133X[101X
  
  [1X4.2-1 RatExpToNDAut[101X
  
  [29X[2XRatExpToNDAut[102X( [3XR[103X ) [32X function
  
  [33X[0;0YGiven a rational expression [3XR[103X, computes the equivalent NFA[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xr:=RationalExpression("aUab");[127X[104X
    [4X[28XaUab[128X[104X
    [4X[25Xgap>[125X [27XDisplay(RatExpToNDAut(r));[127X[104X
    [4X[28X   |  1    2       3    4[128X[104X
    [4X[28X--------------------------------[128X[104X
    [4X[28X a |                   [ 1, 2 ][128X[104X
    [4X[28X b |      [ 3 ][128X[104X
    [4X[28XInitial state:    [ 4 ][128X[104X
    [4X[28XAccepting states: [ 1, 3 ][128X[104X
    [4X[25Xgap>[125X [27Xr:=RationalExpression("xUxy"); [127X[104X
    [4X[28XxUxy[128X[104X
    [4X[25Xgap>[125X [27XDisplay(RatExpToNDAut(r));    [127X[104X
    [4X[28X   |  1    2       3    4[128X[104X
    [4X[28X--------------------------------[128X[104X
    [4X[28X x |                   [ 1, 2 ]   [128X[104X
    [4X[28X y |      [ 3 ]                   [128X[104X
    [4X[28XInitial state:    [ 4 ][128X[104X
    [4X[28XAccepting states: [ 1, 3 ][128X[104X
  [4X[32X[104X
  
  [1X4.2-2 RatExpToAutomaton[101X
  
  [29X[2XRatExpToAutomaton[102X( [3XR[103X ) [32X function
  [29X[2XRatExpToAut[102X( [3XR[103X ) [32X function
  
  [33X[0;0YGiven  a  rational  expression  [3XR[103X,  these functions, which are synonyms, use
  [2XRatExpToNDAut[102X  ([14X4.2-1[114X))  to  compute the equivalent NFA and then returns the
  equivalent minimal DFA[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xr:=RationalExpression("@U(aUb)(aUb)");[127X[104X
    [4X[28X@U(aUb)(aUb)[128X[104X
    [4X[25Xgap>[125X [27XDisplay(RatExpToAut(r));[127X[104X
    [4X[28X   |  1  2  3  4[128X[104X
    [4X[28X-----------------[128X[104X
    [4X[28X a |  3  1  3  2[128X[104X
    [4X[28X b |  3  1  3  2[128X[104X
    [4X[28XInitial state:    [ 4 ][128X[104X
    [4X[28XAccepting states: [ 1, 4 ][128X[104X
    [4X[25Xgap>[125X [27Xr:=RationalExpression("@U(0U1)(0U1)");[127X[104X
    [4X[28X@U(0U1)(0U1)[128X[104X
    [4X[25Xgap>[125X [27XDisplay(RatExpToAut(r));              [127X[104X
    [4X[28X   |  1  2  3  4  [128X[104X
    [4X[28X-----------------[128X[104X
    [4X[28X 0 |  3  1  3  2  [128X[104X
    [4X[28X 1 |  3  1  3  2  [128X[104X
    [4X[28XInitial state:    [ 4 ][128X[104X
    [4X[28XAccepting states: [ 1, 4 ][128X[104X
  [4X[32X[104X
  
  
  [1X4.3 [33X[0;0YSome tests on automata[133X[101X
  
  [33X[0;0YThis  section  describes  functions that perform tests on automata, rational
  expressions and their accepted languages.[133X
  
  [1X4.3-1 IsEmptyLang[101X
  
  [29X[2XIsEmptyLang[102X( [3XR[103X ) [32X function
  
  [33X[0;0YThis  function  tests if the language given through a rational expression or
  an automaton [3X R [103X is the empty language.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xr:=RandomRatExp(2);[127X[104X
    [4X[28Xempty_set[128X[104X
    [4X[25Xgap>[125X [27XIsEmptyLang(r);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27Xr:=RandomRatExp(2);[127X[104X
    [4X[28XaUb[128X[104X
    [4X[25Xgap>[125X [27XIsEmptyLang(r);[127X[104X
    [4X[28Xfalse[128X[104X
  [4X[32X[104X
  
  [1X4.3-2 IsFullLang[101X
  
  [29X[2XIsFullLang[102X( [3XR[103X ) [32X function
  
  [33X[0;0YThis  function  tests if the language given through a rational expression or
  an automaton [3X R [103X represents the Kleene closure of the alphabet of [3X R [103X .[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xr:=RationalExpression("aUb");[127X[104X
    [4X[28XaUb[128X[104X
    [4X[25Xgap>[125X [27XIsFullLang(r);[127X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27Xr:=RationalExpression("(aUb)*");[127X[104X
    [4X[28X(aUb)*[128X[104X
    [4X[25Xgap>[125X [27XIsFullLang(r);[127X[104X
    [4X[28Xtrue[128X[104X
  [4X[32X[104X
  
  [1X4.3-3 AreEqualLang[101X
  
  [29X[2XAreEqualLang[102X( [3XA1[103X, [3XA2[103X ) [32X function
  [29X[2XAreEquivAut[102X( [3XA1[103X, [3XA2[103X ) [32X function
  
  [33X[0;0YThese  functions,  which  are  synonyms,  test  if  the automata or rational
  expressions [3XA1[103X and [3XA2[103X are equivalent, i.e. represent the same language. This
  is  performed  by  checking  that  the  corresponding  minimal  automata are
  isomorphic. Note hat this cannot happen if the alphabets are different.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xy:=RandomAutomaton("det",4,2);;[127X[104X
    [4X[25Xgap>[125X [27Xx:=RandomAutomaton("det",4,2);;[127X[104X
    [4X[25Xgap>[125X [27XAreEquivAut(x, y);[127X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27Xa:=RationalExpression("(aUb)*ab*");[127X[104X
    [4X[28X(aUb)*ab*[128X[104X
    [4X[25Xgap>[125X [27Xb:=RationalExpression("(aUb)*");[127X[104X
    [4X[28X(aUb)*[128X[104X
    [4X[25Xgap>[125X [27XAreEqualLang(a, b);[127X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27Xa:=RationalExpression("(bUa)*");[127X[104X
    [4X[28X(bUa)*[128X[104X
    [4X[25Xgap>[125X [27XAreEqualLang(a, b);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27Xx:=RationalExpression("(1U0)*");[127X[104X
    [4X[28X(1U0)*[128X[104X
    [4X[25Xgap>[125X [27XAreEqualLang(a, x);  [127X[104X
    [4X[28XThe given languages are not over the same alphabet[128X[104X
    [4X[28Xfalse[128X[104X
  [4X[32X[104X
  
  [1X4.3-4 IsContainedLang[101X
  
  [29X[2XIsContainedLang[102X( [3XR1[103X, [3XR2[103X ) [32X function
  
  [33X[0;0YTests  if  the  language  represented  (through  an  automaton or a rational
  expression)  by  [3X  R1  [103X is contained in the language represented (through an
  automaton or a rational expression) by [3X R2 [103X .[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xr:=RationalExpression("aUab");[127X[104X
    [4X[28XaUab[128X[104X
    [4X[25Xgap>[125X [27Xs:=RationalExpression("a","ab");[127X[104X
    [4X[28Xa[128X[104X
    [4X[25Xgap>[125X [27XIsContainedLang(s,r);[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XIsContainedLang(r,s);[127X[104X
    [4X[28Xfalse[128X[104X
  [4X[32X[104X
  
  [1X4.3-5 AreDisjointLang[101X
  
  [29X[2XAreDisjointLang[102X( [3XR1[103X, [3XR2[103X ) [32X function
  
  [33X[0;0YTests   if  the  languages  represented  (through  automata  or  a  rational
  expressions) by [3X R1 [103X and [3X R2 [103X are disjoint.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xr:=RationalExpression("aUab");;[127X[104X
    [4X[25Xgap>[125X [27Xs:=RationalExpression("a","ab");;[127X[104X
    [4X[25Xgap>[125X [27XAreDisjointLang(r,s);[127X[104X
    [4X[28Xfalse[128X[104X
  [4X[32X[104X
  
