File size: 5,410 Bytes
1c3ffd8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import Mathlib
set_option linter.unusedVariables.analyzeTactics true

open Real BigOperators

theorem imo_1969_p2
  (m n : ℝ)
  (k : β„•)
  (a : β„• β†’ ℝ)
  (f : ℝ β†’ ℝ)
  -- (hβ‚€ : 0 < k)
  -- (h₁ : βˆ€ x, f x = βˆ‘ i in Finset.range k, ((Real.cos (a i + x)) / (2^i)))
  (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