import Mathlib /-! # Open conjectures from the OEIS: ten proved, one refuted, plus one new theorem Each namespace below settles a statement that the On-Line Encyclopedia of Integer Sequences listed as a conjecture when we read it on 24 November 2026. Galperin A331859 colliding blocks and pi: floor(pi*sqrt n) only fails at records Stechkin A274010 Stechkin's function equals tau(n) + tau(n-1) - 2 A394666 A394666 2n-1 divides n! exactly when n > 5 and 2n-1 is not prime (n >= 2) A399155 A399155 subtracting the largest prime factor is never slower A248186 A248186 closed form for the cubic telescoping sequence McGarvey A000045 F(n) = floor(phi*F(n-1) + c) on the stated range of c A001076 A001076 2a(n+1) = a(n+2) - A001077(n+1) A102239 A102239 a(n) = 4a(n-1) + 5a(n-2) - 2 A238952 A238952 Hurt's floor-sum formula A400520 A400520 every n has a multiple that is both a square and a triangular number A341249 A341249 REFUTED: the stated bound fails at n = 2 Quartic (new) the quartic member of the A248183 / A248186 family Family (new) OUR CONJECTURE for the whole family, stated in Lean, NOT proved Dorfman (known) pooled blood testing pays exactly when 3q^3 > 1 (Samuels 1978) The eleventh proved conjecture, A248183, is in its own file A248183.lean. Machine-checked on live.lean-lang.org (Lean 4.37.0-rc1 with Mathlib), no errors: Galperin, Stechkin, A394666, A399155, A248186, McGarvey, A001076, A102239, A238952, A400520, A341249, Quartic, Dorfman Every proof in this file has been checked. Family contains definitions only. -/ namespace Galperin /-- g(n) = pi / arctan(1 / sqrt n). -/ noncomputable def g (n : ℕ) : ℝ := Real.pi / Real.arctan (1 / Real.sqrt (n : ℝ)) /-- OEIS A331859: collisions for mass ratio n. -/ noncomputable def a (n : ℕ) : ℤ := ⌈g n⌉ - 1 /-- OEIS A121854: floor(pi * sqrt n). -/ noncomputable def b (n : ℕ) : ℤ := ⌊Real.pi * Real.sqrt (n : ℝ)⌋ theorem upper_abs (m r w : ℝ) (hr0 : 0 < r) (hw0 : 0 < w) (hr2 : r ^ 2 = m) (hw2 : w ^ 2 = m + 1) : Real.pi / Real.arctan (1 / r) < Real.pi * w := by have hr' : r ≠ 0 := hr0.ne' have hw' : w ≠ 0 := hw0.ne' have hm : m ≠ 0 := by rw [← hr2] exact pow_ne_zero 2 hr' have hθ : 0 < Real.arctan (1 / r) := Real.arctan_pos.mpr (one_div_pos.mpr hr0) have hsin : Real.sin (Real.arctan (1 / r)) = 1 / w := by rw [Real.sin_arctan] have h : 1 + (1 / r) ^ 2 = (w / r) ^ 2 := by rw [div_pow, div_pow, one_pow, hw2, hr2, add_div, div_self hm] rw [h, Real.sqrt_sq (div_pos hw0 hr0).le] field_simp have hlt : 1 / w < Real.arctan (1 / r) := by rw [← hsin] exact Real.sin_lt hθ have h1 : 1 < w * Real.arctan (1 / r) := by have h := mul_lt_mul_of_pos_left hlt hw0 rw [mul_one_div_cancel hw'] at h exact h rw [div_lt_iff₀ hθ] have h2 := mul_lt_mul_of_pos_left h1 Real.pi_pos linarith theorem lower_abs (r : ℝ) (hr0 : 0 < r) : Real.pi * r < Real.pi / Real.arctan (1 / r) := by have hx : 0 < 1 / r := one_div_pos.mpr hr0 have hθ : 0 < Real.arctan (1 / r) := Real.arctan_pos.mpr hx have hlt : Real.arctan (1 / r) < 1 / r := by have h := Real.lt_tan hθ (Real.arctan_lt_pi_div_two _) rw [Real.tan_arctan] at h exact h have h1 : r * Real.arctan (1 / r) < 1 := by have h := mul_lt_mul_of_pos_left hlt hr0 rw [mul_one_div_cancel hr0.ne'] at h exact h rw [lt_div_iff₀ hθ] have h2 := mul_lt_mul_of_pos_left h1 Real.pi_pos linarith theorem upper (m : ℕ) (hm : 1 ≤ m) : g m < Real.pi * Real.sqrt ((m : ℝ) + 1) := by have hmpos : (0 : ℝ) < m := by exact_mod_cast hm exact upper_abs (m : ℝ) (Real.sqrt m) (Real.sqrt ((m : ℝ) + 1)) (Real.sqrt_pos.mpr hmpos) (Real.sqrt_pos.mpr (by linarith)) (Real.sq_sqrt hmpos.le) (Real.sq_sqrt (by linarith)) theorem lower (n : ℕ) (hn : 1 ≤ n) : Real.pi * Real.sqrt (n : ℝ) < g n := by have hnpos : (0 : ℝ) < n := by exact_mod_cast hn exact lower_abs (Real.sqrt n) (Real.sqrt_pos.mpr hnpos) theorem b_le_a (n : ℕ) (hn : 1 ≤ n) : b n ≤ a n := by have h1 : ((b n : ℤ) : ℝ) ≤ Real.pi * Real.sqrt (n : ℝ) := Int.floor_le _ have h2 := lower n hn have h3 : g n ≤ ((⌈g n⌉ : ℤ) : ℝ) := Int.le_ceil _ have h4 : ((b n : ℤ) : ℝ) < ((⌈g n⌉ : ℤ) : ℝ) := by linarith have h5 : b n < ⌈g n⌉ := by exact_mod_cast h4 unfold a omega /-- Kagey's conjecture (A331859): wherever the collision count a(n) differs from floor(pi * sqrt n), n is a record position: a(n) exceeds a(m) for every earlier m. -/ theorem kagey_conjecture (n : ℕ) (h : a n ≠ b n) (m : ℕ) (hm : 1 ≤ m) (hmn : m < n) : a m < a n := by have h1 : ((a m : ℤ) : ℝ) < Real.pi * Real.sqrt (n : ℝ) := by have hk := upper m hm have hceil : ((⌈g m⌉ : ℤ) : ℝ) < g m + 1 := Int.ceil_lt_add_one _ have hmn' : m + 1 ≤ n := hmn have hcast : (m : ℝ) + 1 ≤ (n : ℝ) := by exact_mod_cast hmn' have hsq : Real.sqrt ((m : ℝ) + 1) ≤ Real.sqrt (n : ℝ) := Real.sqrt_le_sqrt hcast have hmul := mul_le_mul_of_nonneg_left hsq Real.pi_pos.le unfold a push_cast linarith have h2 : a m ≤ b n := Int.le_floor.mpr h1.le have h3 : b n ≤ a n := b_le_a n (by omega) omega end Galperin namespace Stechkin theorem pointwise (n m : ℕ) (hm : 2 ≤ m) : (m - 1) ∣ (n * (m - 1)) / m ↔ (m ∣ n ∨ m ∣ (n - 1)) := by obtain ⟨t, rfl⟩ : ∃ t, m = t + 1 := ⟨m - 1, by omega⟩ have ht : 1 ≤ t := by omega rw [Nat.add_sub_cancel] rcases Nat.eq_zero_or_pos (n % (t + 1)) with h0 | hpos · have hd : (t + 1) ∣ n := Nat.dvd_of_mod_eq_zero h0 obtain ⟨q, rfl⟩ := hd constructor · intro _ exact Or.inl (Nat.dvd_mul_right _ _) · intro _ rw [Nat.mul_assoc, Nat.mul_div_cancel_left _ (by omega : 0 < t + 1)] exact Nat.dvd_mul_left _ _ · obtain ⟨s, hs⟩ : ∃ s, n % (t + 1) = s + 1 := ⟨n % (t + 1) - 1, by omega⟩ have hlt : n % (t + 1) < t + 1 := Nat.mod_lt _ (by omega) obtain ⟨e, he⟩ : ∃ e, t = s + e := ⟨t - s, by omega⟩ have he1 : 1 ≤ e := by omega have hn' : n = (t + 1) * (n / (t + 1)) + (s + 1) := by have h := Nat.div_add_mod n (t + 1) rw [hs] at h exact h.symm generalize n / (t + 1) = q at hn' clear hs hlt hpos subst hn' subst he have hdiv : ((s + e + 1) * q + (s + 1)) * (s + e) / (s + e + 1) = q * (s + e) + s := by have hid : ((s + e + 1) * q + (s + 1)) * (s + e) = e + (s + e + 1) * (q * (s + e) + s) := by ring rw [hid, Nat.add_mul_div_left _ _ (by omega : 0 < s + e + 1), Nat.div_eq_of_lt (by omega : e < s + e + 1), Nat.zero_add] rw [hdiv] have hsub : (s + e + 1) * q + (s + 1) - 1 = (s + e + 1) * q + s := by omega rw [hsub] have hL : (s + e) ∣ q * (s + e) + s ↔ s = 0 := by rw [Nat.dvd_add_right (Nat.dvd_mul_left (s + e) q)] constructor · intro h by_contra hne have := Nat.le_of_dvd (by omega) h omega · rintro rfl exact Nat.dvd_zero _ have hR1 : ¬ (s + e + 1) ∣ (s + e + 1) * q + (s + 1) := by rw [Nat.dvd_add_right (Nat.dvd_mul_right (s + e + 1) q)] intro h have := Nat.le_of_dvd (by omega) h omega have hR2 : (s + e + 1) ∣ (s + e + 1) * q + s ↔ s = 0 := by rw [Nat.dvd_add_right (Nat.dvd_mul_right (s + e + 1) q)] constructor · intro h by_contra hne have := Nat.le_of_dvd (by omega) h omega · rintro rfl exact Nat.dvd_zero _ rw [hL, hR2] constructor · intro h exact Or.inr h · rintro (h | h) · exact absurd h hR1 · exact h theorem oudra_conjecture (n : ℕ) (hn : 2 ≤ n) : ((Finset.Icc 2 n).filter (fun m => (m - 1) ∣ (n * (m - 1)) / m)).card = (Nat.divisors n).card + (Nat.divisors (n - 1)).card - 2 := by have hset : (Finset.Icc 2 n).filter (fun m => (m - 1) ∣ (n * (m - 1)) / m) = (Nat.divisors n).erase 1 ∪ (Nat.divisors (n - 1)).erase 1 := by ext m simp only [Finset.mem_filter, Finset.mem_Icc, Finset.mem_union, Finset.mem_erase, Nat.mem_divisors] constructor · rintro ⟨⟨h2, hle⟩, hd⟩ rcases (pointwise n m h2).mp hd with h | h · left exact ⟨by omega, h, by omega⟩ · right exact ⟨by omega, h, by omega⟩ · rintro (⟨h1, hd, hne⟩ | ⟨h1, hd, hne⟩) · have hpos : 0 < m := Nat.pos_of_dvd_of_pos hd (by omega) have hle : m ≤ n := Nat.le_of_dvd (by omega) hd exact ⟨⟨by omega, hle⟩, (pointwise n m (by omega)).mpr (Or.inl hd)⟩ · have hpos : 0 < m := Nat.pos_of_dvd_of_pos hd (by omega) have hle : m ≤ n - 1 := Nat.le_of_dvd (by omega) hd exact ⟨⟨by omega, by omega⟩, (pointwise n m (by omega)).mpr (Or.inr hd)⟩ have hdisj : Disjoint ((Nat.divisors n).erase 1) ((Nat.divisors (n - 1)).erase 1) := by rw [Finset.disjoint_left] intro m h1 h2 rw [Finset.mem_erase, Nat.mem_divisors] at h1 h2 have hd : m ∣ n - (n - 1) := Nat.dvd_sub h1.2.1 h2.2.1 rw [show n - (n - 1) = 1 from by omega] at hd exact h1.1 (Nat.dvd_one.mp hd) have h1n : 1 ∈ Nat.divisors n := Nat.mem_divisors.mpr ⟨one_dvd _, by omega⟩ have h1n' : 1 ∈ Nat.divisors (n - 1) := Nat.mem_divisors.mpr ⟨one_dvd _, by omega⟩ rw [hset, Finset.card_union_of_disjoint hdisj, Finset.card_erase_of_mem h1n, Finset.card_erase_of_mem h1n'] have c1 : 1 ≤ (Nat.divisors n).card := Finset.card_pos.mpr ⟨1, h1n⟩ have c2 : 1 ≤ (Nat.divisors (n - 1)).card := Finset.card_pos.mpr ⟨1, h1n'⟩ omega end Stechkin namespace A394666 theorem prod_dvd_fact (x y n : ℕ) (hx : 0 < x) (hxy : x < y) (hy : y ≤ n) : x * y ∣ n.factorial := by obtain ⟨c, rfl⟩ : ∃ c, y = c + 1 := ⟨y - 1, by omega⟩ have h1 : x ∣ c.factorial := Nat.dvd_factorial hx (by omega) have h2 : x * (c + 1) ∣ c.factorial * (c + 1) := Nat.mul_dvd_mul h1 (dvd_refl _) have h3 : c.factorial * (c + 1) = (c + 1).factorial := by rw [Nat.factorial_succ, Nat.mul_comm] rw [h3] at h2 exact Nat.dvd_trans h2 (Nat.factorial_dvd_factorial hy) theorem factorial_mod (n : ℕ) (hn : 2 ≤ n) : n.factorial % (2 * n - 1) = 0 ↔ (5 < n ∧ ¬ (2 * n - 1).Prime) := by constructor · intro h have hd : (2 * n - 1) ∣ n.factorial := Nat.dvd_of_mod_eq_zero h have hnp : ¬ (2 * n - 1).Prime := by intro hp have := (Nat.Prime.dvd_factorial hp).mp hd omega refine ⟨?_, hnp⟩ by_contra h5 have h5' : n ≤ 5 := by omega clear hd hnp h5 interval_cases n <;> revert h <;> decide · rintro ⟨h5, hnp⟩ apply Nat.mod_eq_zero_of_dvd obtain ⟨a, ⟨b, hab⟩, ha2, halt⟩ := Nat.exists_dvd_of_not_prime2 (by omega : 2 ≤ 2 * n - 1) hnp have ha3 : 3 ≤ a := by rcases Nat.lt_or_ge a 3 with h | h · interval_cases a omega · exact h have hb3 : 3 ≤ b := by rcases Nat.lt_or_ge b 3 with h | h · interval_cases b <;> omega · exact h have hbn : b < n := by have := Nat.mul_le_mul_right b ha3 omega have han : a < n := by have := Nat.mul_le_mul_left a hb3 omega rw [hab] rcases Nat.lt_trichotomy a b with h | h | h · exact prod_dvd_fact a b n (by omega) h (by omega) · rw [← h] at hab ⊢ have h5a : 5 ≤ a := by rcases Nat.lt_or_ge a 5 with h' | h' · interval_cases a <;> omega · exact h' have hsq := Nat.mul_le_mul_right a h5a exact Nat.dvd_trans (Nat.mul_dvd_mul_left a (Nat.dvd_mul_left a 2)) (prod_dvd_fact a (2 * a) n (by omega) (by omega) (by omega)) · rw [Nat.mul_comm] exact prod_dvd_fact b a n (by omega) h (by omega) end A394666 namespace A399155 inductive Steps : ℕ → ℕ → Prop | zero : Steps 0 0 | step (p n k : ℕ) : p.Prime → p ∣ n → 0 < n → Steps (n - p) k → Steps n (k + 1) inductive SpfSteps : ℕ → ℕ → Prop | zero : SpfSteps 0 0 | step (n k : ℕ) : 0 < n → SpfSteps (n - n.minFac) k → SpfSteps n (k + 1) inductive GpfSteps : ℕ → ℕ → Prop | zero : GpfSteps 0 0 | step (p n k : ℕ) : p.Prime → p ∣ n → (∀ q : ℕ, q.Prime → q ∣ n → q ≤ p) → 0 < n → GpfSteps (n - p) k → GpfSteps n (k + 1) def F (n : ℕ) : ℕ := if n % 2 = 0 then n / 2 else (n - n.minFac) / 2 + 1 theorem F_even {n : ℕ} (h : n % 2 = 0) : F n = n / 2 := by simp [F, h] theorem F_odd {n : ℕ} (h : n % 2 = 1) : F n = (n - n.minFac) / 2 + 1 := by simp [F, h] theorem steps_le {n k : ℕ} (h : Steps n k) : k ≤ F n := by induction h with | zero => exact Nat.zero_le _ | step p n k hp hd hpos hs ih => have hple : p ≤ n := Nat.le_of_dvd hpos hd have hp2 : 2 ≤ p := hp.two_le have hne1 : n - p ≠ 1 := by intro h1 have hn : n = p + 1 := by omega rw [hn] at hd have := Nat.dvd_one.mp ((Nat.dvd_add_right (dvd_refl p)).mp hd) omega rcases hp.eq_two_or_odd with h2 | hodd · subst h2 obtain ⟨j, hj⟩ := hd have e1 : (n - 2) % 2 = 0 := by omega have e2 : n % 2 = 0 := by omega rw [F_even e1] at ih rw [F_even e2] omega · rcases Nat.mod_two_eq_zero_or_one n with he | ho · have hodd' : (n - p) % 2 = 1 := by omega have hq := Nat.minFac_prime hne1 have hqd := Nat.minFac_dvd (n - p) have hqle : (n - p).minFac ≤ n - p := Nat.minFac_le (by omega) have hq3 : 3 ≤ (n - p).minFac := by rcases hq.eq_two_or_odd with h2 | h1 · obtain ⟨j, hj⟩ := hqd rw [h2] at hj omega · have := hq.two_le omega rw [F_odd hodd'] at ih rw [F_even he] omega · have hmin : n.minFac ≤ p := Nat.minFac_le_of_dvd hp2 hd have he' : (n - p) % 2 = 0 := by omega rw [F_even he'] at ih rw [F_odd ho] omega theorem spf_eq {n k : ℕ} (h : SpfSteps n k) : k = F n := by induction h with | zero => rfl | step n k hpos hs ih => rcases Nat.mod_two_eq_zero_or_one n with he | ho · have h2 : n.minFac = 2 := (Nat.minFac_eq_two_iff n).mpr (Nat.dvd_of_mod_eq_zero he) rw [h2] at ih rw [F_even (n := n - 2) (by omega)] at ih rw [F_even he] omega · have hqle : n.minFac ≤ n := Nat.minFac_le hpos have hqodd : n.minFac % 2 = 1 := by rcases Nat.mod_two_eq_zero_or_one n.minFac with h0 | h1 · have h2n : 2 ∣ n := Nat.dvd_trans (Nat.dvd_of_mod_eq_zero h0) (Nat.minFac_dvd n) obtain ⟨j, hj⟩ := h2n omega · exact h1 rw [F_even (n := n - n.minFac) (by omega)] at ih rw [F_odd ho] omega theorem gpf_steps {n k : ℕ} (h : GpfSteps n k) : Steps n k := by induction h with | zero => exact Steps.zero | step p n k hp hd _ hpos _ ih => exact Steps.step p n k hp hd hpos ih theorem largest_never_slower {n f g : ℕ} (hf : SpfSteps n f) (hg : GpfSteps n g) : g ≤ f := by rw [spf_eq hf] exact steps_le (gpf_steps hg) end A399155 namespace A248186 open Finset noncomputable def s (k : ℕ) : ℚ := ∑ h ∈ Icc 1 k, 1 / ((h : ℚ) * (h + 1) * (h + 2) * (h + 3)) theorem s_eq (k : ℕ) : s k = 1 / 18 - 1 / (3 * ((k : ℚ) + 1) * (k + 2) * (k + 3)) := by unfold s induction k with | zero => norm_num | succ k ih => rw [sum_Icc_succ_top (by omega), ih] push_cast field_simp ring theorem cond_iff (n k : ℕ) (hn : 0 < n) : (1 / 18 - s k < 1 / (n : ℚ) ^ 3) ↔ n * n * n < 3 * ((k + 1) * (k + 2) * (k + 3)) := by have hn' : (0 : ℚ) < n := by exact_mod_cast hn rw [s_eq] have h1 : (1 : ℚ) / 18 - (1 / 18 - 1 / (3 * ((k : ℚ) + 1) * (k + 2) * (k + 3))) = 1 / (3 * ((k : ℚ) + 1) * (k + 2) * (k + 3)) := by ring rw [h1, one_div_lt_one_div (by positivity) (by positivity)] rw [show (n : ℚ) ^ 3 = ((n * n * n : ℕ) : ℚ) by push_cast; ring, show 3 * ((k : ℚ) + 1) * (k + 2) * (k + 3) = ((3 * ((k + 1) * (k + 2) * (k + 3)) : ℕ) : ℚ) by push_cast; ring] exact Nat.cast_lt theorem r_lb (r : ℝ) (hr : 0 < r) (h3 : 3 * r ^ 3 = 1) : 2 / 3 ≤ r := by by_contra hlt rw [not_le] at hlt have hd : 0 < 2 / 3 - r := by linarith have q1 : r ^ 2 < 4 / 9 := by nlinarith have q2 : r ^ 3 < 8 / 27 := by nlinarith [mul_pos hd (pow_pos hr 2)] linarith theorem real_part (n j : ℕ) (hn : 3 ≤ n) (r : ℝ) (hr : 0 < r) (h3 : 3 * r ^ 3 = 1) (h1 : (j : ℝ) ≤ r * n + r ^ 2 / n - 1) (h2 : r * n + r ^ 2 / n - 1 < (j : ℝ) + 1) : n * n * n < 3 * ((j + 1) * (j + 2) * (j + 3)) ∧ 3 * (j * (j + 1) * (j + 2)) ≤ n * n * n := by have hn3 : (3 : ℝ) ≤ n := by exact_mod_cast hn have hn0 : (0 : ℝ) < n := by linarith have hj0 : (0 : ℝ) ≤ j := Nat.cast_nonneg j have hr23 := r_lb r hr h3 have hn0' : (n : ℝ) ≠ 0 := hn0.ne' have hdiv : r ^ 2 / (n : ℝ) * n = r ^ 2 := by field_simp obtain ⟨T, hT⟩ : ∃ T : ℝ, T = r * (n : ℝ) ^ 2 + r ^ 2 := ⟨_, rfl⟩ have hTn : (r * n + r ^ 2 / n) * n = T := by rw [hT] linear_combination hdiv have key : 3 * T ^ 3 - 3 * T * (n : ℝ) ^ 2 = (n : ℝ) ^ 6 + 1 / 3 := by rw [hT] linear_combination ((n : ℝ) ^ 6 + 3 * r * (n : ℝ) ^ 4 + 3 * r ^ 2 * (n : ℝ) ^ 2 + r ^ 3 + 1 / 3) * h3 have hT2n : 2 * (n : ℝ) ≤ T := by rw [hT] nlinarith [mul_nonneg (sub_nonneg.mpr hr23) (sq_nonneg (n : ℝ)), mul_nonneg hn0.le (sub_nonneg.mpr hn3), sq_nonneg r] have hT0 : 0 < T := by linarith obtain ⟨Y, hYdef⟩ : ∃ Y : ℝ, Y = ((j : ℝ) + 1) * n := ⟨_, rfl⟩ obtain ⟨X, hXdef⟩ : ∃ X : ℝ, X = ((j : ℝ) + 2) * n := ⟨_, rfl⟩ have hY : Y ≤ T := by have h := mul_le_mul_of_nonneg_right (show (j : ℝ) + 1 ≤ r * n + r ^ 2 / n by linarith) hn0.le rw [hYdef] linarith have hX : T < X := by have h := mul_lt_mul_of_pos_right (show r * n + r ^ 2 / n < (j : ℝ) + 2 by linarith) hn0 rw [hXdef] linarith have hYn : (n : ℝ) ≤ Y := by rw [hYdef] nlinarith [mul_nonneg hj0 hn0.le] have hX0 : 0 < X := by linarith have hY0 : 0 < Y := by linarith have eA : 3 * (X ^ 3 - X * (n : ℝ) ^ 2) = (n : ℝ) ^ 3 * (3 * (((j : ℝ) + 1) * ((j : ℝ) + 2) * ((j : ℝ) + 3))) := by rw [hXdef] ring have eB : 3 * (Y ^ 3 - Y * (n : ℝ) ^ 2) = (n : ℝ) ^ 3 * (3 * ((j : ℝ) * ((j : ℝ) + 1) * ((j : ℝ) + 2))) := by rw [hYdef] ring have hfacA : 0 < X ^ 2 + X * T + T ^ 2 - (n : ℝ) ^ 2 := by nlinarith [mul_pos hX0 hT0, sq_nonneg X, mul_nonneg (show (0 : ℝ) ≤ T - n by linarith) (show (0 : ℝ) ≤ T + n by linarith)] have hfacB : 0 ≤ T ^ 2 + T * Y + Y ^ 2 - (n : ℝ) ^ 2 := by nlinarith [mul_pos hT0 hY0, sq_nonneg T, mul_nonneg (show (0 : ℝ) ≤ Y - n by linarith) (show (0 : ℝ) ≤ Y + n by linarith)] have hA' : (n : ℝ) ^ 6 < 3 * (X ^ 3 - X * (n : ℝ) ^ 2) := by nlinarith [mul_pos (sub_pos.mpr hX) hfacA, key] have hB' : 3 * (Y ^ 3 - Y * (n : ℝ) ^ 2) ≤ (n : ℝ) ^ 6 + 1 / 3 := by nlinarith [mul_nonneg (sub_nonneg.mpr hY) hfacB, key] have hn3pos : (0 : ℝ) < (n : ℝ) ^ 3 := pow_pos hn0 3 have hAr : (n : ℝ) ^ 3 < 3 * (((j : ℝ) + 1) * ((j : ℝ) + 2) * ((j : ℝ) + 3)) := by have h : (n : ℝ) ^ 3 * (n : ℝ) ^ 3 < (n : ℝ) ^ 3 * (3 * (((j : ℝ) + 1) * ((j : ℝ) + 2) * ((j : ℝ) + 3))) := by rw [← eA] have e : (n : ℝ) ^ 3 * (n : ℝ) ^ 3 = (n : ℝ) ^ 6 := by ring linarith exact lt_of_mul_lt_mul_left h hn3pos.le have hAN : n * n * n < 3 * ((j + 1) * (j + 2) * (j + 3)) := by have h : ((n : ℝ) * n * n) < 3 * (((j : ℝ) + 1) * ((j : ℝ) + 2) * ((j : ℝ) + 3)) := by nlinarith [hAr] exact_mod_cast h have hBN : n ^ 3 * (3 * (j * (j + 1) * (j + 2))) < n ^ 6 + 1 := by have h : (n : ℝ) ^ 3 * (3 * ((j : ℝ) * ((j : ℝ) + 1) * ((j : ℝ) + 2))) < (n : ℝ) ^ 6 + 1 := by rw [← eB] linarith exact_mod_cast h have hBN2 : n ^ 3 * (3 * (j * (j + 1) * (j + 2))) ≤ n ^ 3 * n ^ 3 := by have e : n ^ 3 * n ^ 3 = n ^ 6 := by ring rw [e] exact Nat.lt_succ_iff.mp hBN have hB := Nat.le_of_mul_le_mul_left hBN2 (pow_pos (by omega : 0 < n) 3) have e3 : n ^ 3 = n * n * n := by ring rw [e3] at hB exact ⟨hAN, hB⟩ /-- Oudra's conjecture for A248186, with r the positive real cube root of 1/3. -/ theorem oudra_conjecture (n : ℕ) (hn : 3 ≤ n) (r : ℝ) (hr : 0 < r) (h3 : 3 * r ^ 3 = 1) : IsLeast {k : ℕ | 1 ≤ k ∧ 1 / 18 - s k < 1 / (n : ℚ) ^ 3} ⌊r * n + r ^ 2 / n - 1⌋₊ := by have hn3 : (3 : ℝ) ≤ n := by exact_mod_cast hn have hn0 : (0 : ℝ) < n := by linarith have hr23 := r_lb r hr h3 have hx : (0 : ℝ) ≤ r * n + r ^ 2 / n - 1 := by have hp : 0 ≤ r ^ 2 / (n : ℝ) := div_nonneg (sq_nonneg r) hn0.le have hq : 2 ≤ r * (n : ℝ) := by nlinarith [mul_nonneg (sub_nonneg.mpr hr23) hn0.le] linarith have h1 := Nat.floor_le hx have h2 := Nat.lt_floor_add_one (r * n + r ^ 2 / n - 1) generalize ⌊r * n + r ^ 2 / n - 1⌋₊ = j at h1 h2 ⊢ obtain ⟨hA, hB⟩ := real_part n j hn r hr h3 h1 h2 have hj1 : 1 ≤ j := by by_contra h0 have hz : j = 0 := by omega subst hz have := Nat.mul_le_mul (Nat.mul_le_mul hn hn) hn omega constructor · exact ⟨hj1, (cond_iff n j (by omega)).mpr hA⟩ · intro k hk obtain ⟨_, hk2⟩ := hk by_contra hlt have hk3 := (cond_iff n k (by omega)).mp hk2 have hkj : k + 1 ≤ j := by omega have hm : (k + 1) * (k + 2) * (k + 3) ≤ j * (j + 1) * (j + 2) := Nat.mul_le_mul (Nat.mul_le_mul hkj (by omega)) (by omega) omega end A248186 namespace McGarvey theorem step (φ : ℝ) (hφ : φ * φ = φ + 1) (m : ℕ) : (Nat.fib (m + 2) : ℝ) - φ * (Nat.fib (m + 1) : ℝ) = (1 - φ) * ((Nat.fib (m + 1) : ℝ) - φ * (Nat.fib m : ℝ)) := by rw [Nat.fib_add_two] push_cast linear_combination (-(Nat.fib m : ℝ)) * hφ theorem bounds (φ : ℝ) (hφ : φ * φ = φ + 1) (h32 : 3 / 2 ≤ φ) (m : ℕ) : 3 - 2 * φ ≤ (Nat.fib (m + 3) : ℝ) - φ * (Nat.fib (m + 2) : ℝ) ∧ (Nat.fib (m + 3) : ℝ) - φ * (Nat.fib (m + 2) : ℝ) ≤ 2 - φ := by induction m with | zero => have h3 : (Nat.fib (0 + 3) : ℝ) = 2 := by norm_num [Nat.fib_add_two] have h2 : (Nat.fib (0 + 2) : ℝ) = 1 := by norm_num [Nat.fib_add_two] rw [h3, h2] constructor <;> linarith | succ k ih => have ih' : 3 - 2 * φ ≤ (Nat.fib (k + 2 + 1) : ℝ) - φ * (Nat.fib (k + 2) : ℝ) ∧ (Nat.fib (k + 2 + 1) : ℝ) - φ * (Nat.fib (k + 2) : ℝ) ≤ 2 - φ := ih obtain ⟨l, u⟩ := ih' show 3 - 2 * φ ≤ (Nat.fib (k + 2 + 2) : ℝ) - φ * (Nat.fib (k + 2 + 1) : ℝ) ∧ (Nat.fib (k + 2 + 2) : ℝ) - φ * (Nat.fib (k + 2 + 1) : ℝ) ≤ 2 - φ rw [step φ hφ (k + 2)] have hφ1 : 0 ≤ φ - 1 := by linarith constructor · nlinarith [mul_nonneg hφ1 (sub_nonneg.mpr u)] · nlinarith [mul_nonneg hφ1 (sub_nonneg.mpr l)] /-- McGarvey's conjecture, for any positive real φ with φ^2 = φ + 1. -/ theorem fib_floor (φ : ℝ) (hφ : φ * φ = φ + 1) (hpos : 0 < φ) (c : ℝ) (hc1 : 2 - φ ≤ c) (hc2 : c < 2 * (2 - φ)) (n : ℕ) (hn : 2 < n) : ⌊φ * (Nat.fib (n - 1) : ℝ) + c⌋ = (Nat.fib n : ℤ) := by have h32 : 3 / 2 ≤ φ := by by_contra hlt rw [not_le] at hlt nlinarith [mul_pos hpos (sub_pos.mpr hlt)] obtain ⟨m, rfl⟩ : ∃ m, n = m + 3 := ⟨n - 3, by omega⟩ have hsub : m + 3 - 1 = m + 2 := by omega rw [hsub, Int.floor_eq_iff] obtain ⟨l, u⟩ := bounds φ hφ h32 m push_cast constructor <;> linarith theorem mcgarvey (c : ℝ) (hc1 : 2 - Real.goldenRatio ≤ c) (hc2 : c < 2 * (2 - Real.goldenRatio)) (n : ℕ) (hn : 2 < n) : ⌊Real.goldenRatio * (Nat.fib (n - 1) : ℝ) + c⌋ = (Nat.fib n : ℤ) := by have h := Real.goldenRatio_sq rw [sq] at h exact fib_floor Real.goldenRatio h Real.goldenRatio_pos c hc1 hc2 n hn end McGarvey namespace A001076 theorem dement (a b : ℕ → ℤ) (a0 : a 0 = 0) (a1 : a 1 = 1) (ha : ∀ n, a (n + 2) = 4 * a (n + 1) + a n) (b0 : b 0 = 1) (b1 : b 1 = 2) (hb : ∀ n, b (n + 2) = 4 * b (n + 1) + b n) (n : ℕ) : 2 * a (n + 1) = a (n + 2) - b (n + 1) := by have aux : ∀ k, b (k + 1) = 2 * a (k + 1) + a k ∧ b (k + 2) = 2 * a (k + 2) + a (k + 1) := by intro k induction k with | zero => have e := ha 0 have f := hb 0 simp only [Nat.zero_add] at * constructor <;> linarith | succ k ih => obtain ⟨h1, h2⟩ := ih have e1 : b (k + 3) = 4 * b (k + 2) + b (k + 1) := hb (k + 1) have e2 : a (k + 3) = 4 * a (k + 2) + a (k + 1) := ha (k + 1) have e3 : a (k + 2) = 4 * a (k + 1) + a k := ha k show b (k + 2) = 2 * a (k + 2) + a (k + 1) ∧ b (k + 3) = 2 * a (k + 3) + a (k + 2) exact ⟨h2, by linarith⟩ have h := (aux n).1 have e := ha n linarith end A001076 namespace A102239 def S (n : ℕ) : ℕ := ∑ i ∈ Finset.range (n + 1), 5 ^ i def a (n : ℕ) : ℕ := S n + 1 - S n % 2 theorem S_closed (n : ℕ) : 4 * S n + 1 = 5 ^ (n + 1) := by induction n with | zero => simp [S] | succ k ih => have h : S (k + 1) = S k + 5 ^ (k + 1) := Finset.sum_range_succ (fun i => 5 ^ i) (k + 1) have e : 5 ^ (k + 1 + 1) = 5 ^ (k + 1) * 5 := pow_succ 5 (k + 1) rw [h, e] linarith theorem S_succ (n : ℕ) : S (n + 1) = 5 * S n + 1 := by have h1 := S_closed n have h2 := S_closed (n + 1) have e : 5 ^ (n + 1 + 1) = 5 ^ (n + 1) * 5 := pow_succ 5 (n + 1) rw [e] at h2 linarith theorem dement (n : ℕ) : a (n + 2) + 2 = 4 * a (n + 1) + 5 * a n := by have h1 : S (n + 1) = 5 * S n + 1 := S_succ n have h2 : S (n + 2) = 5 * S (n + 1) + 1 := S_succ (n + 1) rcases Nat.mod_two_eq_zero_or_one (S n) with h0 | h0 · have m1 : S (n + 1) % 2 = 1 := by omega have m2 : S (n + 2) % 2 = 0 := by omega unfold a rw [m2, m1, h0] omega · have m1 : S (n + 1) % 2 = 0 := by omega have m2 : S (n + 2) % 2 = 1 := by omega unfold a rw [m2, m1, h0] omega end A102239 namespace A238952 theorem hurt (n : ℕ) (hn : 1 ≤ n) : ∑ i ∈ Finset.Icc 1 (n / 2), (Nat.divisors i).card * (n / i - (n - 1) / i) = ∑ d ∈ n.properDivisors, (Nat.divisors d).card := by obtain ⟨k, rfl⟩ : ∃ k, n = k + 1 := ⟨n - 1, by omega⟩ have hset : (k + 1).properDivisors = (Finset.Icc 1 ((k + 1) / 2)).filter (fun i => i ∣ k + 1) := by ext i simp only [Nat.mem_properDivisors, Finset.mem_filter, Finset.mem_Icc] constructor · rintro ⟨hd, hlt⟩ have hpos : 0 < i := Nat.pos_of_dvd_of_pos hd (by omega) obtain ⟨q, hq⟩ := hd have hq2 : 2 ≤ q := by rcases q with _ | _ | q <;> omega have h2 := Nat.mul_le_mul_left i hq2 exact ⟨⟨hpos, by omega⟩, ⟨q, hq⟩⟩ · rintro ⟨⟨h1, h2⟩, hd⟩ exact ⟨hd, by omega⟩ rw [hset, Finset.sum_filter] apply Finset.sum_congr rfl intro i hi rw [Nat.add_sub_cancel, Nat.succ_div] split_ifs with h <;> simp end A238952 namespace A400520 theorem no_sqrt_two : ∀ y : ℕ, 0 < y → ∀ x : ℕ, x * x ≠ 2 * (y * y) := by intro y induction y using Nat.strong_induction_on with | _ y ih => intro hy x hx rcases Nat.mod_two_eq_zero_or_one x with h0 | h1 · obtain ⟨a, rfl⟩ : ∃ a, x = 2 * a := ⟨x / 2, by omega⟩ have e : 2 * a * (2 * a) = 4 * (a * a) := by ring have hya : y * y = 2 * (a * a) := by omega rcases Nat.mod_two_eq_zero_or_one y with g0 | g1 · obtain ⟨c, rfl⟩ : ∃ c, y = 2 * c := ⟨y / 2, by omega⟩ have e' : 2 * c * (2 * c) = 4 * (c * c) := by ring have hac : a * a = 2 * (c * c) := by omega exact ih c (by omega) (by omega) a hac · obtain ⟨c, rfl⟩ : ∃ c, y = 2 * c + 1 := ⟨y / 2, by omega⟩ have e' : (2 * c + 1) * (2 * c + 1) = 4 * (c * c + c) + 1 := by ring omega · obtain ⟨a, rfl⟩ : ∃ a, x = 2 * a + 1 := ⟨x / 2, by omega⟩ have e : (2 * a + 1) * (2 * a + 1) = 4 * (a * a + a) + 1 := by ring omega theorem not_isSquare (n : ℕ) (hn : 0 < n) : ¬ IsSquare ((8 : ℤ) * (n : ℤ) ^ 2) := by rintro ⟨r, hr⟩ have h1 : (8 : ℤ) * (n : ℤ) ^ 2 = (r.natAbs : ℤ) * (r.natAbs : ℤ) := by rw [Int.natAbs_mul_self'] exact hr have h : 8 * n ^ 2 = r.natAbs * r.natAbs := by exact_mod_cast h1 obtain ⟨m, hmd⟩ : ∃ m, m = r.natAbs := ⟨_, rfl⟩ rw [← hmd] at h have e : 8 * n ^ 2 = 2 * ((2 * n) * (2 * n)) := by ring exact no_sqrt_two (2 * n) (by omega) m (h.symm.trans e) /-- Every positive integer has a positive multiple that is both a perfect square and a triangular number. The proof solves the Pell equation x^2 - 8 n^2 z^2 = 1. -/ theorem square_triangular_multiple (n : ℕ) (hn : 0 < n) : ∃ k : ℕ, 1 ≤ k ∧ IsSquare (n * k) ∧ ∃ t : ℕ, 2 * (n * k) = t * (t + 1) := by have hd : (0 : ℤ) < 8 * (n : ℤ) ^ 2 := by positivity obtain ⟨x, z, hxz, hz⟩ := Pell.exists_of_not_isSquare hd (not_isSquare n hn) have hX : (x.natAbs : ℤ) * (x.natAbs : ℤ) = x * x := Int.natAbs_mul_self' x have hZ : (z.natAbs : ℤ) * (z.natAbs : ℤ) = z * z := Int.natAbs_mul_self' z have hN : (x.natAbs : ℤ) * (x.natAbs : ℤ) = 8 * (n : ℤ) ^ 2 * ((z.natAbs : ℤ) * (z.natAbs : ℤ)) + 1 := by rw [hX, hZ] linear_combination hxz have hNat : x.natAbs * x.natAbs = 8 * n ^ 2 * (z.natAbs * z.natAbs) + 1 := by exact_mod_cast hN have hZ1 : 0 < z.natAbs := Int.natAbs_pos.mpr hz obtain ⟨X, hXd⟩ : ∃ X, X = x.natAbs := ⟨_, rfl⟩ obtain ⟨Z, hZd⟩ : ∃ Z, Z = z.natAbs := ⟨_, rfl⟩ rw [← hXd, ← hZd] at hNat rw [← hZd] at hZ1 have e2 : 8 * n ^ 2 * (Z * Z) = 8 * (n ^ 2 * (Z * Z)) := by ring rcases Nat.mod_two_eq_zero_or_one X with hev | hodd · exfalso obtain ⟨q, rfl⟩ : ∃ q, X = 2 * q := ⟨X / 2, by omega⟩ have e : 2 * q * (2 * q) = 4 * (q * q) := by ring omega · obtain ⟨t, rfl⟩ : ∃ t, X = 2 * t + 1 := ⟨X / 2, by omega⟩ have e : (2 * t + 1) * (2 * t + 1) = 4 * (t * (t + 1)) + 1 := by ring have ht : t * (t + 1) = 2 * (n ^ 2 * (Z * Z)) := by omega refine ⟨n * (Z * Z), Nat.mul_pos hn (Nat.mul_pos hZ1 hZ1), ⟨n * Z, by ring⟩, t, ?_⟩ rw [ht] ring /-- Ratushnyak's conjecture for A400520: a(n) > 0, i.e. a suitable multiplier k >= 1 always exists. -/ theorem ratushnyak_conjecture (n : ℕ) : ∃ k : ℕ, 1 ≤ k ∧ (IsSquare (n * k) ∨ IsSquare (n * k + 1)) ∧ ((∃ t : ℕ, 2 * (n * k) = t * (t + 1)) ∨ (∃ t : ℕ, 2 * (n * k + 1) = t * (t + 1))) := by rcases Nat.eq_zero_or_pos n with rfl | hn · exact ⟨1, le_refl 1, Or.inl ⟨0, by simp⟩, Or.inl ⟨0, by simp⟩⟩ · obtain ⟨k, hk, hs, ht⟩ := square_triangular_multiple n hn exact ⟨k, hk, Or.inl hs, Or.inl ht⟩ end A400520 namespace A341249 noncomputable def a (n : ℕ) : ℤ := ⌊(2 + Real.sqrt 2) * (⌊Real.sqrt 2 * (n : ℝ)⌋ : ℝ)⌋ /-- Kimberling's conjecture 1 < r*s*n - a(n) < 2 fails at n = 2. -/ theorem conjecture_false : ¬ ∀ n : ℕ, 1 ≤ n → (1 < (2 + Real.sqrt 2) * Real.sqrt 2 * (n : ℝ) - (a n : ℝ) ∧ (2 + Real.sqrt 2) * Real.sqrt 2 * (n : ℝ) - (a n : ℝ) < 2) := by intro h have h2 := (h 2 (by norm_num)).2 have hc : Real.sqrt 2 ^ 2 = 2 := Real.sq_sqrt (by norm_num) have hc0 : 0 ≤ Real.sqrt 2 := Real.sqrt_nonneg 2 have hlo : (1.41 : ℝ) < Real.sqrt 2 := by by_contra hh rw [not_lt] at hh nlinarith have hhi : Real.sqrt 2 < 1.42 := by by_contra hh rw [not_lt] at hh nlinarith have f1 : ⌊Real.sqrt 2 * ((2 : ℕ) : ℝ)⌋ = 2 := by rw [Int.floor_eq_iff] push_cast constructor <;> linarith have f2 : ⌊(2 + Real.sqrt 2) * ((2 : ℤ) : ℝ)⌋ = 6 := by rw [Int.floor_eq_iff] push_cast constructor <;> linarith unfold a at h2 rw [f1, f2] at h2 push_cast at h2 nlinarith end A341249 namespace Quartic open Finset noncomputable def s (k : ℕ) : ℚ := ∑ h ∈ Icc 1 k, 1 / ((h : ℚ) * (h + 1) * (h + 2) * (h + 3) * (h + 4)) theorem s_eq (k : ℕ) : s k = 1 / 96 - 1 / (4 * ((k : ℚ) + 1) * (k + 2) * (k + 3) * (k + 4)) := by unfold s induction k with | zero => norm_num | succ k ih => rw [sum_Icc_succ_top (by omega), ih] push_cast field_simp ring theorem cond_iff (n k : ℕ) (hn : 0 < n) : (1 / 96 - s k < 1 / (n : ℚ) ^ 4) ↔ n * n * n * n < 4 * ((k + 1) * (k + 2) * (k + 3) * (k + 4)) := by have hn' : (0 : ℚ) < n := by exact_mod_cast hn rw [s_eq] have h1 : (1 : ℚ) / 96 - (1 / 96 - 1 / (4 * ((k : ℚ) + 1) * (k + 2) * (k + 3) * (k + 4))) = 1 / (4 * ((k : ℚ) + 1) * (k + 2) * (k + 3) * (k + 4)) := by ring rw [h1, one_div_lt_one_div (by positivity) (by positivity)] rw [show (n : ℚ) ^ 4 = ((n * n * n * n : ℕ) : ℚ) by push_cast; ring, show 4 * ((k : ℚ) + 1) * (k + 2) * (k + 3) * (k + 4) = ((4 * ((k + 1) * (k + 2) * (k + 3) * (k + 4)) : ℕ) : ℚ) by push_cast; ring] exact Nat.cast_lt theorem real_part (n j : ℕ) (hn : 2 ≤ n) (c : ℝ) (hc0 : 0 < c) (hc : c ^ 2 = 2) (h1 : (j : ℝ) ≤ n * c / 2 + 5 * c / (8 * n) - 3 / 2) (h2 : n * c / 2 + 5 * c / (8 * n) - 3 / 2 < (j : ℝ) + 1) : n * n * n * n < 4 * ((j + 1) * (j + 2) * (j + 3) * (j + 4)) ∧ 4 * (j * (j + 1) * (j + 2) * (j + 3)) ≤ n * n * n * n := by have hn2 : (2 : ℝ) ≤ n := by exact_mod_cast hn have hn0 : (0 : ℝ) < n := by linarith have hj0 : (0 : ℝ) ≤ j := Nat.cast_nonneg j have hn4 : (4 : ℝ) ≤ (n : ℝ) ^ 2 := by nlinarith have hn0' : (n : ℝ) ≠ 0 := hn0.ne' have hdiv : 5 * c / (8 * (n : ℝ)) * (8 * n) = 5 * c := by field_simp obtain ⟨A, hA⟩ : ∃ A : ℝ, A = c * (4 * (n : ℝ) ^ 2 + 5) := ⟨_, rfl⟩ have hτ : ((n : ℝ) * c / 2 + 5 * c / (8 * n)) * (8 * n) = A := by rw [hA] linear_combination hdiv have hA0 : 0 < A := by rw [hA] exact mul_pos hc0 (by positivity) have hA2 : A ^ 2 = 2 * (4 * (n : ℝ) ^ 2 + 5) ^ 2 := by rw [hA, mul_pow, hc] have hU : A < 4 * n * (2 * (j : ℝ) + 5) := by have h := mul_lt_mul_of_pos_right (show (n : ℝ) * c / 2 + 5 * c / (8 * n) < (j : ℝ) + 5 / 2 by linarith) (show (0 : ℝ) < 8 * n by linarith) linarith have hL : 4 * n * (2 * (j : ℝ) + 3) ≤ A := by have h := mul_le_mul_of_nonneg_right (show (j : ℝ) + 3 / 2 ≤ (n : ℝ) * c / 2 + 5 * c / (8 * n) by linarith) (show (0 : ℝ) ≤ 8 * n by linarith) linarith have hBU : 0 < 4 * n * (2 * (j : ℝ) + 5) := by linarith have hBL : 0 ≤ 4 * n * (2 * (j : ℝ) + 3) := by positivity have hsqU : A ^ 2 < (4 * n * (2 * (j : ℝ) + 5)) ^ 2 := by nlinarith [mul_pos (sub_pos.mpr hU) (add_pos hBU hA0)] have hsqL : (4 * n * (2 * (j : ℝ) + 3)) ^ 2 ≤ A ^ 2 := by nlinarith [mul_nonneg (sub_nonneg.mpr hL) (add_nonneg hBL hA0.le)] have h16 : (0 : ℝ) < 16 * (n : ℝ) ^ 2 := by positivity have hQ : 2 * (n : ℝ) ^ 2 + 5 < (2 * (j : ℝ) + 5) ^ 2 := by have h : 16 * (n : ℝ) ^ 2 * (2 * (n : ℝ) ^ 2 + 5) < 16 * (n : ℝ) ^ 2 * (2 * (j : ℝ) + 5) ^ 2 := by nlinarith [hsqU, hA2] exact lt_of_mul_lt_mul_left h h16.le have hQ' : (2 * (j : ℝ) + 3) ^ 2 < 2 * (n : ℝ) ^ 2 + 6 := by have h : 16 * (n : ℝ) ^ 2 * (2 * (j : ℝ) + 3) ^ 2 < 16 * (n : ℝ) ^ 2 * (2 * (n : ℝ) ^ 2 + 6) := by nlinarith [hsqL, hA2, hn4] exact lt_of_mul_lt_mul_left h h16.le have hQN : 2 * n ^ 2 + 5 < (2 * j + 5) ^ 2 := by exact_mod_cast hQ have hQN2 : 2 * n ^ 2 + 6 ≤ (2 * j + 5) ^ 2 := Nat.succ_le_of_lt hQN have hQR : 2 * (n : ℝ) ^ 2 + 6 ≤ (2 * (j : ℝ) + 5) ^ 2 := by exact_mod_cast hQN2 have hQ'N : (2 * j + 3) ^ 2 < 2 * n ^ 2 + 6 := by exact_mod_cast hQ' have hQ'N2 : (2 * j + 3) ^ 2 ≤ 2 * n ^ 2 + 5 := Nat.lt_succ_iff.mp hQ'N have hQ'R : (2 * (j : ℝ) + 3) ^ 2 ≤ 2 * (n : ℝ) ^ 2 + 5 := by exact_mod_cast hQ'N2 have hQ9 : (9 : ℝ) ≤ (2 * (j : ℝ) + 3) ^ 2 := by nlinarith have e16 : 16 * (((j : ℝ) + 1) * ((j : ℝ) + 2) * ((j : ℝ) + 3) * ((j : ℝ) + 4)) = ((2 * (j : ℝ) + 5) ^ 2 - 1) * ((2 * (j : ℝ) + 5) ^ 2 - 9) := by ring have e16' : 16 * ((j : ℝ) * ((j : ℝ) + 1) * ((j : ℝ) + 2) * ((j : ℝ) + 3)) = ((2 * (j : ℝ) + 3) ^ 2 - 1) * ((2 * (j : ℝ) + 3) ^ 2 - 9) := by ring obtain ⟨Q, hQdef⟩ : ∃ Q : ℝ, Q = (2 * (j : ℝ) + 5) ^ 2 := ⟨_, rfl⟩ obtain ⟨P, hPdef⟩ : ∃ P : ℝ, P = (2 * (j : ℝ) + 3) ^ 2 := ⟨_, rfl⟩ rw [← hQdef] at hQR e16 rw [← hPdef] at hQ'R e16' hQ9 have hAr : (n : ℝ) ^ 4 < 4 * (((j : ℝ) + 1) * ((j : ℝ) + 2) * ((j : ℝ) + 3) * ((j : ℝ) + 4)) := by nlinarith [mul_nonneg (sub_nonneg.mpr hQR) (show (0 : ℝ) ≤ Q + (2 * (n : ℝ) ^ 2 + 6) - 10 by linarith), e16] have hBr : 4 * ((j : ℝ) * ((j : ℝ) + 1) * ((j : ℝ) + 2) * ((j : ℝ) + 3)) ≤ (n : ℝ) ^ 4 := by nlinarith [mul_nonneg (sub_nonneg.mpr hQ'R) (show (0 : ℝ) ≤ (2 * (n : ℝ) ^ 2 + 5) + P - 10 by linarith), e16'] have hAN : n * n * n * n < 4 * ((j + 1) * (j + 2) * (j + 3) * (j + 4)) := by have h : ((n : ℝ) * n * n * n) < 4 * (((j : ℝ) + 1) * ((j : ℝ) + 2) * ((j : ℝ) + 3) * ((j : ℝ) + 4)) := by nlinarith [hAr] exact_mod_cast h have hBN : 4 * (j * (j + 1) * (j + 2) * (j + 3)) ≤ n * n * n * n := by have h : 4 * ((j : ℝ) * ((j : ℝ) + 1) * ((j : ℝ) + 2) * ((j : ℝ) + 3)) ≤ ((n : ℝ) * n * n * n) := by nlinarith [hBr] exact_mod_cast h exact ⟨hAN, hBN⟩ /-- New: the quartic member of Kimberling's family has an exact closed form. -/ theorem quartic_formula (n : ℕ) (hn : 4 ≤ n) : IsLeast {k : ℕ | 1 ≤ k ∧ 1 / 96 - s k < 1 / (n : ℚ) ^ 4} ⌊(n : ℝ) * Real.sqrt 2 / 2 + 5 * Real.sqrt 2 / (8 * n) - 3 / 2⌋₊ := by have hc : Real.sqrt 2 ^ 2 = 2 := Real.sq_sqrt (by norm_num) have hc0 : 0 < Real.sqrt 2 := Real.sqrt_pos.mpr (by norm_num) have hn4 : (4 : ℝ) ≤ n := by exact_mod_cast hn have hn0 : (0 : ℝ) < n := by linarith have hc1 : 1 ≤ Real.sqrt 2 := by by_contra hlt rw [not_le] at hlt nlinarith have hx : (0 : ℝ) ≤ (n : ℝ) * Real.sqrt 2 / 2 + 5 * Real.sqrt 2 / (8 * n) - 3 / 2 := by have hp : 0 ≤ 5 * Real.sqrt 2 / (8 * (n : ℝ)) := div_nonneg (by linarith) (by linarith) have hq : 4 ≤ (n : ℝ) * Real.sqrt 2 := by nlinarith [mul_nonneg (sub_nonneg.mpr hn4) (sub_nonneg.mpr hc1)] linarith have h1 := Nat.floor_le hx have h2 := Nat.lt_floor_add_one ((n : ℝ) * Real.sqrt 2 / 2 + 5 * Real.sqrt 2 / (8 * n) - 3 / 2) generalize ⌊(n : ℝ) * Real.sqrt 2 / 2 + 5 * Real.sqrt 2 / (8 * n) - 3 / 2⌋₊ = j at h1 h2 ⊢ obtain ⟨hA, hB⟩ := real_part n j (by omega) (Real.sqrt 2) hc0 hc h1 h2 have hj1 : 1 ≤ j := by by_contra h0 have hz : j = 0 := by omega subst hz have := Nat.mul_le_mul (Nat.mul_le_mul (Nat.mul_le_mul hn hn) hn) hn omega constructor · exact ⟨hj1, (cond_iff n j (by omega)).mpr hA⟩ · intro k hk obtain ⟨_, hk2⟩ := hk by_contra hlt have hk3 := (cond_iff n k (by omega)).mp hk2 have hkj : k + 1 ≤ j := by omega have hm : (k + 1) * (k + 2) * (k + 3) * (k + 4) ≤ j * (j + 1) * (j + 2) * (j + 3) := Nat.mul_le_mul (Nat.mul_le_mul (Nat.mul_le_mul hkj (by omega)) (by omega)) (by omega) omega end Quartic namespace Family /-- k passes the test for (m, n) when n^m < m * (k+1)(k+2)...(k+m). -/ def Works (m n k : ℕ) : Prop := n ^ m < m * ∏ i ∈ Finset.range m, (k + 1 + i) /-- The closed formula. -/ noncomputable def formula (m n : ℕ) : ℝ := (n : ℝ) / (m : ℝ) ^ ((1 : ℝ) / m) + ((m : ℝ) ^ 2 - 1) * (m : ℝ) ^ ((1 : ℝ) / m) / (24 * n) - ((m : ℝ) - 1) / 2 /-- OUR CONJECTURE, stated but NOT proved: for every m >= 2 the formula gives the least passing k for all large enough n. -/ def Conjecture : Prop := ∀ m : ℕ, 2 ≤ m → ∃ N : ℕ, ∀ n : ℕ, N ≤ n → IsLeast {k : ℕ | Works m n k} ⌊formula m n⌋₊ /-- OUR CONJECTURE, stated but NOT proved: for m = 5 there are no exceptions at all. -/ def ConjectureFive : Prop := ∀ n : ℕ, 1 ≤ n → IsLeast {k : ℕ | Works 5 n k} ⌊formula 5 n⌋₊ end Family namespace Dorfman /-- Pooled blood testing (Dorfman, 1943). Mix k samples and test the mix once; if it is positive, test each sample. When a fraction q of samples is negative, the expected number of tests per person is 1/k + 1 - q^k. Testing one by one costs 1. -/ noncomputable def testsPerPerson (q : ℝ) (k : ℕ) : ℝ := 1 / (k : ℝ) + 1 - q ^ k theorem cube_le_three_pow (m : ℕ) : (m + 3) ^ 3 ≤ 3 ^ (m + 3) := by induction m with | zero => norm_num | succ m ih => have e : 3 * (m + 3) ^ 3 = (m + 1 + 3) ^ 3 + (2 * m ^ 3 + 15 * m ^ 2 + 33 * m + 17) := by ring have e2 : 3 ^ (m + 1 + 3) = 3 * 3 ^ (m + 3) := by ring have h1 : (m + 1 + 3) ^ 3 ≤ 3 * (m + 3) ^ 3 := by rw [e] exact Nat.le_add_right _ _ rw [e2] exact le_trans h1 (Nat.mul_le_mul_left 3 ih) theorem cube_le_three_pow' (k : ℕ) (hk : 2 ≤ k) : k ^ 3 ≤ 3 ^ k := by rcases Nat.lt_or_ge k 3 with h | h · have : k = 2 := by omega subst this norm_num · obtain ⟨m, rfl⟩ : ∃ m, k = m + 3 := ⟨k - 3, by omega⟩ exact cube_le_three_pow m /-- If 3 q^3 <= 1, no pool size beats testing one by one. -/ theorem pooling_never_helps (q : ℝ) (hq0 : 0 ≤ q) (h : 3 * q ^ 3 ≤ 1) (k : ℕ) (hk : 2 ≤ k) : 1 ≤ testsPerPerson q k := by have h3 : q ^ 3 ≤ 1 / 3 := by linarith have kpos : (0 : ℝ) < k := by exact_mod_cast (by omega : 0 < k) have a : (q ^ k) ^ 3 ≤ (1 / 3 : ℝ) ^ k := by rw [← pow_mul, mul_comm, pow_mul] exact pow_le_pow_left₀ (by positivity) h3 k have hcast : (k : ℝ) ^ 3 ≤ (3 : ℝ) ^ k := by exact_mod_cast cube_le_three_pow' k hk have b : (1 / 3 : ℝ) ^ k ≤ (1 / (k : ℝ)) ^ 3 := by rw [one_div_pow, one_div_pow] exact one_div_le_one_div_of_le (pow_pos kpos 3) hcast have c : q ^ k ≤ 1 / (k : ℝ) := by by_contra hlt rw [not_le] at hlt have hpos : (0 : ℝ) ≤ 1 / (k : ℝ) := by positivity have := pow_lt_pow_left₀ hlt hpos (by norm_num : (3 : ℕ) ≠ 0) linarith unfold testsPerPerson linarith /-- If 3 q^3 > 1, pools of three already beat testing one by one. -/ theorem pooling_helps (q : ℝ) (h : 1 < 3 * q ^ 3) : testsPerPerson q 3 < 1 := by unfold testsPerPerson push_cast linarith /-- **Pooling threshold.** Some pool size beats one-by-one testing exactly when 3 q^3 > 1, that is, when the negative fraction q exceeds the cube root of 1/3. This is the same number r that appears in the A248186 formula above. Known result (Samuels, 1978); this is a machine-checked proof of it. -/ theorem threshold (q : ℝ) (hq0 : 0 ≤ q) : (∃ k : ℕ, 2 ≤ k ∧ testsPerPerson q k < 1) ↔ 1 < 3 * q ^ 3 := by constructor · rintro ⟨k, hk, hlt⟩ by_contra hle rw [not_lt] at hle have := pooling_never_helps q hq0 hle k hk linarith · intro h exact ⟨3, by norm_num, pooling_helps q h⟩ end Dorfman #print axioms Galperin.kagey_conjecture #print axioms A248186.oudra_conjecture #print axioms Stechkin.oudra_conjecture #print axioms A394666.factorial_mod #print axioms A399155.largest_never_slower #print axioms A001076.dement #print axioms A102239.dement #print axioms A238952.hurt #print axioms McGarvey.mcgarvey #print axioms A341249.conjecture_false #print axioms Quartic.quartic_formula #print axioms A400520.ratushnyak_conjecture #print axioms Dorfman.threshold