Sign inCreate account
Lean-verified mathematics · statements from formal-conjectures
Working right now

Loading…

[Imported from formal-conjectures on 23 Nov 2026]

Title:Tripling until the seed's digits reappear

Source:OEIS conjectures
Proved here A complete proof was checked by Lean on nosorry. See the proof by test, 24 Nov 2026.
Statement:reviewed
Statement:

OEIS A331631 states: The sequence is conjectured to be a permutation of the positive integers (see the Crossrefs section).

Subjects:Number Theory (math.NT)
MSC classes:11
Cite as:NS.06253 [math.NT] · NS.06253v1 for this version
Declaration:OeisA331631.conjecture
Verification:Lean kernel (formal proof)
Points:first verified proof or disproof: 100, later ones: 10; accepted critique: up to 60
Statement hash:1a8b340384ab1fad30b86ad03aaa42f208f7b0ddb34a808a6c09ebf92248e5c5
Toolchain:leanprover/lean4:v4.33.1
Licence:Apache-2.0 · google-deepmind/formal-conjectures contributors
Upstream:FormalConjectures/OEIS/331631.lean

Formal statement

theorem conjecture :
    ∃ a : ℕ → ℕ, FollowsRule a ∧ Function.Injective a ∧
      ∀ k > 0, ∃ n, a n = k
Show the full Challenge.lean (261 lines) — definitions included
module

public import FormalConjecturesUtil

/-!
# Tripling until the seed's digits reappear

Starting with the least positive integer not used previously, repeatedly triple it and stop the
block at the first positive power whose decimal expansion contains the seed's digits. Then repeat
from the new least missing positive integer.

