import Mathlib.Tactic /-- Bonza property, stated in `ℤ` to avoid subtraction issues in `ℕ`. -/ def Bonza (f : ℕ → ℕ) : Prop := (∀ a b : ℕ, 0 < a → 0 < b → (f a : ℤ) ∣ (b : ℤ)^a - (f b : ℤ)^(f a)) ∧ (∀ n : ℕ, 0 < n → 0 < f n) namespace Bonza variable {f : ℕ → ℕ} lemma pos (hf : Bonza f) {n : ℕ} (hn : 0 < n) : 0 < f n := hf.2 n hn /-- Any bonza function satisfies `f 1 = 1`. -/ lemma f_one (hf : Bonza f) : f 1 = 1 := by have hdiv := hf.1 1 1 (by decide) (by decide) -- `f(1) ∣ 1 - f(1)^(f(1))` have hpow : (f 1 : ℤ) ∣ (f 1 : ℤ)^(f 1) := by have hf1 : f 1 ≠ 0 := Nat.ne_of_gt (hf.2 1 (by decide)) -- `dvd_pow` needs exponent nonzero exact dvd_pow (dvd_rfl) (by intro h exact hf1 (by simpa using h)) -- add the two divisible integers to get `1` have hone : (f 1 : ℤ) ∣ (1 : ℤ) := by -- (1 - x) + x = 1 have := dvd_add hdiv hpow simpa [sub_eq_add_neg, add_assoc, add_left_comm, add_comm] using this -- convert to `ℕ` have : f 1 ∣ 1 := (Int.ofNat_dvd.mp (by simpa using hone)) exact Nat.dvd_one.mp this /-- For bonza functions, `f a ∣ a^a` for all `a>0`. -/ lemma f_dvd_self_pow (hf : Bonza f) {a : ℕ} (ha : 0 < a) : f a ∣ a^a := by have hdiv := hf.1 a a ha ha have hfpos : 0 < f a := hf.2 a ha have hpow : (f a : ℤ) ∣ (f a : ℤ)^(f a) := by have hfa0 : f a ≠ 0 := Nat.ne_of_gt hfpos exact dvd_pow (dvd_rfl) (by intro h exact hfa0 (by simpa using h)) have hz : (f a : ℤ) ∣ (a : ℤ)^a := by -- (a^a - f(a)^(f(a))) + f(a)^(f(a)) = a^a have := dvd_add hdiv hpow -- simplify simpa [sub_eq_add_neg, add_assoc, add_left_comm, add_comm] using this -- rewrite `(a:ℤ)^a` as `((a^a : ℕ) : ℤ)` and convert to `ℕ` divisibility have : (f a : ℤ) ∣ (a^a : ℕ) := by -- use `Int.ofNat_dvd` after `norm_cast` -- -- First, coerce the RHS: simpa using (show (f a : ℤ) ∣ (a^a : ℤ) from by -- `norm_cast` turns `(a^a : ℤ)` into `(a:ℤ)^a` -- -- We keep it explicit: simpa using hz) exact (Int.ofNat_dvd.mp this) end Bonza