<p>This chapter describes the representations used in this package for finite automata and some functions to determine information about them.</p>
<p>We have to remark that the states of an automaton are always named <span class="SimpleMath">\(1,2,3,\ldots;\)</span> the alphabet may be given by the user. By default it is <span class="SimpleMath">\(\{a,b,c,\ldots\}\)</span> (or <span class="SimpleMath">\(\{a_1,a_2,a_3,\ldots\}\)</span> in the case of alphabets with more than <span class="SimpleMath">\(26\)</span> letters).</p>
<p>The transition function of an automaton with <span class="SimpleMath">\(q\)</span> states over an alphabet with <span class="SimpleMath">\( n\)</span> letters is represented by a (not necessarily dense) <span class="SimpleMath">\(n\times q\)</span> matrix. Each row of the matrix describes the action of the corresponding letter on the states. In the case of a <em>deterministic automaton</em> (DFA) the entries of the matrix are non-negative integers. When all entries of the transition table are positive integers, the automaton is said to be <em>dense</em> or <em>complete</em>. In the case of a <em>non deterministic automaton</em> (NFA) the entries of the matrix may be lists of non-negative integers. <em>Automata with <span class="SimpleMath">\(\epsilon\)</span>-transitions</em> are also allowed: the last letter of the alphabet is assumed to be <span class="SimpleMath">\(\epsilon\)</span> and is represented by @.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Automaton</code>( <var class="Arg">Type</var>, <var class="Arg">Size</var>, <var class="Arg">Alphabet</var>, <var class="Arg">TransitionTable</var>, <var class="Arg">Initial</var>, <var class="Arg">Accepting</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">Type</code> may be <code class="code">"det"</code>, <code class="code">"nondet"</code> or <code class="code">"epsilon"</code> according to whether the automaton is deterministic, non deterministic or an automaton with <span class="SimpleMath">\(\epsilon\)</span>-transitions. <code class="code">Size</code> is a positive integer representing the number of states of the automaton. <code class="code">Alphabet</code> is the number of letters of the alphabet or a list with the letters of the ordered alphabet. <code class="code">TransitionTable</code> is the transition matrix. The entries are non-negative integers not greater than the size of the automaton. In the case of non deterministic automata, lists of non-negative integers not greater than the size of the automaton are also allowed. <code class="code">Initial</code> and <code class="code">Accepting</code> are, respectively, the lists of initial and accepting states.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">aut:=Automaton("det",4,2,[[3,,3,4],[3,4,0,4]],[1],[4]);</span>
< deterministic automaton on 2 letters with 4 states >
<span class="GAPprompt">gap></span> <span class="GAPinput">Display(aut);</span>
| 1 2 3 4
-----------------
a | 3 3 4
b | 3 4 4
Initial state: [ 1 ]
Accepting state: [ 4 ]
</pre></div>
<p>The alphabet of the automaton may be specified:</p>
<p>Instead of leaving a hole in the transition matrix, we may write a <code class="code">0</code> to mean that no transition is present. Non deterministic automata may be given the same way.</p>
<p>Also in the same way can be given <span class="SimpleMath">\(\epsilon\)</span>-automata. The letter <span class="SimpleMath">\(\epsilon\)</span> is written <code class="code">@</code> instead.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsAutomaton</code>( <var class="Arg">O</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>In the presence of an object <var class="Arg">O</var>, one may want to test whether <code class="code">O</code> is an automaton. This may be done using the function <code class="code">IsAutomaton</code>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsNonDeterministicAutomaton</code>( <var class="Arg">aut</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns <code class="keyw">true</code> when <code class="code">aut</code> is a non deterministic automaton and <code class="keyw">false</code> otherwise.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ String</code>( <var class="Arg">aut</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The way <strong class="pkg">GAP</strong> displays an automaton is quite natural, but when one wants to do small changes, for example using <em>copy/paste</em>, the use of the function <code class="code">String</code> (possibly followed by <code class="code">Print</code>) may be useful.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ RandomAutomaton</code>( <var class="Arg">Type</var>, <var class="Arg">Size</var>, <var class="Arg">Alphabet</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Given the <var class="Arg">Type</var>, the <var class="Arg">Size</var> (i.e. the number of states) and the <var class="Arg">Alphabet</var> (a positive integer or a list), returns a pseudo random automaton with these parameters.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">RandomAutomaton("det",5,"ac");</span>
< deterministic automaton on 2 letters with 5 states >
<span class="GAPprompt">gap></span> <span class="GAPinput">Display(last);</span>
| 1 2 3 4 5
--------------------
a | 2 3
c | 2 3
Initial state: [ 4 ]
Accepting states: [ 3, 4 ]
<span class="GAPprompt">gap></span> <span class="GAPinput">RandomAutomaton("nondet",3,["a","b","c"]);</span>
< non deterministic automaton on 3 letters with 3 states >
<span class="GAPprompt">gap></span> <span class="GAPinput">RandomAutomaton("epsilon",2,"abc");</span>
< epsilon automaton on 4 letters with 2 states >
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ AlphabetOfAutomaton</code>( <var class="Arg">aut</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns the number of symbols in the alphabet of automaton <code class="code">aut</code>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ AlphabetOfAutomatonAsList</code>( <var class="Arg">aut</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns the alphabet of automaton <code class="code">aut</code> always as a list. Note that when the alphabet of the automaton is given as an integer (meaning the number of symbols) not greater than 26 it returns the list <code class="code">"abcd...."</code>. If the alphabet is given by means of an integer greater than 26, the function returns <code class="code">[ "a1", "a2", "a3", "a4", ... ]</code>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ SetInitialStatesOfAutomaton</code>( <var class="Arg">aut</var>, <var class="Arg">I</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Sets the initial states of automaton <code class="code">aut</code>. <code class="code">I</code> may be a positive integer or a list of positive integers.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ FinalStatesOfAutomaton</code>( <var class="Arg">aut</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns the final states of automaton <code class="code">aut</code>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ SetFinalStatesOfAutomaton</code>( <var class="Arg">aut</var>, <var class="Arg">F</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Sets the final states of automaton <code class="code">aut</code>. <code class="code">F</code> may be a positive integer or a list of positive integers.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ NumberStatesOfAutomaton</code>( <var class="Arg">aut</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns the number of states of automaton <code class="code">aut</code>.</p>
<h4>2.3 <span class="Heading">Comparison of automata</span></h4>
<p>Although there is no standard way to compare automata it is useful to be able to do some kind of comparison. Doing so, one can consider sets of automata. We just compare the strings of the automata.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsRecognizedByAutomaton</code>( <var class="Arg">A</var>, <var class="Arg">w</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The arguments are: an automaton <var class="Arg">A</var> and a string (i.e. a word) <var class="Arg">w</var> in the alphabet of the automaton. Returns <code class="code">true</code> if the word is recognized by the automaton and <code class="code">false</code> otherwise.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsPermutationAutomaton</code>( <var class="Arg">aut</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The argument is a deterministic automaton. Returns <code class="keyw">true</code> when each letter of the alphabet induces a permutation on the vertices and <code class="keyw">false</code> otherwise.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsInverseAutomaton</code>( <var class="Arg">aut</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The argument is a deterministic automaton. Returns <code class="keyw">true</code> when each letter of the alphabet induces an injective partial function on the vertices and <code class="keyw">false</code> otherwise.</p>
<p>Frequently an inverse automaton is thought as if the inverse edges (labeled by formal inverses of the letters of the alphabet) were present, although they are usually not explicited. They can be made explicit using the function <code class="code">AddInverseEdgesToInverseAutomaton</code></p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ AddInverseEdgesToInverseAutomaton</code>( <var class="Arg">aut</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The argument is an inverse automaton over the alphabet <span class="SimpleMath">\(\{a,b,c,\ldots\}\)</span>. Returns an automaton with the inverse edges added. (The formal inverse of a letter is represented by the corresponding capital letter.)</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsReversibleAutomaton</code>( <var class="Arg">aut</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The argument is a deterministic automaton. Returns <code class="keyw">true</code> when <var class="Arg">aut</var> is a reversible automaton, i.e. the automaton obtained by reversing all edges and switching the initial and final states (see also <code class="func">ReversedAutomaton</code> (<a href="chap2_mj.html#X7C0526217BFE7A65"><span class="RefLink">2.5-5</span></a>)) is deterministic. Returns <code class="keyw">false</code> otherwise.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CopyAutomaton</code>( <var class="Arg">aut</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns a new automaton, which is a copy of automaton <var class="Arg">aut</var>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ NullCompletionAutomaton</code>( <var class="Arg">aut</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">aut</code> is a deterministic automaton. If it is complete returns <var class="Arg">aut</var>, otherwise returns the completion (with a null state) of <var class="Arg">aut</var>. Notice that the words recognized by <var class="Arg">aut</var> and its completion are the same.</p>
<p>The state added is a <em>sink state</em> i.e. it is a state <span class="SimpleMath">\(q\)</span> which is not initial nor accepting and for all letter <span class="SimpleMath">\(a\)</span> in the alphabet of the automaton, <span class="SimpleMath">\(q\)</span> is the result of the action of <span class="SimpleMath">\(a\)</span> in <span class="SimpleMath">\(q\)</span>. (Notice that reading a word, one does not go out of a sink state.)</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ListSinkStatesAut</code>( <var class="Arg">aut</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Computes the list of all sink states of the automaton <var class="Arg">aut</var>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ RemovedSinkStates</code>( <var class="Arg">aut</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Removes all sink states of the automaton <var class="Arg">aut</var>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PermutedAutomaton</code>( <var class="Arg">aut</var>, <var class="Arg">p</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Given an automaton <var class="Arg">aut</var> and a list <var class="Arg">p</var> representing a permutation of the states, outputs the equivalent permuted automaton.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ListPermutedAutomata</code>( <var class="Arg">aut</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Given an automaton <var class="Arg">aut</var>, returns a list of automata with permuted states</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">x:=Automaton("det",3,2,[ [ 0, 2, 3 ], [ 1, 2, 3 ] ],[ 1 ],[ 2, 3 ]);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">ListPermutedAutomata(x);</span>
[ < deterministic automaton on 2 letters with 3 states >,
< deterministic automaton on 2 letters with 3 states >,
< deterministic automaton on 2 letters with 3 states >,
< deterministic automaton on 2 letters with 3 states >,
< deterministic automaton on 2 letters with 3 states >,
< deterministic automaton on 2 letters with 3 states > ]
</pre></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ NormalizedAutomaton</code>( <var class="Arg">A</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Produces an equivalent automaton but in which the initial state is numbered 1 and the accepting states have the greatest numbers.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UnionAutomata</code>( <var class="Arg">A</var>, <var class="Arg">B</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Produces the disjoint union of the deterministic or non deterministic automata <code class="code">A</code> and <code class="code">B</code>. The output is a non-deterministic automaton.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ProductAutomaton</code>( <var class="Arg">A1</var>, <var class="Arg">A2</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The arguments must be deterministic automata. Returns the product of <var class="Arg">A1</var> and <var class="Arg">A2</var>.</p>
<p>Note: <span class="SimpleMath">\((p,q)->(p-1)m+q\)</span> is a bijection from <span class="SimpleMath">\(\{1,\ldots, n\}\times \{1,\ldots, m\}\)</span> to <span class="SimpleMath">\(\{1,\ldots,mn\}\)</span>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ProductOfLanguages</code>( <var class="Arg">A1</var>, <var class="Arg">A2</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Given two regular languages (as automata or rational expressions), returns an automaton that recognizes the concatenation of the given languages, that is, the set of words <span class="SimpleMath">\(uv\)</span> such that <span class="SimpleMath">\(u\)</span> belongs to the first language and <span class="SimpleMath">\(v\)</span> belongs to the second language.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">a1:=ListOfWordsToAutomaton("ab",["aa","bb"]);</span>
< deterministic automaton on 2 letters with 5 states >
<span class="GAPprompt">gap></span> <span class="GAPinput">a2:=ListOfWordsToAutomaton("ab",["a","b"]);</span>
< deterministic automaton on 2 letters with 3 states >
<span class="GAPprompt">gap></span> <span class="GAPinput">ProductOfLanguages(a1,a2);</span>
< deterministic automaton on 2 letters with 5 states >
<span class="GAPprompt">gap></span> <span class="GAPinput">FAtoRatExp(last);</span>
(bbUaa)(aUb)
</pre></div>
<h4>2.6 <span class="Heading">Links with Semigroups</span></h4>
<p>Each letter of the alphabet of an automaton induces a partial transformation in its set of states. The semigroup generated by these transformations is called the <em>transition semigroup</em> of the automaton.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ SyntacticSemigroupAut</code>( <var class="Arg">aut</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns the syntactic semigroup of the deterministic automaton <var class="Arg">aut</var> (i.e. the transition semigroup of the equivalent minimal automaton) when it is non empty and returns <code class="keyw">fail</code> otherwise.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ SyntacticSemigroupLang</code>( <var class="Arg">rat</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns the syntactic semigroup of the language given by the rational expression <var class="Arg">rat</var>.</p>
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.