1 | """ |
---|

2 | sage: P = ShiftedPrimedTableau([[1,2,3,6,7],[4,5]]) |
---|

3 | sage: Q = ShiftedPrimedTableau([[1,2,3,"4p","6p"],[5,"7p"]]) |
---|

4 | sage: labels = Q.to_chain() + [mu if is_even(i) else 0 for i, mu in enumerate(P.to_chain()[::-1])][1:] |
---|

5 | sage: G = Shifted(shape=[7]*7, labels=labels) |
---|

6 | sage: G.to_word() |
---|

7 | [5, 6, 7, 2, 4, 1, 3] |
---|

8 | """ |
---|

9 | def word_to_standard(w): |
---|

10 | """Convert a word with primed entries to a permutation. |
---|

11 | |
---|

12 | The alphabet is ordered as |
---|

13 | `X' = \{1' < 1 < 2' < 2 < \cdots < n' < n\}` |
---|

14 | |
---|

15 | The word is processed beginning with the smallest entry, primed |
---|

16 | entries are standardised from right to left, unprimed from left |
---|

17 | to right. |
---|

18 | |
---|

19 | EXAMPLES:: |
---|

20 | |
---|

21 | sage: w = ["2'","3'",3,1,"2'","1'",1] |
---|

22 | sage: w = [PrimedEntry(l) for l in w]; w |
---|

23 | |
---|

24 | sage: word_to_standard(w) |
---|

25 | ([5, 6, 7, 2, 4, 1, 3], [1, 1, 1, 2, 2, 3, 3], [2, 3]) |
---|

26 | |
---|

27 | Sagan, just before Lemma 9.2: |
---|

28 | |
---|

29 | sage: w = [1, 1, "2p", "1p", "2p", 2, 2, "3p", "1p", "2p"] |
---|

30 | sage: w = [PrimedEntry(l) for l in w]; w |
---|

31 | [1, 1, 2', 1', 2', 2, 2, 3', 1', 2'] |
---|

32 | sage: word_to_standard(w) |
---|

33 | ([3, 4, 7, 2, 6, 8, 9, 10, 1, 5], [1, 1, 1, 1, 2, 2, 2, 2, 2, 3], [2, 3]) |
---|

34 | """ |
---|

35 | n = len(w) |
---|

36 | k = 1 |
---|

37 | p = [None]*n # the standardised word |
---|

38 | c = sorted([l.integer() for l in w]) # the content |
---|

39 | s = [] # special entries, leftmost occurrence primed |
---|

40 | A = sorted(set(c)) # letters occurring |
---|

41 | for l in A: |
---|

42 | e = PrimedEntry(l).primed() |
---|

43 | for i in range(len(w)): |
---|

44 | if w[n-i-1] == e: |
---|

45 | leftmost = n-i-1 |
---|

46 | p[n-i-1] = k |
---|

47 | k += 1 |
---|

48 | e = e.unprimed() |
---|

49 | for i in range(len(w)): |
---|

50 | if w[i] == e: |
---|

51 | if i < leftmost: |
---|

52 | leftmost = None |
---|

53 | p[i] = k |
---|

54 | k += 1 |
---|

55 | if leftmost is not None: |
---|

56 | s.append(l) |
---|

57 | return (p, c, s) |
---|