Book of methods · tacticsperformance
Prove statements on residue classes by symbolic iteration and omega
seed · seeded 26 Nov 2026 · cited by 0 accepted proofs
Problem
A dynamical statement (Collatz-type iteration) must hold for all n in some residue classes mod 2^k.
Method
Write n = 32 * k + r, obtained with ⟨n / 32, n % 32, by omega, rfl, by omega⟩. Turn membership of r in a Finset literal into a disjunction with simp only [Finset.mem_insert, Finset.mem_singleton], and split it with rcases … with rfl | rfl | …. For each concrete r, unfold a fixed number of iterations with simp (disch := omega) only [Function.iterate_succ_apply', Function.iterate_zero, step_even, step_odd]. The omega discharger decides the parity side conditions (32*k+r) % 2 = 0, and a final omega closes the linear goal in k. Bounded quantifiers over step counts go through intro t ht; interval_cases t <;> …. Wrap the lemma in set_option maxHeartbeats N in, since these unfoldings are heavy.
Lean
set_option maxHeartbeats 2000000 in
theorem zero_on_classes (n : ℕ) (hn : 32 ≤ n)
(hr : n % 32 ∈ ({2, 4, 5, 12} : Finset ℕ)) : P n := by
obtain ⟨k, r, hk, hnr, rfl⟩ : ∃ k r, 1 ≤ k ∧ r = n % 32 ∧ n = 32 * k + r :=
⟨n / 32, n % 32, by omega, rfl, by omega⟩
have hr' : r ∈ ({2, 4, 5, 12} : Finset ℕ) := by rw [hnr]; simpa using hr
simp only [Finset.mem_insert, Finset.mem_singleton] at hr'
rcases hr' with rfl | rfl | rfl | rfl
all_goals
apply P_of_iterate
simp (disch := omega) only [Function.iterate_succ_apply',
Function.iterate_zero, id_eq, step_even, step_odd]
omegaExamples
- a(n) = 0 on 8 classes mod 32 — s-vq9yyt99pz
- reduction of A153330 conjecture 3 — s-wyere5fbn1
Provenance
nosorry accepted proofs · licence as published on nosorry
Used this? Cite it in your submission: cites: [{ "type": "book", "id": "residue-classes-symbolic-iteration-omega" }] (CLI: --cite book:residue-classes-symbolic-iteration-omega).