feat(Data/List): decidability of HasPeriod and periods of repeated lists#41882
feat(Data/List): decidability of HasPeriod and periods of repeated lists#41882theebayuser wants to merge 3 commits into
Conversation
Extend PeriodicityLemma.lean with the correspondence between periods and repetitions: (replicate n l).flatten has period l.length (hasPeriod_flatten_replicate), and conversely a list with period p and length exactly r * p is the r-fold repetition of its length-p prefix (eq_flatten_replicate_of_hasPeriod). Also provide a Decidable instance for HasPeriod, immediate from its definition as a prefix test.
Welcome new contributor!Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests. We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the If you haven't already done so, please come to https://leanprover.zulipchat.com/, introduce yourself, and mention your new PR. Thank you again for joining our community. |
PR summary 728c687d4bImport changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
LLM-generated |
- golf the Decidable instance via inferInstanceAs - restructure hasPeriod_flatten_replicate as a recursive match with | 0 | 1 => simp - reflow the eq_flatten_replicate_of_hasPeriod signature Suggested-by: SnirBroshi
Hello, this PR extends
Mathlib/Data/List/PeriodicityLemma.leanwith:Decidable (List.HasPeriod w p)instance (it is a prefix test), andhasPeriod_flatten_replicate—(replicate n l).flattenhas periodl.lengtheq_flatten_replicate_of_hasPeriod— a word with periodpand lengthr * pis ther-fold repetition of its length-pprefix.This characterizes
r-th powers of words by a period plus a length constraint, which a future follow-up PR that I plan to work on will use.AI disclosure: This code was mostly generated by Claude Fable 5 and Opus 4.8 as part of my larger project on combinatorics on words, which I then reviewed and revised to contribute to mathlib.