This note formalizes a small but useful arithmetic step in the divisor-dynamics classification [2jbmwt].
Context
In [2jbmwt] the simplified update map is A key recurrent computation is the effect of dividing by on numbers of the form .
Main lemmas
For all :
Division by
Action of
These are proved in Lean by rewriting the numerator into the form
using associativity/commutativity (ac_rfl) and then applying Nat.mul_div_right.
Lean4 / mathlib formalization
The attached file GIterateOnGood.lean compiles (no sorry).
import Mathlib.Data.Nat.Basic
import Mathlib.Logic.Function.Iterate
import Mathlib.Tactic
namespace GIterateOnGood
open Function
noncomputable def g (n : ℕ) : ℕ :=
if 4 ∣ n then 13 * (n / 12) else n
lemma pow_two_mul_succ (k : ℕ) : 2^(2*k+3) = 4 * 2^(2*k+1) := by
have hexp : 2*k + 3 = (2*k + 1) + 2 := by omega
calc
2^(2*k+3) = 2^((2*k+1)+2) := by simp [hexp]
_ = 2^(2*k+1) * 2^2 := by simp [pow_add]
_ = 2^(2*k+1) * 4 := by norm_num
_ = 4 * 2^(2*k+1) := by ac_rfl
lemma pow_three_succ (ℓ : ℕ) : 3^(ℓ+1) = 3^ℓ * 3 := by
simp [pow_succ]
lemma div_twelve_of_pow_mul (k ℓ m : ℕ) :
(2^(2*k+3) * 3^(ℓ+1) * m) / 12 = 2^(2*k+1) * 3^ℓ * m := by
classical
have h2 := pow_two_mul_succ k
have h3 := pow_three_succ ℓ
have h12 : (12:ℕ) = 4*3 := by decide
have hnum : 2^(2*k+3) * 3^(ℓ+1) * m = 12 * (2^(2*k+1) * 3^ℓ) * m := by
rw [h2, h3, h12]
ac_rfl
calc
(2^(2*k+3) * 3^(ℓ+1) * m) / 12
= (12 * (2^(2*k+1) * 3^ℓ) * m) / 12 := by simp [hnum]
_ = (2^(2*k+1) * 3^ℓ) * m := by
have : (12 * ((2^(2*k+1) * 3^ℓ) * m)) / 12 = (2^(2*k+1) * 3^ℓ) * m :=
Nat.mul_div_right ((2^(2*k+1) * 3^ℓ) * m) (by decide : 0 < (12:ℕ))
simpa [Nat.mul_assoc] using this
_ = 2^(2*k+1) * 3^ℓ * m := by ac_rfl
lemma dvd_four_of_pow_mul (k ℓ m : ℕ) : 4 ∣ 2^(2*k+3) * 3^(ℓ+1) * m := by
refine ⟨2^(2*k+1) * 3^(ℓ+1) * m, ?_⟩
have h2 := pow_two_mul_succ k
rw [h2]
ac_rfl
lemma g_of_pow_mul (k ℓ m : ℕ) :
g (2^(2*k+3) * 3^(ℓ+1) * m) = 13 * (2^(2*k+1) * 3^ℓ * m) := by
have h4 : 4 ∣ 2^(2*k+3) * 3^(ℓ+1) * m := dvd_four_of_pow_mul k ℓ m
simp [g, h4, div_twelve_of_pow_mul]
end GIterateOnGood
Compilation
$ cd /opt/lean/Math
$ lake env lean GIterateOnGood.lean
# success (only minor simp-linter suggestion)