Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 418346% generated by GAPDoc2LaTeX from XML source (Frank Luebeck)1\documentclass[a4paper,11pt]{report}23\usepackage{a4wide}4\sloppy5\pagestyle{myheadings}6\usepackage{amssymb}7\usepackage[latin1]{inputenc}8\usepackage{makeidx}9\makeindex10\usepackage{color}11\definecolor{FireBrick}{rgb}{0.5812,0.0074,0.0083}12\definecolor{RoyalBlue}{rgb}{0.0236,0.0894,0.6179}13\definecolor{RoyalGreen}{rgb}{0.0236,0.6179,0.0894}14\definecolor{RoyalRed}{rgb}{0.6179,0.0236,0.0894}15\definecolor{LightBlue}{rgb}{0.8544,0.9511,1.0000}16\definecolor{Black}{rgb}{0.0,0.0,0.0}1718\definecolor{linkColor}{rgb}{0.0,0.0,0.554}19\definecolor{citeColor}{rgb}{0.0,0.0,0.554}20\definecolor{fileColor}{rgb}{0.0,0.0,0.554}21\definecolor{urlColor}{rgb}{0.0,0.0,0.554}22\definecolor{promptColor}{rgb}{0.0,0.0,0.589}23\definecolor{brkpromptColor}{rgb}{0.589,0.0,0.0}24\definecolor{gapinputColor}{rgb}{0.589,0.0,0.0}25\definecolor{gapoutputColor}{rgb}{0.0,0.0,0.0}2627%% for a long time these were red and blue by default,28%% now black, but keep variables to overwrite29\definecolor{FuncColor}{rgb}{0.0,0.0,0.0}30%% strange name because of pdflatex bug:31\definecolor{Chapter }{rgb}{0.0,0.0,0.0}32\definecolor{DarkOlive}{rgb}{0.1047,0.2412,0.0064}333435\usepackage{fancyvrb}3637\usepackage{mathptmx,helvet}38\usepackage[T1]{fontenc}39\usepackage{textcomp}404142\usepackage[43pdftex=true,44bookmarks=true,45a4paper=true,46pdftitle={Written with GAPDoc},47pdfcreator={LaTeX with hyperref package / GAPDoc},48colorlinks=true,49backref=page,50breaklinks=true,51linkcolor=linkColor,52citecolor=citeColor,53filecolor=fileColor,54urlcolor=urlColor,55pdfpagemode={UseNone},56]{hyperref}5758\newcommand{\maintitlesize}{\fontsize{50}{55}\selectfont}5960% write page numbers to a .pnr log file for online help61\newwrite\pagenrlog62\immediate\openout\pagenrlog =\jobname.pnr63\immediate\write\pagenrlog{PAGENRS := [}64\newcommand{\logpage}[1]{\protect\write\pagenrlog{#1, \thepage,}}65%% were never documented, give conflicts with some additional packages6667\newcommand{\GAP}{\textsf{GAP}}6869%% nicer description environments, allows long labels70\usepackage{enumitem}71\setdescription{style=nextline}7273%% depth of toc74\setcounter{tocdepth}{1}75767778\usepackage{graphicx}7980%% command for ColorPrompt style examples81\newcommand{\gapprompt}[1]{\color{promptColor}{\bfseries #1}}82\newcommand{\gapbrkprompt}[1]{\color{brkpromptColor}{\bfseries #1}}83\newcommand{\gapinput}[1]{\color{gapinputColor}{#1}}848586\begin{document}8788\logpage{[ 0, 0, 0 ]}89\begin{titlepage}90\mbox{}\vfill9192\begin{center}{\maintitlesize \textbf{Automata\mbox{}}}\\93\vfill9495\hypersetup{pdftitle=Automata}96\markright{\scriptsize \mbox{}\hfill Automata \hfill\mbox{}}97{\Huge ( Version 1.13 ) \mbox{}}\\[1cm]98\mbox{}\\[2cm]99{\Large \textbf{ Manuel Delgado \mbox{}}}\\100{\Large \textbf{ Steve Linton \mbox{}}}\\101{\Large \textbf{ Jos{\a'e} Jo{\~a}o Morais \mbox{}}}\\102\hypersetup{pdfauthor= Manuel Delgado ; Steve Linton ; Jos{\a'e} Jo{\~a}o Morais }103\end{center}\vfill104105\mbox{}\\106{\mbox{}\\107\small \noindent \textbf{ Manuel Delgado } Email: \href{mailto://mdelgado@fc.up.pt} {\texttt{mdelgado@fc.up.pt}}\\108Homepage: \href{http://www.fc.up.pt/cmup/mdelgado} {\texttt{http://www.fc.up.pt/cmup/mdelgado}}}\\109{\mbox{}\\110\small \noindent \textbf{ Steve Linton } Email: \href{mailto://sal@cs.st-andrews.ac.uk} {\texttt{sal@cs.st-andrews.ac.uk}}\\111Homepage: \href{http://www-circa.mcs.st-and.ac.uk/~sal/} {\texttt{http://www-circa.mcs.st-and.ac.uk/\texttt{\symbol{126}}sal/}}}\\112\end{titlepage}113114\newpage\setcounter{page}{2}115{\small116\section*{Copyright}117\logpage{[ 0, 0, 1 ]}118{\copyright} 2004 by Manuel Delgado, Steve Linton and Jos{\a'e} Morais119120We adopt the copyright regulations of \textsf{GAP} as detailed in the copyright notice in the \textsf{GAP} manual. \mbox{}}\\[1cm]121{\small122\section*{Acknowledgements}123\logpage{[ 0, 0, 3 ]}124The first author wishes to acknowledge Cyril Nicaud and Paulo Varandas for125their help in programming some functions of the very first version of this126package. He wishes also to acknowledge useful discussions and comments by127Cyril Nicaud, V{\a'\i}tor H. Fernandes, Jean-Eric Pin and Jorge Almeida.128129The first author also acknowledges support of FCT through CMUP and the FCT and130POCTI Project POCTI/32817/MAT/2000 which is funded in cooperation with the131European Community Fund FEDER.132133The third author acknowledges financial support of FCT and the POCTI program134through a scholarship given by Centro de Matem{\a'a}tica da Universidade do135Porto.136137The authors would like to thank Mark Kambites for his contribution in finding138bugs and making suggestions for the improvement of this package.139140141142143144Concerning the mantainment:145146147148The first author was/is (partially) supported by the FCT project149PTDC/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 program150COMPETE and by the Portuguese Government through the FCT - Funda{\c c}{\~a}o151para a Ci{\^e}ncia e a Tecnologia under the project PEst-C/MAT/UI0144/2011. \mbox{}}\\[1cm]152{\small153\section*{Colophon}154\logpage{[ 0, 0, 2 ]}155This work started in 1998, when the first author was in the LIAFA at the156University of Paris 7, in a post-doc. Encouraged by J. E. Pin, he began the157implementation in \textsf{GAP}3 of an algorithm obtained some time before to answer a question from the158realm of Finite Semigroups proposed by J. Almeida. It is now part of a159separate package: \texttt{finsemi}.160161The first version of this package on automata was prepared by the first author162who gave it the form of a \textsf{GAP} share package. In a second version, prepared by the first and third authors,163many functions have been added and the performance of many of the existing164ones has been improved. Further important improvements, specially concerning165performance, have been achieved when the second author joined the group.166167Since Version 1.12, the package is maintained by the first two authors. Bug168reports, suggestions and comments are, of course, welcome. Please use our169email addresses to this effect. \mbox{}}\\[1cm]170\newpage171172\def\contentsname{Contents\logpage{[ 0, 0, 4 ]}}173174\tableofcontents175\newpage176177178\chapter{\textcolor{Chapter }{ Introduction }}\logpage{[ 1, 0, 0 ]}179\hyperdef{L}{X7DFB63A97E67C0A1}{}180{181In many situations an automaton is conveniently described through a diagram182like the following183184\begin{figure}[htbp] \begin{center} \leavevmode \includegraphics[bb=0 0 132185279]{aut1} \end{center} \label{fig:aut1} \end{figure}186187This 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 of188paths from the initial to the final state.189190The 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 a191rational expression. For instance,192\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]193(aUb)(a(aUb)Ub(aUb))*194\end{Verbatim}195is a rational expression representing the language of the above automaton.196197Kleene's Theorem states that a language is rational if and only if it is the198language of a finite automaton. Both directions of Kleene's Theorem can be199proved constructively, and these algorithms, to go from an automaton to a200rational expression and \emph{vice-versa}, are implemented in this package.201202Of course, one has to pay attention to the size of the output produced. When203producing a deterministic automaton equivalent to a given rational expression204one can obtain an optimal solution (the minimal automaton) using standard205algorithms \cite{AHU:74}.206207When producing a rational expression for the language of an automaton, and208taking into account some reasonable measure for the size of a rational209expression, to determine a minimal one is apparently computationally210difficult. We use here some heuristic methods (to be published elsewhere)211which in practice lead to very reasonable results.212213The 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 has214been very useful and some of the algorithms implemented here are those215implemented in AMoRE. In this package, unlike what happened with AMoRE, we do216not have to worry about the monoid part in order to make it useful to217semigroup theorists, since monoids are already implemented in \textsf{GAP} and we may take advantage of this fact. We just need a function to compute the218transition semigroup of an automaton.219220221222The parts of this package that have not so directly to do with automata or223rational expressions are put into appendices in this manual. Some words about224these appendices follow.225226Using the external program Graphviz \cite{KoutsofiosNorth:2002} to graph visualization, one can visualize automata. This very convenient tool227presently works easily under LINUX.228229Given a finitely generated subgroup of the free group it is possible to230compute a flower automaton and perform Stallings foldings over it in order to231obtain an inverse automaton corresponding to the given subgroup.232233}234235236\chapter{\textcolor{Chapter }{Finite Automata}}\logpage{[ 2, 0, 0 ]}237\hyperdef{L}{X811E5FC2849C5644}{}238{239This chapter describes the representations used in this package for finite240automata and some functions to determine information about them.241242We 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).243244The 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 corresponding245letter on the states. In the case of a \emph{deterministic automaton} (DFA) the entries of the matrix are non-negative integers. When all entries of246the 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 @.247\section{\textcolor{Chapter }{Automata generation}}\logpage{[ 2, 1, 0 ]}248\hyperdef{L}{X821C3B3687B1F2FF}{}249{250The way to create an automaton in \textsf{GAP} is the following251252\subsection{\textcolor{Chapter }{Automaton}}253\logpage{[ 2, 1, 1 ]}\nobreak254\hyperdef{L}{X87D8222D7B50731E}{}255{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{Automaton({\mdseries\slshape Type, Size, Alphabet, TransitionTable, Initial, Accepting})\index{Automaton@\texttt{Automaton}}256\label{Automaton}257}\hfill{\scriptsize (function)}}\\258259260\texttt{Type} may be \texttt{"det"}, \texttt{"nondet"} or \texttt{"epsilon"} according to whether the automaton is deterministic, non deterministic or an261automaton 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 the262ordered alphabet. \texttt{TransitionTable} is the transition matrix. The entries are non-negative integers not greater263than the size of the automaton. In the case of non deterministic automata,264lists of non-negative integers not greater than the size of the automaton are265also allowed. \texttt{Initial} and \texttt{Accepting} are, respectively, the lists of initial and accepting states.266\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]267268!gapprompt@gap>B !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,4]],[1],[4]);B269< deterministic automaton on 2 letters with 4 states >270!gapprompt@gap>B !gapinput@Display(aut);B271| 1 2 3 4272-----------------273a | 3 3 4274b | 3 4 4275Initial state: [ 1 ]276Accepting state: [ 4 ]277278\end{Verbatim}279The alphabet of the automaton may be specified:280\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]281!gapprompt@gap>B !gapinput@aut:=Automaton("det",4,"01",[[3,,3,4],[3,4,0,4]],[1],[4]);B282< deterministic automaton on 2 letters with 4 states >283!gapprompt@gap>B !gapinput@Display(aut);B284| 1 2 3 4285-----------------2860 | 3 3 42871 | 3 4 4288Initial state: [ 1 ]289Accepting state: [ 4 ]290\end{Verbatim}291Instead 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 given292the same way.293\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]294!gapprompt@gap>B !gapinput@ndaut:=Automaton("nondet",4,2,[[3,[1,2],3,0],[3,4,0,[2,3]]],[1],[4]);B295< non deterministic automaton on 2 letters with 4 states >296!gapprompt@gap>B !gapinput@Display(ndaut);B297| 1 2 3 4298-----------------------------------------299a | [ 3 ] [ 1, 2 ] [ 3 ]300b | [ 3 ] [ 4 ] [ 2, 3 ]301Initial state: [ 1 ]302Accepting state: [ 4 ]303\end{Verbatim}304Also in the same way can be given $\epsilon$-automata. The letter $\epsilon$ is written \texttt{@} instead.305\begin{Verbatim}[commandchars=!BC,fontsize=\small,frame=single,label=Example]306!gappromptBgap>C !gapinputBx:=Automaton("epsilon",3,"01@",[[,[2],[3]],[[1,3],,[1]],[[1],[2],C307!gappromptB>C !gapinputB[2]]],[2],[2,3]);C308< epsilon automaton on 3 letters with 3 states >309!gappromptBgap>C !gapinputBDisplay(x);C310| 1 2 3311------------------------------3120 | [ 2 ] [ 3 ]3131 | [ 1, 3 ] [ 1 ]314@ | [ 1 ] [ 2 ] [ 2 ]315Initial state: [ 2 ]316Accepting states: [ 2, 3 ]317\end{Verbatim}318Bigger automata are displayed in another form:319\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]320!gapprompt@gap>| !gapinput@aut:=Automaton("det",16,2,[[4,0,0,6,3,1,4,8,7,4,3,0,6,1,6,0],|321!gapprompt@>| !gapinput@[3,4,0,0,6,1,0,6,1,6,1,6,6,4,8,7,4,5]],[1],[4]);|322< deterministic automaton on 2 letters with 16 states >323!gapprompt@gap>| !gapinput@Display(aut);|3241 a 43251 b 33262 b 4327... some more lines32815 a 632915 b 833016 b 7331Initial state: [ 1 ]332Accepting state: [ 4 ]333\end{Verbatim}334}335336337338\subsection{\textcolor{Chapter }{IsAutomaton}}339\logpage{[ 2, 1, 2 ]}\nobreak340\hyperdef{L}{X83CCDEF9814F1E6D}{}341{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsAutomaton({\mdseries\slshape O})\index{IsAutomaton@\texttt{IsAutomaton}}342\label{IsAutomaton}343}\hfill{\scriptsize (function)}}\\344345346In 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}.347\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]348!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;|349!gapprompt@gap>| !gapinput@IsAutomaton(x);|350true351\end{Verbatim}352}353354355356\subsection{\textcolor{Chapter }{IsDeterministicAutomaton}}357\logpage{[ 2, 1, 3 ]}\nobreak358\hyperdef{L}{X7D39CECC7E12DD8A}{}359{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsDeterministicAutomaton({\mdseries\slshape aut})\index{IsDeterministicAutomaton@\texttt{IsDeterministicAutomaton}}360\label{IsDeterministicAutomaton}361}\hfill{\scriptsize (function)}}\\362363364Returns \texttt{true} when \texttt{aut} is a deterministic automaton and \texttt{false} otherwise.365\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]366!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;|367!gapprompt@gap>| !gapinput@IsDeterministicAutomaton(x);|368true369\end{Verbatim}370}371372373374\subsection{\textcolor{Chapter }{IsNonDeterministicAutomaton}}375\logpage{[ 2, 1, 4 ]}\nobreak376\hyperdef{L}{X83C1148481BAA3DD}{}377{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsNonDeterministicAutomaton({\mdseries\slshape aut})\index{IsNonDeterministicAutomaton@\texttt{IsNonDeterministicAutomaton}}378\label{IsNonDeterministicAutomaton}379}\hfill{\scriptsize (function)}}\\380381382Returns \texttt{true} when \texttt{aut} is a non deterministic automaton and \texttt{false} otherwise.383\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]384!gapprompt@gap>| !gapinput@y:=Automaton("nondet",3,2,[[,[1,3],],[,[2,3],[1,3]]],[1,2],[1,3]);;|385!gapprompt@gap>| !gapinput@IsNonDeterministicAutomaton(y);|386true387\end{Verbatim}388}389390391392\subsection{\textcolor{Chapter }{IsEpsilonAutomaton}}393\logpage{[ 2, 1, 5 ]}\nobreak394\hyperdef{L}{X81EC5331790D6022}{}395{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsEpsilonAutomaton({\mdseries\slshape aut})\index{IsEpsilonAutomaton@\texttt{IsEpsilonAutomaton}}396\label{IsEpsilonAutomaton}397}\hfill{\scriptsize (function)}}\\398399400Returns \texttt{true} when \texttt{aut} is an $\epsilon$-automaton and \texttt{false} otherwise.401\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]402!gapprompt@gap>| !gapinput@z:=Automaton("epsilon",2,2,[[[1,2],],[[2],[1]]],[1,2],[1,2]);;|403!gapprompt@gap>| !gapinput@IsEpsilonAutomaton(z);|404true405\end{Verbatim}406}407408409410\subsection{\textcolor{Chapter }{String}}411\logpage{[ 2, 1, 6 ]}\nobreak412\hyperdef{L}{X81FB5BE27903EC32}{}413{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{String({\mdseries\slshape aut})\index{String@\texttt{String}}414\label{String}415}\hfill{\scriptsize (function)}}\\416417418The way \textsf{GAP} displays an automaton is quite natural, but when one wants to do small419changes, for example using \emph{copy/paste}, the use of the function \texttt{String} (possibly followed by \texttt{Print}) may be usefull.420\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]421!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;|422!gapprompt@gap>| !gapinput@String(x);|423"Automaton(\"det\",3,\"ab\",[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;"424!gapprompt@gap>| !gapinput@Print(String(x));|425Automaton("det",3,"ab",[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;426\end{Verbatim}427428\begin{Verbatim}[commandchars=!|B,fontsize=\small,frame=single,label=Example]429!gapprompt|gap>B !gapinput|z:=Automaton("epsilon",2,2,[[[1,2],],[[2],[1]]],[1,2],[1,2]);;B430!gapprompt|gap>B !gapinput|Print(String(z));B431Automaton("epsilon",2,"a@",[ [ [ 1, 2 ], [ ] ], [ [ 2 ], [ 1 ] ] ],[ 1, 2 ],[ \4321, 2 ]);;433\end{Verbatim}434}435436437438\subsection{\textcolor{Chapter }{RandomAutomaton}}439\logpage{[ 2, 1, 7 ]}\nobreak440\hyperdef{L}{X801019097C93BCCC}{}441{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RandomAutomaton({\mdseries\slshape Type, Size, Alphabet})\index{RandomAutomaton@\texttt{RandomAutomaton}}442\label{RandomAutomaton}443}\hfill{\scriptsize (function)}}\\444445446Given 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 these447parameters.448\begin{Verbatim}[commandchars=!BC,fontsize=\small,frame=single,label=Example]449!gappromptBgap>C !gapinputBRandomAutomaton("det",5,"ac");C450< deterministic automaton on 2 letters with 5 states >451!gappromptBgap>C !gapinputBDisplay(last);C452| 1 2 3 4 5453--------------------454a | 2 3455c | 2 3456Initial state: [ 4 ]457Accepting states: [ 3, 4 ]458459!gappromptBgap>C !gapinputBRandomAutomaton("nondet",3,["a","b","c"]);C460< non deterministic automaton on 3 letters with 3 states >461462!gappromptBgap>C !gapinputBRandomAutomaton("epsilon",2,"abc");C463< epsilon automaton on 4 letters with 2 states >464465!gappromptBgap>C !gapinputBRandomAutomaton("epsilon",2,2);C466< epsilon automaton on 3 letters with 2 states >467!gappromptBgap>C !gapinputBDisplay(last);C468| 1 2469----------------------470a | [ 1, 2 ]471b | [ 2 ] [ 1 ]472@ | [ 1, 2 ]473Initial state: [ 2 ]474Accepting states: [ 1, 2 ]475476!gappromptBgap>C !gapinputBa:=RandomTransformation(3);;C477!gappromptBgap>C !gapinputBb:=RandomTransformation(3);;C478!gappromptBgap>C !gapinputBaut:=RandomAutomaton("det",4,[a,b]);C479< deterministic automaton on 2 letters with 4 states >480\end{Verbatim}481}482483}484485486\section{\textcolor{Chapter }{Automata internals}}\logpage{[ 2, 2, 0 ]}487\hyperdef{L}{X80AB906D86BBC153}{}488{489In this section we describe the functions used to access the internals of an490automaton.491492\subsection{\textcolor{Chapter }{AlphabetOfAutomaton}}493\logpage{[ 2, 2, 1 ]}\nobreak494\hyperdef{L}{X7A34B47778B50FFE}{}495{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AlphabetOfAutomaton({\mdseries\slshape aut})\index{AlphabetOfAutomaton@\texttt{AlphabetOfAutomaton}}496\label{AlphabetOfAutomaton}497}\hfill{\scriptsize (function)}}\\498499500Returns the number of symbols in the alphabet of automaton \texttt{aut}.501\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]502!gapprompt@gap>| !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;|503!gapprompt@gap>| !gapinput@AlphabetOfAutomaton(aut);|5042505\end{Verbatim}506}507508509510\subsection{\textcolor{Chapter }{AlphabetOfAutomatonAsList}}511\logpage{[ 2, 2, 2 ]}\nobreak512\hyperdef{L}{X8044B24B82C59BBF}{}513{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AlphabetOfAutomatonAsList({\mdseries\slshape aut})\index{AlphabetOfAutomatonAsList@\texttt{AlphabetOfAutomatonAsList}}514\label{AlphabetOfAutomatonAsList}515}\hfill{\scriptsize (function)}}\\516517518Returns the alphabet of automaton \texttt{aut} always as a list. Note that when the alphabet of the automaton is given as an519integer (meaning the number of symbols) not greater than 26 it returns the520list \texttt{"abcd...."}. If the alphabet is given by means of an integer greater than 26, the521function returns \texttt{[ "a1", "a2", "a3", "a4", ... ]}.522\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]523!gapprompt@gap>| !gapinput@a:=RandomAutomaton("det",5,"cat");|524< deterministic automaton on 3 letters with 5 states >525!gapprompt@gap>| !gapinput@AlphabetOfAutomaton(a);|5263527!gapprompt@gap>| !gapinput@AlphabetOfAutomatonAsList(a);|528"cat"529!gapprompt@gap>| !gapinput@a:=RandomAutomaton("det",5,20);|530< deterministic automaton on 20 letters with 5 states >531!gapprompt@gap>| !gapinput@AlphabetOfAutomaton(a);|53220533!gapprompt@gap>| !gapinput@AlphabetOfAutomatonAsList(a);|534"abcdefghijklmnopqrst"535!gapprompt@gap>| !gapinput@a:=RandomAutomaton("det",5,30);|536< deterministic automaton on 30 letters with 5 states >537!gapprompt@gap>| !gapinput@AlphabetOfAutomaton(a);|53830539!gapprompt@gap>| !gapinput@AlphabetOfAutomatonAsList(a);|540[ "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11",541"a12", "a13", "a14", "a15", "a16", "a17", "a18", "a19", "a20", "a21",542"a22", "a23", "a24", "a25", "a26", "a27", "a28", "a29", "a30" ]543\end{Verbatim}544}545546547548\subsection{\textcolor{Chapter }{TransitionMatrixOfAutomaton}}549\logpage{[ 2, 2, 3 ]}\nobreak550\hyperdef{L}{X872BB42A81E4D0E7}{}551{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{TransitionMatrixOfAutomaton({\mdseries\slshape aut})\index{TransitionMatrixOfAutomaton@\texttt{TransitionMatrixOfAutomaton}}552\label{TransitionMatrixOfAutomaton}553}\hfill{\scriptsize (function)}}\\554555556Returns the transition matrix of automaton \texttt{aut}.557\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]558!gapprompt@gap>| !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;|559!gapprompt@gap>| !gapinput@TransitionMatrixOfAutomaton(aut);|560[ [ 3, 0, 3, 4 ], [ 3, 4, 0, 0 ] ]561\end{Verbatim}562}563564565566\subsection{\textcolor{Chapter }{InitialStatesOfAutomaton}}567\logpage{[ 2, 2, 4 ]}\nobreak568\hyperdef{L}{X7B5C3CFA83FF80EA}{}569{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{InitialStatesOfAutomaton({\mdseries\slshape aut})\index{InitialStatesOfAutomaton@\texttt{InitialStatesOfAutomaton}}570\label{InitialStatesOfAutomaton}571}\hfill{\scriptsize (function)}}\\572573574Returns the initial states of automaton \texttt{aut}.575\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]576!gapprompt@gap>| !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;|577!gapprompt@gap>| !gapinput@InitialStatesOfAutomaton(aut);|578[ 1 ]579\end{Verbatim}580}581582583584\subsection{\textcolor{Chapter }{SetInitialStatesOfAutomaton}}585\logpage{[ 2, 2, 5 ]}\nobreak586\hyperdef{L}{X8408FE8487028B7F}{}587{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{SetInitialStatesOfAutomaton({\mdseries\slshape aut, I})\index{SetInitialStatesOfAutomaton@\texttt{SetInitialStatesOfAutomaton}}588\label{SetInitialStatesOfAutomaton}589}\hfill{\scriptsize (function)}}\\590591592Sets the initial states of automaton \texttt{aut}. \texttt{I} may be a positive integer or a list of positive integers.593\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]594!gapprompt@gap>| !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;|595!gapprompt@gap>| !gapinput@SetInitialStatesOfAutomaton(aut,4);|596!gapprompt@gap>| !gapinput@InitialStatesOfAutomaton(aut);|597[ 4 ]598!gapprompt@gap>| !gapinput@SetInitialStatesOfAutomaton(aut,[2,3]);|599!gapprompt@gap>| !gapinput@InitialStatesOfAutomaton(aut);|600[ 2, 3 ]601\end{Verbatim}602}603604605606\subsection{\textcolor{Chapter }{FinalStatesOfAutomaton}}607\logpage{[ 2, 2, 6 ]}\nobreak608\hyperdef{L}{X78CDDCC27D085F00}{}609{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{FinalStatesOfAutomaton({\mdseries\slshape aut})\index{FinalStatesOfAutomaton@\texttt{FinalStatesOfAutomaton}}610\label{FinalStatesOfAutomaton}611}\hfill{\scriptsize (function)}}\\612613614Returns the final states of automaton \texttt{aut}.615\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]616!gapprompt@gap>| !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;|617!gapprompt@gap>| !gapinput@FinalStatesOfAutomaton(aut);|618[ 4 ]619\end{Verbatim}620}621622623624\subsection{\textcolor{Chapter }{SetFinalStatesOfAutomaton}}625\logpage{[ 2, 2, 7 ]}\nobreak626\hyperdef{L}{X80689F1480F9D959}{}627{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{SetFinalStatesOfAutomaton({\mdseries\slshape aut, F})\index{SetFinalStatesOfAutomaton@\texttt{SetFinalStatesOfAutomaton}}628\label{SetFinalStatesOfAutomaton}629}\hfill{\scriptsize (function)}}\\630631632Sets the final states of automaton \texttt{aut}. \texttt{F} may be a positive integer or a list of positive integers.633\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]634!gapprompt@gap>| !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;|635!gapprompt@gap>| !gapinput@FinalStatesOfAutomaton(aut);|636[ 4 ]637!gapprompt@gap>| !gapinput@SetFinalStatesOfAutomaton(aut,2);|638!gapprompt@gap>| !gapinput@FinalStatesOfAutomaton(aut);|639[ 2 ]640\end{Verbatim}641}642643644645\subsection{\textcolor{Chapter }{NumberStatesOfAutomaton}}646\logpage{[ 2, 2, 8 ]}\nobreak647\hyperdef{L}{X7D22AD207A3D5FF4}{}648{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{NumberStatesOfAutomaton({\mdseries\slshape aut})\index{NumberStatesOfAutomaton@\texttt{NumberStatesOfAutomaton}}649\label{NumberStatesOfAutomaton}650}\hfill{\scriptsize (function)}}\\651652653Returns the number of states of automaton \texttt{aut}.654\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]655!gapprompt@gap>| !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;|656!gapprompt@gap>| !gapinput@NumberStatesOfAutomaton(aut);|6574658\end{Verbatim}659}660661}662663664\section{\textcolor{Chapter }{Comparison of automata}}\logpage{[ 2, 3, 0 ]}665\hyperdef{L}{X8454E24E7D9FC1C2}{}666{667Although there is no standard way to compare automata it is usefull to be able668to do some kind of comparison. Doing so, one can consider sets of automata. We669just compare the strings of the automata.670\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]671!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 0, 2, 0 ], [ 0, 1, 0 ] ],[ 3 ],[ 2 ]);;|672!gapprompt@gap>| !gapinput@y:=Automaton("det",3,2,[ [ 2, 0, 0 ], [ 1, 3, 0 ] ],[ 3 ],[ 2, 3 ]);;|673!gapprompt@gap>| !gapinput@x=y;|674false675!gapprompt@gap>| !gapinput@Size(Set([y,x,x]));|6762677\end{Verbatim}678}679680681\section{\textcolor{Chapter }{Tests involving automata}}\logpage{[ 2, 4, 0 ]}682\hyperdef{L}{X867887A683961C63}{}683{684This section describes some useful tests involving automata.685686\subsection{\textcolor{Chapter }{IsDenseAutomaton}}687\logpage{[ 2, 4, 1 ]}\nobreak688\hyperdef{L}{X8356E41086482483}{}689{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsDenseAutomaton({\mdseries\slshape aut})\index{IsDenseAutomaton@\texttt{IsDenseAutomaton}}690\label{IsDenseAutomaton}691}\hfill{\scriptsize (function)}}\\692693694Tests whether a deterministic automaton \texttt{aut} is complete. (See also \texttt{NullCompletionAutomaton} (\ref{NullCompletionAutomaton}).)695\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]696!gapprompt@gap>| !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,]],[1],[4]);;|697!gapprompt@gap>| !gapinput@IsDenseAutomaton(aut); |698false699\end{Verbatim}700}701702703704\subsection{\textcolor{Chapter }{IsRecognizedByAutomaton}}705\logpage{[ 2, 4, 2 ]}\nobreak706\hyperdef{L}{X8676D8388053F1E7}{}707{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsRecognizedByAutomaton({\mdseries\slshape A, w})\index{IsRecognizedByAutomaton@\texttt{IsRecognizedByAutomaton}}708\label{IsRecognizedByAutomaton}709}\hfill{\scriptsize (function)}}\\710711712The 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.713\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]714!gapprompt@gap>| !gapinput@aut:=Automaton("det",3,2,[[1,2,1],[2,1,3]],[1],[2]);;|715!gapprompt@gap>| !gapinput@IsRecognizedByAutomaton(aut,"bbb");|716true717718!gapprompt@gap>| !gapinput@aut:=Automaton("det",3,"01",[[1,2,1],[2,1,3]],[1],[2]);;|719!gapprompt@gap>| !gapinput@IsRecognizedByAutomaton(aut,"111");|720true721\end{Verbatim}722}723724725726\subsection{\textcolor{Chapter }{IsPermutationAutomaton}}727\logpage{[ 2, 4, 3 ]}\nobreak728\hyperdef{L}{X80CCDD438258CD25}{}729{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsPermutationAutomaton({\mdseries\slshape aut})\index{IsPermutationAutomaton@\texttt{IsPermutationAutomaton}}730\label{IsPermutationAutomaton}731}\hfill{\scriptsize (function)}}\\732733734The argument is a deterministic automaton. Returns \texttt{true} when each letter of the alphabet induces a permutation on the vertices and \texttt{false} otherwise.735\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]736!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 1, 2, 3 ], [ 1, 2, 3 ] ],[ 1 ],[ 2, 3 ]);;|737!gapprompt@gap>| !gapinput@IsPermutationAutomaton(x);|738true739\end{Verbatim}740}741742743744\subsection{\textcolor{Chapter }{IsInverseAutomaton}}745\logpage{[ 2, 4, 4 ]}\nobreak746\hyperdef{L}{X7B7CA23680888C9C}{}747{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsInverseAutomaton({\mdseries\slshape aut})\index{IsInverseAutomaton@\texttt{IsInverseAutomaton}}748\label{IsInverseAutomaton}749}\hfill{\scriptsize (function)}}\\750751752The argument is a deterministic automaton. Returns \texttt{true} when each letter of the alphabet induces an injective partial function on the753vertices and \texttt{false} otherwise.754\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]755!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 0, 1, 3 ], [ 0, 1, 2 ] ],[ 2 ],[ 1 ]);;|756!gapprompt@gap>| !gapinput@IsInverseAutomaton(x);|757true758\end{Verbatim}759Frequently an inverse automaton is thought as if the inverse edges (labeled by760formal inverses of the letters of the alphabet) were present, although they761are usually not explicited. They can be made explicit using the function \texttt{AddInverseEdgesToInverseAutomaton} }762763764765\subsection{\textcolor{Chapter }{AddInverseEdgesToInverseAutomaton}}766\logpage{[ 2, 4, 5 ]}\nobreak767\hyperdef{L}{X7A4CDEFB84B97849}{}768{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AddInverseEdgesToInverseAutomaton({\mdseries\slshape aut})\index{AddInverseEdgesToInverseAutomaton@\texttt{AddInverseEdgesToInverseAutomaton}}769\label{AddInverseEdgesToInverseAutomaton}770}\hfill{\scriptsize (function)}}\\771772773The argument is an inverse automaton over the alphabet $\{a,b,c,\ldots\}$. Returns an automaton with the inverse edges added. (The formal inverse of a774letter is represented by the corresponding capital letter.)775\begin{Verbatim}[commandchars=!@C,fontsize=\small,frame=single,label=Example]776!gapprompt@gap>C !gapinput@x:=Automaton("det",3,2,[[ 0, 1, 3 ],[ 0, 1, 2 ]],[ 2 ],[ 1 ]);;Display(x);C777| 1 2 3778--------------779a | 1 3780b | 1 2781Initial state: [ 2 ]782Accepting state: [ 1 ]783!gapprompt@gap>C !gapinput@AddInverseEdgesToInverseAutomaton(x);Display(x);C784| 1 2 3785--------------786a | 1 3787b | 1 2788A | 2 3789B | 2 3790Initial state: [ 2 ]791Accepting state: [ 1 ]792\end{Verbatim}793}794795796797\subsection{\textcolor{Chapter }{IsReversibleAutomaton}}798\logpage{[ 2, 4, 6 ]}\nobreak799\hyperdef{L}{X8321BCE57E55FB30}{}800{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsReversibleAutomaton({\mdseries\slshape aut})\index{IsReversibleAutomaton@\texttt{IsReversibleAutomaton}}801\label{IsReversibleAutomaton}802}\hfill{\scriptsize (function)}}\\803804805The 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 edges806and switching the initial and final states (see also \texttt{ReversedAutomaton} (\ref{ReversedAutomaton})) is deterministic. Returns \texttt{false} otherwise.807\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]808!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 0, 1, 2 ], [ 0, 1, 3 ] ],[ 2 ],[ 2 ]);;|809!gapprompt@gap>| !gapinput@IsReversibleAutomaton(x);|810true811\end{Verbatim}812}813814}815816817\section{\textcolor{Chapter }{Basic operations}}\logpage{[ 2, 5, 0 ]}818\hyperdef{L}{X82EB5BE77F9F686A}{}819{820821822\subsection{\textcolor{Chapter }{CopyAutomaton}}823\logpage{[ 2, 5, 1 ]}\nobreak824\hyperdef{L}{X8225A1B886131707}{}825{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{CopyAutomaton({\mdseries\slshape aut})\index{CopyAutomaton@\texttt{CopyAutomaton}}826\label{CopyAutomaton}827}\hfill{\scriptsize (function)}}\\828829830Returns a new automaton, which is a copy of automaton \mbox{\texttt{\mdseries\slshape aut}}. }831832833834\subsection{\textcolor{Chapter }{NullCompletionAutomaton}}835\logpage{[ 2, 5, 2 ]}\nobreak836\hyperdef{L}{X80D423A584246E2E}{}837{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{NullCompletionAutomaton({\mdseries\slshape aut})\index{NullCompletionAutomaton@\texttt{NullCompletionAutomaton}}838\label{NullCompletionAutomaton}839}\hfill{\scriptsize (function)}}\\840841842\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.843\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]844!gapprompt@gap>B !gapinput@aut:=Automaton("det",4,2,[[3,,3,4],[2,4,4,]],[1],[4]);;B845!gapprompt@gap>B !gapinput@IsDenseAutomaton(aut);B846false847!gapprompt@gap>B !gapinput@y:=NullCompletionAutomaton(aut);;Display(y);B848| 1 2 3 4 5849--------------------850a | 3 5 3 4 5851b | 2 4 4 5 5852Initial state: [ 1 ]853Accepting state: [ 4 ]854\end{Verbatim}855The 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.) }856857858859\subsection{\textcolor{Chapter }{ListSinkStatesAut}}860\logpage{[ 2, 5, 3 ]}\nobreak861\hyperdef{L}{X79F052EC81135807}{}862{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ListSinkStatesAut({\mdseries\slshape aut})\index{ListSinkStatesAut@\texttt{ListSinkStatesAut}}863\label{ListSinkStatesAut}864}\hfill{\scriptsize (function)}}\\865866867Computes the list of all sink states of the automaton \mbox{\texttt{\mdseries\slshape aut}}.868\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]869!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 2, 3, 3 ], [ 1, 2, 3 ] ],[ 1 ],[ 2, 3 ]);;|870!gapprompt@gap>| !gapinput@ListSinkStatesAut(x);|871[ ]872!gapprompt@gap>| !gapinput@y:=Automaton("det",3,2,[ [ 2, 3, 3 ], [ 1, 2, 3 ] ],[ 1 ],[ 2 ]);;|873!gapprompt@gap>| !gapinput@ListSinkStatesAut(y);|874[ 3 ]875\end{Verbatim}876}877878879880\subsection{\textcolor{Chapter }{RemovedSinkStates}}881\logpage{[ 2, 5, 4 ]}\nobreak882\hyperdef{L}{X8240136E7A26B1A6}{}883{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RemovedSinkStates({\mdseries\slshape aut})\index{RemovedSinkStates@\texttt{RemovedSinkStates}}884\label{RemovedSinkStates}885}\hfill{\scriptsize (function)}}\\886887888Removes all sink states of the automaton \mbox{\texttt{\mdseries\slshape aut}}.889\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]890!gapprompt@gap>B !gapinput@y:=Automaton("det",3,2,[[ 2, 3, 3 ],[ 1, 2, 3 ]],[ 1 ],[ 2 ]);;Display(y);B891| 1 2 3892--------------893a | 2 3 3894b | 1 2 3895Initial state: [ 1 ]896Accepting state: [ 2 ]897!gapprompt@gap>B !gapinput@x := RemovedSinkStates(y);Display(x);B898< deterministic automaton on 2 letters with 2 states >899| 1 2900-----------901a | 2902b | 1 2903Initial state: [ 1 ]904Accepting state: [ 2 ]905\end{Verbatim}906}907908909910\subsection{\textcolor{Chapter }{ReversedAutomaton}}911\logpage{[ 2, 5, 5 ]}\nobreak912\hyperdef{L}{X7C0526217BFE7A65}{}913{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ReversedAutomaton({\mdseries\slshape aut})\index{ReversedAutomaton@\texttt{ReversedAutomaton}}914\label{ReversedAutomaton}915}\hfill{\scriptsize (function)}}\\916917918Inverts the arrows of the automaton \mbox{\texttt{\mdseries\slshape aut}}.919\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]920!gapprompt@gap>B !gapinput@y:=Automaton("det",3,2,[ [ 2, 3, 3 ], [ 1, 2, 3 ] ],[ 1 ],[ 2 ]);;B921!gapprompt@gap>B !gapinput@z:=ReversedAutomaton(y);;Display(z);B922| 1 2 3923------------------------------924a | [ 1 ] [ 2, 3 ]925b | [ 1 ] [ 2 ] [ 3 ]926Initial state: [ 2 ]927Accepting state: [ 1 ]928\end{Verbatim}929}930931932933\subsection{\textcolor{Chapter }{PermutedAutomaton}}934\logpage{[ 2, 5, 6 ]}\nobreak935\hyperdef{L}{X7A4A066583C71ABE}{}936{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{PermutedAutomaton({\mdseries\slshape aut, p})\index{PermutedAutomaton@\texttt{PermutedAutomaton}}937\label{PermutedAutomaton}938}\hfill{\scriptsize (function)}}\\939940941Given an automaton \mbox{\texttt{\mdseries\slshape aut}} and a list \mbox{\texttt{\mdseries\slshape p}} representing a permutation of the states, outputs the equivalent permuted942automaton.943\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]944!gapprompt@gap>B !gapinput@y:=Automaton("det",4,2,[[2,3,4,2],[0,0,0,1]],[1],[3]);;Display(y);B945| 1 2 3 4946-----------------947a | 2 3 4 2948b | 1949Initial state: [ 1 ]950Accepting state: [ 3 ]951!gapprompt@gap>B !gapinput@Display(PermutedAutomaton(y, [3,2,4,1]));B952| 1 2 3 4953-----------------954a | 2 4 2 1955b | 3956Initial state: [ 3 ]957Accepting state: [ 4 ]958\end{Verbatim}959}960961962963\subsection{\textcolor{Chapter }{ListPermutedAutomata}}964\logpage{[ 2, 5, 7 ]}\nobreak965\hyperdef{L}{X7A72DDF0782E8D5E}{}966{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ListPermutedAutomata({\mdseries\slshape aut})\index{ListPermutedAutomata@\texttt{ListPermutedAutomata}}967\label{ListPermutedAutomata}968}\hfill{\scriptsize (function)}}\\969970971Given an automaton \mbox{\texttt{\mdseries\slshape aut}}, returns a list of automata with permuted states972\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]973!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 0, 2, 3 ], [ 1, 2, 3 ] ],[ 1 ],[ 2, 3 ]);;|974!gapprompt@gap>| !gapinput@ListPermutedAutomata(x);|975[ < deterministic automaton on 2 letters with 3 states >,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\end{Verbatim}982}983984985986\subsection{\textcolor{Chapter }{NormalizedAutomaton}}987\logpage{[ 2, 5, 8 ]}\nobreak988\hyperdef{L}{X7FA7DF6D87D63D67}{}989{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{NormalizedAutomaton({\mdseries\slshape A})\index{NormalizedAutomaton@\texttt{NormalizedAutomaton}}990\label{NormalizedAutomaton}991}\hfill{\scriptsize (function)}}\\992993994Produces an equivalent automaton but in which the initial state is numbered 1995and the accepting states have the greatest numbers.996\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]997!gapprompt@gap>B !gapinput@x:=Automaton("det",3,2,[[ 1, 2, 0 ],[ 0, 1, 2 ]],[2],[1, 2]);;Display(x);B998| 1 2 3999--------------1000a | 1 21001b | 1 21002Initial state: [ 2 ]1003Accepting states: [ 1, 2 ]1004!gapprompt@gap>B !gapinput@Display(NormalizedAutomaton(x));B1005| 1 2 31006--------------1007a | 1 31008b | 3 11009Initial state: [ 1 ]1010Accepting states: [ 3, 1 ]1011\end{Verbatim}1012}1013101410151016\subsection{\textcolor{Chapter }{UnionAutomata}}1017\logpage{[ 2, 5, 9 ]}\nobreak1018\hyperdef{L}{X7A94A77A7C65BA90}{}1019{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{UnionAutomata({\mdseries\slshape A, B})\index{UnionAutomata@\texttt{UnionAutomata}}1020\label{UnionAutomata}1021}\hfill{\scriptsize (function)}}\\102210231024Produces the disjoint union of the deterministic or non deterministic automata \texttt{A} and \texttt{B}. The output is a non-deterministic automaton.1025\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]1026!gapprompt@gap>B !gapinput@x:=Automaton("det",3,2,[ [ 1, 2, 0 ], [ 0, 1, 2 ] ],[ 2 ],[ 1, 2 ]);;B1027!gapprompt@gap>B !gapinput@y:=Automaton("det",3,2,[ [ 0, 1, 3 ], [ 0, 0, 0 ] ],[ 1 ],[ 1, 2, 3 ]);;B1028!gapprompt@gap>B !gapinput@UnionAutomata(x,y);B1029< non deterministic automaton on 2 letters with 6 states >1030!gapprompt@gap>B !gapinput@Display(last);B1031| 1 2 3 4 5 61032------------------------------------------------1033a | [ 1 ] [ 2 ] [ 4 ] [ 6 ]1034b | [ 1 ] [ 2 ]1035Initial states: [ 2, 4 ]1036Accepting states: [ 1, 2, 4, 5, 6 ]1037\end{Verbatim}1038}1039104010411042\subsection{\textcolor{Chapter }{ProductAutomaton}}1043\logpage{[ 2, 5, 10 ]}\nobreak1044\hyperdef{L}{X83E772F2878546A4}{}1045{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ProductAutomaton({\mdseries\slshape A1, A2})\index{ProductAutomaton@\texttt{ProductAutomaton}}1046\label{ProductAutomaton}1047}\hfill{\scriptsize (function)}}\\104810491050The arguments must be deterministic automata. Returns the product of \mbox{\texttt{\mdseries\slshape A1}} and \mbox{\texttt{\mdseries\slshape A2}}.10511052Note: $(p,q)->(p-1)m+q$ is a bijection from $\{1,\ldots, n\}\times \{1,\ldots, m\}$ to $\{1,\ldots,mn\}$.1053\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]1054!gapprompt@gap>B !gapinput@x:=RandomAutomaton("det",3,2);;Display(x);B1055| 1 2 31056--------------1057a | 2 31058b | 11059Initial state: [ 3 ]1060Accepting states: [ 1, 2, 3 ]1061!gapprompt@gap>B !gapinput@y:=RandomAutomaton("det",3,2);;Display(y);B1062| 1 2 31063--------------1064a | 11065b | 1 31066Initial state: [ 3 ]1067Accepting states: [ 1, 3 ]1068!gapprompt@gap>B !gapinput@z:=ProductAutomaton(x, y);;Display(z);B1069| 1 2 3 4 5 6 7 8 91070--------------------------------1071a | 4 71072b | 1 31073Initial state: [ 9 ]1074Accepting states: [ 1, 3, 4, 6, 7, 9 ]1075\end{Verbatim}1076}1077107810791080\subsection{\textcolor{Chapter }{ProductOfLanguages}}1081\logpage{[ 2, 5, 11 ]}\nobreak1082\hyperdef{L}{X85F6AD697DCA5765}{}1083{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ProductOfLanguages({\mdseries\slshape A1, A2})\index{ProductOfLanguages@\texttt{ProductOfLanguages}}1084\label{ProductOfLanguages}1085}\hfill{\scriptsize (function)}}\\108610871088Given two regular languages (as automata or rational expressions), returns an1089automaton that recognizes the concatenation of the given languages, that is,1090the set of words $uv$ such that $u$ belongs to the first language and $v$ belongs to the second language.1091\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]1092!gapprompt@gap>| !gapinput@a1:=ListOfWordsToAutomaton("ab",["aa","bb"]);|1093< deterministic automaton on 2 letters with 5 states >1094!gapprompt@gap>| !gapinput@a2:=ListOfWordsToAutomaton("ab",["a","b"]);|1095< deterministic automaton on 2 letters with 3 states >1096!gapprompt@gap>| !gapinput@ProductOfLanguages(a1,a2);|1097< deterministic automaton on 2 letters with 5 states >1098!gapprompt@gap>| !gapinput@FAtoRatExp(last);|1099(bbUaa)(aUb)1100\end{Verbatim}1101}11021103}110411051106\section{\textcolor{Chapter }{Links with Semigroups}}\logpage{[ 2, 6, 0 ]}1107\hyperdef{L}{X79F21CB37B34A354}{}1108{1109Each letter of the alphabet of an automaton induces a partial transformation1110in its set of states. The semigroup generated by these transformations is1111called the \emph{transition semigroup} of the automaton.11121113\subsection{\textcolor{Chapter }{TransitionSemigroup}}1114\logpage{[ 2, 6, 1 ]}\nobreak1115\hyperdef{L}{X7B9994827CF94CC7}{}1116{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{TransitionSemigroup({\mdseries\slshape aut})\index{TransitionSemigroup@\texttt{TransitionSemigroup}}1117\label{TransitionSemigroup}1118}\hfill{\scriptsize (function)}}\\111911201121Returns the transition semigroup of the deterministic automaton \mbox{\texttt{\mdseries\slshape aut}}.1122\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]1123!gapprompt@gap>| !gapinput@aut := Automaton("det",10,2,[[7,5,7,5,4,9,10,9,10,9],|1124!gapprompt@>| !gapinput@[8,6,8,9,9,1,3,1,9,9]],[2],[6,7,8,9,10]);;|1125!gapprompt@gap>| !gapinput@s := TransitionSemigroup(aut);; |1126!gapprompt@gap>| !gapinput@Size(s); |1127301128\end{Verbatim}1129The transition semigroup of the minimal automaton recognizing a language is1130the \texttt{\symbol{123}}\texttt{\symbol{92}}it syntactic1131semigroup\texttt{\symbol{125}} of that language. }1132113311341135\subsection{\textcolor{Chapter }{SyntacticSemigroupAut}}1136\logpage{[ 2, 6, 2 ]}\nobreak1137\hyperdef{L}{X7E3F29DF86A26347}{}1138{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{SyntacticSemigroupAut({\mdseries\slshape aut})\index{SyntacticSemigroupAut@\texttt{SyntacticSemigroupAut}}1139\label{SyntacticSemigroupAut}1140}\hfill{\scriptsize (function)}}\\114111421143Returns the syntactic semigroup of the deterministic automaton \mbox{\texttt{\mdseries\slshape aut}} (i.e. the transition semigroup of the equivalent minimal automaton) when it is1144non empty and returns \texttt{fail} otherwise.1145\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]1146!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 1, 2, 0 ], [ 0, 1, 2 ] ],[ 2 ],[ 1, 2 ]);;|1147!gapprompt@gap>| !gapinput@S:=SyntacticSemigroupAut(x);;|1148!gapprompt@gap>| !gapinput@Size(S);|114931150\end{Verbatim}1151}1152115311541155\subsection{\textcolor{Chapter }{SyntacticSemigroupLang}}1156\logpage{[ 2, 6, 3 ]}\nobreak1157\hyperdef{L}{X7D058F0D83D7B49B}{}1158{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{SyntacticSemigroupLang({\mdseries\slshape rat})\index{SyntacticSemigroupLang@\texttt{SyntacticSemigroupLang}}1159\label{SyntacticSemigroupLang}1160}\hfill{\scriptsize (function)}}\\116111621163Returns the syntactic semigroup of the language given by the rational1164expression \mbox{\texttt{\mdseries\slshape rat}}.1165\begin{Verbatim}[commandchars=!|A,fontsize=\small,frame=single,label=Example]1166!gapprompt|gap>A !gapinput|rat := RationalExpression("a*ba*ba*(@Ub)");;A1167!gapprompt|gap>A !gapinput|S:=SyntacticSemigroupLang(rat);;A1168!gapprompt|gap>A !gapinput|Size(S);A116971170\end{Verbatim}1171}11721173}11741175}117611771178\chapter{\textcolor{Chapter }{Rational languages}}\logpage{[ 3, 0, 0 ]}1179\hyperdef{L}{X833D315483172905}{}1180{1181Rational languages are conveniently represented through rational expressions.1182These 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}1183\section{\textcolor{Chapter }{Rational Expressions}}\logpage{[ 3, 1, 0 ]}1184\hyperdef{L}{X7C144D368043DE01}{}1185{1186The expressions \texttt{@} and \texttt{"empty\texttt{\symbol{92}}{\textunderscore}set"} are used to represent the empty word and the empty set respectively.11871188\subsection{\textcolor{Chapter }{RationalExpression}}1189\logpage{[ 3, 1, 1 ]}\nobreak1190\hyperdef{L}{X801EC6F38568426D}{}1191{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RationalExpression({\mdseries\slshape expr[, alph]})\index{RationalExpression@\texttt{RationalExpression}}1192\label{RationalExpression}1193}\hfill{\scriptsize (function)}}\\119411951196A 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 symbols1197(other than '"', etc...) occurring in the expression. (The alphabet is then1198ordered with the alphabetical order.)1199\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]1200!gapprompt@gap>| !gapinput@RationalExpression("abUc");|1201abUc1202!gapprompt@gap>| !gapinput@RationalExpression("ab*Uc");|1203ab*Uc1204!gapprompt@gap>| !gapinput@RationalExpression("001U1*");|1205001U1*1206!gapprompt@gap>| !gapinput@RationalExpression("001U1*","012");|1207001U1*1208\end{Verbatim}1209}1210121112121213\subsection{\textcolor{Chapter }{RatExpOnnLetters}}1214\logpage{[ 3, 1, 2 ]}\nobreak1215\hyperdef{L}{X7EE5A70F7F237C41}{}1216{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RatExpOnnLetters({\mdseries\slshape n, operation, list})\index{RatExpOnnLetters@\texttt{RatExpOnnLetters}}1217\label{RatExpOnnLetters}1218}\hfill{\scriptsize (function)}}\\121912201221This is another way to construct a rational expression over an alphabet. The1222user 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 of1223``star'', or a list consisting of an integer when the rational expression is a1224single letter. The empty list \texttt{[ ]} and \texttt{empty\texttt{\symbol{92}}{\textunderscore}set} are other possibilities for \texttt{list}. An example follows1225\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]1226!gapprompt@gap>| !gapinput@RatExpOnnLetters(2,"star",RatExpOnnLetters(2,"product",|1227!gapprompt@>| !gapinput@[RatExpOnnLetters(2,[],[1]),RatExpOnnLetters(2,"union",|1228!gapprompt@>| !gapinput@[RatExpOnnLetters(2,[],[1]),RatExpOnnLetters(2,[],[2])])])); |1229(a(aUb))*1230\end{Verbatim}1231The empty word and the empty set are the rational expressions:1232\begin{Verbatim}[commandchars=!|A,fontsize=\small,frame=single,label=Example]1233!gapprompt|gap>A !gapinput|RatExpOnnLetters(2,[],[]); A1234@1235!gapprompt|gap>A !gapinput|RatExpOnnLetters(2,[],"empty_set");A1236empty_set1237\end{Verbatim}1238}1239124012411242\subsection{\textcolor{Chapter }{RandomRatExp}}1243\logpage{[ 3, 1, 3 ]}\nobreak1244\hyperdef{L}{X7DA59CBE8571796C}{}1245{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RandomRatExp({\mdseries\slshape arg})\index{RandomRatExp@\texttt{RandomRatExp}}1246\label{RandomRatExp}1247}\hfill{\scriptsize (function)}}\\124812491250Given the number of symbols of the alphabet and (possibly) a factor $m$ which is intended to increase the randomality of the expression, returns a1251pseudo random rational expression over that alphabet.1252\begin{Verbatim}[commandchars=!|A,fontsize=\small,frame=single,label=Example]1253!gapprompt|gap>A !gapinput|RandomRatExp(2);A1254b*(@Ua)1255!gapprompt|gap>A !gapinput|RandomRatExp("01");A1256empty_set1257!gapprompt|gap>A !gapinput|RandomRatExp("01");A1258(0U1)*1259!gapprompt|gap>A !gapinput|RandomRatExp("01",7);A12600*1(@U0U1)1261\end{Verbatim}1262}1263126412651266\subsection{\textcolor{Chapter }{SizeRatExp}}1267\logpage{[ 3, 1, 4 ]}\nobreak1268\hyperdef{L}{X7E3AA84784019E6C}{}1269{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{SizeRatExp({\mdseries\slshape r})\index{SizeRatExp@\texttt{SizeRatExp}}1270\label{SizeRatExp}1271}\hfill{\scriptsize (function)}}\\127212731274Returns the size, i.e. the number of symbols of the alphabet, of the rational1275expression \mbox{\texttt{\mdseries\slshape r}}.1276\begin{Verbatim}[commandchars=!|A,fontsize=\small,frame=single,label=Example]1277!gapprompt|gap>A !gapinput|a:=RationalExpression("0*1(@U0U1)");A12780*1(@U0U1)1279!gapprompt|gap>A !gapinput|SizeRatExp(a);A128051281\end{Verbatim}1282}1283128412851286\subsection{\textcolor{Chapter }{IsRationalExpression}}1287\logpage{[ 3, 1, 5 ]}\nobreak1288\hyperdef{L}{X7DDB46817D6E79BE}{}1289{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsRationalExpression({\mdseries\slshape r})\index{IsRationalExpression@\texttt{IsRationalExpression}}1290\label{IsRationalExpression}1291}\hfill{\scriptsize (function)}}\\129212931294Tests whether an object is a rational expression.1295\begin{Verbatim}[commandchars=!|A,fontsize=\small,frame=single,label=Example]1296!gapprompt|gap>A !gapinput|r := RandomRatExp("01",7);A12971(0U1)U@1298!gapprompt|gap>A !gapinput|IsRatExpOnnLettersObj(r) and IsRationalExpressionRep(r);A1299true1300!gapprompt|gap>A !gapinput|IsRationalExpression(RandomRatExp("01"));A1301true1302\end{Verbatim}1303}1304130513061307\subsection{\textcolor{Chapter }{AlphabetOfRatExp}}1308\logpage{[ 3, 1, 6 ]}\nobreak1309\hyperdef{L}{X8773359880149A98}{}1310{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AlphabetOfRatExp({\mdseries\slshape R})\index{AlphabetOfRatExp@\texttt{AlphabetOfRatExp}}1311\label{AlphabetOfRatExp}1312}\hfill{\scriptsize (function)}}\\131313141315Returns the number of symbols in the alphabet of the rational expression \texttt{R}.1316\begin{Verbatim}[commandchars=!|B,fontsize=\small,frame=single,label=Example]1317!gapprompt|gap>B !gapinput|r:=RandomRatExp(2);B1318a*(ba*U@)1319!gapprompt|gap>B !gapinput|AlphabetOfRatExp(r);B132021321!gapprompt|gap>B !gapinput|r:=RandomRatExp("01");B13221*(01*U@)1323!gapprompt|gap>B !gapinput|AlphabetOfRatExp(r);B132421325!gapprompt|gap>B !gapinput|a:=RandomTransformation(3);;B1326!gapprompt|gap>B !gapinput|b:=RandomTransformation(3);;B1327!gapprompt|gap>B !gapinput|r:=RandomRatExp([a,b]);B1328(Transformation( [ 1, 1, 3 ] )UTransformation( [ 1, 1, 2 ] ))*1329!gapprompt|gap>B !gapinput|AlphabetOfRatExp(r);B133021331\end{Verbatim}1332}1333133413351336\subsection{\textcolor{Chapter }{AlphabetOfRatExpAsList}}1337\logpage{[ 3, 1, 7 ]}\nobreak1338\hyperdef{L}{X84B9922B7C006158}{}1339{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AlphabetOfRatExpAsList({\mdseries\slshape R})\index{AlphabetOfRatExpAsList@\texttt{AlphabetOfRatExpAsList}}1340\label{AlphabetOfRatExpAsList}1341}\hfill{\scriptsize (function)}}\\134213431344Returns the alphabet of the rational expression \texttt{R} always as a list. If the alphabet of the rational expression is given by means1345of an integer less than 27 it returns the list \texttt{"abcd...."}, otherwise returns \texttt{[ "a1", "a2", "a3", "a4", ... ]}.1346\begin{Verbatim}[commandchars=!|B,fontsize=\small,frame=single,label=Example]1347!gapprompt|gap>B !gapinput|r:=RandomRatExp(2);B1348(aUb)((aUb)(bU@)U@)U@1349!gapprompt|gap>B !gapinput|AlphabetOfRatExpAsList(r);B1350"ab"1351!gapprompt|gap>B !gapinput|r:=RandomRatExp("01");B13521*(0U@)1353!gapprompt|gap>B !gapinput|AlphabetOfRatExpAsList(r);B1354"01"1355!gapprompt|gap>B !gapinput|r:=RandomRatExp(30);;B1356!gapprompt|gap>B !gapinput|AlphabetOfRatExpAsList(r);B1357[ "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11",1358"a12", "a13", "a14", "a15", "a16", "a17", "a18", "a19", "a20", "a21",1359"a22", "a23", "a24", "a25", "a26", "a27", "a28", "a29", "a30" ]1360\end{Verbatim}1361}1362136313641365\subsection{\textcolor{Chapter }{CopyRatExp}}1366\logpage{[ 3, 1, 8 ]}\nobreak1367\hyperdef{L}{X786A096681CAC3CD}{}1368{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{CopyRatExp({\mdseries\slshape R})\index{CopyRatExp@\texttt{CopyRatExp}}1369\label{CopyRatExp}1370}\hfill{\scriptsize (function)}}\\137113721373Returns a new rational expression, which is a copy of \texttt{R}.1374\begin{Verbatim}[commandchars=!|A,fontsize=\small,frame=single,label=Example]1375!gapprompt|gap>A !gapinput|r:=RandomRatExp(2);A1376a*(bU@)1377!gapprompt|gap>A !gapinput|CopyRatExp(r);A1378a*(bU@)1379\end{Verbatim}1380}13811382}138313841385\section{\textcolor{Chapter }{Comparison of rational expressions}}\logpage{[ 3, 2, 0 ]}1386\hyperdef{L}{X7FB9270D7E8FABF3}{}1387{1388The 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 r11389and r2 are letters, then the lesser is taken from the order in the alphabet;1390if r1 is a letter an r2 a product, union or star, then r1 is lesser than r2; a1391star expression is considered to be lesser than a product or union expression1392and a product lesser than a union; to compare two star expressions we compare1393the expressions under the stars; to compare two product or union expressions1394we compare the subexpressions of each expression from left to right; }139513961397\section{\textcolor{Chapter }{Operations with rational languages}}\logpage{[ 3, 3, 0 ]}1398\hyperdef{L}{X83A280D47DB3A033}{}1399{1400Only operations with rational languages over the same alphabet are allowed.14011402We may compute expressions for the \texttt{product}, \texttt{union} and \texttt{star} (i.e., submonoid generated by) of rational sets. In some cases, simpler1403expressions representing the same set are returned. Note that that two1404simplifications are always made, namely, $r\cup"empty_set" = r$ and $r\epsilon = r$ . Of course, these operations may be used to construct more complex1405expressions. 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}.14061407\subsection{\textcolor{Chapter }{UnionRatExp}}1408\logpage{[ 3, 3, 1 ]}\nobreak1409\hyperdef{L}{X8206BD4E82A81D8F}{}1410{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{UnionRatExp({\mdseries\slshape r, s})\index{UnionRatExp@\texttt{UnionRatExp}}1411\label{UnionRatExp}1412}\hfill{\scriptsize (function)}}\\1413}1414141514161417\subsection{\textcolor{Chapter }{ProductRatExp}}1418\logpage{[ 3, 3, 2 ]}\nobreak1419\hyperdef{L}{X7E29107587611CE2}{}1420{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ProductRatExp({\mdseries\slshape r, s})\index{ProductRatExp@\texttt{ProductRatExp}}1421\label{ProductRatExp}1422}\hfill{\scriptsize (function)}}\\1423}1424142514261427\subsection{\textcolor{Chapter }{ StarRatExp}}1428\logpage{[ 3, 3, 3 ]}\nobreak1429\hyperdef{L}{X83D8DAE6862C8A96}{}1430{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ StarRatExp({\mdseries\slshape r})\index{ StarRatExp@\texttt{ StarRatExp}}1431\label{ StarRatExp}1432}\hfill{\scriptsize (function)}}\\143314341435The expression \texttt{(a(aUb))*} may be produced in the following way1436\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]1437!gapprompt@gap>| !gapinput@r1 := RatExpOnnLetters(2,[],[1]); |1438a1439!gapprompt@gap>| !gapinput@r2 := RatExpOnnLetters(2,[],[2]);|1440b1441!gapprompt@gap>| !gapinput@r3 := UnionRatExp(r1,r2);|1442aUb1443!gapprompt@gap>| !gapinput@r4 := ProductRatExp(r1,r3);|1444a(aUb)1445!gapprompt@gap>| !gapinput@r5 := StarRatExp(r4);|1446(a(aUb))*1447\end{Verbatim}1448}14491450}14511452}145314541455\chapter{\textcolor{Chapter }{Automata \emph{versus} rational expressions}}\logpage{[ 4, 0, 0 ]}1456\hyperdef{L}{X814B7AD47E8EDAFA}{}1457{1458A remarkable theorem due to Kleene shows that a language is recognized by a1459finite automaton precisely when it may be given by means of a rational1460expression, i.e. is a rational language.14611462An automaton and a rational expression are said to be \emph{equivalent} when both represent the same language. In this chapter we describe functions1463to go from automata to equivalent rational expressions and \emph{vice-versa}.1464\section{\textcolor{Chapter }{From automata to rational expressions}}\logpage{[ 4, 1, 0 ]}1465\hyperdef{L}{X7E631B92873300C1}{}1466{146714681469\subsection{\textcolor{Chapter }{AutomatonToRatExp }}1470\logpage{[ 4, 1, 1 ]}\nobreak1471\hyperdef{L}{X8751E3927CA4DEA1}{}1472{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AutomatonToRatExp ({\mdseries\slshape A})\index{AutomatonToRatExp @\texttt{AutomatonToRatExp }}1473\label{AutomatonToRatExp }1474}\hfill{\scriptsize (function)}}\\1475\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AutToRatExp({\mdseries\slshape A})\index{AutToRatExp@\texttt{AutToRatExp}}1476\label{AutToRatExp}1477}\hfill{\scriptsize (function)}}\\1478\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{FAtoRatExp({\mdseries\slshape A})\index{FAtoRatExp@\texttt{FAtoRatExp}}1479\label{FAtoRatExp}1480}\hfill{\scriptsize (function)}}\\148114821483From a finite automaton, \texttt{FAtoRatExp}, \texttt{AutToRatExp} and \texttt{AutomatonToRatExp}, which are synonyms, compute one equivalent rational expression, using the1484state elimination algorithm.1485\begin{Verbatim}[commandchars=!|B,fontsize=\small,frame=single,label=Example]1486!gapprompt|gap>B !gapinput|x:=Automaton("det",4,2,[[ 0, 1, 2, 3 ],[ 0, 1, 2, 3 ]],[ 3 ],[ 1, 3, 4 ]);;B1487!gapprompt|gap>B !gapinput|FAtoRatExp(x);B1488(aUb)(aUb)U@1489!gapprompt|gap>B !gapinput|aut:=Automaton("det",4,"xy",[[ 0, 1, 2, 3 ],[ 0, 1, 2, 3 ]],[ 3 ],[ 1, 3, 4 ]);;B1490!gapprompt|gap>B !gapinput|FAtoRatExp(aut);B1491(xUy)(xUy)U@1492\end{Verbatim}1493}14941495}149614971498\section{\textcolor{Chapter }{From rational expression to automata}}\logpage{[ 4, 2, 0 ]}1499\hyperdef{L}{X8138227D7E65FC8C}{}1500{150115021503\subsection{\textcolor{Chapter }{RatExpToNDAut}}1504\logpage{[ 4, 2, 1 ]}\nobreak1505\hyperdef{L}{X840EEB7B7DD8B03D}{}1506{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RatExpToNDAut({\mdseries\slshape R})\index{RatExpToNDAut@\texttt{RatExpToNDAut}}1507\label{RatExpToNDAut}1508}\hfill{\scriptsize (function)}}\\150915101511Given a rational expression \mbox{\texttt{\mdseries\slshape R}}, computes the equivalent NFA1512\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]1513!gapprompt@gap>B !gapinput@r:=RationalExpression("aUab");B1514aUab1515!gapprompt@gap>B !gapinput@Display(RatExpToNDAut(r));B1516| 1 2 3 41517--------------------------------1518a | [ 1, 2 ]1519b | [ 3 ]1520Initial state: [ 4 ]1521Accepting states: [ 1, 3 ]1522!gapprompt@gap>B !gapinput@r:=RationalExpression("xUxy"); B1523xUxy1524!gapprompt@gap>B !gapinput@Display(RatExpToNDAut(r)); B1525| 1 2 3 41526--------------------------------1527x | [ 1, 2 ]1528y | [ 3 ]1529Initial state: [ 4 ]1530Accepting states: [ 1, 3 ]1531\end{Verbatim}1532}1533153415351536\subsection{\textcolor{Chapter }{RatExpToAutomaton}}1537\logpage{[ 4, 2, 2 ]}\nobreak1538\hyperdef{L}{X866BCCB2788E8561}{}1539{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RatExpToAutomaton({\mdseries\slshape R})\index{RatExpToAutomaton@\texttt{RatExpToAutomaton}}1540\label{RatExpToAutomaton}1541}\hfill{\scriptsize (function)}}\\1542\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RatExpToAut({\mdseries\slshape R})\index{RatExpToAut@\texttt{RatExpToAut}}1543\label{RatExpToAut}1544}\hfill{\scriptsize (function)}}\\154515461547Given 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 DFA1548\begin{Verbatim}[commandchars=!BC,fontsize=\small,frame=single,label=Example]1549!gappromptBgap>C !gapinputBr:=RationalExpression("@U(aUb)(aUb)");C1550@U(aUb)(aUb)1551!gappromptBgap>C !gapinputBDisplay(RatExpToAut(r));C1552| 1 2 3 41553-----------------1554a | 3 1 3 21555b | 3 1 3 21556Initial state: [ 4 ]1557Accepting states: [ 1, 4 ]1558!gappromptBgap>C !gapinputBr:=RationalExpression("@U(0U1)(0U1)");C1559@U(0U1)(0U1)1560!gappromptBgap>C !gapinputBDisplay(RatExpToAut(r)); C1561| 1 2 3 41562-----------------15630 | 3 1 3 215641 | 3 1 3 21565Initial state: [ 4 ]1566Accepting states: [ 1, 4 ]1567\end{Verbatim}1568}15691570}157115721573\section{\textcolor{Chapter }{ Some tests on automata }}\logpage{[ 4, 3, 0 ]}1574\hyperdef{L}{X85DCEFB88712056E}{}1575{1576This section describes functions that perform tests on automata, rational1577expressions and their accepted languages.15781579\subsection{\textcolor{Chapter }{IsEmptyLang}}1580\logpage{[ 4, 3, 1 ]}\nobreak1581\hyperdef{L}{X84E0143A860889A6}{}1582{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsEmptyLang({\mdseries\slshape R})\index{IsEmptyLang@\texttt{IsEmptyLang}}1583\label{IsEmptyLang}1584}\hfill{\scriptsize (function)}}\\158515861587This function tests if the language given through a rational expression or an1588automaton \mbox{\texttt{\mdseries\slshape R }} is the empty language.1589\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]1590!gapprompt@gap>| !gapinput@r:=RandomRatExp(2);|1591empty_set1592!gapprompt@gap>| !gapinput@IsEmptyLang(r);|1593true1594!gapprompt@gap>| !gapinput@r:=RandomRatExp(2);|1595aUb1596!gapprompt@gap>| !gapinput@IsEmptyLang(r);|1597false1598\end{Verbatim}1599}1600160116021603\subsection{\textcolor{Chapter }{IsFullLang}}1604\logpage{[ 4, 3, 2 ]}\nobreak1605\hyperdef{L}{X86AA1A5F7E1EEAFE}{}1606{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsFullLang({\mdseries\slshape R})\index{IsFullLang@\texttt{IsFullLang}}1607\label{IsFullLang}1608}\hfill{\scriptsize (function)}}\\160916101611This function tests if the language given through a rational expression or an1612automaton \mbox{\texttt{\mdseries\slshape R }} represents the Kleene closure of the alphabet of \mbox{\texttt{\mdseries\slshape R }} .1613\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]1614!gapprompt@gap>| !gapinput@r:=RationalExpression("aUb");|1615aUb1616!gapprompt@gap>| !gapinput@IsFullLang(r);|1617false1618!gapprompt@gap>| !gapinput@r:=RationalExpression("(aUb)*");|1619(aUb)*1620!gapprompt@gap>| !gapinput@IsFullLang(r);|1621true1622\end{Verbatim}1623}1624162516261627\subsection{\textcolor{Chapter }{AreEqualLang}}1628\logpage{[ 4, 3, 3 ]}\nobreak1629\hyperdef{L}{X8346D1B17DBF96E7}{}1630{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AreEqualLang({\mdseries\slshape A1, A2})\index{AreEqualLang@\texttt{AreEqualLang}}1631\label{AreEqualLang}1632}\hfill{\scriptsize (function)}}\\1633\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AreEquivAut({\mdseries\slshape A1, A2})\index{AreEquivAut@\texttt{AreEquivAut}}1634\label{AreEquivAut}1635}\hfill{\scriptsize (function)}}\\163616371638These functions, which are synonyms, test if the automata or rational1639expressions \mbox{\texttt{\mdseries\slshape A1}} and \mbox{\texttt{\mdseries\slshape A2}} are equivalent, i.e. represent the same language. This is performed by1640checking that the corresponding minimal automata are isomorphic. Note hat this1641cannot happen if the alphabets are different.1642\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]1643!gapprompt@gap>| !gapinput@y:=RandomAutomaton("det",4,2);;|1644!gapprompt@gap>| !gapinput@x:=RandomAutomaton("det",4,2);;|1645!gapprompt@gap>| !gapinput@AreEquivAut(x, y);|1646false1647!gapprompt@gap>| !gapinput@a:=RationalExpression("(aUb)*ab*");|1648(aUb)*ab*1649!gapprompt@gap>| !gapinput@b:=RationalExpression("(aUb)*");|1650(aUb)*1651!gapprompt@gap>| !gapinput@AreEqualLang(a, b);|1652false1653!gapprompt@gap>| !gapinput@a:=RationalExpression("(bUa)*");|1654(bUa)*1655!gapprompt@gap>| !gapinput@AreEqualLang(a, b);|1656true1657!gapprompt@gap>| !gapinput@x:=RationalExpression("(1U0)*");|1658(1U0)*1659!gapprompt@gap>| !gapinput@AreEqualLang(a, x); |1660The given languages are not over the same alphabet1661false1662\end{Verbatim}1663}1664166516661667\subsection{\textcolor{Chapter }{IsContainedLang}}1668\logpage{[ 4, 3, 4 ]}\nobreak1669\hyperdef{L}{X7FCB176285FA5BBB}{}1670{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsContainedLang({\mdseries\slshape R1, R2})\index{IsContainedLang@\texttt{IsContainedLang}}1671\label{IsContainedLang}1672}\hfill{\scriptsize (function)}}\\167316741675Tests if the language represented (through an automaton or a rational1676expression) by \mbox{\texttt{\mdseries\slshape R1 }} is contained in the language represented (through an automaton or a rational1677expression) by \mbox{\texttt{\mdseries\slshape R2 }} .1678\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]1679!gapprompt@gap>| !gapinput@r:=RationalExpression("aUab");|1680aUab1681!gapprompt@gap>| !gapinput@s:=RationalExpression("a","ab");|1682a1683!gapprompt@gap>| !gapinput@IsContainedLang(s,r);|1684true1685!gapprompt@gap>| !gapinput@IsContainedLang(r,s);|1686false1687\end{Verbatim}1688}1689169016911692\subsection{\textcolor{Chapter }{AreDisjointLang}}1693\logpage{[ 4, 3, 5 ]}\nobreak1694\hyperdef{L}{X83F1DE067C2D31A5}{}1695{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AreDisjointLang({\mdseries\slshape R1, R2})\index{AreDisjointLang@\texttt{AreDisjointLang}}1696\label{AreDisjointLang}1697}\hfill{\scriptsize (function)}}\\169816991700Tests if the languages represented (through automata or a rational1701expressions) by \mbox{\texttt{\mdseries\slshape R1 }} and \mbox{\texttt{\mdseries\slshape R2 }} are disjoint.1702\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]1703!gapprompt@gap>| !gapinput@r:=RationalExpression("aUab");;|1704!gapprompt@gap>| !gapinput@s:=RationalExpression("a","ab");;|1705!gapprompt@gap>| !gapinput@AreDisjointLang(r,s);|1706false1707\end{Verbatim}1708}17091710}17111712}171317141715\chapter{\textcolor{Chapter }{Some functions involving automata}}\logpage{[ 5, 0, 0 ]}1716\hyperdef{L}{X7919AA9384EBC6A5}{}1717{1718This chapter describes some functions involving automata. It starts with1719functions to obtain equivalent automata of other type. Then the minimalization1720is considered.1721\section{\textcolor{Chapter }{From one type to another}}\logpage{[ 5, 1, 0 ]}1722\hyperdef{L}{X8050E142796E0CBF}{}1723{1724Recall that two automata are said to be equivalent when they recognize the1725same language. Next we have functions which have as input automata of one type1726and as output equivalent automata of another type.17271728\subsection{\textcolor{Chapter }{EpsilonToNFA}}1729\logpage{[ 5, 1, 1 ]}\nobreak1730\hyperdef{L}{X81E06D518428CA3C}{}1731{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{EpsilonToNFA({\mdseries\slshape A})\index{EpsilonToNFA@\texttt{EpsilonToNFA}}1732\label{EpsilonToNFA}1733}\hfill{\scriptsize (function)}}\\173417351736\mbox{\texttt{\mdseries\slshape A}} is an automaton with $\epsilon$-transitions. Returns a NFA recognizing the same language.1737\begin{Verbatim}[commandchars=!BC,fontsize=\small,frame=single,label=Example]1738!gappromptBgap>C !gapinputBx:=RandomAutomaton("epsilon",3,2);;Display(x);C1739| 1 2 31740------------------------------------1741a | [ 2 ] [ 3 ] [ 2 ]1742b | [ 1, 2 ] [ 1, 2 ] [ 1, 3 ]1743@ | [ 1, 2 ] [ 1, 2 ] [ 1, 2 ]1744Initial states: [ 2, 3 ]1745Accepting states: [ 1, 2, 3 ]1746!gappromptBgap>C !gapinputBDisplay(EpsilonToNFA(x));C1747| 1 2 31748------------------------------------------1749a | [ 1, 2 ] [ 1, 2, 3 ] [ 1, 2 ]1750b | [ 1, 2 ] [ 1, 2 ] [ 1, 2, 3 ]1751Initial states: [ 1, 2, 3 ]1752Accepting states: [ 1, 2, 3 ]1753\end{Verbatim}1754}1755175617571758\subsection{\textcolor{Chapter }{EpsilonToNFASet}}1759\logpage{[ 5, 1, 2 ]}\nobreak1760\hyperdef{L}{X81DC84E17A170270}{}1761{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{EpsilonToNFASet({\mdseries\slshape A})\index{EpsilonToNFASet@\texttt{EpsilonToNFASet}}1762\label{EpsilonToNFASet}1763}\hfill{\scriptsize (function)}}\\176417651766\mbox{\texttt{\mdseries\slshape A}} is an automaton with $\epsilon$-transitions. Returns a NFA recognizing the same language. This function1767differs from \texttt{EpsilonToNFA} (\ref{EpsilonToNFA}) in that it is faster for smaller automata, or automata with few epsilon1768transitions, but slower in the really hard cases. }1769177017711772\subsection{\textcolor{Chapter }{EpsilonCompactedAut}}1773\logpage{[ 5, 1, 3 ]}\nobreak1774\hyperdef{L}{X871F807D79CE148C}{}1775{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{EpsilonCompactedAut({\mdseries\slshape A})\index{EpsilonCompactedAut@\texttt{EpsilonCompactedAut}}1776\label{EpsilonCompactedAut}1777}\hfill{\scriptsize (function)}}\\177817791780\mbox{\texttt{\mdseries\slshape A}} is an automaton with $\epsilon$-transitions. Returns an $\epsilon$NFA with each strongly-connected component of the epsilon-transitions digraph1781of \mbox{\texttt{\mdseries\slshape A}} identified with a single state and recognizing the same language.1782\begin{Verbatim}[commandchars=!BF,fontsize=\small,frame=single,label=Example]1783!gappromptBgap>F !gapinputBx:=RandomAutomaton("epsilon",3,2);;Display(x);F1784| 1 2 31785------------------------------------1786a | [ 1, 2 ] [ 1, 3 ] [ 1, 2 ]1787b | [ 1, 2 ] [ 1, 2 ] [ 2, 3 ]1788@ | [ 3 ] [ 2 ]1789Initial state: [ 3 ]1790Accepting states: [ 1, 3 ]1791!gappromptBgap>F !gapinputBDisplay(EpsilonCompactedAut(x));F1792| 1 21793-------------------------1794a | [ 1, 2 ] [ 1, 2 ]1795b | [ 1, 2 ] [ 1, 2 ]1796@ |1797Initial state: [ 2 ]1798Accepting states: [ 1, 2 ]1799\end{Verbatim}1800}1801180218031804\subsection{\textcolor{Chapter }{ReducedNFA}}1805\logpage{[ 5, 1, 4 ]}\nobreak1806\hyperdef{L}{X83B0473278DC14F3}{}1807{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ReducedNFA({\mdseries\slshape A})\index{ReducedNFA@\texttt{ReducedNFA}}1808\label{ReducedNFA}1809}\hfill{\scriptsize (function)}}\\181018111812\mbox{\texttt{\mdseries\slshape A}} is a non deterministic automaton (without $\epsilon$-transitions). Returns an NFA accepting the same language as its input but1813with possibly fewer states (it quotients out by the smallest right-invariant1814partition of the states). A paper describing the algorithm is in preparation.1815\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]1816!gapprompt@gap>B !gapinput@x:=RandomAutomaton("nondet",5,2);;Display(x);B1817| 1 2 3 4 51818----------------------------------------------------------------------1819a | [ 1, 5 ] [ 1, 2, 4, 5 ] [ 1, 3, 5 ] [ 3, 4, 5 ] [ 4 ]1820b | [ 2, 3, 4 ] [ 3 ] [ 2, 3, 4 ] [ 2, 4, 5 ] [ 3 ]1821Initial state: [ 4 ]1822Accepting states: [ 1, 3, 4, 5 ]1823!gapprompt@gap>B !gapinput@Display(ReducedNFA(x));B1824| 1 2 3 41825--------------------------------------------------------1826a | [ 1, 3 ] [ 1, 2, 3, 4 ] [ 4 ] [ 1, 3, 4 ]1827b | [ 1, 2, 4 ] [ 1 ] [ 1 ] [ 2, 3, 4 ]1828Initial state: [ 4 ]1829Accepting states: [ 1, 3, 4 ]1830\end{Verbatim}1831}1832183318341835\subsection{\textcolor{Chapter }{NFAtoDFA}}1836\logpage{[ 5, 1, 5 ]}\nobreak1837\hyperdef{L}{X87D0F9F17F2BEB57}{}1838{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{NFAtoDFA({\mdseries\slshape A})\index{NFAtoDFA@\texttt{NFAtoDFA}}1839\label{NFAtoDFA}1840}\hfill{\scriptsize (function)}}\\184118421843Given an NFA, these synonym functions, compute the equivalent DFA, using the1844powerset construction, according to the algorithm presented in the report of1845the AMoRE \cite{AMORE:95} program. The returned automaton is dense deterministic1846\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]1847!gapprompt@gap>B !gapinput@x:=RandomAutomaton("nondet",3,2);;Display(x);B1848| 1 2 31849---------------------------1850a | [ 2 ] [ 1, 3 ]1851b | [ 2, 3 ]1852Initial states: [ 1, 3 ]1853Accepting states: [ 1, 2 ]1854!gapprompt@gap>B !gapinput@Display(NFAtoDFA(x));B1855| 1 2 31856--------------1857a | 2 2 11858b | 3 3 31859Initial state: [ 1 ]1860Accepting states: [ 1, 2, 3 ]1861\end{Verbatim}1862}1863186418651866\subsection{\textcolor{Chapter }{FuseSymbolsAut}}1867\logpage{[ 5, 1, 6 ]}\nobreak1868\hyperdef{L}{X7B61945581FE4AC6}{}1869{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{FuseSymbolsAut({\mdseries\slshape A, s1, s2})\index{FuseSymbolsAut@\texttt{FuseSymbolsAut}}1870\label{FuseSymbolsAut}1871}\hfill{\scriptsize (function)}}\\187218731874Given 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}}.1875\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]1876!gapprompt@gap>B !gapinput@x:=RandomAutomaton("det",3,2);;Display(x);B1877| 1 2 31878--------------1879a | 2 31880b | 11881Initial state: [ 3 ]1882Accepting states: [ 1, 2, 3 ]1883!gapprompt@gap>B !gapinput@Display(FuseSymbolsAut(x,1,2));B1884| 1 2 31885---------------------------1886a | [ 2 ] [ 1, 3 ]1887Initial state: [ 3 ]1888Accepting states: [ 1, 2, 3 ]1889\end{Verbatim}1890}18911892}189318941895\section{\textcolor{Chapter }{Minimalization of an automaton}}\logpage{[ 5, 2, 0 ]}1896\hyperdef{L}{X862A34E9801BEB25}{}1897{1898The algorithm used to minimalize a dense deterministic automaton (i.e., to1899compute a dense minimal automaton recognizing the same language) is based on1900an 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 inaccessible1901states. Again, the documentation for the computer program AMoRE \cite{AMORE:95} has been very useful.19021903\subsection{\textcolor{Chapter }{UsefulAutomaton}}1904\logpage{[ 5, 2, 1 ]}\nobreak1905\hyperdef{L}{X7B5B5B10868FB525}{}1906{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{UsefulAutomaton({\mdseries\slshape A})\index{UsefulAutomaton@\texttt{UsefulAutomaton}}1907\label{UsefulAutomaton}1908}\hfill{\scriptsize (function)}}\\190919101911Given 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.1912\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]1913!gapprompt@gap>B !gapinput@x:=RandomAutomaton("det",4,2);;Display(x);B1914| 1 2 3 41915-----------------1916a | 3 41917b | 1 41918Initial state: [ 3 ]1919Accepting states: [ 2, 3, 4 ]1920!gapprompt@gap>B !gapinput@Display(UsefulAutomaton(x));B1921| 1 2 31922--------------1923a | 2 3 31924b | 3 3 31925Initial state: [ 1 ]1926Accepting states: [ 1, 2 ]1927\end{Verbatim}1928}1929193019311932\subsection{\textcolor{Chapter }{MinimalizedAut}}1933\logpage{[ 5, 2, 2 ]}\nobreak1934\hyperdef{L}{X83C26846866AEE46}{}1935{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{MinimalizedAut({\mdseries\slshape A})\index{MinimalizedAut@\texttt{MinimalizedAut}}1936\label{MinimalizedAut}1937}\hfill{\scriptsize (function)}}\\193819391940Returns the minimal automaton equivalent to \mbox{\texttt{\mdseries\slshape A}}.1941\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]1942!gapprompt@gap>B !gapinput@x:=RandomAutomaton("det",4,2);;Display(x);B1943| 1 2 3 41944-----------------1945a | 3 41946b | 1 2 31947Initial state: [ 4 ]1948Accepting states: [ 2, 3, 4 ]1949!gapprompt@gap>B !gapinput@Display(MinimalizedAut(x));B1950| 1 21951-----------1952a | 2 21953b | 2 21954Initial state: [ 1 ]1955Accepting state: [ 1 ]1956\end{Verbatim}1957}1958195919601961\subsection{\textcolor{Chapter }{ MinimalAutomaton}}1962\logpage{[ 5, 2, 3 ]}\nobreak1963\hyperdef{L}{X7F7AE088808A5D00}{}1964{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ MinimalAutomaton({\mdseries\slshape A})\index{ MinimalAutomaton@\texttt{ MinimalAutomaton}}1965\label{ MinimalAutomaton}1966}\hfill{\scriptsize (attribute)}}\\196719681969Returns the minimal automaton equivalent to \mbox{\texttt{\mdseries\slshape A}}, but stores it so that future computations of this automaton just return the1970stored automaton.1971\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]1972!gapprompt@gap>B !gapinput@x:=RandomAutomaton("det",4,2);;Display(x);B1973| 1 2 3 41974-----------------1975a | 2 41976b | 3 41977Initial state: [ 4 ]1978Accepting states: [ 1, 2, 3 ]1979!gapprompt@gap>B !gapinput@Display(MinimalAutomaton(x));B1980| 11981--------1982a | 11983b | 11984Initial state: [ 1 ]1985Accepting state:1986\end{Verbatim}1987}1988198919901991\subsection{\textcolor{Chapter }{AccessibleStates}}1992\logpage{[ 5, 2, 4 ]}\nobreak1993\hyperdef{L}{X7F484D5A781BB643}{}1994{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AccessibleStates({\mdseries\slshape aut[, p]})\index{AccessibleStates@\texttt{AccessibleStates}}1995\label{AccessibleStates}1996}\hfill{\scriptsize (function)}}\\199719981999Computes 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.2000\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]2001!gapprompt@gap>B !gapinput@x:=RandomAutomaton("det",4,2);;Display(x);B2002| 1 2 3 42003-----------------2004a | 1 2 42005b | 2 42006Initial state: [ 2 ]2007Accepting states: [ 1, 2, 3 ]2008!gapprompt@gap>B !gapinput@AccessibleStates(x,3);B2009[ 1, 2, 3, 4 ]2010\end{Verbatim}2011}2012201320142015\subsection{\textcolor{Chapter }{AccessibleAutomaton}}2016\logpage{[ 5, 2, 5 ]}\nobreak2017\hyperdef{L}{X804A6BC979DA6E61}{}2018{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AccessibleAutomaton({\mdseries\slshape A})\index{AccessibleAutomaton@\texttt{AccessibleAutomaton}}2019\label{AccessibleAutomaton}2020}\hfill{\scriptsize (function)}}\\202120222023If \mbox{\texttt{\mdseries\slshape A}} is a deterministic automaton, not necessarily dense, an equivalent dense2024deterministic accessible automaton is returned. (The function \texttt{UsefulAutomaton} is called.)20252026If \mbox{\texttt{\mdseries\slshape A}} is not deterministic with a single initial state, an equivalent accessible2027automaton is returned.2028\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]2029!gapprompt@gap>B !gapinput@x:=RandomAutomaton("det",4,2);;Display(x);B2030| 1 2 3 42031-----------------2032a | 1 32033b | 1 3 42034Initial state: [ 2 ]2035Accepting states: [ 3, 4 ]2036!gapprompt@gap>B !gapinput@Display(AccessibleAutomaton(x));B2037| 1 2 3 42038-----------------2039a | 2 4 4 42040b | 2 3 4 42041Initial state: [ 1 ]2042Accepting states: [ 2, 3 ]2043\end{Verbatim}2044}2045204620472048\subsection{\textcolor{Chapter }{IntersectionLanguage}}2049\logpage{[ 5, 2, 6 ]}\nobreak2050\hyperdef{L}{X7BAACCAF7E2D213B}{}2051{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IntersectionLanguage({\mdseries\slshape A1, A2})\index{IntersectionLanguage@\texttt{IntersectionLanguage}}2052\label{IntersectionLanguage}2053}\hfill{\scriptsize (function)}}\\2054\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IntersectionAutomaton({\mdseries\slshape A1, A2})\index{IntersectionAutomaton@\texttt{IntersectionAutomaton}}2055\label{IntersectionAutomaton}2056}\hfill{\scriptsize (function)}}\\205720582059Computes an automaton that recognizes the intersection of the languages given2060(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 as2061ProductAutomaton, but works for all kinds of automata. Note that the language2062of the product of two automata is precisely the intersection of the languages2063of the automata.2064\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]2065!gapprompt@gap>B !gapinput@x:=RandomAutomaton("det",3,2);;Display(x);B2066| 1 2 32067--------------2068a | 2 32069b | 12070Initial state: [ 3 ]2071Accepting states: [ 1, 2, 3 ]2072!gapprompt@gap>B !gapinput@y:=RandomAutomaton("det",3,2);;Display(y);B2073| 1 2 32074--------------2075a | 12076b | 1 32077Initial state: [ 3 ]2078Accepting states: [ 1, 3 ]2079!gapprompt@gap>B !gapinput@Display(IntersectionLanguage(x,y));B2080| 1 22081-----------2082a | 2 22083b | 2 22084Initial state: [ 1 ]2085Accepting state: [ 1 ]2086\end{Verbatim}2087}2088208920902091\subsection{\textcolor{Chapter }{AutomatonAllPairsPaths}}2092\logpage{[ 5, 2, 7 ]}\nobreak2093\hyperdef{L}{X8460C44386EE6225}{}2094{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AutomatonAllPairsPaths({\mdseries\slshape A})\index{AutomatonAllPairsPaths@\texttt{AutomatonAllPairsPaths}}2095\label{AutomatonAllPairsPaths}2096}\hfill{\scriptsize (function)}}\\209720982099Given 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 state2100j in \mbox{\texttt{\mdseries\slshape A}}.2101\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]2102!gapprompt@gap>B !gapinput@a:=RandomAutomaton("det",3,2);B2103< deterministic automaton on 2 letters with 3 states >2104!gapprompt@gap>B !gapinput@AutomatonAllPairsPaths(a);B2105[ [ [ [ 1, 1 ] ], [ ], [ ] ], [ [ [ 2, 1 ] ], [ [ 2, 2 ] ], [ ] ],2106[ [ [ 3, 2, 1 ] ], [ [ 3, 2 ] ], [ [ 3, 3 ] ] ] ]2107!gapprompt@gap>B !gapinput@Display(a);B2108| 1 2 32109--------------2110a | 1 22111b | 1 2 32112Initial state: [ 3 ]2113Accepting states: [ 1, 2 ]2114\end{Verbatim}2115}21162117}21182119}212021212122\chapter{\textcolor{Chapter }{Finite regular languages}}\logpage{[ 6, 0, 0 ]}2123\hyperdef{L}{X7AF3E5D081126EBD}{}2124{2125This chapter describes some functions to deal with finite regular languages.2126\section{\textcolor{Chapter }{Dealing with finite regular languages}}\logpage{[ 6, 1, 0 ]}2127\hyperdef{L}{X85643AEB7E7FB39A}{}2128{212921302131\subsection{\textcolor{Chapter }{IsFiniteRegularLanguage}}2132\logpage{[ 6, 1, 1 ]}\nobreak2133\hyperdef{L}{X82971FC2851B7B30}{}2134{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{IsFiniteRegularLanguage({\mdseries\slshape L})\index{IsFiniteRegularLanguage@\texttt{IsFiniteRegularLanguage}}2135\label{IsFiniteRegularLanguage}2136}\hfill{\scriptsize (function)}}\\213721382139\mbox{\texttt{\mdseries\slshape L}} is an automaton or a rational expression. This function tests whether its2140argument represents a finite language or not.2141\begin{Verbatim}[commandchars=!|A,fontsize=\small,frame=single,label=Example]2142!gapprompt|gap>A !gapinput|RandomRatExp(2);A2143b*(aU@)2144!gapprompt|gap>A !gapinput|IsFiniteRegularLanguage(last);A2145false2146!gapprompt|gap>A !gapinput|RandomRatExp(2);A2147aUbU@2148!gapprompt|gap>A !gapinput|IsFiniteRegularLanguage(last);A2149true2150\end{Verbatim}2151}2152215321542155\subsection{\textcolor{Chapter }{FiniteRegularLanguageToListOfWords}}2156\logpage{[ 6, 1, 2 ]}\nobreak2157\hyperdef{L}{X7E48CD3E78277FF7}{}2158{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{FiniteRegularLanguageToListOfWords({\mdseries\slshape L})\index{FiniteRegularLanguageToListOfWords@\texttt{FiniteRegularLanguageToListOfWords}}2159\label{FiniteRegularLanguageToListOfWords}2160}\hfill{\scriptsize (function)}}\\216121622163\mbox{\texttt{\mdseries\slshape L}} is an automaton or a rational expression. This function outputs the recognized2164language as a list of words.2165\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2166!gapprompt@gap>| !gapinput@r:=RationalExpression("aaUx(aUb)"); |2167aaUx(aUb)2168!gapprompt@gap>| !gapinput@ FiniteRegularLanguageToListOfWords(r);|2169[ "aa", "xa", "xb" ]2170\end{Verbatim}2171}2172217321742175\subsection{\textcolor{Chapter }{ListOfWordsToAutomaton}}2176\logpage{[ 6, 1, 3 ]}\nobreak2177\hyperdef{L}{X7F9C5C6F815773E6}{}2178{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ListOfWordsToAutomaton({\mdseries\slshape alph, L})\index{ListOfWordsToAutomaton@\texttt{ListOfWordsToAutomaton}}2179\label{ListOfWordsToAutomaton}2180}\hfill{\scriptsize (function)}}\\218121822183Given 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 of2184words.2185\begin{Verbatim}[commandchars=!|B,fontsize=\small,frame=single,label=Example]2186!gapprompt|gap>B !gapinput|ListOfWordsToAutomaton("ab",["aaa","bba",""]);B2187< deterministic automaton on 2 letters with 6 states >2188!gapprompt|gap>B !gapinput|FAtoRatExp(last);B2189(bbUaa)aU@2190\end{Verbatim}2191}21922193}21942195}2196219721982199\appendix220022012202\chapter{\textcolor{Chapter }{Directed graphs}}\logpage{[ "A", 0, 0 ]}2203\hyperdef{L}{X82FB3D357E1BE288}{}2204{2205Automata are frequently described through directed labeled graphs. This2206appendix on directed graphs (digraphs) is devoted to some functions designed2207with the purpose of being used as auxiliary functions to deal with automata,2208but may have independent interest.2209\section{\textcolor{Chapter }{Directed graphs}}\logpage{[ "A", 1, 0 ]}2210\hyperdef{L}{X82FB3D357E1BE288}{}2211{2212A 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 1322213299]{graph} \end{center} \label{fig:graph} \end{figure}2214221522162217\subsection{\textcolor{Chapter }{RandomDiGraph}}2218\logpage{[ "A", 1, 1 ]}\nobreak2219\hyperdef{L}{X86CF9F66788B2A24}{}2220{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{RandomDiGraph({\mdseries\slshape n})\index{RandomDiGraph@\texttt{RandomDiGraph}}2221\label{RandomDiGraph}2222}\hfill{\scriptsize (function)}}\\222322242225Produces a pseudo random digraph with $n$ vertices2226\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2227!gapprompt@gap>| !gapinput@RandomDiGraph(4);|2228[ [ ], [ 1, 2, 4 ], [ ], [ ] ]2229\end{Verbatim}2230}2231223222332234\subsection{\textcolor{Chapter }{VertexInDegree}}2235\logpage{[ "A", 1, 2 ]}\nobreak2236\hyperdef{L}{X868EE741872B932D}{}2237{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{VertexInDegree({\mdseries\slshape DG, v})\index{VertexInDegree@\texttt{VertexInDegree}}2238\label{VertexInDegree}2239}\hfill{\scriptsize (function)}}\\224022412242Computes the in degree of the vertex \mbox{\texttt{\mdseries\slshape v}} of the directed graph \mbox{\texttt{\mdseries\slshape DG}}2243\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2244!gapprompt@gap>| !gapinput@G:=RandomDiGraph(4);|2245[ [ 1 ], [ 1, 2, 4 ], [ ], [ 1, 2, 3 ] ]2246!gapprompt@gap>| !gapinput@VertexInDegree(G,2);|224722248\end{Verbatim}2249}2250225122522253\subsection{\textcolor{Chapter }{VertexOutDegree}}2254\logpage{[ "A", 1, 3 ]}\nobreak2255\hyperdef{L}{X84DF2E8E7A7B32C6}{}2256{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{VertexOutDegree({\mdseries\slshape DG, v})\index{VertexOutDegree@\texttt{VertexOutDegree}}2257\label{VertexOutDegree}2258}\hfill{\scriptsize (function)}}\\225922602261Computes the out degree of the vertex \mbox{\texttt{\mdseries\slshape v}} of the directed graph \mbox{\texttt{\mdseries\slshape DG}}2262\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2263!gapprompt@gap>| !gapinput@G:=RandomDiGraph(4);|2264[ [ 1 ], [ 1, 2, 4 ], [ ], [ 1, 2, 3 ] ]2265!gapprompt@gap>| !gapinput@VertexOutDegree(G,2);|226632267\end{Verbatim}2268}2269227022712272\subsection{\textcolor{Chapter }{AutoVertexDegree}}2273\logpage{[ "A", 1, 4 ]}\nobreak2274\hyperdef{L}{X7FA6FAAE7AA8715D}{}2275{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AutoVertexDegree({\mdseries\slshape DG, v})\index{AutoVertexDegree@\texttt{AutoVertexDegree}}2276\label{AutoVertexDegree}2277}\hfill{\scriptsize (function)}}\\227822792280Computes the degree of the vertex \mbox{\texttt{\mdseries\slshape v}} of the directed graph \mbox{\texttt{\mdseries\slshape DG}}2281\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2282!gapprompt@gap>| !gapinput@G:=RandomDiGraph(4);|2283[ [ 1 ], [ 1, 2, 4 ], [ ], [ 1, 2, 3 ] ]2284!gapprompt@gap>| !gapinput@AutoVertexDegree(G,2);|228552286\end{Verbatim}2287}2288228922902291\subsection{\textcolor{Chapter }{ReversedGraph}}2292\logpage{[ "A", 1, 5 ]}\nobreak2293\hyperdef{L}{X7BA5F1DF7DA89DC5}{}2294{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ReversedGraph({\mdseries\slshape G})\index{ReversedGraph@\texttt{ReversedGraph}}2295\label{ReversedGraph}2296}\hfill{\scriptsize (function)}}\\229722982299Computes the reversed graph of the directed graph G. It is the graph obtained2300from G by reversing the edges.2301\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2302!gapprompt@gap>| !gapinput@G:=RandomDiGraph(4);|2303[ [ ], [ 4 ], [ 2 ], [ 1, 4 ] ]2304!gapprompt@gap>| !gapinput@ReversedGraph(G);|2305[ [ 4 ], [ 3 ], [ ], [ 2, 4 ] ]2306\end{Verbatim}2307}23082309We say that a digraph is connected when for every pair of vertices there is a2310path consisting of directed or reversed edges from one vertex to the other.23112312\subsection{\textcolor{Chapter }{AutoConnectedComponents}}2313\logpage{[ "A", 1, 6 ]}\nobreak2314\hyperdef{L}{X7F23780E7A12A79E}{}2315{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AutoConnectedComponents({\mdseries\slshape G})\index{AutoConnectedComponents@\texttt{AutoConnectedComponents}}2316\label{AutoConnectedComponents}2317}\hfill{\scriptsize (function)}}\\231823192320Computes a list of the connected components of the digraph2321\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2322!gapprompt@gap>| !gapinput@G:=RandomDiGraph(6);|2323[ [ ], [ 1, 4, 5, 6 ], [ ], [ 1, 3, 5, 6 ], [ 2, 3 ], [ 2, 4, 6 ] ]2324!gapprompt@gap>| !gapinput@AutoConnectedComponents(G);|2325[ [ 1, 2, 3, 4, 5, 6 ] ]2326\end{Verbatim}2327}23282329Two vertices of a digraph belong to a strongly connected component if there is2330a directed path from each one to the other.2331233223332334\subsection{\textcolor{Chapter }{GraphStronglyConnectedComponents}}2335\logpage{[ "A", 1, 7 ]}\nobreak2336\hyperdef{L}{X7D5288C982F92481}{}2337{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{GraphStronglyConnectedComponents({\mdseries\slshape G})\index{GraphStronglyConnectedComponents@\texttt{GraphStronglyConnectedComponents}}2338\label{GraphStronglyConnectedComponents}2339}\hfill{\scriptsize (function)}}\\234023412342Produces the strongly connected components of the digraph \mbox{\texttt{\mdseries\slshape G}}.2343\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2344!gapprompt@gap>| !gapinput@G:=RandomDiGraph(6);|2345[ [ ], [ 4 ], [ ], [ 4, 6 ], [ ], [ 1, 4, 5, 6 ] ]2346!gapprompt@gap>| !gapinput@GraphStronglyConnectedComponents(G);|2347[ [ 1 ], [ 2 ], [ 3 ], [ 4, 6 ], [ 5 ] ]2348\end{Verbatim}2349}2350235123522353\subsection{\textcolor{Chapter }{UnderlyingMultiGraphOfAutomaton}}2354\logpage{[ "A", 1, 8 ]}\nobreak2355\hyperdef{L}{X859B7C517AFBD198}{}2356{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{UnderlyingMultiGraphOfAutomaton({\mdseries\slshape A})\index{UnderlyingMultiGraphOfAutomaton@\texttt{UnderlyingMultiGraphOfAutomaton}}2357\label{UnderlyingMultiGraphOfAutomaton}2358}\hfill{\scriptsize (function)}}\\235923602361\mbox{\texttt{\mdseries\slshape A}} is an automaton. The output is the underlying directed multi-graph.2362\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]2363!gapprompt@gap>B !gapinput@a:=RandomAutomaton("det",3,2);;Display(a);B2364| 1 2 32365--------------2366a | 1 32367b | 2 32368Initial state: [ 1 ]2369Accepting states: [ 1, 2 ]2370!gapprompt@gap>B !gapinput@UnderlyingMultiGraphOfAutomaton(a);B2371[ [ 1 ], [ 3, 2 ], [ 3 ] ]2372\end{Verbatim}2373}2374237523762377\subsection{\textcolor{Chapter }{UnderlyingGraphOfAutomaton}}2378\logpage{[ "A", 1, 9 ]}\nobreak2379\hyperdef{L}{X78CF8E507E100C62}{}2380{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{UnderlyingGraphOfAutomaton({\mdseries\slshape A})\index{UnderlyingGraphOfAutomaton@\texttt{UnderlyingGraphOfAutomaton}}2381\label{UnderlyingGraphOfAutomaton}2382}\hfill{\scriptsize (function)}}\\238323842385\mbox{\texttt{\mdseries\slshape A}} is an automaton. The output is the underlying directed graph.2386\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]2387!gapprompt@gap>B !gapinput@a:=RandomAutomaton("det",3,2);;Display(a);B2388| 1 2 32389--------------2390a | 1 22391b | 1 22392Initial state: [ 2 ]2393Accepting state: [ 2 ]2394!gapprompt@gap>B !gapinput@UnderlyingGraphOfAutomaton(a);B2395[ [ 1 ], [ 1, 2 ], [ 2 ] ]2396\end{Verbatim}2397}2398239924002401\subsection{\textcolor{Chapter }{DiGraphToRelation}}2402\logpage{[ "A", 1, 10 ]}\nobreak2403\hyperdef{L}{X78869D478792B3AD}{}2404{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{DiGraphToRelation({\mdseries\slshape D})\index{DiGraphToRelation@\texttt{DiGraphToRelation}}2405\label{DiGraphToRelation}2406}\hfill{\scriptsize (function)}}\\240724082409Returns the relation corresponding to the digraph. Note that a directed graph2410may be seen in a natural way as a binary relation on the set of vertices.2411\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2412!gapprompt@gap>| !gapinput@G:=RandomDiGraph(4);|2413[ [ ], [ ], [ 4 ], [ 4 ] ]2414!gapprompt@gap>| !gapinput@DiGraphToRelation(G);|2415[ [ 3, 4 ], [ 4, 4 ] ]2416\end{Verbatim}2417}2418241924202421\subsection{\textcolor{Chapter }{MSccAutomaton}}2422\logpage{[ "A", 1, 11 ]}\nobreak2423\hyperdef{L}{X7D63604A8413AAAF}{}2424{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{MSccAutomaton({\mdseries\slshape A})\index{MSccAutomaton@\texttt{MSccAutomaton}}2425\label{MSccAutomaton}2426}\hfill{\scriptsize (function)}}\\242724282429Produces an automaton where, in each strongly connected component, edges2430labeled by inverses are added. (M stands for modified.)24312432This construction is useful in Finite Semigroup Theory.2433\begin{Verbatim}[commandchars=!@C,fontsize=\small,frame=single,label=Example]2434!gapprompt@gap>C !gapinput@a:=RandomAutomaton("det",3,2);;Display(a);C2435| 1 2 32436--------------2437a | 1 32438b | 2 32439Initial state: [ 1 ]2440Accepting states: [ 1, 2, 3 ]2441!gapprompt@gap>C !gapinput@MSccAutomaton(a);C2442< deterministic automaton on 4 letters with 3 states >2443!gapprompt@gap>C !gapinput@Display(last);C2444| 1 2 32445--------------2446a | 1 32447b | 2 32448A | 12449B |2450Initial state: [ 1 ]2451Accepting states: [ 1, 2, 3 ]2452\end{Verbatim}2453}2454245524562457\subsection{\textcolor{Chapter }{AutoIsAcyclicGraph}}2458\logpage{[ "A", 1, 12 ]}\nobreak2459\hyperdef{L}{X7971EE367B6B7F36}{}2460{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{AutoIsAcyclicGraph({\mdseries\slshape G})\index{AutoIsAcyclicGraph@\texttt{AutoIsAcyclicGraph}}2461\label{AutoIsAcyclicGraph}2462}\hfill{\scriptsize (function)}}\\246324642465The argument is a graph's list of adjacencies and this function returns true2466if the argument is an acyclic graph and false otherwise.2467\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2468!gapprompt@gap>| !gapinput@RandomDiGraph(3);|2469[ [ ], [ 3 ], [ 2 ] ]2470!gapprompt@gap>| !gapinput@AutoIsAcyclicGraph(last);|2471false2472\end{Verbatim}2473}24742475}24762477}247824792480\chapter{\textcolor{Chapter }{ Drawing automata }}\logpage{[ "B", 0, 0 ]}2481\hyperdef{L}{X82D249F0793E6561}{}2482{2483The 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/}}.2484\section{\textcolor{Chapter }{ Installing some external programs }}\logpage{[ "B", 1, 0 ]}2485\hyperdef{L}{X7988DBAB78EA0C06}{}2486{2487In 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}. }248824892490\section{\textcolor{Chapter }{ Functions to draw automata }}\logpage{[ "B", 2, 0 ]}2491\hyperdef{L}{X84C97CA079719B11}{}2492{249324942495\subsection{\textcolor{Chapter }{DrawAutomaton}}2496\logpage{[ "B", 2, 1 ]}\nobreak2497\hyperdef{L}{X7BC2FDA77FD0237B}{}2498{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{DrawAutomaton({\mdseries\slshape A[, state{\textunderscore}names, L, file]})\index{DrawAutomaton@\texttt{DrawAutomaton}}2499\label{DrawAutomaton}2500}\hfill{\scriptsize (function)}}\\250125022503This 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.25042505An 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 graph2506node.25072508The argument \mbox{\texttt{\mdseries\slshape L}} is a list of lists of integers, each of which specifies a set of states to be2509drawn in a different color.25102511The argument \mbox{\texttt{\mdseries\slshape file}} is a string that specifies the name of the file containing the drawing. If it2512is not give, it defaults to \texttt{"automaton"}.2513\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2514!gapprompt@gap>| !gapinput@x:=Automaton("det",3,2,[ [ 2, 3, 0 ], [ 0, 1, 2 ] ],[ 1 ],[ 1, 2, 3 ]);;|2515!gapprompt@gap>| !gapinput@DrawAutomaton(x,"file_name");|2516Displaying file: /tmp/tmp.Rj0v1s/file_name.dot.ps25172518!gapprompt@gap>| !gapinput@DrawAutomaton(x,["st 1", "2", "C"],"file_name");|2519Displaying file: /tmp/tmp.BCH3FO/file_name.dot.ps25202521!gapprompt@gap>| !gapinput@DrawAutomaton(x,["st 1", "2", "C"],[[2],[1,3]]);|2522Displaying file: /tmp/tmp.LPnJMq/automaton.dot.ps2523\end{Verbatim}2524The output of the three previous \texttt{DrawAutomaton} commands would be the following diagrams displayed in a \emph{ghostview} window, respectively.25252526\begin{figure}[htbp] \begin{center} \leavevmode \includegraphics[bb=0 0 742527250]{aut2.jpg} \end{center} \label{fig:aut2} \end{figure}25282529\begin{figure}[htbp] \begin{center} \leavevmode \includegraphics[bb=0 0 1002530250]{aut2_1.jpg} \end{center} \label{fig:aut2_1} \end{figure}25312532\begin{figure}[htbp] \begin{center} \leavevmode \includegraphics[bb=0 0 1002533250]{aut2_2.jpg} \end{center} \label{fig:aut2_2} \end{figure}25342535}2536253725382539\subsection{\textcolor{Chapter }{DrawAutomata}}2540\logpage{[ "B", 2, 2 ]}\nobreak2541\hyperdef{L}{X7AEE146D8391CA3D}{}2542{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{DrawAutomata({\mdseries\slshape A, B[, file]})\index{DrawAutomata@\texttt{DrawAutomata}}2543\label{DrawAutomata}2544}\hfill{\scriptsize (function)}}\\254525462547This 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 plain2548style. }2549255025512552\subsection{\textcolor{Chapter }{DrawGraph}}2553\logpage{[ "B", 2, 3 ]}\nobreak2554\hyperdef{L}{X7D17B77F829F9CCB}{}2555{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{DrawGraph({\mdseries\slshape G[, file]})\index{DrawGraph@\texttt{DrawGraph}}2556\label{DrawGraph}2557}\hfill{\scriptsize (function)}}\\255825592560Draws a graph specified as an adjacency list \texttt{G}. }2561256225632564\subsection{\textcolor{Chapter }{DrawSCCAutomaton}}2565\logpage{[ "B", 2, 4 ]}\nobreak2566\hyperdef{L}{X7E478FDD807853CA}{}2567{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{DrawSCCAutomaton({\mdseries\slshape A[, state{\textunderscore}names, L, file]})\index{DrawSCCAutomaton@\texttt{DrawSCCAutomaton}}2568\label{DrawSCCAutomaton}2569}\hfill{\scriptsize (function)}}\\257025712572Draws automaton \texttt{ A } and highlights it's strongly connected components by drawing the other edges2573in a dotted style.25742575The 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}). }25762577}257825792580\section{\textcolor{Chapter }{Drawings output formats}}\logpage{[ "B", 3, 0 ]}2581\hyperdef{L}{X7F5419527FFCD1DF}{}2582{2583Since 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. }258425852586\section{\textcolor{Chapter }{Drawings extra graph attributes}}\logpage{[ "B", 4, 0 ]}2587\hyperdef{L}{X795DD98D86A1A441}{}2588{2589Since 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. }25902591}259225932594\chapter{\textcolor{Chapter }{Inverse automata and subgroups of the free group}}\logpage{[ "C", 0, 0 ]}2595\hyperdef{L}{X7DBBB0537ADC9899}{}2596{2597Inverse automata with a single initial/accepting state are in a one to one2598correspondence with finitely generated subgroups of the free group over the2599alphabet 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}.2600\section{\textcolor{Chapter }{From subgroups to inverse automata}}\logpage{[ "C", 1, 0 ]}2601\hyperdef{L}{X7DDDA5127A3D170C}{}2602{2603A finitely generated subgroup of a finitely generated free group is given2604through a list whose first element is the number of generators of the free2605group and the remaining elements are the generators of the subgroup. The set2606of 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 the2607corresponding capital letter.26082609A generator of the subgroup may be given through a string of letters or2610through a list of positive integers as should be clear from the example that2611follows.26122613For 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 following2614functions.26152616\subsection{\textcolor{Chapter }{GeneratorsToListRepresentation}}2617\logpage{[ "C", 1, 1 ]}\nobreak2618\hyperdef{L}{X85358D097C314EB5}{}2619{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{GeneratorsToListRepresentation({\mdseries\slshape L})\index{GeneratorsToListRepresentation@\texttt{GeneratorsToListRepresentation}}2620\label{GeneratorsToListRepresentation}2621}\hfill{\scriptsize (function)}}\\2622262326242625\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2626!gapprompt@gap>| !gapinput@L:=[2,"abA","bbabAB"];;|2627!gapprompt@gap>| !gapinput@GeneratorsToListRepresentation(L);|2628[ 2, [ 1, 2, 3 ], [ 2, 2, 1, 2, 3, 4 ] ]2629\end{Verbatim}2630}2631263226332634\subsection{\textcolor{Chapter }{ListToGeneratorsRepresentation}}2635\logpage{[ "C", 1, 2 ]}\nobreak2636\hyperdef{L}{X80F3E10784590374}{}2637{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{ListToGeneratorsRepresentation({\mdseries\slshape K})\index{ListToGeneratorsRepresentation@\texttt{ListToGeneratorsRepresentation}}2638\label{ListToGeneratorsRepresentation}2639}\hfill{\scriptsize (function)}}\\2640264126422643\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2644!gapprompt@gap>| !gapinput@K:=[2,[1,2,3],[2,2,1,2,3,4]];;|2645!gapprompt@gap>| !gapinput@ListToGeneratorsRepresentation(K);|2646[ 2, "abA", "bbabAB" ]2647\end{Verbatim}2648}2649265026512652\subsection{\textcolor{Chapter }{FlowerAutomaton}}2653\logpage{[ "C", 1, 3 ]}\nobreak2654\hyperdef{L}{X7EAFF7E879D115C5}{}2655{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{FlowerAutomaton({\mdseries\slshape L})\index{FlowerAutomaton@\texttt{FlowerAutomaton}}2656\label{FlowerAutomaton}2657}\hfill{\scriptsize (function)}}\\265826592660The argument \texttt{L} is a subgroup of the free group given through any of the representations2661described above. Returns the flower automaton.2662\begin{Verbatim}[commandchars=!@C,fontsize=\small,frame=single,label=Example]2663!gapprompt@gap>C !gapinput@W:=[2,"bbbAB","abAbA"];;C2664!gapprompt@gap>C !gapinput@A:=FlowerAutomaton(W);C2665< non deterministic automaton on 2 letters with 9 states >2666!gapprompt@gap>C !gapinput@Display(A);C2667| 1 2 3 4 5 6 7 8 92668---------------------------------------------------------------------2669a | [ 6, 9 ] [ 4 ] [ 7 ]2670b | [ 2, 5 ] [ 3 ] [ 4 ] [ 7 ] [ 9 ]2671Initial state: [ 1 ]2672Accepting state: [ 1 ]2673\end{Verbatim}2674}2675267626772678\subsection{\textcolor{Chapter }{FoldFlowerAutomaton}}2679\logpage{[ "C", 1, 4 ]}\nobreak2680\hyperdef{L}{X7F729A4E8784D92E}{}2681{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{FoldFlowerAutomaton({\mdseries\slshape A})\index{FoldFlowerAutomaton@\texttt{FoldFlowerAutomaton}}2682\label{FoldFlowerAutomaton}2683}\hfill{\scriptsize (function)}}\\268426852686Makes identifications on the flower automaton \texttt{A}. In the literature, these identifications are called Stallings foldings.26872688(This function may have \texttt{true} as a second argument. WARNING: the second argument should only be used when2689facilities to draw automata are available. In that case, one may visualize the2690identifications that are taking place.)2691\begin{Verbatim}[commandchars=!@C,fontsize=\small,frame=single,label=Example]2692!gapprompt@gap>C !gapinput@B := FoldFlowerAutomaton(A);C2693< deterministic automaton on 2 letters with 7 states >2694!gapprompt@gap>C !gapinput@Display(B);C2695| 1 2 3 4 5 6 72696--------------------------2697a | 5 4 62698b | 2 3 4 6 52699Initial state: [ 1 ]2700Accepting state: [ 1 ]2701\end{Verbatim}2702}2703270427052706\subsection{\textcolor{Chapter }{SubgroupGenToInvAut}}2707\logpage{[ "C", 1, 5 ]}\nobreak2708\hyperdef{L}{X826D581D794F1BFB}{}2709{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{SubgroupGenToInvAut({\mdseries\slshape L})\index{SubgroupGenToInvAut@\texttt{SubgroupGenToInvAut}}2710\label{SubgroupGenToInvAut}2711}\hfill{\scriptsize (function)}}\\271227132714Returns the inverse automaton corresponding to the subgroup given by \mbox{\texttt{\mdseries\slshape L}}.2715\begin{Verbatim}[commandchars=!@C,fontsize=\small,frame=single,label=Example]2716!gapprompt@gap>C !gapinput@L:=[2,"bbbAB","AbAbA"];;C2717!gapprompt@gap>C !gapinput@SubgroupGenToInvAut(L);C2718< deterministic automaton on 2 letters with 8 states >2719!gapprompt@gap>C !gapinput@Display(last);C2720| 1 2 3 4 5 6 7 82721-----------------------------2722a | 8 4 1 62723b | 2 3 4 6 82724Initial state: [ 1 ]2725Accepting state: [ 1 ]27262727\end{Verbatim}2728}27292730}273127322733\section{\textcolor{Chapter }{From inverse automata to subgroups}}\logpage{[ "C", 2, 0 ]}2734\hyperdef{L}{X85F2060A86DBE62B}{}2735{2736Given an inverse automaton with a single initial/accepting state, one can find2737a set of generators for the subgroup represented by the automaton. Moreover,2738using a geodesic tree, one can find a Nielsen reduced set of generators \cite{KM:2002}.27392740\subsection{\textcolor{Chapter }{GeodesicTreeOfInverseAutomaton}}2741\logpage{[ "C", 2, 1 ]}\nobreak2742\hyperdef{L}{X81DA149779A167BD}{}2743{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{GeodesicTreeOfInverseAutomaton({\mdseries\slshape A})\index{GeodesicTreeOfInverseAutomaton@\texttt{GeodesicTreeOfInverseAutomaton}}2744\label{GeodesicTreeOfInverseAutomaton}2745}\hfill{\scriptsize (function)}}\\274627472748Returns a subautomaton of \mbox{\texttt{\mdseries\slshape A}}whose underlying graph is a geodesic tree of the underlying graph of the2749inverse automaton \texttt{A}.2750\begin{Verbatim}[commandchars=!@B,fontsize=\small,frame=single,label=Example]2751!gapprompt@gap>B !gapinput@A:=Automaton("det",4,2,[ [ 3, 4, 0, 0 ], [ 2, 3, 4, 0 ] ],[ 1 ],[ 1 ]);;B2752!gapprompt@gap>B !gapinput@G := GeodesicTreeOfInverseAutomaton(A);B2753< deterministic automaton on 2 letters with 4 states >2754!gapprompt@gap>B !gapinput@Display(G);B2755| 1 2 3 42756-----------------2757a | 32758b | 2 42759Initial state: [ 1 ]2760Accepting state: [ 1 ]2761\end{Verbatim}2762}2763276427652766\subsection{\textcolor{Chapter }{InverseAutomatonToGenerators}}2767\logpage{[ "C", 2, 2 ]}\nobreak2768\hyperdef{L}{X7F117C43814F2CDE}{}2769{\noindent\textcolor{FuncColor}{$\triangleright$\ \ \texttt{InverseAutomatonToGenerators({\mdseries\slshape A})\index{InverseAutomatonToGenerators@\texttt{InverseAutomatonToGenerators}}2770\label{InverseAutomatonToGenerators}2771}\hfill{\scriptsize (function)}}\\277227732774Returns a set of generators (given trough the representation above) of the2775subgroup of the free group corresponding to the automaton \texttt{A} given.2776\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2777!gapprompt@gap>| !gapinput@NW := InverseAutomatonToGenerators(A);|2778[ 2, "baBA", "bbA" ]2779\end{Verbatim}2780}27812782}27832784}27852786\def\bibname{References\logpage{[ "Bib", 0, 0 ]}2787\hyperdef{L}{X7A6F98FD85F02BFE}{}2788}27892790\bibliographystyle{alpha}2791\bibliography{AutMan}27922793\addcontentsline{toc}{chapter}{References}27942795\def\indexname{Index\logpage{[ "Ind", 0, 0 ]}2796\hyperdef{L}{X83A0356F839C696F}{}2797}27982799\cleardoublepage2800\phantomsection2801\addcontentsline{toc}{chapter}{Index}280228032804\printindex28052806\newpage2807\immediate\write\pagenrlog{["End"], \arabic{page}];}2808\immediate\closeout\pagenrlog2809\end{document}281028112812