import Mathlib /-! # Generalized d-adic Collatz Pair Chain and Residue-Class Link For integers `d ≥ 2`, `a > 1` with `Nat.Coprime a d`, define the generalized d-adic Collatz map `T d a : ℤ → ℤ`: * `T d a x = x / d` if `d ∣ x`, * `T d a x = (a * x + res d a x) / d` otherwise, where `res d a x ∈ {1, ..., d-1}` is the unique residue satisfying `a * x + res d a x ≡ 0 (mod d)`. We formalize: 1. The d-adic pair chain `(s, μ) ∈ ℕ × ℤ` with transition `step d a : State → Fin d → State`. 2. The exact one-step transition lemma `step_rel` on `ℤ`. 3. The affine transition lemma `step_affine` on `ℤ` and the induced bijection `sigZMod` on `ZMod (d ^ k)`. 4. The exact link between the merged residue class count `C_k(d, a, m)` (both in `Finset.range (d^k)` and in `ZMod (d^k)`) and the k-step absorption probability `pAbs (step d a) absorbed k ⟨0, m⟩` of the d-adic pair chain. -/ namespace DAdicCollatz /-! ## Core definitions -/ /-- Unique residue `r ∈ {0, ..., d - 1}` with `a * x + r ≡ 0 (mod d)`. -/ def res (d a : ℕ) (x : ℤ) : ℤ := (-(a : ℤ) * x) % (d : ℤ) /-- Generalized d-adic Collatz map on `ℤ`. -/ def T (d a : ℕ) (x : ℤ) : ℤ := if x % (d : ℤ) = 0 then x / (d : ℤ) else ((a : ℤ) * x + res d a x) / (d : ℤ) /-- State `(s, μ) ∈ ℕ × ℤ` of the d-adic pair chain, representing `q = a^s * p + μ`. -/ structure State where s : ℕ mu : ℤ deriving DecidableEq, Repr /-- Normalize level-0 states by taking `|μ|`. -/ def State.norm (st : State) : State := if st.s = 0 then ⟨0, |st.mu|⟩ else st /-- The merged / absorbing state `(0, 0)`. -/ def absorbed : State := ⟨0, 0⟩ /-- One step of the d-adic pair chain on digit `c : Fin d`. -/ def step (d a : ℕ) (st : State) (c : Fin d) : State := let qRem := ((a : ℤ) ^ st.s * (c.val : ℤ) + st.mu) % (d : ℤ) if c.val = 0 then if qRem = 0 then (⟨st.s, st.mu / (d : ℤ)⟩ : State).norm else ⟨st.s + 1, ((a : ℤ) * st.mu + res d a st.mu) / (d : ℤ)⟩ else if qRem = 0 then match st.s with | 0 => ⟨1, (res d a (c.val : ℤ) - (a : ℤ) * st.mu) / (d : ℤ)⟩ | s' + 1 => (⟨s', (st.mu - (a : ℤ) ^ s' * res d a (c.val : ℤ)) / (d : ℤ)⟩ : State).norm else (⟨st.s, ((a : ℤ) * st.mu + res d a ((a : ℤ) ^ st.s * (c.val : ℤ) + st.mu) - (a : ℤ) ^ st.s * res d a (c.val : ℤ)) / (d : ℤ)⟩ : State).norm /-- The state reached from `st` along a word of digits `w : List (Fin d)`. -/ def run (d a : ℕ) (st : State) (w : List (Fin d)) : State := w.foldl (step d a) st /-- Pair relation: `q = a^s * p + μ`. -/ def Rel (a : ℕ) (st : State) (p q : ℤ) : Prop := q = (a : ℤ) ^ st.s * p + st.mu /-- Normalized weight `|μ| / a^s`. -/ noncomputable def weight (a : ℕ) (st : State) : ℝ := |(st.mu : ℝ)| / (a : ℝ) ^ st.s /-! ## Basic properties of `res` and `T` -/ theorem isCoprime_int_of_coprime {a d : ℕ} (hcop : Nat.Coprime a d) : IsCoprime (d : ℤ) (a : ℤ) := Nat.isCoprime_iff_coprime.mpr hcop.symm theorem res_nonneg {d a : ℕ} (hd : 0 < d) (x : ℤ) : 0 ≤ res d a x := Int.emod_nonneg _ (by omega) theorem res_lt {d a : ℕ} (hd : 0 < d) (x : ℤ) : res d a x < (d : ℤ) := Int.emod_lt_of_pos _ (by omega) theorem dvd_mul_add_res (d a : ℕ) (x : ℤ) : (d : ℤ) ∣ (a : ℤ) * x + res d a x := by apply Int.dvd_of_emod_eq_zero unfold res rw [Int.add_emod, Int.emod_emod, ← Int.add_emod] have h : (a : ℤ) * x + -(a : ℤ) * x = 0 := by ring rw [h, Int.zero_emod] theorem res_congr {d a : ℕ} {x y : ℤ} (h : x % (d : ℤ) = y % (d : ℤ)) : res d a x = res d a y := by unfold res rw [Int.mul_emod, Int.mul_emod (-(a : ℤ)) y, h] theorem res_add_mul (d a : ℕ) (x t : ℤ) : res d a (x + (d : ℤ) * t) = res d a x := by apply res_congr rw [Int.add_mul_emod_self_left] theorem res_eq_zero_iff {d a : ℕ} (hcop : Nat.Coprime a d) (x : ℤ) : res d a x = 0 ↔ (d : ℤ) ∣ x := by unfold res rw [← Int.dvd_iff_emod_eq_zero, show -(a : ℤ) * x = -((a : ℤ) * x) by ring, dvd_neg] constructor · intro h exact (isCoprime_int_of_coprime hcop).dvd_of_dvd_mul_left h · intro h exact dvd_mul_of_dvd_right h (a : ℤ) theorem res_pos_of_emod_ne_zero {d a : ℕ} (hd : 0 < d) (hcop : Nat.Coprime a d) {x : ℤ} (hx : x % (d : ℤ) ≠ 0) : 1 ≤ res d a x := by have h0 : 0 ≤ res d a x := res_nonneg hd x have hne : res d a x ≠ 0 := by intro h apply hx exact Int.emod_eq_zero_of_dvd ((res_eq_zero_iff hcop x).mp h) omega theorem d_mul_T_of_emod_eq_zero {d a : ℕ} {x : ℤ} (hx : x % (d : ℤ) = 0) : (d : ℤ) * T d a x = x := by unfold T rw [if_pos hx] exact Int.mul_ediv_cancel' (Int.dvd_of_emod_eq_zero hx) theorem d_mul_T_of_emod_ne_zero {d a : ℕ} {x : ℤ} (hx : x % (d : ℤ) ≠ 0) : (d : ℤ) * T d a x = (a : ℤ) * x + res d a x := by unfold T rw [if_neg hx] exact Int.mul_ediv_cancel' (dvd_mul_add_res d a x) theorem T_add_mul {d a : ℕ} (hd : 0 < d) (x t : ℤ) : T d a (x + (d : ℤ) * t) = T d a x + (if x % (d : ℤ) = 0 then 1 else (a : ℤ)) * t := by have hd0 : (d : ℤ) ≠ 0 := by omega apply mul_left_cancel₀ hd0 have hmod : (x + (d : ℤ) * t) % (d : ℤ) = x % (d : ℤ) := Int.add_mul_emod_self_left x d t by_cases hx : x % (d : ℤ) = 0 · rw [if_pos hx, d_mul_T_of_emod_eq_zero (by rw [hmod, hx]), mul_add, d_mul_T_of_emod_eq_zero hx] ring · rw [if_neg hx, d_mul_T_of_emod_ne_zero (by rw [hmod]; exact hx), res_add_mul, mul_add (d : ℤ) (T d a x), d_mul_T_of_emod_ne_zero hx] ring /-! ## Unfolding lemmas and `step_rel` -/ theorem State.norm_of_pos (s : ℕ) (μ : ℤ) (hs : 0 < s) : (⟨s, μ⟩ : State).norm = ⟨s, μ⟩ := by simp [State.norm, Nat.pos_iff_ne_zero.mp hs] theorem State.norm_zero (μ : ℤ) : (⟨0, μ⟩ : State).norm = ⟨0, |μ|⟩ := by simp [State.norm] theorem State.norm_s (st : State) : st.norm.s = st.s := by unfold State.norm split_ifs with h · exact h.symm · rfl theorem step_absorbed {d a : ℕ} (c : Fin d) : step d a absorbed c = absorbed := by unfold step absorbed dsimp only simp only [pow_zero, one_mul, add_zero] have hmod : (c.val : ℤ) % (d : ℤ) = (c.val : ℤ) := Int.emod_eq_of_lt (Int.natCast_nonneg _) (by exact_mod_cast c.isLt) rw [hmod] by_cases hc : c.val = 0 · simp [hc, State.norm] · simp [hc, State.norm] theorem rel_zero_iff (a : ℕ) (p q : ℤ) : Rel a absorbed p q ↔ q = p := by simp [Rel, absorbed] theorem rel_norm_or (a : ℕ) (st : State) (x y : ℤ) (h : y = (a : ℤ) ^ st.s * x + st.mu) : Rel a st.norm x y ∨ Rel a st.norm y x := by unfold State.norm split_ifs with hs · rw [hs, pow_zero, one_mul] at h rcases abs_cases st.mu with ⟨ha, _⟩ | ⟨ha, _⟩ · left show y = (a : ℤ) ^ 0 * x + |st.mu| rw [ha, pow_zero, one_mul] exact h · right show x = (a : ℤ) ^ 0 * y + |st.mu| rw [ha, pow_zero, one_mul] omega · exact Or.inl h /-- The digit of `p` modulo `d` as an element of `Fin d`. -/ def digit (d : ℕ) (hd : 0 < d) (p : ℤ) : Fin d := ⟨(p % (d : ℤ)).toNat, by have h1 : 0 ≤ p % (d : ℤ) := Int.emod_nonneg p (by omega) have h2 : p % (d : ℤ) < (d : ℤ) := Int.emod_lt_of_pos p (by omega) omega⟩ theorem digit_val_cast {d : ℕ} (hd : 0 < d) (p : ℤ) : ((digit d hd p).val : ℤ) = p % (d : ℤ) := by unfold digit dsimp only exact Int.toNat_of_nonneg (Int.emod_nonneg p (by omega)) /-- **One-step pair-chain transition lemma on `ℤ`.** If `q = a^s * p + μ`, then `(T p, T q)` (up to swapping roles when normalizing at level 0 or descending from level 0) satisfies the relation for `step d a ⟨s, μ⟩ (digit d hd p)`. -/ theorem step_rel {d a : ℕ} (hd : 0 < d) (st : State) (p q : ℤ) (h : Rel a st p q) : Rel a (step d a st (digit d hd p)) (T d a p) (T d a q) ∨ Rel a (step d a st (digit d hd p)) (T d a q) (T d a p) := by have hd0 : (d : ℤ) ≠ 0 := by omega obtain ⟨s, μ⟩ := st change q = (a : ℤ) ^ s * p + μ at h set c : Fin d := digit d hd p have hc_cast : (c.val : ℤ) = p % (d : ℤ) := digit_val_cast hd p have hq_mod : q % (d : ℤ) = ((a : ℤ) ^ s * (c.val : ℤ) + μ) % (d : ℤ) := by rw [h, hc_cast, Int.add_emod, Int.mul_emod, Int.add_emod ((a : ℤ) ^ s * (p % (d : ℤ))), Int.mul_emod ((a : ℤ) ^ s), Int.emod_emod] have hres_p : res d a p = res d a (c.val : ℤ) := by apply res_congr rw [hc_cast, Int.emod_emod] have hres_q : res d a q = res d a ((a : ℤ) ^ s * (c.val : ℤ) + μ) := res_congr hq_mod unfold step dsimp only by_cases hc0 : c.val = 0 · rw [if_pos hc0] have hp0 : p % (d : ℤ) = 0 := by rw [← hc_cast]; exact_mod_cast hc0 have hq_mod' : q % (d : ℤ) = μ % (d : ℤ) := by rw [hq_mod, hc0, Nat.cast_zero, mul_zero, zero_add] have hTp : (d : ℤ) * T d a p = p := d_mul_T_of_emod_eq_zero hp0 by_cases hqr : ((a : ℤ) ^ s * (c.val : ℤ) + μ) % (d : ℤ) = 0 · rw [if_pos hqr] have hq0 : q % (d : ℤ) = 0 := by rw [hq_mod]; exact hqr have hμ0 : μ % (d : ℤ) = 0 := by rw [← hq_mod']; exact hq0 have hTq : (d : ℤ) * T d a q = q := d_mul_T_of_emod_eq_zero hq0 have hμd : (d : ℤ) * (μ / (d : ℤ)) = μ := Int.mul_ediv_cancel' (Int.dvd_of_emod_eq_zero hμ0) apply rel_norm_or show T d a q = (a : ℤ) ^ s * T d a p + μ / (d : ℤ) apply mul_left_cancel₀ hd0 linear_combination hTq + h - (a : ℤ) ^ s * hTp - hμd · rw [if_neg hqr] have hqne : q % (d : ℤ) ≠ 0 := by rw [hq_mod]; exact hqr have hTq : (d : ℤ) * T d a q = (a : ℤ) * q + res d a q := d_mul_T_of_emod_ne_zero hqne have hres_q' : res d a q = res d a μ := res_congr hq_mod' rw [hres_q'] at hTq have hdiv : (d : ℤ) * (((a : ℤ) * μ + res d a μ) / (d : ℤ)) = (a : ℤ) * μ + res d a μ := Int.mul_ediv_cancel' (dvd_mul_add_res d a μ) left show T d a q = (a : ℤ) ^ (s + 1) * T d a p + ((a : ℤ) * μ + res d a μ) / (d : ℤ) apply mul_left_cancel₀ hd0 rw [pow_succ'] linear_combination hTq + (a : ℤ) * h - (a : ℤ) * (a : ℤ) ^ s * hTp - hdiv · rw [if_neg hc0] have hpne : p % (d : ℤ) ≠ 0 := by rw [← hc_cast] exact_mod_cast hc0 have hTp : (d : ℤ) * T d a p = (a : ℤ) * p + res d a (c.val : ℤ) := by rw [← hres_p] exact d_mul_T_of_emod_ne_zero hpne by_cases hqr : ((a : ℤ) ^ s * (c.val : ℤ) + μ) % (d : ℤ) = 0 · rw [if_pos hqr] have hq0 : q % (d : ℤ) = 0 := by rw [hq_mod]; exact hqr have hTq : (d : ℤ) * T d a q = q := d_mul_T_of_emod_eq_zero hq0 cases s with | zero => rw [pow_zero, one_mul] at h hqr have hdvd : (d : ℤ) ∣ res d a (c.val : ℤ) - (a : ℤ) * μ := by have h1 : (d : ℤ) ∣ (a : ℤ) * (c.val : ℤ) + res d a (c.val : ℤ) := dvd_mul_add_res d a (c.val : ℤ) have h2 : (d : ℤ) ∣ (a : ℤ) * ((c.val : ℤ) + μ) := dvd_mul_of_dvd_right (Int.dvd_of_emod_eq_zero hqr) (a : ℤ) have h3 : res d a (c.val : ℤ) - (a : ℤ) * μ = ((a : ℤ) * (c.val : ℤ) + res d a (c.val : ℤ)) - (a : ℤ) * ((c.val : ℤ) + μ) := by ring rw [h3] exact dvd_sub h1 h2 have hdiv : (d : ℤ) * ((res d a (c.val : ℤ) - (a : ℤ) * μ) / (d : ℤ)) = res d a (c.val : ℤ) - (a : ℤ) * μ := Int.mul_ediv_cancel' hdvd right show T d a p = (a : ℤ) ^ 1 * T d a q + (res d a (c.val : ℤ) - (a : ℤ) * μ) / (d : ℤ) apply mul_left_cancel₀ hd0 rw [pow_one] linear_combination hTp - (a : ℤ) * hTq - (a : ℤ) * h - hdiv | succ s' => have hdvd : (d : ℤ) ∣ μ - (a : ℤ) ^ s' * res d a (c.val : ℤ) := by have h1 : (d : ℤ) ∣ (a : ℤ) ^ (s' + 1) * (c.val : ℤ) + μ := Int.dvd_of_emod_eq_zero hqr have h2 : (d : ℤ) ∣ (a : ℤ) ^ s' * ((a : ℤ) * (c.val : ℤ) + res d a (c.val : ℤ)) := dvd_mul_of_dvd_right (dvd_mul_add_res d a (c.val : ℤ)) _ have h3 : μ - (a : ℤ) ^ s' * res d a (c.val : ℤ) = ((a : ℤ) ^ (s' + 1) * (c.val : ℤ) + μ) - (a : ℤ) ^ s' * ((a : ℤ) * (c.val : ℤ) + res d a (c.val : ℤ)) := by rw [pow_succ] ring rw [h3] exact dvd_sub h1 h2 have hdiv : (d : ℤ) * ((μ - (a : ℤ) ^ s' * res d a (c.val : ℤ)) / (d : ℤ)) = μ - (a : ℤ) ^ s' * res d a (c.val : ℤ) := Int.mul_ediv_cancel' hdvd apply rel_norm_or show T d a q = (a : ℤ) ^ s' * T d a p + (μ - (a : ℤ) ^ s' * res d a (c.val : ℤ)) / (d : ℤ) apply mul_left_cancel₀ hd0 rw [pow_succ] at h linear_combination hTq + h - (a : ℤ) ^ s' * hTp - hdiv · rw [if_neg hqr] have hqne : q % (d : ℤ) ≠ 0 := by rw [hq_mod]; exact hqr have hTq : (d : ℤ) * T d a q = (a : ℤ) * q + res d a ((a : ℤ) ^ s * (c.val : ℤ) + μ) := by rw [← hres_q] exact d_mul_T_of_emod_ne_zero hqne have hdvd : (d : ℤ) ∣ (a : ℤ) * μ + res d a ((a : ℤ) ^ s * (c.val : ℤ) + μ) - (a : ℤ) ^ s * res d a (c.val : ℤ) := by have h1 : (d : ℤ) ∣ (a : ℤ) * ((a : ℤ) ^ s * (c.val : ℤ) + μ) + res d a ((a : ℤ) ^ s * (c.val : ℤ) + μ) := dvd_mul_add_res d a _ have h2 : (d : ℤ) ∣ (a : ℤ) ^ s * ((a : ℤ) * (c.val : ℤ) + res d a (c.val : ℤ)) := dvd_mul_of_dvd_right (dvd_mul_add_res d a _) _ have h3 : (a : ℤ) * μ + res d a ((a : ℤ) ^ s * (c.val : ℤ) + μ) - (a : ℤ) ^ s * res d a (c.val : ℤ) = ((a : ℤ) * ((a : ℤ) ^ s * (c.val : ℤ) + μ) + res d a ((a : ℤ) ^ s * (c.val : ℤ) + μ)) - (a : ℤ) ^ s * ((a : ℤ) * (c.val : ℤ) + res d a (c.val : ℤ)) := by ring rw [h3] exact dvd_sub h1 h2 have hdiv : (d : ℤ) * (((a : ℤ) * μ + res d a ((a : ℤ) ^ s * (c.val : ℤ) + μ) - (a : ℤ) ^ s * res d a (c.val : ℤ)) / (d : ℤ)) = (a : ℤ) * μ + res d a ((a : ℤ) ^ s * (c.val : ℤ) + μ) - (a : ℤ) ^ s * res d a (c.val : ℤ) := Int.mul_ediv_cancel' hdvd apply rel_norm_or show T d a q = (a : ℤ) ^ s * T d a p + ((a : ℤ) * μ + res d a ((a : ℤ) ^ s * (c.val : ℤ) + μ) - (a : ℤ) ^ s * res d a (c.val : ℤ)) / (d : ℤ) apply mul_left_cancel₀ hd0 linear_combination hTq + (a : ℤ) * h - (a : ℤ) ^ s * hTp - hdiv /-! ## d-ary Expectation and Absorption Probability -/ /-- Expected value of `f` after `k` uniform `Fin d` steps. -/ noncomputable def E {S : Type*} {d : ℕ} (stepFn : S → Fin d → S) (f : S → ℝ) : ℕ → S → ℝ | 0, st => f st | k + 1, st => (∑ c : Fin d, E stepFn f k (stepFn st c)) / (d : ℝ) /-- Probability of sitting at `abs` after `k` uniform `Fin d` steps. -/ noncomputable def pAbs {S : Type*} [DecidableEq S] {d : ℕ} (stepFn : S → Fin d → S) (abs : S) (k : ℕ) (st : S) : ℝ := E stepFn (fun t => if t = abs then 1 else 0) k st theorem pAbs_zero {S : Type*} [DecidableEq S] {d : ℕ} (stepFn : S → Fin d → S) (abs st : S) : pAbs stepFn abs 0 st = if st = abs then 1 else 0 := rfl theorem pAbs_succ {S : Type*} [DecidableEq S] {d : ℕ} (stepFn : S → Fin d → S) (abs : S) (k : ℕ) (st : S) : pAbs stepFn abs (k + 1) st = (∑ c : Fin d, pAbs stepFn abs k (stepFn st c)) / (d : ℝ) := rfl /-! ## Merged Residue Classes on `ℤ` and `ZMod (d^k)` -/ /-- The pair `(P, a^s * P + μ)` has merged after `k` steps of `T d a`. -/ def Phi (d a : ℕ) (st : State) (k : ℕ) (P : ℤ) : Prop := (T d a)^[k] P = (T d a)^[k] ((a : ℤ) ^ st.s * P + st.mu) /-- The entire residue class `x mod d^k` has merged after `k` steps. -/ def Good (d a : ℕ) (st : State) (k : ℕ) (x : ℤ) : Prop := ∀ t : ℤ, Phi d a st k (x + (d : ℤ) ^ k * t) open Classical in /-- Merged residue classes `r ∈ {0, ..., d^k - 1}` for pair state `st`. -/ noncomputable def merged (d a : ℕ) (st : State) (k : ℕ) : Finset ℕ := (Finset.range (d ^ k)).filter fun p => Good d a st k (p : ℤ) /-- Number `C_k(d, a, m)` of merged residue classes mod `d^k` for offset `m`. -/ noncomputable def C_k (d a : ℕ) (m : ℤ) (k : ℕ) : ℕ := (merged d a ⟨0, m⟩ k).card open Classical in /-- Merged residue classes as a subset of `ZMod (d ^ k)`. -/ noncomputable def mergedZMod (d a : ℕ) (st : State) (k : ℕ) [NeZero (d ^ k)] : Finset (ZMod (d ^ k)) := Finset.univ.filter fun x => Good d a st k (x.val : ℤ) theorem card_mergedZMod_eq {d a : ℕ} (hd : 0 < d) (st : State) (k : ℕ) [NeZero (d ^ k)] : (mergedZMod d a st k).card = (merged d a st k).card := by have _ := hd apply Finset.card_bij (fun (x : ZMod (d ^ k)) _ => x.val) · intro x hx simp only [mergedZMod, Finset.mem_filter, Finset.mem_univ, true_and] at hx simp only [merged, Finset.mem_filter, Finset.mem_range] exact ⟨ZMod.val_lt x, hx⟩ · intro x _ y _ hxy exact ZMod.val_injective (d ^ k) hxy · intro p hp simp only [merged, Finset.mem_filter, Finset.mem_range] at hp refine ⟨(p : ZMod (d ^ k)), ?_, ZMod.val_natCast_of_lt hp.1⟩ simp only [mergedZMod, Finset.mem_filter, Finset.mem_univ, true_and] rw [ZMod.val_natCast_of_lt hp.1] exact hp.2 theorem mem_merged (d a : ℕ) (st : State) (k p : ℕ) : p ∈ merged d a st k ↔ p < d ^ k ∧ Good d a st k (p : ℤ) := by simp only [merged, Finset.mem_filter, Finset.mem_range] theorem good_add_mul (d a : ℕ) (st : State) (k : ℕ) (x u : ℤ) : Good d a st k (x + (d : ℤ) ^ k * u) ↔ Good d a st k x := by constructor · intro H t have h := H (t - u) rwa [show x + (d : ℤ) ^ k * u + (d : ℤ) ^ k * (t - u) = x + (d : ℤ) ^ k * t by ring] at h · intro H t have h := H (u + t) rwa [show x + (d : ℤ) ^ k * (u + t) = x + (d : ℤ) ^ k * u + (d : ℤ) ^ k * t by ring] at h theorem good_emod (d a : ℕ) (st : State) (k : ℕ) (x : ℤ) : Good d a st k (x % (d : ℤ) ^ k) ↔ Good d a st k x := by have e : x = x % (d : ℤ) ^ k + (d : ℤ) ^ k * (x / (d : ℤ) ^ k) := (Int.emod_add_mul_ediv x ((d : ℤ) ^ k)).symm conv_rhs => rw [e] exact (good_add_mul d a st k _ _).symm /-! ## Affine structure of `(T d a)^[k]` on a class mod `d^k` -/ /-- Number of non-divisible steps among `x, T x, ..., T^[k-1] x`. -/ def nonDivCount (d a : ℕ) : ℕ → ℤ → ℕ | 0, _ => 0 | k + 1, x => (if x % (d : ℤ) = 0 then 0 else 1) + nonDivCount d a k (T d a x) theorem T_iterate_add {d a : ℕ} (hd : 0 < d) (k : ℕ) (x t : ℤ) : (T d a)^[k] (x + (d : ℤ) ^ k * t) = (T d a)^[k] x + (a : ℤ) ^ nonDivCount d a k x * t := by induction k generalizing x t with | zero => simp [nonDivCount] | succ k ih => have e : x + (d : ℤ) ^ (k + 1) * t = x + (d : ℤ) * ((d : ℤ) ^ k * t) := by rw [pow_succ'] ring rw [Function.iterate_succ_apply, Function.iterate_succ_apply, e, T_add_mul hd] by_cases hx : x % (d : ℤ) = 0 · simp only [if_pos hx, one_mul, nonDivCount, zero_add] exact ih (T d a x) t · simp only [if_neg hx, nonDivCount] have e' : T d a x + (a : ℤ) * ((d : ℤ) ^ k * t) = T d a x + (d : ℤ) ^ k * ((a : ℤ) * t) := by ring rw [e', ih (T d a x) ((a : ℤ) * t), pow_add, pow_one] ring /-- If merging holds along a progression `y + d^k * (g * t)` with `g ≠ 0`, it holds on the whole residue class `y mod d^k`. -/ theorem good_of_thin {d a : ℕ} (hd : 0 < d) (st : State) (k : ℕ) (y g : ℤ) (hg : g ≠ 0) (H : ∀ t : ℤ, Phi d a st k (y + (d : ℤ) ^ k * (g * t))) : Good d a st k y := by have e1 : ∀ t : ℤ, (T d a)^[k] (y + (d : ℤ) ^ k * t) = (T d a)^[k] y + (a : ℤ) ^ nonDivCount d a k y * t := T_iterate_add hd k y have e2 : ∀ t : ℤ, (T d a)^[k] ((a : ℤ) ^ st.s * (y + (d : ℤ) ^ k * t) + st.mu) = (T d a)^[k] ((a : ℤ) ^ st.s * y + st.mu) + (a : ℤ) ^ nonDivCount d a k ((a : ℤ) ^ st.s * y + st.mu) * ((a : ℤ) ^ st.s * t) := by intro t rw [← T_iterate_add hd] congr 1 ring have h0 := H 0 have h1 := H 1 unfold Phi at h0 h1 rw [e1, e2] at h0 h1 have hβ : ((a : ℤ) ^ nonDivCount d a k y - (a : ℤ) ^ nonDivCount d a k ((a : ℤ) ^ st.s * y + st.mu) * (a : ℤ) ^ st.s) * g = 0 := by linear_combination h1 - h0 have hβ' := (mul_eq_zero.mp hβ).resolve_right hg intro t unfold Phi rw [e1, e2] linear_combination h0 + t * hβ' /-! ## Affine bijections on residues mod `d^k` and on `ZMod (d^k)` -/ /-- Affine map `p ↦ (g * p + h) mod d^k` on `{0, ..., d^k - 1}`. -/ def sig (d k : ℕ) (g h : ℤ) (p : ℕ) : ℕ := ((g * (p : ℤ) + h) % (d : ℤ) ^ k).toNat /-- Affine map `x ↦ g * x + h` on `ZMod (d^k)`. -/ def sigZMod (d k : ℕ) (g h : ℤ) (x : ZMod (d ^ k)) : ZMod (d ^ k) := (g : ZMod (d ^ k)) * x + (h : ZMod (d ^ k)) theorem sig_cast {d : ℕ} (hd : 0 < d) (k : ℕ) (g h : ℤ) (p : ℕ) : ((sig d k g h p : ℕ) : ℤ) = (g * (p : ℤ) + h) % (d : ℤ) ^ k := by unfold sig exact Int.toNat_of_nonneg (Int.emod_nonneg _ (by positivity)) theorem sig_lt {d : ℕ} (hd : 0 < d) (k : ℕ) (g h : ℤ) (p : ℕ) : sig d k g h p < d ^ k := by have h1 : (g * (p : ℤ) + h) % (d : ℤ) ^ k < (d : ℤ) ^ k := Int.emod_lt_of_pos _ (by positivity) have h2 : ((sig d k g h p : ℕ) : ℤ) < ((d ^ k : ℕ) : ℤ) := by rw [sig_cast hd] push_cast exact h1 exact_mod_cast h2 theorem sig_inj {d : ℕ} (hd : 0 < d) (k : ℕ) (g h : ℤ) (hg : IsCoprime (d : ℤ) g) {p p' : ℕ} (hp : p < d ^ k) (hp' : p' < d ^ k) (hpp : sig d k g h p = sig d k g h p') : p = p' := by have hpZ : (p : ℤ) < (d : ℤ) ^ k := by exact_mod_cast hp have hpZ' : (p' : ℤ) < (d : ℤ) ^ k := by exact_mod_cast hp' have h1 : (g * (p : ℤ) + h) % (d : ℤ) ^ k = (g * (p' : ℤ) + h) % (d : ℤ) ^ k := by rw [← sig_cast hd, ← sig_cast hd, hpp] have h2 : ((d : ℤ) ^ k) ∣ (g * (p' : ℤ) + h) - (g * (p : ℤ) + h) := Int.ModEq.dvd h1 have h3 : ((d : ℤ) ^ k) ∣ ((p' : ℤ) - (p : ℤ)) * g := by have e : (g * (p' : ℤ) + h) - (g * (p : ℤ) + h) = ((p' : ℤ) - (p : ℤ)) * g := by ring rwa [e] at h2 have h4 : ((d : ℤ) ^ k) ∣ (p' : ℤ) - (p : ℤ) := hg.pow_left.dvd_of_dvd_mul_right h3 have h5 : (p' : ℤ) - (p : ℤ) = 0 := Int.eq_zero_of_abs_lt_dvd h4 (abs_lt.mpr ⟨by omega, by omega⟩) omega theorem sig_surj {d : ℕ} (hd : 0 < d) (k : ℕ) (g h : ℤ) (hg : IsCoprime (d : ℤ) g) (b : ℕ) (hb : b < d ^ k) : ∃ p, p < d ^ k ∧ sig d k g h p = b := by have hinj : Set.InjOn (sig d k g h) (Finset.range (d ^ k) : Set ℕ) := by intro p hp p' hp' hpp exact sig_inj hd k g h hg (Finset.mem_range.mp hp) (Finset.mem_range.mp hp') hpp have hsub : (Finset.range (d ^ k)).image (sig d k g h) ⊆ Finset.range (d ^ k) := by intro x hx obtain ⟨p, _, rfl⟩ := Finset.mem_image.mp hx exact Finset.mem_range.mpr (sig_lt hd k g h p) have heq : (Finset.range (d ^ k)).image (sig d k g h) = Finset.range (d ^ k) := Finset.eq_of_subset_of_card_le hsub (by rw [Finset.card_image_of_injOn hinj]) have hb' : b ∈ (Finset.range (d ^ k)).image (sig d k g h) := by rw [heq] exact Finset.mem_range.mpr hb obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hb' exact ⟨p, Finset.mem_range.mp hp, rfl⟩ /-- `sigZMod` is a bijection on `ZMod (d^k)` whenever `IsCoprime (d : ℤ) g`. -/ theorem sigZMod_bijective {d : ℕ} (k : ℕ) (g h : ℤ) (hg : IsCoprime (d : ℤ) g) : Function.Bijective (sigZMod d k g h) := by obtain ⟨u, v, huv⟩ := hg.pow_left (m := k) have hunit : (g : ZMod (d ^ k)) * (v : ZMod (d ^ k)) = 1 := by have hcast : ((u * (d : ℤ) ^ k + v * g : ℤ) : ZMod (d ^ k)) = ((1 : ℤ) : ZMod (d ^ k)) := congrArg Int.cast huv have hdzero : ((d : ZMod (d ^ k)) ^ k) = 0 := by rw [← Nat.cast_pow, ZMod.natCast_self] push_cast at hcast rw [hdzero, mul_zero, zero_add] at hcast linear_combination hcast refine ⟨fun x y hxy => ?_, fun y => ?_⟩ · have h1 : (g : ZMod (d ^ k)) * x = (g : ZMod (d ^ k)) * y := by unfold sigZMod at hxy exact add_right_cancel hxy have h2 : (v : ZMod (d ^ k)) * ((g : ZMod (d ^ k)) * x) = (v : ZMod (d ^ k)) * ((g : ZMod (d ^ k)) * y) := congrArg _ h1 linear_combination h2 - x * hunit + y * hunit · refine ⟨(v : ZMod (d ^ k)) * (y - (h : ZMod (d ^ k))), ?_⟩ unfold sigZMod linear_combination (y - (h : ZMod (d ^ k))) * hunit /-! ## One-step affine transition lemma and counting recursion -/ theorem aff_ext (a₁ b₁ A₁ B₁ D M : ℤ) {u v : ℤ} (huv : u ≠ v) (hu : A₁ * u + B₁ = D * (a₁ * u + b₁) + M) (hv : A₁ * v + B₁ = D * (a₁ * v + b₁) + M) (w : ℤ) : A₁ * w + B₁ = D * (a₁ * w + b₁) + M := by have h : (A₁ - D * a₁) * (u - v) = 0 := by linear_combination hu - hv have hp : A₁ - D * a₁ = 0 := (mul_eq_zero.mp h).resolve_right (sub_ne_zero.mpr huv) linear_combination hu + (w - u) * hp theorem affine_dichotomy (a₁ b₁ A₁ B₁ D M : ℤ) (R : ∀ u : ℤ, A₁ * u + B₁ = D * (a₁ * u + b₁) + M ∨ a₁ * u + b₁ = D * (A₁ * u + B₁) + M) : (∀ u : ℤ, A₁ * u + B₁ = D * (a₁ * u + b₁) + M) ∨ (∀ u : ℤ, a₁ * u + b₁ = D * (A₁ * u + B₁) + M) := by have h01 : (0 : ℤ) ≠ 1 := by norm_num have h02 : (0 : ℤ) ≠ 2 := by norm_num have h12 : (1 : ℤ) ≠ 2 := by norm_num rcases R 0 with h0 | h0 <;> rcases R 1 with h1 | h1 <;> rcases R 2 with h2 | h2 · exact Or.inl (aff_ext a₁ b₁ A₁ B₁ D M h01 h0 h1) · exact Or.inl (aff_ext a₁ b₁ A₁ B₁ D M h01 h0 h1) · exact Or.inl (aff_ext a₁ b₁ A₁ B₁ D M h02 h0 h2) · exact Or.inr (aff_ext A₁ B₁ a₁ b₁ D M h12 h1 h2) · exact Or.inl (aff_ext a₁ b₁ A₁ B₁ D M h12 h1 h2) · exact Or.inr (aff_ext A₁ B₁ a₁ b₁ D M h02 h0 h2) · exact Or.inr (aff_ext A₁ B₁ a₁ b₁ D M h01 h0 h1) · exact Or.inr (aff_ext A₁ B₁ a₁ b₁ D M h01 h0 h1) theorem digit_mul_add {d : ℕ} (hd : 0 < d) (c : Fin d) (u : ℤ) : digit d hd ((d : ℤ) * u + (c.val : ℤ)) = c := by apply Fin.ext have h1 : ((d : ℤ) * u + (c.val : ℤ)) % (d : ℤ) = (c.val : ℤ) := by rw [add_comm, Int.add_mul_emod_self_left] exact Int.emod_eq_of_lt (Int.natCast_nonneg _) (by exact_mod_cast c.isLt) have h2 := digit_val_cast hd ((d : ℤ) * u + (c.val : ℤ)) rw [h1] at h2 exact_mod_cast h2 /-- **One-step affine transition lemma.** On the residue class `x = d * u + c`, merging after `k + 1` steps from state `st` is equivalent to merging after `k` steps from `step d a st c` at an affine point `g * u + h` with `g` coprime to `d` (and `g ≠ 0`). -/ theorem step_affine {d a : ℕ} (hd : 2 ≤ d) (ha : 1 < a) (hcop : Nat.Coprime a d) (st : State) (c : Fin d) : ∃ g h : ℤ, IsCoprime (d : ℤ) g ∧ g ≠ 0 ∧ ∀ (k : ℕ) (u : ℤ), Phi d a st (k + 1) ((d : ℤ) * u + (c.val : ℤ)) ↔ Phi d a (step d a st c) k (g * u + h) := by have hdpos : 0 < d := by omega have hcopZ : IsCoprime (d : ℤ) (a : ℤ) := isCoprime_int_of_coprime hcop have ha0 : (a : ℤ) ≠ 0 := by omega -- `T (d * u + c)` is affine in `u` obtain ⟨a₁, b₁, ha₁_cop, ha₁_ne, hab₁⟩ : ∃ a₁ b₁ : ℤ, IsCoprime (d : ℤ) a₁ ∧ a₁ ≠ 0 ∧ ∀ u : ℤ, T d a ((d : ℤ) * u + (c.val : ℤ)) = a₁ * u + b₁ := by refine ⟨if (c.val : ℤ) % (d : ℤ) = 0 then 1 else (a : ℤ), T d a (c.val : ℤ), ?_, ?_, fun u => ?_⟩ · split_ifs · exact isCoprime_one_right · exact hcopZ · split_ifs · norm_num · exact ha0 · rw [show (d : ℤ) * u + (c.val : ℤ) = (c.val : ℤ) + (d : ℤ) * u by ring, T_add_mul hdpos] ring -- `T (a^s * (d * u + c) + μ)` is affine in `u` obtain ⟨A₁, B₁, hA₁_cop, hA₁_ne, hAB₁⟩ : ∃ A₁ B₁ : ℤ, IsCoprime (d : ℤ) A₁ ∧ A₁ ≠ 0 ∧ ∀ u : ℤ, T d a ((a : ℤ) ^ st.s * ((d : ℤ) * u + (c.val : ℤ)) + st.mu) = A₁ * u + B₁ := by refine ⟨(if ((a : ℤ) ^ st.s * (c.val : ℤ) + st.mu) % (d : ℤ) = 0 then 1 else (a : ℤ)) * (a : ℤ) ^ st.s, T d a ((a : ℤ) ^ st.s * (c.val : ℤ) + st.mu), ?_, ?_, fun u => ?_⟩ · apply IsCoprime.mul_right · split_ifs · exact isCoprime_one_right · exact hcopZ · exact hcopZ.pow_right · apply mul_ne_zero · split_ifs · norm_num · exact ha0 · exact pow_ne_zero _ ha0 · rw [show (a : ℤ) ^ st.s * ((d : ℤ) * u + (c.val : ℤ)) + st.mu = ((a : ℤ) ^ st.s * (c.val : ℤ) + st.mu) + (d : ℤ) * ((a : ℤ) ^ st.s * u) by ring, T_add_mul hdpos] ring have R : ∀ u : ℤ, A₁ * u + B₁ = (a : ℤ) ^ (step d a st c).s * (a₁ * u + b₁) + (step d a st c).mu ∨ a₁ * u + b₁ = (a : ℤ) ^ (step d a st c).s * (A₁ * u + B₁) + (step d a st c).mu := by intro u have h := step_rel hdpos st ((d : ℤ) * u + (c.val : ℤ)) ((a : ℤ) ^ st.s * ((d : ℤ) * u + (c.val : ℤ)) + st.mu) rfl rw [digit_mul_add hdpos c u, hab₁ u, hAB₁ u] at h exact h rcases affine_dichotomy a₁ b₁ A₁ B₁ _ _ R with H | H · refine ⟨a₁, b₁, ha₁_cop, ha₁_ne, fun k u => ?_⟩ unfold Phi rw [Function.iterate_succ_apply, Function.iterate_succ_apply, hab₁ u, hAB₁ u, H u] · refine ⟨A₁, B₁, hA₁_cop, hA₁_ne, fun k u => ?_⟩ unfold Phi rw [Function.iterate_succ_apply, Function.iterate_succ_apply, hab₁ u, hAB₁ u, H u] exact eq_comm theorem good_succ_iff {d a : ℕ} (hd : 0 < d) (st : State) (c : Fin d) (g h : ℤ) (hg_ne : g ≠ 0) (k : ℕ) (H : ∀ u : ℤ, Phi d a st (k + 1) ((d : ℤ) * u + (c.val : ℤ)) ↔ Phi d a (step d a st c) k (g * u + h)) (p' : ℕ) : Good d a st (k + 1) ((d * p' + c.val : ℕ) : ℤ) ↔ Good d a (step d a st c) k (sig d k g h p') := by rw [sig_cast hd, good_emod] have key : ∀ t : ℤ, Phi d a st (k + 1) (((d * p' + c.val : ℕ) : ℤ) + (d : ℤ) ^ (k + 1) * t) ↔ Phi d a (step d a st c) k (g * (p' : ℤ) + h + (d : ℤ) ^ k * (g * t)) := by intro t have e1 : ((d * p' + c.val : ℕ) : ℤ) + (d : ℤ) ^ (k + 1) * t = (d : ℤ) * ((p' : ℤ) + (d : ℤ) ^ k * t) + (c.val : ℤ) := by push_cast rw [pow_succ'] ring have e2 : g * (p' : ℤ) + h + (d : ℤ) ^ k * (g * t) = g * ((p' : ℤ) + (d : ℤ) ^ k * t) + h := by ring rw [e1, e2] exact H _ constructor · intro G apply good_of_thin hd _ _ _ g hg_ne intro t exact (key t).mp (G t) · intro G t exact (key t).mpr (G (g * t)) theorem card_residue {d a : ℕ} (hd : 2 ≤ d) (ha : 1 < a) (hcop : Nat.Coprime a d) (st : State) (k : ℕ) (c : Fin d) : ((merged d a st (k + 1)).filter (fun p => p % d = c.val)).card = (merged d a (step d a st c) k).card := by have hdpos : 0 < d := by omega obtain ⟨g, h, hg_cop, hg_ne, H⟩ := step_affine hd ha hcop st c apply Finset.card_bij (fun p _ => sig d k g h (p / d)) · intro p hp rw [Finset.mem_filter, mem_merged] at hp obtain ⟨⟨_, hG⟩, hmod⟩ := hp rw [mem_merged] refine ⟨sig_lt hdpos k g h _, ?_⟩ have e : d * (p / d) + c.val = p := by have := Nat.div_add_mod p d omega have hG' : Good d a st (k + 1) ((d * (p / d) + c.val : ℕ) : ℤ) := by rw [e] exact hG exact (good_succ_iff hdpos st c g h hg_ne k (H k) (p / d)).mp hG' · intro p₁ hp₁ p₂ hp₂ heq rw [Finset.mem_filter, mem_merged] at hp₁ hp₂ have hlt₁ : p₁ < d ^ k * d := by rw [← pow_succ]; exact hp₁.1.1 have hlt₂ : p₂ < d ^ k * d := by rw [← pow_succ]; exact hp₂.1.1 have h1 : p₁ / d < d ^ k := (Nat.div_lt_iff_lt_mul hdpos).mpr hlt₁ have h2 : p₂ / d < d ^ k := (Nat.div_lt_iff_lt_mul hdpos).mpr hlt₂ have h3 : p₁ / d = p₂ / d := sig_inj hdpos k g h hg_cop h1 h2 heq have hmul : d * (p₁ / d) = d * (p₂ / d) := congrArg (d * ·) h3 have hm₁ := hp₁.2 have hm₂ := hp₂.2 have e₁ := Nat.div_add_mod p₁ d have e₂ := Nat.div_add_mod p₂ d omega · intro b hb rw [mem_merged] at hb obtain ⟨q, hq, rfl⟩ := sig_surj hdpos k g h hg_cop b hb.1 refine ⟨d * q + c.val, ?_, ?_⟩ · rw [Finset.mem_filter, mem_merged] refine ⟨⟨?_, ?_⟩, ?_⟩ · rw [pow_succ'] have h1 : d * q + d ≤ d * d ^ k := by have : q + 1 ≤ d ^ k := hq calc d * q + d = d * (q + 1) := by ring _ ≤ d * d ^ k := Nat.mul_le_mul_left d this omega · exact (good_succ_iff hdpos st c g h hg_ne k (H k) q).mpr hb.2 · rw [Nat.mul_add_mod, Nat.mod_eq_of_lt c.isLt] · have e : (d * q + c.val) / d = q := by rw [Nat.mul_add_div hdpos, Nat.div_eq_of_lt c.isLt, add_zero] show sig d k g h ((d * q + c.val) / d) = sig d k g h q rw [e] theorem card_merged_zero {d a : ℕ} (ha : 1 < a) (st : State) : (merged d a st 0).card = if st = absorbed then 1 else 0 := by split_ifs with hs · subst hs have hm : merged d a absorbed 0 = {0} := by ext p rw [mem_merged, Finset.mem_singleton] constructor · rintro ⟨hp, _⟩ simpa using hp · rintro rfl refine ⟨by norm_num, fun t => ?_⟩ simp [Phi, absorbed] rw [hm] rfl · have hm : merged d a st 0 = ∅ := by apply Finset.eq_empty_of_forall_notMem intro p hp rw [mem_merged] at hp obtain ⟨hp0, hG⟩ := hp have hp0' : p = 0 := by simpa using hp0 subst hp0' obtain ⟨s, μ⟩ := st have h0 := hG 0 have h1 := hG 1 unfold Phi at h0 h1 simp only [Function.iterate_zero, id_eq, Nat.cast_zero, pow_zero, mul_zero, add_zero, zero_add, mul_one] at h0 h1 have hμ : μ = 0 := h0.symm subst hμ rw [add_zero] at h1 have hs0 : s = 0 := by rcases Nat.eq_zero_or_pos s with rfl | hspos · rfl · exfalso have hpow : (1 : ℤ) < (a : ℤ) ^ s := one_lt_pow₀ (by exact_mod_cast ha) hspos.ne' omega exact hs (by rw [hs0]; rfl) rw [hm] rfl theorem card_merged_succ {d a : ℕ} (hd : 2 ≤ d) (ha : 1 < a) (hcop : Nat.Coprime a d) (st : State) (k : ℕ) : (merged d a st (k + 1)).card = ∑ c : Fin d, (merged d a (step d a st c) k).card := by have hdpos : 0 < d := by omega have hpart : merged d a st (k + 1) = Finset.univ.biUnion (fun c : Fin d => (merged d a st (k + 1)).filter (fun p => p % d = c.val)) := by ext p simp only [Finset.mem_biUnion, Finset.mem_univ, true_and, Finset.mem_filter] constructor · intro hp exact ⟨⟨p % d, Nat.mod_lt p hdpos⟩, hp, rfl⟩ · rintro ⟨_, hp, _⟩ exact hp have hdisj : Set.PairwiseDisjoint (↑(Finset.univ : Finset (Fin d)) : Set (Fin d)) (fun (c : Fin d) => (merged d a st (k + 1)).filter (fun p => p % d = c.val)) := by intro c₁ _ c₂ _ hne dsimp only [Function.onFun] rw [Finset.disjoint_filter] intro p _ h1 h2 apply hne exact Fin.ext (by omega) conv_lhs => rw [hpart] rw [Finset.card_biUnion hdisj] exact Finset.sum_congr rfl fun c _ => card_residue hd ha hcop st k c /-- **Exact link between merged residue classes and the pair chain.** -/ theorem card_merged_eq {d a : ℕ} (hd : 2 ≤ d) (ha : 1 < a) (hcop : Nat.Coprime a d) : ∀ (k : ℕ) (st : State), ((merged d a st k).card : ℝ) = pAbs (step d a) absorbed k st * (d : ℝ) ^ k | 0, st => by rw [card_merged_zero ha, pAbs_zero] split_ifs <;> simp | k + 1, st => by have hd0 : (d : ℝ) ≠ 0 := by positivity rw [card_merged_succ hd ha hcop, Nat.cast_sum, pAbs_succ] simp_rw [card_merged_eq hd ha hcop k] rw [← Finset.sum_mul, pow_succ] field_simp /-- **Link for `C_k(d, a, m)`.** -/ theorem C_k_div_pow_eq_pAbs {d a : ℕ} (hd : 2 ≤ d) (ha : 1 < a) (hcop : Nat.Coprime a d) (m : ℤ) (k : ℕ) : ((C_k d a m k : ℕ) : ℝ) / (d : ℝ) ^ k = pAbs (step d a) absorbed k ⟨0, m⟩ := by have hdk : (d : ℝ) ^ k ≠ 0 := pow_ne_zero k (by positivity) unfold C_k rw [card_merged_eq hd ha hcop k ⟨0, m⟩, mul_div_cancel_right₀ _ hdk] end DAdicCollatz #print axioms DAdicCollatz.step_rel #print axioms DAdicCollatz.step_affine #print axioms DAdicCollatz.sigZMod_bijective #print axioms DAdicCollatz.card_mergedZMod_eq #print axioms DAdicCollatz.card_merged_eq #print axioms DAdicCollatz.C_k_div_pow_eq_pAbs