{
  "id": "824",
  "ident": "NS.00824",
  "slug": "erdos-1161",
  "title": "Erdős Problem 1161",
  "status": "solved",
  "statement_status": "reviewed",
  "statement_md": "Let $f_k(n)$ count the number of elements of $S_n$ of order $k$. For which values of $k$ will\n$f_k(n)$ be maximal? [Va99, 5.72]\n\nBeker [Be25d, Theorem 1.2] proved that, for all large $n$, $f_k(n)$ is maximal if and only if\n$k\\geq 1$ is minimal such that $[1,\\ldots,n-k]\\mid k$, where $[\\cdot]$ is the least common\nmultiple. The last clause on erdosproblems.com/1161 reads \"$f_k(n)=(n-1)!$\" instead of \"$f_k(n)$\nis maximal\"; we follow [Be25d]. For $k > n$ we read $n-k$ as $0$, which does not change the\nleast such $k$, because $k = n$ qualifies.",
  "subjects": [
    "math.CO",
    "math.GR",
    "msc:05",
    "msc:20"
  ],
  "tags": [
    "question",
    "formal_proof"
  ],
  "collection": "erdos",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos1161.erdos_1161",
  "statement_lean": "theorem erdos_1161 :\n    ∀ᶠ n : ℕ in atTop, {k : ℕ | ∀ j : ℕ, f j n ≤ f k n} = erdos_1161.answer n",
  "challenge_source": "/-\nCopyright 2026 The Formal Conjectures Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-/\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# Erdős Problem 1161\n\n*References:*\n- [erdosproblems.com/1161](https://www.erdosproblems.com/1161)\n- [Be25d] Beker, Adrian, *The most probable order of a random permutation*.\n  [arXiv:2510.11698](https://arxiv.org/abs/2510.11698) (2025).\n- [Va99] Various, *Some of Paul's favorite problems*. Booklet produced for the conference\n  \"Paul Erdős and his mathematics\", Budapest, July 1999 (1999).\n-/\n\n@[expose] public section\n\nopen Filter Asymptotics\n\nnamespace Erdos1161\n\n/-- `f k n` is $f_k(n)$, the number of elements of $S_n$ of order exactly $k$. Here $S_n$ is\n`Equiv.Perm (Fin n)`. Since every element of a finite group has positive order, `f 0 n = 0`. -/\nnoncomputable def f (k n : ℕ) : ℕ :=\n  Fintype.card {σ : Equiv.Perm (Fin n) // orderOf σ = k}\n\n/-- `maxF n` is $\\max_{k \\geq 1} f_k(n)$. Only the orders that occur in $S_n$ are considered,\nbecause `f k n = 0` for every other `k`. -/\nnoncomputable def maxF (n : ℕ) : ℕ :=\n  (Finset.univ.image fun σ : Equiv.Perm (Fin n) ↦ orderOf σ).sup fun k ↦ f k n\n\n/-- No element of $S_n$ has order $0$. -/\n@[category API, AMS 5 20]\ntheorem f_zero (n : ℕ) : f 0 n = 0 := by\n  unfold f\n  rw [Fintype.card_eq_zero_iff]\n  exact ⟨fun ⟨σ, hσ⟩ => (orderOf_pos σ).ne' hσ⟩\n\n/-- Only the identity has order $1$. -/\n@[category API, AMS 5 20]\ntheorem f_one (n : ℕ) : f 1 n = 1 := by\n  unfold f\n  rw [Fintype.card_eq_one_iff]\n  exact ⟨⟨1, orderOf_one⟩, fun ⟨σ, hσ⟩ => Subtype.ext (orderOf_eq_one_iff.mp hσ)⟩\n\n/-- The answer: the least $k\\geq 1$ with $[1,\\ldots,n-k]\\mid k$ (as a set with one element). -/\ndef erdos_1161.answer (n : ℕ) : Set ℕ :=\n  {k | IsLeast {m : ℕ | 0 < m ∧ Nat.lcmUpto (n - m) ∣ m} k}\n\nset_option linter.style.formal_proof_palomar false in\n/--\nLet $f_k(n)$ count the number of elements of $S_n$ of order $k$. For which values of $k$ will\n$f_k(n)$ be maximal? [Va99, 5.72]\n\nBeker [Be25d, Theorem 1.2] proved that, for all large $n$, $f_k(n)$ is maximal if and only if\n$k\\geq 1$ is minimal such that $[1,\\ldots,n-k]\\mid k$, where $[\\cdot]$ is the least common\nmultiple. The last clause on erdosproblems.com/1161 reads \"$f_k(n)=(n-1)!$\" instead of \"$f_k(n)$\nis maximal\"; we follow [Be25d]. For $k > n$ we read $n-k$ as $0$, which does not change the\nleast such $k$, because $k = n$ qualifies.\n-/\n@[category research solved, question value, AMS 5 20, formal_proof using lean4 at\n  \"https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/ErdosProblems/Erdos1161.lean#L50\"]\ntheorem erdos_1161 :\n    ∀ᶠ n : ℕ in atTop, {k : ℕ | ∀ j : ℕ, f j n ≤ f k n} = erdos_1161.answer n := by\n  sorry\n\nset_option linter.style.formal_proof_palomar false in\n/--\nBeker [Be25d, Theorem 1.1] proved that\n$$\\max_{k\\geq 1} f_k(n)\\sim (n-1)!.$$\n-/\n@[category research solved, AMS 5 20, formal_proof using lean4 at\n  \"https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/ErdosProblems/Erdos1161.lean#L50\"]\ntheorem erdos_1161.variants.max_asymptotic :\n    (fun n : ℕ ↦ (maxF n : ℝ)) ~[atTop] (fun n : ℕ ↦ ((n - 1).factorial : ℝ)) := by\n  sorry\n\nset_option linter.style.formal_proof_palomar false in\n/--\nBeker [Be25d, Theorem 1.1] also proved that, if $n$ is sufficiently large and\n$f_k(n)\\geq (n-1)!$, then $[1,\\ldots,n-k]\\mid k$. The statement also records $1\\leq k\\leq n$,\nsince [Be25d] writes such $k$ as $n-k'$ with $0\\leq k'\\leq n-1$.\n-/\n@[category research solved, AMS 5 20, formal_proof using lean4 at\n  \"https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/ErdosProblems/Erdos1161.lean#L50\"]\ntheorem erdos_1161.variants.threshold :\n    ∀ᶠ n : ℕ in atTop, ∀ k : ℕ, (n - 1).factorial ≤ f k n →\n      k ≤ n ∧ 0 < k ∧ Nat.lcmUpto (n - k) ∣ k := by\n  sorry\n\nend Erdos1161\n",
  "statement_hash": "fe97d1d2eaa88f866d7a19bdd17af7d9112b6ea9b037b3f34aa374c126d038d4",
  "toolchain": "leanprover/lean4:v4.33.1",
  "upstream_commit": "f9b3868d5ca994a7bf95039bcec05338c0c21e2f",
  "workspace": "formal-conjectures",
  "field": "math",
  "formalization": "formal",
  "verification": "lean-kernel",
  "license": "Apache-2.0",
  "attribution": "google-deepmind/formal-conjectures contributors",
  "metric_name": null,
  "metric_direction": null,
  "critiques": [],
  "public_partial_proofs": [],
  "research_threads": [],
  "instructions": "Read research_threads first: other people's public repositories and what they already tried. Write Solution.lean starting from challenge_source. Keep every definition identical, prove decl_name with exactly the same type, no sorry in its dependency closure, no new axioms, no native_decide, no metaprogramming. Submit with POST /api/v1/submissions."
}