{
  "id": "4432",
  "ident": "NS.04432",
  "slug": "oeis-100475--conjecture",
  "title": "Prime-th recurrence with reversal at each step · conjecture",
  "status": "open",
  "statement_status": "reviewed",
  "statement_md": "Starting at a positive value other than $a(0) = 1$, does this sequence ever go into a loop?\n\nThe positivity hypothesis is required because the source recurrence uses the one-based prime index\n`p₁ = 2`; the `x = 0` branch above is only an artifact of making `aStartAt` total on `ℕ`.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [
    "question"
  ],
  "collection": "oeis",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "OeisA100475.conjecture",
  "statement_lean": "theorem conjecture :\n    ∃ x : ℕ, 0 < x ∧ x ≠ 1 ∧ IsUltimatelyPeriodic (aStartAt x)",
  "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# Prime-th recurrence with reversal at each step\n\n$$a(n) = \\operatorname{reversal}(p_{a(n-1)})$$\nwith $a(0)=1$, where $p_k$ is the $k$-th prime number.\n\n*References:*\n- [A100475](https://oeis.org/A100475)\n-/\n\n@[expose] public section\n\nnamespace OeisA100475\n\nopen Nat List\n\n/-- Reverses the base 10 digits of a natural number. -/\ndef reverseDigits (k : ℕ) : ℕ :=\n  Nat.ofDigits 10 (Nat.digits 10 k |>.reverse)\n\n/-- The primary defining sequence `a`.\na n is the Prime-th recurrence with reversal at each step.\n$a(n) = \\operatorname{reversal}(p_{a(n-1)})$\nwith $a(0)=1$, where $p_k$ is the $k$-th prime number (i.e., $p_1=2, p_2=3, \\dots$). -/\nnoncomputable def a : ℕ → ℕ\n  | 0 => 1\n  | n + 1 =>\n    let k := a n\n    if k = 0 then 0\n    else reverseDigits (Nat.nth Nat.Prime (k - 1))\n\n@[category API, AMS 11]\nlemma a_succ (n : ℕ) :\n    a (n + 1) = if a n = 0 then 0 else reverseDigits (Nat.nth Nat.Prime (a n - 1)) := by\n  rfl\n\n/-- Term theorems verifying the first few values of the sequence against the official OEIS b-file -/\n@[category test, AMS 11]\ntheorem a_0 : a 0 = 1 := by rfl\n\n@[category test, AMS 11]\ntheorem a_1 : a 1 = 2 := by\n  rw [a_succ]\n  rw [a_0]\n  simp [Nat.nth_prime_zero_eq_two, reverseDigits]\n\n@[category test, AMS 11]\ntheorem a_2 : a 2 = 3 := by\n  rw [a_succ]\n  rw [a_1]\n  simp [Nat.nth_prime_one_eq_three, reverseDigits]\n\n@[category test, AMS 11]\ntheorem a_3 : a 3 = 5 := by\n  rw [a_succ]\n  rw [a_2]\n  simp [Nat.nth_prime_two_eq_five, reverseDigits]\n\n@[category test, AMS 11]\ntheorem a_4 : a 4 = 11 := by\n  rw [a_succ]\n  rw [a_3]\n  simp [Nat.nth_prime_four_eq_eleven, reverseDigits]\n  rfl\n\n/-- Definition of the generalized sequence starting at x. -/\nnoncomputable def aStartAt (x : ℕ) : ℕ → ℕ\n  | 0 => x\n  | n + 1 =>\n    let k := aStartAt x n\n    if k = 0 then 0\n    else reverseDigits (Nat.nth Nat.Prime (k - 1))\n\n/-- A sequence $f : \\mathbb{N} \\to \\mathbb{N}$ is ultimately periodic if there exist\n$N, P \\in \\mathbb{N}$, with $P>0$, such that for all $n \\ge N$, $f(n+P) = f(n)$. -/\ndef IsUltimatelyPeriodic (f : ℕ → ℕ) : Prop :=\n  ∃ N P, P > 0 ∧ ∀ n, n ≥ N → f (n + P) = f n\n\n/-- The totalized recurrence stays at zero when initialized at zero. The OEIS recurrence itself\nuses one-based prime indices, so this is a boundary behavior of the formalization rather than a\nterm of the original sequence. -/\n@[category API, AMS 11]\nlemma aStartAt_zero (n : ℕ) : aStartAt 0 n = 0 := by\n  induction n with\n  | zero => rfl\n  | succ n ih => simp [aStartAt, ih]\n\n/--\nIf zero is admitted as a starting value, then a start other than $1$ does go into a loop: the\nsequence starting at zero is constant. This records the degenerate answer created by totalizing\nthe one-based prime recurrence at index zero.\n-/\n@[category research solved, question, AMS 11]\ntheorem conjecture_with_zero :\n    ∃ x : ℕ, x ≠ 1 ∧ IsUltimatelyPeriodic (aStartAt x) := by\n  refine ⟨0, by omega, 0, 1, by omega, ?_⟩\n  intro n _\n  rw [aStartAt_zero, aStartAt_zero]\n\n/--\nStarting at a positive value other than $a(0) = 1$, does this sequence ever go into a loop?\n\nThe positivity hypothesis is required because the source recurrence uses the one-based prime index\n`p₁ = 2`; the `x = 0` branch above is only an artifact of making `aStartAt` total on `ℕ`.\n-/\n@[category research open, question, AMS 11]\ntheorem conjecture :\n    ∃ x : ℕ, 0 < x ∧ x ≠ 1 ∧ IsUltimatelyPeriodic (aStartAt x) := by\n  sorry\n\nend OeisA100475\n",
  "statement_hash": "9fa2e0e887d0d8e5b8c3043aded923135cf6e0056100e5223d0155557845983a",
  "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."
}