|
|
import Mathlib |
|
|
set_option linter.unusedVariables.analyzeTactics true |
|
|
|
|
|
open Real BigOperators |
|
|
|
|
|
theorem imo_1969_p2 |
|
|
(m n : ℝ) |
|
|
(k : ℕ) |
|
|
(a : ℕ → ℝ) |
|
|
(f : ℝ → ℝ) |
|
|
|
|
|
|
|
|
(h₁ : ∀ x, f x = Finset.sum (Finset.range k) fun i => ((Real.cos (a i + x)) / (2^i))) |
|
|
(h₂ : f m = 0) |
|
|
(h₃ : f n = 0) |
|
|
(h₄: Finset.sum (Finset.range k) (fun i => (((cos (a i)) / (2 ^ i)))) ≠ 0) : |
|
|
∃ t : ℤ, m - n = t * π := by |
|
|
let Ccos := Finset.sum (Finset.range k) (fun i => (((cos (a i)) / (2 ^ i)))) |
|
|
let Csin := Finset.sum (Finset.range k) (fun i => (((sin (a i)) / (2 ^ i)))) |
|
|
have hCcos: Ccos = Finset.sum (Finset.range k) (fun i => (((cos (a i)) / (2 ^ i)))) := by |
|
|
exact rfl |
|
|
have hCsin: Csin = Finset.sum (Finset.range k) (fun i => (((sin (a i)) / (2 ^ i)))) := by |
|
|
exact rfl |
|
|
have h₅: ∀ x, f x = Ccos * cos x - Csin * sin x := by |
|
|
intro x |
|
|
rw [h₁ x] |
|
|
have h₅₀: ∑ i ∈ Finset.range k, (cos (a i + x) / 2 ^ i) |
|
|
= ∑ i ∈ Finset.range k, (((cos (a i) * cos (x) - sin (a i) * sin (x)) / (2^i))) := by |
|
|
refine Finset.sum_congr (by rfl) ?_ |
|
|
simp |
|
|
intros i _ |
|
|
refine (div_eq_div_iff ?_ ?_).mpr ?_ |
|
|
. exact Ne.symm (NeZero.ne' (2 ^ i)) |
|
|
. exact Ne.symm (NeZero.ne' (2 ^ i)) |
|
|
. refine mul_eq_mul_right_iff.mpr ?_ |
|
|
simp |
|
|
exact cos_add (a i) x |
|
|
rw [h₅₀] |
|
|
ring_nf |
|
|
rw [Finset.sum_sub_distrib] |
|
|
have h₅₂: ∑ i ∈ Finset.range k, cos (a i) * cos x * (1 / 2) ^ i |
|
|
= ∑ i ∈ Finset.range k, (cos (a i) * (1 / 2) ^ i) * cos x := by |
|
|
refine Finset.sum_congr (by rfl) ?_ |
|
|
simp |
|
|
intro i _ |
|
|
linarith |
|
|
have h₅₃: ∑ x_1 ∈ Finset.range k, sin (a x_1) * sin x * (1 / 2) ^ x_1 |
|
|
= ∑ x_1 ∈ Finset.range k, ((sin (a x_1) * (1 / 2) ^ x_1) * sin x) := by |
|
|
refine Finset.sum_congr (by rfl) ?_ |
|
|
simp |
|
|
intro i _ |
|
|
linarith |
|
|
rw [h₅₂, ← Finset.sum_mul _ _ (cos x)] |
|
|
rw [h₅₃, ← Finset.sum_mul _ _ (sin x)] |
|
|
ring_nf at hCcos |
|
|
ring_nf at hCsin |
|
|
rw [hCcos, hCsin] |
|
|
have h₆: (∃ x, (f x = 0 ∧ cos x = 0)) → ∀ y, f y = Ccos * cos y := by |
|
|
intro g₀ |
|
|
obtain ⟨x, hx₀, hx₁⟩ := g₀ |
|
|
have g₁: Finset.sum (Finset.range k) (fun i => (((sin (a i)) / (2 ^ i)))) = 0 := by |
|
|
rw [h₅ x, hx₁] at hx₀ |
|
|
simp at hx₀ |
|
|
cases' hx₀ with hx₂ hx₃ |
|
|
. exact hx₂ |
|
|
. exfalso |
|
|
apply sin_eq_zero_iff_cos_eq.mp at hx₃ |
|
|
cases' hx₃ with hx₃ hx₄ |
|
|
. linarith |
|
|
. linarith |
|
|
intro y |
|
|
rw [h₅ y] |
|
|
have g₂: Csin = 0 := by |
|
|
linarith |
|
|
rw [g₂, zero_mul] |
|
|
exact sub_zero (Ccos * cos y) |
|
|
by_cases hmn: (cos m = 0) ∨ (cos n = 0) |
|
|
. have h₇: ∀ (x : ℝ), f x = Ccos * cos x := by |
|
|
refine h₆ ?_ |
|
|
cases' hmn with hm hn |
|
|
. use m |
|
|
. use n |
|
|
have h₈: ∀ x, f x = 0 → cos x = 0 := by |
|
|
intros x hx₀ |
|
|
rw [h₇ x] at hx₀ |
|
|
refine eq_zero_of_ne_zero_of_mul_left_eq_zero ?_ hx₀ |
|
|
exact h₄ |
|
|
have hm₀: ∃ t:ℤ , m = (2 * ↑ t + 1) * π / 2 := by |
|
|
refine cos_eq_zero_iff.mp ?_ |
|
|
exact h₈ m h₂ |
|
|
have hn₀: ∃ t:ℤ , n = (2 * ↑ t + 1) * π / 2 := by |
|
|
refine cos_eq_zero_iff.mp ?_ |
|
|
exact h₈ n h₃ |
|
|
obtain ⟨tm, hm₁⟩ := hm₀ |
|
|
obtain ⟨tn, hn₁⟩ := hn₀ |
|
|
rw [hm₁, hn₁] |
|
|
use (tm - tn) |
|
|
rw [Int.cast_sub] |
|
|
ring_nf |
|
|
. push_neg at hmn |
|
|
have h₇: tan m = tan n := by |
|
|
have h₇₀: ∀ (x:ℝ), (f x = 0 ∧ cos x ≠ 0) → tan x = Ccos / Csin := by |
|
|
intro x hx₀ |
|
|
rw [tan_eq_sin_div_cos] |
|
|
symm |
|
|
refine (div_eq_div_iff ?_ ?_).mp ?_ |
|
|
. simp |
|
|
exact hx₀.2 |
|
|
. simp |
|
|
have hx₁: Ccos * cos x ≠ 0 := by |
|
|
refine mul_ne_zero ?_ hx₀.2 |
|
|
exact h₄ |
|
|
have hx₂: Ccos * cos x = Csin * sin x := by |
|
|
rw [h₅ x] at hx₀ |
|
|
refine eq_of_sub_eq_zero ?_ |
|
|
exact hx₀.1 |
|
|
have hx₃: Csin * sin x ≠ 0 := by |
|
|
rw [← hx₂] |
|
|
exact hx₁ |
|
|
exact left_ne_zero_of_mul hx₃ |
|
|
. simp |
|
|
symm |
|
|
refine eq_of_sub_eq_zero ?_ |
|
|
rw [h₅ x] at hx₀ |
|
|
linarith |
|
|
have h₇₁: tan m = Ccos / Csin := by |
|
|
refine h₇₀ m ?_ |
|
|
constructor |
|
|
. exact h₂ |
|
|
. exact hmn.1 |
|
|
have h₇₂: tan n = Ccos / Csin := by |
|
|
refine h₇₀ n ?_ |
|
|
constructor |
|
|
. exact h₃ |
|
|
. exact hmn.2 |
|
|
rw [h₇₁, h₇₂] |
|
|
have h₈: sin (m - n) = 0 := by |
|
|
have h₈₀: tan m - tan n = 0 := by exact sub_eq_zero_of_eq h₇ |
|
|
have h₈₁: (sin m * cos n - cos m * sin n) / (cos m * cos n) = 0 := by |
|
|
rw [← div_sub_div (sin m) (sin n) hmn.1 hmn.2] |
|
|
repeat rw [← tan_eq_sin_div_cos] |
|
|
exact h₈₀ |
|
|
have h₈₂: sin (m - n) / (cos m * cos n) = 0 := by |
|
|
rw [sin_sub] |
|
|
exact h₈₁ |
|
|
apply div_eq_zero_iff.mp at h₈₂ |
|
|
cases' h₈₂ with h₈₂ h₈₃ |
|
|
. exact h₈₂ |
|
|
. exfalso |
|
|
simp at h₈₃ |
|
|
cases' h₈₃ with h₈₄ h₈₅ |
|
|
. exact hmn.1 h₈₄ |
|
|
. exact hmn.2 h₈₅ |
|
|
apply sin_eq_zero_iff.mp at h₈ |
|
|
let ⟨t, ht⟩ := h₈ |
|
|
use t |
|
|
exact ht.symm |
|
|
|