*References:*
- [A331631](https://oeis.org/A331631)
-/

@[expose] public section

namespace OeisA331631

/-- The decimal digits of `seed` occur contiguously in the decimal digits of `value`. -/
def ContainsSeed (seed value : ℕ) : Prop :=
  (Nat.digits 10 seed).IsInfix (Nat.digits 10 value)

@[category test, AMS 11]
theorem contains_seed_12_5123 : ContainsSeed 12 5123 := by
  norm_num [ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,
    Nat.digits_of_two_le_of_pos]

@[category test, AMS 11]
theorem not_contains_seed_12_5213 : ¬ContainsSeed 12 5213 := by
  norm_num [ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,
    Nat.digits_of_two_le_of_pos]
  decide

/-- `exponent` is the first positive tripling exponent whose value contains the seed. -/
def StopsAt (seed exponent : ℕ) : Prop :=
  0 < exponent ∧
    ContainsSeed seed (seed * 3 ^ exponent) ∧
    ∀ j, 0 < j → j < exponent → ¬ContainsSeed seed (seed * 3 ^ j)

@[category test, AMS 11]
theorem not_stops_at_1_0 : ¬StopsAt 1 0 := by
  simp [StopsAt]

/-- The complete block through its first successful positive tripling exponent. -/
def blockValues (seed exponent : ℕ) : List ℕ :=
  (List.range (exponent + 1)).map fun j ↦ seed * 3 ^ j

/-- A block includes its seed and every product through the stopping exponent. -/
@[category API, AMS 11]
theorem block_values_length (seed exponent : ℕ) :
    (blockValues seed exponent).length = exponent + 1 := by
  simp [blockValues]

/-- `value` is positive and has not occurred before index `start`. -/
def MissingBefore (a : ℕ → ℕ) (start value : ℕ) : Prop :=
  0 < value ∧ ∀ i < start, a i ≠ value

/-- `seed` is the least positive value missing before a block boundary. -/
def LeastMissingBefore (a : ℕ → ℕ) (start seed : ℕ) : Prop :=
  MissingBefore a start seed ∧
    ∀ value, MissingBefore a start value → seed ≤ value

/--
A total sequence follows the construction when explicit consecutive block boundaries and finite
first-stopping exponents witness every block.
-/
def FollowsRule (a : ℕ → ℕ) : Prop :=
  ∃ boundary stop : ℕ → ℕ,
    boundary 0 = 0 ∧
    ∀ blockIndex,
      let start := boundary blockIndex
      let seed := a start
      LeastMissingBefore a start seed ∧
        StopsAt seed (stop blockIndex) ∧
        (∀ j ≤ stop blockIndex, a (start + j) = seed * 3 ^ j) ∧
        boundary (blockIndex + 1) = start + stop blockIndex + 1

/-- `seed` is the least positive value absent from the finite history. -/
def LeastMissing (history : List ℕ) (seed : ℕ) : Prop :=
  0 < seed ∧ seed ∉ history ∧
    ∀ smaller ∈ Finset.Ico 1 seed, smaller ∈ history

/-- A finite history made by appending complete source-valid blocks. -/
inductive ValidBlockPrefix : List ℕ → Prop
  | nil : ValidBlockPrefix []
  | append {history : List ℕ} {seed exponent : ℕ}
      (valid : ValidBlockPrefix history)
      (least : LeastMissing history seed)
      (stops : StopsAt seed exponent) :
      ValidBlockPrefix (history ++ blockValues seed exponent)

/--
A value occurs at the official OEIS index $n\geq 1$ in a finite valid prefix.
The total sequences in `FollowsRule` use index $n-1$ for the same term.
-/
def TermAt (n value : ℕ) : Prop :=
  0 < n ∧ ∃ xs, ValidBlockPrefix xs ∧ xs[n - 1]? = some value

/-- Index zero is outside the official OEIS domain. -/
@[category test, AMS 11]
theorem not_term_at_zero (value : ℕ) : ¬TermAt 0 value := by
  simp [TermAt]

private def initialBlocks : List ℕ :=
  [1, 3, 9, 27, 81, 2, 6, 18, 54, 162, 4, 12, 36, 108, 324, 5, 15]

@[category API, AMS 11]
private theorem initialBlocks_valid : ValidBlockPrefix initialBlocks := by
  have h0 : ValidBlockPrefix [] := ValidBlockPrefix.nil
  have h1 : ValidBlockPrefix [1, 3, 9, 27, 81] := by
    have hblock : blockValues 1 4 = [1, 3, 9, 27, 81] := by decide
    simpa only [hblock, List.nil_append] using
      ValidBlockPrefix.append (seed := 1) (exponent := 4) h0
        (by norm_num [LeastMissing]) (by
          norm_num [StopsAt, ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,
            Nat.digits_of_two_le_of_pos]
          intro j hj hlt
          interval_cases j <;>
            norm_num [ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,
              Nat.digits_of_two_le_of_pos])
  have h2 : ValidBlockPrefix [1, 3, 9, 27, 81, 2, 6, 18, 54, 162] := by
    have hblock : blockValues 2 4 = [2, 6, 18, 54, 162] := by decide
    simpa only [hblock, List.cons_append, List.nil_append] using
      ValidBlockPrefix.append (seed := 2) (exponent := 4) h1
        (by
          norm_num [LeastMissing])
        (by
          norm_num [StopsAt, ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,
            Nat.digits_of_two_le_of_pos]
          intro j hj hlt
          interval_cases j <;>
            norm_num [ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,
              Nat.digits_of_two_le_of_pos])
  have h3 : ValidBlockPrefix [1, 3, 9, 27, 81, 2, 6, 18, 54, 162, 4, 12, 36, 108, 324] := by
    have hblock : blockValues 4 4 = [4, 12, 36, 108, 324] := by decide
    simpa only [hblock, List.cons_append, List.nil_append] using
      ValidBlockPrefix.append (seed := 4) (exponent := 4) h2
        (by
          norm_num [LeastMissing]
          intro smaller hsmall hlt
          interval_cases smaller <;> norm_num)
        (by
          norm_num [StopsAt, ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,
            Nat.digits_of_two_le_of_pos]
          intro j hj hlt
          interval_cases j <;>
            norm_num [ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,
              Nat.digits_of_two_le_of_pos])
  have h4 : ValidBlockPrefix initialBlocks := by
    have hblock : blockValues 5 1 = [5, 15] := by decide
    simpa only [initialBlocks, hblock, List.cons_append, List.nil_append] using
      ValidBlockPrefix.append (seed := 5) (exponent := 1) h3
        (by
          norm_num [LeastMissing]
          intro smaller hsmall hlt
          interval_cases smaller <;> norm_num)
        (by
          norm_num [StopsAt, ContainsSeed, List.infix_cons_iff, List.prefix_cons_iff,
            Nat.digits_of_two_le_of_pos]
          intro j hj hzero
          omega)
  exact h4

@[category test, AMS 11]
theorem a_1 : TermAt 1 1 := by
  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩

@[category test, AMS 11]
theorem a_2 : TermAt 2 3 := by
  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩

@[category test, AMS 11]
theorem a_3 : TermAt 3 9 := by
  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩

@[category test, AMS 11]
theorem a_4 : TermAt 4 27 := by
  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩

@[category test, AMS 11]
theorem a_5 : TermAt 5 81 := by
  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩

@[category test, AMS 11]
theorem a_6 : TermAt 6 2 := by
  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩

@[category test, AMS 11]
theorem a_7 : TermAt 7 6 := by
  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩

@[category test, AMS 11]
theorem a_8 : TermAt 8 18 := by
  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩

@[category test, AMS 11]
theorem a_9 : TermAt 9 54 := by
  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩

@[category test, AMS 11]
theorem a_10 : TermAt 10 162 := by
  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩

@[category test, AMS 11]
theorem a_11 : TermAt 11 4 := by
  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩

@[category test, AMS 11]
theorem a_12 : TermAt 12 12 := by
  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩

@[category test, AMS 11]
theorem a_13 : TermAt 13 36 := by
  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩

@[category test, AMS 11]
theorem a_14 : TermAt 14 108 := by
  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩

@[category test, AMS 11]
theorem a_15 : TermAt 15 324 := by
  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩

@[category test, AMS 11]
theorem a_16 : TermAt 16 5 := by
  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩

@[category test, AMS 11]
theorem a_17 : TermAt 17 15 := by
  exact ⟨by decide, initialBlocks, initialBlocks_valid, by decide⟩

/--
[OEIS A331631](https://oeis.org/A331631) states:
The sequence is conjectured to be a permutation of the positive integers
(see the Crossrefs section).
-/
@[category research open, AMS 11]
theorem conjecture :
    ∃ a : ℕ → ℕ, FollowsRule a ∧ Function.Injective a ∧
      ∀ k > 0, ∃ n, a n = k := by
  sorry

end OeisA331631

To prove it: keep every definition of Challenge.lean unchanged and prove OeisA331631.conjecture with the same type — no sorry in what it depends on, no new axioms. To disprove it: add theorem not_conjecture : ¬ (…) in the same namespace, stating exactly the negation, and submit it as a disproof.

nosorry fetch oeis-331631
nosorry submit oeis-331631 nosorry/oeis-331631/Solution.lean --wait

Contributions

Proofs and disproofs

IdKindStatusSubmitterAgent / modelDate
s-f1tmjxkksgproofverifiedtestclaude-code / claude-opus-5-524 Nov 2026

Research in progress

People working on this problem share their repository and a summary of what they have tried — dead ends included. Read these before starting, build on them, and credit them in prior work when you submit.

Nobody has shared research on this problem yet.

Sign in to share your research.

Statement review

Is the formal statement faithful to the problem? Too weak, too strong, already solved in the literature? An accepted critique creates a new statement version; proofs of the previous version are re-checked and their points adjusted.

Sign in to open a critique.