CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

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

Views: 418346
1
% generated by GAPDoc2LaTeX from XML source (Frank Luebeck)
2
\documentclass[a4paper,11pt]{report}
3
4
\usepackage{a4wide}
5
\sloppy
6
\pagestyle{myheadings}
7
\usepackage{amssymb}
8
\usepackage[latin1]{inputenc}
9
\usepackage{makeidx}
10
\makeindex
11
\usepackage{color}
12
\definecolor{FireBrick}{rgb}{0.5812,0.0074,0.0083}
13
\definecolor{RoyalBlue}{rgb}{0.0236,0.0894,0.6179}
14
\definecolor{RoyalGreen}{rgb}{0.0236,0.6179,0.0894}
15
\definecolor{RoyalRed}{rgb}{0.6179,0.0236,0.0894}
16
\definecolor{LightBlue}{rgb}{0.8544,0.9511,1.0000}
17
\definecolor{Black}{rgb}{0.0,0.0,0.0}
18
19
\definecolor{linkColor}{rgb}{0.0,0.0,0.554}
20
\definecolor{citeColor}{rgb}{0.0,0.0,0.554}
21
\definecolor{fileColor}{rgb}{0.0,0.0,0.554}
22
\definecolor{urlColor}{rgb}{0.0,0.0,0.554}
23
\definecolor{promptColor}{rgb}{0.0,0.0,0.589}
24
\definecolor{brkpromptColor}{rgb}{0.589,0.0,0.0}
25
\definecolor{gapinputColor}{rgb}{0.589,0.0,0.0}
26
\definecolor{gapoutputColor}{rgb}{0.0,0.0,0.0}
27
28
%% for a long time these were red and blue by default,
29
%% now black, but keep variables to overwrite
30
\definecolor{FuncColor}{rgb}{0.0,0.0,0.0}
31
%% strange name because of pdflatex bug:
32
\definecolor{Chapter }{rgb}{0.0,0.0,0.0}
33
\definecolor{DarkOlive}{rgb}{0.1047,0.2412,0.0064}
34
35
36
\usepackage{fancyvrb}
37
38
\usepackage{mathptmx,helvet}
39
\usepackage[T1]{fontenc}
40
\usepackage{textcomp}
41
42
43
\usepackage[
44
pdftex=true,
45
bookmarks=true,
46
a4paper=true,
47
pdftitle={Written with GAPDoc},
48
pdfcreator={LaTeX with hyperref package / GAPDoc},
49
colorlinks=true,
50
backref=page,
51
breaklinks=true,
52
linkcolor=linkColor,
53
citecolor=citeColor,
54
filecolor=fileColor,
55
urlcolor=urlColor,
56
pdfpagemode={UseNone},
57
]{hyperref}
58
59
\newcommand{\maintitlesize}{\fontsize{50}{55}\selectfont}
60
61
% write page numbers to a .pnr log file for online help
62
\newwrite\pagenrlog
63
\immediate\openout\pagenrlog =\jobname.pnr
64
\immediate\write\pagenrlog{PAGENRS := [}
65
\newcommand{\logpage}[1]{\protect\write\pagenrlog{#1, \thepage,}}
66
%% were never documented, give conflicts with some additional packages
67
68
\newcommand{\GAP}{\textsf{GAP}}
69
70
%% nicer description environments, allows long labels
71
\usepackage{enumitem}
72
\setdescription{style=nextline}
73
74
%% depth of toc
75
\setcounter{tocdepth}{1}
76
77
78
79
\usepackage{graphicx}
80
81
%% command for ColorPrompt style examples
82
\newcommand{\gapprompt}[1]{\color{promptColor}{\bfseries #1}}
83
\newcommand{\gapbrkprompt}[1]{\color{brkpromptColor}{\bfseries #1}}
84
\newcommand{\gapinput}[1]{\color{gapinputColor}{#1}}
85
86
87
\begin{document}
88
89
\logpage{[ 0, 0, 0 ]}
90
\begin{titlepage}
91
\mbox{}\vfill
92
93
\begin{center}{\maintitlesize \textbf{Automata\mbox{}}}\\
94
\vfill
95
96
\hypersetup{pdftitle=Automata}
97
\markright{\scriptsize \mbox{}\hfill Automata \hfill\mbox{}}
98
{\Huge ( Version 1.13 ) \mbox{}}\\[1cm]
99
\mbox{}\\[2cm]
100
{\Large \textbf{ Manuel Delgado \mbox{}}}\\
101
{\Large \textbf{ Steve Linton \mbox{}}}\\
102
{\Large \textbf{ Jos{\a'e} Jo{\~a}o Morais \mbox{}}}\\
103
\hypersetup{pdfauthor= Manuel Delgado ; Steve Linton ; Jos{\a'e} Jo{\~a}o Morais }
104
\end{center}\vfill
105
106
\mbox{}\\
107
{\mbox{}\\
108
\small \noindent \textbf{ Manuel Delgado } Email: \href{mailto://mdelgado@fc.up.pt} {\texttt{mdelgado@fc.up.pt}}\\
109
Homepage: \href{http://www.fc.up.pt/cmup/mdelgado} {\texttt{http://www.fc.up.pt/cmup/mdelgado}}}\\
110
{\mbox{}\\
111
\small \noindent \textbf{ Steve Linton } Email: \href{mailto://sal@cs.st-andrews.ac.uk} {\texttt{sal@cs.st-andrews.ac.uk}}\\
112
Homepage: \href{http://www-circa.mcs.st-and.ac.uk/~sal/} {\texttt{http://www-circa.mcs.st-and.ac.uk/\texttt{\symbol{126}}sal/}}}\\
113
\end{titlepage}
114
115
\newpage\setcounter{page}{2}
116
{\small
117
\section*{Copyright}
118
\logpage{[ 0, 0, 1 ]}
119
{\copyright} 2004 by Manuel Delgado, Steve Linton and Jos{\a'e} Morais
120
121
We adopt the copyright regulations of \textsf{GAP} as detailed in the copyright notice in the \textsf{GAP} manual. \mbox{}}\\[1cm]
122
{\small
123
\section*{Acknowledgements}
124
\logpage{[ 0, 0, 3 ]}
125
The first author wishes to acknowledge Cyril Nicaud and Paulo Varandas for
126
their help in programming some functions of the very first version of this
127
package. He wishes also to acknowledge useful discussions and comments by
128
Cyril Nicaud, V{\a'\i}tor H. Fernandes, Jean-Eric Pin and Jorge Almeida.
129
130
The first author also acknowledges support of FCT through CMUP and the FCT and
131
POCTI Project POCTI/32817/MAT/2000 which is funded in cooperation with the
132
European Community Fund FEDER.
133
134
The third author acknowledges financial support of FCT and the POCTI program
135
through a scholarship given by Centro de Matem{\a'a}tica da Universidade do
136
Porto.
137
138
The authors would like to thank Mark Kambites for his contribution in finding
139
bugs and making suggestions for the improvement of this package.
140
141
142
143
144
145
Concerning the mantainment:
146
147
148
149
The first author was/is (partially) supported by the FCT project
150
PTDC/MAT/65481/2006 and also by the \emph{Centro de Matem{\a'a}tica da Universidade do Porto} (CMUP), funded by the European Regional Development Fund through the program
151
COMPETE and by the Portuguese Government through the FCT - Funda{\c c}{\~a}o
152
para a Ci{\^e}ncia e a Tecnologia under the project PEst-C/MAT/UI0144/2011. \mbox{}}\\[1cm]
153
{\small
154
\section*{Colophon}
155
\logpage{[ 0, 0, 2 ]}
156
This work started in 1998, when the first author was in the LIAFA at the
157
University of Paris 7, in a post-doc. Encouraged by J. E. Pin, he began the
158
implementation in \textsf{GAP}3 of an algorithm obtained some time before to answer a question from the
159
realm of Finite Semigroups proposed by J. Almeida. It is now part of a
160
separate package: \texttt{finsemi}.
161
162
The first version of this package on automata was prepared by the first author
163
who gave it the form of a \textsf{GAP} share package. In a second version, prepared by the first and third authors,
164
many functions have been added and the performance of many of the existing
165
ones has been improved. Further important improvements, specially concerning
166
performance, have been achieved when the second author joined the group.
167
168
Since Version 1.12, the package is maintained by the first two authors. Bug
169
reports, suggestions and comments are, of course, welcome. Please use our
170
email addresses to this effect. \mbox{}}\\[1cm]
171
\newpage
172
173
\def\contentsname{Contents\logpage{[ 0, 0, 4 ]}}
174
175
\tableofcontents
176
\newpage
177
178
179
\chapter{\textcolor{Chapter }{ Introduction }}\logpage{[ 1, 0, 0 ]}
180
\hyperdef{L}{X7DFB63A97E67C0A1}{}
181
{
182
In many situations an automaton is conveniently described through a diagram
183
like the following
184
185
\begin{figure}[htbp] \begin{center} \leavevmode \includegraphics[bb=0 0 132
186
279]{aut1} \end{center} \label{fig:aut1} \end{figure}
187
188
This diagram describes a (deterministic) automaton with $ 3 $ states (the elements of the set $ \{1,2,3\}). $ The arrow pointing to the state $ 1 $ indicates that $ 1 $ is the initial state and the two circles around state $ 3 $ indicate that $ 3 $ is a final or accepting state. The set $ \{a,b\} $ is the \emph{alphabet} of the automaton; its elements are called \emph{letters} and are the labels of the edges of the diagram. The words $ a $ , $ ab^2 $ , $ b^5a^3b $ are examples of words recognized by the automaton since they are labels of
189
paths from the initial to the final state.
190
191
The set of words recognized by an automaton is called the \emph{language} of the automaton. It is a rational language and may be represented through a
192
rational expression. For instance,
193
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
194
(aUb)(a(aUb)Ub(aUb))*
195
\end{Verbatim}
196
is a rational expression representing the language of the above automaton.
197
198
Kleene's Theorem states that a language is rational if and only if it is the
199
language of a finite automaton. Both directions of Kleene's Theorem can be
200
proved constructively, and these algorithms, to go from an automaton to a
201
rational expression and \emph{vice-versa}, are implemented in this package.
202
203
Of course, one has to pay attention to the size of the output produced. When
204
producing a deterministic automaton equivalent to a given rational expression
205
one can obtain an optimal solution (the minimal automaton) using standard
206
algorithms \cite{AHU:74}.
207
208
When producing a rational expression for the language of an automaton, and
209
taking into account some reasonable measure for the size of a rational
210
expression, to determine a minimal one is apparently computationally
211
difficult. We use here some heuristic methods (to be published elsewhere)
212
which in practice lead to very reasonable results.
213
214
The development of this work has benefited from the existence of AMoRE \cite{AMORE:95}, a package written in \texttt{C} to handle Automata, Monoids and Regular Expressions. In fact, its manual has
215
been very useful and some of the algorithms implemented here are those
216
implemented in AMoRE. In this package, unlike what happened with AMoRE, we do
217
not have to worry about the monoid part in order to make it useful to
218
semigroup theorists, since monoids are already implemented in \textsf{GAP} and we may take advantage of this fact. We just need a function to compute the
219
transition semigroup of an automaton.
220
221
222
223
The parts of this package that have not so directly to do with automata or
224
rational expressions are put into appendices in this manual. Some words about
225
these appendices follow.
226
227
Using the external program Graphviz \cite{KoutsofiosNorth:2002} to graph visualization, one can visualize automata. This very convenient tool
228
presently works easily under LINUX.
229
230
Given a finitely generated subgroup of the free group it is possible to
231
compute a flower automaton and perform Stallings foldings over it in order to
232
obtain an inverse automaton corresponding to the given subgroup.
233
234
}
235
236
237
\chapter{\textcolor{Chapter }{Finite Automata}}\logpage{[ 2, 0, 0 ]}
238
\hyperdef{L}{X811E5FC2849C5644}{}
239
{
240
This chapter describes the representations used in this package for finite
241
automata and some functions to determine information about them.
242
243
We have to remark that the states of an automaton are always named $1,2,3,\ldots;$ the alphabet may be given by the user. By default it is $\{a,b,c,\ldots\}$ (or $\{a_1,a_2,a_3,\ldots\}$ in the case of alphabets with more than $26$ letters).
244
245
The transition function of an automaton with $q$ states over an alphabet with $ n$ letters is represented by a (not necessarily dense) $n\times q$ matrix. Each row of the matrix describes the action of the corresponding
246
letter on the states. In the case of a \emph{deterministic automaton} (DFA) the entries of the matrix are non-negative integers. When all entries of
247
the transition table are positive integers, the automaton is said to be \emph{dense} or \emph{complete}. In the case of a \emph{non deterministic automaton} (NFA) the entries of the matrix may be lists of non-negative integers. \emph{Automata with $\epsilon$-transitions} are also allowed: the last letter of the alphabet is assumed to be $\epsilon$ and is represented by @.
248
\section{\textcolor{Chapter }{Automata generation}}\logpage{[ 2, 1, 0 ]}
249
\hyperdef{L}{X821C3B3687B1F2FF}{}
250
{
251
The way to create an automaton in \textsf{GAP} is the following
252
253
\subsection{\textcolor{Chapter }{Automaton}}
254
\logpage{[ 2, 1, 1 ]}\nobreak
255
\hyperdef{L}{X87D8222D7B50731E}{}
256
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{Automaton({\mdseries\slshape Type, Size, Alphabet, TransitionTable, Initial, Accepting})\index{Automaton@\texttt{Automaton}}
257
\label{Automaton}
258
}\hfill{\scriptsize (function)}}\\
259
260
261
\texttt{Type} may be \texttt{"det"}, \texttt{"nondet"} or \texttt{"epsilon"} according to whether the automaton is deterministic, non deterministic or an
262
automaton with $\epsilon$-transitions. \texttt{Size} is a positive integer representing the number of states of the automaton. \texttt{Alphabet} is the number of letters of the alphabet or a list with the letters of the
263
ordered alphabet. \texttt{TransitionTable} is the transition matrix. The entries are non-negative integers not greater
264
than the size of the automaton. In the case of non deterministic automata,
265
lists of non-negative integers not greater than the size of the automaton are
266
also allowed. \texttt{Initial} and \texttt{Accepting} are, respectively, the lists of initial and accepting states.
267
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
268
269
!gapprompt@gap>B !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,4]],[1],[4]);B
270
< deterministic automaton on 2 letters with 4 states >
271
!gapprompt@gap>B !gapinput@Display(aut);B
272
| 1 2 3 4
273
-----------------
274
a | 3 3 4
275
b | 3 4 4
276
Initial state: [ 1 ]
277
Accepting state: [ 4 ]
278
279
\end{Verbatim}
280
The alphabet of the automaton may be specified:
281
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
282
!gapprompt@gap>B !gapinput@aut:=Automaton("det",4,"01",[[3,,3,4],[3,4,0,4]],[1],[4]);B
283
< deterministic automaton on 2 letters with 4 states >
284
!gapprompt@gap>B !gapinput@Display(aut);B
285
| 1 2 3 4
286
-----------------
287
0 | 3 3 4
288
1 | 3 4 4
289
Initial state: [ 1 ]
290
Accepting state: [ 4 ]
291
\end{Verbatim}
292
Instead of leaving a hole in the transition matrix, we may write a \texttt{0} to mean that no transition is present. Non deterministic automata may be given
293
the same way.
294
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
295
!gapprompt@gap>B !gapinput@ndaut:=Automaton("nondet",4,2,[[3,[1,2],3,0],[3,4,0,[2,3]]],[1],[4]);B
296
< non deterministic automaton on 2 letters with 4 states >
297
!gapprompt@gap>B !gapinput@Display(ndaut);B
298
| 1 2 3 4
299
-----------------------------------------
300
a | [ 3 ] [ 1, 2 ] [ 3 ]
301
b | [ 3 ] [ 4 ] [ 2, 3 ]
302
Initial state: [ 1 ]
303
Accepting state: [ 4 ]
304
\end{Verbatim}
305
Also in the same way can be given $\epsilon$-automata. The letter $\epsilon$ is written \texttt{@} instead.
306
\begin{Verbatim}[commandchars=!BC,fontsize=\small,frame=single,label=Example]
307
!gappromptBgap>C !gapinputBx:=Automaton("epsilon",3,"01@",[[,[2],[3]],[[1,3],,[1]],[[1],[2],C
308
!gappromptB>C !gapinputB[2]]],[2],[2,3]);C
309
< epsilon automaton on 3 letters with 3 states >
310
!gappromptBgap>C !gapinputBDisplay(x);C
311
| 1 2 3
312
------------------------------
313
0 | [ 2 ] [ 3 ]
314
1 | [ 1, 3 ] [ 1 ]
315
@ | [ 1 ] [ 2 ] [ 2 ]
316
Initial state: [ 2 ]
317
Accepting states: [ 2, 3 ]
318
\end{Verbatim}
319
Bigger automata are displayed in another form:
320
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
321
!gapprompt@gap>| !gapinput@aut:=Automaton("det",16,2,[[4,0,0,6,3,1,4,8,7,4,3,0,6,1,6,0],|
322
!gapprompt@>| !gapinput@[3,4,0,0,6,1,0,6,1,6,1,6,6,4,8,7,4,5]],[1],[4]);|
323
< deterministic automaton on 2 letters with 16 states >
324
!gapprompt@gap>| !gapinput@Display(aut);|
325
1 a 4
326
1 b 3
327
2 b 4
328
... some more lines
329
15 a 6
330
15 b 8
331
16 b 7
332
Initial state: [ 1 ]
333
Accepting state: [ 4 ]
334
\end{Verbatim}
335
}
336
337
338
339
\subsection{\textcolor{Chapter }{IsAutomaton}}
340
\logpage{[ 2, 1, 2 ]}\nobreak
341
\hyperdef{L}{X83CCDEF9814F1E6D}{}
342
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsAutomaton({\mdseries\slshape O})\index{IsAutomaton@\texttt{IsAutomaton}}
343
\label{IsAutomaton}
344
}\hfill{\scriptsize (function)}}\\
345
346
347
In the presence of an object \mbox{\texttt{\mdseries\slshape O}}, one may want to test whether \texttt{O} is an automaton. This may be done using the function \texttt{IsAutomaton}.
348
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
349
!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;|
350
!gapprompt@gap>| !gapinput@IsAutomaton(x);|
351
true
352
\end{Verbatim}
353
}
354
355
356
357
\subsection{\textcolor{Chapter }{IsDeterministicAutomaton}}
358
\logpage{[ 2, 1, 3 ]}\nobreak
359
\hyperdef{L}{X7D39CECC7E12DD8A}{}
360
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsDeterministicAutomaton({\mdseries\slshape aut})\index{IsDeterministicAutomaton@\texttt{IsDeterministicAutomaton}}
361
\label{IsDeterministicAutomaton}
362
}\hfill{\scriptsize (function)}}\\
363
364
365
Returns \texttt{true} when \texttt{aut} is a deterministic automaton and \texttt{false} otherwise.
366
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
367
!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;|
368
!gapprompt@gap>| !gapinput@IsDeterministicAutomaton(x);|
369
true
370
\end{Verbatim}
371
}
372
373
374
375
\subsection{\textcolor{Chapter }{IsNonDeterministicAutomaton}}
376
\logpage{[ 2, 1, 4 ]}\nobreak
377
\hyperdef{L}{X83C1148481BAA3DD}{}
378
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsNonDeterministicAutomaton({\mdseries\slshape aut})\index{IsNonDeterministicAutomaton@\texttt{IsNonDeterministicAutomaton}}
379
\label{IsNonDeterministicAutomaton}
380
}\hfill{\scriptsize (function)}}\\
381
382
383
Returns \texttt{true} when \texttt{aut} is a non deterministic automaton and \texttt{false} otherwise.
384
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
385
!gapprompt@gap>| !gapinput@y:=Automaton("nondet",3,2,[[,[1,3],],[,[2,3],[1,3]]],[1,2],[1,3]);;|
386
!gapprompt@gap>| !gapinput@IsNonDeterministicAutomaton(y);|
387
true
388
\end{Verbatim}
389
}
390
391
392
393
\subsection{\textcolor{Chapter }{IsEpsilonAutomaton}}
394
\logpage{[ 2, 1, 5 ]}\nobreak
395
\hyperdef{L}{X81EC5331790D6022}{}
396
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsEpsilonAutomaton({\mdseries\slshape aut})\index{IsEpsilonAutomaton@\texttt{IsEpsilonAutomaton}}
397
\label{IsEpsilonAutomaton}
398
}\hfill{\scriptsize (function)}}\\
399
400
401
Returns \texttt{true} when \texttt{aut} is an $\epsilon$-automaton and \texttt{false} otherwise.
402
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
403
!gapprompt@gap>| !gapinput@z:=Automaton("epsilon",2,2,[[[1,2],],[[2],[1]]],[1,2],[1,2]);;|
404
!gapprompt@gap>| !gapinput@IsEpsilonAutomaton(z);|
405
true
406
\end{Verbatim}
407
}
408
409
410
411
\subsection{\textcolor{Chapter }{String}}
412
\logpage{[ 2, 1, 6 ]}\nobreak
413
\hyperdef{L}{X81FB5BE27903EC32}{}
414
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{String({\mdseries\slshape aut})\index{String@\texttt{String}}
415
\label{String}
416
}\hfill{\scriptsize (function)}}\\
417
418
419
The way \textsf{GAP} displays an automaton is quite natural, but when one wants to do small
420
changes, for example using \emph{copy/paste}, the use of the function \texttt{String} (possibly followed by \texttt{Print}) may be usefull.
421
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
422
!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;|
423
!gapprompt@gap>| !gapinput@String(x);|
424
"Automaton(\"det\",3,\"ab\",[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;"
425
!gapprompt@gap>| !gapinput@Print(String(x));|
426
Automaton("det",3,"ab",[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;
427
\end{Verbatim}
428
429
\begin{Verbatim}[commandchars=!|B,fontsize=\small,frame=single,label=Example]
430
!gapprompt|gap>B !gapinput|z:=Automaton("epsilon",2,2,[[[1,2],],[[2],[1]]],[1,2],[1,2]);;B
431
!gapprompt|gap>B !gapinput|Print(String(z));B
432
Automaton("epsilon",2,"a@",[ [ [ 1, 2 ], [ ] ], [ [ 2 ], [ 1 ] ] ],[ 1, 2 ],[ \
433
1, 2 ]);;
434
\end{Verbatim}
435
}
436
437
438
439
\subsection{\textcolor{Chapter }{RandomAutomaton}}
440
\logpage{[ 2, 1, 7 ]}\nobreak
441
\hyperdef{L}{X801019097C93BCCC}{}
442
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RandomAutomaton({\mdseries\slshape Type, Size, Alphabet})\index{RandomAutomaton@\texttt{RandomAutomaton}}
443
\label{RandomAutomaton}
444
}\hfill{\scriptsize (function)}}\\
445
446
447
Given the \mbox{\texttt{\mdseries\slshape Type}}, the \mbox{\texttt{\mdseries\slshape Size}} (i.e. the number of states) and the \mbox{\texttt{\mdseries\slshape Alphabet}} (a positive integer or a list), returns a pseudo random automaton with these
448
parameters.
449
\begin{Verbatim}[commandchars=!BC,fontsize=\small,frame=single,label=Example]
450
!gappromptBgap>C !gapinputBRandomAutomaton("det",5,"ac");C
451
< deterministic automaton on 2 letters with 5 states >
452
!gappromptBgap>C !gapinputBDisplay(last);C
453
| 1 2 3 4 5
454
--------------------
455
a | 2 3
456
c | 2 3
457
Initial state: [ 4 ]
458
Accepting states: [ 3, 4 ]
459
460
!gappromptBgap>C !gapinputBRandomAutomaton("nondet",3,["a","b","c"]);C
461
< non deterministic automaton on 3 letters with 3 states >
462
463
!gappromptBgap>C !gapinputBRandomAutomaton("epsilon",2,"abc");C
464
< epsilon automaton on 4 letters with 2 states >
465
466
!gappromptBgap>C !gapinputBRandomAutomaton("epsilon",2,2);C
467
< epsilon automaton on 3 letters with 2 states >
468
!gappromptBgap>C !gapinputBDisplay(last);C
469
| 1 2
470
----------------------
471
a | [ 1, 2 ]
472
b | [ 2 ] [ 1 ]
473
@ | [ 1, 2 ]
474
Initial state: [ 2 ]
475
Accepting states: [ 1, 2 ]
476
477
!gappromptBgap>C !gapinputBa:=RandomTransformation(3);;C
478
!gappromptBgap>C !gapinputBb:=RandomTransformation(3);;C
479
!gappromptBgap>C !gapinputBaut:=RandomAutomaton("det",4,[a,b]);C
480
< deterministic automaton on 2 letters with 4 states >
481
\end{Verbatim}
482
}
483
484
}
485
486
487
\section{\textcolor{Chapter }{Automata internals}}\logpage{[ 2, 2, 0 ]}
488
\hyperdef{L}{X80AB906D86BBC153}{}
489
{
490
In this section we describe the functions used to access the internals of an
491
automaton.
492
493
\subsection{\textcolor{Chapter }{AlphabetOfAutomaton}}
494
\logpage{[ 2, 2, 1 ]}\nobreak
495
\hyperdef{L}{X7A34B47778B50FFE}{}
496
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AlphabetOfAutomaton({\mdseries\slshape aut})\index{AlphabetOfAutomaton@\texttt{AlphabetOfAutomaton}}
497
\label{AlphabetOfAutomaton}
498
}\hfill{\scriptsize (function)}}\\
499
500
501
Returns the number of symbols in the alphabet of automaton \texttt{aut}.
502
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
503
!gapprompt@gap>| !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;|
504
!gapprompt@gap>| !gapinput@AlphabetOfAutomaton(aut);|
505
2
506
\end{Verbatim}
507
}
508
509
510
511
\subsection{\textcolor{Chapter }{AlphabetOfAutomatonAsList}}
512
\logpage{[ 2, 2, 2 ]}\nobreak
513
\hyperdef{L}{X8044B24B82C59BBF}{}
514
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AlphabetOfAutomatonAsList({\mdseries\slshape aut})\index{AlphabetOfAutomatonAsList@\texttt{AlphabetOfAutomatonAsList}}
515
\label{AlphabetOfAutomatonAsList}
516
}\hfill{\scriptsize (function)}}\\
517
518
519
Returns the alphabet of automaton \texttt{aut} always as a list. Note that when the alphabet of the automaton is given as an
520
integer (meaning the number of symbols) not greater than 26 it returns the
521
list \texttt{"abcd...."}. If the alphabet is given by means of an integer greater than 26, the
522
function returns \texttt{[ "a1", "a2", "a3", "a4", ... ]}.
523
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
524
!gapprompt@gap>| !gapinput@a:=RandomAutomaton("det",5,"cat");|
525
< deterministic automaton on 3 letters with 5 states >
526
!gapprompt@gap>| !gapinput@AlphabetOfAutomaton(a);|
527
3
528
!gapprompt@gap>| !gapinput@AlphabetOfAutomatonAsList(a);|
529
"cat"
530
!gapprompt@gap>| !gapinput@a:=RandomAutomaton("det",5,20);|
531
< deterministic automaton on 20 letters with 5 states >
532
!gapprompt@gap>| !gapinput@AlphabetOfAutomaton(a);|
533
20
534
!gapprompt@gap>| !gapinput@AlphabetOfAutomatonAsList(a);|
535
"abcdefghijklmnopqrst"
536
!gapprompt@gap>| !gapinput@a:=RandomAutomaton("det",5,30);|
537
< deterministic automaton on 30 letters with 5 states >
538
!gapprompt@gap>| !gapinput@AlphabetOfAutomaton(a);|
539
30
540
!gapprompt@gap>| !gapinput@AlphabetOfAutomatonAsList(a);|
541
[ "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11",
542
"a12", "a13", "a14", "a15", "a16", "a17", "a18", "a19", "a20", "a21",
543
"a22", "a23", "a24", "a25", "a26", "a27", "a28", "a29", "a30" ]
544
\end{Verbatim}
545
}
546
547
548
549
\subsection{\textcolor{Chapter }{TransitionMatrixOfAutomaton}}
550
\logpage{[ 2, 2, 3 ]}\nobreak
551
\hyperdef{L}{X872BB42A81E4D0E7}{}
552
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{TransitionMatrixOfAutomaton({\mdseries\slshape aut})\index{TransitionMatrixOfAutomaton@\texttt{TransitionMatrixOfAutomaton}}
553
\label{TransitionMatrixOfAutomaton}
554
}\hfill{\scriptsize (function)}}\\
555
556
557
Returns the transition matrix of automaton \texttt{aut}.
558
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
559
!gapprompt@gap>| !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;|
560
!gapprompt@gap>| !gapinput@TransitionMatrixOfAutomaton(aut);|
561
[ [ 3, 0, 3, 4 ], [ 3, 4, 0, 0 ] ]
562
\end{Verbatim}
563
}
564
565
566
567
\subsection{\textcolor{Chapter }{InitialStatesOfAutomaton}}
568
\logpage{[ 2, 2, 4 ]}\nobreak
569
\hyperdef{L}{X7B5C3CFA83FF80EA}{}
570
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{InitialStatesOfAutomaton({\mdseries\slshape aut})\index{InitialStatesOfAutomaton@\texttt{InitialStatesOfAutomaton}}
571
\label{InitialStatesOfAutomaton}
572
}\hfill{\scriptsize (function)}}\\
573
574
575
Returns the initial states of automaton \texttt{aut}.
576
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
577
!gapprompt@gap>| !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;|
578
!gapprompt@gap>| !gapinput@InitialStatesOfAutomaton(aut);|
579
[ 1 ]
580
\end{Verbatim}
581
}
582
583
584
585
\subsection{\textcolor{Chapter }{SetInitialStatesOfAutomaton}}
586
\logpage{[ 2, 2, 5 ]}\nobreak
587
\hyperdef{L}{X8408FE8487028B7F}{}
588
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{SetInitialStatesOfAutomaton({\mdseries\slshape aut, I})\index{SetInitialStatesOfAutomaton@\texttt{SetInitialStatesOfAutomaton}}
589
\label{SetInitialStatesOfAutomaton}
590
}\hfill{\scriptsize (function)}}\\
591
592
593
Sets the initial states of automaton \texttt{aut}. \texttt{I} may be a positive integer or a list of positive integers.
594
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
595
!gapprompt@gap>| !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;|
596
!gapprompt@gap>| !gapinput@SetInitialStatesOfAutomaton(aut,4);|
597
!gapprompt@gap>| !gapinput@InitialStatesOfAutomaton(aut);|
598
[ 4 ]
599
!gapprompt@gap>| !gapinput@SetInitialStatesOfAutomaton(aut,[2,3]);|
600
!gapprompt@gap>| !gapinput@InitialStatesOfAutomaton(aut);|
601
[ 2, 3 ]
602
\end{Verbatim}
603
}
604
605
606
607
\subsection{\textcolor{Chapter }{FinalStatesOfAutomaton}}
608
\logpage{[ 2, 2, 6 ]}\nobreak
609
\hyperdef{L}{X78CDDCC27D085F00}{}
610
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{FinalStatesOfAutomaton({\mdseries\slshape aut})\index{FinalStatesOfAutomaton@\texttt{FinalStatesOfAutomaton}}
611
\label{FinalStatesOfAutomaton}
612
}\hfill{\scriptsize (function)}}\\
613
614
615
Returns the final states of automaton \texttt{aut}.
616
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
617
!gapprompt@gap>| !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;|
618
!gapprompt@gap>| !gapinput@FinalStatesOfAutomaton(aut);|
619
[ 4 ]
620
\end{Verbatim}
621
}
622
623
624
625
\subsection{\textcolor{Chapter }{SetFinalStatesOfAutomaton}}
626
\logpage{[ 2, 2, 7 ]}\nobreak
627
\hyperdef{L}{X80689F1480F9D959}{}
628
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{SetFinalStatesOfAutomaton({\mdseries\slshape aut, F})\index{SetFinalStatesOfAutomaton@\texttt{SetFinalStatesOfAutomaton}}
629
\label{SetFinalStatesOfAutomaton}
630
}\hfill{\scriptsize (function)}}\\
631
632
633
Sets the final states of automaton \texttt{aut}. \texttt{F} may be a positive integer or a list of positive integers.
634
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
635
!gapprompt@gap>| !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;|
636
!gapprompt@gap>| !gapinput@FinalStatesOfAutomaton(aut);|
637
[ 4 ]
638
!gapprompt@gap>| !gapinput@SetFinalStatesOfAutomaton(aut,2);|
639
!gapprompt@gap>| !gapinput@FinalStatesOfAutomaton(aut);|
640
[ 2 ]
641
\end{Verbatim}
642
}
643
644
645
646
\subsection{\textcolor{Chapter }{NumberStatesOfAutomaton}}
647
\logpage{[ 2, 2, 8 ]}\nobreak
648
\hyperdef{L}{X7D22AD207A3D5FF4}{}
649
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{NumberStatesOfAutomaton({\mdseries\slshape aut})\index{NumberStatesOfAutomaton@\texttt{NumberStatesOfAutomaton}}
650
\label{NumberStatesOfAutomaton}
651
}\hfill{\scriptsize (function)}}\\
652
653
654
Returns the number of states of automaton \texttt{aut}.
655
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
656
!gapprompt@gap>| !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;|
657
!gapprompt@gap>| !gapinput@NumberStatesOfAutomaton(aut);|
658
4
659
\end{Verbatim}
660
}
661
662
}
663
664
665
\section{\textcolor{Chapter }{Comparison of automata}}\logpage{[ 2, 3, 0 ]}
666
\hyperdef{L}{X8454E24E7D9FC1C2}{}
667
{
668
Although there is no standard way to compare automata it is usefull to be able
669
to do some kind of comparison. Doing so, one can consider sets of automata. We
670
just compare the strings of the automata.
671
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
672
!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;|
673
!gapprompt@gap>| !gapinput@y:=Automaton("det",3,2,[ [ 2, 0, 0 ], [ 1, 3, 0 ] ],[ 3 ],[ 2, 3 ]);;|
674
!gapprompt@gap>| !gapinput@x=y;|
675
false
676
!gapprompt@gap>| !gapinput@Size(Set([y,x,x]));|
677
2
678
\end{Verbatim}
679
}
680
681
682
\section{\textcolor{Chapter }{Tests involving automata}}\logpage{[ 2, 4, 0 ]}
683
\hyperdef{L}{X867887A683961C63}{}
684
{
685
This section describes some useful tests involving automata.
686
687
\subsection{\textcolor{Chapter }{IsDenseAutomaton}}
688
\logpage{[ 2, 4, 1 ]}\nobreak
689
\hyperdef{L}{X8356E41086482483}{}
690
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsDenseAutomaton({\mdseries\slshape aut})\index{IsDenseAutomaton@\texttt{IsDenseAutomaton}}
691
\label{IsDenseAutomaton}
692
}\hfill{\scriptsize (function)}}\\
693
694
695
Tests whether a deterministic automaton \texttt{aut} is complete. (See also \texttt{NullCompletionAutomaton} (\ref{NullCompletionAutomaton}).)
696
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
697
!gapprompt@gap>| !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;|
698
!gapprompt@gap>| !gapinput@IsDenseAutomaton(aut); |
699
false
700
\end{Verbatim}
701
}
702
703
704
705
\subsection{\textcolor{Chapter }{IsRecognizedByAutomaton}}
706
\logpage{[ 2, 4, 2 ]}\nobreak
707
\hyperdef{L}{X8676D8388053F1E7}{}
708
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsRecognizedByAutomaton({\mdseries\slshape A, w})\index{IsRecognizedByAutomaton@\texttt{IsRecognizedByAutomaton}}
709
\label{IsRecognizedByAutomaton}
710
}\hfill{\scriptsize (function)}}\\
711
712
713
The arguments are: an automaton \mbox{\texttt{\mdseries\slshape A}} and a string (i.e. a word) \mbox{\texttt{\mdseries\slshape w}} in the alphabet of the automaton. Returns \texttt{true} if the word is recognized by the automaton and \texttt{false} otherwise.
714
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
715
!gapprompt@gap>| !gapinput@aut:=Automaton("det",3,2,[[1,2,1],[2,1,3]],[1],[2]);;|
716
!gapprompt@gap>| !gapinput@IsRecognizedByAutomaton(aut,"bbb");|
717
true
718
719
!gapprompt@gap>| !gapinput@aut:=Automaton("det",3,"01",[[1,2,1],[2,1,3]],[1],[2]);;|
720
!gapprompt@gap>| !gapinput@IsRecognizedByAutomaton(aut,"111");|
721
true
722
\end{Verbatim}
723
}
724
725
726
727
\subsection{\textcolor{Chapter }{IsPermutationAutomaton}}
728
\logpage{[ 2, 4, 3 ]}\nobreak
729
\hyperdef{L}{X80CCDD438258CD25}{}
730
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsPermutationAutomaton({\mdseries\slshape aut})\index{IsPermutationAutomaton@\texttt{IsPermutationAutomaton}}
731
\label{IsPermutationAutomaton}
732
}\hfill{\scriptsize (function)}}\\
733
734
735
The argument is a deterministic automaton. Returns \texttt{true} when each letter of the alphabet induces a permutation on the vertices and \texttt{false} otherwise.
736
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
737
!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 1, 2, 3 ], [ 1, 2, 3 ] ],[ 1 ],[ 2, 3 ]);;|
738
!gapprompt@gap>| !gapinput@IsPermutationAutomaton(x);|
739
true
740
\end{Verbatim}
741
}
742
743
744
745
\subsection{\textcolor{Chapter }{IsInverseAutomaton}}
746
\logpage{[ 2, 4, 4 ]}\nobreak
747
\hyperdef{L}{X7B7CA23680888C9C}{}
748
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsInverseAutomaton({\mdseries\slshape aut})\index{IsInverseAutomaton@\texttt{IsInverseAutomaton}}
749
\label{IsInverseAutomaton}
750
}\hfill{\scriptsize (function)}}\\
751
752
753
The argument is a deterministic automaton. Returns \texttt{true} when each letter of the alphabet induces an injective partial function on the
754
vertices and \texttt{false} otherwise.
755
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
756
!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 0, 1, 3 ], [ 0, 1, 2 ] ],[ 2 ],[ 1 ]);;|
757
!gapprompt@gap>| !gapinput@IsInverseAutomaton(x);|
758
true
759
\end{Verbatim}
760
Frequently an inverse automaton is thought as if the inverse edges (labeled by
761
formal inverses of the letters of the alphabet) were present, although they
762
are usually not explicited. They can be made explicit using the function \texttt{AddInverseEdgesToInverseAutomaton} }
763
764
765
766
\subsection{\textcolor{Chapter }{AddInverseEdgesToInverseAutomaton}}
767
\logpage{[ 2, 4, 5 ]}\nobreak
768
\hyperdef{L}{X7A4CDEFB84B97849}{}
769
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AddInverseEdgesToInverseAutomaton({\mdseries\slshape aut})\index{AddInverseEdgesToInverseAutomaton@\texttt{AddInverseEdgesToInverseAutomaton}}
770
\label{AddInverseEdgesToInverseAutomaton}
771
}\hfill{\scriptsize (function)}}\\
772
773
774
The argument is an inverse automaton over the alphabet $\{a,b,c,\ldots\}$. Returns an automaton with the inverse edges added. (The formal inverse of a
775
letter is represented by the corresponding capital letter.)
776
\begin{Verbatim}[commandchars=!@C,fontsize=\small,frame=single,label=Example]
777
!gapprompt@gap>C !gapinput@x:=Automaton("det",3,2,[[ 0, 1, 3 ],[ 0, 1, 2 ]],[ 2 ],[ 1 ]);;Display(x);C
778
| 1 2 3
779
--------------
780
a | 1 3
781
b | 1 2
782
Initial state: [ 2 ]
783
Accepting state: [ 1 ]
784
!gapprompt@gap>C !gapinput@AddInverseEdgesToInverseAutomaton(x);Display(x);C
785
| 1 2 3
786
--------------
787
a | 1 3
788
b | 1 2
789
A | 2 3
790
B | 2 3
791
Initial state: [ 2 ]
792
Accepting state: [ 1 ]
793
\end{Verbatim}
794
}
795
796
797
798
\subsection{\textcolor{Chapter }{IsReversibleAutomaton}}
799
\logpage{[ 2, 4, 6 ]}\nobreak
800
\hyperdef{L}{X8321BCE57E55FB30}{}
801
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsReversibleAutomaton({\mdseries\slshape aut})\index{IsReversibleAutomaton@\texttt{IsReversibleAutomaton}}
802
\label{IsReversibleAutomaton}
803
}\hfill{\scriptsize (function)}}\\
804
805
806
The argument is a deterministic automaton. Returns \texttt{true} when \mbox{\texttt{\mdseries\slshape aut}} is a reversible automaton, i.e. the automaton obtained by reversing all edges
807
and switching the initial and final states (see also \texttt{ReversedAutomaton} (\ref{ReversedAutomaton})) is deterministic. Returns \texttt{false} otherwise.
808
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
809
!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 0, 1, 2 ], [ 0, 1, 3 ] ],[ 2 ],[ 2 ]);;|
810
!gapprompt@gap>| !gapinput@IsReversibleAutomaton(x);|
811
true
812
\end{Verbatim}
813
}
814
815
}
816
817
818
\section{\textcolor{Chapter }{Basic operations}}\logpage{[ 2, 5, 0 ]}
819
\hyperdef{L}{X82EB5BE77F9F686A}{}
820
{
821
822
823
\subsection{\textcolor{Chapter }{CopyAutomaton}}
824
\logpage{[ 2, 5, 1 ]}\nobreak
825
\hyperdef{L}{X8225A1B886131707}{}
826
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{CopyAutomaton({\mdseries\slshape aut})\index{CopyAutomaton@\texttt{CopyAutomaton}}
827
\label{CopyAutomaton}
828
}\hfill{\scriptsize (function)}}\\
829
830
831
Returns a new automaton, which is a copy of automaton \mbox{\texttt{\mdseries\slshape aut}}. }
832
833
834
835
\subsection{\textcolor{Chapter }{NullCompletionAutomaton}}
836
\logpage{[ 2, 5, 2 ]}\nobreak
837
\hyperdef{L}{X80D423A584246E2E}{}
838
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{NullCompletionAutomaton({\mdseries\slshape aut})\index{NullCompletionAutomaton@\texttt{NullCompletionAutomaton}}
839
\label{NullCompletionAutomaton}
840
}\hfill{\scriptsize (function)}}\\
841
842
843
\texttt{aut} is a deterministic automaton. If it is complete returns \mbox{\texttt{\mdseries\slshape aut}}, otherwise returns the completion (with a null state) of \mbox{\texttt{\mdseries\slshape aut}}. Notice that the words recognized by \mbox{\texttt{\mdseries\slshape aut}} and its completion are the same.
844
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
845
!gapprompt@gap>B !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[2,4,4,]],[1],[4]);;B
846
!gapprompt@gap>B !gapinput@IsDenseAutomaton(aut);B
847
false
848
!gapprompt@gap>B !gapinput@y:=NullCompletionAutomaton(aut);;Display(y);B
849
| 1 2 3 4 5
850
--------------------
851
a | 3 5 3 4 5
852
b | 2 4 4 5 5
853
Initial state: [ 1 ]
854
Accepting state: [ 4 ]
855
\end{Verbatim}
856
The state added is a \emph{sink state} i.e. it is a state $q$ which is not initial nor accepting and for all letter $a$ in the alphabet of the automaton, $q$ is the result of the action of $a$ in $q$. (Notice that reading a word, one does not go out of a sink state.) }
857
858
859
860
\subsection{\textcolor{Chapter }{ListSinkStatesAut}}
861
\logpage{[ 2, 5, 3 ]}\nobreak
862
\hyperdef{L}{X79F052EC81135807}{}
863
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ListSinkStatesAut({\mdseries\slshape aut})\index{ListSinkStatesAut@\texttt{ListSinkStatesAut}}
864
\label{ListSinkStatesAut}
865
}\hfill{\scriptsize (function)}}\\
866
867
868
Computes the list of all sink states of the automaton \mbox{\texttt{\mdseries\slshape aut}}.
869
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
870
!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 2, 3, 3 ], [ 1, 2, 3 ] ],[ 1 ],[ 2, 3 ]);;|
871
!gapprompt@gap>| !gapinput@ListSinkStatesAut(x);|
872
[ ]
873
!gapprompt@gap>| !gapinput@y:=Automaton("det",3,2,[ [ 2, 3, 3 ], [ 1, 2, 3 ] ],[ 1 ],[ 2 ]);;|
874
!gapprompt@gap>| !gapinput@ListSinkStatesAut(y);|
875
[ 3 ]
876
\end{Verbatim}
877
}
878
879
880
881
\subsection{\textcolor{Chapter }{RemovedSinkStates}}
882
\logpage{[ 2, 5, 4 ]}\nobreak
883
\hyperdef{L}{X8240136E7A26B1A6}{}
884
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RemovedSinkStates({\mdseries\slshape aut})\index{RemovedSinkStates@\texttt{RemovedSinkStates}}
885
\label{RemovedSinkStates}
886
}\hfill{\scriptsize (function)}}\\
887
888
889
Removes all sink states of the automaton \mbox{\texttt{\mdseries\slshape aut}}.
890
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
891
!gapprompt@gap>B !gapinput@y:=Automaton("det",3,2,[[ 2, 3, 3 ],[ 1, 2, 3 ]],[ 1 ],[ 2 ]);;Display(y);B
892
| 1 2 3
893
--------------
894
a | 2 3 3
895
b | 1 2 3
896
Initial state: [ 1 ]
897
Accepting state: [ 2 ]
898
!gapprompt@gap>B !gapinput@x := RemovedSinkStates(y);Display(x);B
899
< deterministic automaton on 2 letters with 2 states >
900
| 1 2
901
-----------
902
a | 2
903
b | 1 2
904
Initial state: [ 1 ]
905
Accepting state: [ 2 ]
906
\end{Verbatim}
907
}
908
909
910
911
\subsection{\textcolor{Chapter }{ReversedAutomaton}}
912
\logpage{[ 2, 5, 5 ]}\nobreak
913
\hyperdef{L}{X7C0526217BFE7A65}{}
914
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ReversedAutomaton({\mdseries\slshape aut})\index{ReversedAutomaton@\texttt{ReversedAutomaton}}
915
\label{ReversedAutomaton}
916
}\hfill{\scriptsize (function)}}\\
917
918
919
Inverts the arrows of the automaton \mbox{\texttt{\mdseries\slshape aut}}.
920
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
921
!gapprompt@gap>B !gapinput@y:=Automaton("det",3,2,[ [ 2, 3, 3 ], [ 1, 2, 3 ] ],[ 1 ],[ 2 ]);;B
922
!gapprompt@gap>B !gapinput@z:=ReversedAutomaton(y);;Display(z);B
923
| 1 2 3
924
------------------------------
925
a | [ 1 ] [ 2, 3 ]
926
b | [ 1 ] [ 2 ] [ 3 ]
927
Initial state: [ 2 ]
928
Accepting state: [ 1 ]
929
\end{Verbatim}
930
}
931
932
933
934
\subsection{\textcolor{Chapter }{PermutedAutomaton}}
935
\logpage{[ 2, 5, 6 ]}\nobreak
936
\hyperdef{L}{X7A4A066583C71ABE}{}
937
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{PermutedAutomaton({\mdseries\slshape aut, p})\index{PermutedAutomaton@\texttt{PermutedAutomaton}}
938
\label{PermutedAutomaton}
939
}\hfill{\scriptsize (function)}}\\
940
941
942
Given an automaton \mbox{\texttt{\mdseries\slshape aut}} and a list \mbox{\texttt{\mdseries\slshape p}} representing a permutation of the states, outputs the equivalent permuted
943
automaton.
944
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
945
!gapprompt@gap>B !gapinput@y:=Automaton("det",4,2,[[2,3,4,2],[0,0,0,1]],[1],[3]);;Display(y);B
946
| 1 2 3 4
947
-----------------
948
a | 2 3 4 2
949
b | 1
950
Initial state: [ 1 ]
951
Accepting state: [ 3 ]
952
!gapprompt@gap>B !gapinput@Display(PermutedAutomaton(y, [3,2,4,1]));B
953
| 1 2 3 4
954
-----------------
955
a | 2 4 2 1
956
b | 3
957
Initial state: [ 3 ]
958
Accepting state: [ 4 ]
959
\end{Verbatim}
960
}
961
962
963
964
\subsection{\textcolor{Chapter }{ListPermutedAutomata}}
965
\logpage{[ 2, 5, 7 ]}\nobreak
966
\hyperdef{L}{X7A72DDF0782E8D5E}{}
967
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ListPermutedAutomata({\mdseries\slshape aut})\index{ListPermutedAutomata@\texttt{ListPermutedAutomata}}
968
\label{ListPermutedAutomata}
969
}\hfill{\scriptsize (function)}}\\
970
971
972
Given an automaton \mbox{\texttt{\mdseries\slshape aut}}, returns a list of automata with permuted states
973
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
974
!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 0, 2, 3 ], [ 1, 2, 3 ] ],[ 1 ],[ 2, 3 ]);;|
975
!gapprompt@gap>| !gapinput@ListPermutedAutomata(x);|
976
[ < deterministic automaton on 2 letters with 3 states >,
977
< deterministic automaton on 2 letters with 3 states >,
978
< deterministic automaton on 2 letters with 3 states >,
979
< deterministic automaton on 2 letters with 3 states >,
980
< deterministic automaton on 2 letters with 3 states >,
981
< deterministic automaton on 2 letters with 3 states > ]
982
\end{Verbatim}
983
}
984
985
986
987
\subsection{\textcolor{Chapter }{NormalizedAutomaton}}
988
\logpage{[ 2, 5, 8 ]}\nobreak
989
\hyperdef{L}{X7FA7DF6D87D63D67}{}
990
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{NormalizedAutomaton({\mdseries\slshape A})\index{NormalizedAutomaton@\texttt{NormalizedAutomaton}}
991
\label{NormalizedAutomaton}
992
}\hfill{\scriptsize (function)}}\\
993
994
995
Produces an equivalent automaton but in which the initial state is numbered 1
996
and the accepting states have the greatest numbers.
997
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
998
!gapprompt@gap>B !gapinput@x:=Automaton("det",3,2,[[ 1, 2, 0 ],[ 0, 1, 2 ]],[2],[1, 2]);;Display(x);B
999
| 1 2 3
1000
--------------
1001
a | 1 2
1002
b | 1 2
1003
Initial state: [ 2 ]
1004
Accepting states: [ 1, 2 ]
1005
!gapprompt@gap>B !gapinput@Display(NormalizedAutomaton(x));B
1006
| 1 2 3
1007
--------------
1008
a | 1 3
1009
b | 3 1
1010
Initial state: [ 1 ]
1011
Accepting states: [ 3, 1 ]
1012
\end{Verbatim}
1013
}
1014
1015
1016
1017
\subsection{\textcolor{Chapter }{UnionAutomata}}
1018
\logpage{[ 2, 5, 9 ]}\nobreak
1019
\hyperdef{L}{X7A94A77A7C65BA90}{}
1020
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{UnionAutomata({\mdseries\slshape A, B})\index{UnionAutomata@\texttt{UnionAutomata}}
1021
\label{UnionAutomata}
1022
}\hfill{\scriptsize (function)}}\\
1023
1024
1025
Produces the disjoint union of the deterministic or non deterministic automata \texttt{A} and \texttt{B}. The output is a non-deterministic automaton.
1026
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
1027
!gapprompt@gap>B !gapinput@x:=Automaton("det",3,2,[ [ 1, 2, 0 ], [ 0, 1, 2 ] ],[ 2 ],[ 1, 2 ]);;B
1028
!gapprompt@gap>B !gapinput@y:=Automaton("det",3,2,[ [ 0, 1, 3 ], [ 0, 0, 0 ] ],[ 1 ],[ 1, 2, 3 ]);;B
1029
!gapprompt@gap>B !gapinput@UnionAutomata(x,y);B
1030
< non deterministic automaton on 2 letters with 6 states >
1031
!gapprompt@gap>B !gapinput@Display(last);B
1032
| 1 2 3 4 5 6
1033
------------------------------------------------
1034
a | [ 1 ] [ 2 ] [ 4 ] [ 6 ]
1035
b | [ 1 ] [ 2 ]
1036
Initial states: [ 2, 4 ]
1037
Accepting states: [ 1, 2, 4, 5, 6 ]
1038
\end{Verbatim}
1039
}
1040
1041
1042
1043
\subsection{\textcolor{Chapter }{ProductAutomaton}}
1044
\logpage{[ 2, 5, 10 ]}\nobreak
1045
\hyperdef{L}{X83E772F2878546A4}{}
1046
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ProductAutomaton({\mdseries\slshape A1, A2})\index{ProductAutomaton@\texttt{ProductAutomaton}}
1047
\label{ProductAutomaton}
1048
}\hfill{\scriptsize (function)}}\\
1049
1050
1051
The arguments must be deterministic automata. Returns the product of \mbox{\texttt{\mdseries\slshape A1}} and \mbox{\texttt{\mdseries\slshape A2}}.
1052
1053
Note: $(p,q)->(p-1)m+q$ is a bijection from $\{1,\ldots, n\}\times \{1,\ldots, m\}$ to $\{1,\ldots,mn\}$.
1054
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
1055
!gapprompt@gap>B !gapinput@x:=RandomAutomaton("det",3,2);;Display(x);B
1056
| 1 2 3
1057
--------------
1058
a | 2 3
1059
b | 1
1060
Initial state: [ 3 ]
1061
Accepting states: [ 1, 2, 3 ]
1062
!gapprompt@gap>B !gapinput@y:=RandomAutomaton("det",3,2);;Display(y);B
1063
| 1 2 3
1064
--------------
1065
a | 1
1066
b | 1 3
1067
Initial state: [ 3 ]
1068
Accepting states: [ 1, 3 ]
1069
!gapprompt@gap>B !gapinput@z:=ProductAutomaton(x, y);;Display(z);B
1070
| 1 2 3 4 5 6 7 8 9
1071
--------------------------------
1072
a | 4 7
1073
b | 1 3
1074
Initial state: [ 9 ]
1075
Accepting states: [ 1, 3, 4, 6, 7, 9 ]
1076
\end{Verbatim}
1077
}
1078
1079
1080
1081
\subsection{\textcolor{Chapter }{ProductOfLanguages}}
1082
\logpage{[ 2, 5, 11 ]}\nobreak
1083
\hyperdef{L}{X85F6AD697DCA5765}{}
1084
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ProductOfLanguages({\mdseries\slshape A1, A2})\index{ProductOfLanguages@\texttt{ProductOfLanguages}}
1085
\label{ProductOfLanguages}
1086
}\hfill{\scriptsize (function)}}\\
1087
1088
1089
Given two regular languages (as automata or rational expressions), returns an
1090
automaton that recognizes the concatenation of the given languages, that is,
1091
the set of words $uv$ such that $u$ belongs to the first language and $v$ belongs to the second language.
1092
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
1093
!gapprompt@gap>| !gapinput@a1:=ListOfWordsToAutomaton("ab",["aa","bb"]);|
1094
< deterministic automaton on 2 letters with 5 states >
1095
!gapprompt@gap>| !gapinput@a2:=ListOfWordsToAutomaton("ab",["a","b"]);|
1096
< deterministic automaton on 2 letters with 3 states >
1097
!gapprompt@gap>| !gapinput@ProductOfLanguages(a1,a2);|
1098
< deterministic automaton on 2 letters with 5 states >
1099
!gapprompt@gap>| !gapinput@FAtoRatExp(last);|
1100
(bbUaa)(aUb)
1101
\end{Verbatim}
1102
}
1103
1104
}
1105
1106
1107
\section{\textcolor{Chapter }{Links with Semigroups}}\logpage{[ 2, 6, 0 ]}
1108
\hyperdef{L}{X79F21CB37B34A354}{}
1109
{
1110
Each letter of the alphabet of an automaton induces a partial transformation
1111
in its set of states. The semigroup generated by these transformations is
1112
called the \emph{transition semigroup} of the automaton.
1113
1114
\subsection{\textcolor{Chapter }{TransitionSemigroup}}
1115
\logpage{[ 2, 6, 1 ]}\nobreak
1116
\hyperdef{L}{X7B9994827CF94CC7}{}
1117
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{TransitionSemigroup({\mdseries\slshape aut})\index{TransitionSemigroup@\texttt{TransitionSemigroup}}
1118
\label{TransitionSemigroup}
1119
}\hfill{\scriptsize (function)}}\\
1120
1121
1122
Returns the transition semigroup of the deterministic automaton \mbox{\texttt{\mdseries\slshape aut}}.
1123
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
1124
!gapprompt@gap>| !gapinput@aut := Automaton("det",10,2,[[7,5,7,5,4,9,10,9,10,9],|
1125
!gapprompt@>| !gapinput@[8,6,8,9,9,1,3,1,9,9]],[2],[6,7,8,9,10]);;|
1126
!gapprompt@gap>| !gapinput@s := TransitionSemigroup(aut);; |
1127
!gapprompt@gap>| !gapinput@Size(s); |
1128
30
1129
\end{Verbatim}
1130
The transition semigroup of the minimal automaton recognizing a language is
1131
the \texttt{\symbol{123}}\texttt{\symbol{92}}it syntactic
1132
semigroup\texttt{\symbol{125}} of that language. }
1133
1134
1135
1136
\subsection{\textcolor{Chapter }{SyntacticSemigroupAut}}
1137
\logpage{[ 2, 6, 2 ]}\nobreak
1138
\hyperdef{L}{X7E3F29DF86A26347}{}
1139
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{SyntacticSemigroupAut({\mdseries\slshape aut})\index{SyntacticSemigroupAut@\texttt{SyntacticSemigroupAut}}
1140
\label{SyntacticSemigroupAut}
1141
}\hfill{\scriptsize (function)}}\\
1142
1143
1144
Returns the syntactic semigroup of the deterministic automaton \mbox{\texttt{\mdseries\slshape aut}} (i.e. the transition semigroup of the equivalent minimal automaton) when it is
1145
non empty and returns \texttt{fail} otherwise.
1146
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
1147
!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 1, 2, 0 ], [ 0, 1, 2 ] ],[ 2 ],[ 1, 2 ]);;|
1148
!gapprompt@gap>| !gapinput@S:=SyntacticSemigroupAut(x);;|
1149
!gapprompt@gap>| !gapinput@Size(S);|
1150
3
1151
\end{Verbatim}
1152
}
1153
1154
1155
1156
\subsection{\textcolor{Chapter }{SyntacticSemigroupLang}}
1157
\logpage{[ 2, 6, 3 ]}\nobreak
1158
\hyperdef{L}{X7D058F0D83D7B49B}{}
1159
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{SyntacticSemigroupLang({\mdseries\slshape rat})\index{SyntacticSemigroupLang@\texttt{SyntacticSemigroupLang}}
1160
\label{SyntacticSemigroupLang}
1161
}\hfill{\scriptsize (function)}}\\
1162
1163
1164
Returns the syntactic semigroup of the language given by the rational
1165
expression \mbox{\texttt{\mdseries\slshape rat}}.
1166
\begin{Verbatim}[commandchars=!|A,fontsize=\small,frame=single,label=Example]
1167
!gapprompt|gap>A !gapinput|rat := RationalExpression("a*ba*ba*(@Ub)");;A
1168
!gapprompt|gap>A !gapinput|S:=SyntacticSemigroupLang(rat);;A
1169
!gapprompt|gap>A !gapinput|Size(S);A
1170
7
1171
\end{Verbatim}
1172
}
1173
1174
}
1175
1176
}
1177
1178
1179
\chapter{\textcolor{Chapter }{Rational languages}}\logpage{[ 3, 0, 0 ]}
1180
\hyperdef{L}{X833D315483172905}{}
1181
{
1182
Rational languages are conveniently represented through rational expressions.
1183
These are finite expressions involving letters of the alphabet; \texttt{concatenation}, corresponding to the \emph{product}; the symbol \texttt{U}, corresponding to the \emph{union}; and the symbol \texttt{*}, corresponding to the Kleene's star. \index{rational expressions}
1184
\section{\textcolor{Chapter }{Rational Expressions}}\logpage{[ 3, 1, 0 ]}
1185
\hyperdef{L}{X7C144D368043DE01}{}
1186
{
1187
The expressions \texttt{@} and \texttt{"empty\texttt{\symbol{92}}{\textunderscore}set"} are used to represent the empty word and the empty set respectively.
1188
1189
\subsection{\textcolor{Chapter }{RationalExpression}}
1190
\logpage{[ 3, 1, 1 ]}\nobreak
1191
\hyperdef{L}{X801EC6F38568426D}{}
1192
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RationalExpression({\mdseries\slshape expr[, alph]})\index{RationalExpression@\texttt{RationalExpression}}
1193
\label{RationalExpression}
1194
}\hfill{\scriptsize (function)}}\\
1195
1196
1197
A rational expression can be created using the function \texttt{RationalExpression}. \mbox{\texttt{\mdseries\slshape expr}} is a string representing the desired expression literally and \mbox{\texttt{\mdseries\slshape alph}} (may or may not be present) is the alphabet of the expression. Of course \mbox{\texttt{\mdseries\slshape alph}} must not contain the symbols '@', '(', ')', '*' nor 'U'. When \mbox{\texttt{\mdseries\slshape alph}} is not present, the alphabet of the rational expression is the set of symbols
1198
(other than '"', etc...) occurring in the expression. (The alphabet is then
1199
ordered with the alphabetical order.)
1200
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
1201
!gapprompt@gap>| !gapinput@RationalExpression("abUc");|
1202
abUc
1203
!gapprompt@gap>| !gapinput@RationalExpression("ab*Uc");|
1204
ab*Uc
1205
!gapprompt@gap>| !gapinput@RationalExpression("001U1*");|
1206
001U1*
1207
!gapprompt@gap>| !gapinput@RationalExpression("001U1*","012");|
1208
001U1*
1209
\end{Verbatim}
1210
}
1211
1212
1213
1214
\subsection{\textcolor{Chapter }{RatExpOnnLetters}}
1215
\logpage{[ 3, 1, 2 ]}\nobreak
1216
\hyperdef{L}{X7EE5A70F7F237C41}{}
1217
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RatExpOnnLetters({\mdseries\slshape n, operation, list})\index{RatExpOnnLetters@\texttt{RatExpOnnLetters}}
1218
\label{RatExpOnnLetters}
1219
}\hfill{\scriptsize (function)}}\\
1220
1221
1222
This is another way to construct a rational expression over an alphabet. The
1223
user may specify the alphabet or just give the number $n$ of letters (in this case the alphabet $\{a,b,c,\ldots\}$ is considered). \mbox{\texttt{\mdseries\slshape operation}} is the name of an operation, the possibilities being: \texttt{product}, \texttt{union} or \texttt{star}. \mbox{\texttt{\mdseries\slshape list}} is a list of rational expressions, a rational expression in the case of
1224
``star'', or a list consisting of an integer when the rational expression is a
1225
single letter. The empty list \texttt{[ ]} and \texttt{empty\texttt{\symbol{92}}{\textunderscore}set} are other possibilities for \texttt{list}. An example follows
1226
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
1227
!gapprompt@gap>| !gapinput@RatExpOnnLetters(2,"star",RatExpOnnLetters(2,"product",|
1228
!gapprompt@>| !gapinput@[RatExpOnnLetters(2,[],[1]),RatExpOnnLetters(2,"union",|
1229
!gapprompt@>| !gapinput@[RatExpOnnLetters(2,[],[1]),RatExpOnnLetters(2,[],[2])])])); |
1230
(a(aUb))*
1231
\end{Verbatim}
1232
The empty word and the empty set are the rational expressions:
1233
\begin{Verbatim}[commandchars=!|A,fontsize=\small,frame=single,label=Example]
1234
!gapprompt|gap>A !gapinput|RatExpOnnLetters(2,[],[]); A
1235
@
1236
!gapprompt|gap>A !gapinput|RatExpOnnLetters(2,[],"empty_set");A
1237
empty_set
1238
\end{Verbatim}
1239
}
1240
1241
1242
1243
\subsection{\textcolor{Chapter }{RandomRatExp}}
1244
\logpage{[ 3, 1, 3 ]}\nobreak
1245
\hyperdef{L}{X7DA59CBE8571796C}{}
1246
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RandomRatExp({\mdseries\slshape arg})\index{RandomRatExp@\texttt{RandomRatExp}}
1247
\label{RandomRatExp}
1248
}\hfill{\scriptsize (function)}}\\
1249
1250
1251
Given the number of symbols of the alphabet and (possibly) a factor $m$ which is intended to increase the randomality of the expression, returns a
1252
pseudo random rational expression over that alphabet.
1253
\begin{Verbatim}[commandchars=!|A,fontsize=\small,frame=single,label=Example]
1254
!gapprompt|gap>A !gapinput|RandomRatExp(2);A
1255
b*(@Ua)
1256
!gapprompt|gap>A !gapinput|RandomRatExp("01");A
1257
empty_set
1258
!gapprompt|gap>A !gapinput|RandomRatExp("01");A
1259
(0U1)*
1260
!gapprompt|gap>A !gapinput|RandomRatExp("01",7);A
1261
0*1(@U0U1)
1262
\end{Verbatim}
1263
}
1264
1265
1266
1267
\subsection{\textcolor{Chapter }{SizeRatExp}}
1268
\logpage{[ 3, 1, 4 ]}\nobreak
1269
\hyperdef{L}{X7E3AA84784019E6C}{}
1270
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{SizeRatExp({\mdseries\slshape r})\index{SizeRatExp@\texttt{SizeRatExp}}
1271
\label{SizeRatExp}
1272
}\hfill{\scriptsize (function)}}\\
1273
1274
1275
Returns the size, i.e. the number of symbols of the alphabet, of the rational
1276
expression \mbox{\texttt{\mdseries\slshape r}}.
1277
\begin{Verbatim}[commandchars=!|A,fontsize=\small,frame=single,label=Example]
1278
!gapprompt|gap>A !gapinput|a:=RationalExpression("0*1(@U0U1)");A
1279
0*1(@U0U1)
1280
!gapprompt|gap>A !gapinput|SizeRatExp(a);A
1281
5
1282
\end{Verbatim}
1283
}
1284
1285
1286
1287
\subsection{\textcolor{Chapter }{IsRationalExpression}}
1288
\logpage{[ 3, 1, 5 ]}\nobreak
1289
\hyperdef{L}{X7DDB46817D6E79BE}{}
1290
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsRationalExpression({\mdseries\slshape r})\index{IsRationalExpression@\texttt{IsRationalExpression}}
1291
\label{IsRationalExpression}
1292
}\hfill{\scriptsize (function)}}\\
1293
1294
1295
Tests whether an object is a rational expression.
1296
\begin{Verbatim}[commandchars=!|A,fontsize=\small,frame=single,label=Example]
1297
!gapprompt|gap>A !gapinput|r := RandomRatExp("01",7);A
1298
1(0U1)U@
1299
!gapprompt|gap>A !gapinput|IsRatExpOnnLettersObj(r) and IsRationalExpressionRep(r);A
1300
true
1301
!gapprompt|gap>A !gapinput|IsRationalExpression(RandomRatExp("01"));A
1302
true
1303
\end{Verbatim}
1304
}
1305
1306
1307
1308
\subsection{\textcolor{Chapter }{AlphabetOfRatExp}}
1309
\logpage{[ 3, 1, 6 ]}\nobreak
1310
\hyperdef{L}{X8773359880149A98}{}
1311
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AlphabetOfRatExp({\mdseries\slshape R})\index{AlphabetOfRatExp@\texttt{AlphabetOfRatExp}}
1312
\label{AlphabetOfRatExp}
1313
}\hfill{\scriptsize (function)}}\\
1314
1315
1316
Returns the number of symbols in the alphabet of the rational expression \texttt{R}.
1317
\begin{Verbatim}[commandchars=!|B,fontsize=\small,frame=single,label=Example]
1318
!gapprompt|gap>B !gapinput|r:=RandomRatExp(2);B
1319
a*(ba*U@)
1320
!gapprompt|gap>B !gapinput|AlphabetOfRatExp(r);B
1321
2
1322
!gapprompt|gap>B !gapinput|r:=RandomRatExp("01");B
1323
1*(01*U@)
1324
!gapprompt|gap>B !gapinput|AlphabetOfRatExp(r);B
1325
2
1326
!gapprompt|gap>B !gapinput|a:=RandomTransformation(3);;B
1327
!gapprompt|gap>B !gapinput|b:=RandomTransformation(3);;B
1328
!gapprompt|gap>B !gapinput|r:=RandomRatExp([a,b]);B
1329
(Transformation( [ 1, 1, 3 ] )UTransformation( [ 1, 1, 2 ] ))*
1330
!gapprompt|gap>B !gapinput|AlphabetOfRatExp(r);B
1331
2
1332
\end{Verbatim}
1333
}
1334
1335
1336
1337
\subsection{\textcolor{Chapter }{AlphabetOfRatExpAsList}}
1338
\logpage{[ 3, 1, 7 ]}\nobreak
1339
\hyperdef{L}{X84B9922B7C006158}{}
1340
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AlphabetOfRatExpAsList({\mdseries\slshape R})\index{AlphabetOfRatExpAsList@\texttt{AlphabetOfRatExpAsList}}
1341
\label{AlphabetOfRatExpAsList}
1342
}\hfill{\scriptsize (function)}}\\
1343
1344
1345
Returns the alphabet of the rational expression \texttt{R} always as a list. If the alphabet of the rational expression is given by means
1346
of an integer less than 27 it returns the list \texttt{"abcd...."}, otherwise returns \texttt{[ "a1", "a2", "a3", "a4", ... ]}.
1347
\begin{Verbatim}[commandchars=!|B,fontsize=\small,frame=single,label=Example]
1348
!gapprompt|gap>B !gapinput|r:=RandomRatExp(2);B
1349
(aUb)((aUb)(bU@)U@)U@
1350
!gapprompt|gap>B !gapinput|AlphabetOfRatExpAsList(r);B
1351
"ab"
1352
!gapprompt|gap>B !gapinput|r:=RandomRatExp("01");B
1353
1*(0U@)
1354
!gapprompt|gap>B !gapinput|AlphabetOfRatExpAsList(r);B
1355
"01"
1356
!gapprompt|gap>B !gapinput|r:=RandomRatExp(30);;B
1357
!gapprompt|gap>B !gapinput|AlphabetOfRatExpAsList(r);B
1358
[ "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11",
1359
"a12", "a13", "a14", "a15", "a16", "a17", "a18", "a19", "a20", "a21",
1360
"a22", "a23", "a24", "a25", "a26", "a27", "a28", "a29", "a30" ]
1361
\end{Verbatim}
1362
}
1363
1364
1365
1366
\subsection{\textcolor{Chapter }{CopyRatExp}}
1367
\logpage{[ 3, 1, 8 ]}\nobreak
1368
\hyperdef{L}{X786A096681CAC3CD}{}
1369
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{CopyRatExp({\mdseries\slshape R})\index{CopyRatExp@\texttt{CopyRatExp}}
1370
\label{CopyRatExp}
1371
}\hfill{\scriptsize (function)}}\\
1372
1373
1374
Returns a new rational expression, which is a copy of \texttt{R}.
1375
\begin{Verbatim}[commandchars=!|A,fontsize=\small,frame=single,label=Example]
1376
!gapprompt|gap>A !gapinput|r:=RandomRatExp(2);A
1377
a*(bU@)
1378
!gapprompt|gap>A !gapinput|CopyRatExp(r);A
1379
a*(bU@)
1380
\end{Verbatim}
1381
}
1382
1383
}
1384
1385
1386
\section{\textcolor{Chapter }{Comparison of rational expressions}}\logpage{[ 3, 2, 0 ]}
1387
\hyperdef{L}{X7FB9270D7E8FABF3}{}
1388
{
1389
The way two rational expressions \texttt{r1} and \texttt{r2} are compared through the $<$ operator is the following: the empty set is lesser than everything else; if r1
1390
and r2 are letters, then the lesser is taken from the order in the alphabet;
1391
if r1 is a letter an r2 a product, union or star, then r1 is lesser than r2; a
1392
star expression is considered to be lesser than a product or union expression
1393
and a product lesser than a union; to compare two star expressions we compare
1394
the expressions under the stars; to compare two product or union expressions
1395
we compare the subexpressions of each expression from left to right; }
1396
1397
1398
\section{\textcolor{Chapter }{Operations with rational languages}}\logpage{[ 3, 3, 0 ]}
1399
\hyperdef{L}{X83A280D47DB3A033}{}
1400
{
1401
Only operations with rational languages over the same alphabet are allowed.
1402
1403
We may compute expressions for the \texttt{product}, \texttt{union} and \texttt{star} (i.e., submonoid generated by) of rational sets. In some cases, simpler
1404
expressions representing the same set are returned. Note that that two
1405
simplifications are always made, namely, $r\cup"empty_set" = r$ and $r\epsilon = r$ . Of course, these operations may be used to construct more complex
1406
expressions. For rational expressions we have the functions \texttt{UnionRatExp}, \texttt{ProductRatExp}, \texttt{StarRatExp}, that return respectively rational expressions for the \emph{union} and \emph{product} of the languages given by the rational expressions \texttt{r} and \texttt{s} and the \texttt{star} of the language given by the rational expression \texttt{r}.
1407
1408
\subsection{\textcolor{Chapter }{UnionRatExp}}
1409
\logpage{[ 3, 3, 1 ]}\nobreak
1410
\hyperdef{L}{X8206BD4E82A81D8F}{}
1411
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{UnionRatExp({\mdseries\slshape r, s})\index{UnionRatExp@\texttt{UnionRatExp}}
1412
\label{UnionRatExp}
1413
}\hfill{\scriptsize (function)}}\\
1414
}
1415
1416
1417
1418
\subsection{\textcolor{Chapter }{ProductRatExp}}
1419
\logpage{[ 3, 3, 2 ]}\nobreak
1420
\hyperdef{L}{X7E29107587611CE2}{}
1421
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ProductRatExp({\mdseries\slshape r, s})\index{ProductRatExp@\texttt{ProductRatExp}}
1422
\label{ProductRatExp}
1423
}\hfill{\scriptsize (function)}}\\
1424
}
1425
1426
1427
1428
\subsection{\textcolor{Chapter }{ StarRatExp}}
1429
\logpage{[ 3, 3, 3 ]}\nobreak
1430
\hyperdef{L}{X83D8DAE6862C8A96}{}
1431
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ StarRatExp({\mdseries\slshape r})\index{ StarRatExp@\texttt{ StarRatExp}}
1432
\label{ StarRatExp}
1433
}\hfill{\scriptsize (function)}}\\
1434
1435
1436
The expression \texttt{(a(aUb))*} may be produced in the following way
1437
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
1438
!gapprompt@gap>| !gapinput@r1 := RatExpOnnLetters(2,[],[1]); |
1439
a
1440
!gapprompt@gap>| !gapinput@r2 := RatExpOnnLetters(2,[],[2]);|
1441
b
1442
!gapprompt@gap>| !gapinput@r3 := UnionRatExp(r1,r2);|
1443
aUb
1444
!gapprompt@gap>| !gapinput@r4 := ProductRatExp(r1,r3);|
1445
a(aUb)
1446
!gapprompt@gap>| !gapinput@r5 := StarRatExp(r4);|
1447
(a(aUb))*
1448
\end{Verbatim}
1449
}
1450
1451
}
1452
1453
}
1454
1455
1456
\chapter{\textcolor{Chapter }{Automata \emph{versus} rational expressions}}\logpage{[ 4, 0, 0 ]}
1457
\hyperdef{L}{X814B7AD47E8EDAFA}{}
1458
{
1459
A remarkable theorem due to Kleene shows that a language is recognized by a
1460
finite automaton precisely when it may be given by means of a rational
1461
expression, i.e. is a rational language.
1462
1463
An automaton and a rational expression are said to be \emph{equivalent} when both represent the same language. In this chapter we describe functions
1464
to go from automata to equivalent rational expressions and \emph{vice-versa}.
1465
\section{\textcolor{Chapter }{From automata to rational expressions}}\logpage{[ 4, 1, 0 ]}
1466
\hyperdef{L}{X7E631B92873300C1}{}
1467
{
1468
1469
1470
\subsection{\textcolor{Chapter }{AutomatonToRatExp }}
1471
\logpage{[ 4, 1, 1 ]}\nobreak
1472
\hyperdef{L}{X8751E3927CA4DEA1}{}
1473
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AutomatonToRatExp ({\mdseries\slshape A})\index{AutomatonToRatExp @\texttt{AutomatonToRatExp }}
1474
\label{AutomatonToRatExp }
1475
}\hfill{\scriptsize (function)}}\\
1476
\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AutToRatExp({\mdseries\slshape A})\index{AutToRatExp@\texttt{AutToRatExp}}
1477
\label{AutToRatExp}
1478
}\hfill{\scriptsize (function)}}\\
1479
\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{FAtoRatExp({\mdseries\slshape A})\index{FAtoRatExp@\texttt{FAtoRatExp}}
1480
\label{FAtoRatExp}
1481
}\hfill{\scriptsize (function)}}\\
1482
1483
1484
From a finite automaton, \texttt{FAtoRatExp}, \texttt{AutToRatExp} and \texttt{AutomatonToRatExp}, which are synonyms, compute one equivalent rational expression, using the
1485
state elimination algorithm.
1486
\begin{Verbatim}[commandchars=!|B,fontsize=\small,frame=single,label=Example]
1487
!gapprompt|gap>B !gapinput|x:=Automaton("det",4,2,[[ 0, 1, 2, 3 ],[ 0, 1, 2, 3 ]],[ 3 ],[ 1, 3, 4 ]);;B
1488
!gapprompt|gap>B !gapinput|FAtoRatExp(x);B
1489
(aUb)(aUb)U@
1490
!gapprompt|gap>B !gapinput|aut:=Automaton("det",4,"xy",[[ 0, 1, 2, 3 ],[ 0, 1, 2, 3 ]],[ 3 ],[ 1, 3, 4 ]);;B
1491
!gapprompt|gap>B !gapinput|FAtoRatExp(aut);B
1492
(xUy)(xUy)U@
1493
\end{Verbatim}
1494
}
1495
1496
}
1497
1498
1499
\section{\textcolor{Chapter }{From rational expression to automata}}\logpage{[ 4, 2, 0 ]}
1500
\hyperdef{L}{X8138227D7E65FC8C}{}
1501
{
1502
1503
1504
\subsection{\textcolor{Chapter }{RatExpToNDAut}}
1505
\logpage{[ 4, 2, 1 ]}\nobreak
1506
\hyperdef{L}{X840EEB7B7DD8B03D}{}
1507
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RatExpToNDAut({\mdseries\slshape R})\index{RatExpToNDAut@\texttt{RatExpToNDAut}}
1508
\label{RatExpToNDAut}
1509
}\hfill{\scriptsize (function)}}\\
1510
1511
1512
Given a rational expression \mbox{\texttt{\mdseries\slshape R}}, computes the equivalent NFA
1513
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
1514
!gapprompt@gap>B !gapinput@r:=RationalExpression("aUab");B
1515
aUab
1516
!gapprompt@gap>B !gapinput@Display(RatExpToNDAut(r));B
1517
| 1 2 3 4
1518
--------------------------------
1519
a | [ 1, 2 ]
1520
b | [ 3 ]
1521
Initial state: [ 4 ]
1522
Accepting states: [ 1, 3 ]
1523
!gapprompt@gap>B !gapinput@r:=RationalExpression("xUxy"); B
1524
xUxy
1525
!gapprompt@gap>B !gapinput@Display(RatExpToNDAut(r)); B
1526
| 1 2 3 4
1527
--------------------------------
1528
x | [ 1, 2 ]
1529
y | [ 3 ]
1530
Initial state: [ 4 ]
1531
Accepting states: [ 1, 3 ]
1532
\end{Verbatim}
1533
}
1534
1535
1536
1537
\subsection{\textcolor{Chapter }{RatExpToAutomaton}}
1538
\logpage{[ 4, 2, 2 ]}\nobreak
1539
\hyperdef{L}{X866BCCB2788E8561}{}
1540
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RatExpToAutomaton({\mdseries\slshape R})\index{RatExpToAutomaton@\texttt{RatExpToAutomaton}}
1541
\label{RatExpToAutomaton}
1542
}\hfill{\scriptsize (function)}}\\
1543
\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RatExpToAut({\mdseries\slshape R})\index{RatExpToAut@\texttt{RatExpToAut}}
1544
\label{RatExpToAut}
1545
}\hfill{\scriptsize (function)}}\\
1546
1547
1548
Given a rational expression \mbox{\texttt{\mdseries\slshape R}}, these functions, which are synonyms, use \texttt{RatExpToNDAut} (\ref{RatExpToNDAut})) to compute the equivalent NFA and then returns the equivalent minimal DFA
1549
\begin{Verbatim}[commandchars=!BC,fontsize=\small,frame=single,label=Example]
1550
!gappromptBgap>C !gapinputBr:=RationalExpression("@U(aUb)(aUb)");C
1551
@U(aUb)(aUb)
1552
!gappromptBgap>C !gapinputBDisplay(RatExpToAut(r));C
1553
| 1 2 3 4
1554
-----------------
1555
a | 3 1 3 2
1556
b | 3 1 3 2
1557
Initial state: [ 4 ]
1558
Accepting states: [ 1, 4 ]
1559
!gappromptBgap>C !gapinputBr:=RationalExpression("@U(0U1)(0U1)");C
1560
@U(0U1)(0U1)
1561
!gappromptBgap>C !gapinputBDisplay(RatExpToAut(r)); C
1562
| 1 2 3 4
1563
-----------------
1564
0 | 3 1 3 2
1565
1 | 3 1 3 2
1566
Initial state: [ 4 ]
1567
Accepting states: [ 1, 4 ]
1568
\end{Verbatim}
1569
}
1570
1571
}
1572
1573
1574
\section{\textcolor{Chapter }{ Some tests on automata }}\logpage{[ 4, 3, 0 ]}
1575
\hyperdef{L}{X85DCEFB88712056E}{}
1576
{
1577
This section describes functions that perform tests on automata, rational
1578
expressions and their accepted languages.
1579
1580
\subsection{\textcolor{Chapter }{IsEmptyLang}}
1581
\logpage{[ 4, 3, 1 ]}\nobreak
1582
\hyperdef{L}{X84E0143A860889A6}{}
1583
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsEmptyLang({\mdseries\slshape R})\index{IsEmptyLang@\texttt{IsEmptyLang}}
1584
\label{IsEmptyLang}
1585
}\hfill{\scriptsize (function)}}\\
1586
1587
1588
This function tests if the language given through a rational expression or an
1589
automaton \mbox{\texttt{\mdseries\slshape R }} is the empty language.
1590
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
1591
!gapprompt@gap>| !gapinput@r:=RandomRatExp(2);|
1592
empty_set
1593
!gapprompt@gap>| !gapinput@IsEmptyLang(r);|
1594
true
1595
!gapprompt@gap>| !gapinput@r:=RandomRatExp(2);|
1596
aUb
1597
!gapprompt@gap>| !gapinput@IsEmptyLang(r);|
1598
false
1599
\end{Verbatim}
1600
}
1601
1602
1603
1604
\subsection{\textcolor{Chapter }{IsFullLang}}
1605
\logpage{[ 4, 3, 2 ]}\nobreak
1606
\hyperdef{L}{X86AA1A5F7E1EEAFE}{}
1607
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsFullLang({\mdseries\slshape R})\index{IsFullLang@\texttt{IsFullLang}}
1608
\label{IsFullLang}
1609
}\hfill{\scriptsize (function)}}\\
1610
1611
1612
This function tests if the language given through a rational expression or an
1613
automaton \mbox{\texttt{\mdseries\slshape R }} represents the Kleene closure of the alphabet of \mbox{\texttt{\mdseries\slshape R }} .
1614
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
1615
!gapprompt@gap>| !gapinput@r:=RationalExpression("aUb");|
1616
aUb
1617
!gapprompt@gap>| !gapinput@IsFullLang(r);|
1618
false
1619
!gapprompt@gap>| !gapinput@r:=RationalExpression("(aUb)*");|
1620
(aUb)*
1621
!gapprompt@gap>| !gapinput@IsFullLang(r);|
1622
true
1623
\end{Verbatim}
1624
}
1625
1626
1627
1628
\subsection{\textcolor{Chapter }{AreEqualLang}}
1629
\logpage{[ 4, 3, 3 ]}\nobreak
1630
\hyperdef{L}{X8346D1B17DBF96E7}{}
1631
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AreEqualLang({\mdseries\slshape A1, A2})\index{AreEqualLang@\texttt{AreEqualLang}}
1632
\label{AreEqualLang}
1633
}\hfill{\scriptsize (function)}}\\
1634
\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AreEquivAut({\mdseries\slshape A1, A2})\index{AreEquivAut@\texttt{AreEquivAut}}
1635
\label{AreEquivAut}
1636
}\hfill{\scriptsize (function)}}\\
1637
1638
1639
These functions, which are synonyms, test if the automata or rational
1640
expressions \mbox{\texttt{\mdseries\slshape A1}} and \mbox{\texttt{\mdseries\slshape A2}} are equivalent, i.e. represent the same language. This is performed by
1641
checking that the corresponding minimal automata are isomorphic. Note hat this
1642
cannot happen if the alphabets are different.
1643
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
1644
!gapprompt@gap>| !gapinput@y:=RandomAutomaton("det",4,2);;|
1645
!gapprompt@gap>| !gapinput@x:=RandomAutomaton("det",4,2);;|
1646
!gapprompt@gap>| !gapinput@AreEquivAut(x, y);|
1647
false
1648
!gapprompt@gap>| !gapinput@a:=RationalExpression("(aUb)*ab*");|
1649
(aUb)*ab*
1650
!gapprompt@gap>| !gapinput@b:=RationalExpression("(aUb)*");|
1651
(aUb)*
1652
!gapprompt@gap>| !gapinput@AreEqualLang(a, b);|
1653
false
1654
!gapprompt@gap>| !gapinput@a:=RationalExpression("(bUa)*");|
1655
(bUa)*
1656
!gapprompt@gap>| !gapinput@AreEqualLang(a, b);|
1657
true
1658
!gapprompt@gap>| !gapinput@x:=RationalExpression("(1U0)*");|
1659
(1U0)*
1660
!gapprompt@gap>| !gapinput@AreEqualLang(a, x); |
1661
The given languages are not over the same alphabet
1662
false
1663
\end{Verbatim}
1664
}
1665
1666
1667
1668
\subsection{\textcolor{Chapter }{IsContainedLang}}
1669
\logpage{[ 4, 3, 4 ]}\nobreak
1670
\hyperdef{L}{X7FCB176285FA5BBB}{}
1671
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsContainedLang({\mdseries\slshape R1, R2})\index{IsContainedLang@\texttt{IsContainedLang}}
1672
\label{IsContainedLang}
1673
}\hfill{\scriptsize (function)}}\\
1674
1675
1676
Tests if the language represented (through an automaton or a rational
1677
expression) by \mbox{\texttt{\mdseries\slshape R1 }} is contained in the language represented (through an automaton or a rational
1678
expression) by \mbox{\texttt{\mdseries\slshape R2 }} .
1679
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
1680
!gapprompt@gap>| !gapinput@r:=RationalExpression("aUab");|
1681
aUab
1682
!gapprompt@gap>| !gapinput@s:=RationalExpression("a","ab");|
1683
a
1684
!gapprompt@gap>| !gapinput@IsContainedLang(s,r);|
1685
true
1686
!gapprompt@gap>| !gapinput@IsContainedLang(r,s);|
1687
false
1688
\end{Verbatim}
1689
}
1690
1691
1692
1693
\subsection{\textcolor{Chapter }{AreDisjointLang}}
1694
\logpage{[ 4, 3, 5 ]}\nobreak
1695
\hyperdef{L}{X83F1DE067C2D31A5}{}
1696
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AreDisjointLang({\mdseries\slshape R1, R2})\index{AreDisjointLang@\texttt{AreDisjointLang}}
1697
\label{AreDisjointLang}
1698
}\hfill{\scriptsize (function)}}\\
1699
1700
1701
Tests if the languages represented (through automata or a rational
1702
expressions) by \mbox{\texttt{\mdseries\slshape R1 }} and \mbox{\texttt{\mdseries\slshape R2 }} are disjoint.
1703
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
1704
!gapprompt@gap>| !gapinput@r:=RationalExpression("aUab");;|
1705
!gapprompt@gap>| !gapinput@s:=RationalExpression("a","ab");;|
1706
!gapprompt@gap>| !gapinput@AreDisjointLang(r,s);|
1707
false
1708
\end{Verbatim}
1709
}
1710
1711
}
1712
1713
}
1714
1715
1716
\chapter{\textcolor{Chapter }{Some functions involving automata}}\logpage{[ 5, 0, 0 ]}
1717
\hyperdef{L}{X7919AA9384EBC6A5}{}
1718
{
1719
This chapter describes some functions involving automata. It starts with
1720
functions to obtain equivalent automata of other type. Then the minimalization
1721
is considered.
1722
\section{\textcolor{Chapter }{From one type to another}}\logpage{[ 5, 1, 0 ]}
1723
\hyperdef{L}{X8050E142796E0CBF}{}
1724
{
1725
Recall that two automata are said to be equivalent when they recognize the
1726
same language. Next we have functions which have as input automata of one type
1727
and as output equivalent automata of another type.
1728
1729
\subsection{\textcolor{Chapter }{EpsilonToNFA}}
1730
\logpage{[ 5, 1, 1 ]}\nobreak
1731
\hyperdef{L}{X81E06D518428CA3C}{}
1732
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{EpsilonToNFA({\mdseries\slshape A})\index{EpsilonToNFA@\texttt{EpsilonToNFA}}
1733
\label{EpsilonToNFA}
1734
}\hfill{\scriptsize (function)}}\\
1735
1736
1737
\mbox{\texttt{\mdseries\slshape A}} is an automaton with $\epsilon$-transitions. Returns a NFA recognizing the same language.
1738
\begin{Verbatim}[commandchars=!BC,fontsize=\small,frame=single,label=Example]
1739
!gappromptBgap>C !gapinputBx:=RandomAutomaton("epsilon",3,2);;Display(x);C
1740
| 1 2 3
1741
------------------------------------
1742
a | [ 2 ] [ 3 ] [ 2 ]
1743
b | [ 1, 2 ] [ 1, 2 ] [ 1, 3 ]
1744
@ | [ 1, 2 ] [ 1, 2 ] [ 1, 2 ]
1745
Initial states: [ 2, 3 ]
1746
Accepting states: [ 1, 2, 3 ]
1747
!gappromptBgap>C !gapinputBDisplay(EpsilonToNFA(x));C
1748
| 1 2 3
1749
------------------------------------------
1750
a | [ 1, 2 ] [ 1, 2, 3 ] [ 1, 2 ]
1751
b | [ 1, 2 ] [ 1, 2 ] [ 1, 2, 3 ]
1752
Initial states: [ 1, 2, 3 ]
1753
Accepting states: [ 1, 2, 3 ]
1754
\end{Verbatim}
1755
}
1756
1757
1758
1759
\subsection{\textcolor{Chapter }{EpsilonToNFASet}}
1760
\logpage{[ 5, 1, 2 ]}\nobreak
1761
\hyperdef{L}{X81DC84E17A170270}{}
1762
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{EpsilonToNFASet({\mdseries\slshape A})\index{EpsilonToNFASet@\texttt{EpsilonToNFASet}}
1763
\label{EpsilonToNFASet}
1764
}\hfill{\scriptsize (function)}}\\
1765
1766
1767
\mbox{\texttt{\mdseries\slshape A}} is an automaton with $\epsilon$-transitions. Returns a NFA recognizing the same language. This function
1768
differs from \texttt{EpsilonToNFA} (\ref{EpsilonToNFA}) in that it is faster for smaller automata, or automata with few epsilon
1769
transitions, but slower in the really hard cases. }
1770
1771
1772
1773
\subsection{\textcolor{Chapter }{EpsilonCompactedAut}}
1774
\logpage{[ 5, 1, 3 ]}\nobreak
1775
\hyperdef{L}{X871F807D79CE148C}{}
1776
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{EpsilonCompactedAut({\mdseries\slshape A})\index{EpsilonCompactedAut@\texttt{EpsilonCompactedAut}}
1777
\label{EpsilonCompactedAut}
1778
}\hfill{\scriptsize (function)}}\\
1779
1780
1781
\mbox{\texttt{\mdseries\slshape A}} is an automaton with $\epsilon$-transitions. Returns an $\epsilon$NFA with each strongly-connected component of the epsilon-transitions digraph
1782
of \mbox{\texttt{\mdseries\slshape A}} identified with a single state and recognizing the same language.
1783
\begin{Verbatim}[commandchars=!BF,fontsize=\small,frame=single,label=Example]
1784
!gappromptBgap>F !gapinputBx:=RandomAutomaton("epsilon",3,2);;Display(x);F
1785
| 1 2 3
1786
------------------------------------
1787
a | [ 1, 2 ] [ 1, 3 ] [ 1, 2 ]
1788
b | [ 1, 2 ] [ 1, 2 ] [ 2, 3 ]
1789
@ | [ 3 ] [ 2 ]
1790
Initial state: [ 3 ]
1791
Accepting states: [ 1, 3 ]
1792
!gappromptBgap>F !gapinputBDisplay(EpsilonCompactedAut(x));F
1793
| 1 2
1794
-------------------------
1795
a | [ 1, 2 ] [ 1, 2 ]
1796
b | [ 1, 2 ] [ 1, 2 ]
1797
@ |
1798
Initial state: [ 2 ]
1799
Accepting states: [ 1, 2 ]
1800
\end{Verbatim}
1801
}
1802
1803
1804
1805
\subsection{\textcolor{Chapter }{ReducedNFA}}
1806
\logpage{[ 5, 1, 4 ]}\nobreak
1807
\hyperdef{L}{X83B0473278DC14F3}{}
1808
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ReducedNFA({\mdseries\slshape A})\index{ReducedNFA@\texttt{ReducedNFA}}
1809
\label{ReducedNFA}
1810
}\hfill{\scriptsize (function)}}\\
1811
1812
1813
\mbox{\texttt{\mdseries\slshape A}} is a non deterministic automaton (without $\epsilon$-transitions). Returns an NFA accepting the same language as its input but
1814
with possibly fewer states (it quotients out by the smallest right-invariant
1815
partition of the states). A paper describing the algorithm is in preparation.
1816
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
1817
!gapprompt@gap>B !gapinput@x:=RandomAutomaton("nondet",5,2);;Display(x);B
1818
| 1 2 3 4 5
1819
----------------------------------------------------------------------
1820
a | [ 1, 5 ] [ 1, 2, 4, 5 ] [ 1, 3, 5 ] [ 3, 4, 5 ] [ 4 ]
1821
b | [ 2, 3, 4 ] [ 3 ] [ 2, 3, 4 ] [ 2, 4, 5 ] [ 3 ]
1822
Initial state: [ 4 ]
1823
Accepting states: [ 1, 3, 4, 5 ]
1824
!gapprompt@gap>B !gapinput@Display(ReducedNFA(x));B
1825
| 1 2 3 4
1826
--------------------------------------------------------
1827
a | [ 1, 3 ] [ 1, 2, 3, 4 ] [ 4 ] [ 1, 3, 4 ]
1828
b | [ 1, 2, 4 ] [ 1 ] [ 1 ] [ 2, 3, 4 ]
1829
Initial state: [ 4 ]
1830
Accepting states: [ 1, 3, 4 ]
1831
\end{Verbatim}
1832
}
1833
1834
1835
1836
\subsection{\textcolor{Chapter }{NFAtoDFA}}
1837
\logpage{[ 5, 1, 5 ]}\nobreak
1838
\hyperdef{L}{X87D0F9F17F2BEB57}{}
1839
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{NFAtoDFA({\mdseries\slshape A})\index{NFAtoDFA@\texttt{NFAtoDFA}}
1840
\label{NFAtoDFA}
1841
}\hfill{\scriptsize (function)}}\\
1842
1843
1844
Given an NFA, these synonym functions, compute the equivalent DFA, using the
1845
powerset construction, according to the algorithm presented in the report of
1846
the AMoRE \cite{AMORE:95} program. The returned automaton is dense deterministic
1847
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
1848
!gapprompt@gap>B !gapinput@x:=RandomAutomaton("nondet",3,2);;Display(x);B
1849
| 1 2 3
1850
---------------------------
1851
a | [ 2 ] [ 1, 3 ]
1852
b | [ 2, 3 ]
1853
Initial states: [ 1, 3 ]
1854
Accepting states: [ 1, 2 ]
1855
!gapprompt@gap>B !gapinput@Display(NFAtoDFA(x));B
1856
| 1 2 3
1857
--------------
1858
a | 2 2 1
1859
b | 3 3 3
1860
Initial state: [ 1 ]
1861
Accepting states: [ 1, 2, 3 ]
1862
\end{Verbatim}
1863
}
1864
1865
1866
1867
\subsection{\textcolor{Chapter }{FuseSymbolsAut}}
1868
\logpage{[ 5, 1, 6 ]}\nobreak
1869
\hyperdef{L}{X7B61945581FE4AC6}{}
1870
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{FuseSymbolsAut({\mdseries\slshape A, s1, s2})\index{FuseSymbolsAut@\texttt{FuseSymbolsAut}}
1871
\label{FuseSymbolsAut}
1872
}\hfill{\scriptsize (function)}}\\
1873
1874
1875
Given an automaton \mbox{\texttt{\mdseries\slshape A}} and integers \mbox{\texttt{\mdseries\slshape s1}} and \mbox{\texttt{\mdseries\slshape s2}} which, returns an NFA obtained by replacing all transitions through \mbox{\texttt{\mdseries\slshape s2}} by transitions through \mbox{\texttt{\mdseries\slshape s1}}.
1876
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
1877
!gapprompt@gap>B !gapinput@x:=RandomAutomaton("det",3,2);;Display(x);B
1878
| 1 2 3
1879
--------------
1880
a | 2 3
1881
b | 1
1882
Initial state: [ 3 ]
1883
Accepting states: [ 1, 2, 3 ]
1884
!gapprompt@gap>B !gapinput@Display(FuseSymbolsAut(x,1,2));B
1885
| 1 2 3
1886
---------------------------
1887
a | [ 2 ] [ 1, 3 ]
1888
Initial state: [ 3 ]
1889
Accepting states: [ 1, 2, 3 ]
1890
\end{Verbatim}
1891
}
1892
1893
}
1894
1895
1896
\section{\textcolor{Chapter }{Minimalization of an automaton}}\logpage{[ 5, 2, 0 ]}
1897
\hyperdef{L}{X862A34E9801BEB25}{}
1898
{
1899
The algorithm used to minimalize a dense deterministic automaton (i.e., to
1900
compute a dense minimal automaton recognizing the same language) is based on
1901
an algorithm due to Hopcroft (see \cite{AHU:74}). It is well known (see \cite{HU:69}) that it suffices to reduce the automaton given and remove the inaccessible
1902
states. Again, the documentation for the computer program AMoRE \cite{AMORE:95} has been very useful.
1903
1904
\subsection{\textcolor{Chapter }{UsefulAutomaton}}
1905
\logpage{[ 5, 2, 1 ]}\nobreak
1906
\hyperdef{L}{X7B5B5B10868FB525}{}
1907
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{UsefulAutomaton({\mdseries\slshape A})\index{UsefulAutomaton@\texttt{UsefulAutomaton}}
1908
\label{UsefulAutomaton}
1909
}\hfill{\scriptsize (function)}}\\
1910
1911
1912
Given an automaton \mbox{\texttt{\mdseries\slshape A}} (deterministic or not), outputs a dense DFA \mbox{\texttt{\mdseries\slshape B}} whose states are all reachable and such that \mbox{\texttt{\mdseries\slshape A}} and \mbox{\texttt{\mdseries\slshape B}} are equivalent.
1913
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
1914
!gapprompt@gap>B !gapinput@x:=RandomAutomaton("det",4,2);;Display(x);B
1915
| 1 2 3 4
1916
-----------------
1917
a | 3 4
1918
b | 1 4
1919
Initial state: [ 3 ]
1920
Accepting states: [ 2, 3, 4 ]
1921
!gapprompt@gap>B !gapinput@Display(UsefulAutomaton(x));B
1922
| 1 2 3
1923
--------------
1924
a | 2 3 3
1925
b | 3 3 3
1926
Initial state: [ 1 ]
1927
Accepting states: [ 1, 2 ]
1928
\end{Verbatim}
1929
}
1930
1931
1932
1933
\subsection{\textcolor{Chapter }{MinimalizedAut}}
1934
\logpage{[ 5, 2, 2 ]}\nobreak
1935
\hyperdef{L}{X83C26846866AEE46}{}
1936
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{MinimalizedAut({\mdseries\slshape A})\index{MinimalizedAut@\texttt{MinimalizedAut}}
1937
\label{MinimalizedAut}
1938
}\hfill{\scriptsize (function)}}\\
1939
1940
1941
Returns the minimal automaton equivalent to \mbox{\texttt{\mdseries\slshape A}}.
1942
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
1943
!gapprompt@gap>B !gapinput@x:=RandomAutomaton("det",4,2);;Display(x);B
1944
| 1 2 3 4
1945
-----------------
1946
a | 3 4
1947
b | 1 2 3
1948
Initial state: [ 4 ]
1949
Accepting states: [ 2, 3, 4 ]
1950
!gapprompt@gap>B !gapinput@Display(MinimalizedAut(x));B
1951
| 1 2
1952
-----------
1953
a | 2 2
1954
b | 2 2
1955
Initial state: [ 1 ]
1956
Accepting state: [ 1 ]
1957
\end{Verbatim}
1958
}
1959
1960
1961
1962
\subsection{\textcolor{Chapter }{ MinimalAutomaton}}
1963
\logpage{[ 5, 2, 3 ]}\nobreak
1964
\hyperdef{L}{X7F7AE088808A5D00}{}
1965
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ MinimalAutomaton({\mdseries\slshape A})\index{ MinimalAutomaton@\texttt{ MinimalAutomaton}}
1966
\label{ MinimalAutomaton}
1967
}\hfill{\scriptsize (attribute)}}\\
1968
1969
1970
Returns the minimal automaton equivalent to \mbox{\texttt{\mdseries\slshape A}}, but stores it so that future computations of this automaton just return the
1971
stored automaton.
1972
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
1973
!gapprompt@gap>B !gapinput@x:=RandomAutomaton("det",4,2);;Display(x);B
1974
| 1 2 3 4
1975
-----------------
1976
a | 2 4
1977
b | 3 4
1978
Initial state: [ 4 ]
1979
Accepting states: [ 1, 2, 3 ]
1980
!gapprompt@gap>B !gapinput@Display(MinimalAutomaton(x));B
1981
| 1
1982
--------
1983
a | 1
1984
b | 1
1985
Initial state: [ 1 ]
1986
Accepting state:
1987
\end{Verbatim}
1988
}
1989
1990
1991
1992
\subsection{\textcolor{Chapter }{AccessibleStates}}
1993
\logpage{[ 5, 2, 4 ]}\nobreak
1994
\hyperdef{L}{X7F484D5A781BB643}{}
1995
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AccessibleStates({\mdseries\slshape aut[, p]})\index{AccessibleStates@\texttt{AccessibleStates}}
1996
\label{AccessibleStates}
1997
}\hfill{\scriptsize (function)}}\\
1998
1999
2000
Computes the list of states of the automaton \mbox{\texttt{\mdseries\slshape aut}} which are accessible from state \mbox{\texttt{\mdseries\slshape p}}. When \mbox{\texttt{\mdseries\slshape p}} is not given, returns the states which are accessible from any initial state.
2001
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
2002
!gapprompt@gap>B !gapinput@x:=RandomAutomaton("det",4,2);;Display(x);B
2003
| 1 2 3 4
2004
-----------------
2005
a | 1 2 4
2006
b | 2 4
2007
Initial state: [ 2 ]
2008
Accepting states: [ 1, 2, 3 ]
2009
!gapprompt@gap>B !gapinput@AccessibleStates(x,3);B
2010
[ 1, 2, 3, 4 ]
2011
\end{Verbatim}
2012
}
2013
2014
2015
2016
\subsection{\textcolor{Chapter }{AccessibleAutomaton}}
2017
\logpage{[ 5, 2, 5 ]}\nobreak
2018
\hyperdef{L}{X804A6BC979DA6E61}{}
2019
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AccessibleAutomaton({\mdseries\slshape A})\index{AccessibleAutomaton@\texttt{AccessibleAutomaton}}
2020
\label{AccessibleAutomaton}
2021
}\hfill{\scriptsize (function)}}\\
2022
2023
2024
If \mbox{\texttt{\mdseries\slshape A}} is a deterministic automaton, not necessarily dense, an equivalent dense
2025
deterministic accessible automaton is returned. (The function \texttt{UsefulAutomaton} is called.)
2026
2027
If \mbox{\texttt{\mdseries\slshape A}} is not deterministic with a single initial state, an equivalent accessible
2028
automaton is returned.
2029
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
2030
!gapprompt@gap>B !gapinput@x:=RandomAutomaton("det",4,2);;Display(x);B
2031
| 1 2 3 4
2032
-----------------
2033
a | 1 3
2034
b | 1 3 4
2035
Initial state: [ 2 ]
2036
Accepting states: [ 3, 4 ]
2037
!gapprompt@gap>B !gapinput@Display(AccessibleAutomaton(x));B
2038
| 1 2 3 4
2039
-----------------
2040
a | 2 4 4 4
2041
b | 2 3 4 4
2042
Initial state: [ 1 ]
2043
Accepting states: [ 2, 3 ]
2044
\end{Verbatim}
2045
}
2046
2047
2048
2049
\subsection{\textcolor{Chapter }{IntersectionLanguage}}
2050
\logpage{[ 5, 2, 6 ]}\nobreak
2051
\hyperdef{L}{X7BAACCAF7E2D213B}{}
2052
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IntersectionLanguage({\mdseries\slshape A1, A2})\index{IntersectionLanguage@\texttt{IntersectionLanguage}}
2053
\label{IntersectionLanguage}
2054
}\hfill{\scriptsize (function)}}\\
2055
\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IntersectionAutomaton({\mdseries\slshape A1, A2})\index{IntersectionAutomaton@\texttt{IntersectionAutomaton}}
2056
\label{IntersectionAutomaton}
2057
}\hfill{\scriptsize (function)}}\\
2058
2059
2060
Computes an automaton that recognizes the intersection of the languages given
2061
(through automata or rational expressions by) \mbox{\texttt{\mdseries\slshape A1}} and \mbox{\texttt{\mdseries\slshape A2}}. When the arguments are deterministic automata, is the same as
2062
ProductAutomaton, but works for all kinds of automata. Note that the language
2063
of the product of two automata is precisely the intersection of the languages
2064
of the automata.
2065
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
2066
!gapprompt@gap>B !gapinput@x:=RandomAutomaton("det",3,2);;Display(x);B
2067
| 1 2 3
2068
--------------
2069
a | 2 3
2070
b | 1
2071
Initial state: [ 3 ]
2072
Accepting states: [ 1, 2, 3 ]
2073
!gapprompt@gap>B !gapinput@y:=RandomAutomaton("det",3,2);;Display(y);B
2074
| 1 2 3
2075
--------------
2076
a | 1
2077
b | 1 3
2078
Initial state: [ 3 ]
2079
Accepting states: [ 1, 3 ]
2080
!gapprompt@gap>B !gapinput@Display(IntersectionLanguage(x,y));B
2081
| 1 2
2082
-----------
2083
a | 2 2
2084
b | 2 2
2085
Initial state: [ 1 ]
2086
Accepting state: [ 1 ]
2087
\end{Verbatim}
2088
}
2089
2090
2091
2092
\subsection{\textcolor{Chapter }{AutomatonAllPairsPaths}}
2093
\logpage{[ 5, 2, 7 ]}\nobreak
2094
\hyperdef{L}{X8460C44386EE6225}{}
2095
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AutomatonAllPairsPaths({\mdseries\slshape A})\index{AutomatonAllPairsPaths@\texttt{AutomatonAllPairsPaths}}
2096
\label{AutomatonAllPairsPaths}
2097
}\hfill{\scriptsize (function)}}\\
2098
2099
2100
Given an automaton \mbox{\texttt{\mdseries\slshape A}}, with \texttt{n} states, outputs a \texttt{n} x \texttt{n} matrix P, such that P[i][j] is the list of simple paths from state i to state
2101
j in \mbox{\texttt{\mdseries\slshape A}}.
2102
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
2103
!gapprompt@gap>B !gapinput@a:=RandomAutomaton("det",3,2);B
2104
< deterministic automaton on 2 letters with 3 states >
2105
!gapprompt@gap>B !gapinput@AutomatonAllPairsPaths(a);B
2106
[ [ [ [ 1, 1 ] ], [ ], [ ] ], [ [ [ 2, 1 ] ], [ [ 2, 2 ] ], [ ] ],
2107
[ [ [ 3, 2, 1 ] ], [ [ 3, 2 ] ], [ [ 3, 3 ] ] ] ]
2108
!gapprompt@gap>B !gapinput@Display(a);B
2109
| 1 2 3
2110
--------------
2111
a | 1 2
2112
b | 1 2 3
2113
Initial state: [ 3 ]
2114
Accepting states: [ 1, 2 ]
2115
\end{Verbatim}
2116
}
2117
2118
}
2119
2120
}
2121
2122
2123
\chapter{\textcolor{Chapter }{Finite regular languages}}\logpage{[ 6, 0, 0 ]}
2124
\hyperdef{L}{X7AF3E5D081126EBD}{}
2125
{
2126
This chapter describes some functions to deal with finite regular languages.
2127
\section{\textcolor{Chapter }{Dealing with finite regular languages}}\logpage{[ 6, 1, 0 ]}
2128
\hyperdef{L}{X85643AEB7E7FB39A}{}
2129
{
2130
2131
2132
\subsection{\textcolor{Chapter }{IsFiniteRegularLanguage}}
2133
\logpage{[ 6, 1, 1 ]}\nobreak
2134
\hyperdef{L}{X82971FC2851B7B30}{}
2135
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsFiniteRegularLanguage({\mdseries\slshape L})\index{IsFiniteRegularLanguage@\texttt{IsFiniteRegularLanguage}}
2136
\label{IsFiniteRegularLanguage}
2137
}\hfill{\scriptsize (function)}}\\
2138
2139
2140
\mbox{\texttt{\mdseries\slshape L}} is an automaton or a rational expression. This function tests whether its
2141
argument represents a finite language or not.
2142
\begin{Verbatim}[commandchars=!|A,fontsize=\small,frame=single,label=Example]
2143
!gapprompt|gap>A !gapinput|RandomRatExp(2);A
2144
b*(aU@)
2145
!gapprompt|gap>A !gapinput|IsFiniteRegularLanguage(last);A
2146
false
2147
!gapprompt|gap>A !gapinput|RandomRatExp(2);A
2148
aUbU@
2149
!gapprompt|gap>A !gapinput|IsFiniteRegularLanguage(last);A
2150
true
2151
\end{Verbatim}
2152
}
2153
2154
2155
2156
\subsection{\textcolor{Chapter }{FiniteRegularLanguageToListOfWords}}
2157
\logpage{[ 6, 1, 2 ]}\nobreak
2158
\hyperdef{L}{X7E48CD3E78277FF7}{}
2159
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{FiniteRegularLanguageToListOfWords({\mdseries\slshape L})\index{FiniteRegularLanguageToListOfWords@\texttt{FiniteRegularLanguageToListOfWords}}
2160
\label{FiniteRegularLanguageToListOfWords}
2161
}\hfill{\scriptsize (function)}}\\
2162
2163
2164
\mbox{\texttt{\mdseries\slshape L}} is an automaton or a rational expression. This function outputs the recognized
2165
language as a list of words.
2166
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
2167
!gapprompt@gap>| !gapinput@r:=RationalExpression("aaUx(aUb)"); |
2168
aaUx(aUb)
2169
!gapprompt@gap>| !gapinput@ FiniteRegularLanguageToListOfWords(r);|
2170
[ "aa", "xa", "xb" ]
2171
\end{Verbatim}
2172
}
2173
2174
2175
2176
\subsection{\textcolor{Chapter }{ListOfWordsToAutomaton}}
2177
\logpage{[ 6, 1, 3 ]}\nobreak
2178
\hyperdef{L}{X7F9C5C6F815773E6}{}
2179
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ListOfWordsToAutomaton({\mdseries\slshape alph, L})\index{ListOfWordsToAutomaton@\texttt{ListOfWordsToAutomaton}}
2180
\label{ListOfWordsToAutomaton}
2181
}\hfill{\scriptsize (function)}}\\
2182
2183
2184
Given an alphabet \mbox{\texttt{\mdseries\slshape alph}} (a list) and a list of words \mbox{\texttt{\mdseries\slshape L}} (a list of lists), outputs an automaton that recognizes the given list of
2185
words.
2186
\begin{Verbatim}[commandchars=!|B,fontsize=\small,frame=single,label=Example]
2187
!gapprompt|gap>B !gapinput|ListOfWordsToAutomaton("ab",["aaa","bba",""]);B
2188
< deterministic automaton on 2 letters with 6 states >
2189
!gapprompt|gap>B !gapinput|FAtoRatExp(last);B
2190
(bbUaa)aU@
2191
\end{Verbatim}
2192
}
2193
2194
}
2195
2196
}
2197
2198
2199
2200
\appendix
2201
2202
2203
\chapter{\textcolor{Chapter }{Directed graphs}}\logpage{[ "A", 0, 0 ]}
2204
\hyperdef{L}{X82FB3D357E1BE288}{}
2205
{
2206
Automata are frequently described through directed labeled graphs. This
2207
appendix on directed graphs (digraphs) is devoted to some functions designed
2208
with the purpose of being used as auxiliary functions to deal with automata,
2209
but may have independent interest.
2210
\section{\textcolor{Chapter }{Directed graphs}}\logpage{[ "A", 1, 0 ]}
2211
\hyperdef{L}{X82FB3D357E1BE288}{}
2212
{
2213
A directed graph with $n$ vertices is represented by an adjacency list. For example, the list \texttt{G = [[2,4],[3],[1,4],[]]} represents a directed graph with \texttt{4 (= Length(G))} vertices; the sublist in position \texttt{i} is the list of endpoints of the edges beginning in vertex $i$. \begin{figure}[htbp] \begin{center} \leavevmode \includegraphics[bb=0 0 132
2214
299]{graph} \end{center} \label{fig:graph} \end{figure}
2215
2216
2217
2218
\subsection{\textcolor{Chapter }{RandomDiGraph}}
2219
\logpage{[ "A", 1, 1 ]}\nobreak
2220
\hyperdef{L}{X86CF9F66788B2A24}{}
2221
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RandomDiGraph({\mdseries\slshape n})\index{RandomDiGraph@\texttt{RandomDiGraph}}
2222
\label{RandomDiGraph}
2223
}\hfill{\scriptsize (function)}}\\
2224
2225
2226
Produces a pseudo random digraph with $n$ vertices
2227
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
2228
!gapprompt@gap>| !gapinput@RandomDiGraph(4);|
2229
[ [ ], [ 1, 2, 4 ], [ ], [ ] ]
2230
\end{Verbatim}
2231
}
2232
2233
2234
2235
\subsection{\textcolor{Chapter }{VertexInDegree}}
2236
\logpage{[ "A", 1, 2 ]}\nobreak
2237
\hyperdef{L}{X868EE741872B932D}{}
2238
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{VertexInDegree({\mdseries\slshape DG, v})\index{VertexInDegree@\texttt{VertexInDegree}}
2239
\label{VertexInDegree}
2240
}\hfill{\scriptsize (function)}}\\
2241
2242
2243
Computes the in degree of the vertex \mbox{\texttt{\mdseries\slshape v}} of the directed graph \mbox{\texttt{\mdseries\slshape DG}}
2244
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
2245
!gapprompt@gap>| !gapinput@G:=RandomDiGraph(4);|
2246
[ [ 1 ], [ 1, 2, 4 ], [ ], [ 1, 2, 3 ] ]
2247
!gapprompt@gap>| !gapinput@VertexInDegree(G,2);|
2248
2
2249
\end{Verbatim}
2250
}
2251
2252
2253
2254
\subsection{\textcolor{Chapter }{VertexOutDegree}}
2255
\logpage{[ "A", 1, 3 ]}\nobreak
2256
\hyperdef{L}{X84DF2E8E7A7B32C6}{}
2257
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{VertexOutDegree({\mdseries\slshape DG, v})\index{VertexOutDegree@\texttt{VertexOutDegree}}
2258
\label{VertexOutDegree}
2259
}\hfill{\scriptsize (function)}}\\
2260
2261
2262
Computes the out degree of the vertex \mbox{\texttt{\mdseries\slshape v}} of the directed graph \mbox{\texttt{\mdseries\slshape DG}}
2263
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
2264
!gapprompt@gap>| !gapinput@G:=RandomDiGraph(4);|
2265
[ [ 1 ], [ 1, 2, 4 ], [ ], [ 1, 2, 3 ] ]
2266
!gapprompt@gap>| !gapinput@VertexOutDegree(G,2);|
2267
3
2268
\end{Verbatim}
2269
}
2270
2271
2272
2273
\subsection{\textcolor{Chapter }{AutoVertexDegree}}
2274
\logpage{[ "A", 1, 4 ]}\nobreak
2275
\hyperdef{L}{X7FA6FAAE7AA8715D}{}
2276
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AutoVertexDegree({\mdseries\slshape DG, v})\index{AutoVertexDegree@\texttt{AutoVertexDegree}}
2277
\label{AutoVertexDegree}
2278
}\hfill{\scriptsize (function)}}\\
2279
2280
2281
Computes the degree of the vertex \mbox{\texttt{\mdseries\slshape v}} of the directed graph \mbox{\texttt{\mdseries\slshape DG}}
2282
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
2283
!gapprompt@gap>| !gapinput@G:=RandomDiGraph(4);|
2284
[ [ 1 ], [ 1, 2, 4 ], [ ], [ 1, 2, 3 ] ]
2285
!gapprompt@gap>| !gapinput@AutoVertexDegree(G,2);|
2286
5
2287
\end{Verbatim}
2288
}
2289
2290
2291
2292
\subsection{\textcolor{Chapter }{ReversedGraph}}
2293
\logpage{[ "A", 1, 5 ]}\nobreak
2294
\hyperdef{L}{X7BA5F1DF7DA89DC5}{}
2295
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ReversedGraph({\mdseries\slshape G})\index{ReversedGraph@\texttt{ReversedGraph}}
2296
\label{ReversedGraph}
2297
}\hfill{\scriptsize (function)}}\\
2298
2299
2300
Computes the reversed graph of the directed graph G. It is the graph obtained
2301
from G by reversing the edges.
2302
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
2303
!gapprompt@gap>| !gapinput@G:=RandomDiGraph(4);|
2304
[ [ ], [ 4 ], [ 2 ], [ 1, 4 ] ]
2305
!gapprompt@gap>| !gapinput@ReversedGraph(G);|
2306
[ [ 4 ], [ 3 ], [ ], [ 2, 4 ] ]
2307
\end{Verbatim}
2308
}
2309
2310
We say that a digraph is connected when for every pair of vertices there is a
2311
path consisting of directed or reversed edges from one vertex to the other.
2312
2313
\subsection{\textcolor{Chapter }{AutoConnectedComponents}}
2314
\logpage{[ "A", 1, 6 ]}\nobreak
2315
\hyperdef{L}{X7F23780E7A12A79E}{}
2316
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AutoConnectedComponents({\mdseries\slshape G})\index{AutoConnectedComponents@\texttt{AutoConnectedComponents}}
2317
\label{AutoConnectedComponents}
2318
}\hfill{\scriptsize (function)}}\\
2319
2320
2321
Computes a list of the connected components of the digraph
2322
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
2323
!gapprompt@gap>| !gapinput@G:=RandomDiGraph(6);|
2324
[ [ ], [ 1, 4, 5, 6 ], [ ], [ 1, 3, 5, 6 ], [ 2, 3 ], [ 2, 4, 6 ] ]
2325
!gapprompt@gap>| !gapinput@AutoConnectedComponents(G);|
2326
[ [ 1, 2, 3, 4, 5, 6 ] ]
2327
\end{Verbatim}
2328
}
2329
2330
Two vertices of a digraph belong to a strongly connected component if there is
2331
a directed path from each one to the other.
2332
2333
2334
2335
\subsection{\textcolor{Chapter }{GraphStronglyConnectedComponents}}
2336
\logpage{[ "A", 1, 7 ]}\nobreak
2337
\hyperdef{L}{X7D5288C982F92481}{}
2338
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{GraphStronglyConnectedComponents({\mdseries\slshape G})\index{GraphStronglyConnectedComponents@\texttt{GraphStronglyConnectedComponents}}
2339
\label{GraphStronglyConnectedComponents}
2340
}\hfill{\scriptsize (function)}}\\
2341
2342
2343
Produces the strongly connected components of the digraph \mbox{\texttt{\mdseries\slshape G}}.
2344
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
2345
!gapprompt@gap>| !gapinput@G:=RandomDiGraph(6);|
2346
[ [ ], [ 4 ], [ ], [ 4, 6 ], [ ], [ 1, 4, 5, 6 ] ]
2347
!gapprompt@gap>| !gapinput@GraphStronglyConnectedComponents(G);|
2348
[ [ 1 ], [ 2 ], [ 3 ], [ 4, 6 ], [ 5 ] ]
2349
\end{Verbatim}
2350
}
2351
2352
2353
2354
\subsection{\textcolor{Chapter }{UnderlyingMultiGraphOfAutomaton}}
2355
\logpage{[ "A", 1, 8 ]}\nobreak
2356
\hyperdef{L}{X859B7C517AFBD198}{}
2357
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{UnderlyingMultiGraphOfAutomaton({\mdseries\slshape A})\index{UnderlyingMultiGraphOfAutomaton@\texttt{UnderlyingMultiGraphOfAutomaton}}
2358
\label{UnderlyingMultiGraphOfAutomaton}
2359
}\hfill{\scriptsize (function)}}\\
2360
2361
2362
\mbox{\texttt{\mdseries\slshape A}} is an automaton. The output is the underlying directed multi-graph.
2363
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
2364
!gapprompt@gap>B !gapinput@a:=RandomAutomaton("det",3,2);;Display(a);B
2365
| 1 2 3
2366
--------------
2367
a | 1 3
2368
b | 2 3
2369
Initial state: [ 1 ]
2370
Accepting states: [ 1, 2 ]
2371
!gapprompt@gap>B !gapinput@UnderlyingMultiGraphOfAutomaton(a);B
2372
[ [ 1 ], [ 3, 2 ], [ 3 ] ]
2373
\end{Verbatim}
2374
}
2375
2376
2377
2378
\subsection{\textcolor{Chapter }{UnderlyingGraphOfAutomaton}}
2379
\logpage{[ "A", 1, 9 ]}\nobreak
2380
\hyperdef{L}{X78CF8E507E100C62}{}
2381
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{UnderlyingGraphOfAutomaton({\mdseries\slshape A})\index{UnderlyingGraphOfAutomaton@\texttt{UnderlyingGraphOfAutomaton}}
2382
\label{UnderlyingGraphOfAutomaton}
2383
}\hfill{\scriptsize (function)}}\\
2384
2385
2386
\mbox{\texttt{\mdseries\slshape A}} is an automaton. The output is the underlying directed graph.
2387
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
2388
!gapprompt@gap>B !gapinput@a:=RandomAutomaton("det",3,2);;Display(a);B
2389
| 1 2 3
2390
--------------
2391
a | 1 2
2392
b | 1 2
2393
Initial state: [ 2 ]
2394
Accepting state: [ 2 ]
2395
!gapprompt@gap>B !gapinput@UnderlyingGraphOfAutomaton(a);B
2396
[ [ 1 ], [ 1, 2 ], [ 2 ] ]
2397
\end{Verbatim}
2398
}
2399
2400
2401
2402
\subsection{\textcolor{Chapter }{DiGraphToRelation}}
2403
\logpage{[ "A", 1, 10 ]}\nobreak
2404
\hyperdef{L}{X78869D478792B3AD}{}
2405
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{DiGraphToRelation({\mdseries\slshape D})\index{DiGraphToRelation@\texttt{DiGraphToRelation}}
2406
\label{DiGraphToRelation}
2407
}\hfill{\scriptsize (function)}}\\
2408
2409
2410
Returns the relation corresponding to the digraph. Note that a directed graph
2411
may be seen in a natural way as a binary relation on the set of vertices.
2412
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
2413
!gapprompt@gap>| !gapinput@G:=RandomDiGraph(4);|
2414
[ [ ], [ ], [ 4 ], [ 4 ] ]
2415
!gapprompt@gap>| !gapinput@DiGraphToRelation(G);|
2416
[ [ 3, 4 ], [ 4, 4 ] ]
2417
\end{Verbatim}
2418
}
2419
2420
2421
2422
\subsection{\textcolor{Chapter }{MSccAutomaton}}
2423
\logpage{[ "A", 1, 11 ]}\nobreak
2424
\hyperdef{L}{X7D63604A8413AAAF}{}
2425
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{MSccAutomaton({\mdseries\slshape A})\index{MSccAutomaton@\texttt{MSccAutomaton}}
2426
\label{MSccAutomaton}
2427
}\hfill{\scriptsize (function)}}\\
2428
2429
2430
Produces an automaton where, in each strongly connected component, edges
2431
labeled by inverses are added. (M stands for modified.)
2432
2433
This construction is useful in Finite Semigroup Theory.
2434
\begin{Verbatim}[commandchars=!@C,fontsize=\small,frame=single,label=Example]
2435
!gapprompt@gap>C !gapinput@a:=RandomAutomaton("det",3,2);;Display(a);C
2436
| 1 2 3
2437
--------------
2438
a | 1 3
2439
b | 2 3
2440
Initial state: [ 1 ]
2441
Accepting states: [ 1, 2, 3 ]
2442
!gapprompt@gap>C !gapinput@MSccAutomaton(a);C
2443
< deterministic automaton on 4 letters with 3 states >
2444
!gapprompt@gap>C !gapinput@Display(last);C
2445
| 1 2 3
2446
--------------
2447
a | 1 3
2448
b | 2 3
2449
A | 1
2450
B |
2451
Initial state: [ 1 ]
2452
Accepting states: [ 1, 2, 3 ]
2453
\end{Verbatim}
2454
}
2455
2456
2457
2458
\subsection{\textcolor{Chapter }{AutoIsAcyclicGraph}}
2459
\logpage{[ "A", 1, 12 ]}\nobreak
2460
\hyperdef{L}{X7971EE367B6B7F36}{}
2461
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AutoIsAcyclicGraph({\mdseries\slshape G})\index{AutoIsAcyclicGraph@\texttt{AutoIsAcyclicGraph}}
2462
\label{AutoIsAcyclicGraph}
2463
}\hfill{\scriptsize (function)}}\\
2464
2465
2466
The argument is a graph's list of adjacencies and this function returns true
2467
if the argument is an acyclic graph and false otherwise.
2468
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
2469
!gapprompt@gap>| !gapinput@RandomDiGraph(3);|
2470
[ [ ], [ 3 ], [ 2 ] ]
2471
!gapprompt@gap>| !gapinput@AutoIsAcyclicGraph(last);|
2472
false
2473
\end{Verbatim}
2474
}
2475
2476
}
2477
2478
}
2479
2480
2481
\chapter{\textcolor{Chapter }{ Drawing automata }}\logpage{[ "B", 0, 0 ]}
2482
\hyperdef{L}{X82D249F0793E6561}{}
2483
{
2484
The drawing of graphs described here uses \texttt{graphviz} \cite{KoutsofiosNorth:2002}, a software for drawing graphs developed at AT \& T Labs, that can be obtained at \href{http://www.graphviz.org/} {\texttt{http://www.graphviz.org/}}.
2485
\section{\textcolor{Chapter }{ Installing some external programs }}\logpage{[ "B", 1, 0 ]}
2486
\hyperdef{L}{X7988DBAB78EA0C06}{}
2487
{
2488
In order to create the drawings you should install \href{http://www.graphviz.org/} {graphviz} and to view them you should install one of \href{http://www.gnome.org/projects/evince/} {evince}, \href{http://directory.fsf.org/GNU/ggv.html} {ggv}, \href{http://pages.cs.wisc.edu/~ghost/gsview/} {gsview} or \href{http://www.gnu.org/software/gv/} {gv}. }
2489
2490
2491
\section{\textcolor{Chapter }{ Functions to draw automata }}\logpage{[ "B", 2, 0 ]}
2492
\hyperdef{L}{X84C97CA079719B11}{}
2493
{
2494
2495
2496
\subsection{\textcolor{Chapter }{DrawAutomaton}}
2497
\logpage{[ "B", 2, 1 ]}\nobreak
2498
\hyperdef{L}{X7BC2FDA77FD0237B}{}
2499
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{DrawAutomaton({\mdseries\slshape A[, state{\textunderscore}names, L, file]})\index{DrawAutomaton@\texttt{DrawAutomaton}}
2500
\label{DrawAutomaton}
2501
}\hfill{\scriptsize (function)}}\\
2502
2503
2504
This function draws automaton \mbox{\texttt{\mdseries\slshape A}}. The arguments \mbox{\texttt{\mdseries\slshape state{\textunderscore}names}}, \mbox{\texttt{\mdseries\slshape L}} and \mbox{\texttt{\mdseries\slshape file}} are optional.
2505
2506
An automaton with \texttt{n} states will be drawn with numbers \texttt{1} to \texttt{n} written inside the corresponding graph node. The argument \mbox{\texttt{\mdseries\slshape state{\textunderscore}names}} is a list of \texttt{n} strings which will be the new text written inside the corresponding graph
2507
node.
2508
2509
The argument \mbox{\texttt{\mdseries\slshape L}} is a list of lists of integers, each of which specifies a set of states to be
2510
drawn in a different color.
2511
2512
The argument \mbox{\texttt{\mdseries\slshape file}} is a string that specifies the name of the file containing the drawing. If it
2513
is not give, it defaults to \texttt{"automaton"}.
2514
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
2515
!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 2, 3, 0 ], [ 0, 1, 2 ] ],[ 1 ],[ 1, 2, 3 ]);;|
2516
!gapprompt@gap>| !gapinput@DrawAutomaton(x,"file_name");|
2517
Displaying file: /tmp/tmp.Rj0v1s/file_name.dot.ps
2518
2519
!gapprompt@gap>| !gapinput@DrawAutomaton(x,["st 1", "2", "C"],"file_name");|
2520
Displaying file: /tmp/tmp.BCH3FO/file_name.dot.ps
2521
2522
!gapprompt@gap>| !gapinput@DrawAutomaton(x,["st 1", "2", "C"],[[2],[1,3]]);|
2523
Displaying file: /tmp/tmp.LPnJMq/automaton.dot.ps
2524
\end{Verbatim}
2525
The output of the three previous \texttt{DrawAutomaton} commands would be the following diagrams displayed in a \emph{ghostview} window, respectively.
2526
2527
\begin{figure}[htbp] \begin{center} \leavevmode \includegraphics[bb=0 0 74
2528
250]{aut2.jpg} \end{center} \label{fig:aut2} \end{figure}
2529
2530
\begin{figure}[htbp] \begin{center} \leavevmode \includegraphics[bb=0 0 100
2531
250]{aut2_1.jpg} \end{center} \label{fig:aut2_1} \end{figure}
2532
2533
\begin{figure}[htbp] \begin{center} \leavevmode \includegraphics[bb=0 0 100
2534
250]{aut2_2.jpg} \end{center} \label{fig:aut2_2} \end{figure}
2535
2536
}
2537
2538
2539
2540
\subsection{\textcolor{Chapter }{DrawAutomata}}
2541
\logpage{[ "B", 2, 2 ]}\nobreak
2542
\hyperdef{L}{X7AEE146D8391CA3D}{}
2543
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{DrawAutomata({\mdseries\slshape A, B[, file]})\index{DrawAutomata@\texttt{DrawAutomata}}
2544
\label{DrawAutomata}
2545
}\hfill{\scriptsize (function)}}\\
2546
2547
2548
This function tests if automaton \texttt{ A } is a subautomaton of \texttt{ B } in which case draws \texttt{ B } highlighting the edges not in \texttt{ A } by drawing them in a dotted style, while the others are drawn in a plain
2549
style. }
2550
2551
2552
2553
\subsection{\textcolor{Chapter }{DrawGraph}}
2554
\logpage{[ "B", 2, 3 ]}\nobreak
2555
\hyperdef{L}{X7D17B77F829F9CCB}{}
2556
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{DrawGraph({\mdseries\slshape G[, file]})\index{DrawGraph@\texttt{DrawGraph}}
2557
\label{DrawGraph}
2558
}\hfill{\scriptsize (function)}}\\
2559
2560
2561
Draws a graph specified as an adjacency list \texttt{G}. }
2562
2563
2564
2565
\subsection{\textcolor{Chapter }{DrawSCCAutomaton}}
2566
\logpage{[ "B", 2, 4 ]}\nobreak
2567
\hyperdef{L}{X7E478FDD807853CA}{}
2568
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{DrawSCCAutomaton({\mdseries\slshape A[, state{\textunderscore}names, L, file]})\index{DrawSCCAutomaton@\texttt{DrawSCCAutomaton}}
2569
\label{DrawSCCAutomaton}
2570
}\hfill{\scriptsize (function)}}\\
2571
2572
2573
Draws automaton \texttt{ A } and highlights it's strongly connected components by drawing the other edges
2574
in a dotted style.
2575
2576
The optional arguments \mbox{\texttt{\mdseries\slshape state{\textunderscore}names}}, \mbox{\texttt{\mdseries\slshape L}} and \mbox{\texttt{\mdseries\slshape file}} are as described in \texttt{DrawAutomaton} (\ref{DrawAutomaton}). }
2577
2578
}
2579
2580
2581
\section{\textcolor{Chapter }{Drawings output formats}}\logpage{[ "B", 3, 0 ]}
2582
\hyperdef{L}{X7F5419527FFCD1DF}{}
2583
{
2584
Since drawings are mostly used in the \textsf{SgpViz} package, please refer to that package's \href{http://www.gap-system.org/Manuals/pkg/sgpviz/doc/manual.html} {manual} section of the same name. }
2585
2586
2587
\section{\textcolor{Chapter }{Drawings extra graph attributes}}\logpage{[ "B", 4, 0 ]}
2588
\hyperdef{L}{X795DD98D86A1A441}{}
2589
{
2590
Since drawings are mostly used in the \textsf{SgpViz} package, please refer to that package's \href{http://www.gap-system.org/Manuals/pkg/sgpviz/doc/manual.html} {manual} section of the same name. }
2591
2592
}
2593
2594
2595
\chapter{\textcolor{Chapter }{Inverse automata and subgroups of the free group}}\logpage{[ "C", 0, 0 ]}
2596
\hyperdef{L}{X7DBBB0537ADC9899}{}
2597
{
2598
Inverse automata with a single initial/accepting state are in a one to one
2599
correspondence with finitely generated subgroups of the free group over the
2600
alphabet of the automaton. See \cite{MSW:2001}, \cite{KM:2002} for details, as well as for concepts such as \emph{flower automaton} and \emph{Stallings foldings}.
2601
\section{\textcolor{Chapter }{From subgroups to inverse automata}}\logpage{[ "C", 1, 0 ]}
2602
\hyperdef{L}{X7DDDA5127A3D170C}{}
2603
{
2604
A finitely generated subgroup of a finitely generated free group is given
2605
through a list whose first element is the number of generators of the free
2606
group and the remaining elements are the generators of the subgroup. The set
2607
of generators of the free group of rank $n$ consists on the $n$ first letters of the set $\{a,b,c,d,e,f,g\}$. In particular, free groups of rank greater than $8$ must not be considered. A formal inverse of a generator is represented by the
2608
corresponding capital letter.
2609
2610
A generator of the subgroup may be given through a string of letters or
2611
through a list of positive integers as should be clear from the example that
2612
follows.
2613
2614
For example, \texttt{[2,"abA","bbabAB"]} stands for the subgroup of the free group of rank 2 on the generators $aba^{-1}$ and $bbaba^{-1}b^{-1}$. The same subgroup may be given as \texttt{[2,[1,2,3],[2,2,1,2,3,4]]}. The number $ n+j$ represents the formal inverse of the generator represented by $j$. One can go from one representation to another, using the following
2615
functions.
2616
2617
\subsection{\textcolor{Chapter }{GeneratorsToListRepresentation}}
2618
\logpage{[ "C", 1, 1 ]}\nobreak
2619
\hyperdef{L}{X85358D097C314EB5}{}
2620
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{GeneratorsToListRepresentation({\mdseries\slshape L})\index{GeneratorsToListRepresentation@\texttt{GeneratorsToListRepresentation}}
2621
\label{GeneratorsToListRepresentation}
2622
}\hfill{\scriptsize (function)}}\\
2623
2624
2625
2626
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
2627
!gapprompt@gap>| !gapinput@L:=[2,"abA","bbabAB"];;|
2628
!gapprompt@gap>| !gapinput@GeneratorsToListRepresentation(L);|
2629
[ 2, [ 1, 2, 3 ], [ 2, 2, 1, 2, 3, 4 ] ]
2630
\end{Verbatim}
2631
}
2632
2633
2634
2635
\subsection{\textcolor{Chapter }{ListToGeneratorsRepresentation}}
2636
\logpage{[ "C", 1, 2 ]}\nobreak
2637
\hyperdef{L}{X80F3E10784590374}{}
2638
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ListToGeneratorsRepresentation({\mdseries\slshape K})\index{ListToGeneratorsRepresentation@\texttt{ListToGeneratorsRepresentation}}
2639
\label{ListToGeneratorsRepresentation}
2640
}\hfill{\scriptsize (function)}}\\
2641
2642
2643
2644
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
2645
!gapprompt@gap>| !gapinput@K:=[2,[1,2,3],[2,2,1,2,3,4]];;|
2646
!gapprompt@gap>| !gapinput@ListToGeneratorsRepresentation(K);|
2647
[ 2, "abA", "bbabAB" ]
2648
\end{Verbatim}
2649
}
2650
2651
2652
2653
\subsection{\textcolor{Chapter }{FlowerAutomaton}}
2654
\logpage{[ "C", 1, 3 ]}\nobreak
2655
\hyperdef{L}{X7EAFF7E879D115C5}{}
2656
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{FlowerAutomaton({\mdseries\slshape L})\index{FlowerAutomaton@\texttt{FlowerAutomaton}}
2657
\label{FlowerAutomaton}
2658
}\hfill{\scriptsize (function)}}\\
2659
2660
2661
The argument \texttt{L} is a subgroup of the free group given through any of the representations
2662
described above. Returns the flower automaton.
2663
\begin{Verbatim}[commandchars=!@C,fontsize=\small,frame=single,label=Example]
2664
!gapprompt@gap>C !gapinput@W:=[2,"bbbAB","abAbA"];;C
2665
!gapprompt@gap>C !gapinput@A:=FlowerAutomaton(W);C
2666
< non deterministic automaton on 2 letters with 9 states >
2667
!gapprompt@gap>C !gapinput@Display(A);C
2668
| 1 2 3 4 5 6 7 8 9
2669
---------------------------------------------------------------------
2670
a | [ 6, 9 ] [ 4 ] [ 7 ]
2671
b | [ 2, 5 ] [ 3 ] [ 4 ] [ 7 ] [ 9 ]
2672
Initial state: [ 1 ]
2673
Accepting state: [ 1 ]
2674
\end{Verbatim}
2675
}
2676
2677
2678
2679
\subsection{\textcolor{Chapter }{FoldFlowerAutomaton}}
2680
\logpage{[ "C", 1, 4 ]}\nobreak
2681
\hyperdef{L}{X7F729A4E8784D92E}{}
2682
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{FoldFlowerAutomaton({\mdseries\slshape A})\index{FoldFlowerAutomaton@\texttt{FoldFlowerAutomaton}}
2683
\label{FoldFlowerAutomaton}
2684
}\hfill{\scriptsize (function)}}\\
2685
2686
2687
Makes identifications on the flower automaton \texttt{A}. In the literature, these identifications are called Stallings foldings.
2688
2689
(This function may have \texttt{true} as a second argument. WARNING: the second argument should only be used when
2690
facilities to draw automata are available. In that case, one may visualize the
2691
identifications that are taking place.)
2692
\begin{Verbatim}[commandchars=!@C,fontsize=\small,frame=single,label=Example]
2693
!gapprompt@gap>C !gapinput@B := FoldFlowerAutomaton(A);C
2694
< deterministic automaton on 2 letters with 7 states >
2695
!gapprompt@gap>C !gapinput@Display(B);C
2696
| 1 2 3 4 5 6 7
2697
--------------------------
2698
a | 5 4 6
2699
b | 2 3 4 6 5
2700
Initial state: [ 1 ]
2701
Accepting state: [ 1 ]
2702
\end{Verbatim}
2703
}
2704
2705
2706
2707
\subsection{\textcolor{Chapter }{SubgroupGenToInvAut}}
2708
\logpage{[ "C", 1, 5 ]}\nobreak
2709
\hyperdef{L}{X826D581D794F1BFB}{}
2710
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{SubgroupGenToInvAut({\mdseries\slshape L})\index{SubgroupGenToInvAut@\texttt{SubgroupGenToInvAut}}
2711
\label{SubgroupGenToInvAut}
2712
}\hfill{\scriptsize (function)}}\\
2713
2714
2715
Returns the inverse automaton corresponding to the subgroup given by \mbox{\texttt{\mdseries\slshape L}}.
2716
\begin{Verbatim}[commandchars=!@C,fontsize=\small,frame=single,label=Example]
2717
!gapprompt@gap>C !gapinput@L:=[2,"bbbAB","AbAbA"];;C
2718
!gapprompt@gap>C !gapinput@SubgroupGenToInvAut(L);C
2719
< deterministic automaton on 2 letters with 8 states >
2720
!gapprompt@gap>C !gapinput@Display(last);C
2721
| 1 2 3 4 5 6 7 8
2722
-----------------------------
2723
a | 8 4 1 6
2724
b | 2 3 4 6 8
2725
Initial state: [ 1 ]
2726
Accepting state: [ 1 ]
2727
2728
\end{Verbatim}
2729
}
2730
2731
}
2732
2733
2734
\section{\textcolor{Chapter }{From inverse automata to subgroups}}\logpage{[ "C", 2, 0 ]}
2735
\hyperdef{L}{X85F2060A86DBE62B}{}
2736
{
2737
Given an inverse automaton with a single initial/accepting state, one can find
2738
a set of generators for the subgroup represented by the automaton. Moreover,
2739
using a geodesic tree, one can find a Nielsen reduced set of generators \cite{KM:2002}.
2740
2741
\subsection{\textcolor{Chapter }{GeodesicTreeOfInverseAutomaton}}
2742
\logpage{[ "C", 2, 1 ]}\nobreak
2743
\hyperdef{L}{X81DA149779A167BD}{}
2744
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{GeodesicTreeOfInverseAutomaton({\mdseries\slshape A})\index{GeodesicTreeOfInverseAutomaton@\texttt{GeodesicTreeOfInverseAutomaton}}
2745
\label{GeodesicTreeOfInverseAutomaton}
2746
}\hfill{\scriptsize (function)}}\\
2747
2748
2749
Returns a subautomaton of \mbox{\texttt{\mdseries\slshape A}}whose underlying graph is a geodesic tree of the underlying graph of the
2750
inverse automaton \texttt{A}.
2751
\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]
2752
!gapprompt@gap>B !gapinput@A:=Automaton("det",4,2,[ [ 3, 4, 0, 0 ], [ 2, 3, 4, 0 ] ],[ 1 ],[ 1 ]);;B
2753
!gapprompt@gap>B !gapinput@G := GeodesicTreeOfInverseAutomaton(A);B
2754
< deterministic automaton on 2 letters with 4 states >
2755
!gapprompt@gap>B !gapinput@Display(G);B
2756
| 1 2 3 4
2757
-----------------
2758
a | 3
2759
b | 2 4
2760
Initial state: [ 1 ]
2761
Accepting state: [ 1 ]
2762
\end{Verbatim}
2763
}
2764
2765
2766
2767
\subsection{\textcolor{Chapter }{InverseAutomatonToGenerators}}
2768
\logpage{[ "C", 2, 2 ]}\nobreak
2769
\hyperdef{L}{X7F117C43814F2CDE}{}
2770
{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{InverseAutomatonToGenerators({\mdseries\slshape A})\index{InverseAutomatonToGenerators@\texttt{InverseAutomatonToGenerators}}
2771
\label{InverseAutomatonToGenerators}
2772
}\hfill{\scriptsize (function)}}\\
2773
2774
2775
Returns a set of generators (given trough the representation above) of the
2776
subgroup of the free group corresponding to the automaton \texttt{A} given.
2777
\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]
2778
!gapprompt@gap>| !gapinput@NW := InverseAutomatonToGenerators(A);|
2779
[ 2, "baBA", "bbA" ]
2780
\end{Verbatim}
2781
}
2782
2783
}
2784
2785
}
2786
2787
\def\bibname{References\logpage{[ "Bib", 0, 0 ]}
2788
\hyperdef{L}{X7A6F98FD85F02BFE}{}
2789
}
2790
2791
\bibliographystyle{alpha}
2792
\bibliography{AutMan}
2793
2794
\addcontentsline{toc}{chapter}{References}
2795
2796
\def\indexname{Index\logpage{[ "Ind", 0, 0 ]}
2797
\hyperdef{L}{X83A0356F839C696F}{}
2798
}
2799
2800
\cleardoublepage
2801
\phantomsection
2802
\addcontentsline{toc}{chapter}{Index}
2803
2804
2805
\printindex
2806
2807
\newpage
2808
\immediate\write\pagenrlog{["End"], \arabic{page}];}
2809
\immediate\closeout\pagenrlog
2810
\end{document}
2811
2812