Pattern Matching for Permutations St´ ephane Vialette 2 CNRS & LIGM, Universit´ e Paris-Est Marne-la-Vall´ ee, France Permutation Pattern 2013, Paris Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 1 / 69
Outline 1 The general problem 2 A few restricted permutations 3 Small patterns 4 A focus on separable permutations 5 Consecutive occurrences 6 Some open problems Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 2 / 69
Pattern matching for permutations Pattern containment / involvement / avoidance A permutation π is said to contain another permutation σ , in symbols σ � π , if there exists a subsequence of entries of π that has the same relative order as σ , and in this case σ is said to be a pattern of π . Otherwise, π is said to avoid the permutation σ . Example A permutation contains the pattern 123 (resp. 321) if it has an increasing (resp. decreasing) subsequence of length 3. Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 3 / 69
Pattern matching for permutations Two (deliberately vague) problems we are interested in Pattern matching Given two permutations π and σ (we may have constraints on π and/or σ ), how fast can we decide whether σ is involved in π ? Common pattern Given a collection Π = ( π 1 , π 2 , . . . , π n ) of n permutations (we may have constraints on π 1 , π 2 , . . . , π n ) and a “constraint” C , find the largest permutation σ that satisfies C and that is involved in every permutation in Π. We may be interested in returning only the size of the largest common permutation. Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 4 / 69
Pattern matching for permutations Theorem ( [Bose, Buss, Lubiw 98] ) For two permutations π and σ , deciding whether σ � π is NP -complete. Remarks The problem is ascribed to H. Wilf in [Bose, Buss, Lubiw 98] . Reduction from 3 -Satisfiability . Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 5 / 69
Matching diagrams Definition A matching diagram is a graph G such that V ( G ) is equipped with a total order and E ( G ) is a perfect matching. Restricted matching diagrams A matching diagram G is said to be precedence-free if there do not exist edges ( i , j ) and ( k , ℓ ) in G such that i < j < k < ℓ or k < ℓ < i < j . A matching diagram G is said to be crossing-free if there do not exist edges ( i , j ) and ( k , ℓ ) in G such that i < k < j < ℓ or k < i < ℓ < j . A matching diagram G is said to be inclusion-free if there do not exist edges ( i , j ) and ( k , ℓ ) in G such that i < k < ℓ < j or k < i < j < ℓ . Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 6 / 69
Pattern matching for separable patterns Matching diagram Theorem ( [Folklore] ) Precedence-free matching diagrams of size 2 n are in one-to-one correspondence with permutations of length n Remarks The vertices of G which are left endpoints of edges are labeled { 1 , 2 , . . . , n } . The vertices of G which are right endpoints of edges are labeled { n + 1 , n + 2 , . . . , 2 n } . The permutation π corresponding to G is defined by π ( j − n ) = i if and only if ( i , j ) ∈ E ( G ). Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 7 / 69
Pattern matching for separable patterns Matching diagram Examples Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 8 / 69
Pattern matching for permutations Proving hardness of pattern involvement using matching diagrams [V. 04] Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 9 / 69
Pattern matching for permutations But I really need to answer my “ does σ occur in π ? ” question ! Sage ( combinat/permutation.py ) def has_pattern(self, patt): r""" Returns the boolean answering the question ’Is patt a pattern appearing in permutation p?’ EXAMPLES:: sage: Permutation([3,5,1,4,6,2]).has_pattern([1,3,2]) True """ p = self n = len(p) l = len(patt) if l > n: return False for pos in subword.Subwords(range(n),l): if to_standard(map( lambda z: p[z] , pos)) == patt: return True return False Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 10 / 69
Pattern matching for permutations General upper bound Theorem ( [Ahal, Rabinovich 08] ) Let π ∈ S n and σ ∈ S m . One can decide whether σ is involved in π in O ( n 0 . 47 m + o ( m ) ) time. Remarks The authors introduce two naturally defined (related) permutation complexity measures C ( π ) and a somewhat finer C T ( π ). They show that the algorithms run in time O ( n 1+ C ( σ ) ) and O ( n 2 C T ( σ ) ). In the general case, C ( σ ) ≤ 0 . 47 k + o ( m ). Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 11 / 69
Pattern matching for permutations Fixed-parameter approach Theorem ( [Bruner, Lackner 12] ) Let π ∈ S n and σ ∈ S m . One can decide whether σ is involved in π in O (1 . 79 run( π ) ) or O ∗ (( n 2 / 2 run( σ )) run( σ ) ) time. Remarks Ahal and Rabinovich’s O ( n 0 . 47 m + o ( m ) ) time algorithm is O ( n 1+run( σ ) ) time. Deciding whether σ is involved in π is W[1] -hard w.r.t. the parameter run( σ ). Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 12 / 69
Alternating permutations Definition (Alternating permutations) A permutation π = π 1 π 2 . . . π n ∈ S n is alternating if π 1 > π 2 < π 3 > . . . , and reverse alternating if π 1 < π 2 > π 3 < . . . . Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 13 / 69
Alternating permutations Theorem ( [Rizzi, V. 2013] ) Deciding whether σ is involved in π is NP -complete even if both π and σ are alternating. Proof (Key idea). Let π ∈ S n and σ ∈ S m . Define π ′ = (2 n + 1) π 1 (2 n ) π 2 . . . ( n + 2) π k ( n + 1) σ ′ = (2 m + 1) σ 1 (2 km ) σ 2 . . . ( m + 2) σ m ( m + 1) Claim: σ is involved in π if and only if σ ′ is involved in π ′ . Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 14 / 69
Finding a largest common permutations Theorem ( [Bose, Buss, Lubiw 98] ) Given a collection Π = ( π 1 , π 2 , . . . , π n ) of n permutations and a positive integer m, deciding whether there exists a permutation σ ∈ S m that is involved in every permutation in Π is NP -complete. Remarks The problem is at least as hard as deciding whether a given permutation σ is involved in another given permutation π . The problem is NP -complete for n ≥ 2. This naturally reduces to an optimization problem. Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 15 / 69
Finding a largest common permutations Definition Let G be a precedence-free matching diagram. A tower is a set of pairwise nested edges. The height of G is defined to be the size of the maximum cardinality tower in G . A staircase is a set of pairwise crossing edges. The depth of G is defined to be the size of the maximum cardinality staircase in G . The matching diagram G is called a tower of staircases if any two maximal staircases do not share an edge (it is furthermore called balanced if all its maximal staircases are of equal cardinality), a staircase of towers if any two maximal towers do not share an edge (it is furthermore called balanced if all its maximal towers are of equal cardinality) Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 16 / 69
Finding a largest common permutations Theorem ( [Fertin, Hermelin, Rizzi, V. 10] ) Let G 1 , G 2 , . . . , G n be a collection of towers of staircases of depth at most 2 , and ℓ be a positive integers. Deciding whether there exists a matching diagram of size ℓ that occurs in every tower of staircases G i , 1 ≤ i ≤ n, is NP -complete. Example 1 2 3 4 5 6 7 7 5 6 3 4 2 1 Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 17 / 69
Finding a largest common permutations Theorem ( [Fertin, Hermelin, Rizzi, V. 10] ) Let π = ( π 1 , π 2 , . . . , π n ) be a collection of permutations of size at most m. The problem of computing the largest permutation that is involved in every permutation in Π is approximable within ratio √ opt in O ( nm 1 . 5 ) time, where opt is the size of an optimal solution. This is the limit of our approach . . . Lemma ( [Fertin, Hermelin, Rizzi, V. 10] ) For every collection Π ⊆ S n , n ∈ N and | Π | ≤ 2 n , there exists σ ∈ S K , K = Ω( k 2 ) , which avoids all permutations in Π . Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 18 / 69
A quick parenthesis Theorem ( [Fertin, Hermelin, Rizzi, V. 10] ) Let G = ( G 1 , G 2 , . . . , G n ) be a collection of linear graphs of maximum size m. There exists an algorithm with approximation ratio O ( √ opt log opt ) that runs in O ( nm 3 . 5 log m ) time and returns a linear graph that occurs in every linear graph in G , where opt is the size of an optimal solution Remarks Precedence-free matching diagrams remains the bottleneck. Any matching diagram of size n contains either a precedence-free matching diagram, an inclusion-free matching diagram, or a √ 17 − 1 n 2 / 3 . crossing-free matching diagram of size 8 Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 19 / 69
Outline 1 The general problem 2 A few restricted permutations 3 Small patterns 4 A focus on separable permutations 5 Consecutive occurrences 6 Some open problems Vialette (LIGM – UPEMLV) Pattern Matching PP 2013 20 / 69
Recommend
More recommend