Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 418346<?xml version="1.0" encoding="UTF-8"?>1<!-- $Id: automata.xml,v 1.13 Exp $ -->23<Chapter><Heading>Finite Automata</Heading>45This chapter describes the representations used in this package for6finite automata and some functions to determine information about them.7<P/>8We have to remark that the states of an automaton are always named9<M>1,2,3,\ldots;</M> the alphabet may be given by the user. By default10it is <M>\{a,b,c,\ldots\}</M> (or <M>\{a_1,a_2,a_3,\ldots\}</M> in the11case of alphabets with more than <M>26</M> letters).12<P/>13The transition function of an automaton with <M>q</M> states over an alphabet with <M> n</M>14letters is represented by a (not necessarily dense) <M>n\times q</M>15matrix. Each row of the matrix describes the action of the corresponding16letter on the states.17In the case of a <Emph>deterministic automaton</Emph> (DFA) the entries of the18matrix are non-negative integers.19When all entries of the transition table20are positive integers, the automaton is said to be21<Emph>dense</Emph> or <Emph>complete</Emph>.22<!--<Index>automaton!complete</Index><Index>automaton!dense</Index>-->2324In the case of a <Emph>non deterministic automaton</Emph> (NFA) the entries of the25matrix may be lists of non-negative integers.2627<Emph>Automata with <M>\epsilon</M>-transitions</Emph> are also allowed: the28last letter of the alphabet is assumed to be <M>\epsilon</M> and is represented by @.2930<Section><Heading>Automata generation</Heading>31<!-- In the case of <Emph>non32deterministic automata</Emph> the entries of the matrix are lists of33non-negative integers. -->3435The way to create an automaton in &GAP; is the following36<ManSection>37<Func Name="Automaton" Arg="Type, Size, Alphabet,TransitionTable,38Initial, Accepting"/>39<Description>40<!-- The names chosen for the arguments describe their meaning.-->41<C>Type</C> may be42<C>"det"</C>, <C>"nondet"</C> or <C>"epsilon"</C> according to whether43the automaton is deterministic, non deterministic or an automaton with44<M>\epsilon</M>-transitions.45<C>Size</C> is a positive integer representing the46number of states of the automaton. <C>Alphabet</C> is the number of47letters of the alphabet or a list with the letters of the ordered alphabet.48<C>TransitionTable</C> is the transition matrix. The49entries are non-negative integers not greater than the size of the automaton.50In the case of non deterministic automata, lists of non-negative integers not51greater than the size of the automaton are also allowed. <C>Initial</C>52and <C>Accepting</C> are, respectively, the lists of initial and accepting53states.54<Example>55<![CDATA[56gap> aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,4]],[1],[4]);57< deterministic automaton on 2 letters with 4 states >58gap> Display(aut);59| 1 2 3 460-----------------61a | 3 3 462b | 3 4 463Initial state: [ 1 ]64Accepting state: [ 4 ]65]]>66</Example>67The alphabet of the automaton may be specified:68<Example><![CDATA[69gap> aut:=Automaton("det",4,"01",[[3,,3,4],[3,4,0,4]],[1],[4]);70< deterministic automaton on 2 letters with 4 states >71gap> Display(aut);72| 1 2 3 473-----------------740 | 3 3 4751 | 3 4 476Initial state: [ 1 ]77Accepting state: [ 4 ]78]]></Example>79Instead of leaving a hole in the transition matrix, we may write a <C>0</C>80to mean that no transition is present.81Non deterministic automata may be given the same way.82<Example><![CDATA[83gap> ndaut:=Automaton("nondet",4,2,[[3,[1,2],3,0],[3,4,0,[2,3]]],[1],[4]);84< non deterministic automaton on 2 letters with 4 states >85gap> Display(ndaut);86| 1 2 3 487-----------------------------------------88a | [ 3 ] [ 1, 2 ] [ 3 ]89b | [ 3 ] [ 4 ] [ 2, 3 ]90Initial state: [ 1 ]91Accepting state: [ 4 ]92]]></Example>93Also in the same way can be given <M>\epsilon</M>-automata. The letter <M>\epsilon</M> is written <C>@</C> instead.94<Example><![CDATA[95gap> x:=Automaton("epsilon",3,"01@",[[,[2],[3]],[[1,3],,[1]],[[1],[2],96> [2]]],[2],[2,3]);97< epsilon automaton on 3 letters with 3 states >98gap> Display(x);99| 1 2 3100------------------------------1010 | [ 2 ] [ 3 ]1021 | [ 1, 3 ] [ 1 ]103@ | [ 1 ] [ 2 ] [ 2 ]104Initial state: [ 2 ]105Accepting states: [ 2, 3 ]106]]></Example>107Bigger automata are displayed in another form:108<Example><![CDATA[109gap> aut:=Automaton("det",16,2,[[4,0,0,6,3,1,4,8,7,4,3,0,6,1,6,0],110> [3,4,0,0,6,1,0,6,1,6,1,6,6,4,8,7,4,5]],[1],[4]);111< deterministic automaton on 2 letters with 16 states >112gap> Display(aut);1131 a 41141 b 31152 b 4116... some more lines11715 a 611815 b 811916 b 7120Initial state: [ 1 ]121Accepting state: [ 4 ]122]]></Example>123</Description> </ManSection>124125<ManSection>126<Func Name="IsAutomaton" Arg="O"/>127<Description>128In the presence of an object <A>O</A>, one may want to test whether129<C>O</C> is an automaton. This may be done using the function <C>IsAutomaton</C>.130<Example><![CDATA[131gap> x:=Automaton("det",3,2,[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;132gap> IsAutomaton(x);133true134]]></Example>135</Description> </ManSection>136137<ManSection>138<Func Name="IsDeterministicAutomaton" Arg="aut"/>139<Description>140Returns <K>true</K> when <C>aut</C> is a deterministic automaton and <K>false</K> otherwise.141<Example><![CDATA[142gap> x:=Automaton("det",3,2,[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;143gap> IsDeterministicAutomaton(x);144true145]]></Example>146</Description> </ManSection>147<!-- silentius -->148<ManSection>149<Func Name="IsNonDeterministicAutomaton" Arg="aut"/>150<Description>151Returns <K>true</K> when <C>aut</C> is a non deterministic automaton and <K>false</K> otherwise.152<Example><![CDATA[153gap> y:=Automaton("nondet",3,2,[[,[1,3],],[,[2,3],[1,3]]],[1,2],[1,3]);;154gap> IsNonDeterministicAutomaton(y);155true156]]></Example>157</Description> </ManSection>158159<ManSection>160<Func Name="IsEpsilonAutomaton" Arg="aut"/>161<Description>162Returns <K>true</K> when <C>aut</C> is an <M>\epsilon</M>-automaton and <K>false</K> otherwise.163<Example><![CDATA[164gap> z:=Automaton("epsilon",2,2,[[[1,2],],[[2],[1]]],[1,2],[1,2]);;165gap> IsEpsilonAutomaton(z);166true167]]></Example>168</Description> </ManSection>169<ManSection>170<Func Name="String" Arg="aut"/>171<Description>172173The way &GAP; displays an automaton is quite natural, but when one wants to174do small changes, for example using <E>copy/paste</E>, the use of the function175<C>String</C> (possibly followed by <C>Print</C>) may be usefull.176<Example><![CDATA[177gap> x:=Automaton("det",3,2,[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;178gap> String(x);179"Automaton(\"det\",3,\"ab\",[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;"180gap> Print(String(x));181Automaton("det",3,"ab",[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;182]]></Example>183<Example><![CDATA[184gap> z:=Automaton("epsilon",2,2,[[[1,2],],[[2],[1]]],[1,2],[1,2]);;185gap> Print(String(z));186Automaton("epsilon",2,"a@",[ [ [ 1, 2 ], [ ] ], [ [ 2 ], [ 1 ] ] ],[ 1, 2 ],[ \1871, 2 ]);;188]]></Example>189</Description> </ManSection>190191<ManSection>192<Func Name="RandomAutomaton" Arg="Type, Size, Alphabet"/>193<Description>194Given the <A>Type</A>, the <A>Size</A> (i.e. the number of states) and the <A>Alphabet</A> (a positive integer195or a list), returns a pseudo random automaton with196these parameters.197<Example><![CDATA[198gap> RandomAutomaton("det",5,"ac");199< deterministic automaton on 2 letters with 5 states >200gap> Display(last);201| 1 2 3 4 5202--------------------203a | 2 3204c | 2 3205Initial state: [ 4 ]206Accepting states: [ 3, 4 ]207208gap> RandomAutomaton("nondet",3,["a","b","c"]);209< non deterministic automaton on 3 letters with 3 states >210211gap> RandomAutomaton("epsilon",2,"abc");212< epsilon automaton on 4 letters with 2 states >213214gap> RandomAutomaton("epsilon",2,2);215< epsilon automaton on 3 letters with 2 states >216gap> Display(last);217| 1 2218----------------------219a | [ 1, 2 ]220b | [ 2 ] [ 1 ]221@ | [ 1, 2 ]222Initial state: [ 2 ]223Accepting states: [ 1, 2 ]224225gap> a:=RandomTransformation(3);;226gap> b:=RandomTransformation(3);;227gap> aut:=RandomAutomaton("det",4,[a,b]);228< deterministic automaton on 2 letters with 4 states >229]]></Example>230</Description> </ManSection>231232</Section>233234235<Section><Heading>Automata internals</Heading>236In this section we describe the functions used to access the internals of an automaton.237238<ManSection>239<Func Name="AlphabetOfAutomaton" Arg="aut"/>240<Description>241242Returns the number of symbols in the alphabet of automaton <C>aut</C>.243<Example><![CDATA[244gap> aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;245gap> AlphabetOfAutomaton(aut);2462247]]></Example>248</Description> </ManSection>249250251<ManSection>252<Func Name="AlphabetOfAutomatonAsList" Arg="aut"/>253<Description>254255Returns the alphabet of automaton <C>aut</C> always256as a list.257258Note that when the alphabet of the automaton is given as an integer259(meaning the number of symbols)260not greater than 26 it returns the list <C>"abcd...."</C>.261If the alphabet is given by means of an integer greater than 26, the262function returns <C>[ "a1", "a2", "a3", "a4", ... ]</C>.263<Example><![CDATA[264gap> a:=RandomAutomaton("det",5,"cat");265< deterministic automaton on 3 letters with 5 states >266gap> AlphabetOfAutomaton(a);2673268gap> AlphabetOfAutomatonAsList(a);269"cat"270gap> a:=RandomAutomaton("det",5,20);271< deterministic automaton on 20 letters with 5 states >272gap> AlphabetOfAutomaton(a);27320274gap> AlphabetOfAutomatonAsList(a);275"abcdefghijklmnopqrst"276gap> a:=RandomAutomaton("det",5,30);277< deterministic automaton on 30 letters with 5 states >278gap> AlphabetOfAutomaton(a);27930280gap> AlphabetOfAutomatonAsList(a);281[ "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11",282"a12", "a13", "a14", "a15", "a16", "a17", "a18", "a19", "a20", "a21",283"a22", "a23", "a24", "a25", "a26", "a27", "a28", "a29", "a30" ]284]]></Example>285</Description> </ManSection>286287288289<ManSection>290<Func Name="TransitionMatrixOfAutomaton" Arg="aut"/>291<Description>292293Returns the transition matrix of automaton <C>aut</C>.294<Example><![CDATA[295gap> aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;296gap> TransitionMatrixOfAutomaton(aut);297[ [ 3, 0, 3, 4 ], [ 3, 4, 0, 0 ] ]298]]></Example>299</Description> </ManSection>300301302<ManSection>303<Func Name="InitialStatesOfAutomaton" Arg="aut"/>304<Description>305306Returns the initial states of automaton <C>aut</C>.307<Example><![CDATA[308gap> aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;309gap> InitialStatesOfAutomaton(aut);310[ 1 ]311]]></Example>312</Description> </ManSection>313314315<ManSection>316<Func Name="SetInitialStatesOfAutomaton" Arg="aut, I"/>317<Description>318319Sets the initial states of automaton <C>aut</C>.320<C>I</C> may be a positive integer or a list of positive integers.321<Example><![CDATA[322gap> aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;323gap> SetInitialStatesOfAutomaton(aut,4);324gap> InitialStatesOfAutomaton(aut);325[ 4 ]326gap> SetInitialStatesOfAutomaton(aut,[2,3]);327gap> InitialStatesOfAutomaton(aut);328[ 2, 3 ]329]]></Example>330</Description> </ManSection>331332333<ManSection>334<Func Name="FinalStatesOfAutomaton" Arg="aut"/>335<Description>336337Returns the final states of automaton <C>aut</C>.338<Example><![CDATA[339gap> aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;340gap> FinalStatesOfAutomaton(aut);341[ 4 ]342]]></Example>343</Description> </ManSection>344345346<ManSection>347<Func Name="SetFinalStatesOfAutomaton" Arg="aut, F"/>348<Description>349350Sets the final states of automaton <C>aut</C>.351<C>F</C> may be a positive integer or a list of positive integers.352<Example><![CDATA[353gap> aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;354gap> FinalStatesOfAutomaton(aut);355[ 4 ]356gap> SetFinalStatesOfAutomaton(aut,2);357gap> FinalStatesOfAutomaton(aut);358[ 2 ]359]]></Example>360</Description> </ManSection>361362363<ManSection>364<Func Name="NumberStatesOfAutomaton" Arg="aut"/>365<Description>366367Returns the number of states of automaton <C>aut</C>.368<Example><![CDATA[369gap> aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;370gap> NumberStatesOfAutomaton(aut);3714372]]></Example>373</Description> </ManSection>374375</Section>376377378379<Section><Heading>Comparison of automata</Heading>380Although there is no standard way to compare automata it is usefull to be able to do some kind of comparison. Doing so, one can consider sets of automata.381We just compare the strings of the automata.382<Log>383gap> x:=Automaton("det",3,2,[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;384gap> y:=Automaton("det",3,2,[ [ 2, 0, 0 ], [ 1, 3, 0 ] ],[ 3 ],[ 2, 3 ]);;385gap> x=y;386false387gap> Size(Set([y,x,x]));3882389</Log>390</Section>391<Section><Heading>Tests involving automata</Heading>392393This section describes some useful tests involving automata.394395<ManSection>396<Func Name="IsDenseAutomaton" Arg="aut"/>397<Description>398399Tests whether a deterministic automaton <C>aut</C> is complete.400(See also <Ref Func="NullCompletionAutomaton"/>.)401<Example><![CDATA[402gap> aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;403gap> IsDenseAutomaton(aut);404false405]]></Example>406</Description> </ManSection>407408<ManSection>409<Func Name="IsRecognizedByAutomaton" Arg="A,w"/>410<Description>411The arguments are: an automaton <A>A</A> and a string (i.e. a word) <A>w</A> in the alphabet of the automaton.412Returns <C>true</C> if the word is recognized by the automaton413and <C>false</C> otherwise.414415<Example><![CDATA[416gap> aut:=Automaton("det",3,2,[[1,2,1],[2,1,3]],[1],[2]);;417gap> IsRecognizedByAutomaton(aut,"bbb");418true419420gap> aut:=Automaton("det",3,"01",[[1,2,1],[2,1,3]],[1],[2]);;421gap> IsRecognizedByAutomaton(aut,"111");422true423]]></Example>424</Description> </ManSection>425426427<ManSection>428<Func Name="IsPermutationAutomaton" Arg="aut"/>429<Description>430The argument is a deterministic automaton. Returns <K>true</K> when each letter of the alphabet induces a permutation on the vertices and <K>false</K> otherwise. <Example><![CDATA[431gap> x:=Automaton("det",3,2,[ [ 1, 2, 3 ], [ 1, 2, 3 ] ],[ 1 ],[ 2, 3 ]);;432gap> IsPermutationAutomaton(x);433true434]]></Example>435</Description> </ManSection>436437<ManSection>438<Func Name="IsInverseAutomaton" Arg="aut"/>439<Description>440The argument is a deterministic automaton. Returns <K>true</K> when each letter of the alphabet induces an injective partial function on the vertices and <K>false</K> otherwise. <Example><![CDATA[441gap> x:=Automaton("det",3,2,[ [ 0, 1, 3 ], [ 0, 1, 2 ] ],[ 2 ],[ 1 ]);;442gap> IsInverseAutomaton(x);443true444]]></Example>445446Frequently an inverse automaton is thought as if the inverse edges (labeled by formal inverses of the letters of the alphabet) were present, although they are usually not explicited. They can be made explicit using the function <C>AddInverseEdgesToInverseAutomaton</C>447</Description> </ManSection>448449<ManSection>450<Func Name="AddInverseEdgesToInverseAutomaton" Arg="aut"/>451<Description>452The argument is an inverse automaton over the alphabet <M>\{a,b,c,\ldots\}</M>. Returns an automaton with the inverse edges added. (The formal inverse of a letter is represented by the corresponding capital letter.)453<Example><![CDATA[454gap> x:=Automaton("det",3,2,[[ 0, 1, 3 ],[ 0, 1, 2 ]],[ 2 ],[ 1 ]);;Display(x);455| 1 2 3456--------------457a | 1 3458b | 1 2459Initial state: [ 2 ]460Accepting state: [ 1 ]461gap> AddInverseEdgesToInverseAutomaton(x);Display(x);462| 1 2 3463--------------464a | 1 3465b | 1 2466A | 2 3467B | 2 3468Initial state: [ 2 ]469Accepting state: [ 1 ]470]]></Example>471</Description> </ManSection>472473<ManSection>474<Func Name="IsReversibleAutomaton" Arg="aut"/>475<Description>476The argument is a deterministic automaton.477Returns <K>true</K> when <A>aut</A> is a reversible automaton, i.e. the automaton obtained by reversing all edges and switching the initial and final states478(see also <Ref Func="ReversedAutomaton"/>) is deterministic. Returns <K>false</K> otherwise.479<Example><![CDATA[480gap> x:=Automaton("det",3,2,[ [ 0, 1, 2 ], [ 0, 1, 3 ] ],[ 2 ],[ 2 ]);;481gap> IsReversibleAutomaton(x);482true483]]></Example>484</Description> </ManSection>485486</Section>487488<Section><Heading>Basic operations</Heading>489490491<ManSection>492<Func Name="CopyAutomaton" Arg="aut"/>493<Description>494Returns a new automaton, which is a copy of automaton <A>aut</A>.495</Description> </ManSection>496497498<ManSection>499<Func Name="NullCompletionAutomaton" Arg="aut"/>500<Description>501502<C>aut</C> is a deterministic automaton. If it is complete returns <A>aut</A>,503otherwise returns the completion (with a null state) of <A>aut</A>. Notice that the words recognized by <A>aut</A> and its completion are the same.504<Example><![CDATA[505gap> aut:=Automaton("det",4,2,[[3,,3,4],[2,4,4,]],[1],[4]);;506gap> IsDenseAutomaton(aut);507false508gap> y:=NullCompletionAutomaton(aut);;Display(y);509| 1 2 3 4 5510--------------------511a | 3 5 3 4 5512b | 2 4 4 5 5513Initial state: [ 1 ]514Accepting state: [ 4 ]515]]></Example>516517The state added is a <Emph>sink state</Emph> i.e. it is a state <M>q</M> which is not initial nor accepting and for all letter <M>a</M> in the alphabet of the automaton, <M>q</M> is the result of the action of <M>a</M> in <M>q</M>. (Notice that reading518a word, one does not go out of a sink state.)519</Description> </ManSection>520521<ManSection>522<Func Name="ListSinkStatesAut" Arg="aut"/>523<Description>524Computes the list of all sink states of the automaton <A>aut</A>.525<Example><![CDATA[526gap> x:=Automaton("det",3,2,[ [ 2, 3, 3 ], [ 1, 2, 3 ] ],[ 1 ],[ 2, 3 ]);;527gap> ListSinkStatesAut(x);528[ ]529gap> y:=Automaton("det",3,2,[ [ 2, 3, 3 ], [ 1, 2, 3 ] ],[ 1 ],[ 2 ]);;530gap> ListSinkStatesAut(y);531[ 3 ]532]]></Example>533</Description> </ManSection>534535<ManSection>536<Func Name="RemovedSinkStates" Arg="aut"/>537<Description>538Removes all sink states of the automaton <A>aut</A>.539<Example><![CDATA[540gap> y:=Automaton("det",3,2,[[ 2, 3, 3 ],[ 1, 2, 3 ]],[ 1 ],[ 2 ]);;Display(y);541| 1 2 3542--------------543a | 2 3 3544b | 1 2 3545Initial state: [ 1 ]546Accepting state: [ 2 ]547gap> x := RemovedSinkStates(y);Display(x);548< deterministic automaton on 2 letters with 2 states >549| 1 2550-----------551a | 2552b | 1 2553Initial state: [ 1 ]554Accepting state: [ 2 ]555]]></Example>556</Description> </ManSection>557558<ManSection>559<Func Name="ReversedAutomaton" Arg="aut"/>560<Description>561Inverts the arrows of the automaton <A>aut</A>.562<Example><![CDATA[563gap> y:=Automaton("det",3,2,[ [ 2, 3, 3 ], [ 1, 2, 3 ] ],[ 1 ],[ 2 ]);;564gap> z:=ReversedAutomaton(y);;Display(z);565| 1 2 3566------------------------------567a | [ 1 ] [ 2, 3 ]568b | [ 1 ] [ 2 ] [ 3 ]569Initial state: [ 2 ]570Accepting state: [ 1 ]571]]></Example>572</Description> </ManSection>573574575<ManSection>576<Func Name="PermutedAutomaton" Arg="aut, p"/>577<Description>578Given an automaton <A>aut</A> and a list <A>p</A> representing a permutation of the states,579outputs the equivalent permuted automaton.580<Example><![CDATA[581gap> y:=Automaton("det",4,2,[[2,3,4,2],[0,0,0,1]],[1],[3]);;Display(y);582| 1 2 3 4583-----------------584a | 2 3 4 2585b | 1586Initial state: [ 1 ]587Accepting state: [ 3 ]588gap> Display(PermutedAutomaton(y, [3,2,4,1]));589| 1 2 3 4590-----------------591a | 2 4 2 1592b | 3593Initial state: [ 3 ]594Accepting state: [ 4 ]595]]></Example>596</Description> </ManSection>597598599600<ManSection>601<Func Name="ListPermutedAutomata" Arg="aut"/>602<Description>603Given an automaton <A>aut</A>, returns a list of automata with permuted states604<Example><![CDATA[605gap> x:=Automaton("det",3,2,[ [ 0, 2, 3 ], [ 1, 2, 3 ] ],[ 1 ],[ 2, 3 ]);;606gap> ListPermutedAutomata(x);607[ < deterministic automaton on 2 letters with 3 states >,608< deterministic automaton on 2 letters with 3 states >,609< deterministic automaton on 2 letters with 3 states >,610< deterministic automaton on 2 letters with 3 states >,611< deterministic automaton on 2 letters with 3 states >,612< deterministic automaton on 2 letters with 3 states > ]613]]></Example>614</Description> </ManSection>615616617<ManSection>618<Func Name="NormalizedAutomaton" Arg="A"/>619<Description>620Produces an equivalent automaton but in which the initial state is numbered 1 and the accepting states have the greatest numbers.621<Example><![CDATA[622gap> x:=Automaton("det",3,2,[[ 1, 2, 0 ],[ 0, 1, 2 ]],[2],[1, 2]);;Display(x);623| 1 2 3624--------------625a | 1 2626b | 1 2627Initial state: [ 2 ]628Accepting states: [ 1, 2 ]629gap> Display(NormalizedAutomaton(x));630| 1 2 3631--------------632a | 1 3633b | 3 1634Initial state: [ 1 ]635Accepting states: [ 3, 1 ]636]]></Example>637</Description> </ManSection>638639<ManSection>640<Func Name="UnionAutomata" Arg="A,B"/>641<Description>642Produces the disjoint union of the deterministic or non deterministic automata <C>A</C> and <C>B</C>. The output is a non-deterministic automaton.643<Example><![CDATA[644gap> x:=Automaton("det",3,2,[ [ 1, 2, 0 ], [ 0, 1, 2 ] ],[ 2 ],[ 1, 2 ]);;645gap> y:=Automaton("det",3,2,[ [ 0, 1, 3 ], [ 0, 0, 0 ] ],[ 1 ],[ 1, 2, 3 ]);;646gap> UnionAutomata(x,y);647< non deterministic automaton on 2 letters with 6 states >648gap> Display(last);649| 1 2 3 4 5 6650------------------------------------------------651a | [ 1 ] [ 2 ] [ 4 ] [ 6 ]652b | [ 1 ] [ 2 ]653Initial states: [ 2, 4 ]654Accepting states: [ 1, 2, 4, 5, 6 ]655]]></Example>656</Description> </ManSection>657658<ManSection>659<Func Name="ProductAutomaton" Arg="A1,A2"/>660<Description>661The arguments must be deterministic automata. Returns the product of <A>A1</A> and <A>A2</A>.662<P/>663Note: <M>(p,q)->(p-1)m+q</M> is a bijection from <M>\{1,\ldots, n\}\times \{1,\ldots, m\}</M> to <M>\{1,\ldots,mn\}</M>.664<Example><![CDATA[665gap> x:=RandomAutomaton("det",3,2);;Display(x);666| 1 2 3667--------------668a | 2 3669b | 1670Initial state: [ 3 ]671Accepting states: [ 1, 2, 3 ]672gap> y:=RandomAutomaton("det",3,2);;Display(y);673| 1 2 3674--------------675a | 1676b | 1 3677Initial state: [ 3 ]678Accepting states: [ 1, 3 ]679gap> z:=ProductAutomaton(x, y);;Display(z);680| 1 2 3 4 5 6 7 8 9681--------------------------------682a | 4 7683b | 1 3684Initial state: [ 9 ]685Accepting states: [ 1, 3, 4, 6, 7, 9 ]686]]></Example>687</Description>688</ManSection>689690691<ManSection>692<Func Name="ProductOfLanguages" Arg="A1,A2"/>693<Description>694Given two regular languages (as automata or rational expressions),695returns an automaton that recognizes the concatenation of the given696languages, that is, the set of words <M>uv</M> such that697<M>u</M> belongs to the first language and <M>v</M>698belongs to the second language.699<Example><![CDATA[700gap> a1:=ListOfWordsToAutomaton("ab",["aa","bb"]);701< deterministic automaton on 2 letters with 5 states >702gap> a2:=ListOfWordsToAutomaton("ab",["a","b"]);703< deterministic automaton on 2 letters with 3 states >704gap> ProductOfLanguages(a1,a2);705< deterministic automaton on 2 letters with 5 states >706gap> FAtoRatExp(last);707(bbUaa)(aUb)708]]></Example>709</Description>710</ManSection>711712713</Section>714<Section><Heading>Links with Semigroups</Heading>715716Each letter of the alphabet of an automaton induces a partial transformation in its set of717states. The semigroup generated by these transformations is718called the <E>transition semigroup</E> of the automaton.719720<ManSection>721<Func Name="TransitionSemigroup" Arg="aut"/>722<Description>723724Returns the transition semigroup of the deterministic automaton <A>aut</A>.725<Example><![CDATA[726gap> aut := Automaton("det",10,2,[[7,5,7,5,4,9,10,9,10,9],727> [8,6,8,9,9,1,3,1,9,9]],[2],[6,7,8,9,10]);;728gap> s := TransitionSemigroup(aut);;729gap> Size(s);73030731]]></Example>732733The transition semigroup of the minimal automaton recognizing a language is734the {\it syntactic semigroup} of that language.735736</Description> </ManSection>737<ManSection>738<Func Name="SyntacticSemigroupAut" Arg="aut"/>739<Description>740741Returns the syntactic semigroup of the deterministic automaton <A>aut</A> (i.e. the transition semigroup of the equivalent minimal automaton)742when it is non empty and returns <K>fail</K> otherwise.743<Example><![CDATA[744gap> x:=Automaton("det",3,2,[ [ 1, 2, 0 ], [ 0, 1, 2 ] ],[ 2 ],[ 1, 2 ]);;745gap> S:=SyntacticSemigroupAut(x);;746gap> Size(S);7473748]]></Example>749</Description> </ManSection>750<ManSection>751<Func Name="SyntacticSemigroupLang" Arg="rat"/>752<Description>753Returns the syntactic semigroup of the language given by the rational expression <A>rat</A>.754<Example><![CDATA[755gap> rat := RationalExpression("a*ba*ba*(@Ub)");;756gap> S:=SyntacticSemigroupLang(rat);;757gap> Size(S);7587759]]></Example>760</Description> </ManSection>761</Section>762</Chapter>763764765766767