44
P ERM PAL P ERMUTATION P ATTERN AVOIDANCE L IBRARY Arnar Bjarni Arnarson Álfur Birkir Bjarnason Sigurjón Freyr Viktorsson Unnar Freyr Erlendsson T-404-LOKA May 2017 School of Computer Science Reykjavík University Project report

P PAL PERMUTATION PATTERN AVOIDANCE LIBRARY 2017.pdf1 Chapter1 Introduction Thisprojectisaimedathelpingmathematiciansworkinginthefieldofpermutationpatterns

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

  • PERMPALPERMUTATION PATTERN AVOIDANCE LIBRARY

    Arnar Bjarni ArnarsonÁlfur Birkir BjarnasonSigurjón Freyr ViktorssonUnnar Freyr ErlendssonT-404-LOKAMay 2017School of Computer ScienceReykjavík University

    Project report

  • ii

  • PermPALPermutation Pattern Avoidance Library

    Arnar Bjarni ArnarsonÁlfur Birkir Bjarnason

    Sigurjón Freyr ViktorssonUnnar Freyr Erlendsson

    May 2017

    Abstract

    We explore and develop ways to enumerate permutation pattern avoidance classes fromcombinatorial structures defined by the algorithms Struct and ATRAP. Generating functionsand recurrence relations are used to describe the coefficients for permutations of certainlengths. Enumeration of avoidance classes from Struct covers was successful in all cases,but recursively defined structures posed a problem in ATRAP trees. The generating functionswe obtained for bases with patterns from S3 and S4 were categorized into Wilf-Classes. Adatabase and a web site were set up to store and display all the results, and are accessible onhttp://permpal.ru.is.

    http://permpal.ru.is

  • PermPALPermutation Pattern Avoidance Library

    Arnar Bjarni ArnarsonÁlfur Birkir Bjarnason

    Sigurjón Freyr ViktorssonUnnar Freyr Erlendsson

    maí 2017

    Útdráttur

    Við leitum leiða til að reikna út tölusetningu (e. enumeration) á klösumumraðana (e. permutati-on classes) sem innihalda ekkimynstur út frá fléttufræðilegum (e. combinatorial) formgerðum(e. structure) sem skilgreind eru af reikniritunum Struct og ATRAP. Framleiðniföll og rakn-ingarformúlur eru notuð til að reikna fjölda umraðana af ákveðnum lengdum. Talning út fráStruct þekjum (e. cover) heppnaðist í öllum tilvikum en endurkvæmni í formgerðum ATRAPtrjáa gerði sambærilega talningu þeirra erfiða. Framleiðniföll sem við reiknuðum út fyrirklasa með mynstur sem innihalda umraðanir úr S3 og S4 voru flokkuð í Wilf klasa (e. Wilf-classes). Gagnagrunnur og vefur var settur upp til að geyma og birta allar niðurstöður, semeru aðgengilegar á http://permpal.ru.is.

    iv

    http://permpal.ru.is

  • Acknowledgements

    We would like to thank Ragnar Ardal, Christian Bean, Anders Claessen, Jay Pantone andHenning Ulfarsson, for inviting us to work on this project in parallel with their own research.We would also like to thank them for their support, ideas and the access to their permutationmanipulating libraries.Research partially supported by grant 141761-051 from the Icelandic Research Fund.

  • vi

  • vii

    Contents

    Acknowledgements v

    Contents vii

    List of Figures ix

    List of Tables xi

    1 Introduction 11.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    2 Permutations 32.1 Permutations and Their Classes . . . . . . . . . . . . . . . . . . . . . . . . 32.2 Tilings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    3 Struct Covers 73.1 Struct Cover to Recurrence Relation . . . . . . . . . . . . . . . . . . . . 7

    3.1.1 The Intitial Condition . . . . . . . . . . . . . . . . . . . . . . . . . 73.1.2 Recursive step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.1.3 The Special Case of Points . . . . . . . . . . . . . . . . . . . . . . 11

    3.2 Struct Cover to Generating Function . . . . . . . . . . . . . . . . . . . . 123.2.1 Combinatorial Structures . . . . . . . . . . . . . . . . . . . . . . . 123.2.2 Factors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.2.3 Automatic Generating Functions for Factors . . . . . . . . . . . . . 123.2.4 Hadamard Product . . . . . . . . . . . . . . . . . . . . . . . . . . 143.2.5 Unique Factors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

    4 ATRAP Trees 154.1 ATRAP Trees and Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . 154.2 Generating Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.3 Bases from both S3 and S4 . . . . . . . . . . . . . . . . . . . . . . . . . . 17

    4.3.1 Wilf-Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.3.2 Finite classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

    5 PermPAL 215.1 Viewing an entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

    5.1.1 Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215.1.2 Drawing ATRAP trees . . . . . . . . . . . . . . . . . . . . . . . . . 22

    5.2 Searching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225.3 Technical details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

    http://permpal.ru.is

  • viii

    5.4 Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235.4.1 Columns of an entry . . . . . . . . . . . . . . . . . . . . . . . . . 24

    6 Conclusion 27

    Bibliography 29

  • ix

    List of Figures

    2.1 Some tilings that describe 431562 . . . . . . . . . . . . . . . . . . . . . . . . 42.2 A tiling and its factors and graph . . . . . . . . . . . . . . . . . . . . . . . . . 5

    3.1 Struct cover of Av(132). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.2 Struct cover of Av(123, 132, 213, 3412, 3421). . . . . . . . . . . . . . . . . . 83.3 Some examples of mixing permutations. . . . . . . . . . . . . . . . . . . . . . 93.4 Struct cover of Av(132). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    4.1 Example trees for Av(132) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    5.1 Some examples of results from coefficient search queries. . . . . . . . . . . . . 22

  • x

  • xi

    List of Tables

    4.1 The 10 largest Wilf classes for bases in β . . . . . . . . . . . . . . . . . . . . . 184.2 Finite permutation classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

  • xii

  • 1

    Chapter 1

    Introduction

    This project is aimed at helping mathematicians working in the field of permutation patternsby providing methods for calculating generating functions automatically, storing the resultsand displaying them in an accessible manner for others to enjoy. The enumeration of theseclasses using generating functions and recurrence relations is usually done by hand but wedescribe automatic methods of extracting said mathematical formulas from combinatorialstructures provided by the algorithms Struct and ATRAP.

    1.1 BackgroundIn his book The Art of Computer Programming vol. 1, Donald Knuth proved that all permut-ations, that do not contain the permutation 231, could be sorted using only a single stack forinternalmemory storage, thus giving birth to themodern study of permutation patterns (Knuth1968). This information alone does not tell us much. Is that a lot of permutations or only ahandful? Are they possibly infinitely many? The problem of enumerating such permutationclasses has been studied since. It turns out that the so-called stack-sortable permutationsare counted by the Catalan numbers ({1, 1, 2, 5, 14, 42, . . . }, https://oeis.org/A000108).They are indeed infinitely many.

    Since Knuth introduced the stack-sortable permutations, much work has been done in thefield of permutation classes. Still, the work can be tedious, repetitive and infinite, as there areinfinitely many permutation classes. Henning Ulfarsson has been working on permutationclasses for a few years now, and has a few students working on the ATRAP and Structalgorithms with him. With his algorithms, Ulfarsson’s group seeks to fully automate theenumeration of permutation classes. In late 2016, he and his team had produced automaticconjectures of the combinatorial structures of classes that avoid several sets of permutationsof length 4. The next step is to take those structures and deduce an enumeration for each.To this end, Ulfarsson introduced us to his ideas of putting mathematicians out of a job andproposed a project for which he would be the instructor.

    Ulfarsson’ group already had some ideas on how to calculate generating functions fromStruct covers and had tried them successfully by pen and paper for some covers. Thequestion was "Is it possible to derive these generating functions automatically for all Structcovers?" and "What about recurrence relations?"

    Initially, we defined our project to be the research, and possible implementation, of au-tomatic algorithms to calculate both generating functions and recurrence relations for theenumerations of permutation classes from the output of Struct. We would also apply ourprocedures to the already present logs of Struct output and set up an encyclopedia for per-

    https://oeis.org/A000108

  • 2 CHAPTER 1. INTRODUCTION

    mutation classes where we would make our findings accessible. As there are infinitely manypermutation classes we would limit our work to permutation patterns that avoid permutationsof length 4 or less, or combinations thereof, focusing on permutations of length 4.

    Later, as Ulfarsson and his team developed the proving algorithm ATRAP, we decidedto also try our procedures on ATRAP trees and see how we could improve them to be fullycompatible with ATRAP. We made some headway at this but as ATRAP is, as of today, still indevelopment we could not finish.

    In this report, we will describe our findings and developed tools. In Chapter 2, we willdefine permutations, permutation classes, tilings and other concepts used in the report. InChapter 3, we discuss how to automatically calculate the recurrence relations and generatingfunctions of classes from their Struct covers. In Chapter 4, we take a look at ATRAPtrees, what we can deduce from them and where our limitations lie. We then discuss howwe enumerated some simple classes from ATRAP trees. Lastly, in Chapter 5, we showcasethe website and database at http://permpal.ru.is and how this encyclopedia permuticashould be of use to mathematicians interested in permutation patterns.

    http://permpal.ru.is

  • 3

    Chapter 2

    Permutations

    In this chapter, we will introduce definitions used throughout the text.

    2.1 Permutations and Their ClassesA permutation of length n is a word on [n] = {1, 2, ..., n} where each letter appears exactlyonce. The set of all permutations of length n is Sn and the set of all permutations of alllengths is the set S. The permutation 1 is also called the point, denoted •. The point notationis mostly used in tilings, as described in Section 2.2.

    For a word w of length n, let wi be the i-th letter of w if i ≤ n. Two words w and v suchthat wi < w j implies vi < v j for all i and j are said to be order isomorphic. A subword w′ ofa word w is a word obtained by removing some of the letters in w. The letters of w′ do notneed to be adjacent in the original word w.

    Example 1. The word 231 is a permutation of length 3, so 231 ∈ S3. This permutation isorder isomorphic to 352 but not to 423. 352352352 is a subword of 433315556222.

    We say that a permutation p is less than a permutation q if |p| < |q | or, if they are ofequal length, if p is lexically smaller than q. That is for p = p1p2 · · · pn and q = q1q2 · · · qm

    p < q if n < mp < q if n = m and p1 = q1, p2 = q2, . . . , pi−1 = qi−1 but pi < qi .

    A permutation π contains a permutation p if there is a subword in π that is order isomorphicto p. If π does not contain p then we say π avoids p. In this setting we say p is a (classicalpermutation) pattern.

    Example 2. Since 352 is a subword of 431562 and 352 is order isomorphic to 231, 431562contains 231. However, 431562 avoids 1234.

    An avoidance class or permutation class C with basis B is the set of all permutationsthat avoid all permutations in B. We write C = Av(B). If B = {b1, b2, . . . , bn} we writeAv(B) and Av(b1, b2, . . . , bn) interchangeably. The permutation classes Av(12) and Av(21)are often denoted D or �, and I or �, respectively. This is because Av(12) is the class ofdecreasing permutations and Av(21) is the class of increasing permutations.

    We say a sorted basis B is less than a sorted basis B′ if for the first permutations p ∈ Band q ∈ B′ from smallest to largest that differ, p < q holds. For two general bases B and B′,B is less than B′ if B sorted is less than B′ sorted.

  • 4 CHAPTER 2. PERMUTATIONS

    Given a permutation class C = Av(B) we say that Cn or Avn(B) is the set of all permuta-tions of length n in C. The enumeration of the class C is the infinite sequence {cn} such thatcn = |Cn | for all n. Two permutation classes C and C′ are Wilf-equivalent if they have thesame enumeration. Two Wilf-equivalent permutation classes are said to belong to the sameWilf-class. Wilf-classes are equivalence classes.

    2.2 TilingsIn order to define tilings we recall generalized grid classes as introduced by Vatter 2011.Given a permutation π of length n, and two integer intervals [d0, d1], [r0, r1] such that d0, r0 ≥ 0and d1, r1 ≤ n then π([d0, d1] × [r0, r1]) is the permutation that is order isomorphic to thesubword with indices from [d0, d1] and values in [r0, r2].

    Example 3. Consider 431562([2, 6] × [2, 5]). We take only the letters of 431562 withindices from 2 to 6, that is the subword 31562. Then, from the subword 31562 we take theletters with values from 2 to 5, that is the subword 352. 352 is order isomorphic to 231 so431562([2, 6] × [2, 5]) = 231.

    A tiling is a t × u matrix (indexed with cartesian (x, y) coordinates) whose entries arepermutation classes, or the set {•}. A tiling T is said to describe a permutation π of lengthn if there exists a pair of sequences d = (d1, d2, . . . , dt+1) and r = (r1, r2, . . . , rt+1) such that1 = d1 ≤ · · · ≤ dt+1 = n+1 and 1 = r1 ≤ · · · ≤ ru+1 = n+1 such that π([dk, dk+1)×[rl, rl+1))is in Tk,l for all k in [t] and l in [u]. If for each permutation described by a tiling T , thesequences c and r are unique, then T is said to be natural.

    ••

    ••

    (a) A tiling that only describes431562

    (b) A tiling that describesmore permutations than only431562

    ��•

    (c) A tiling that describes evenmore permutations than theone before

    Figure 2.1: Some tilings that describe 431562

    Example 4. In Figure 2.1 there are three different tilings that describe the permutationp = 431562. The tiling in Figure 2.1a only describes p and can therefore be called the tilingof p. Here both sequences, c and r , are (1, 2, 3, 4, 5, 6, 7). In Figure 2.1b the sequence c is(1, 3, 4, 6, 7) and the sequence r is (1, 2, 3, 5, 7) because 12 from the subword 56 is in � and21 from the subword 43 is in �. Similarly for Figure 2.1c the sequence c is (1, 4, 6, 7) andthe sequence r is (1, 5, 7) but now 321 from the subword 431 must be in�, which it is.We will often display permutations as tilings like the one in Figure 2.1a to better get a feelingof their geometric attributes. We can also say that in Figure 2.1c, we can substitute � with12 and� with 321 to obtain the tiling of p and thereby p.

    Each non-empty cell in a tiling is called a block. We define a graph on tilings whereeach node represents a block and two nodes are connected by an edge if and only if they arein the same row or column. Each connected component in this graph and its respective set

  • 2.2. TILINGS 5

    of blocks is called a factor. Factors come into play when we calculate generating functionsfor tilings. The rank of tilings and factors is a number from 0 to 9 based on our perceivedcomplexity of the structure.

    �•

    �•

    A

    (a) Example tiling T

    � �•�

    ••A

    (b) The factors in T

    � � �

    A

    ••

    (c) The graph of T

    � � �

    A

    ••

    •(d) Rearranged graph of T

    Figure 2.2: A tiling and its factors and graph

    Example 5. In Figure 2.2 we see an example tiling and its factors. Each row and column forma clique in the graph of the tiling and by rearranging the graph, each connected componentreveals the factors of the graph.

    Two tilings are disjoint if no permutation is described by both tilings. A permutation isdescribed by the union of two tilings if it is described by at least one of the tilings. Similarly,in the disjoint union of tilings each permutation in the union is described by exactly one ofthe tilings. A cover of a permutation class C is the disjoint union of tilings such that eachpermutation in C is described by exactly one tiling in the cover. If all the tilings in a coverare natural, the cover is natural.

  • 6

  • 7

    Chapter 3

    Struct Covers

    In this chapter, we will discuss how to enumerate permutation classes using their Structcovers. There are two ways of doing this; combinatorially finding a recurrence relation orfinding the generating function. Both ways will be discussed.

    A Struct cover of a class is a natural cover conjectured by the algorithm Struct todescribe exactly the permutations in the class as described by Bean, Gudmundsson, andUlfarsson 2017.

    3.1 Struct Cover to Recurrence RelationA recurrence relation for the sequence {an} is an equation that expresses an in terms of oneor more of the previous terms of the sequence for all integers n with n ≥ n0, where n0 is apositive integer. The set of ai for all i < n0 is called the initial condition.

    In our context of permutation classes, the sequences we are interested in are the enumer-ations of classes where each ai is the number of permutations of length i in the class. Wewill now describe how to algorithmically calculate a recurrence relation for the enumerationfrom the Struct cover of a permutation class.

    Since Struct covers are natural, each permutation of the class is described by exactlyone tiling of the cover in a unique way. Therefore, we can calculate how many permutationseach tiling describes in isolation and sum them up in the end.

    3.1.1 The Intitial ConditionFor Struct covers, we define n0 to be the smallest integer such that all tilings that containonly points or are empty describe permutations that are smaller than n0. That is, for eachtiling, if all cells are empty or contain the point, the number of points is smaller than n0. Inorder to calculate the initial condition, we generate all the permutations smaller than n0 foreach tiling and count them.

    A = t A•

    A

    Figure 3.1: Struct cover of Av(132).

    Example 6. In the introduction in Chapter 1 we mentioned the stack-sortable permutationsthat avoid 231. Let’s enumerate the permutation class Av(231). As we will discuss in

  • 8 CHAPTER 3. STRUCT COVERS

    Section 4.3, all classes with symmetric bases have the same enumeration so we will look atthe symmetric class with the smallest basis, that is Av(132).Consider the Struct cover for A = Av(132) in Figure 3.1. Let {an} be the enumeration ofA. In this cover, the largest tiling that consists only of points or is empty is the empty tiling.It has 0 points and therefore n0 = 1. We must, therefore, find all permutations of lengthsmaller than 1. This is simple as it is only the empty permutation � . Therefore a0 = 1, andthis is our only initial condition.

    C = t•• t •

    tC

    Figure 3.2: Struct cover of Av(123, 132, 213, 3412, 3421).

    Example 7. If we want to look at a more complex initial condition we can look at the Structcover for C = Av(123, 132, 213, 3412, 3421) with enumeration {cn} in Figure 3.2. In thiscover, the largest tiling that consists only of points is the third tiling from the left. It has 3points and therefore n0 = 4. We then find all permutations of length smaller than 4.We see that the empty permutation � is described by the first tiling. This is the onlypermutation of length 0 so c0 = 1. The point permutation can be described by substitutingC in the last tiling with � , which we have verified is in C. This is the only permutation oflength 1 so c1 = 1. The permutation 12 is described by the second tiling and the permutation21 can be described by the last tiling by substituting C with the point permutation, which isin C. These are the only permutations of length 2 and so c2 = 2. The permutation 231 isdescribed by the third tiling and the permutations 312 and 321 can be described by the lasttiling by substituting C with 12 and 21 respectively. These are the only length 3 permutationsdescribable by this cover and so c3 = 3.Together c0, c1, c2 and c3 make up the initial condition for the recurrence relation of C.

    3.1.2 Recursive step

    In order to find the recursive step we only look at the tilings that do not only containpoints, since those that do cannot, by definition of n0, describe permutations of length n0 orhigher. As stated before, we can calculate how many permutations each tiling describes inisolation and sum them up in the end.

    Therefore, for each tiling, we assume an n ≥ n0. For each tiling that contains a non-emptyblock, we count howmany permutations of length n the tiling describes. To do this we defineand prove a few combinatorial rules regarding tilings.

    Theorem 1. Let T be a non-empty tiling. Let there be b ≥ 1 cells in T that contain the per-mutation classes C(1), C(2), . . . , C(b) with enumerations {c(1)n }, {c(2)n }, . . . , {c(b)n } respectively.The number of permutations of length n described by T is given by the formula:

    tn =(n)∑

    p1=0

    (n−p1)∑p2=0· · ·(n−p1−p2−···−pb−2)∑

    pb−1=0r · d ·

    b∏i=1

    c(i)pi (3.1)

  • 3.1. STRUCT COVER TO RECURRENCE RELATION 9

    where pb = n − p1 − p2 − · · · − pb−1 and r and d are the products of the multinomialcoefficients for each row and column (ísl. dálkur, hence the d) respectively. That is, ris the product of (

    ps(1) + ps(2) + · · · + ps(b′)ps(1), ps(2), . . . , ps(b′)

    )(3.2)

    for each row, with some b′ ≥ 1 non-empty cells and a mapping s, from [b′] to the cor-responding indices of the classes in the given row, and d is calculated similarly for thecolumns.

    The intuition of this formula is that for a given n we want to know in how many ways wecan arrange n points to be described by a tiling. First, we assign the n points to the blocks.For each assignment (p1, p2, . . . , pk) of the n points there are c(1)p1 , c

    (2)p2 , . . . , c

    (b)pk ways to choose

    a permutation of length pi from each block. Then the points in each row and column must beordered relatively between the blocks. That is to say, in each row which block should havethe highest point, the second-highest, etc. This is done by the multinomial coefficients in dand r .

    p

    •q

    (a) p and q share a row in theoriginal tiling

    ••

    ••

    (b) All points in p are above q

    (c) Mixing the points in p andq

    ••

    (d) Mixing the points in p andq

    (e) Mixing the points in p andq

    ••

    ••

    (f) All points in p are below q

    Figure 3.3: Some examples of mixing permutations.

    Example 8. To illustrate the use of the multinomials consider the permutations p = 21 andq = 12 in the tiling shown in Figure 3.3. Here, there are

    (2+22,2

    )=

    ( 42,2

    )=

    (42)= 5 ways to

    relatively arrange the points in p and q. These arrangements are displayed in Figure 3.3. Inall the examples the leftmost two points still represent p = 21 and the rightmost two pointsq = 12, as they should.

    Let’s state this formally

    Lemma 1. Let T be a tiling such that in a given row or column there are b ≥ 1 permutationsπ1, π2, . . . , πb. There are (

    |π1 | + |π2 | + · · · + |πb ||π1 |, |π2 |, . . . , |πb |

    )(3.3)

    ways to relatively order the permutations within the row or column

  • 10 CHAPTER 3. STRUCT COVERS

    Proof. We prove this by induction on b.Without loss of meaningful generality, we can prove this only for rows. In the base case

    b = 1 there is only one permutation π1 in the row. This means we wish to assign |π1 | verticalplaces to a single permutation that should be assigned |π1 | places. This can be done in1 =

    ( |π1 ||π1 |

    )ways, so the formula holds.

    Next, assume the formula holds for some b − 1 ≥ 1. That is, there are b − 1 ≥ 1permutations π1, π2, . . . , πb−1 and there are(

    |π1 | + |π2 | + · · · + |πb−1 ||π1 |, |π2 |, . . . , |πb−1 |

    )ways to relatively order the permutations within the row.

    We now introduce a new permutation, πb, to the row. Assume the other b−1 have alreadybeen relatively ordered. We wish to find a place for the |πb | points within the seats of theother already ordered permutations. This can be done in(

    (|π1 | + |π2 | + · · · + |πb−1 |) + (|πb |)(|π1 | + |π2 | + · · · + |πb−1 |), (|πb |)

    )=

    (|π1 | + |π2 | + · · · + |πb |

    (|π1 | + |π2 | + · · · + |πb−1 |), (|πb |)

    )ways. Collectively there are therefore(|π1 | + |π2 | + · · · + |πb−1 ||π1 |, |π2 |, . . . , |πb−1 |

    )·(

    |π1 | + |π2 | + · · · + |πb |(|π1 | + |π2 | + · · · + |πb−1 |), (|πb |)

    )=

    (|π1 | + |π2 | + · · · + |πb ||π1 |, |π2 |, . . . , |πb |

    )ways to relatively order the permutations which is what we wanted to show. �

    We are now ready for the formal proof of the formula.

    Proof of Theorem 1. Let b ≥ 1 and C(i) permutation classes with enumerations {c(i)n} forall i ∈ {1, 2, . . . , b}. For each tuple (p1, p2, . . . , pb) such that

    ∑bi=1 pi = n we assign pi points

    to each class C(i). In total there have been assigned n points within the tiling and so thepermutation that will be described is of length n. Each C(i) can now choose a permutation inc(i)pi ways and therefore collectively the classes can choose permutations in

    b∏i=1

    c(i)pi

    unique ways with this point assignment tuple. We now use Lemma 1 to determine in howmany ways each row and column can be internally ordered between the classes by lettingr be the product of the multinomial coefficients of all the rows and d be the product of themultinomial coefficients for all the columns as stated in Theorem 1. There are therefore

    r · d ·b∏

    i=1c(i)pi

    unique permutations of length n described by T with this point assignment tuple.This formula uses the fact that each tiling from Struct is natural.All that is left now is to sum up the number of permutations described by T for each point

    assignment tuple. This can be done with the formula(n)∑

    p1=0

    (n−p1)∑p2=0· · ·(n−p1−p2−···−pb−2)∑

    pb−1=0r · d ·

    b∏i=1

    c(i)pi

    where pb = n − p1 − p2 − · · · − pb−1 which is what we wanted to show. �

  • 3.1. STRUCT COVER TO RECURRENCE RELATION 11

    We now only have to use Theorem 1 to calculate tn for each tiling where b ≥ 1 as othertilings only contribute to the initial condition and sum them together. By not substituting thec(i)pi and n in the formula we get a general recurrence relation for the Struct cover. If noneof the C(i) is the class the cover describes there is no recurrence. We still call the formulascalculated recurrence relations for simplicity’s sake.

    3.1.3 The Special Case of Points

    The point block has the enumeration {0, 1, 0, 0, 0, . . . } since there is only one way ofplacing a point, and that is by placing the permutation 1, of length 1. In the formula abovethere are many terms to calculate but if there is a point in the tiling, the majority of thoseterms will evaluate to 0. Therefore, we can take a shortcut in calculating the recurrencerelation by assuming each point block will be assigned exactly one point and disregard anyother point assignment tuples. In effect, this leads to the formula

    (n−l)∑p1=0

    (n−l−p1)∑p2=0

    · · ·(n−l−p1−p2−···−pb′−2)∑

    pb′−1=0r · d ·

    b′∏i=1

    c(i)pi

    where l is the number of points, and b′ = b − l. We have assigned the classes C(i) thatare only the point class one point each and use the fact that they can then only choose onepermutation, which will not affect the overall product.

    We can nowfinish the recurrence relations for Av(132) and Av(123, 132, 213, 3412, 3421).

    Example 6 (Continued). In the previous part of Example 6 the initial condition for A =Av(132) was shown to be a0 = 1. We now wish to calculate the recurrence relation for somegeneral length n from the Struct cover in Figure 3.1. For this, we only need to look at thelarger tiling, since the other describes no permutations of length n0 = 1 or more, and use theformula from Theorem 1. Since no two blocks share a row or column, d and r are going tobe equal to 1 in all cases. We also see that there is one point block and therefore l = 1. theformula then gives us

    an =n−1∑p1=0

    ap1 · an−1−p1

    Along with the initial condition a0 = 1, this is the recurrence relation for the enumeration ofA. By calculating the first few terms of the enumeration from the recurrence relation we seethat it is {1, 1, 2, 5, 14, 42 . . . } which is indeed the Catalan sequence.

    Example 7 (Continued). Similarly to above, we take the initial conditions for C = Av(123,132, 213, 3412, 3421), c0 = 1, c1 = 1, c2 = 2 and c3 = 3 as calculated in the previous part ofExample 7. We then look only at the last tiling and justlike above, no blocks share rows orcolumns and there is only one point block. Therefore d = r = 1 and l = 1 and we get

    cn = cn−1

    Along with the initial condition c0 = 1, c1 = 1, c2 = 2 and c3 = 3, this is the recurrencerelation for the enumeration of C.

  • 12 CHAPTER 3. STRUCT COVERS

    3.2 Struct Cover to Generating FunctionA generating function is another way of describing an infinite sequence of numbers bytreating the coefficients of its power series as the terms in the sequence.

    We will say that if a permutation class has a power series∑

    i≥0 ai xi then ai tells ushow many permutations of length i are in that permutation class. A motivation for alsofinding the generating functions for permutation classes, and not only recurrence relations,is that they are easier to compare than recurrence relations and it can be done withoutdirectly comparing (infinitely many) coefficients. We will now discuss methods of obtaininga generating function for a given Struct cover.

    3.2.1 Combinatorial StructuresWe start by noting that our tilings are combinatorial structures as defined by Flajolet andSedgewick 2009 where the empty tiling is our neutral class, E, and points are our atomicclass, Z. As a consequence of this we have that the generating functions for those areE(x) = 1, Z(x) = x. This is in accordance with the fact that the enumeration of the class {�}is {1, 0, 0, 0, . . . } and the enumeration of the set {•} is {0, 1, 0, 0, 0, . . . }. As a general rulewe denote the generating function of permutation class C with C(x).

    For a Struct cover we have a disjoint union of tilings so we can say that the generatingfunction of a cover C is the sum of the generating functions of all the tilings in C. If we knowthe generating function for every tiling it will be easy to compute the generating function fora whole cover.

    3.2.2 FactorsWe have simplified the problem to just needing to find a generating function for each tilingindependently, but we can simplify it even further. For every tiling, the only blocks thataffect each other are the blocks that are in the same factor. This allows us to consider eachfactor independently. We can then combine the combinatorial structures, using the Cartesianproduct, which is equivalent to multiplying together the generating functions. This gives usa nice formula for calculating a generating function for a cover which we will formalize inTheorem 2.

    Theorem 2. Let C be a cover and let C(x) be its generating function, then

    C(x) =∑T∈C

    ∏F∈T

    G(x) (3.4)

    where T is a tiling in C, F is a factor in T and G(x) is the generating function for the factorF.

    This shows that if we can automatically compute the generating function for each factorwe can do it for every cover. Still, this proved challenging and we do not have fully automaticmethods for computing every single factor. We will now discuss which factors we canautomatically calculate the generating functions, and how we do it.

    3.2.3 Automatic Generating Functions for FactorsThere are a lot of factors that we can process with automatic methods, consider a factor witha single vertex, its generating function will just be the generating function for that block.

  • 3.2. STRUCT COVER TO GENERATING FUNCTION 13

    A = t•

    A

    A

    Figure 3.4: Struct cover of Av(132).

    Example 9. We can calculate generating function A(x) for A with Theorem 2 to be

    A(x) = 1 + x · A(x)2

    which can be solved for A(x) to get the equation

    A(x) =√

    1 − 4x + 12x

    which is indeed the generating function for the Catalan numbers.

    Now consider a factor F which only consists of a single clique with p > 1 points.Algorithm 1 gives an iterative method to find its generating function G(x).

    Algorithm 1 Calculating the generating function G(x) of factor F which only consists of asingle clique of points with no classes

    p← number of points in FG(x) ← xi ← 0while i < p − 1 do

    G(x) ← x ·(

    ddx x · G(x)

    )i ← i + 1

    end whilereturn G(x)

    For p points this will return G(x) = p! · xp which is correct, as we are arranging p pointsin every possible way, so the coefficient ap = p! and all other coefficients are 0. We cando something very similar if we have a factor with p ≥ 1 points and a class A, with thegenerating function A(x), as can be seen in Algorithm 2.

    Algorithm 2 Calculating the generating function G(x) of factor F which only consists of asingle clique with exactly one class

    p← number of points in FG(x) ← A(x), where A is the only class in F and A(x) is its generating functioni ← 0while i < p do

    G(x) ← x ·(

    ddx x · G(x)

    )i ← i + 1

    end whilereturn G(x)

    Now we have discussed some automatic methods for finding generating functions forfactors but how do we find them if there are for example two classes interleaving?

  • 14 CHAPTER 3. STRUCT COVERS

    3.2.4 Hadamard ProductThe Hadamard product, also called the termwise product, of two power series, A(x) =∑

    n≥0 anxn and B(x) =∑

    n≥0 bnxn, is defined as

    A(x)~ B(x) =∑n≥0

    anbnxn.

    One of our advisors, Jay Pantone, described a way to use the Hadamard product toautomatically find a generating function for a factor F if all of its simple cycles are containedin a clique.

    However finding the Hadamard product of two generating functions has not been imple-mented in Python or Sage and as we found out it is not an easy task. It has, however, beenimplemented in Maple in the gfun package developed by Salvy and Zimmermann 1992.

    3.2.5 Unique FactorsTrying to find ways to semi automatically find generating functions, we decided to find outhow many unique factors there were in our database, down to symmetry. In total, we foundthere were 21 425 non-trivial factors that we could not process automatically. However,when only considering the smallest symmetry of each class in the factors, and only countinga single symmetry of each of those factors, there were only 29 different factors. When takendown to isomorphism of the underlying graph as described in Chapter 2, there were only25 different factors. Since there were so few non-trivial factors with different enumerations,we could calculate the generating function for each one by hand, with help from ChristianBean, and store the generating functions in a database. This allowed us to find a generatingfunction for all of the Struct covers using Theorem 2.

    There are certain disadvantages to this method. If we get new covers that have a non-trivial factor we have not seen before, we can not apply automatic methods, until we havecalculated the generating function of the factor by hand and inserted into our database ofknown factors.

  • 15

    Chapter 4

    ATRAP Trees

    Like Struct, ATRAP seeks to find combinatorial structures for permutation classes. However,it does so in a different way. While Struct covers are conjectures that need to be verified byother means, ATRAP trees are both structural descriptions of classes and proofs of their owncorrectness. These trees are much more complicated than the simple Struct covers. Firstly,they are trees and not just a list of tilings, but within the trees, the relations between nodescan also be of many types. ATRAP knows many different strategies to derive the trees and allthose strategies interact differently with the nodes. In this chapter, we will shortly describeATRAP trees and their characteristics, and how we could or could not calculate generatingfunctions from these trees.

    4.1 ATRAP Trees and RecursionAs stated above, ATRAP produces proof trees. In these proof trees, the root node is a simple1 × 1 tiling whose only block is the class for which we wish to deduce a tree. ATRAP thenrepeatedly splits the nodes of the tree into children nodes, where each permutation in theparent node is described by the tiling in exactly one child node. This is done through variousstrategies described by Bean, Gudmundsson, and Ulfarsson 2017. The algorithm stops whenall the leaf nodes are simple enough to be a verifiable cover. Sometimes, however, a part ofa node might actually be identical to another node. In this case, the node is split into nodesthat contain subtilings, called components, of the tiling in the parent node and tries to verifythe correctness of the parent tiling. This is done either by verifying that components arevery simple, or calling on the older node and stating its similarity. This latter way is calledrecursion, since the generating function of the leaf node depends on the generating functionof an internal, older node. It is those recursions that pose a problem since in their absencethe leaf nodes of ATRAP trees do not form a natural cover.

    4.2 Generating FunctionsFor the simple case of trees with no recursing nodes, it is simple to treat covers obtainedfrom the leaves of the tree as a Struct cover and calculate both recurrence relations andgenerating functions as stated in Chapter 3.

    If however there is recursion in the tree we would need to use other methods. A simplecase of recursions is when the part of a leaf that recurses is not dependent on any other partof the node.

  • 16 CHAPTER 4. ATRAP TREES

    (a) A simple tree with no recursion

    (b) A tree with simple recursion

    Figure 4.1: Example trees for Av(132)

    Example 10. The tree in Figure 4.1a has no recursion. We could say that the A classes inthe right child recursed back to the root node but those are too trivial to be problematic sincethey have exactly the same attributes as similar cases in Struct covers. By taking only theleaf nodes, we get a very simple cover that might as well have been generated by Struct.The tree in Figure 4.1b, however, is much more complicated. The last three leaves arecomponents of the tiling in the parent node that each needed to be checked for recursions.The rightmost leaf node is identical to the second child of the root node and can, therefore,recurse back to it. The other components are simple enough to be verified by themselves.Also, all the components are independent (no block shares a row or column with a block fromanother component) and can, therefore, be treated as factors. In order to find the generatingfunction for this tree we first look at the whole tree, that is to say, we set up a functionalequation for the generating function A(x) of the root node R. We will also want to know thegenerating function A′(x) for the internal node that is recursed to, R′. To do this we set up afunctional equation for A′(x) as well and then solve the system of equations we have defined.

  • 4.3. BASES FROM BOTH S3 AND S4 17

    The leaves from left to right have the generating functions: 1, xA(x), A(x), x and A′(x).Since the three rightmost leaves can be treated as factors of their parent the parent node thenhas the generating function xA(x)A′(x). Now, for the subtree rooted at R′, the children of R′form a cover so A′(x) = xA(x) + xA(x)A′(x). A cover for the whole tree can then be writtenas A(x) = 1 + xA(x) + xA(x)A′(x). We can now solve the system of equations

    A(x) = 1 + xA(x) + xA(x)A′(x),A′(x) = xA(x) + xA(x)A′(x)

    and get

    A(x) =√

    1 − 4x + 12x

    ,

    A′(x) =√

    1 − 4x + 1 − 2x2x

    which is in accordance with the results from Example 9.

    Although the procedure used in Example 10 may seem simple enough, if the recursingcomponents were not independent of the rest of the tiling we do not as of yet know how tocalculate generating functions for the tiling. Those dependent components and the fact thatATRAP is still in development lead us to leave automated calculations of generating functionsof recursing trees as future work.

    4.3 Bases from both S3 and S4Both Struct and ATRAP seek to represent permutation classes as tilings of simpler classes.Those simpler classes often have bases with permutations of both lengths 3 and 4. In order tofinalize the enumerations of the bases from S4, we need to know the enumerations of thoseclasses as well. We, therefore, wish to look at the set

    β0 = {X ∪ Y | X ⊆ S3 and Y ⊆ S4 and |X | ≥ 1 and |Y | ≥ 1} . (4.1)

    We already know that there are 23! − 1 = 26 − 1 = 63 non-empty subsets of S3 and24!−1 = 224−1 = 16 777 215 non-empty subsets ofS4. This means |β0 | = 63 ·16 777 215 =1 056 964 545. That’s over a billion bases and enumerating all of them would take a longtime. Much longer than needed.

    Taking a closer look at the properties of those bases, we see that, for example, the basis{123, 1234, 1423} contains both 123 and 1234. However, any permutation that contains1234 must also contain 123, and any permutation that avoids 123 must avoid 1234. It istherefore sufficient to look at the basis {123, 1423} since Av({123, 1423}) will have all thesame permutations as Av({123, 1234, 1423}). This holds as a general rule. Any permutationin a basis that contains another permutation in the same basis is redundant. Therefore, wecan refine β0 to

    β1 = {X ∪ Y | X ⊆ S3 and Y ⊆ Av(X)4 and |X | ≥ 1 and |Y | ≥ 1} . (4.2)

    A small program to count these shows that we have drastically reduced the number of basesto |β1 | = 101, 768.

  • 18 CHAPTER 4. ATRAP TREES

    Further analysis shows that permutation classes with symmetric bases have the sameenumerations. By symmetric bases, we mean that two bases B and B′ are symmetric if wecan rotate and mirror each permutation in B in the same way to obtain B′ and vice versa. Anypermutation that contains a permutation in B can be rotated and mirrored in the same wayand will then contain a permutation in B′. Therefore the avoidance classes of two symmetricbases are symmetric in the same way and thereby have the same enumeration. This showsthat it is sufficient to enumerate a single symmetry of each basis in β1 to have enumerated allof them. Recall that we defined an ordering of permutations and bases in Chapter 2. In orderto find a single symmetry of each basis, we generate all symmetries and take the smallestone. After eliminating redundant symmetries we have the set β of size 14 181. This is amuch more feasible set of bases to enumerate.

    4.3.1 Wilf-ClassesAs stated above, in order to be able to finish the enumeration of the original S4 bases, wewould need the recurrence relations and generating functions for the classes with bases in β.We, therefore, ran ATRAP on the bases in β and attempted to calculate their enumerations.Most of the bases were well behaved and their trees had no recursions. Above, we mentionedthat in this case we can simply take the leaves and create a cover from them. Of the14 181 classes, 13 833 had no recursions. After processing them we could group entries bygenerating functions to a total of 922 Wilf-Classes. We list the 10 largest Wilf-Classes inTable 4.1. Note that these numbers are not final since we were unable to produce generatingfunctions for the classes that had trees with recursing nodes.

    Generating Function Enumeration # of classes

    5x4 + 5x3 + 2x2 + x + 1 {1, 1, 2, 5, 5, 0, 0, . . . } 302

    4x4 + 5x3 + 2x2 + x + 1 {1, 1, 2, 5, 4, 0, 0, . . . } 279−x5+2x3+x2−x+1

    x2−2x+1 {1, 1, 2, 5, 8, 10, 12, . . . } 254

    x5 + 5x4 + 5x3 + 2x2 + x + 1 {1, 1, 2, 5, 5, 1, 0, . . . } 246

    −2x4+3x3+x2+1x−1 {1, 1, 2, 5, 7, 7, 7, . . . } 237x5−x4−3x3−x2−1

    x−1 {1, 1, 2, 5, 6, 5, 5, . . . } 234

    x5 + 6x4 + 5x3 + 2x2 + x + 1 {1, 1, 2, 5, 6, 1, 0, . . . } 219

    6x4 + 5x3 + 2x2 + x + 1 {1, 1, 2, 5, 6, 0, 0, . . . } 211

    2x5 + 6x4 + 5x3 + 2x2 + x + 1 {1, 1, 2, 5, 6, 2, 0, . . . } 2052x5−3x3−x2−1

    x−1 {1, 1, 2, 5, 5, 3, 3, . . . } 203

    Table 4.1: The 10 largest Wilf classes for bases in β

    4.3.2 Finite classesWe thought it would also be interesting to know how many of these permutation classes arefinite. Table 4.2 shows for each k, how many classes contain no permutation of length k but

  • 4.3. BASES FROM BOTH S3 AND S4 19

    contain at least 1 permutation of length k − 1. There are a total of 4 809 finite classes withbases from β, which is just over one third. It is worthwhile to mention that finite classes withthe same k are not necessarily Wilf-equivalent.

    k # of classes4 175 13026 23387 9598 193

    Table 4.2: Finite permutation classes

  • 20

  • 21

    Chapter 5

    PermPAL

    The PermPALwebsite exhibits the vast amount of data contained in our database to people allover the world. This is an important part of the project as without a proper interface to the datait is useless to everyone but us. The website can be accessed at http://permpal.ru.is.

    5.1 Viewing an entryWhen viewing an entry the following properties are shown if applicable.

    • Conjectured Struct cover

    • ATRAP tree (only shown when an ATRAP tree for the class is available)

    • Permutation examples

    • Recurrence relation

    • Functional equation for the generating function

    • Solved generating function

    • Coefficients (first few terms of the enumeration)

    Since classes with symmetric bases have the same enumeration, and both symmetric Structcovers and ATRAP trees, we only store the class that has the smallest symmetric basis.

    5.1.1 StatisticsThe statistics page http://permpal.ru.is/perms/stats shows a few statistics on thedatabase. Length statistics show how many bases of each length, where the length of abasis is the number of permutation in said basis, are present in the database. The countand percentage of all entries are shown for each base length giving you an idea how theentries are distributed in length. Rank statistics show how many classes of each rank are inthe database. Dependency statistics shows the top 100 referenced bases. This analyzes thedepends column of each entry in the database and counts howmany times each class appears.

    http://permpal.ru.ishttp://permpal.ru.ishttp://permpal.ru.ishttp://permpal.ru.is/perms/stats

  • 22 CHAPTER 5. PERMPAL

    5.1.2 Drawing ATRAP treesAs the development of the ATRAP algorithm continued the need to be able to draw trees onthe website, without having to go through the database became apparent. Drawing large treesby hand is time-consuming and tedious so an automatic method proved helpful. We createda subpage http://permpal.ru.is/perms/draw which allows users to submit an ATRAPtree in the computer readable JSON form which can be obtained from running the ATRAPalgorithm.

    This JSON data is parsed and sent to a view which renders a tree. To do this, we use theTreant.js library in the samemanner as the page that displays an entry. This allows developersto quickly see the results of an ATRAP run in a very visual way. We place tooltips on everynode of the tree which display information on why the node was created and whether it isrelated to other nodes through tree recursion.

    5.2 SearchingThe best way to navigate the website is through the search page http://permpal.ru.is/perms/searchwhere you can put in a wide variety of parameters to gather the exact patternsyou require. Once you’ve found a pattern you want to know more about you simply go to theentry’s page. The parameters you can search by are the following:

    Exact searchMatches permutation classes which have the exact permutations you entered ex. 123,321 gives you only the page for Av(123, 321). We take the smallest symmetry of theinputs to exact matches, since those are the only entries in the database.

    Include permutationsThis will give you all permutation classes whose basis includes the permutations youenter ex. 123, 132 gives [Av(123, 132),Av(123, 132, 213),Av(123, 132, 213, 231), . . .].

    Exclude permutationsHere you can exclude bases that contain certain permutations. This is mostly usefulalong with other search parameters.

    CoefficientsSearching by coefficients is inspired by the OEIS website and offers wild cards aswell as searching any part of the coefficients, not just the beginning. In Figure 5.1we include some examples of coefficient searches and results. Note that on the searchpage all permutations which match the conditions are shown, not just one.

    Coefficient query Example permutation class Coefficients1, 1, 1, 1, 1, 1, 1 Av(123, 132, 213, 231, 312) 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 11, 2, 3 Av(123, 132, 213) 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 899, 8, _, 6 Av(132, 1234, 2341, 3214, 3421, 4213) 1, 1, 2, 5, 9, 8, 7, 6, 6, 6, 6

    Figure 5.1: Some examples of results from coefficient search queries.

    RanksYou can define the rank of the permutation class. This is useful for finding classeswhich have a complex structure.

    HTTP://PERMPAL.RU.IShttp://permpal.ru.is/perms/drawhttp://permpal.ru.is/perms/searchhttp://permpal.ru.is/perms/searchhttp://www.oeis.org

  • 5.3. TECHNICAL DETAILS 23

    Length of basisThis property specifies how many permutations are contained in the basis of the classex. Av(123, 132) has basis length 2.

    Length of patterns in basisThis property specifies the length of permutations in the basis. Searching for 3, 4 willgive you all classes which have only permutations of length 3 or 4 ex. Av(123, 2143)has basis pattern lengths 3, 4.

    DownloadWhen this option is selected instead of displaying the search results the whole result setis collected into a file and sent along with the query that was executed on the database.This was requested by Ulfarsson for his own analysis.

    ATRAP treesThis option allows you to filter out any classes which do not have an ATRAP treeassociated with them in the database.

    All of these options can be combined so filtering out what you want should be no problem.

    5.3 Technical detailsThe server is implemented with the Flask Python framework. We chose Flask because itis very simple, fast, heavily documented, well maintained and implemented in the samelanguage as all of the ATRAP/Struct code. This will help simplify modifications of thewebsite in the future for students working on the project.

    Flask depends on Jinja2 and recommends using it for HTML templating as well. Seeingthat Jinja2 provides all the functionality we needed, such as partial HTML files and viewlogic using Python like syntax, we saw no reason not to use it. The website is styled with theBootstrap front-end framework which provides simple classes to make the site look like it isfrom this decade.

    We use two JavaScript packages, MathJax and Treant.js. Treant.js provides us with asimple API to highly customizable trees using JSON data. MathJax lets us render LATEXequations to aesthetically represent tilings, recurrence relations, generating functions andother mathematics on the web page.

    5.4 DatabaseWe chose MongoDB to store all our data. There are several pros to using MongoDB overtraditional SQL relational databases and other NoSQL databases. We chose MongoDB overother NoSQL solutions since we had experience with it and it has been around for longenough that we were confident in the features and tools available.

    Schema-lessWe didn’t want to have a pre-defined schema since we knew the columns would changeover the course of the project. The log format we received for ATRAP trees was a workin progress so there were many small and big changes and specifying the tables for arelational database would have been a large amount of repeated work.

  • 24 CHAPTER 5. PERMPAL

    Ease of useThe documentation for MongoDB is great and the community is big. We lookedaround and found the Python package PyMongo which allows us to query the databaseusing Python objects and methods.

    NoSQLWe don’t have a lot of data types that interact with each other, there is really onlyone data type which stores everything for a certain entry. All the data for an entry isobtained from the log and calculations on the data. We felt that a NoSQL solutionwould be a good choice here.

    Object basedThe document storage is highly compatible with Python since Python isn’t staticallytyped and therefore we don’t need to change much in our code when working with newversions of documents obtained from MongoDB.

    FastMongoDB is very fast in our use case since we would have needed a lot of joinscollecting data from different tables every time someone requested an entry had wechosen a SQL database. Instead, we return the document for an entry and almosteverything we need is already calculated and ready to display.

    Array methodsMongoDB supplies methods to work with arrays of documents. This was crucial forimplementing coefficient search on the entries.

    5.4.1 Columns of an entryIn the end, we decided on a somewhat final structure for the database entries. These are thecolumns for every entry in alphabetical order

    avoidStores a string representing the avoiding class ex. "123_213_1432_2431_4132".

    avoid_arrStores the permutations for the basis in an array of strings ex. ["123", "213","1432", "2431", "4132"].

    basis_lengthStores the lengths of permutations in the basis in an array of numbers ex. "123_213_1432_2431_4132" has basis_length [3,4].

    coeffsStores the first few coefficients of the entry an array of numbers ex. "123_213_1432_2431_4132" has coeffs [1, 1, 2, 4, 5, 8, 13, 21, 34, 55, 89].

    depends and revdependsStores the information necessary for the legend of the trees and tables. It is a mappingfrom permutation classes to letters and the other way around.

    examplesStores examples of permutations which are in the class, typically only of small sizes.

    HTTP://PERMPAL.RU.IS

  • 5.4. DATABASE 25

    genfStores the generating function for the entry in a LATEX equation.

    lengthStores the length of the basis as a number ex. "123_213_1432_2431_4132" haslength 5.

    rankStores the rank of the entry as a number ex. "123_213_1432_2431_4132" has rank2.

    recurrenceStores the recurrence relation for an entry. It is a dictionary with the keys being the nin cn and the value being either a LATEX equation or a number depending on whetherthe class references another class.

    solved_genfStores the solved generating function for the entry in a LATEX equation.

    sympy_genfStores the a generating function in the format that Sympy uses ex. "(x**5 + x**4- x**3 - 1)/(x**2 + x - 1)".

    tileStores the Struct cover for a class if it exists. It is an array of arrays representing aStruct tiling. Each object in the inner tiling has coordinates and a value.

    treeStores an ATRAP tree for a class. This is not present on many entries since not allclasses have been tested on the ATRAP algorithm.

    verifiedStores a boolean telling us whether verification of the enumerations given by thegenerating function and recurrence relation was successful.

  • 26

  • 27

    Chapter 6

    Conclusion

    We have shown that it is indeed possible to automatically conjecture enumerations of per-mutation classes through Struct and recurrence relations calculated as shown in Section3.1. For many classes, it is even possible to automatically calculate generating functionsfrom Struct covers as shown in Section 3.2. We were successful in finding generatingfunctions and recurrence relations for all logs available from the Struct algorithm. That isover 150 000 classes. With our work on bases from β as mentioned in Section 4.3 we alsoshowed that for many classes it is possible to automatically prove enumerations of classeswith ATRAP and generating functions as described in Section 4.2.

    For enumerations from Struct covers, Struct itself is a bottleneck, as it can notconjecture covers for all classes, as well as the calculation of generating functions for non-trivial factors. For ATRAP it is obvious that work on recursing nodes is needed. As ATRAP isdeveloped further we are sure that this will be done.

    All our calculated data is accessible on the PermPAL website. From there the databasecan be queried in an intuitive but powerful way and the results are displayed in a clear visualmanner. The website is live and will be updated in the future. Features to the website as wellas more data on more classes can be added. From our data, we have partially Wilf-classifiedthe bases from β but as more classes are successfully enumerated this classification shouldbe gathered and their permutation classes linked on the website.

    Below is a short list of ideas for future work on PermPAL.

    • Add a feature to PermPAL so that users can request information on a certain basis.

    • Allow the submission of new Struct or ATRAP logs for the server to process anddisplay.

    • Calculate more coefficients on demand. Currently, we only calculate up to a certainfixed length.

    • Implement the Hadamard product in Python. This would possibly enable us to fullyautomate the calculation of generating functions.

    • Calculate generating functions for ATRAP trees with complex recursion.

    • Categorize classes by their Wilf-Classification on PermPAL and continue the classifi-cation of new ATRAP trees.

    We hope that PermPAL will be of use to those working with permutation classes and thatwe, or others, will be able to maintain and update the website in order to keep it relevant.

    http://permpal.ru.ishttp://permpal.ru.ishttp://permpal.ru.ishttp://permpal.ru.ishttp://permpal.ru.is

  • 28

  • 29

    Bibliography

    Bean, Christian, Bjarki Gudmundsson, and Henning Ulfarsson (2017). Algorithmic Enumer-ation of Permutation Classes. eprint: arXiv:1705.04109.

    Flajolet, Philippe and Robert Sedgewick (2009). Analytic Combinatorics. Cambridge Uni-versity Press, pp. 24–27.

    Knuth, Donald E. (1968). The Art of Computer Programming, Vol. 1: Fundamental Algo-rithms. Redwood City, CA, USA: Addison Wesley Longman Publishing Co., Inc.

    Salvy, Bruno and Paul Zimmermann (1992). GFUN : a maple package for the manipulationof generating and holonomic functions in one variable. Research Report. INRIA. 14 pp.

    Vatter, Vincent (2011). “Small permutation classes”. In: Proc. Lond. Math. Soc. (3) 103.5,pp. 879–921.

    arXiv:1705.04109

  • 30

  • School of Computer ScienceReykjavík UniversityMenntavegur 1101 Reykjavík, IcelandTel. +354 599 6200Fax +354 599 6201www.ru.is

    www.ru.is

    AcknowledgementsContentsList of FiguresList of TablesIntroductionBackground

    PermutationsPermutations and Their ClassesTilings

    Struct CoversStruct Cover to Recurrence RelationThe Intitial ConditionRecursive stepThe Special Case of Points

    Struct Cover to Generating FunctionCombinatorial StructuresFactorsAutomatic Generating Functions for FactorsHadamard ProductUnique Factors

    ATRAP TreesATRAP Trees and RecursionGenerating FunctionsBases from both S3 and S4Wilf-ClassesFinite classes

    PermPALViewing an entryStatisticsDrawing ATRAP trees

    SearchingTechnical detailsDatabaseColumns of an entry

    ConclusionBibliography