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<Chapter><Heading>Pattern Classes</Heading>12Permutation pattern classes can be determined using their corresponding basis.3The basis of a pattern class is the anti-chain of the class,4under the order of containment. A permutation <M>\pi</M> contains another5permutation <M>\sigma</M> (of shorter length) if there is a subsequence6in <M>\pi</M>, which is isomorphic to <M>\sigma</M>. <P/>7With the rational language of the rank encoded class, it is also possible8to find the rational language of the basis and vice versa.9Several specific kinds of transducers are used in this process.10<Cite Key="RegCloSetPerms"/>1112<Section><Heading>Transducers</Heading>1314<ManSection>15<Func Name="Transducer" Arg="states,init,transitions,accepting"/>16<Returns>A record that represents a transducer.</Returns>17<Description>18A transducer is essentially an automaton, where running through the process does not19determine whether the input is accepted, but the input is translated to another language,20over a different alphabet. <P/>21Formally a transducer is a six-tuple with:22<M>Q</M> being the set of states, <M>S</M> the input alphabet, <M>G</M> the output alphabet,23<M>I \in Q</M> the start state, <M>A \subseteq Q</M> the set of accept states, and with the transition function24<M>f: Q \times (S \cup \{e\}) \rightarrow Q \times (G \cup \{e\})</M>, where <M>e</M> is the empty word. <P/>25In this function the transducer is stored by defining how many states there are, which one (by index) is the start26or initial state, the transitions are of the form <C>[inputletter,outputletter,fromstate,tostate]</C> and27a list of accept states. The input and output alphabet are determined by the input and output letters on28the transitions.29<Example><![CDATA[30gap> trans:=Transducer(3,1,[[1,2,1,2],[1,2,2,2],[2,2,1,3],[2,2,2,3],31> [1,1,3,3],[2,2,3,3]],[2]);32rec( accepting := [ 2 ], initial := 1, states := 3,33transitions := [ [ 1, 2, 1, 2 ], [ 1, 2, 2, 2 ], [ 2, 2, 1, 3 ],34[ 2, 2, 2, 3 ], [ 1, 1, 3, 3 ], [ 2, 2, 3, 3 ] ] )35gap> ]]></Example>36<Alt Only="LaTeX">37This transducer can be visualised as the following graph:38\begin{figure}[H] \begin{center} \leavevmode \includegraphics[scale=0.75]{img/trans.jpg} \end{center} \end{figure}39</Alt>40<Alt Only="HTML">41This transducer can be visualised as the following graph:42<br><center><img src="img/trans.jpg" WIDTH=241 HEIGHT=296 ></center><br>43</Alt>44</Description>45</ManSection>4647484950<ManSection>51<Func Name="DeletionTransducer" Arg="k"/>52<Returns>A transducer over <C>k</C>+1 states.</Returns>53<Description>54A deletion transducer is a transducer that deletes one letter of a rank encoded permutation55and returns the correct rank encoding of the new permutation. The deletion transducer over <C>k</C>56deletes letters over the set of all rank encoded permutations with highest rank <C>k</C>.57Specifically, running through a deletion transducer with a rank encoded permutation, of highest rank <C>k</C>,58will lead to the set of all rank encoded permutations that have one letter of the initial permutation removed.59It is important to note that computing these shorter permutations with the transducer, is done by reading the60input permutation from right to left.61For example the deletion transducer with <C>k</C>=3, looks as follows:62<Example><![CDATA[63gap> DeletionTransducer(3);64rec( accepting := [ 1 .. 3 ], initial := 4, states := 4,65transitions := [ [ 1, 1, 4, 4 ], [ 1, 0, 4, 1 ], [ 2, 1, 1, 1 ],66[ 1, 1, 1, 2 ], [ 3, 2, 1, 1 ], [ 1, 1, 2, 3 ], [ 1, 1, 3, 3 ],67[ 2, 2, 4, 4 ], [ 2, 0, 4, 2 ], [ 3, 2, 2, 2 ], [ 2, 2, 2, 3 ],68[ 2, 2, 3, 3 ], [ 3, 3, 4, 4 ], [ 3, 0, 4, 3 ], [ 3, 3, 3, 3 ] ] )69gap> ]]></Example>70<Alt Only="LaTeX">71\begin{figure}[H] \begin{center} \leavevmode \includegraphics[scale=0.75]{img/dt3.jpg} \end{center} \end{figure}72</Alt>73<Alt Only="HTML">74<br><center><img src="img/dt3.jpg" WIDTH=288 HEIGHT=317 ></center><br>75</Alt>76</Description>77</ManSection>7879808182<ManSection>83<Func Name="TransposedTransducer" Arg="t"/>84<Returns>A new transducer with interchanged input and output letters on each transition.</Returns>85<Description>86A transducer is transposed when all origins and destinations of transitions are left the same as before87but the input and output letters on each transition are interchanged.88Taking the deletion transducer from above, its transpose looks as follows:89<Example><![CDATA[90gap> TransposedTransducer(DeletionTransducer(3));91rec( accepting := [ 1 .. 3 ], initial := 4, states := 4,92transitions := [ [ 1, 1, 4, 4 ], [ 0, 1, 4, 1 ], [ 1, 2, 1, 1 ],93[ 1, 1, 1, 2 ], [ 2, 3, 1, 1 ], [ 1, 1, 2, 3 ], [ 1, 1, 3, 3 ],94[ 2, 2, 4, 4 ], [ 0, 2, 4, 2 ], [ 2, 3, 2, 2 ], [ 2, 2, 2, 3 ],95[ 2, 2, 3, 3 ], [ 3, 3, 4, 4 ], [ 0, 3, 4, 3 ], [ 3, 3, 3, 3 ] ] )96gap> ]]></Example>97<Alt Only="LaTeX">98\begin{figure}[H] \begin{center} \leavevmode \includegraphics[scale=0.75]{img/dtt3.jpg} \end{center} \end{figure}99</Alt>100<Alt Only="HTML">101<br><center><img src="img/dtt3.jpg" WIDTH=293 HEIGHT=319 ></center><br>102</Alt>103</Description>104</ManSection>105106107108109<ManSection>110<Func Name="InvolvementTransducer" Arg="k"/>111<Returns>A transducer over <C>k</C>+1 states, with a <C>k</C> sized alphabet.</Returns>112<Description>113An involvement transducer is a transducer over <C>k</C>+1 states, and deletes114any number of letters in a rank encoded permutation, of rank at most <C>k</C>.115<Example><![CDATA[116gap> InvolvementTransducer(3);117rec( accepting := [ 1 .. 4 ], initial := 4, states := 4,118transitions := [ [ 1, 1, 1, 2 ], [ 1, 0, 1, 3 ], [ 2, 1, 1, 1 ],119[ 2, 0, 1, 3 ], [ 3, 2, 1, 1 ], [ 3, 0, 1, 1 ], [ 1, 1, 2, 4 ],120[ 1, 0, 2, 1 ], [ 2, 2, 2, 4 ], [ 2, 0, 2, 2 ], [ 3, 2, 2, 2 ],121[ 3, 0, 2, 2 ], [ 1, 1, 3, 2 ], [ 1, 0, 3, 3 ], [ 2, 1, 3, 1 ],122[ 2, 0, 3, 3 ], [ 3, 1, 3, 3 ], [ 3, 0, 3, 3 ], [ 1, 1, 4, 4 ],123[ 1, 0, 4, 1 ], [ 2, 2, 4, 4 ], [ 2, 0, 4, 2 ], [ 3, 3, 4, 4 ],124[ 3, 0, 4, 4 ] ] )125gap> ]]></Example>126<Alt Only="LaTeX">127\begin{figure}[H] \begin{center} \leavevmode \includegraphics[scale=0.75]{img/it3.jpg} \end{center} \end{figure}128</Alt>129<Alt Only="HTML">130<br><center><img src="img/it3.jpg" WIDTH=318 HEIGHT=331 ></center><br>131</Alt>132</Description>133</ManSection>134135136137138139<ManSection>140<Func Name="CombineAutTransducer" Arg="aut,trans"/>141<Returns>An automaton consisting of a combination of <C>aut</C> and <C>trans</C>.</Returns>142<Description>143Combining automata and transducers is done over the natural "translation" of the by the automaton accepted language144through the transducer and then building a new automaton that accepts the new language. The function145<C>CombineAutTransducer</C> does this process and returns the new non-deterministic automaton.146<Example><![CDATA[147gap> a:=Automaton("det",1,1,[[1]],[1],[1]);148< deterministic automaton on 1 letters with 1 states >149gap> AutToRatExp(a);150a*151gap> t:=Transducer(2,1,[[1,2,1,2],[2,1,1,2],152> [1,1,2,1],[2,2,2,1]],[1]);153rec( accepting := [ 1 ], initial := 1, states := 2,154transitions := [ [ 1, 2, 1, 2 ], [ 2, 1, 1, 2 ], [ 1, 1, 2, 1 ],155[ 2, 2, 2, 1 ] ] )156gap> res:=CombineAutTransducer(a,t);157< non deterministic automaton on 2 letters with 2 states >158gap> AutToRatExp(res);159(ba)*160gap> Display(res);161| 1 2162-------------------163a | [ 1 ]164b | [ 2 ]165Initial state: [ 1 ]166Accepting state: [ 1 ]167gap> ]]></Example>168169</Description>170</ManSection>171172</Section>173174175176<Section><Heading>From Class to Basis and vice versa</Heading>177<ManSection>178<Func Name="BasisAutomaton" Arg="a"/>179<Returns>An automaton that accepts the rank encoded permutations of the basis180of the input automaton <C>a</C>.</Returns>181<Description>182Every pattern class has a basis that consists of the smallest set of permutations which do not183belong to the class. Using184<Display Mode="M">B(L)=(L^{r} D^{t})^{r} \cap L^{c}</Display>185it is possible using the deletion transducer <M>D</M> and the language of rank encoded permutations <M>L</M>186to find the language of the rank encoded permutations of the basis <M>B(L)</M>, and thus the basis.187<Example><![CDATA[188gap> x:=Parstacks(2,2);189[ [ 2, 4 ], [ 3, 6 ], [ 2 ], [ 5, 6 ], [ 4 ], [ ] ]190gap> xa:=GraphToAut(x,1,6);191< epsilon automaton on 5 letters with 66 states >192gap> ma:=MinimalAutomaton(xa);193< deterministic automaton on 4 letters with 9 states >194gap> Display(ma);195| 1 2 3 4 5 6 7 8 9196--------------------------------197a | 1 2 1 3 2 2 6 6 3198b | 3 2 3 3 4 3 6 9 3199c | 9 2 9 4 6 6 4 9 9200d | 8 2 8 7 5 5 7 8 8201Initial state: [ 1 ]202Accepting state: [ 1 ]203gap> ba:=BasisAutomaton(ma);204< deterministic automaton on 4 letters with 9 states >205gap> Display(ba);206| 1 2 3 4 5 6 7 8 9207--------------------------------208a | 2 2 1 3 4 2 2 2 2209b | 2 2 2 2 2 4 1 2 8210c | 2 2 2 2 2 2 1 2 2211d | 2 2 2 9 2 2 5 6 2212Initial state: [ 7 ]213Accepting states: [ 1, 5 ]214gap> AutToRatExp(ba);215d(a(dbdb)*aaU@)UbUc216gap> ]]></Example>217Ignoring the trailing <C>UbUc</C> which essentially are noise, the basis of the pattern class indicates which218permutations are avoided in this particular class. The shortest permutation in the basis, looking at the rational expression,219is <M>daaa</M>, which can be translated to 4111 and decoded to the permutation 4123.220</Description>221</ManSection>222223224225226<ManSection>227<Func Name="ClassAutomaton" Arg="a"/>228<Returns>The automaton that accepts permutations of the class in their rank encoding.</Returns>229<Description>230The function <C>ClassAutomaton</C> does the reverse process of <C>BasisAutomaton</C>. Namely it231takes the automaton that represents the language of the rank encoded basis of a permutation class,232and using the formula233<Display Mode="M">L=B_{k} \cap ((B(L)^{r} I^{t})^{c} )^{r}</Display>234returns the automaton that accepts the rank encoded permutations of the class.235In the formula, <M>B_{k}</M> is the automaton that accepts all permutations of any length with236highest rank <M>k</M>, <M>B(L)</M> is the automaton that represents the basis and <M>I</M> is237the involement transducer.238<Example><![CDATA[239gap> xa:=Automaton("det",9,4,[[2,2,1,3,4,2,2,2,2],[2,2,2,2,2,4,1,2,8],240> [2,2,2,2,2,2,1,2,2],[2,2,2,9,2,2,5,6,2]],[7],[1,5]);241< deterministic automaton on 4 letters with 9 states >242gap> ca:=ClassAutomaton(xa);243< deterministic automaton on 4 letters with 9 states >244gap> Display(ca);245| 1 2 3 4 5 6 7 8 9246--------------------------------247a | 1 2 1 3 2 2 6 6 3248b | 3 2 3 3 4 3 6 9 3249c | 9 2 9 4 6 6 4 9 9250d | 8 2 8 7 5 5 7 8 8251Initial state: [ 1 ]252Accepting state: [ 1 ]253gap> IsPossibleGraphAut(ca);254true255gap> ]]></Example>256</Description>257</ManSection>258259260261262<ManSection>263<Func Name="BoundedClassAutomaton" Arg="k"/>264<Returns>An automaton that accepts all rank encoded permutations, with highest rank being <C>k</C>.</Returns>265<Description>266The bounded class automaton, is an automaton that accepts all rank encoded permutations, of any length, with267highest rank <C>k</C>.268<Example><![CDATA[269gap> BoundedClassAutomaton(3);270< deterministic automaton on 3 letters with 3 states >271gap> Display(last);272| 1 2 3273--------------274a | 1 1 2275b | 2 2 2276c | 3 3 3277Initial state: [ 1 ]278Accepting state: [ 1 ]279gap> ]]></Example>280</Description>281</ManSection>282283284285286287<ManSection>288<Func Name="ClassAutFromBaseEncoding" Arg="base,k"/>289<Returns>The class automaton from a list of rank encoded basis permutations.</Returns>290<Description>291Given the permutations in the basis, in their rank encoded form, and the bound of the rank292of the permutations of the class, <C>ClassAutFromBaseEncoding</C> builds the automaton that293accepts rank encoded permutations of the class.294<Example><![CDATA[295gap> ClassAutFromBaseEncoding([[4,1,1,1]],4);296< deterministic automaton on 4 letters with 7 states >297gap> Display(last);298| 1 2 3 4 5 6 7299--------------------------300a | 1 2 1 3 2 2 6301b | 3 2 3 3 4 3 4302c | 4 2 4 4 6 6 4303d | 7 2 7 7 5 5 7304Initial state: [ 1 ]305Accepting state: [ 1 ]306gap> ]]></Example>307</Description>308</ManSection>309310<ManSection>311<Func Name="ClassAutFromBase" Arg="perms,k"/>312<Returns>The class automaton from a list of permutations of the basis.</Returns>313<Description>314Taking <C>perms</C> which is the list of permutations in the basis and <C>k</C> an315integer which indicates the highest rank in the encoded permutations of the class,316<C>ClassAutFromBase</C> constructs the automaton that accepts the language317of rank encoded permutations of the class.318319<!-- Given the permutations of the basis and the highest rank of the encoded permutations320of the class, <C>ClassAutFromBase</C> constructs the automaton that accepts the language321of rank encoded permutations of the class. -->322<Example><![CDATA[323gap> ClassAutFromBase([[4,1,2,3]],4);324< deterministic automaton on 4 letters with 7 states >325gap> Display(last);326| 1 2 3 4 5 6 7327--------------------------328a | 1 2 1 3 2 2 6329b | 3 2 3 3 4 3 4330c | 4 2 4 4 6 6 4331d | 7 2 7 7 5 5 7332Initial state: [ 1 ]333Accepting state: [ 1 ]334gap> ]]></Example>335</Description>336</ManSection>337338339340341<ManSection>342<Func Name="ExpandAlphabet" Arg="a,newAlphabet"/>343<Returns>The automaton <C>a</C>, over the alphabet of size <C>newAlphabet</C>.</Returns>344<Description>345Given an automaton and the size of the new alphabet, which has to be bigger than the size of346the alphabet in <C>a</C> , <C>ExpandAlphabet</C> changes the automaton <C>a</C> to contain347an alphabet of size <C>newAlphabet</C>. The new letters have no transitions within the348automaton.349<Example><![CDATA[350gap> aut:=Automaton("det",3,2,[[2,2,3],[3,3,3]],[1],[3]);351< deterministic automaton on 2 letters with 3 states >352gap> Display(aut);353| 1 2 3354--------------355a | 2 2 3356b | 3 3 3357Initial state: [ 1 ]358Accepting state: [ 3 ]359gap> ExpandAlphabet(aut,4);360< deterministic automaton on 4 letters with 3 states >361gap> Display(last);362| 1 2 3363--------------364a | 2 2 3365b | 3 3 3366c |367d |368Initial state: [ 1 ]369Accepting state: [ 3 ]370gap> ]]></Example>371</Description>372</ManSection>373374375376</Section>377378379380<Section><Heading>Direct Sum of Regular Classes</Heading>381382It is obvious that the direct sum of two rational pattern classes is also rational. But the skew sum of two rational383pattern classes does not imply that the resulting pattern class is rational, because if the second class in the384sum has infinitely many permutations, the alphabet of the skew sum class will be infinite and thusly the resulting385class will not be rational.386387<ManSection>388<Func Name="ClassDirectSum" Arg="aut1,aut2"/>389<Returns>An automaton that corresponds to the direct sum of <C>aut1</C> with <C>aut2</C>.</Returns>390<Description>391<C>ClassDirectSum</C> builds the concatenation automaton of <C>aut1</C> with <C>aut2</C>, which corresponds392to the pattern class <C>aut1</C> <M>\oplus</M> <C>aut2</C>.393<!-- EXAMPLE !!!!!!!! -->394<Example><![CDATA[395gap> a:=BasisAutomaton(GraphToAut(Parstacks(2,2),1,6));396< deterministic automaton on 4 letters with 9 states >397gap> AutToRatExp(a);398d(a(dbdb)*aaU@)UbUc399gap> b:=MinimalAutomaton(GraphToAut(Seqstacks(2,2),1,6));400< deterministic automaton on 3 letters with 3 states >401gap> AutToRatExp(b);402((cc*(aUb)Ub)(cc*(aUb)Ub)*aUa)*403gap> ab:=ClassDirectSum(a,b);404< deterministic automaton on 4 letters with 11 states >405gap> AutToRatExp(ab);406((d(acUc)c*(aUb)Ud(abUb))(cc*(aUb)Ub)*aUda(d(bdbd)*bdbaaUa)UbUc)((cc*(aUb)U\407b)(cc*(aUb)Ub)*aUa)*Ud(aU@)408gap> ]]></Example>409</Description>410</ManSection>411412413414</Section>415416417418419420<Section><Heading>Statistical Inspections</Heading>421It is of interest to see what permutations and how many of different length are accepted by the class,422respectively the basis. <P/>423In this section, the examples will be inspecting the basis automaton of the token passing network424containing 2 stacks of capacity 2, which are situated in parallel to each other.425<Example><![CDATA[426gap> x:=Parstacks(2,2);427[ [ 2, 4 ], [ 3, 6 ], [ 2 ], [ 5, 6 ], [ 4 ], [ ] ]428gap> xa:=GraphToAut(x,1,6);429< epsilon automaton on 5 letters with 66 states >430gap> ma:=MinimalAutomaton(xa);431< deterministic automaton on 4 letters with 9 states >432gap> ba:=BasisAutomaton(ma);433< deterministic automaton on 4 letters with 9 states >434gap> AutToRatExp(ba);435d(a(dbdb)*aaU@)UbUc436gap> ]]></Example>437438439440<ManSection>441<Func Name="Spectrum" Arg="aut [, int]"/>442<Returns>A list indicating how many words of each length from 1 to443<C>int</C> or 15 (default) are accepted by the automaton.</Returns>444<Description>445Each entry in the returned list indicates how many words of length the index of the entry446are accepted by the automaton <C>aut</C>. The length of the list is447by default 15, but if this is too much or too little the second optional argument448regulates the length of the list.449<Example><![CDATA[450gap> Spectrum(ba);451[ 3, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ]452gap> Spectrum(ba,20);453[ 3, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1 ]454gap> ]]></Example>455</Description>456</ManSection>457458459460461<ManSection>462<Func Name="NumberAcceptedWords" Arg="aut,len"/>463<Returns>The number of words of length <C>len</C> accepted by the automaton <C>aut</C>.</Returns>464<Description>465Given the automaton <C>aut</C> and the integer <C>len</C>, <C>NumberAcceptedWords</C> determines466how many words of length <C>len</C> are accepted by the automaton.467<Example><![CDATA[468gap> NumberAcceptedWords(ba,1);4693470gap> NumberAcceptedWords(ba,16);4711472gap> ]]></Example>473</Description>474</ManSection>475476477478479<ManSection>480<Func Name="AutStateTransitionMatrix" Arg="aut"/>481<Returns>A matrix containing the number of transitions between states of the automaton <C>aut</C>.</Returns>482<Description>483In the matrix computed by <C>AutStateTransitionMatrix</C> the rows are indexed by the state the transitions484are originating from, the columnns are indexed by the states the transitions are ending at. Each entry485<M>a_{i,j}</M> of the matrix represents the number of transitions from the state <M>i</M> to the state <M>j</M>.486<Example><![CDATA[487gap> AutStateTransitionMatrix(ba);488[ [ 0, 4, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 4, 0, 0, 0, 0, 0, 0, 0 ],489[ 1, 3, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 2, 1, 0, 0, 0, 0, 0, 1 ],490[ 0, 3, 0, 1, 0, 0, 0, 0, 0 ], [ 0, 3, 0, 1, 0, 0, 0, 0, 0 ],491[ 2, 1, 0, 0, 1, 0, 0, 0, 0 ], [ 0, 3, 0, 0, 0, 1, 0, 0, 0 ],492[ 0, 3, 0, 0, 0, 0, 0, 1, 0 ] ]493gap> ]]></Example>494</Description>495</ManSection>496497498499500<ManSection>501<Func Name="AcceptedWords" Arg="aut,int"/>502<Returns>All words of length <C>int</C> that are accepted by the automaton <C>aut</C>.</Returns>503<Description>504<C>AcceptedWords</C> outputs all permutations accepted by the automaton <C>aut</C>, which have length505<C>int</C>, in a list. The permutations are output in their rank encoding.506<Example><![CDATA[507gap> AcceptedWords(ba,1);508[ [ 2 ], [ 3 ], [ 4 ] ]509gap> AcceptedWords(ba,16);510[ [ 4, 1, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 1, 1 ] ]511gap> ]]></Example>512</Description>513</ManSection>514515516517518<ManSection>519<Func Name="AcceptedWordsR" Arg="aut,int1 [,int2]"/>520<Func Name="AcceptedWordsReversed" Arg="aut,int1 [,int2]"/>521<Returns>The list of all by the automaton accepted words of length <C>int1</C>,522where each word is written in reverse.</Returns>523<Description>524The functions <C>AcceptedWordsR</C> and <C>AcceptedWordsReversed</C> are synonymous and take the following525arguments; an automaton <C>aut</C>, an integer <C>int1</C> which indicates the length of the words that are526accepted by the <C>aut</C> and another integer <C>int2</C> which is optional and represents the initial state527of <C>aut</C>. The return value of these functions is the list containing all permutations of length <C>int1</C>528that are accepted by <C>aut</C>. The permutations are rank encoded and written in reverse.529<Example><![CDATA[530gap> AcceptedWordsR(ba,1);531[ [ 2 ], [ 3 ], [ 4 ] ]532gap> AcceptedWordsReversed(ba,16);533[ [ 1, 1, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 1, 4 ] ]534gap> ]]></Example>535</Description>536</ManSection>537538539</Section>540541</Chapter>542543