{
  "id": "6253",
  "ident": "NS.06253",
  "slug": "oeis-331631",
  "title": "Tripling until the seed's digits reappear",
  "status": "open",
  "statement_status": "reviewed",
  "statement_md": "[OEIS A331631](https://oeis.org/A331631) states:\nThe sequence is conjectured to be a permutation of the positive integers\n(see the Crossrefs section).",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [],
  "collection": "oeis",
  "source_url": null,
  "solved_on_platform": true,
  "needs_answer": false,
  "version": 1,
  "decl_name": "OeisA331631.conjecture",
  "statement_lean": "theorem conjecture :\n    ∃ a : ℕ → ℕ, FollowsRule a ∧ Function.Injective a ∧\n      ∀ k > 0, ∃ n, a n = k",
  "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-/\n\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# Tripling until the seed's digits reappear\n\nStarting with the least positive integer not used previously, repeatedly triple it and stop the\nblock at the first positive power whose decimal expansion contains the seed's digits. Then repeat\nfrom the new least missing positive integer.\n\n*References:*\n- [A331631](https://oeis.org/A331631)\n-/\n\n@[expose] public section\n\nnamespace OeisA331631\n\n/-- The decimal digits of `seed` occur contiguously in the decimal digits of `value`. -/\ndef ContainsSeed (seed value : ℕ) : Prop :=\n  (Nat.digits 10 seed).IsInfix (Nat.digits 10 value)\n\n@[category test, AMS 11]\ntheorem contains_seed_12_5123 : ContainsSeed 12 5123 := by\n  norm_num [ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,\n    Nat.digits_of_two_le_of_pos]\n\n@[category test, AMS 11]\ntheorem not_contains_seed_12_5213 : ¬ContainsSeed 12 5213 := by\n  norm_num [ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,\n    Nat.digits_of_two_le_of_pos]\n  decide\n\n/-- `exponent` is the first positive tripling exponent whose value contains the seed. -/\ndef StopsAt (seed exponent : ℕ) : Prop :=\n  0 < exponent ∧\n    ContainsSeed seed (seed * 3 ^ exponent) ∧\n    ∀ j, 0 < j → j < exponent → ¬ContainsSeed seed (seed * 3 ^ j)\n\n@[category test, AMS 11]\ntheorem not_stops_at_1_0 : ¬StopsAt 1 0 := by\n  simp [StopsAt]\n\n/-- The complete block through its first successful positive tripling exponent. -/\ndef blockValues (seed exponent : ℕ) : List ℕ :=\n  (List.range (exponent + 1)).map fun j ↦ seed * 3 ^ j\n\n/-- A block includes its seed and every product through the stopping exponent. -/\n@[category API, AMS 11]\ntheorem block_values_length (seed exponent : ℕ) :\n    (blockValues seed exponent).length = exponent + 1 := by\n  simp [blockValues]\n\n/-- `value` is positive and has not occurred before index `start`. -/\ndef MissingBefore (a : ℕ → ℕ) (start value : ℕ) : Prop :=\n  0 < value ∧ ∀ i < start, a i ≠ value\n\n/-- `seed` is the least positive value missing before a block boundary. -/\ndef LeastMissingBefore (a : ℕ → ℕ) (start seed : ℕ) : Prop :=\n  MissingBefore a start seed ∧\n    ∀ value, MissingBefore a start value → seed ≤ value\n\n/--\nA total sequence follows the construction when explicit consecutive block boundaries and finite\nfirst-stopping exponents witness every block.\n-/\ndef FollowsRule (a : ℕ → ℕ) : Prop :=\n  ∃ boundary stop : ℕ → ℕ,\n    boundary 0 = 0 ∧\n    ∀ blockIndex,\n      let start := boundary blockIndex\n      let seed := a start\n      LeastMissingBefore a start seed ∧\n        StopsAt seed (stop blockIndex) ∧\n        (∀ j ≤ stop blockIndex, a (start + j) = seed * 3 ^ j) ∧\n        boundary (blockIndex + 1) = start + stop blockIndex + 1\n\n/-- `seed` is the least positive value absent from the finite history. -/\ndef LeastMissing (history : List ℕ) (seed : ℕ) : Prop :=\n  0 < seed ∧ seed ∉ history ∧\n    ∀ smaller ∈ Finset.Ico 1 seed, smaller ∈ history\n\n/-- A finite history made by appending complete source-valid blocks. -/\ninductive ValidBlockPrefix : List ℕ → Prop\n  | nil : ValidBlockPrefix []\n  | append {history : List ℕ} {seed exponent : ℕ}\n      (valid : ValidBlockPrefix history)\n      (least : LeastMissing history seed)\n      (stops : StopsAt seed exponent) :\n      ValidBlockPrefix (history ++ blockValues seed exponent)\n\n/--\nA value occurs at the official OEIS index $n\\geq 1$ in a finite valid prefix.\nThe total sequences in `FollowsRule` use index $n-1$ for the same term.\n-/\ndef TermAt (n value : ℕ) : Prop :=\n  0 < n ∧ ∃ xs, ValidBlockPrefix xs ∧ xs[n - 1]? = some value\n\n/-- Index zero is outside the official OEIS domain. -/\n@[category test, AMS 11]\ntheorem not_term_at_zero (value : ℕ) : ¬TermAt 0 value := by\n  simp [TermAt]\n\nprivate def initialBlocks : List ℕ :=\n  [1, 3, 9, 27, 81, 2, 6, 18, 54, 162, 4, 12, 36, 108, 324, 5, 15]\n\n@[category API, AMS 11]\nprivate theorem initialBlocks_valid : ValidBlockPrefix initialBlocks := by\n  have h0 : ValidBlockPrefix [] := ValidBlockPrefix.nil\n  have h1 : ValidBlockPrefix [1, 3, 9, 27, 81] := by\n    have hblock : blockValues 1 4 = [1, 3, 9, 27, 81] := by decide\n    simpa only [hblock, List.nil_append] using\n      ValidBlockPrefix.append (seed := 1) (exponent := 4) h0\n        (by norm_num [LeastMissing]) (by\n          norm_num [StopsAt, ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,\n            Nat.digits_of_two_le_of_pos]\n          intro j hj hlt\n          interval_cases j <;>\n            norm_num [ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,\n              Nat.digits_of_two_le_of_pos])\n  have h2 : ValidBlockPrefix [1, 3, 9, 27, 81, 2, 6, 18, 54, 162] := by\n    have hblock : blockValues 2 4 = [2, 6, 18, 54, 162] := by decide\n    simpa only [hblock, List.cons_append, List.nil_append] using\n      ValidBlockPrefix.append (seed := 2) (exponent := 4) h1\n        (by\n          norm_num [LeastMissing])\n        (by\n          norm_num [StopsAt, ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,\n            Nat.digits_of_two_le_of_pos]\n          intro j hj hlt\n          interval_cases j <;>\n            norm_num [ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,\n              Nat.digits_of_two_le_of_pos])\n  have h3 : ValidBlockPrefix [1, 3, 9, 27, 81, 2, 6, 18, 54, 162, 4, 12, 36, 108, 324] := by\n    have hblock : blockValues 4 4 = [4, 12, 36, 108, 324] := by decide\n    simpa only [hblock, List.cons_append, List.nil_append] using\n      ValidBlockPrefix.append (seed := 4) (exponent := 4) h2\n        (by\n          norm_num [LeastMissing]\n          intro smaller hsmall hlt\n          interval_cases smaller <;> norm_num)\n        (by\n          norm_num [StopsAt, ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,\n            Nat.digits_of_two_le_of_pos]\n          intro j hj hlt\n          interval_cases j <;>\n            norm_num [ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,\n              Nat.digits_of_two_le_of_pos])\n  have h4 : ValidBlockPrefix initialBlocks := by\n    have hblock : blockValues 5 1 = [5, 15] := by decide\n    simpa only [initialBlocks, hblock, List.cons_append, List.nil_append] using\n      ValidBlockPrefix.append (seed := 5) (exponent := 1) h3\n        (by\n          norm_num [LeastMissing]\n          intro smaller hsmall hlt\n          interval_cases smaller <;> norm_num)\n        (by\n          norm_num [StopsAt, ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,\n            Nat.digits_of_two_le_of_pos]\n          intro j hj hzero\n          omega)\n  exact h4\n\n@[category test, AMS 11]\ntheorem a_1 : TermAt 1 1 := by\n  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_2 : TermAt 2 3 := by\n  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_3 : TermAt 3 9 := by\n  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_4 : TermAt 4 27 := by\n  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_5 : TermAt 5 81 := by\n  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_6 : TermAt 6 2 := by\n  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_7 : TermAt 7 6 := by\n  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_8 : TermAt 8 18 := by\n  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_9 : TermAt 9 54 := by\n  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_10 : TermAt 10 162 := by\n  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_11 : TermAt 11 4 := by\n  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_12 : TermAt 12 12 := by\n  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_13 : TermAt 13 36 := by\n  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_14 : TermAt 14 108 := by\n  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_15 : TermAt 15 324 := by\n  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_16 : TermAt 16 5 := by\n  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_17 : TermAt 17 15 := by\n  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩\n\n/--\n[OEIS A331631](https://oeis.org/A331631) states:\nThe sequence is conjectured to be a permutation of the positive integers\n(see the Crossrefs section).\n-/\n@[category research open, AMS 11]\ntheorem conjecture :\n    ∃ a : ℕ → ℕ, FollowsRule a ∧ Function.Injective a ∧\n      ∀ k > 0, ∃ n, a n = k := by\n  sorry\n\nend OeisA331631\n",
  "statement_hash": "1a8b340384ab1fad30b86ad03aaa42f208f7b0ddb34a808a6c09ebf92248e5c5",
  "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."
}