User friendly ways to give semigroups and automata This chapter describes two Tcl/Tk graphical interfaces that can be used to define and edit semigroups and automata.
Finite automata The function Xautomaton without arguments opens a new window where an automaton may be specified. A finite automaton (which may then be edited) may be given as argument.
gap> XAutomaton();
It opens a window like the following:

\begin{center} \includegraphics[width=0.5\textwidth]{images/xaut.png} \end{center} <br><center><img src="images/xaut.png"></center><br> Var is the &GAP; name of the automaton, States is the number of states, Alphabet represents the alphabet and may be given through a positive integer (in this case the alphabet is understood to be a,b,c,... ) or through a string whose symbols, in order, being the letters of the alphabet. The numbers corresponding to the initial and accepting states are placed in the respective boxes. The automaton may be specified to be deterministic, non deterministic or with epsilon transitions. After pressing the transition matrix button the window gets larger and the transition matrix of the automaton may be given. The ith row of the matrix describes the action of the ith letter on the states. \begin{center} \includegraphics[width=0.5\textwidth]{images/xautoma.png} \end{center} <br><center><img src="images/xautoma.png"></center><br> A non deterministic automaton may be given as follows: \begin{center} \includegraphics[width=0.5\textwidth]{images/xndAUT.png} \end{center} <br><center><img src="images/xndAUT.png"></center><br>

By pressing the button Ok the &GAP; shell aquires the aspect shown in the following picture and the automaton ndAUT may be used to do computations. Some computations such as getting a rational expression representing the language of the automaton, the (complete) minimal automaton representing the same language or the transition semigroup of the automaton, may be done directly after pressing the Functions button. \begin{center} \includegraphics[width=0.5\textwidth]{images/xndAUTok.png} \end{center} <br><center><img src="images/xndAUTok.png"></center><br>

By pressing the button View an image representing the automaton is displayed in a new window. \begin{center} \includegraphics[width=0.5\textwidth]{images/ndAutImage.png} \end{center} <br><center><img src="images/ndAutImage.png"></center><br> An automaton with epsilon transitions may be given as follows shown in the following picture. The last letter of the alphabet is always considered to be the \epsilon. In the images it is represented by @. \begin{center} \includegraphics[width=0.4\textwidth]{images/EpsTrAut.png} \end{center} <br><center><img src="images/EpsTrAut.png"></center><br>

A new window with an image representing the automaton may be obtained by pressing the button View . \begin{center} \includegraphics[width=0.4\textwidth]{images/EpsTrAutImage.png} \end{center} <br><center><img src="images/EpsTrAutImage.png"></center><br>

In the next example it is given an argument to the function XAutomaton.
gap> A := RandomAutomaton("det",2,2); < deterministic automaton on 2 letters with 2 states > gap> XAutomaton(A);
It opens a window like the following:

\begin{center} \includegraphics[width=0.5\textwidth]{images/xautgiven.png} \end{center} <br><center><img src="images/xautgiven.png"></center><br>
Finite semigroups The most common ways to give a semigroup to are through generators and relations, a set of (partial) transformations as generating set and as syntactic semigroups of automata or rational languages. The function XSemigroup without arguments opens a new window where a semigroup (or monoid) may be specified. A finite semigroup (which may then be edited) may be given as argument.
gap> XSemigroup();
It opens a window like the following: \begin{center} \includegraphics[width=0.5\textwidth]{images/xsgp.png} \end{center} <br><center><img src="images/xsgp.png"></center><br> where one may choose how to give the semigroup. Semigroups given through generators and relations In the window opened by XSemigroup, by pressing the button Proceed the window should enlarge and have the following aspect. (If the window does not enlarge automatically, use the mouse to do it.)

\begin{center} \includegraphics[width=0.5\textwidth]{images/xb211.png} \end{center} <br><center><img src="images/xb211.png"></center><br> GAP variable is the &GAP; name of the semigroup. One has then to specify the number of generators, the number of relations (which does not to be exact) and whether one wants to produce a monoid or a semigroup. Pressing the Proceed button one gets: \begin{center} \includegraphics[width=0.5\textwidth]{images/xb212.png} \end{center} <br><center><img src="images/xb212.png"></center><br> \begin{center} \includegraphics[width=0.5\textwidth]{images/xb21.png} \end{center} <br><center><img src="images/xb21.png"></center><br> When giving the relations, the usual abbreviations "0" and "1" may be used.

Pressing the Done button would output the following to the shell where GAP is running: \begin{center} \includegraphics[width=0.4\textwidth]{images/gapb21.png} \end{center} <br><center><img src="images/gapb21.png"></center><br>

The menu button Functions has the following commands: \begin{center} \includegraphics[width=0.4\textwidth]{images/funcsind.png} \includegraphics[width=0.4\textwidth]{images/funcsmenu.png} \end{center} The interface allows to add and remove &GAP; functions to the menu. When adding a function, the name of the function should be provided. (In its current version, it works only with functions that have as only argument a semigroup.)

By pressing the menu button Functions and selecting "Draw Schutzenberger Graphs" would pop up the following window: \begin{center} \includegraphics[width=0.4\textwidth]{images/ShuzenbergerGraphb21.png} \end{center}

The menu button Functions has the following commands: <br><center> <img src="images/funcsind.png"> <img src="images/funcsmenu.png"> </center><br> The interface allows to add and remove &GAP; functions to the menu. When adding a function, the name of the function should be provided. (In its current version, it works only with functions that have as only argument a semigroup.)

By pressing the menu button Functions and selecting "Draw Schutzenberger Graphs" would pop up the following window: <br><center><img src="images/ShuzenbergerGraphb21.png"></center><br> \begin{center} \includegraphics[width=0.4\textwidth]{images/CayleyGraphb21.png} \end{center} By pressing the menu button Functions and selecting "Draw Cayley Graph" would pop up the following window: <br><center><img src="images/CayleyGraphb21.png"></center><br> \begin{center} \includegraphics[width=0.4\textwidth]{images/DClassesb21.png} \end{center} By pressing the menu button Functions and selecting "Draw D-Classes" would pop up the following window: <br><center><img src="images/DClassesb21.png"></center><br> Semigroups given by partial transformations `XSemigroup(poi3);` would pop up the following window, where everything should be clear: \begin{center} \includegraphics[width=0.5\textwidth]{images/Xsemigroup1.png} \end{center} <br><center><img src="images/Xsemigroup1.png"></center><br> Syntatic semigroups `XSemigroup();` would pop up the following window, where we would select "Syntatic semigroup", press the Proceed button and then choose either to give a "Rational expression" or an "Automaton" by pressing one of those buttons: \begin{center} \includegraphics[width=0.5\textwidth]{images/Xsemigroup2.png} \end{center} <br><center><img src="images/Xsemigroup2.png"></center><br> If "Rational expression" is chosen, a new window pops up where the expression can be specified: \begin{center} \includegraphics[width=0.4\textwidth]{images/regexp.png} \end{center} <br><center><img src="images/regexp.png"></center><br> After pressing the Ok button, notice that the menu button Functions appears on the main window (lower right corner) meaning that GAP already recognizes the given semigroup: \begin{center} \includegraphics[width=0.4\textwidth]{images/regexp2.png} \end{center} <br><center><img src="images/regexp2.png"></center><br>