/- Copyright 2026 The Formal Conjectures Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -/ module public import FormalConjecturesUtil /-! # Step difference bound $a(n+1) - a(n) \in \{1, 2\}$ in mass-redistribution cellular automata $a(n)$ is the number of steps needed to reach a stable configuration in the 1D cellular automaton initialized with one cell with mass $n$ and based on the rule "each cell gives half of its mass, rounded down, to its right neighbor". The stable configuration is $n$ cells with mass 1. *References:* - [A300997](https://oeis.org/A300997) - [arxiv/2605.22763](https://arxiv.org/abs/2605.22763) *Advancing Mathematics Research with AI-Driven Formal Proof Search* by George Tsoukalas et al. -/ @[expose] public section namespace OeisA300997 open List Nat Function Set /-- $a(n)$ is the number of steps needed to reach a stable configuration in the 1D cellular automaton initialized with one cell with mass $n$ and based on the rule "each cell gives half of its mass, rounded down, to its right neighbor". The stable configuration is $n$ cells with mass 1. -/ noncomputable def a (n : ℕ) : ℕ := let half_ceil (m : ℕ) : ℕ := (m + 1) / 2 let half_floor (m : ℕ) : ℕ := m / 2 let trim_trailing_zeros (l : List ℕ) : List ℕ := (List.reverse l).dropWhile (fun x => x = 0) |>.reverse let ca_step (config : List ℕ) : List ℕ := let base_masses := config.map half_ceil ++ [0] let received_masses := 0 :: config.map half_floor let next_config_long := List.zipWith Nat.add base_masses received_masses trim_trailing_zeros next_config_long if n = 0 then 0 else let initial_config : List ℕ := [n] let target_config : List ℕ := List.replicate n 1 -- State after t steps, computed by folding ca_step t times using foldl over a range. let S (t : ℕ) : List ℕ := (List.range t).foldl (fun acc _ => ca_step acc) initial_config -- The set of time steps k at which the configuration is stable. let stable_steps : Set ℕ := {k | S k = target_config} -- a(n) is the smallest k in this set, defined by the set infimum (sInf). sInf stable_steps @[category test, AMS 11] lemma a_1 : a 1 = 0 := by simp [a, Nat.sInf_eq_zero, Set.mem_ofPred_eq, List.replicate] @[category test, AMS 11] lemma a_2 : a 2 = 1 := by unfold a norm_num refine le_antisymm (Nat.sInf_le ?_) ?_ · simp only [Set.mem_ofPred_eq] decide · refine Nat.one_le_iff_ne_zero.mpr fun h => ?_ rcases Nat.sInf_eq_zero.mp h with h0 | h0 · simp only [Set.mem_ofPred_eq] at h0 exact absurd h0 (by decide) · exact absurd h0 (Set.nonempty_iff_ne_empty.mp ⟨1, by simp only [Set.mem_ofPred_eq]; decide⟩) @[category test, AMS 11] lemma a_3 : a 3 = 3 := by norm_num [a] refine IsLeast.csInf_eq ⟨?_, ?_⟩ · simp only [Set.mem_ofPred_eq] decide · intro k hk simp only [Set.mem_ofPred_eq] at hk by_contra hlt push Not at hlt interval_cases k <;> exact absurd hk (by decide) @[category test, AMS 11] lemma a_4 : a 4 = 4 := by norm_num [a] apply le_antisymm · apply Nat.sInf_le simp only [Set.mem_ofPred_eq] decide · apply le_csInf · refine ⟨4, ?_⟩ simp only [Set.mem_ofPred_eq] decide · intro b hb simp only [Set.mem_ofPred_eq] at hb by_contra hb4 push Not at hb4 interval_cases b <;> exact absurd hb (by decide) @[category test, AMS 11] lemma a_5 : a 5 = 6 := by have key : ∀ s : Set ℕ, 6 ∈ s → (∀ k < 6, k ∉ s) → sInf s = 6 := by intro s h6 hlt refine le_antisymm (Nat.sInf_le h6) ?_ by_contra h push Not at h exact hlt _ h (Nat.sInf_mem ⟨6, h6⟩) unfold a norm_num apply key · simp only [Set.mem_ofPred_eq] decide · intro k hk simp only [Set.mem_ofPred_eq] interval_cases k <;> decide set_option linter.style.formal_proof_palomar false in /-- Conjecture: It appears that the finite difference of this sequence only contains 1's and 2's. A formal proof has been found with the methods described in [arxiv/2605.22763](https://arxiv.org/abs/2605.22763). -/ @[category research solved, AMS 11, formal_proof using formal_conjectures at "https://github.com/mo271/formal-conjectures/blob/a32396489dcb8f86c3549b93aa358ac6a10a3a1f/FormalConjectures/OEIS/300997.wip.lean#L1153"] theorem a_succ_eq : ∀ n : ℕ, 1 ≤ n → a (n + 1) = a n + 1 ∨ a (n + 1) = a n + 2 := by sorry end OeisA300997