Lyndon and primitive words
DefinitionPrimitive word#✓fully proved
A nonempty finite word is primitive if it is not a proper power of another word.
def IsPrimitiveWord {α : Type*} (u : List α) : Prop :=
u ≠ [] ∧ ∀ (v : List α) (n : ℕ), List.flatten (List.replicate n v) = u → n = 1
DefinitionContent of a word#✓fully proved
Let \(r\) be a natural number. The content of a word \(w\) over the alphabet \(\{0, \dots, r-1\}\) is the function that assigns to each letter \(i\) the number of occurrences of \(i\) in \(w\).
Used by 11
DefinitionLyndon word#✓fully proved
Let \(\alpha\) be a linearly ordered alphabet, and order the words over \(\alpha\) lexicographically. A word \(w\) over \(\alpha\) of length \(n\) is a Lyndon word if it is nonempty and, for every \(k\) with \(0 < k < n\), \(w\) is strictly smaller than its rotation by \(k\), the word obtained by moving the first \(k\) letters of \(w\) to the end.
def IsLyndonWord {α : Type*} [LinearOrder α] (w : List α) : Prop :=
w ≠ [] ∧ ∀ k, 0 < k → k < w.length → w < w.rotate k
TheoremContent is additive under concatenation#✓fully proved
For a natural number \(r\), words \(u\) and \(v\) over the alphabet \(\{0, \dots, r-1\}\), and every letter \(i\), the number of occurrences of \(i\) in the concatenation \(uv\) is the number of occurrences of \(i\) in \(u\) plus the number of occurrences of \(i\) in \(v\).
@[simp]
theorem wittWordContent_append {r : ℕ} (u v : List (Fin r)) :
wittWordContent (u ++ v) = fun i => wittWordContent u i + wittWordContent v i
def wittWordContent {r : ℕ} (w : List (Fin r)) : Fin r → ℕ :=
fun i => w.count i
MathlibExt/Combinatorics/Words/LyndonWord.lean:34
Uses 1 · Used by 2
TheoremContent of a one-letter word#✓fully proved
Let \(r\) be a natural number. For every letter \(i\) of the alphabet \(\{0, \dots, r-1\}\), the content of the one-letter word \(i\) takes the value \(1\) at \(i\) and the value \(0\) at every other letter.
@[simp]
theorem wittWordContent_singleton {r : ℕ} (i : Fin r) :
wittWordContent [i] = Function.update (fun _ => 0) i 1
def wittWordContent {r : ℕ} (w : List (Fin r)) : Fin r → ℕ :=
fun i => w.count i
MathlibExt/Combinatorics/Words/LyndonWord.lean:34
Uses 1 · Used by 1
TheoremContent of a word after prepending a letter#✓fully proved
Let \(r\) be a natural number, let \(w\) be a word over the alphabet \(\{0, \dots, r-1\}\), let \(i\) be a letter, and write \(c(u)\) for the content of a word \(u\) (the number of occurrences of each letter in \(u\)). If \(iw\) denotes \(w\) with \(i\) prepended, then \(c(iw)(i) = c(w)(i) + 1\) and \(c(iw)(j) = c(w)(j)\) for every letter \(j \ne i\).
@[simp]
theorem wittWordContent_cons {r : ℕ} (i : Fin r) (w : List (Fin r)) :
wittWordContent (i :: w) =
Function.update (wittWordContent w) i (wittWordContent w i + 1)
def wittWordContent {r : ℕ} (w : List (Fin r)) : Fin r → ℕ :=
fun i => w.count i
MathlibExt/Combinatorics/Words/LyndonWord.lean:34
Uses 1 · Used by 1
TheoremThe content of a word sums to its length#✓fully proved
For a natural number \(r\) and a word \(w\) over the alphabet \(\{0, \dots, r-1\}\), summing over all letters \(i\) the number of occurrences of \(i\) in \(w\) gives the length of \(w\).
@[simp]
theorem sum_wittWordContent {r : ℕ} (w : List (Fin r)) :
(∑ i, wittWordContent w i) = w.length
def wittWordContent {r : ℕ} (w : List (Fin r)) : Fin r → ℕ :=
fun i => w.count i
MathlibExt/Combinatorics/Words/LyndonWord.lean:34
Uses 1 · Used by 4
DefinitionWords with prescribed content#✓fully proved
Let \(r\) be a natural number. Given a function \(d\) from the alphabet \(\{0, \dots, r-1\}\) to the natural numbers, the words of content \(d\) are the words \(w\) over this alphabet whose content equals \(d\), that is, in which each letter \(i\) occurs exactly \(d(i)\) times.
def WordsOfContent {r : ℕ} (degree : Fin r → ℕ) :=
{w : List (Fin r) // wittWordContent w = degree}
def wittWordContent {r : ℕ} (w : List (Fin r)) : Fin r → ℕ :=
fun i => w.count i
MathlibExt/Combinatorics/Words/LyndonWord.lean:34
Uses 1 · Used by 6
DefinitionLyndon words of given content#✓fully proved
For a natural number \(r\) and natural numbers \(n_0, \dots, n_{r-1}\), the set of Lyndon words over the alphabet \(\{0, \dots, r-1\}\), ordered as the natural numbers, in which each letter \(i\) occurs exactly \(n_i\) times.
def LyndonWordsOfContent {r : ℕ} (degree : Fin r → ℕ) :=
{w : WordsOfContent degree // IsLyndonWord w.1}
def WordsOfContent {r : ℕ} (degree : Fin r → ℕ) :=
{w : List (Fin r) // wittWordContent w = degree}
MathlibExt/Combinatorics/Words/LyndonWord.lean:81
def IsLyndonWord {α : Type*} [LinearOrder α] (w : List α) : Prop :=
w ≠ [] ∧ ∀ k, 0 < k → k < w.length → w < w.rotate k
MathlibExt/Combinatorics/Words/LyndonWord.lean:38
Uses 3 · Used by 2
TheoremWords of given content are counted by the multinomial coefficient#✓fully proved
Let \(r\) be a natural number, let \(n_0, \dots, n_{r-1}\) be natural numbers, and let \(n = n_0 + \dots + n_{r-1}\). The number of words over the alphabet \(\{0, \dots, r-1\}\) in which each letter \(i\) occurs exactly \(n_i\) times is the multinomial coefficient \(\binom{n}{n_0, \ldots, n_{r-1}} = \frac{n!}{n_0! \cdots n_{r-1}!}\).
theorem card_wordsOfContent_eq_multinomial {r : ℕ} (degree : Fin r → ℕ) :
Fintype.card (WordsOfContent degree) = Nat.multinomial Finset.univ degree
def WordsOfContent {r : ℕ} (degree : Fin r → ℕ) :=
{w : List (Fin r) // wittWordContent w = degree}
MathlibExt/Combinatorics/Words/LyndonWord.lean:81
Uses 4 · Used by 2
TheoremPrimitivity via distinct rotations#✓fully proved
Let \(w\) be a word of length \(n\), and for \(0 \le k < n\) let \(w_k\) be the rotation of \(w\) by \(k\), obtained by moving the first \(k\) letters of \(w\) to the end. Then \(w\) is primitive if and only if \(w\) is nonempty and the \(n\) words \(w_0, w_1, \dots, w_{n-1}\) are pairwise distinct.
theorem isPrimitiveWord_iff_nodup_cyclicPermutations {α : Type*} {w : List α} :
IsPrimitiveWord w ↔ w ≠ [] ∧ w.cyclicPermutations.Nodup
def IsPrimitiveWord {α : Type*} (u : List α) : Prop :=
u ≠ [] ∧ ∀ (v : List α) (n : ℕ), List.flatten (List.replicate n v) = u → n = 1
MathlibExt/Combinatorics/Words/PrimitiveWord.lean:28
Uses 1 · Used by 3
TheoremNontrivial rotations move a primitive word#✓fully proved
If \(w\) is a primitive word of length \(n\) and \(0 < k < n\), then the rotation of \(w\) by \(k\), obtained by moving the first \(k\) letters of \(w\) to the end, is different from \(w\).
theorem rotate_ne_of_isPrimitiveWord {α : Type*} {w : List α}
(hw : IsPrimitiveWord w) {k : ℕ} (hk0 : 0 < k) (hk : k < w.length) :
w.rotate k ≠ w
def IsPrimitiveWord {α : Type*} (u : List α) : Prop :=
u ≠ [] ∧ ∀ (v : List α) (n : ℕ), List.flatten (List.replicate n v) = u → n = 1
MathlibExt/Combinatorics/Words/PrimitiveWord.lean:28
Uses 2 · Used by 1
DefinitionPrimitive words of given content#✓fully proved
For a natural number \(r\) and natural numbers \(n_0, \dots, n_{r-1}\), the set of primitive words over the alphabet \(\{0, \dots, r-1\}\) in which each letter \(i\) occurs exactly \(n_i\) times.
def PrimitiveWordsOfContent {r : ℕ} (degree : Fin r → ℕ) :=
{w : WordsOfContent degree // IsPrimitiveWord w.1}
def WordsOfContent {r : ℕ} (degree : Fin r → ℕ) :=
{w : List (Fin r) // wittWordContent w = degree}
MathlibExt/Combinatorics/Words/LyndonWord.lean:81
def IsPrimitiveWord {α : Type*} (u : List α) : Prop :=
u ≠ [] ∧ ∀ (v : List α) (n : ℕ), List.flatten (List.replicate n v) = u → n = 1
MathlibExt/Combinatorics/Words/PrimitiveWord.lean:28
Uses 3 · Used by 1
TheoremLyndon words are primitive#✓fully proved
Every Lyndon word over a linearly ordered alphabet is primitive.
theorem isPrimitiveWord_of_isLyndonWord {α : Type*} [LinearOrder α] {w : List α}
(hw : IsLyndonWord w) : IsPrimitiveWord w
def IsLyndonWord {α : Type*} [LinearOrder α] (w : List α) : Prop :=
w ≠ [] ∧ ∀ k, 0 < k → k < w.length → w < w.rotate k
MathlibExt/Combinatorics/Words/LyndonWord.lean:38
def IsPrimitiveWord {α : Type*} (u : List α) : Prop :=
u ≠ [] ∧ ∀ (v : List α) (n : ℕ), List.flatten (List.replicate n v) = u → n = 1
MathlibExt/Combinatorics/Words/PrimitiveWord.lean:28
Uses 3 · Used by 1
TheoremWitt's formula for the number of Lyndon words of given content#✓fully proved
Let \(r\) be a natural number and let \(n_0, \dots, n_{r-1}\) be natural numbers with \(n = n_0 + \dots + n_{r-1} > 0\). Order the alphabet \(\{0, \dots, r-1\}\) as the natural numbers and order words over it lexicographically. Then the number of Lyndon words over this alphabet in which each letter \(i\) occurs exactly \(n_i\) times equals, as a rational number, Witt's multigraded value \(M(n_0, \dots, n_{r-1}) = \frac{1}{n} \sum_{d \mid g} \mu(d) \binom{n/d}{n_0/d, \ldots, n_{r-1}/d}\), where \(g = \gcd(n_0, \dots, n_{r-1})\), the sum runs over the positive divisors \(d\) of \(g\), and \(\mu\) is the Möbius function.
theorem card_lyndonWordsOfContent_eq_wittMultigradedValue {r : ℕ}
(degree : Fin r → ℕ) (hdegree : 0 < ∑ i, degree i) :
(Fintype.card (LyndonWordsOfContent degree) : ℚ) = wittMultigradedValue degree
def LyndonWordsOfContent {r : ℕ} (degree : Fin r → ℕ) :=
{w : WordsOfContent degree // IsLyndonWord w.1}
MathlibExt/Combinatorics/Words/LyndonWord.lean:85
def wittMultigradedValue {r : ℕ} (degree : Fin r → ℕ) : ℚ :=
let n := Finset.sum Finset.univ degree
let g := Finset.univ.gcd degree
if n = 0 then 0
else (1 / (n : ℚ)) * Finset.sum (Nat.divisors g) (fun d =>
((ArithmeticFunction.moebius d : ℤ) : ℚ) *
(Nat.multinomial Finset.univ (fun i => degree i / d) : ℚ))
MathlibExt/Algebra/Lie/WittMultigradedValue.lean:34
Uses 13 · Used by 1
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.