Add first 12 Lean solutions
Browse files- Putnam-bench-verified/1962/Putnam1962A1.lean +892 -0
- Putnam-bench-verified/1962/Putnam1962A2.lean +1068 -0
- Putnam-bench-verified/1962/Putnam1962A3.lean +382 -0
- Putnam-bench-verified/1962/Putnam1962A4.lean +187 -0
- Putnam-bench-verified/1962/Putnam1962A5.lean +73 -0
- Putnam-bench-verified/1962/Putnam1962A6.lean +82 -0
- Putnam-bench-verified/1962/Putnam1962B1.lean +49 -0
- Putnam-bench-verified/1962/Putnam1962B2.lean +30 -0
- Putnam-bench-verified/1962/Putnam1962B3.lean +26 -0
- Putnam-bench-verified/1962/Putnam1962B5.lean +306 -0
- Putnam-bench-verified/1962/Putnam1962B6.lean +1550 -0
- Putnam-bench-verified/1963/Putnam1963A2.lean +162 -0
- README.md +35 -0
Putnam-bench-verified/1962/Putnam1962A1.lean
ADDED
|
@@ -0,0 +1,892 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
open MeasureTheory
|
| 4 |
+
|
| 5 |
+
noncomputable section
|
| 6 |
+
|
| 7 |
+
open Set
|
| 8 |
+
|
| 9 |
+
private def std3 (i : Fin 3) : Fin 3 → ℝ := fun j => if i = j then 1 else 0
|
| 10 |
+
|
| 11 |
+
private def fin3Cycle120 : Equiv.Perm (Fin 3) where
|
| 12 |
+
toFun i := ![(2 : Fin 3), 0, 1] i
|
| 13 |
+
invFun i := ![(1 : Fin 3), 2, 0] i
|
| 14 |
+
left_inv := by
|
| 15 |
+
intro i
|
| 16 |
+
fin_cases i <;> rfl
|
| 17 |
+
right_inv := by
|
| 18 |
+
intro i
|
| 19 |
+
fin_cases i <;> rfl
|
| 20 |
+
|
| 21 |
+
private def fin3Cycle201 : Equiv.Perm (Fin 3) where
|
| 22 |
+
toFun i := ![(1 : Fin 3), 2, 0] i
|
| 23 |
+
invFun i := ![(2 : Fin 3), 0, 1] i
|
| 24 |
+
left_inv := by
|
| 25 |
+
intro i
|
| 26 |
+
fin_cases i <;> rfl
|
| 27 |
+
right_inv := by
|
| 28 |
+
intro i
|
| 29 |
+
fin_cases i <;> rfl
|
| 30 |
+
|
| 31 |
+
private lemma std3_extreme_left_notMem
|
| 32 |
+
{p q : Fin 3 → ℝ} (hp1 : 0 < p 1) (hq1 : 0 < q 1) :
|
| 33 |
+
std3 0 ∉ convexHull ℝ ({std3 2, p, q} : Set (Fin 3 → ℝ)) := by
|
| 34 |
+
classical
|
| 35 |
+
intro h
|
| 36 |
+
let U : Finset (Fin 3 → ℝ) := {std3 2, p, q}
|
| 37 |
+
have hU : std3 0 ∈ convexHull ℝ (U : Set (Fin 3 → ℝ)) := by
|
| 38 |
+
simpa [U] using h
|
| 39 |
+
rw [Finset.mem_convexHull'] at hU
|
| 40 |
+
rcases hU with ⟨w, hw_nonneg, _hw_sum, hw_eq⟩
|
| 41 |
+
have hcoord1 := congr_fun hw_eq (1 : Fin 3)
|
| 42 |
+
have hw_p_nonneg : 0 ≤ w p := hw_nonneg p (by simp [U])
|
| 43 |
+
have hw_q_nonneg : 0 ≤ w q := hw_nonneg q (by simp [U])
|
| 44 |
+
have hsumzero : ∑ x ∈ ({p, q} : Finset (Fin 3 → ℝ)), w x * x 1 = 0 := by
|
| 45 |
+
simpa [U, std3] using hcoord1
|
| 46 |
+
have hterm_zero :
|
| 47 |
+
∀ x ∈ ({p, q} : Finset (Fin 3 → ℝ)), w x * x 1 = 0 := by
|
| 48 |
+
exact (Finset.sum_eq_zero_iff_of_nonneg (by
|
| 49 |
+
intro x hx
|
| 50 |
+
simp at hx
|
| 51 |
+
rcases hx with rfl | rfl
|
| 52 |
+
· exact mul_nonneg hw_p_nonneg hp1.le
|
| 53 |
+
· exact mul_nonneg hw_q_nonneg hq1.le)).mp hsumzero
|
| 54 |
+
have hwp : w p = 0 := by
|
| 55 |
+
have hpzero := hterm_zero p (by simp)
|
| 56 |
+
exact (mul_eq_zero.mp hpzero).resolve_right (ne_of_gt hp1)
|
| 57 |
+
have hwq : w q = 0 := by
|
| 58 |
+
have hqzero := hterm_zero q (by simp)
|
| 59 |
+
exact (mul_eq_zero.mp hqzero).resolve_right (ne_of_gt hq1)
|
| 60 |
+
have hcoord0 := congr_fun hw_eq (0 : Fin 3)
|
| 61 |
+
simp [U, std3, hwp, hwq] at hcoord0
|
| 62 |
+
|
| 63 |
+
private lemma std3_extreme_right_notMem
|
| 64 |
+
{p q : Fin 3 → ℝ} (hp1 : 0 < p 1) (hq1 : 0 < q 1) :
|
| 65 |
+
std3 2 ∉ convexHull ℝ ({std3 0, p, q} : Set (Fin 3 → ℝ)) := by
|
| 66 |
+
classical
|
| 67 |
+
intro h
|
| 68 |
+
let U : Finset (Fin 3 → ℝ) := {std3 0, p, q}
|
| 69 |
+
have hU : std3 2 ∈ convexHull ℝ (U : Set (Fin 3 → ℝ)) := by
|
| 70 |
+
simpa [U] using h
|
| 71 |
+
rw [Finset.mem_convexHull'] at hU
|
| 72 |
+
rcases hU with ⟨w, hw_nonneg, _hw_sum, hw_eq⟩
|
| 73 |
+
have hcoord1 := congr_fun hw_eq (1 : Fin 3)
|
| 74 |
+
have hw_p_nonneg : 0 ≤ w p := hw_nonneg p (by simp [U])
|
| 75 |
+
have hw_q_nonneg : 0 ≤ w q := hw_nonneg q (by simp [U])
|
| 76 |
+
have hsumzero : ∑ x ∈ ({p, q} : Finset (Fin 3 → ℝ)), w x * x 1 = 0 := by
|
| 77 |
+
simpa [U, std3] using hcoord1
|
| 78 |
+
have hterm_zero :
|
| 79 |
+
∀ x ∈ ({p, q} : Finset (Fin 3 → ℝ)), w x * x 1 = 0 := by
|
| 80 |
+
exact (Finset.sum_eq_zero_iff_of_nonneg (by
|
| 81 |
+
intro x hx
|
| 82 |
+
simp at hx
|
| 83 |
+
rcases hx with rfl | rfl
|
| 84 |
+
· exact mul_nonneg hw_p_nonneg hp1.le
|
| 85 |
+
· exact mul_nonneg hw_q_nonneg hq1.le)).mp hsumzero
|
| 86 |
+
have hwp : w p = 0 := by
|
| 87 |
+
have hpzero := hterm_zero p (by simp)
|
| 88 |
+
exact (mul_eq_zero.mp hpzero).resolve_right (ne_of_gt hp1)
|
| 89 |
+
have hwq : w q = 0 := by
|
| 90 |
+
have hqzero := hterm_zero q (by simp)
|
| 91 |
+
exact (mul_eq_zero.mp hqzero).resolve_right (ne_of_gt hq1)
|
| 92 |
+
have hcoord2 := congr_fun hw_eq (2 : Fin 3)
|
| 93 |
+
simp [U, std3, hwp, hwq] at hcoord2
|
| 94 |
+
|
| 95 |
+
private lemma std3_middle_point_notMem
|
| 96 |
+
{p q : Fin 3 → ℝ}
|
| 97 |
+
(hq0 : 0 < q 0) (hq1 : 0 < q 1)
|
| 98 |
+
(h01 : p 0 / q 0 < p 1 / q 1) :
|
| 99 |
+
p ∉ convexHull ℝ ({std3 0, std3 2, q} : Set (Fin 3 → ℝ)) := by
|
| 100 |
+
classical
|
| 101 |
+
intro h
|
| 102 |
+
let U : Finset (Fin 3 → ℝ) := {std3 0, std3 2, q}
|
| 103 |
+
have hU : p ∈ convexHull ℝ (U : Set (Fin 3 → ℝ)) := by
|
| 104 |
+
simpa [U] using h
|
| 105 |
+
rw [Finset.mem_convexHull'] at hU
|
| 106 |
+
rcases hU with ⟨w, hw_nonneg, _hw_sum, hw_eq⟩
|
| 107 |
+
have hcoord0 := congr_fun hw_eq (0 : Fin 3)
|
| 108 |
+
have hcoord1 := congr_fun hw_eq (1 : Fin 3)
|
| 109 |
+
have hw0_nonneg : 0 ≤ w (std3 0) := hw_nonneg (std3 0) (by simp [U])
|
| 110 |
+
have h02 : std3 0 ≠ std3 2 := by
|
| 111 |
+
intro h
|
| 112 |
+
have := congr_fun h (0 : Fin 3)
|
| 113 |
+
simp [std3] at this
|
| 114 |
+
have hq_ne0 : q ≠ std3 0 := by
|
| 115 |
+
intro h
|
| 116 |
+
have := congr_fun h (1 : Fin 3)
|
| 117 |
+
simp [std3] at this
|
| 118 |
+
linarith
|
| 119 |
+
have hq_ne2 : q ≠ std3 2 := by
|
| 120 |
+
intro h
|
| 121 |
+
have := congr_fun h (1 : Fin 3)
|
| 122 |
+
simp [std3] at this
|
| 123 |
+
linarith
|
| 124 |
+
have hratio : p 0 * q 1 < p 1 * q 0 := by
|
| 125 |
+
have hq0ne : q 0 ≠ 0 := ne_of_gt hq0
|
| 126 |
+
have hq1ne : q 1 ≠ 0 := ne_of_gt hq1
|
| 127 |
+
field_simp [hq0ne, hq1ne] at h01
|
| 128 |
+
nlinarith
|
| 129 |
+
simp [U, std3, h02, hq_ne0.symm, hq_ne2.symm] at hcoord0 hcoord1
|
| 130 |
+
have hle : p 1 * q 0 ≤ p 0 * q 1 := by
|
| 131 |
+
nlinarith [mul_nonneg hw0_nonneg hq1.le]
|
| 132 |
+
nlinarith
|
| 133 |
+
|
| 134 |
+
private lemma std3_middle_point_notMem'
|
| 135 |
+
{p q : Fin 3 → ℝ}
|
| 136 |
+
(hp1 : 0 < p 1) (hp2 : 0 < p 2)
|
| 137 |
+
(hq1 : 0 < q 1) (hq2 : 0 < q 2)
|
| 138 |
+
(h12 : p 1 / q 1 < p 2 / q 2) :
|
| 139 |
+
q ∉ convexHull ℝ ({std3 0, std3 2, p} : Set (Fin 3 → ℝ)) := by
|
| 140 |
+
classical
|
| 141 |
+
intro h
|
| 142 |
+
let U : Finset (Fin 3 → ℝ) := {std3 0, std3 2, p}
|
| 143 |
+
have hU : q ∈ convexHull ℝ (U : Set (Fin 3 → ℝ)) := by
|
| 144 |
+
simpa [U] using h
|
| 145 |
+
rw [Finset.mem_convexHull'] at hU
|
| 146 |
+
rcases hU with ⟨w, hw_nonneg, _hw_sum, hw_eq⟩
|
| 147 |
+
have hcoord1 := congr_fun hw_eq (1 : Fin 3)
|
| 148 |
+
have hcoord2 := congr_fun hw_eq (2 : Fin 3)
|
| 149 |
+
have hw2_nonneg : 0 ≤ w (std3 2) := hw_nonneg (std3 2) (by simp [U])
|
| 150 |
+
have h02 : std3 0 ≠ std3 2 := by
|
| 151 |
+
intro h
|
| 152 |
+
have := congr_fun h (0 : Fin 3)
|
| 153 |
+
simp [std3] at this
|
| 154 |
+
have hp_ne0 : p ≠ std3 0 := by
|
| 155 |
+
intro h
|
| 156 |
+
have := congr_fun h (1 : Fin 3)
|
| 157 |
+
simp [std3] at this
|
| 158 |
+
linarith
|
| 159 |
+
have hp_ne2 : p ≠ std3 2 := by
|
| 160 |
+
intro h
|
| 161 |
+
have := congr_fun h (1 : Fin 3)
|
| 162 |
+
simp [std3] at this
|
| 163 |
+
linarith
|
| 164 |
+
have hratio : p 1 * q 2 < p 2 * q 1 := by
|
| 165 |
+
have hq1ne : q 1 ≠ 0 := ne_of_gt hq1
|
| 166 |
+
have hq2ne : q 2 ≠ 0 := ne_of_gt hq2
|
| 167 |
+
field_simp [hq1ne, hq2ne] at h12
|
| 168 |
+
nlinarith
|
| 169 |
+
simp [U, std3, h02, hp_ne0.symm, hp_ne2.symm] at hcoord1 hcoord2
|
| 170 |
+
have hle : p 2 * q 1 ≤ p 1 * q 2 := by
|
| 171 |
+
nlinarith [mul_nonneg hw2_nonneg hp1.le]
|
| 172 |
+
nlinarith
|
| 173 |
+
|
| 174 |
+
private lemma std3_convexIndependent_of_ratio
|
| 175 |
+
{p q : Fin 3 → ℝ}
|
| 176 |
+
(hp0 : 0 < p 0) (hp1 : 0 < p 1) (hp2 : 0 < p 2)
|
| 177 |
+
(hq0 : 0 < q 0) (hq1 : 0 < q 1) (hq2 : 0 < q 2)
|
| 178 |
+
(h01 : p 0 / q 0 < p 1 / q 1)
|
| 179 |
+
(h12 : p 1 / q 1 < p 2 / q 2) :
|
| 180 |
+
ConvexIndependent ℝ
|
| 181 |
+
((↑) : ({std3 0, std3 2, p, q} : Set (Fin 3 → ℝ)) → (Fin 3 → ℝ)) := by
|
| 182 |
+
classical
|
| 183 |
+
rw [convexIndependent_set_iff_notMem_convexHull_diff]
|
| 184 |
+
intro x hx
|
| 185 |
+
rw [Set.mem_insert_iff, Set.mem_insert_iff, Set.mem_insert_iff, Set.mem_singleton_iff] at hx
|
| 186 |
+
rcases hx with rfl | rfl | rfl | rfl
|
| 187 |
+
· intro h
|
| 188 |
+
exact std3_extreme_left_notMem hp1 hq1
|
| 189 |
+
(convexHull_mono (by intro y hy; simp at hy ⊢; tauto) h)
|
| 190 |
+
· intro h
|
| 191 |
+
exact std3_extreme_right_notMem hp1 hq1
|
| 192 |
+
(convexHull_mono (by intro y hy; simp at hy ⊢; tauto) h)
|
| 193 |
+
· intro h
|
| 194 |
+
exact std3_middle_point_notMem hq0 hq1 h01
|
| 195 |
+
(convexHull_mono (by intro y hy; simp at hy ⊢; tauto) h)
|
| 196 |
+
· intro h
|
| 197 |
+
exact std3_middle_point_notMem' hp1 hp2 hq1 hq2 h12
|
| 198 |
+
(convexHull_mono (by intro y hy; simp at hy ⊢; tauto) h)
|
| 199 |
+
|
| 200 |
+
private lemma exists_quad_of_four_extreme
|
| 201 |
+
{S : Set (ℝ × ℝ)}
|
| 202 |
+
(hE4 : 4 ≤ ((convexHull ℝ S).extremePoints ℝ).ncard) :
|
| 203 |
+
∃ T ⊆ S, T.ncard = 4 ∧ ¬∃ t ∈ T, t ∈ convexHull ℝ (T \ {t}) := by
|
| 204 |
+
classical
|
| 205 |
+
let E : Set (ℝ × ℝ) := (convexHull ℝ S).extremePoints ℝ
|
| 206 |
+
obtain ⟨T, _hempty, hTE, hTcard⟩ :=
|
| 207 |
+
Set.exists_subsuperset_card_eq (s := (∅ : Set (ℝ × ℝ))) (t := E) (n := 4)
|
| 208 |
+
(by simp) (by simp) hE4
|
| 209 |
+
have hEsubS : E ⊆ S := by
|
| 210 |
+
intro x hx
|
| 211 |
+
exact extremePoints_convexHull_subset (𝕜 := ℝ) (A := S) hx
|
| 212 |
+
have hTsubS : T ⊆ S := hTE.trans hEsubS
|
| 213 |
+
have hEci : ConvexIndependent ℝ ((↑) : E → (ℝ × ℝ)) :=
|
| 214 |
+
(convex_convexHull ℝ S).convexIndependent_extremePoints
|
| 215 |
+
have hTci : ConvexIndependent ℝ ((↑) : T → (ℝ × ℝ)) :=
|
| 216 |
+
hEci.mono hTE
|
| 217 |
+
have hTnot : ∀ t ∈ T, t ∉ convexHull ℝ (T \ {t}) :=
|
| 218 |
+
convexIndependent_set_iff_notMem_convexHull_diff.mp hTci
|
| 219 |
+
refine ⟨T, hTsubS, hTcard, ?_⟩
|
| 220 |
+
rintro ⟨t, htT, htconv⟩
|
| 221 |
+
exact hTnot t htT htconv
|
| 222 |
+
|
| 223 |
+
private lemma subset_convexHull_extremePoints_of_finite
|
| 224 |
+
{S : Set (ℝ × ℝ)} (hSfin : S.Finite) :
|
| 225 |
+
S ⊆ convexHull ℝ ((convexHull ℝ S).extremePoints ℝ) := by
|
| 226 |
+
intro x hx
|
| 227 |
+
have hcompact : IsCompact (convexHull ℝ S) := hSfin.isCompact_convexHull
|
| 228 |
+
have hconv : Convex ℝ (convexHull ℝ S) := convex_convexHull ℝ S
|
| 229 |
+
have hEsub : (convexHull ℝ S).extremePoints ℝ ⊆ S := by
|
| 230 |
+
intro y hy
|
| 231 |
+
exact extremePoints_convexHull_subset (𝕜 := ℝ) (A := S) hy
|
| 232 |
+
have hclosed : IsClosed (convexHull ℝ ((convexHull ℝ S).extremePoints ℝ)) :=
|
| 233 |
+
(hSfin.subset hEsub).isClosed_convexHull
|
| 234 |
+
have hkm := closure_convexHull_extremePoints hcompact hconv
|
| 235 |
+
have hxcl : x ∈ closure (convexHull ℝ ((convexHull ℝ S).extremePoints ℝ)) := by
|
| 236 |
+
rw [hkm]
|
| 237 |
+
exact subset_convexHull ℝ S hx
|
| 238 |
+
simpa [hclosed.closure_eq] using hxcl
|
| 239 |
+
|
| 240 |
+
private lemma collinear_triple_of_mem_convexHull_pair
|
| 241 |
+
{a b x y z : ℝ × ℝ}
|
| 242 |
+
(hx : x ∈ convexHull ℝ ({a, b} : Set (ℝ × ℝ)))
|
| 243 |
+
(hy : y ∈ convexHull ℝ ({a, b} : Set (ℝ × ℝ)))
|
| 244 |
+
(hz : z ∈ convexHull ℝ ({a, b} : Set (ℝ × ℝ))) :
|
| 245 |
+
Collinear ℝ ({x, y, z} : Set (ℝ × ℝ)) := by
|
| 246 |
+
have hxline : x ∈ line[ℝ, a, b] :=
|
| 247 |
+
convexHull_subset_affineSpan ({a, b} : Set (ℝ × ℝ)) hx
|
| 248 |
+
have hyline : y ∈ line[ℝ, a, b] :=
|
| 249 |
+
convexHull_subset_affineSpan ({a, b} : Set (ℝ × ℝ)) hy
|
| 250 |
+
have hzline : z ∈ line[ℝ, a, b] :=
|
| 251 |
+
convexHull_subset_affineSpan ({a, b} : Set (ℝ × ℝ)) hz
|
| 252 |
+
exact collinear_triple_of_mem_affineSpan_pair hxline hyline hzline
|
| 253 |
+
|
| 254 |
+
private lemma not_extremePoints_ncard_le_two
|
| 255 |
+
{S : Set (ℝ × ℝ)}
|
| 256 |
+
(hS : S.ncard = 5)
|
| 257 |
+
(hnoncol : ∀ s ⊆ S, s.ncard = 3 → ¬Collinear ℝ s) :
|
| 258 |
+
¬ ((convexHull ℝ S).extremePoints ℝ).ncard ≤ 2 := by
|
| 259 |
+
classical
|
| 260 |
+
let E : Set (ℝ × ℝ) := (convexHull ℝ S).extremePoints ℝ
|
| 261 |
+
have hSfin : S.Finite := Set.finite_of_ncard_ne_zero (by rw [hS]; norm_num)
|
| 262 |
+
have hEsubS : E ⊆ S := by
|
| 263 |
+
intro x hx
|
| 264 |
+
exact extremePoints_convexHull_subset (𝕜 := ℝ) (A := S) hx
|
| 265 |
+
have hEfin : E.Finite := hSfin.subset hEsubS
|
| 266 |
+
have hSsubHullE : S ⊆ convexHull ℝ E := by
|
| 267 |
+
simpa [E] using subset_convexHull_extremePoints_of_finite hSfin
|
| 268 |
+
obtain ⟨x, hxS, y, hyS, z, hzS, hxy, hxz, hyz⟩ :=
|
| 269 |
+
(Set.two_lt_ncard hSfin).mp (by rw [hS]; norm_num)
|
| 270 |
+
have hxyzsubS : ({x, y, z} : Set (ℝ × ℝ)) ⊆ S := by
|
| 271 |
+
intro w hw
|
| 272 |
+
simp at hw
|
| 273 |
+
rcases hw with rfl | rfl | rfl
|
| 274 |
+
· exact hxS
|
| 275 |
+
· exact hyS
|
| 276 |
+
· exact hzS
|
| 277 |
+
have hxyzcard : ({x, y, z} : Set (ℝ × ℝ)).ncard = 3 := by
|
| 278 |
+
rw [Set.ncard_eq_three]
|
| 279 |
+
exact ⟨x, y, z, hxy, hxz, hyz, rfl⟩
|
| 280 |
+
have hnotxyz : ¬Collinear ℝ ({x, y, z} : Set (ℝ × ℝ)) :=
|
| 281 |
+
hnoncol ({x, y, z} : Set (ℝ × ℝ)) hxyzsubS hxyzcard
|
| 282 |
+
intro hEle2
|
| 283 |
+
have hEle2E : E.ncard ≤ 2 := by
|
| 284 |
+
simpa [E] using hEle2
|
| 285 |
+
have hcases : E.ncard = 0 ∨ E.ncard = 1 ∨ E.ncard = 2 := by omega
|
| 286 |
+
rcases hcases with hE0 | hE1 | hE2
|
| 287 |
+
· have hEempty : E = ∅ := by
|
| 288 |
+
simpa [Set.ncard_eq_zero hEfin] using hE0
|
| 289 |
+
have hxHull := hSsubHullE hxS
|
| 290 |
+
simp [hEempty] at hxHull
|
| 291 |
+
· obtain ⟨a, hEeq⟩ := Set.ncard_eq_one.mp hE1
|
| 292 |
+
have hxEq : x = a := by
|
| 293 |
+
have hxHull := hSsubHullE hxS
|
| 294 |
+
simpa [hEeq] using hxHull
|
| 295 |
+
have hyEq : y = a := by
|
| 296 |
+
have hyHull := hSsubHullE hyS
|
| 297 |
+
simpa [hEeq] using hyHull
|
| 298 |
+
exact hxy (hxEq.trans hyEq.symm)
|
| 299 |
+
· obtain ⟨a, b, _hab, hEeq⟩ := Set.ncard_eq_two.mp hE2
|
| 300 |
+
have hxHull : x ∈ convexHull ℝ ({a, b} : Set (ℝ × ℝ)) := by
|
| 301 |
+
simpa [hEeq] using hSsubHullE hxS
|
| 302 |
+
have hyHull : y ∈ convexHull ℝ ({a, b} : Set (ℝ × ℝ)) := by
|
| 303 |
+
simpa [hEeq] using hSsubHullE hyS
|
| 304 |
+
have hzHull : z ∈ convexHull ℝ ({a, b} : Set (ℝ × ℝ)) := by
|
| 305 |
+
simpa [hEeq] using hSsubHullE hzS
|
| 306 |
+
exact hnotxyz (collinear_triple_of_mem_convexHull_pair hxHull hyHull hzHull)
|
| 307 |
+
|
| 308 |
+
private lemma not_collinear_of_mem_distinct
|
| 309 |
+
{S : Set (ℝ × ℝ)}
|
| 310 |
+
(hnoncol : ∀ s ⊆ S, s.ncard = 3 → ¬Collinear ℝ s)
|
| 311 |
+
{a b c : ℝ × ℝ}
|
| 312 |
+
(haS : a ∈ S) (hbS : b ∈ S) (hcS : c ∈ S)
|
| 313 |
+
(hab : a ≠ b) (hac : a ≠ c) (hbc : b ≠ c) :
|
| 314 |
+
¬Collinear ℝ ({a, b, c} : Set (ℝ × ℝ)) := by
|
| 315 |
+
have hsub : ({a, b, c} : Set (ℝ × ℝ)) ⊆ S := by
|
| 316 |
+
intro x hx
|
| 317 |
+
simp at hx
|
| 318 |
+
rcases hx with rfl | rfl | rfl
|
| 319 |
+
· exact haS
|
| 320 |
+
· exact hbS
|
| 321 |
+
· exact hcS
|
| 322 |
+
have hcard : ({a, b, c} : Set (ℝ × ℝ)).ncard = 3 := by
|
| 323 |
+
rw [Set.ncard_eq_three]
|
| 324 |
+
exact ⟨a, b, c, hab, hac, hbc, rfl⟩
|
| 325 |
+
exact hnoncol ({a, b, c} : Set (ℝ × ℝ)) hsub hcard
|
| 326 |
+
|
| 327 |
+
private lemma affineBasis_convexIndependent_of_ratio
|
| 328 |
+
(b : AffineBasis (Fin 3) ℝ (ℝ × ℝ)) {p q : ℝ × ℝ}
|
| 329 |
+
(hp0 : 0 < b.coord 0 p) (hp1 : 0 < b.coord 1 p) (hp2 : 0 < b.coord 2 p)
|
| 330 |
+
(hq0 : 0 < b.coord 0 q) (hq1 : 0 < b.coord 1 q) (hq2 : 0 < b.coord 2 q)
|
| 331 |
+
(h01 : b.coord 0 p / b.coord 0 q < b.coord 1 p / b.coord 1 q)
|
| 332 |
+
(h12 : b.coord 1 p / b.coord 1 q < b.coord 2 p / b.coord 2 q) :
|
| 333 |
+
ConvexIndependent ℝ
|
| 334 |
+
((↑) : ({b 0, b 2, p, q} : Set (ℝ × ℝ)) → (ℝ × ℝ)) := by
|
| 335 |
+
classical
|
| 336 |
+
let f : (ℝ × ℝ) →ᵃ[ℝ] (Fin 3 → ℝ) := b.coords
|
| 337 |
+
let C : Set (Fin 3 → ℝ) := {std3 0, std3 2, f p, f q}
|
| 338 |
+
have hf_inj : Function.Injective f := by
|
| 339 |
+
intro x y hxy
|
| 340 |
+
apply b.ext_elem
|
| 341 |
+
intro i
|
| 342 |
+
exact congr_fun hxy i
|
| 343 |
+
have hb0 : f (b 0) = std3 0 := by
|
| 344 |
+
ext i
|
| 345 |
+
fin_cases i <;> simp [f, std3]
|
| 346 |
+
have hb2 : f (b 2) = std3 2 := by
|
| 347 |
+
ext i
|
| 348 |
+
fin_cases i <;> simp [f, std3]
|
| 349 |
+
have hCci : ConvexIndependent ℝ ((↑) : C → (Fin 3 → ℝ)) := by
|
| 350 |
+
subst C
|
| 351 |
+
simpa [f, AffineBasis.coords_apply] using
|
| 352 |
+
(std3_convexIndependent_of_ratio
|
| 353 |
+
(p := f p) (q := f q)
|
| 354 |
+
(by simpa [f, AffineBasis.coords_apply] using hp0)
|
| 355 |
+
(by simpa [f, AffineBasis.coords_apply] using hp1)
|
| 356 |
+
(by simpa [f, AffineBasis.coords_apply] using hp2)
|
| 357 |
+
(by simpa [f, AffineBasis.coords_apply] using hq0)
|
| 358 |
+
(by simpa [f, AffineBasis.coords_apply] using hq1)
|
| 359 |
+
(by simpa [f, AffineBasis.coords_apply] using hq2)
|
| 360 |
+
(by simpa [f, AffineBasis.coords_apply] using h01)
|
| 361 |
+
(by simpa [f, AffineBasis.coords_apply] using h12))
|
| 362 |
+
rw [convexIndependent_set_iff_notMem_convexHull_diff]
|
| 363 |
+
intro x hxT hxconv
|
| 364 |
+
have hxC : f x ∈ C := by
|
| 365 |
+
rw [Set.mem_insert_iff, Set.mem_insert_iff, Set.mem_insert_iff, Set.mem_singleton_iff] at hxT
|
| 366 |
+
rcases hxT with rfl | rfl | rfl | rfl
|
| 367 |
+
· simp [C, hb0]
|
| 368 |
+
· simp [C, hb2]
|
| 369 |
+
· simp [C]
|
| 370 |
+
· simp [C]
|
| 371 |
+
have hxcoord : f x ∈ convexHull ℝ (f '' (({b 0, b 2, p, q} : Set (ℝ × ℝ)) \ {x})) := by
|
| 372 |
+
rw [← f.image_convexHull]
|
| 373 |
+
exact ⟨x, hxconv, rfl⟩
|
| 374 |
+
have himage_subset : f '' (({b 0, b 2, p, q} : Set (ℝ × ℝ)) \ {x}) ⊆ C \ {f x} := by
|
| 375 |
+
rintro y ⟨z, hz, rfl⟩
|
| 376 |
+
rcases hz with ⟨hzT, hzx⟩
|
| 377 |
+
constructor
|
| 378 |
+
· rw [Set.mem_insert_iff, Set.mem_insert_iff, Set.mem_insert_iff, Set.mem_singleton_iff] at hzT
|
| 379 |
+
rcases hzT with rfl | rfl | rfl | rfl
|
| 380 |
+
· simp [C, hb0]
|
| 381 |
+
· simp [C, hb2]
|
| 382 |
+
· simp [C]
|
| 383 |
+
· simp [C]
|
| 384 |
+
· intro hfx
|
| 385 |
+
exact hzx (hf_inj hfx)
|
| 386 |
+
exact (convexIndependent_set_iff_notMem_convexHull_diff.mp hCci)
|
| 387 |
+
(f x) hxC (convexHull_mono himage_subset hxcoord)
|
| 388 |
+
|
| 389 |
+
private lemma coord_zero_mem_line12
|
| 390 |
+
(b : AffineBasis (Fin 3) ℝ (ℝ × ℝ)) {p : ℝ × ℝ}
|
| 391 |
+
(h0 : b.coord 0 p = 0) : p ∈ affineSpan ℝ ({b 1, b 2} : Set (ℝ × ℝ)) := by
|
| 392 |
+
rw [mem_affineSpan_pair_iff_exists_lineMap_eq]
|
| 393 |
+
refine ⟨b.coord 2 p, ?_⟩
|
| 394 |
+
apply b.ext_elem
|
| 395 |
+
intro i
|
| 396 |
+
fin_cases i
|
| 397 |
+
· rw [AffineMap.apply_lineMap]
|
| 398 |
+
simp [h0]
|
| 399 |
+
· rw [AffineMap.apply_lineMap]
|
| 400 |
+
have hsum := b.sum_coord_apply_eq_one p
|
| 401 |
+
rw [Fin.sum_univ_three] at hsum
|
| 402 |
+
simp [AffineMap.lineMap_apply_module]
|
| 403 |
+
linarith
|
| 404 |
+
· rw [AffineMap.apply_lineMap]
|
| 405 |
+
simp [AffineMap.lineMap_apply_module]
|
| 406 |
+
|
| 407 |
+
private lemma coord_zero_mem_line02
|
| 408 |
+
(b : AffineBasis (Fin 3) ℝ (ℝ × ℝ)) {p : ℝ × ℝ}
|
| 409 |
+
(h1 : b.coord 1 p = 0) : p ∈ affineSpan ℝ ({b 0, b 2} : Set (ℝ × ℝ)) := by
|
| 410 |
+
rw [mem_affineSpan_pair_iff_exists_lineMap_eq]
|
| 411 |
+
refine ⟨b.coord 2 p, ?_⟩
|
| 412 |
+
apply b.ext_elem
|
| 413 |
+
intro i
|
| 414 |
+
fin_cases i
|
| 415 |
+
· rw [AffineMap.apply_lineMap]
|
| 416 |
+
have hsum := b.sum_coord_apply_eq_one p
|
| 417 |
+
rw [Fin.sum_univ_three] at hsum
|
| 418 |
+
simp [AffineMap.lineMap_apply_module]
|
| 419 |
+
linarith
|
| 420 |
+
· rw [AffineMap.apply_lineMap]
|
| 421 |
+
simp [h1]
|
| 422 |
+
· rw [AffineMap.apply_lineMap]
|
| 423 |
+
simp [AffineMap.lineMap_apply_module]
|
| 424 |
+
|
| 425 |
+
private lemma coord_zero_mem_line01
|
| 426 |
+
(b : AffineBasis (Fin 3) ℝ (ℝ × ℝ)) {p : ℝ × ℝ}
|
| 427 |
+
(h2 : b.coord 2 p = 0) : p ∈ affineSpan ℝ ({b 0, b 1} : Set (ℝ × ℝ)) := by
|
| 428 |
+
rw [mem_affineSpan_pair_iff_exists_lineMap_eq]
|
| 429 |
+
refine ⟨b.coord 1 p, ?_⟩
|
| 430 |
+
apply b.ext_elem
|
| 431 |
+
intro i
|
| 432 |
+
fin_cases i
|
| 433 |
+
· rw [AffineMap.apply_lineMap]
|
| 434 |
+
have hsum := b.sum_coord_apply_eq_one p
|
| 435 |
+
rw [Fin.sum_univ_three] at hsum
|
| 436 |
+
simp [AffineMap.lineMap_apply_module]
|
| 437 |
+
linarith
|
| 438 |
+
· rw [AffineMap.apply_lineMap]
|
| 439 |
+
simp [AffineMap.lineMap_apply_module]
|
| 440 |
+
· rw [AffineMap.apply_lineMap]
|
| 441 |
+
simp [h2]
|
| 442 |
+
|
| 443 |
+
private lemma coord0_pos_of_mem_convexHull_of_not_collinear
|
| 444 |
+
(b : AffineBasis (Fin 3) ℝ (ℝ × ℝ)) {p : ℝ × ℝ}
|
| 445 |
+
(hp : p ∈ convexHull ℝ (Set.range b))
|
| 446 |
+
(hnot : ¬ Collinear ℝ ({p, b 1, b 2} : Set (ℝ × ℝ))) :
|
| 447 |
+
0 < b.coord 0 p := by
|
| 448 |
+
have hpnonneg : ∀ i, 0 ≤ b.coord i p := by
|
| 449 |
+
simpa [AffineBasis.convexHull_eq_nonneg_coord] using hp
|
| 450 |
+
have hne : b.coord 0 p ≠ 0 := by
|
| 451 |
+
intro hzero
|
| 452 |
+
exact hnot (collinear_insert_of_mem_affineSpan_pair (coord_zero_mem_line12 b hzero))
|
| 453 |
+
exact lt_of_le_of_ne (hpnonneg 0) hne.symm
|
| 454 |
+
|
| 455 |
+
private lemma coord1_pos_of_mem_convexHull_of_not_collinear
|
| 456 |
+
(b : AffineBasis (Fin 3) ℝ (ℝ × ℝ)) {p : ℝ × ℝ}
|
| 457 |
+
(hp : p ∈ convexHull ℝ (Set.range b))
|
| 458 |
+
(hnot : ¬ Collinear ℝ ({p, b 0, b 2} : Set (ℝ × ℝ))) :
|
| 459 |
+
0 < b.coord 1 p := by
|
| 460 |
+
have hpnonneg : ∀ i, 0 ≤ b.coord i p := by
|
| 461 |
+
simpa [AffineBasis.convexHull_eq_nonneg_coord] using hp
|
| 462 |
+
have hne : b.coord 1 p ≠ 0 := by
|
| 463 |
+
intro hzero
|
| 464 |
+
exact hnot (collinear_insert_of_mem_affineSpan_pair (coord_zero_mem_line02 b hzero))
|
| 465 |
+
exact lt_of_le_of_ne (hpnonneg 1) hne.symm
|
| 466 |
+
|
| 467 |
+
private lemma coord2_pos_of_mem_convexHull_of_not_collinear
|
| 468 |
+
(b : AffineBasis (Fin 3) ℝ (ℝ × ℝ)) {p : ℝ × ℝ}
|
| 469 |
+
(hp : p ∈ convexHull ℝ (Set.range b))
|
| 470 |
+
(hnot : ¬ Collinear ℝ ({p, b 0, b 1} : Set (ℝ × ℝ))) :
|
| 471 |
+
0 < b.coord 2 p := by
|
| 472 |
+
have hpnonneg : ∀ i, 0 ≤ b.coord i p := by
|
| 473 |
+
simpa [AffineBasis.convexHull_eq_nonneg_coord] using hp
|
| 474 |
+
have hne : b.coord 2 p ≠ 0 := by
|
| 475 |
+
intro hzero
|
| 476 |
+
exact hnot (collinear_insert_of_mem_affineSpan_pair (coord_zero_mem_line01 b hzero))
|
| 477 |
+
exact lt_of_le_of_ne (hpnonneg 2) hne.symm
|
| 478 |
+
|
| 479 |
+
private lemma ratio01_ne_of_not_collinear
|
| 480 |
+
(b : AffineBasis (Fin 3) ℝ (ℝ × ℝ)) {p q : ℝ × ℝ}
|
| 481 |
+
(hp0 : 0 < b.coord 0 p) (_hp1 : 0 < b.coord 1 p)
|
| 482 |
+
(hq0 : 0 < b.coord 0 q) (hq1 : 0 < b.coord 1 q)
|
| 483 |
+
(hnot : ¬ Collinear ℝ ({p, q, b 2} : Set (ℝ × ℝ))) :
|
| 484 |
+
b.coord 0 p / b.coord 0 q ≠ b.coord 1 p / b.coord 1 q := by
|
| 485 |
+
intro hratio
|
| 486 |
+
have hline : p ∈ affineSpan ℝ ({q, b 2} : Set (ℝ × ℝ)) := by
|
| 487 |
+
rw [mem_affineSpan_pair_iff_exists_lineMap_eq]
|
| 488 |
+
let r : ℝ := b.coord 0 p / b.coord 0 q
|
| 489 |
+
have hr0 : r * b.coord 0 q = b.coord 0 p := by
|
| 490 |
+
dsimp [r]
|
| 491 |
+
field_simp [ne_of_gt hq0]
|
| 492 |
+
have hr1 : r * b.coord 1 q = b.coord 1 p := by
|
| 493 |
+
have hq0ne : b.coord 0 q ≠ 0 := ne_of_gt hq0
|
| 494 |
+
have hq1ne : b.coord 1 q ≠ 0 := ne_of_gt hq1
|
| 495 |
+
dsimp [r]
|
| 496 |
+
field_simp [hq0ne, hq1ne] at hratio ⊢
|
| 497 |
+
nlinarith
|
| 498 |
+
refine ⟨1 - r, ?_⟩
|
| 499 |
+
apply b.ext_elem
|
| 500 |
+
intro i
|
| 501 |
+
fin_cases i
|
| 502 |
+
· rw [AffineMap.apply_lineMap]
|
| 503 |
+
simp [AffineMap.lineMap_apply_module, hr0]
|
| 504 |
+
· rw [AffineMap.apply_lineMap]
|
| 505 |
+
simp [AffineMap.lineMap_apply_module, hr1]
|
| 506 |
+
· rw [AffineMap.apply_lineMap]
|
| 507 |
+
have hp_sum := b.sum_coord_apply_eq_one p
|
| 508 |
+
have hq_sum := b.sum_coord_apply_eq_one q
|
| 509 |
+
rw [Fin.sum_univ_three] at hp_sum hq_sum
|
| 510 |
+
simp [AffineMap.lineMap_apply_module]
|
| 511 |
+
nlinarith
|
| 512 |
+
exact hnot (collinear_insert_of_mem_affineSpan_pair hline)
|
| 513 |
+
|
| 514 |
+
private lemma ratio12_ne_of_not_collinear
|
| 515 |
+
(b : AffineBasis (Fin 3) ℝ (ℝ × ℝ)) {p q : ℝ × ℝ}
|
| 516 |
+
(hp1 : 0 < b.coord 1 p) (_hp2 : 0 < b.coord 2 p)
|
| 517 |
+
(hq1 : 0 < b.coord 1 q) (hq2 : 0 < b.coord 2 q)
|
| 518 |
+
(hnot : ¬ Collinear ℝ ({p, q, b 0} : Set (ℝ × ℝ))) :
|
| 519 |
+
b.coord 1 p / b.coord 1 q ≠ b.coord 2 p / b.coord 2 q := by
|
| 520 |
+
intro hratio
|
| 521 |
+
have hline : p ∈ affineSpan ℝ ({q, b 0} : Set (ℝ × ℝ)) := by
|
| 522 |
+
rw [mem_affineSpan_pair_iff_exists_lineMap_eq]
|
| 523 |
+
let r : ℝ := b.coord 1 p / b.coord 1 q
|
| 524 |
+
have hr1 : r * b.coord 1 q = b.coord 1 p := by
|
| 525 |
+
dsimp [r]
|
| 526 |
+
field_simp [ne_of_gt hq1]
|
| 527 |
+
have hr2 : r * b.coord 2 q = b.coord 2 p := by
|
| 528 |
+
have hq1ne : b.coord 1 q ≠ 0 := ne_of_gt hq1
|
| 529 |
+
have hq2ne : b.coord 2 q ≠ 0 := ne_of_gt hq2
|
| 530 |
+
dsimp [r]
|
| 531 |
+
field_simp [hq1ne, hq2ne] at hratio ⊢
|
| 532 |
+
nlinarith
|
| 533 |
+
refine ⟨1 - r, ?_⟩
|
| 534 |
+
apply b.ext_elem
|
| 535 |
+
intro i
|
| 536 |
+
fin_cases i
|
| 537 |
+
· rw [AffineMap.apply_lineMap]
|
| 538 |
+
have hp_sum := b.sum_coord_apply_eq_one p
|
| 539 |
+
have hq_sum := b.sum_coord_apply_eq_one q
|
| 540 |
+
rw [Fin.sum_univ_three] at hp_sum hq_sum
|
| 541 |
+
simp [AffineMap.lineMap_apply_module]
|
| 542 |
+
nlinarith
|
| 543 |
+
· rw [AffineMap.apply_lineMap]
|
| 544 |
+
simp [AffineMap.lineMap_apply_module, hr1]
|
| 545 |
+
· rw [AffineMap.apply_lineMap]
|
| 546 |
+
simp [AffineMap.lineMap_apply_module, hr2]
|
| 547 |
+
exact hnot (collinear_insert_of_mem_affineSpan_pair hline)
|
| 548 |
+
|
| 549 |
+
private lemma ratio02_ne_of_not_collinear
|
| 550 |
+
(b : AffineBasis (Fin 3) ℝ (ℝ × ℝ)) {p q : ℝ × ℝ}
|
| 551 |
+
(hp0 : 0 < b.coord 0 p) (_hp2 : 0 < b.coord 2 p)
|
| 552 |
+
(hq0 : 0 < b.coord 0 q) (hq2 : 0 < b.coord 2 q)
|
| 553 |
+
(hnot : ¬ Collinear ℝ ({p, q, b 1} : Set (ℝ × ℝ))) :
|
| 554 |
+
b.coord 0 p / b.coord 0 q ≠ b.coord 2 p / b.coord 2 q := by
|
| 555 |
+
intro hratio
|
| 556 |
+
have hline : p ∈ affineSpan ℝ ({q, b 1} : Set (ℝ × ℝ)) := by
|
| 557 |
+
rw [mem_affineSpan_pair_iff_exists_lineMap_eq]
|
| 558 |
+
let r : ℝ := b.coord 0 p / b.coord 0 q
|
| 559 |
+
have hr0 : r * b.coord 0 q = b.coord 0 p := by
|
| 560 |
+
dsimp [r]
|
| 561 |
+
field_simp [ne_of_gt hq0]
|
| 562 |
+
have hr2 : r * b.coord 2 q = b.coord 2 p := by
|
| 563 |
+
have hq0ne : b.coord 0 q ≠ 0 := ne_of_gt hq0
|
| 564 |
+
have hq2ne : b.coord 2 q ≠ 0 := ne_of_gt hq2
|
| 565 |
+
dsimp [r]
|
| 566 |
+
field_simp [hq0ne, hq2ne] at hratio ⊢
|
| 567 |
+
nlinarith
|
| 568 |
+
refine ⟨1 - r, ?_⟩
|
| 569 |
+
apply b.ext_elem
|
| 570 |
+
intro i
|
| 571 |
+
fin_cases i
|
| 572 |
+
· rw [AffineMap.apply_lineMap]
|
| 573 |
+
simp [AffineMap.lineMap_apply_module, hr0]
|
| 574 |
+
· rw [AffineMap.apply_lineMap]
|
| 575 |
+
have hp_sum := b.sum_coord_apply_eq_one p
|
| 576 |
+
have hq_sum := b.sum_coord_apply_eq_one q
|
| 577 |
+
rw [Fin.sum_univ_three] at hp_sum hq_sum
|
| 578 |
+
simp [AffineMap.lineMap_apply_module]
|
| 579 |
+
nlinarith
|
| 580 |
+
· rw [AffineMap.apply_lineMap]
|
| 581 |
+
simp [AffineMap.lineMap_apply_module, hr2]
|
| 582 |
+
exact hnot (collinear_insert_of_mem_affineSpan_pair hline)
|
| 583 |
+
|
| 584 |
+
private lemma exists_quad_of_ordered_basis
|
| 585 |
+
{S : Set (ℝ × ℝ)} (b : AffineBasis (Fin 3) ℝ (ℝ × ℝ)) {p q : ℝ × ℝ}
|
| 586 |
+
(hb0S : b 0 ∈ S) (hb2S : b 2 ∈ S) (hpS : p ∈ S) (hqS : q ∈ S)
|
| 587 |
+
(h02 : b 0 ≠ b 2) (h0p : b 0 ≠ p) (h0q : b 0 ≠ q)
|
| 588 |
+
(h2p : b 2 ≠ p) (h2q : b 2 ≠ q) (hpq : p ≠ q)
|
| 589 |
+
(hp0 : 0 < b.coord 0 p) (hp1 : 0 < b.coord 1 p) (hp2 : 0 < b.coord 2 p)
|
| 590 |
+
(hq0 : 0 < b.coord 0 q) (hq1 : 0 < b.coord 1 q) (hq2 : 0 < b.coord 2 q)
|
| 591 |
+
(h01 : b.coord 0 p / b.coord 0 q < b.coord 1 p / b.coord 1 q)
|
| 592 |
+
(h12 : b.coord 1 p / b.coord 1 q < b.coord 2 p / b.coord 2 q) :
|
| 593 |
+
∃ T ⊆ S, T.ncard = 4 ∧ ¬∃ t ∈ T, t ∈ convexHull ℝ (T \ {t}) := by
|
| 594 |
+
classical
|
| 595 |
+
let T : Set (ℝ × ℝ) := {b 0, b 2, p, q}
|
| 596 |
+
have hTsub : T ⊆ S := by
|
| 597 |
+
intro x hx
|
| 598 |
+
simp [T] at hx
|
| 599 |
+
rcases hx with rfl | rfl | rfl | rfl
|
| 600 |
+
· exact hb0S
|
| 601 |
+
· exact hb2S
|
| 602 |
+
· exact hpS
|
| 603 |
+
· exact hqS
|
| 604 |
+
have hTcard : T.ncard = 4 := by
|
| 605 |
+
rw [Set.ncard_eq_four]
|
| 606 |
+
refine ⟨b 0, b 2, p, q, h02, h0p, h0q, h2p, h2q, hpq, rfl⟩
|
| 607 |
+
have hci : ConvexIndependent ℝ ((↑) : T → (ℝ × ℝ)) := by
|
| 608 |
+
simpa [T] using
|
| 609 |
+
affineBasis_convexIndependent_of_ratio b hp0 hp1 hp2 hq0 hq1 hq2 h01 h12
|
| 610 |
+
have hnot : ∀ t ∈ T, t ∉ convexHull ℝ (T \ {t}) :=
|
| 611 |
+
convexIndependent_set_iff_notMem_convexHull_diff.mp hci
|
| 612 |
+
refine ⟨T, hTsub, hTcard, ?_⟩
|
| 613 |
+
rintro ⟨t, htT, htconv⟩
|
| 614 |
+
exact hnot t htT htconv
|
| 615 |
+
|
| 616 |
+
private lemma exists_quad_of_ordered_reindex
|
| 617 |
+
{S : Set (ℝ × ℝ)} (b : AffineBasis (Fin 3) ℝ (ℝ × ℝ))
|
| 618 |
+
(e : Equiv.Perm (Fin 3)) {p q : ℝ × ℝ}
|
| 619 |
+
(hb0S : b (e.symm 0) ∈ S) (hb2S : b (e.symm 2) ∈ S)
|
| 620 |
+
(hpS : p ∈ S) (hqS : q ∈ S)
|
| 621 |
+
(h02 : b (e.symm 0) ≠ b (e.symm 2))
|
| 622 |
+
(h0p : b (e.symm 0) ≠ p) (h0q : b (e.symm 0) ≠ q)
|
| 623 |
+
(h2p : b (e.symm 2) ≠ p) (h2q : b (e.symm 2) ≠ q) (hpq : p ≠ q)
|
| 624 |
+
(hp0 : 0 < b.coord (e.symm 0) p)
|
| 625 |
+
(hp1 : 0 < b.coord (e.symm 1) p)
|
| 626 |
+
(hp2 : 0 < b.coord (e.symm 2) p)
|
| 627 |
+
(hq0 : 0 < b.coord (e.symm 0) q)
|
| 628 |
+
(hq1 : 0 < b.coord (e.symm 1) q)
|
| 629 |
+
(hq2 : 0 < b.coord (e.symm 2) q)
|
| 630 |
+
(h01 : b.coord (e.symm 0) p / b.coord (e.symm 0) q <
|
| 631 |
+
b.coord (e.symm 1) p / b.coord (e.symm 1) q)
|
| 632 |
+
(h12 : b.coord (e.symm 1) p / b.coord (e.symm 1) q <
|
| 633 |
+
b.coord (e.symm 2) p / b.coord (e.symm 2) q) :
|
| 634 |
+
∃ T ⊆ S, T.ncard = 4 ∧ ¬∃ t ∈ T, t ∈ convexHull ℝ (T \ {t}) := by
|
| 635 |
+
exact
|
| 636 |
+
exists_quad_of_ordered_basis (S := S) (b.reindex e)
|
| 637 |
+
(by simpa [AffineBasis.reindex_apply] using hb0S)
|
| 638 |
+
(by simpa [AffineBasis.reindex_apply] using hb2S)
|
| 639 |
+
hpS hqS
|
| 640 |
+
(by simpa [AffineBasis.reindex_apply] using h02)
|
| 641 |
+
(by simpa [AffineBasis.reindex_apply] using h0p)
|
| 642 |
+
(by simpa [AffineBasis.reindex_apply] using h0q)
|
| 643 |
+
(by simpa [AffineBasis.reindex_apply] using h2p)
|
| 644 |
+
(by simpa [AffineBasis.reindex_apply] using h2q)
|
| 645 |
+
hpq
|
| 646 |
+
(by simpa [AffineBasis.coord_reindex] using hp0)
|
| 647 |
+
(by simpa [AffineBasis.coord_reindex] using hp1)
|
| 648 |
+
(by simpa [AffineBasis.coord_reindex] using hp2)
|
| 649 |
+
(by simpa [AffineBasis.coord_reindex] using hq0)
|
| 650 |
+
(by simpa [AffineBasis.coord_reindex] using hq1)
|
| 651 |
+
(by simpa [AffineBasis.coord_reindex] using hq2)
|
| 652 |
+
(by simpa [AffineBasis.coord_reindex] using h01)
|
| 653 |
+
(by simpa [AffineBasis.coord_reindex] using h12)
|
| 654 |
+
|
| 655 |
+
private lemma exists_quad_of_basis_ratios
|
| 656 |
+
{S : Set (ℝ × ℝ)} (b : AffineBasis (Fin 3) ℝ (ℝ × ℝ)) {p q : ℝ × ℝ}
|
| 657 |
+
(hb0S : b 0 ∈ S) (hb1S : b 1 ∈ S) (hb2S : b 2 ∈ S)
|
| 658 |
+
(hpS : p ∈ S) (hqS : q ∈ S)
|
| 659 |
+
(h01v : b 0 ≠ b 1) (h02v : b 0 ≠ b 2) (h12v : b 1 ≠ b 2)
|
| 660 |
+
(h0p : b 0 ≠ p) (h0q : b 0 ≠ q)
|
| 661 |
+
(h1p : b 1 ≠ p) (h1q : b 1 ≠ q)
|
| 662 |
+
(h2p : b 2 ≠ p) (h2q : b 2 ≠ q) (hpq : p ≠ q)
|
| 663 |
+
(hp0 : 0 < b.coord 0 p) (hp1 : 0 < b.coord 1 p) (hp2 : 0 < b.coord 2 p)
|
| 664 |
+
(hq0 : 0 < b.coord 0 q) (hq1 : 0 < b.coord 1 q) (hq2 : 0 < b.coord 2 q)
|
| 665 |
+
(hr01ne : b.coord 0 p / b.coord 0 q ≠ b.coord 1 p / b.coord 1 q)
|
| 666 |
+
(hr12ne : b.coord 1 p / b.coord 1 q ≠ b.coord 2 p / b.coord 2 q)
|
| 667 |
+
(hr02ne : b.coord 0 p / b.coord 0 q ≠ b.coord 2 p / b.coord 2 q) :
|
| 668 |
+
∃ T ⊆ S, T.ncard = 4 ∧ ¬∃ t ∈ T, t ∈ convexHull ℝ (T \ {t}) := by
|
| 669 |
+
rcases lt_or_gt_of_ne hr01ne with h01 | h10
|
| 670 |
+
· rcases lt_or_gt_of_ne hr12ne with h12 | h21
|
| 671 |
+
· exact
|
| 672 |
+
exists_quad_of_ordered_reindex (S := S) b (Equiv.refl (Fin 3))
|
| 673 |
+
hb0S hb2S hpS hqS h02v h0p h0q h2p h2q hpq
|
| 674 |
+
hp0 hp1 hp2 hq0 hq1 hq2 h01 h12
|
| 675 |
+
· rcases lt_or_gt_of_ne hr02ne with h02 | h20
|
| 676 |
+
· exact
|
| 677 |
+
exists_quad_of_ordered_reindex (S := S) b (Equiv.swap (1 : Fin 3) (2 : Fin 3))
|
| 678 |
+
(by simpa using hb0S) (by simpa using hb1S) hpS hqS
|
| 679 |
+
(by simpa using h01v) (by simpa using h0p) (by simpa using h0q)
|
| 680 |
+
(by simpa using h1p) (by simpa using h1q) hpq
|
| 681 |
+
(by simpa using hp0) (by simpa using hp2) (by simpa using hp1)
|
| 682 |
+
(by simpa using hq0) (by simpa using hq2) (by simpa using hq1)
|
| 683 |
+
(by simpa using h02) (by simpa using h21)
|
| 684 |
+
· exact
|
| 685 |
+
exists_quad_of_ordered_reindex (S := S) b fin3Cycle201
|
| 686 |
+
(by simpa [fin3Cycle201] using hb2S) (by simpa [fin3Cycle201] using hb1S)
|
| 687 |
+
hpS hqS
|
| 688 |
+
(by simpa [fin3Cycle201] using h12v.symm)
|
| 689 |
+
(by simpa [fin3Cycle201] using h2p) (by simpa [fin3Cycle201] using h2q)
|
| 690 |
+
(by simpa [fin3Cycle201] using h1p) (by simpa [fin3Cycle201] using h1q)
|
| 691 |
+
hpq
|
| 692 |
+
(by simpa [fin3Cycle201] using hp2) (by simpa [fin3Cycle201] using hp0)
|
| 693 |
+
(by simpa [fin3Cycle201] using hp1)
|
| 694 |
+
(by simpa [fin3Cycle201] using hq2) (by simpa [fin3Cycle201] using hq0)
|
| 695 |
+
(by simpa [fin3Cycle201] using hq1)
|
| 696 |
+
(by simpa [fin3Cycle201] using h20) (by simpa [fin3Cycle201] using h01)
|
| 697 |
+
· rcases lt_or_gt_of_ne hr02ne with h02 | h20
|
| 698 |
+
· exact
|
| 699 |
+
exists_quad_of_ordered_reindex (S := S) b (Equiv.swap (0 : Fin 3) (1 : Fin 3))
|
| 700 |
+
(by simpa using hb1S) (by simpa using hb2S) hpS hqS
|
| 701 |
+
(by simpa using h12v) (by simpa using h1p) (by simpa using h1q)
|
| 702 |
+
(by simpa using h2p) (by simpa using h2q) hpq
|
| 703 |
+
(by simpa using hp1) (by simpa using hp0) (by simpa using hp2)
|
| 704 |
+
(by simpa using hq1) (by simpa using hq0) (by simpa using hq2)
|
| 705 |
+
(by simpa using h10) (by simpa using h02)
|
| 706 |
+
· rcases lt_or_gt_of_ne hr12ne with h12 | h21
|
| 707 |
+
· exact
|
| 708 |
+
exists_quad_of_ordered_reindex (S := S) b fin3Cycle120
|
| 709 |
+
(by simpa [fin3Cycle120] using hb1S) (by simpa [fin3Cycle120] using hb0S)
|
| 710 |
+
hpS hqS
|
| 711 |
+
(by simpa [fin3Cycle120] using h01v.symm)
|
| 712 |
+
(by simpa [fin3Cycle120] using h1p) (by simpa [fin3Cycle120] using h1q)
|
| 713 |
+
(by simpa [fin3Cycle120] using h0p) (by simpa [fin3Cycle120] using h0q)
|
| 714 |
+
hpq
|
| 715 |
+
(by simpa [fin3Cycle120] using hp1) (by simpa [fin3Cycle120] using hp2)
|
| 716 |
+
(by simpa [fin3Cycle120] using hp0)
|
| 717 |
+
(by simpa [fin3Cycle120] using hq1) (by simpa [fin3Cycle120] using hq2)
|
| 718 |
+
(by simpa [fin3Cycle120] using hq0)
|
| 719 |
+
(by simpa [fin3Cycle120] using h12) (by simpa [fin3Cycle120] using h20)
|
| 720 |
+
· exact
|
| 721 |
+
exists_quad_of_ordered_reindex (S := S) b (Equiv.swap (0 : Fin 3) (2 : Fin 3))
|
| 722 |
+
(by simpa using hb2S) (by simpa using hb0S) hpS hqS
|
| 723 |
+
(by simpa using h02v.symm) (by simpa using h2p) (by simpa using h2q)
|
| 724 |
+
(by simpa using h0p) (by simpa using h0q) hpq
|
| 725 |
+
(by simpa using hp2) (by simpa using hp1) (by simpa using hp0)
|
| 726 |
+
(by simpa using hq2) (by simpa using hq1) (by simpa using hq0)
|
| 727 |
+
(by simpa using h21) (by simpa using h10)
|
| 728 |
+
|
| 729 |
+
private lemma exists_quad_of_three_extreme
|
| 730 |
+
{S : Set (ℝ × ℝ)}
|
| 731 |
+
(hS : S.ncard = 5)
|
| 732 |
+
(hnoncol : ∀ s ⊆ S, s.ncard = 3 → ¬Collinear ℝ s)
|
| 733 |
+
(hE3 : ((convexHull ℝ S).extremePoints ℝ).ncard = 3) :
|
| 734 |
+
∃ T ⊆ S, T.ncard = 4 ∧ ¬∃ t ∈ T, t ∈ convexHull ℝ (T \ {t}) := by
|
| 735 |
+
classical
|
| 736 |
+
let E : Set (ℝ × ℝ) := (convexHull ℝ S).extremePoints ℝ
|
| 737 |
+
have hSfin : S.Finite := Set.finite_of_ncard_ne_zero (by rw [hS]; norm_num)
|
| 738 |
+
have hEsubS : E ⊆ S := by
|
| 739 |
+
intro x hx
|
| 740 |
+
exact extremePoints_convexHull_subset (𝕜 := ℝ) (A := S) hx
|
| 741 |
+
have hEfin : E.Finite := hSfin.subset hEsubS
|
| 742 |
+
have hE3E : E.ncard = 3 := by
|
| 743 |
+
simpa [E] using hE3
|
| 744 |
+
have hSsubHullE : S ⊆ convexHull ℝ E := by
|
| 745 |
+
simpa [E] using subset_convexHull_extremePoints_of_finite hSfin
|
| 746 |
+
obtain ⟨A, B, C, hAB, hAC, hBC, hEeq⟩ := Set.ncard_eq_three.mp hE3E
|
| 747 |
+
have hAS : A ∈ S := hEsubS (by simp [hEeq])
|
| 748 |
+
have hBS : B ∈ S := hEsubS (by simp [hEeq])
|
| 749 |
+
have hCS : C ∈ S := hEsubS (by simp [hEeq])
|
| 750 |
+
let D : Set (ℝ × ℝ) := S \ E
|
| 751 |
+
have hDcard : D.ncard = 2 := by
|
| 752 |
+
change (S \ E).ncard = 2
|
| 753 |
+
rw [Set.ncard_diff hEsubS hEfin, hS, hE3E]
|
| 754 |
+
obtain ⟨p, q, hpq, hDeq⟩ := Set.ncard_eq_two.mp hDcard
|
| 755 |
+
have hpD : p ∈ D := by simp [hDeq]
|
| 756 |
+
have hqD : q ∈ D := by simp [hDeq]
|
| 757 |
+
have hpS : p ∈ S := hpD.1
|
| 758 |
+
have hqS : q ∈ S := hqD.1
|
| 759 |
+
have hpnotE : p ∉ E := hpD.2
|
| 760 |
+
have hqnotE : q ∉ E := hqD.2
|
| 761 |
+
have hpA : p ≠ A := by
|
| 762 |
+
intro h
|
| 763 |
+
exact hpnotE (by simp [hEeq, h])
|
| 764 |
+
have hpB : p ≠ B := by
|
| 765 |
+
intro h
|
| 766 |
+
exact hpnotE (by simp [hEeq, h])
|
| 767 |
+
have hpC : p ≠ C := by
|
| 768 |
+
intro h
|
| 769 |
+
exact hpnotE (by simp [hEeq, h])
|
| 770 |
+
have hqA : q ≠ A := by
|
| 771 |
+
intro h
|
| 772 |
+
exact hqnotE (by simp [hEeq, h])
|
| 773 |
+
have hqB : q ≠ B := by
|
| 774 |
+
intro h
|
| 775 |
+
exact hqnotE (by simp [hEeq, h])
|
| 776 |
+
have hqC : q ≠ C := by
|
| 777 |
+
intro h
|
| 778 |
+
exact hqnotE (by simp [hEeq, h])
|
| 779 |
+
let pts : Fin 3 → ℝ × ℝ := ![A, B, C]
|
| 780 |
+
have hABCnot : ¬Collinear ℝ ({A, B, C} : Set (ℝ × ℝ)) :=
|
| 781 |
+
not_collinear_of_mem_distinct hnoncol hAS hBS hCS hAB hAC hBC
|
| 782 |
+
have hind : AffineIndependent ℝ pts := by
|
| 783 |
+
rw [affineIndependent_iff_not_collinear_set]
|
| 784 |
+
simpa [pts] using hABCnot
|
| 785 |
+
let b : AffineBasis (Fin 3) ℝ (ℝ × ℝ) :=
|
| 786 |
+
{ toFun := pts
|
| 787 |
+
ind' := hind
|
| 788 |
+
tot' := (hind.affineSpan_eq_top_iff_card_eq_finrank_add_one).2
|
| 789 |
+
(by simp [Module.finrank_prod]) }
|
| 790 |
+
have hb0eq : b 0 = A := rfl
|
| 791 |
+
have hb1eq : b 1 = B := rfl
|
| 792 |
+
have hb2eq : b 2 = C := rfl
|
| 793 |
+
have hRangeB : Set.range b = ({A, B, C} : Set (ℝ × ℝ)) := by
|
| 794 |
+
ext x
|
| 795 |
+
constructor
|
| 796 |
+
· rintro ⟨i, rfl⟩
|
| 797 |
+
fin_cases i
|
| 798 |
+
· exact Or.inl hb0eq
|
| 799 |
+
· exact Or.inr (Or.inl hb1eq)
|
| 800 |
+
· exact Or.inr (Or.inr hb2eq)
|
| 801 |
+
· intro hx
|
| 802 |
+
simp at hx
|
| 803 |
+
rcases hx with rfl | rfl | rfl
|
| 804 |
+
· exact ⟨(0 : Fin 3), hb0eq.symm⟩
|
| 805 |
+
· exact ⟨(1 : Fin 3), hb1eq.symm⟩
|
| 806 |
+
· exact ⟨(2 : Fin 3), hb2eq.symm⟩
|
| 807 |
+
have hb0S : b 0 ∈ S := by rw [hb0eq]; exact hAS
|
| 808 |
+
have hb1S : b 1 ∈ S := by rw [hb1eq]; exact hBS
|
| 809 |
+
have hb2S : b 2 ∈ S := by rw [hb2eq]; exact hCS
|
| 810 |
+
have hb01 : b 0 ≠ b 1 := by rwa [hb0eq, hb1eq]
|
| 811 |
+
have hb02 : b 0 ≠ b 2 := by rwa [hb0eq, hb2eq]
|
| 812 |
+
have hb12 : b 1 ≠ b 2 := by rwa [hb1eq, hb2eq]
|
| 813 |
+
have hb0p : b 0 ≠ p := by rw [hb0eq]; exact hpA.symm
|
| 814 |
+
have hb0q : b 0 ≠ q := by rw [hb0eq]; exact hqA.symm
|
| 815 |
+
have hb1p : b 1 ≠ p := by rw [hb1eq]; exact hpB.symm
|
| 816 |
+
have hb1q : b 1 ≠ q := by rw [hb1eq]; exact hqB.symm
|
| 817 |
+
have hb2p : b 2 ≠ p := by rw [hb2eq]; exact hpC.symm
|
| 818 |
+
have hb2q : b 2 ≠ q := by rw [hb2eq]; exact hqC.symm
|
| 819 |
+
have hpHull : p ∈ convexHull ℝ (Set.range b) := by
|
| 820 |
+
have hpHullE := hSsubHullE hpS
|
| 821 |
+
rw [hRangeB]
|
| 822 |
+
simpa [hEeq] using hpHullE
|
| 823 |
+
have hqHull : q ∈ convexHull ℝ (Set.range b) := by
|
| 824 |
+
have hqHullE := hSsubHullE hqS
|
| 825 |
+
rw [hRangeB]
|
| 826 |
+
simpa [hEeq] using hqHullE
|
| 827 |
+
have hp0 : 0 < b.coord 0 p :=
|
| 828 |
+
coord0_pos_of_mem_convexHull_of_not_collinear b hpHull
|
| 829 |
+
(by
|
| 830 |
+
simpa [b, pts] using
|
| 831 |
+
not_collinear_of_mem_distinct hnoncol hpS hBS hCS hpB hpC hBC)
|
| 832 |
+
have hp1 : 0 < b.coord 1 p :=
|
| 833 |
+
coord1_pos_of_mem_convexHull_of_not_collinear b hpHull
|
| 834 |
+
(by
|
| 835 |
+
simpa [b, pts] using
|
| 836 |
+
not_collinear_of_mem_distinct hnoncol hpS hAS hCS hpA hpC hAC)
|
| 837 |
+
have hp2 : 0 < b.coord 2 p :=
|
| 838 |
+
coord2_pos_of_mem_convexHull_of_not_collinear b hpHull
|
| 839 |
+
(by
|
| 840 |
+
simpa [b, pts] using
|
| 841 |
+
not_collinear_of_mem_distinct hnoncol hpS hAS hBS hpA hpB hAB)
|
| 842 |
+
have hq0 : 0 < b.coord 0 q :=
|
| 843 |
+
coord0_pos_of_mem_convexHull_of_not_collinear b hqHull
|
| 844 |
+
(by
|
| 845 |
+
simpa [b, pts] using
|
| 846 |
+
not_collinear_of_mem_distinct hnoncol hqS hBS hCS hqB hqC hBC)
|
| 847 |
+
have hq1 : 0 < b.coord 1 q :=
|
| 848 |
+
coord1_pos_of_mem_convexHull_of_not_collinear b hqHull
|
| 849 |
+
(by
|
| 850 |
+
simpa [b, pts] using
|
| 851 |
+
not_collinear_of_mem_distinct hnoncol hqS hAS hCS hqA hqC hAC)
|
| 852 |
+
have hq2 : 0 < b.coord 2 q :=
|
| 853 |
+
coord2_pos_of_mem_convexHull_of_not_collinear b hqHull
|
| 854 |
+
(by
|
| 855 |
+
simpa [b, pts] using
|
| 856 |
+
not_collinear_of_mem_distinct hnoncol hqS hAS hBS hqA hqB hAB)
|
| 857 |
+
have hr01ne : b.coord 0 p / b.coord 0 q ≠ b.coord 1 p / b.coord 1 q :=
|
| 858 |
+
ratio01_ne_of_not_collinear b hp0 hp1 hq0 hq1
|
| 859 |
+
(by
|
| 860 |
+
simpa [b, pts] using
|
| 861 |
+
not_collinear_of_mem_distinct hnoncol hpS hqS hCS hpq hpC hqC)
|
| 862 |
+
have hr12ne : b.coord 1 p / b.coord 1 q ≠ b.coord 2 p / b.coord 2 q :=
|
| 863 |
+
ratio12_ne_of_not_collinear b hp1 hp2 hq1 hq2
|
| 864 |
+
(by
|
| 865 |
+
simpa [b, pts] using
|
| 866 |
+
not_collinear_of_mem_distinct hnoncol hpS hqS hAS hpq hpA hqA)
|
| 867 |
+
have hr02ne : b.coord 0 p / b.coord 0 q ≠ b.coord 2 p / b.coord 2 q :=
|
| 868 |
+
ratio02_ne_of_not_collinear b hp0 hp2 hq0 hq2
|
| 869 |
+
(by
|
| 870 |
+
simpa [b, pts] using
|
| 871 |
+
not_collinear_of_mem_distinct hnoncol hpS hqS hBS hpq hpB hqB)
|
| 872 |
+
exact
|
| 873 |
+
exists_quad_of_basis_ratios b hb0S hb1S hb2S hpS hqS hb01 hb02 hb12
|
| 874 |
+
hb0p hb0q hb1p hb1q hb2p hb2q hpq
|
| 875 |
+
hp0 hp1 hp2 hq0 hq1 hq2 hr01ne hr12ne hr02ne
|
| 876 |
+
|
| 877 |
+
/--
|
| 878 |
+
Given five points in a plane, no three of which lie on a straight line, show that some four of these points form the vertices of a convex quadrilateral.
|
| 879 |
+
-/
|
| 880 |
+
theorem putnam_1962_a1
|
| 881 |
+
(S : Set (ℝ × ℝ))
|
| 882 |
+
(hS : S.ncard = 5)
|
| 883 |
+
(hnoncol : ∀ s ⊆ S, s.ncard = 3 → ¬Collinear ℝ s)
|
| 884 |
+
: ∃ T ⊆ S, T.ncard = 4 ∧ ¬∃ t ∈ T, t ∈ convexHull ℝ (T \ {t}) :=
|
| 885 |
+
by
|
| 886 |
+
classical
|
| 887 |
+
by_cases hE4 : 4 ≤ ((convexHull ℝ S).extremePoints ℝ).ncard
|
| 888 |
+
· exact exists_quad_of_four_extreme hE4
|
| 889 |
+
· have hnotle2 : ¬ ((convexHull ℝ S).extremePoints ℝ).ncard ≤ 2 :=
|
| 890 |
+
not_extremePoints_ncard_le_two hS hnoncol
|
| 891 |
+
have hE3 : ((convexHull ℝ S).extremePoints ℝ).ncard = 3 := by omega
|
| 892 |
+
exact exists_quad_of_three_extreme hS hnoncol hE3
|
Putnam-bench-verified/1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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
open MeasureTheory Set
|
| 4 |
+
|
| 5 |
+
private lemma putnam_1962_a2_integral_rat (a c x : ℝ) (hx : 0 < x)
|
| 6 |
+
(hden : ∀ t ∈ Icc (0 : ℝ) x, 1 - c * t ≠ 0) :
|
| 7 |
+
∫ t in (0 : ℝ)..x, a / (1 - c * t) ^ 2 = a * x / (1 - c * x) := by
|
| 8 |
+
have hderiv : ∀ t ∈ uIcc (0 : ℝ) x,
|
| 9 |
+
HasDerivAt (fun u : ℝ => a * u / (1 - c * u)) (a / (1 - c * t) ^ 2) t := by
|
| 10 |
+
intro t ht
|
| 11 |
+
have ht' : t ∈ Icc (0 : ℝ) x := by simpa [uIcc_of_le hx.le] using ht
|
| 12 |
+
have h : 1 - c * t ≠ 0 := hden t ht'
|
| 13 |
+
convert (((hasDerivAt_const t a).mul (hasDerivAt_id t)).div
|
| 14 |
+
((hasDerivAt_const t (1 : ℝ)).sub ((hasDerivAt_const t c).mul (hasDerivAt_id t))) h) using 1
|
| 15 |
+
simp only [Pi.sub_apply, Pi.mul_apply, id_eq]
|
| 16 |
+
field_simp [h]
|
| 17 |
+
ring
|
| 18 |
+
have hcont : ContinuousOn (fun t : ℝ => a / (1 - c * t) ^ 2) (uIcc (0 : ℝ) x) := by
|
| 19 |
+
intro t ht
|
| 20 |
+
have ht' : t ∈ Icc (0 : ℝ) x := by simpa [uIcc_of_le hx.le] using ht
|
| 21 |
+
fun_prop (disch := exact pow_ne_zero 2 (hden t ht'))
|
| 22 |
+
have hint : IntervalIntegrable (fun t : ℝ => a / (1 - c * t) ^ 2) volume (0 : ℝ) x := by
|
| 23 |
+
exact hcont.intervalIntegrable
|
| 24 |
+
rw [intervalIntegral.integral_eq_sub_of_hasDerivAt hderiv hint]
|
| 25 |
+
ring
|
| 26 |
+
|
| 27 |
+
private lemma putnam_1962_a2_average_rat (a c x : ℝ) (hx : 0 < x)
|
| 28 |
+
(hden : ∀ t ∈ Icc (0 : ℝ) x, 1 - c * t ≠ 0) :
|
| 29 |
+
(⨍ t in Ico (0 : ℝ) x, a / (1 - c * t) ^ 2) = a / (1 - c * x) := by
|
| 30 |
+
have hset : (⨍ t in Ico (0 : ℝ) x, a / (1 - c * t) ^ 2) =
|
| 31 |
+
(⨍ t in Ioc (0 : ℝ) x, a / (1 - c * t) ^ 2) := by
|
| 32 |
+
exact setAverage_congr (μ := volume) (f := fun t : ℝ => a / (1 - c * t) ^ 2) Ico_ae_eq_Ioc
|
| 33 |
+
rw [hset]
|
| 34 |
+
rw [setAverage_eq]
|
| 35 |
+
rw [Real.volume_real_Ioc_of_le hx.le]
|
| 36 |
+
rw [← intervalIntegral.integral_of_le hx.le]
|
| 37 |
+
rw [putnam_1962_a2_integral_rat a c x hx hden]
|
| 38 |
+
rw [smul_eq_mul]
|
| 39 |
+
field_simp [hx.ne']
|
| 40 |
+
ring
|
| 41 |
+
|
| 42 |
+
private lemma putnam_1962_a2_sqrt_rat (a d : ℝ) (ha : 0 ≤ a) (hd : 0 < d) :
|
| 43 |
+
√(a * (a / d ^ 2)) = a / d := by
|
| 44 |
+
have hnon : 0 ≤ a / d := div_nonneg ha hd.le
|
| 45 |
+
rw [show a * (a / d ^ 2) = (a / d) ^ 2 by field_simp [hd.ne'], Real.sqrt_sq hnon]
|
| 46 |
+
|
| 47 |
+
private lemma putnam_1962_a2_rational_P
|
| 48 |
+
(P : Set ℝ → (ℝ → ℝ) → Prop)
|
| 49 |
+
(P_def : ∀ s f, P s f ↔ 0 ≤ f ∧ ∀ x ∈ s, ⨍ t in Ico 0 x, f t = √(f 0 * f x))
|
| 50 |
+
{a c e : ℝ} (ha : 0 ≤ a)
|
| 51 |
+
(hden_pos : ∀ x ∈ Ioo (0 : ℝ) e, 0 < 1 - c * x) :
|
| 52 |
+
P (Ioo 0 e) (fun x : ℝ => a / (1 - c * x) ^ 2) := by
|
| 53 |
+
rw [P_def]
|
| 54 |
+
constructor
|
| 55 |
+
· intro x
|
| 56 |
+
exact div_nonneg ha (sq_nonneg _)
|
| 57 |
+
· intro x hx
|
| 58 |
+
have hden : ∀ t ∈ Icc (0 : ℝ) x, 1 - c * t ≠ 0 := by
|
| 59 |
+
intro t ht
|
| 60 |
+
have hte : t < e := lt_of_le_of_lt ht.2 hx.2
|
| 61 |
+
have hpos : 0 < 1 - c * t := by
|
| 62 |
+
by_cases ht0 : t = 0
|
| 63 |
+
· simp [ht0]
|
| 64 |
+
· exact hden_pos t ⟨lt_of_le_of_ne ht.1 (Ne.symm ht0), hte⟩
|
| 65 |
+
exact hpos.ne'
|
| 66 |
+
rw [putnam_1962_a2_average_rat a c x hx.1 hden]
|
| 67 |
+
simpa using (putnam_1962_a2_sqrt_rat a (1 - c * x) ha (hden_pos x hx)).symm
|
| 68 |
+
|
| 69 |
+
private lemma putnam_1962_a2_cutoff_P
|
| 70 |
+
(P : Set ℝ → (ℝ → ℝ) → Prop)
|
| 71 |
+
(P_def : ∀ s f, P s f ↔ 0 ≤ f ∧ ∀ x ∈ s, ⨍ t in Ico 0 x, f t = √(f 0 * f x))
|
| 72 |
+
{a c e : ℝ} (ha : 0 ≤ a) (hc : 0 < c) (he_inv : e ≤ 1 / c)
|
| 73 |
+
(hden_pos : ∀ x ∈ Ioo (0 : ℝ) e, 0 < 1 - c * x) :
|
| 74 |
+
P (Ioo 0 e) (fun x : ℝ => if x < 1 / c then a / (1 - c * x) ^ 2 else 0) := by
|
| 75 |
+
rw [P_def]
|
| 76 |
+
constructor
|
| 77 |
+
· intro x
|
| 78 |
+
change (0 : ℝ) ≤ (if x < 1 / c then a / (1 - c * x) ^ 2 else 0)
|
| 79 |
+
by_cases hx : x < 1 / c
|
| 80 |
+
· rw [if_pos hx]
|
| 81 |
+
exact div_nonneg ha (sq_nonneg _)
|
| 82 |
+
· rw [if_neg hx]
|
| 83 |
+
· intro x hx
|
| 84 |
+
have hxcut : x < 1 / c := lt_of_lt_of_le hx.2 he_inv
|
| 85 |
+
have hden : ∀ t ∈ Icc (0 : ℝ) x, 1 - c * t ≠ 0 := by
|
| 86 |
+
intro t ht
|
| 87 |
+
have hte : t < e := lt_of_le_of_lt ht.2 hx.2
|
| 88 |
+
have hpos : 0 < 1 - c * t := by
|
| 89 |
+
by_cases ht0 : t = 0
|
| 90 |
+
· simp [ht0]
|
| 91 |
+
· exact hden_pos t ⟨lt_of_le_of_ne ht.1 (Ne.symm ht0), hte⟩
|
| 92 |
+
exact hpos.ne'
|
| 93 |
+
have havg :
|
| 94 |
+
(⨍ t in Ico (0 : ℝ) x, (if t < 1 / c then a / (1 - c * t) ^ 2 else 0)) =
|
| 95 |
+
(⨍ t in Ico (0 : ℝ) x, a / (1 - c * t) ^ 2) := by
|
| 96 |
+
refine setAverage_congr_fun (μ := volume) (s := Ico (0 : ℝ) x) measurableSet_Ico ?_
|
| 97 |
+
filter_upwards [] with t ht
|
| 98 |
+
have htcut : t < 1 / c := lt_trans ht.2 hxcut
|
| 99 |
+
rw [if_pos htcut]
|
| 100 |
+
rw [havg, putnam_1962_a2_average_rat a c x hx.1 hden]
|
| 101 |
+
have h0cut : (0 : ℝ) < 1 / c := one_div_pos.mpr hc
|
| 102 |
+
have h0val : (if (0 : ℝ) < 1 / c then a / (1 - c * 0) ^ 2 else 0) = a := by
|
| 103 |
+
rw [if_pos h0cut]
|
| 104 |
+
ring
|
| 105 |
+
have hxval : (if x < 1 / c then a / (1 - c * x) ^ 2 else 0) = a / (1 - c * x) ^ 2 := by
|
| 106 |
+
rw [if_pos hxcut]
|
| 107 |
+
rw [h0val, hxval]
|
| 108 |
+
exact (putnam_1962_a2_sqrt_rat a (1 - c * x) ha (hden_pos x hx)).symm
|
| 109 |
+
|
| 110 |
+
private lemma putnam_1962_a2_zero_on_pos_average
|
| 111 |
+
{f : ℝ → ℝ} (hfzero : ∀ x : ℝ, 0 < x → f x = 0) (x : ℝ) :
|
| 112 |
+
(⨍ t in Ico (0 : ℝ) x, f t) = 0 := by
|
| 113 |
+
have hcongr : (⨍ t in Ico (0 : ℝ) x, f t) = (⨍ t in Ico (0 : ℝ) x, (0 : ℝ)) := by
|
| 114 |
+
refine setAverage_congr_fun (μ := volume) (s := Ico (0 : ℝ) x) measurableSet_Ico ?_
|
| 115 |
+
filter_upwards [show ∀ᵐ t : ℝ ∂volume, t ≠ 0 by rw [ae_iff]; simp] with t htne htmem
|
| 116 |
+
exact hfzero t (lt_of_le_of_ne htmem.1 (Ne.symm htne))
|
| 117 |
+
simpa using hcongr
|
| 118 |
+
|
| 119 |
+
private lemma putnam_1962_a2_zero_on_Ioo_average
|
| 120 |
+
{f : ℝ → ℝ} {x : ℝ} (hfzero : ∀ t ∈ Ioo (0 : ℝ) x, f t = 0) :
|
| 121 |
+
(⨍ t in Ico (0 : ℝ) x, f t) = 0 := by
|
| 122 |
+
have hcongr : (⨍ t in Ico (0 : ℝ) x, f t) = (⨍ t in Ico (0 : ℝ) x, (0 : ℝ)) := by
|
| 123 |
+
refine setAverage_congr_fun (μ := volume) (s := Ico (0 : ℝ) x) measurableSet_Ico ?_
|
| 124 |
+
filter_upwards [show ∀ᵐ t : ℝ ∂volume, t ≠ 0 by rw [ae_iff]; simp] with t htne htmem
|
| 125 |
+
exact hfzero t ⟨lt_of_le_of_ne htmem.1 (Ne.symm htne), htmem.2⟩
|
| 126 |
+
simpa using hcongr
|
| 127 |
+
|
| 128 |
+
private lemma putnam_1962_a2_zero_on_pos_P
|
| 129 |
+
(P : Set ℝ → (ℝ → ℝ) → Prop)
|
| 130 |
+
(P_def : ∀ s f, P s f ↔ 0 ≤ f ∧ ∀ x ∈ s, ⨍ t in Ico 0 x, f t = √(f 0 * f x))
|
| 131 |
+
{f : ℝ → ℝ} (hf_nonneg : 0 ≤ f) (hfzero : ∀ x : ℝ, 0 < x → f x = 0) :
|
| 132 |
+
P (Ioi 0) f := by
|
| 133 |
+
rw [P_def]
|
| 134 |
+
refine ⟨hf_nonneg, ?_⟩
|
| 135 |
+
intro x hx
|
| 136 |
+
rw [putnam_1962_a2_zero_on_pos_average hfzero x, hfzero x hx]
|
| 137 |
+
simp
|
| 138 |
+
|
| 139 |
+
private lemma putnam_1962_a2_point_zero_branch_mem (a : ℝ) (ha : 0 ≤ a) :
|
| 140 |
+
(fun x : ℝ => if x = 0 then a else 0) ∈
|
| 141 |
+
({f | (∃ a c : ℝ, 0 ≤ a ∧ f = (fun x : ℝ ↦ a / (1 - c * x) ^ 2)) ∨
|
| 142 |
+
(∃ a c : ℝ, 0 ≤ a ∧ 0 < c ∧
|
| 143 |
+
f = (fun x : ℝ ↦ if x < 1 / c then a / (1 - c * x) ^ 2 else 0)) ∨
|
| 144 |
+
(0 ≤ f ∧ ∀ x : ℝ, 0 < x → f x = 0) ∨
|
| 145 |
+
(∃ e : ℝ, 0 < e ∧ f 0 = 0 ∧ 0 ≤ f ∧
|
| 146 |
+
∀ x ∈ Ioo (0 : ℝ) e, (⨍ t in Ico (0 : ℝ) x, f t) = 0)} :
|
| 147 |
+
Set (ℝ → ℝ)) := by
|
| 148 |
+
right; right; left
|
| 149 |
+
constructor
|
| 150 |
+
· intro x
|
| 151 |
+
by_cases hx : x = 0
|
| 152 |
+
· simp [hx, ha]
|
| 153 |
+
· simp [hx]
|
| 154 |
+
· intro x hx
|
| 155 |
+
simp [hx.ne']
|
| 156 |
+
|
| 157 |
+
private lemma putnam_1962_a2_fourth_P
|
| 158 |
+
(P : Set ℝ → (ℝ → ℝ) → Prop)
|
| 159 |
+
(P_def : ∀ s f, P s f ↔ 0 ≤ f ∧ ∀ x ∈ s, ⨍ t in Ico 0 x, f t = √(f 0 * f x))
|
| 160 |
+
{f : ℝ → ℝ} {e : ℝ} (h0 : f 0 = 0) (hf_nonneg : 0 ≤ f)
|
| 161 |
+
(havg : ∀ x ∈ Ioo (0 : ℝ) e, (⨍ t in Ico (0 : ℝ) x, f t) = 0) :
|
| 162 |
+
P (Ioo 0 e) f := by
|
| 163 |
+
rw [P_def]
|
| 164 |
+
refine ⟨hf_nonneg, ?_⟩
|
| 165 |
+
intro x hx
|
| 166 |
+
rw [havg x hx]
|
| 167 |
+
simp [h0]
|
| 168 |
+
|
| 169 |
+
private lemma putnam_1962_a2_integral_eq_average {f : ℝ → ℝ} {x : ℝ} (hx : 0 < x) :
|
| 170 |
+
(∫ t in (0 : ℝ)..x, f t) = x * (⨍ t in Ico (0 : ℝ) x, f t) := by
|
| 171 |
+
have hset : (⨍ t in Ico (0 : ℝ) x, f t) = (⨍ t in Ioc (0 : ℝ) x, f t) := by
|
| 172 |
+
exact setAverage_congr (μ := volume) (f := f) Ico_ae_eq_Ioc
|
| 173 |
+
rw [hset, setAverage_eq, Real.volume_real_Ioc_of_le hx.le,
|
| 174 |
+
← intervalIntegral.integral_of_le hx.le]
|
| 175 |
+
simp [smul_eq_mul]
|
| 176 |
+
field_simp [hx.ne']
|
| 177 |
+
|
| 178 |
+
private lemma putnam_1962_a2_f_eq_primitive_sq
|
| 179 |
+
{f : ℝ → ℝ} {a b u : ℝ} (ha : 0 < a) (hub : u ∈ Ioo (0 : ℝ) b)
|
| 180 |
+
(hf_nonneg : 0 ≤ f)
|
| 181 |
+
(havg : ∀ x ∈ Ioo (0 : ℝ) b, (⨍ t in Ico (0 : ℝ) x, f t) = √(a * f x)) :
|
| 182 |
+
f u = (∫ t in (0 : ℝ)..u, f t) ^ 2 / (a * u ^ 2) := by
|
| 183 |
+
have hu : 0 < u := hub.1
|
| 184 |
+
have hF : (∫ t in (0 : ℝ)..u, f t) = u * √(a * f u) := by
|
| 185 |
+
rw [putnam_1962_a2_integral_eq_average (f := f) hu, havg u hub]
|
| 186 |
+
have hsq : (∫ t in (0 : ℝ)..u, f t) ^ 2 = u ^ 2 * (a * f u) := by
|
| 187 |
+
rw [hF]
|
| 188 |
+
rw [mul_pow, Real.sq_sqrt (mul_nonneg ha.le (hf_nonneg u))]
|
| 189 |
+
have hden : a * u ^ 2 ≠ 0 := by positivity
|
| 190 |
+
field_simp [hden]
|
| 191 |
+
nlinarith [hsq]
|
| 192 |
+
|
| 193 |
+
private lemma putnam_1962_a2_continuousAt_of_intervalIntegrable
|
| 194 |
+
{f : ℝ → ℝ} {a b t : ℝ} (ha : 0 < a) (ht : t ∈ Ioo (0 : ℝ) b)
|
| 195 |
+
(hf_nonneg : 0 ≤ f)
|
| 196 |
+
(havg : ∀ x ∈ Ioo (0 : ℝ) b, (⨍ t in Ico (0 : ℝ) x, f t) = √(a * f x))
|
| 197 |
+
(hint : IntervalIntegrable f volume (0 : ℝ) b) :
|
| 198 |
+
ContinuousAt f t := by
|
| 199 |
+
let F : ℝ → ℝ := fun u => ∫ v in (0 : ℝ)..u, f v
|
| 200 |
+
have hb0 : 0 ≤ b := le_of_lt (lt_trans ht.1 ht.2)
|
| 201 |
+
have hcontFOn : ContinuousOn F (Icc (0 : ℝ) b) := by
|
| 202 |
+
have hac : AbsolutelyContinuousOnInterval F (0 : ℝ) b := by
|
| 203 |
+
exact hint.absolutelyContinuousOnInterval_intervalIntegral (c := (0 : ℝ))
|
| 204 |
+
(by
|
| 205 |
+
simpa [uIcc_of_le hb0] using
|
| 206 |
+
(show (0 : ℝ) ∈ Icc (0 : ℝ) b from ⟨le_rfl, hb0⟩))
|
| 207 |
+
simpa [F, uIcc_of_le hb0] using hac.continuousOn
|
| 208 |
+
have hcontF : ContinuousAt F t := hcontFOn.continuousAt (Icc_mem_nhds ht.1 ht.2)
|
| 209 |
+
have htne : t ≠ 0 := ne_of_gt ht.1
|
| 210 |
+
have hane : a ≠ 0 := ne_of_gt ha
|
| 211 |
+
have hden : a * t ^ 2 ≠ 0 := mul_ne_zero hane (pow_ne_zero 2 htne)
|
| 212 |
+
have hcontExpr : ContinuousAt (fun u : ℝ => F u ^ 2 / (a * u ^ 2)) t := by
|
| 213 |
+
exact (hcontF.pow 2).div
|
| 214 |
+
((continuousAt_const.mul ((continuousAt_id : ContinuousAt (fun u : ℝ => u) t).pow 2)))
|
| 215 |
+
hden
|
| 216 |
+
have hevent : f =ᶠ[nhds t] fun u : ℝ => F u ^ 2 / (a * u ^ 2) := by
|
| 217 |
+
filter_upwards [Ioo_mem_nhds ht.1 ht.2] with u hu
|
| 218 |
+
exact putnam_1962_a2_f_eq_primitive_sq (f := f) (a := a) (b := b) ha hu
|
| 219 |
+
hf_nonneg havg
|
| 220 |
+
exact hcontExpr.congr_of_eventuallyEq hevent
|
| 221 |
+
|
| 222 |
+
private lemma putnam_1962_a2_primitive_hasDerivAt
|
| 223 |
+
{f : ℝ → ℝ} {a b t : ℝ} (ha : 0 < a) (ht : t ∈ Ioo (0 : ℝ) b)
|
| 224 |
+
(hf_nonneg : 0 ≤ f)
|
| 225 |
+
(havg : ∀ x ∈ Ioo (0 : ℝ) b, (⨍ t in Ico (0 : ℝ) x, f t) = √(a * f x))
|
| 226 |
+
(hint : IntervalIntegrable f volume (0 : ℝ) b) :
|
| 227 |
+
HasDerivAt (fun u => ∫ v in (0 : ℝ)..u, f v)
|
| 228 |
+
((∫ v in (0 : ℝ)..t, f v) ^ 2 / (a * t ^ 2)) t := by
|
| 229 |
+
have hb0 : 0 ≤ b := le_of_lt (lt_trans ht.1 ht.2)
|
| 230 |
+
have hsub : uIcc (0 : ℝ) t ⊆ uIcc (0 : ℝ) b := by
|
| 231 |
+
refine uIcc_subset_uIcc ?_ ?_
|
| 232 |
+
· simpa [uIcc_of_le hb0] using
|
| 233 |
+
(show (0 : ℝ) ∈ Icc (0 : ℝ) b from ⟨le_rfl, hb0⟩)
|
| 234 |
+
· simpa [uIcc_of_le hb0] using
|
| 235 |
+
(show t ∈ Icc (0 : ℝ) b from ⟨ht.1.le, ht.2.le⟩)
|
| 236 |
+
have hint0t : IntervalIntegrable f volume (0 : ℝ) t := hint.mono_set hsub
|
| 237 |
+
have hcont_all : ∀ y ∈ Ioo (0 : ℝ) b, ContinuousAt f y := by
|
| 238 |
+
intro y hy
|
| 239 |
+
exact putnam_1962_a2_continuousAt_of_intervalIntegrable (f := f) (a := a) (b := b)
|
| 240 |
+
ha hy hf_nonneg havg hint
|
| 241 |
+
have hmeas : StronglyMeasurableAtFilter f (nhds t) volume := by
|
| 242 |
+
exact ContinuousAt.stronglyMeasurableAtFilter (s := Ioo (0 : ℝ) b) isOpen_Ioo
|
| 243 |
+
hcont_all t ht
|
| 244 |
+
have hcont : ContinuousAt f t := hcont_all t ht
|
| 245 |
+
have hder := intervalIntegral.integral_hasDerivAt_right (a := (0 : ℝ)) (b := t)
|
| 246 |
+
hint0t hmeas hcont
|
| 247 |
+
convert hder using 1
|
| 248 |
+
exact (putnam_1962_a2_f_eq_primitive_sq (f := f) (a := a) (b := b) ha ht
|
| 249 |
+
hf_nonneg havg).symm
|
| 250 |
+
|
| 251 |
+
private lemma putnam_1962_a2_lipschitz_quad
|
| 252 |
+
{a p M t : ℝ} (ha : 0 < a) (hp : 0 < p) (hpt : p ≤ t) (hM : 0 ≤ M) :
|
| 253 |
+
LipschitzOnWith ⟨2 * M / (a * p ^ 2), by positivity⟩
|
| 254 |
+
(fun y : ℝ => y ^ 2 / (a * t ^ 2)) (Icc (0 : ℝ) M) := by
|
| 255 |
+
refine LipschitzOnWith.of_dist_le_mul ?_
|
| 256 |
+
intro x hx y hy
|
| 257 |
+
rw [Real.dist_eq, Real.dist_eq]
|
| 258 |
+
have htpos : 0 < t := lt_of_lt_of_le hp hpt
|
| 259 |
+
have hdenpos : 0 < a * t ^ 2 := mul_pos ha (sq_pos_of_pos htpos)
|
| 260 |
+
have hpdenpos : 0 < a * p ^ 2 := mul_pos ha (sq_pos_of_pos hp)
|
| 261 |
+
have hxabs : |x| ≤ M := by
|
| 262 |
+
rw [abs_of_nonneg hx.1]
|
| 263 |
+
exact hx.2
|
| 264 |
+
have hyabs : |y| ≤ M := by
|
| 265 |
+
rw [abs_of_nonneg hy.1]
|
| 266 |
+
exact hy.2
|
| 267 |
+
have hsum : |x + y| ≤ 2 * M := by
|
| 268 |
+
calc
|
| 269 |
+
|x + y| ≤ |x| + |y| := abs_add_le x y
|
| 270 |
+
_ ≤ M + M := add_le_add hxabs hyabs
|
| 271 |
+
_ = 2 * M := by ring
|
| 272 |
+
have hsq : x ^ 2 / (a * t ^ 2) - y ^ 2 / (a * t ^ 2) =
|
| 273 |
+
(x - y) * (x + y) / (a * t ^ 2) := by
|
| 274 |
+
ring
|
| 275 |
+
rw [hsq]
|
| 276 |
+
have hmain : |(x - y) * (x + y) / (a * t ^ 2)| ≤
|
| 277 |
+
(2 * M / (a * p ^ 2)) * |x - y| := by
|
| 278 |
+
rw [abs_div, abs_of_pos hdenpos, abs_mul]
|
| 279 |
+
have ht2ge : p ^ 2 ≤ t ^ 2 := (sq_le_sq₀ hp.le htpos.le).mpr hpt
|
| 280 |
+
have h_inv : 1 / (a * t ^ 2) ≤ 1 / (a * p ^ 2) := by
|
| 281 |
+
refine one_div_le_one_div_of_le hpdenpos ?_
|
| 282 |
+
exact mul_le_mul_of_nonneg_left ht2ge ha.le
|
| 283 |
+
calc
|
| 284 |
+
|x - y| * |x + y| / (a * t ^ 2) =
|
| 285 |
+
|x - y| * (|x + y| * (1 / (a * t ^ 2))) := by
|
| 286 |
+
field_simp [hdenpos.ne']
|
| 287 |
+
_ ≤ |x - y| * ((2 * M) * (1 / (a * p ^ 2))) := by
|
| 288 |
+
gcongr
|
| 289 |
+
_ = (2 * M / (a * p ^ 2)) * |x - y| := by
|
| 290 |
+
field_simp [hpdenpos.ne']
|
| 291 |
+
simpa [NNReal.coe_mk] using hmain
|
| 292 |
+
|
| 293 |
+
private lemma putnam_1962_a2_primitive_nonneg
|
| 294 |
+
{f : ℝ → ℝ} {a b x : ℝ} (hx : x ∈ Ioo (0 : ℝ) b)
|
| 295 |
+
(havg : ∀ x ∈ Ioo (0 : ℝ) b, (⨍ t in Ico (0 : ℝ) x, f t) = √(a * f x)) :
|
| 296 |
+
0 ≤ ∫ t in (0 : ℝ)..x, f t := by
|
| 297 |
+
rw [putnam_1962_a2_integral_eq_average (f := f) hx.1, havg x hx]
|
| 298 |
+
exact mul_nonneg hx.1.le (Real.sqrt_nonneg _)
|
| 299 |
+
|
| 300 |
+
private lemma putnam_1962_a2_primitive_mono_le
|
| 301 |
+
{f : ℝ → ℝ} {r t : ℝ} (htr : t ≤ r) (hf_nonneg : 0 ≤ f)
|
| 302 |
+
(hint0r : IntervalIntegrable f volume (0 : ℝ) r)
|
| 303 |
+
(hint0t : IntervalIntegrable f volume (0 : ℝ) t) :
|
| 304 |
+
(∫ u in (0 : ℝ)..t, f u) ≤ ∫ u in (0 : ℝ)..r, f u := by
|
| 305 |
+
have hdiff := intervalIntegral.integral_interval_sub_left hint0r hint0t
|
| 306 |
+
have hnonneg : 0 ≤ ∫ u in t..r, f u :=
|
| 307 |
+
intervalIntegral.integral_nonneg htr (fun u _ => hf_nonneg u)
|
| 308 |
+
nlinarith
|
| 309 |
+
|
| 310 |
+
private lemma putnam_1962_a2_intervalIntegrable_of_ne
|
| 311 |
+
{f : ℝ → ℝ} {a b x : ℝ} (ha : 0 < a) (hx : x ∈ Ioo (0 : ℝ) b)
|
| 312 |
+
(hf_nonneg : 0 ≤ f)
|
| 313 |
+
(havg : ∀ x ∈ Ioo (0 : ℝ) b, (⨍ t in Ico (0 : ℝ) x, f t) = √(a * f x))
|
| 314 |
+
(hfx : f x ≠ 0) :
|
| 315 |
+
IntervalIntegrable f volume (0 : ℝ) x := by
|
| 316 |
+
have hfxpos : 0 < f x := lt_of_le_of_ne (hf_nonneg x) (Ne.symm hfx)
|
| 317 |
+
have hFpos : 0 < ∫ t in (0 : ℝ)..x, f t := by
|
| 318 |
+
rw [putnam_1962_a2_integral_eq_average (f := f) hx.1, havg x hx]
|
| 319 |
+
exact mul_pos hx.1 (Real.sqrt_pos.2 (mul_pos ha hfxpos))
|
| 320 |
+
exact intervalIntegral.intervalIntegrable_of_integral_ne_zero hFpos.ne'
|
| 321 |
+
|
| 322 |
+
private lemma putnam_1962_a2_exists_ne_before
|
| 323 |
+
{f : ℝ → ℝ} {a b x : ℝ} (ha : 0 < a) (hx : x ∈ Ioo (0 : ℝ) b)
|
| 324 |
+
(hf_nonneg : 0 ≤ f)
|
| 325 |
+
(havg : ∀ x ∈ Ioo (0 : ℝ) b, (⨍ t in Ico (0 : ℝ) x, f t) = √(a * f x))
|
| 326 |
+
(hfx : f x ≠ 0) :
|
| 327 |
+
∃ p : ℝ, 0 < p ∧ p < x ∧ f p ≠ 0 := by
|
| 328 |
+
by_contra hnone
|
| 329 |
+
have hfzero : ∀ t ∈ Ioo (0 : ℝ) x, f t = 0 := by
|
| 330 |
+
intro t ht
|
| 331 |
+
by_contra hft
|
| 332 |
+
exact hnone ⟨t, ht.1, ht.2, hft⟩
|
| 333 |
+
have havg0 := putnam_1962_a2_zero_on_Ioo_average (f := f) hfzero
|
| 334 |
+
have hfxpos : 0 < f x := lt_of_le_of_ne (hf_nonneg x) (Ne.symm hfx)
|
| 335 |
+
have hmain := havg x hx
|
| 336 |
+
rw [havg0] at hmain
|
| 337 |
+
have hsqrtpos : 0 < √(a * f x) := Real.sqrt_pos.2 (mul_pos ha hfxpos)
|
| 338 |
+
nlinarith
|
| 339 |
+
|
| 340 |
+
private lemma putnam_1962_a2_exists_ne_between_right
|
| 341 |
+
{f : ℝ → ℝ} {a b x y : ℝ} (ha : 0 < a) (hx : x ∈ Ioo (0 : ℝ) b)
|
| 342 |
+
(hxy : x < y) (hyb : y < b) (hf_nonneg : 0 ≤ f)
|
| 343 |
+
(havg : ∀ x ∈ Ioo (0 : ℝ) b, (⨍ t in Ico (0 : ℝ) x, f t) = √(a * f x))
|
| 344 |
+
(hfx : f x ≠ 0) :
|
| 345 |
+
∃ z : ℝ, z ∈ Ioo x y ∧ f z ≠ 0 := by
|
| 346 |
+
by_contra hnone
|
| 347 |
+
let m : ℝ := (x + y) / 2
|
| 348 |
+
have hxm : x < m := by dsimp [m]; linarith
|
| 349 |
+
have hmy : m < y := by dsimp [m]; linarith
|
| 350 |
+
have hmb : m ∈ Ioo (0 : ℝ) b := ⟨lt_trans hx.1 hxm, lt_trans hmy hyb⟩
|
| 351 |
+
have hfm : f m = 0 := by
|
| 352 |
+
by_contra hne
|
| 353 |
+
exact hnone ⟨m, ⟨hxm, hmy⟩, hne⟩
|
| 354 |
+
have hint0x : IntervalIntegrable f volume (0 : ℝ) x :=
|
| 355 |
+
putnam_1962_a2_intervalIntegrable_of_ne (f := f) (a := a) (b := b)
|
| 356 |
+
ha hx hf_nonneg havg hfx
|
| 357 |
+
have hFx_pos : 0 < ∫ t in (0 : ℝ)..x, f t := by
|
| 358 |
+
rw [putnam_1962_a2_integral_eq_average (f := f) hx.1, havg x hx]
|
| 359 |
+
have hfxpos : 0 < f x := lt_of_le_of_ne (hf_nonneg x) (Ne.symm hfx)
|
| 360 |
+
exact mul_pos hx.1 (Real.sqrt_pos.2 (mul_pos ha hfxpos))
|
| 361 |
+
have hzero_on : EqOn f (fun _ : ℝ => 0) (uIoc x m) := by
|
| 362 |
+
intro t ht
|
| 363 |
+
have ht' : t ∈ Ioc x m := by simpa [uIoc_of_le hxm.le] using ht
|
| 364 |
+
by_contra hne
|
| 365 |
+
exact hnone ⟨t, ⟨ht'.1, lt_of_le_of_lt ht'.2 hmy⟩, hne⟩
|
| 366 |
+
have hintxm : IntervalIntegrable f volume x m := by
|
| 367 |
+
exact (IntervalIntegrable.congr hzero_on.symm) (intervalIntegrable_const (c := (0 : ℝ)))
|
| 368 |
+
have hint0m : IntervalIntegrable f volume (0 : ℝ) m := hint0x.trans hintxm
|
| 369 |
+
have hIntxm : ∫ t in x..m, f t = 0 := by
|
| 370 |
+
have hae : ∀ᵐ t ∂volume, t ∈ uIoc x m → f t = (fun _ : ℝ => 0) t :=
|
| 371 |
+
ae_of_all volume hzero_on
|
| 372 |
+
rw [intervalIntegral.integral_congr_ae hae]
|
| 373 |
+
exact intervalIntegral.integral_zero
|
| 374 |
+
have hsub := intervalIntegral.integral_interval_sub_left hint0m hint0x
|
| 375 |
+
have hFm_eq : (∫ t in (0 : ℝ)..m, f t) = ∫ t in (0 : ℝ)..x, f t := by
|
| 376 |
+
nlinarith
|
| 377 |
+
have hFm_zero : (∫ t in (0 : ℝ)..m, f t) = 0 := by
|
| 378 |
+
rw [putnam_1962_a2_integral_eq_average (f := f) hmb.1, havg m hmb, hfm]
|
| 379 |
+
simp
|
| 380 |
+
nlinarith
|
| 381 |
+
|
| 382 |
+
private lemma putnam_1962_a2_primitive_pos_of_exists_ne
|
| 383 |
+
{f : ℝ → ℝ} {a b p : ℝ} (ha : 0 < a) (hp : p ∈ Ioo (0 : ℝ) b)
|
| 384 |
+
(hfp : f p ≠ 0) (hf_nonneg : 0 ≤ f)
|
| 385 |
+
(havg : ∀ x ∈ Ioo (0 : ℝ) b, (⨍ t in Ico (0 : ℝ) x, f t) = √(a * f x))
|
| 386 |
+
(hint : IntervalIntegrable f volume (0 : ℝ) b) :
|
| 387 |
+
∀ x ∈ Ioo (0 : ℝ) b, 0 < ∫ t in (0 : ℝ)..x, f t := by
|
| 388 |
+
let F : ℝ → ℝ := fun x => ∫ t in (0 : ℝ)..x, f t
|
| 389 |
+
have hFp_pos : 0 < F p := by
|
| 390 |
+
change 0 < ∫ t in (0 : ℝ)..p, f t
|
| 391 |
+
rw [putnam_1962_a2_integral_eq_average (f := f) hp.1, havg p hp]
|
| 392 |
+
have hfppos : 0 < f p := lt_of_le_of_ne (hf_nonneg p) (Ne.symm hfp)
|
| 393 |
+
exact mul_pos hp.1 (Real.sqrt_pos.2 (mul_pos ha hfppos))
|
| 394 |
+
intro x hx
|
| 395 |
+
by_cases hpx : p ≤ x
|
| 396 |
+
· have hb0 : 0 ≤ b := le_of_lt (lt_trans hx.1 hx.2)
|
| 397 |
+
have hsubx : uIcc (0 : ℝ) x ⊆ uIcc (0 : ℝ) b := by
|
| 398 |
+
refine uIcc_subset_uIcc ?_ ?_
|
| 399 |
+
· simpa [uIcc_of_le hb0] using
|
| 400 |
+
(show (0 : ℝ) ∈ Icc (0 : ℝ) b from ⟨le_rfl, hb0⟩)
|
| 401 |
+
· simpa [uIcc_of_le hb0] using
|
| 402 |
+
(show x ∈ Icc (0 : ℝ) b from ⟨hx.1.le, hx.2.le⟩)
|
| 403 |
+
have hsubp : uIcc (0 : ℝ) p ⊆ uIcc (0 : ℝ) b := by
|
| 404 |
+
refine uIcc_subset_uIcc ?_ ?_
|
| 405 |
+
· simpa [uIcc_of_le hb0] using
|
| 406 |
+
(show (0 : ℝ) ∈ Icc (0 : ℝ) b from ⟨le_rfl, hb0⟩)
|
| 407 |
+
· simpa [uIcc_of_le hb0] using
|
| 408 |
+
(show p ∈ Icc (0 : ℝ) b from ⟨hp.1.le, hp.2.le⟩)
|
| 409 |
+
have hmono := putnam_1962_a2_primitive_mono_le (f := f) (r := x) (t := p) hpx
|
| 410 |
+
hf_nonneg (hint.mono_set hsubx) (hint.mono_set hsubp)
|
| 411 |
+
exact lt_of_lt_of_le hFp_pos hmono
|
| 412 |
+
· have hxp : x < p := lt_of_not_ge hpx
|
| 413 |
+
have hFx_nonneg : 0 ≤ F x := by
|
| 414 |
+
exact putnam_1962_a2_primitive_nonneg (f := f) (a := a) (b := b) hx havg
|
| 415 |
+
by_contra hxnot
|
| 416 |
+
have hFx : F x = 0 := le_antisymm (le_of_not_gt hxnot) hFx_nonneg
|
| 417 |
+
have hFp_nonneg : 0 ≤ F p := hFp_pos.le
|
| 418 |
+
have hderivF : ∀ y ∈ Icc x p,
|
| 419 |
+
HasDerivAt F (F y ^ 2 / (a * y ^ 2)) y := by
|
| 420 |
+
intro y hy
|
| 421 |
+
have hyb : y ∈ Ioo (0 : ℝ) b :=
|
| 422 |
+
⟨lt_of_lt_of_le hx.1 hy.1, lt_of_le_of_lt hy.2 hp.2⟩
|
| 423 |
+
simpa [F] using putnam_1962_a2_primitive_hasDerivAt (f := f) (a := a) (b := b)
|
| 424 |
+
ha hyb hf_nonneg havg hint
|
| 425 |
+
have hcontF : ContinuousOn F (Icc x p) := HasDerivAt.continuousOn hderivF
|
| 426 |
+
have hderivZ : ∀ y ∈ Ico x p,
|
| 427 |
+
HasDerivWithinAt (fun _ : ℝ => (0 : ℝ))
|
| 428 |
+
(((0 : ℝ) ^ 2) / (a * y ^ 2)) (Ici y) y := by
|
| 429 |
+
intro y hy
|
| 430 |
+
simpa using (hasDerivAt_const y (0 : ℝ)).hasDerivWithinAt (s := Ici y)
|
| 431 |
+
have hmemF : ∀ y ∈ Ico x p, F y ∈ Icc (0 : ℝ) (F p) := by
|
| 432 |
+
intro y hy
|
| 433 |
+
have hyb : y ∈ Ioo (0 : ℝ) b :=
|
| 434 |
+
⟨lt_of_lt_of_le hx.1 hy.1, lt_of_le_of_lt hy.2.le hp.2⟩
|
| 435 |
+
have hb0 : 0 ≤ b := le_of_lt (lt_trans hyb.1 hyb.2)
|
| 436 |
+
have hsuby : uIcc (0 : ℝ) y ⊆ uIcc (0 : ℝ) b := by
|
| 437 |
+
refine uIcc_subset_uIcc ?_ ?_
|
| 438 |
+
· simpa [uIcc_of_le hb0] using
|
| 439 |
+
(show (0 : ℝ) ∈ Icc (0 : ℝ) b from ⟨le_rfl, hb0⟩)
|
| 440 |
+
· simpa [uIcc_of_le hb0] using
|
| 441 |
+
(show y ∈ Icc (0 : ℝ) b from ⟨hyb.1.le, hyb.2.le⟩)
|
| 442 |
+
have hsubp : uIcc (0 : ℝ) p ⊆ uIcc (0 : ℝ) b := by
|
| 443 |
+
refine uIcc_subset_uIcc ?_ ?_
|
| 444 |
+
· simpa [uIcc_of_le hb0] using
|
| 445 |
+
(show (0 : ℝ) ∈ Icc (0 : ℝ) b from ⟨le_rfl, hb0⟩)
|
| 446 |
+
· simpa [uIcc_of_le hb0] using
|
| 447 |
+
(show p ∈ Icc (0 : ℝ) b from ⟨hp.1.le, hp.2.le⟩)
|
| 448 |
+
refine ⟨putnam_1962_a2_primitive_nonneg (f := f) (a := a) (b := b) hyb havg, ?_⟩
|
| 449 |
+
exact putnam_1962_a2_primitive_mono_le (f := f) (r := p) (t := y) hy.2.le
|
| 450 |
+
hf_nonneg (hint.mono_set hsubp) (hint.mono_set hsuby)
|
| 451 |
+
have hmemZ : ∀ y ∈ Ico x p, (fun _ : ℝ => (0 : ℝ)) y ∈ Icc (0 : ℝ) (F p) := by
|
| 452 |
+
intro y hy
|
| 453 |
+
exact ⟨le_rfl, hFp_nonneg⟩
|
| 454 |
+
have hv : ∀ y ∈ Ico x p,
|
| 455 |
+
LipschitzOnWith ⟨2 * F p / (a * x ^ 2), by positivity⟩
|
| 456 |
+
(fun z : ℝ => z ^ 2 / (a * y ^ 2)) (Icc (0 : ℝ) (F p)) := by
|
| 457 |
+
intro y hy
|
| 458 |
+
exact putnam_1962_a2_lipschitz_quad (a := a) (p := x) (M := F p) (t := y)
|
| 459 |
+
ha hx.1 hy.1 hFp_nonneg
|
| 460 |
+
have heqOn := ODE_solution_unique_of_mem_Icc_right
|
| 461 |
+
(v := fun y z : ℝ => z ^ 2 / (a * y ^ 2))
|
| 462 |
+
(s := fun _ : ℝ => Icc (0 : ℝ) (F p))
|
| 463 |
+
(K := ⟨2 * F p / (a * x ^ 2), by positivity⟩)
|
| 464 |
+
hv hcontF
|
| 465 |
+
(fun y hy => (hderivF y (Ico_subset_Icc_self hy)).hasDerivWithinAt)
|
| 466 |
+
hmemF continuousOn_const hderivZ hmemZ hFx
|
| 467 |
+
have hpzero : F p = 0 := heqOn ⟨hxp.le, le_rfl⟩
|
| 468 |
+
exact hFp_pos.ne' hpzero
|
| 469 |
+
|
| 470 |
+
private lemma putnam_1962_a2_integrable_classification
|
| 471 |
+
{f : ℝ → ℝ} {a b p : ℝ} (ha : 0 < a) (hp : p ∈ Ioo (0 : ℝ) b)
|
| 472 |
+
(hfp : f p ≠ 0) (hf_nonneg : 0 ≤ f)
|
| 473 |
+
(havg : ∀ x ∈ Ioo (0 : ℝ) b, (⨍ t in Ico (0 : ℝ) x, f t) = √(a * f x))
|
| 474 |
+
(hint : IntervalIntegrable f volume (0 : ℝ) b) :
|
| 475 |
+
∃ c : ℝ,
|
| 476 |
+
(∀ x ∈ Ioo (0 : ℝ) b, 0 < 1 - c * x) ∧
|
| 477 |
+
∀ x ∈ Ioo (0 : ℝ) b, f x = a / (1 - c * x) ^ 2 := by
|
| 478 |
+
let F : ℝ → ℝ := fun x => ∫ t in (0 : ℝ)..x, f t
|
| 479 |
+
have hFpos : ∀ x ∈ Ioo (0 : ℝ) b, 0 < F x :=
|
| 480 |
+
putnam_1962_a2_primitive_pos_of_exists_ne (f := f) (a := a) (b := b) (p := p)
|
| 481 |
+
ha hp hfp hf_nonneg havg hint
|
| 482 |
+
let c : ℝ := a * ((a * p)⁻¹ - (F p)⁻¹)
|
| 483 |
+
refine ⟨c, ?_, ?_⟩
|
| 484 |
+
· intro x hx
|
| 485 |
+
have hderivF : ∀ y ∈ Ioo (0 : ℝ) b,
|
| 486 |
+
HasDerivAt F (F y ^ 2 / (a * y ^ 2)) y := by
|
| 487 |
+
intro y hy
|
| 488 |
+
simpa [F] using putnam_1962_a2_primitive_hasDerivAt (f := f) (a := a) (b := b)
|
| 489 |
+
ha hy hf_nonneg havg hint
|
| 490 |
+
let Q : ℝ → ℝ := fun y => (F y)⁻¹ - (a * y)⁻¹
|
| 491 |
+
have hQderivAt : ∀ y ∈ Ioo (0 : ℝ) b, HasDerivAt Q 0 y := by
|
| 492 |
+
intro y hy
|
| 493 |
+
have hFy : F y ≠ 0 := ne_of_gt (hFpos y hy)
|
| 494 |
+
have hay : a * y ≠ 0 := mul_ne_zero ha.ne' (ne_of_gt hy.1)
|
| 495 |
+
have h1 := (hderivF y hy).inv hFy
|
| 496 |
+
have h2 := ((hasDerivAt_const y a).mul (hasDerivAt_id y)).inv hay
|
| 497 |
+
have hsub := h1.sub h2
|
| 498 |
+
convert hsub using 1
|
| 499 |
+
· simp
|
| 500 |
+
field_simp [ha.ne', (ne_of_gt hy.1), hFy]
|
| 501 |
+
ring
|
| 502 |
+
have hQdiff : DifferentiableOn ℝ Q (Ioo (0 : ℝ) b) := by
|
| 503 |
+
intro y hy
|
| 504 |
+
exact (hQderivAt y hy).differentiableAt.differentiableWithinAt
|
| 505 |
+
have hQderiv : EqOn (deriv Q) 0 (Ioo (0 : ℝ) b) := by
|
| 506 |
+
intro y hy
|
| 507 |
+
exact (hQderivAt y hy).deriv
|
| 508 |
+
have hQeq : Q x = Q p :=
|
| 509 |
+
isOpen_Ioo.is_const_of_deriv_eq_zero isPreconnected_Ioo hQdiff hQderiv hx hp
|
| 510 |
+
have hcp : Q p = -c / a := by
|
| 511 |
+
simp [Q, c]
|
| 512 |
+
field_simp [ha.ne']
|
| 513 |
+
ring
|
| 514 |
+
have hrec : (F x)⁻¹ - (a * x)⁻¹ = -c / a := by
|
| 515 |
+
simpa [Q] using hQeq.trans hcp
|
| 516 |
+
have hdeneq : 1 - c * x = a * x / F x := by
|
| 517 |
+
have hane : a ≠ 0 := ne_of_gt ha
|
| 518 |
+
have hxne : x ≠ 0 := ne_of_gt hx.1
|
| 519 |
+
have hFxne : F x ≠ 0 := ne_of_gt (hFpos x hx)
|
| 520 |
+
field_simp [hane, hxne, hFxne] at hrec ⊢
|
| 521 |
+
nlinarith
|
| 522 |
+
rw [hdeneq]
|
| 523 |
+
exact div_pos (mul_pos ha hx.1) (hFpos x hx)
|
| 524 |
+
· intro x hx
|
| 525 |
+
have hderivF : ∀ y ∈ Ioo (0 : ℝ) b,
|
| 526 |
+
HasDerivAt F (F y ^ 2 / (a * y ^ 2)) y := by
|
| 527 |
+
intro y hy
|
| 528 |
+
simpa [F] using putnam_1962_a2_primitive_hasDerivAt (f := f) (a := a) (b := b)
|
| 529 |
+
ha hy hf_nonneg havg hint
|
| 530 |
+
let Q : ℝ → ℝ := fun y => (F y)⁻¹ - (a * y)⁻¹
|
| 531 |
+
have hQderivAt : ∀ y ∈ Ioo (0 : ℝ) b, HasDerivAt Q 0 y := by
|
| 532 |
+
intro y hy
|
| 533 |
+
have hFy : F y ≠ 0 := ne_of_gt (hFpos y hy)
|
| 534 |
+
have hay : a * y ≠ 0 := mul_ne_zero ha.ne' (ne_of_gt hy.1)
|
| 535 |
+
have h1 := (hderivF y hy).inv hFy
|
| 536 |
+
have h2 := ((hasDerivAt_const y a).mul (hasDerivAt_id y)).inv hay
|
| 537 |
+
have hsub := h1.sub h2
|
| 538 |
+
convert hsub using 1
|
| 539 |
+
· simp
|
| 540 |
+
field_simp [ha.ne', (ne_of_gt hy.1), hFy]
|
| 541 |
+
ring
|
| 542 |
+
have hQdiff : DifferentiableOn ℝ Q (Ioo (0 : ℝ) b) := by
|
| 543 |
+
intro y hy
|
| 544 |
+
exact (hQderivAt y hy).differentiableAt.differentiableWithinAt
|
| 545 |
+
have hQderiv : EqOn (deriv Q) 0 (Ioo (0 : ℝ) b) := by
|
| 546 |
+
intro y hy
|
| 547 |
+
exact (hQderivAt y hy).deriv
|
| 548 |
+
have hQeq : Q x = Q p :=
|
| 549 |
+
isOpen_Ioo.is_const_of_deriv_eq_zero isPreconnected_Ioo hQdiff hQderiv hx hp
|
| 550 |
+
have hcp : Q p = -c / a := by
|
| 551 |
+
simp [Q, c]
|
| 552 |
+
field_simp [ha.ne']
|
| 553 |
+
ring
|
| 554 |
+
have hrec : (F x)⁻¹ - (a * x)⁻¹ = -c / a := by
|
| 555 |
+
simpa [Q] using hQeq.trans hcp
|
| 556 |
+
have hF_eq : F x = a * x / (1 - c * x) := by
|
| 557 |
+
have hdeneq : 1 - c * x = a * x / F x := by
|
| 558 |
+
have hane : a ≠ 0 := ne_of_gt ha
|
| 559 |
+
have hxne : x ≠ 0 := ne_of_gt hx.1
|
| 560 |
+
have hFxne : F x ≠ 0 := ne_of_gt (hFpos x hx)
|
| 561 |
+
field_simp [hane, hxne, hFxne] at hrec ⊢
|
| 562 |
+
nlinarith
|
| 563 |
+
rw [hdeneq]
|
| 564 |
+
field_simp [ne_of_gt (hFpos x hx), ha.ne', (ne_of_gt hx.1)]
|
| 565 |
+
have hf_eq := putnam_1962_a2_f_eq_primitive_sq (f := f) (a := a) (b := b)
|
| 566 |
+
ha hx hf_nonneg havg
|
| 567 |
+
rw [hf_eq]
|
| 568 |
+
change F x ^ 2 / (a * x ^ 2) = a / (1 - c * x) ^ 2
|
| 569 |
+
rw [hF_eq]
|
| 570 |
+
field_simp [ha.ne', (ne_of_gt hx.1)]
|
| 571 |
+
|
| 572 |
+
private lemma putnam_1962_a2_integrable_classification_explicit
|
| 573 |
+
{f : ℝ → ℝ} {a b p : ℝ} (ha : 0 < a) (hp : p ∈ Ioo (0 : ℝ) b)
|
| 574 |
+
(hfp : f p ≠ 0) (hf_nonneg : 0 ≤ f)
|
| 575 |
+
(havg : ∀ x ∈ Ioo (0 : ℝ) b, (⨍ t in Ico (0 : ℝ) x, f t) = √(a * f x))
|
| 576 |
+
(hint : IntervalIntegrable f volume (0 : ℝ) b) :
|
| 577 |
+
let F : ℝ → ℝ := fun x => ∫ t in (0 : ℝ)..x, f t
|
| 578 |
+
let c : ℝ := a * ((a * p)⁻¹ - (F p)⁻¹)
|
| 579 |
+
(∀ x ∈ Ioo (0 : ℝ) b, 0 < 1 - c * x) ∧
|
| 580 |
+
∀ x ∈ Ioo (0 : ℝ) b, f x = a / (1 - c * x) ^ 2 := by
|
| 581 |
+
intro F c
|
| 582 |
+
have hFpos : 0 < F p := by
|
| 583 |
+
change 0 < ∫ t in (0 : ℝ)..p, f t
|
| 584 |
+
rw [putnam_1962_a2_integral_eq_average (f := f) hp.1, havg p hp]
|
| 585 |
+
have hfppos : 0 < f p := lt_of_le_of_ne (hf_nonneg p) (Ne.symm hfp)
|
| 586 |
+
exact mul_pos hp.1 (Real.sqrt_pos.2 (mul_pos ha hfppos))
|
| 587 |
+
rcases putnam_1962_a2_integrable_classification (f := f) (a := a) (b := b) (p := p)
|
| 588 |
+
ha hp hfp hf_nonneg havg hint with ⟨d, hdpos, hdeq⟩
|
| 589 |
+
have hFp_eq : F p = a * p / (1 - d * p) := by
|
| 590 |
+
change ∫ t in (0 : ℝ)..p, f t = a * p / (1 - d * p)
|
| 591 |
+
rw [putnam_1962_a2_integral_eq_average (f := f) hp.1, havg p hp, hdeq p hp]
|
| 592 |
+
rw [putnam_1962_a2_sqrt_rat a (1 - d * p) ha.le (hdpos p hp)]
|
| 593 |
+
ring
|
| 594 |
+
have hdc : d = c := by
|
| 595 |
+
dsimp [c]
|
| 596 |
+
rw [hFp_eq]
|
| 597 |
+
field_simp [ha.ne', (ne_of_gt hp.1), (hdpos p hp).ne']
|
| 598 |
+
ring
|
| 599 |
+
constructor
|
| 600 |
+
· intro x hx
|
| 601 |
+
simpa [← hdc] using hdpos x hx
|
| 602 |
+
· intro x hx
|
| 603 |
+
simpa [← hdc] using hdeq x hx
|
| 604 |
+
|
| 605 |
+
private lemma putnam_1962_a2_formula_of_ne_in_interval
|
| 606 |
+
{f : ℝ → ℝ} {a b p y0 : ℝ} (ha : 0 < a)
|
| 607 |
+
(hp_pos : 0 < p) (hpy0 : p < y0) (hy0b : y0 < b)
|
| 608 |
+
(hfp : f p ≠ 0) (hfy0 : f y0 ≠ 0) (hf_nonneg : 0 ≤ f)
|
| 609 |
+
(havg : ∀ x ∈ Ioo (0 : ℝ) b, (⨍ t in Ico (0 : ℝ) x, f t) = √(a * f x)) :
|
| 610 |
+
let F : ℝ → ℝ := fun x => ∫ t in (0 : ℝ)..x, f t
|
| 611 |
+
let c : ℝ := a * ((a * p)⁻¹ - (F p)⁻¹)
|
| 612 |
+
∀ x ∈ Ioo (0 : ℝ) b, f x ≠ 0 →
|
| 613 |
+
0 < 1 - c * x ∧ f x = a / (1 - c * x) ^ 2 := by
|
| 614 |
+
intro F c x hx hfx
|
| 615 |
+
let w : ℝ := max x y0
|
| 616 |
+
let u : ℝ := (w + b) / 2
|
| 617 |
+
have hw_pos : 0 < w := lt_of_lt_of_le hx.1 (le_max_left x y0)
|
| 618 |
+
have hw_b : w < b := max_lt hx.2 hy0b
|
| 619 |
+
have hw_ne : f w ≠ 0 := by
|
| 620 |
+
by_cases hxy : x ≤ y0
|
| 621 |
+
· have hw : w = y0 := by simp [w, max_eq_right hxy]
|
| 622 |
+
simpa [hw] using hfy0
|
| 623 |
+
· have hyx : y0 ≤ x := le_of_not_ge hxy
|
| 624 |
+
have hw : w = x := by simp [w, max_eq_left hyx]
|
| 625 |
+
simpa [hw] using hfx
|
| 626 |
+
have hwu : w < u := by dsimp [u]; linarith
|
| 627 |
+
have hub : u < b := by dsimp [u]; linarith
|
| 628 |
+
rcases putnam_1962_a2_exists_ne_between_right (f := f) (a := a) (b := b)
|
| 629 |
+
ha ⟨hw_pos, hw_b⟩ hwu hub hf_nonneg havg hw_ne with ⟨z, hz, hfz⟩
|
| 630 |
+
have hz_mem : z ∈ Ioo (0 : ℝ) b := ⟨lt_trans hw_pos hz.1, lt_trans hz.2 hub⟩
|
| 631 |
+
have hpz : p ∈ Ioo (0 : ℝ) z := by
|
| 632 |
+
refine ⟨hp_pos, ?_⟩
|
| 633 |
+
exact lt_of_lt_of_le hpy0 (le_max_right x y0) |>.trans hz.1
|
| 634 |
+
have hxz : x ∈ Ioo (0 : ℝ) z := ⟨hx.1, lt_of_le_of_lt (le_max_left x y0) hz.1⟩
|
| 635 |
+
have hint0z : IntervalIntegrable f volume (0 : ℝ) z :=
|
| 636 |
+
putnam_1962_a2_intervalIntegrable_of_ne (f := f) (a := a) (b := b)
|
| 637 |
+
ha hz_mem hf_nonneg havg hfz
|
| 638 |
+
have hclass := putnam_1962_a2_integrable_classification_explicit
|
| 639 |
+
(f := f) (a := a) (b := z) (p := p) ha hpz hfp hf_nonneg
|
| 640 |
+
(fun t ht => havg t ⟨ht.1, lt_trans ht.2 hz_mem.2⟩) hint0z
|
| 641 |
+
exact ⟨hclass.1 x hxz, hclass.2 x hxz⟩
|
| 642 |
+
|
| 643 |
+
private lemma putnam_1962_a2_ne_of_lt_ne
|
| 644 |
+
{f : ℝ → ℝ} {a b x y : ℝ} (ha : 0 < a) (hy : y ∈ Ioo (0 : ℝ) b)
|
| 645 |
+
(hx0 : 0 < x) (hxy : x < y) (hf_nonneg : 0 ≤ f)
|
| 646 |
+
(havg : ∀ x ∈ Ioo (0 : ℝ) b, (⨍ t in Ico (0 : ℝ) x, f t) = √(a * f x))
|
| 647 |
+
(hfy : f y ≠ 0) :
|
| 648 |
+
f x ≠ 0 := by
|
| 649 |
+
rcases putnam_1962_a2_exists_ne_before (f := f) (a := a) (b := b)
|
| 650 |
+
ha hy hf_nonneg havg hfy with ⟨p, hp0, hpy, hfp⟩
|
| 651 |
+
have hint0y : IntervalIntegrable f volume (0 : ℝ) y :=
|
| 652 |
+
putnam_1962_a2_intervalIntegrable_of_ne (f := f) (a := a) (b := b)
|
| 653 |
+
ha hy hf_nonneg havg hfy
|
| 654 |
+
have hp : p ∈ Ioo (0 : ℝ) y := ⟨hp0, hpy⟩
|
| 655 |
+
rcases putnam_1962_a2_integrable_classification (f := f) (a := a) (b := y) (p := p)
|
| 656 |
+
ha hp hfp hf_nonneg (fun t ht => havg t ⟨ht.1, lt_trans ht.2 hy.2⟩) hint0y
|
| 657 |
+
with ⟨c, hden, hrat⟩
|
| 658 |
+
have hx : x ∈ Ioo (0 : ℝ) y := ⟨hx0, hxy⟩
|
| 659 |
+
rw [hrat x hx]
|
| 660 |
+
exact div_ne_zero ha.ne' (pow_ne_zero 2 (hden x hx).ne')
|
| 661 |
+
|
| 662 |
+
private lemma putnam_1962_a2_no_stop_before_pole
|
| 663 |
+
{f : ℝ → ℝ} {a c e r : ℝ} (ha : 0 < a) (hrpos : 0 < r) (hre : r < e)
|
| 664 |
+
(hden_left : ∀ x : ℝ, 0 < x → x < r → 0 < 1 - c * x)
|
| 665 |
+
(hleft : ∀ x : ℝ, 0 < x → x < r → f x = a / (1 - c * x) ^ 2)
|
| 666 |
+
(hright : ∀ x : ℝ, r ≤ x → x < e → f x = 0)
|
| 667 |
+
(hdenr : 0 < 1 - c * r)
|
| 668 |
+
(havg : ∀ x ∈ Ioo (0 : ℝ) e, (⨍ t in Ico (0 : ℝ) x, f t) = √(a * f x)) :
|
| 669 |
+
False := by
|
| 670 |
+
let m : ℝ := (r + e) / 2
|
| 671 |
+
have hrm : r < m := by dsimp [m]; linarith
|
| 672 |
+
have hme : m < e := by dsimp [m]; linarith
|
| 673 |
+
have hmpos : 0 < m := lt_trans hrpos hrm
|
| 674 |
+
let rat : ℝ → ℝ := fun x => a / (1 - c * x) ^ 2
|
| 675 |
+
have hdenIcc : ∀ t ∈ Icc (0 : ℝ) r, 1 - c * t ≠ 0 := by
|
| 676 |
+
intro t ht
|
| 677 |
+
rcases eq_or_lt_of_le ht.1 with rfl | htpos
|
| 678 |
+
· norm_num
|
| 679 |
+
rcases lt_or_eq_of_le ht.2 with htr | rfl
|
| 680 |
+
· exact (hden_left t htpos htr).ne'
|
| 681 |
+
· exact hdenr.ne'
|
| 682 |
+
have hrat_int_val : ∫ t in (0 : ℝ)..r, rat t = a * r / (1 - c * r) := by
|
| 683 |
+
simpa [rat] using putnam_1962_a2_integral_rat a c r hrpos hdenIcc
|
| 684 |
+
have hrat_int : IntervalIntegrable rat volume (0 : ℝ) r := by
|
| 685 |
+
refine intervalIntegral.intervalIntegrable_of_integral_ne_zero ?_
|
| 686 |
+
rw [hrat_int_val]
|
| 687 |
+
exact (div_pos (mul_pos ha hrpos) hdenr).ne'
|
| 688 |
+
have hae_rat_f : ∀ᵐ t ∂volume, t ∈ uIoc (0 : ℝ) r → rat t = f t := by
|
| 689 |
+
filter_upwards [show ∀ᵐ t : ℝ ∂volume, t ≠ r by rw [ae_iff]; simp] with t htrne ht
|
| 690 |
+
have ht' : t ∈ Ioc (0 : ℝ) r := by simpa [uIoc_of_le hrpos.le] using ht
|
| 691 |
+
have hlt : t < r := lt_of_le_of_ne ht'.2 htrne
|
| 692 |
+
exact (hleft t ht'.1 hlt).symm
|
| 693 |
+
have hf_int0r : IntervalIntegrable f volume (0 : ℝ) r :=
|
| 694 |
+
hrat_int.congr_ae ((ae_restrict_iff' measurableSet_uIoc).mpr hae_rat_f)
|
| 695 |
+
have hzero_rm : EqOn f (fun _ : ℝ => 0) (uIoc r m) := by
|
| 696 |
+
intro t ht
|
| 697 |
+
have ht' : t ∈ Ioc r m := by simpa [uIoc_of_le hrm.le] using ht
|
| 698 |
+
exact hright t ht'.1.le (lt_of_le_of_lt ht'.2 hme)
|
| 699 |
+
have hf_intrm : IntervalIntegrable f volume r m := by
|
| 700 |
+
exact (IntervalIntegrable.congr hzero_rm.symm) (intervalIntegrable_const (c := (0 : ℝ)))
|
| 701 |
+
have hf_int0m : IntervalIntegrable f volume (0 : ℝ) m := hf_int0r.trans hf_intrm
|
| 702 |
+
have hInt0r : ∫ t in (0 : ℝ)..r, f t = a * r / (1 - c * r) := by
|
| 703 |
+
rw [← hrat_int_val]
|
| 704 |
+
exact (intervalIntegral.integral_congr_ae
|
| 705 |
+
(Filter.Eventually.mono hae_rat_f fun t ht hmem => (ht hmem).symm))
|
| 706 |
+
have hIntrm : ∫ t in r..m, f t = 0 := by
|
| 707 |
+
have hae : ∀ᵐ t ∂volume, t ∈ uIoc r m → f t = (fun _ : ℝ => 0) t :=
|
| 708 |
+
ae_of_all volume hzero_rm
|
| 709 |
+
rw [intervalIntegral.integral_congr_ae hae]
|
| 710 |
+
exact intervalIntegral.integral_zero
|
| 711 |
+
have hsub := intervalIntegral.integral_interval_sub_left hf_int0m hf_int0r
|
| 712 |
+
have hInt0m : ∫ t in (0 : ℝ)..m, f t = a * r / (1 - c * r) := by
|
| 713 |
+
nlinarith
|
| 714 |
+
have hfm : f m = 0 := hright m hrm.le hme
|
| 715 |
+
have hInt0m_zero : ∫ t in (0 : ℝ)..m, f t = 0 := by
|
| 716 |
+
rw [putnam_1962_a2_integral_eq_average (f := f) hmpos, havg m ⟨hmpos, hme⟩, hfm]
|
| 717 |
+
simp
|
| 718 |
+
have hpos : 0 < a * r / (1 - c * r) := div_pos (mul_pos ha hrpos) hdenr
|
| 719 |
+
nlinarith
|
| 720 |
+
|
| 721 |
+
-- {f | (∃ a c : ℝ, 0 ≤ a ∧ f = (fun x : ℝ ↦ a / (1 - c * x) ^ 2)) ∨ (∃ a c : ℝ, 0 ≤ a ∧ 0 < c ∧ f = (fun x : ℝ ↦ if x < 1 / c then a / (1 - c * x) ^ 2 else 0)) ∨ (0 ≤ f ∧ ∀ x : ℝ, 0 < x → f x = 0) ∨ (∃ e : ℝ, 0 < e ∧ f 0 = 0 ∧ 0 ≤ f ∧ ∀ x ∈ Ioo (0 : ℝ) e, (⨍ t in Ico (0 : ℝ) x, f t) = 0)}
|
| 722 |
+
/--
|
| 723 |
+
Find every real-valued function $f$ whose domain is an interval $I$ (finite or infinite) having 0 as a left-hand endpoint, such that for every positive member $x$ of $I$ the average of $f$ over the closed interval $[0, x]$ is equal to the geometric mean of the numbers $f(0)$ and $f(x)$.
|
| 724 |
+
-/
|
| 725 |
+
theorem putnam_1962_a2
|
| 726 |
+
(P : Set ℝ → (ℝ → ℝ) → Prop)
|
| 727 |
+
(P_def : ∀ s f, P s f ↔ 0 ≤ f ∧ ∀ x ∈ s, ⨍ t in Ico 0 x, f t = √(f 0 * f x)) :
|
| 728 |
+
(∀ f,
|
| 729 |
+
(P (Ioi 0) f → ∃ g ∈ (({f | (∃ a c : ℝ, 0 ≤ a ∧ f = (fun x : ℝ ↦ a / (1 - c * x) ^ 2)) ∨ (∃ a c : ℝ, 0 ≤ a ∧ 0 < c ∧ f = (fun x : ℝ ↦ if x < 1 / c then a / (1 - c * x) ^ 2 else 0)) ∨ (0 ≤ f ∧ ∀ x : ℝ, 0 < x → f x = 0) ∨ (∃ e : ℝ, 0 < e ∧ f 0 = 0 ∧ 0 ≤ f ∧ ∀ x ∈ Ioo (0 : ℝ) e, (⨍ t in Ico (0 : ℝ) x, f t) = 0)}) : Set (ℝ → ℝ) ), EqOn f g (Ici 0)) ∧
|
| 730 |
+
(∀ e > 0, P (Ioo 0 e) f → ∃ g ∈ (({f | (∃ a c : ℝ, 0 ≤ a ∧ f = (fun x : ℝ ↦ a / (1 - c * x) ^ 2)) ∨ (∃ a c : ℝ, 0 ≤ a ∧ 0 < c ∧ f = (fun x : ℝ ↦ if x < 1 / c then a / (1 - c * x) ^ 2 else 0)) ∨ (0 ≤ f ∧ ∀ x : ℝ, 0 < x → f x = 0) ∨ (∃ e : ℝ, 0 < e ∧ f 0 = 0 ∧ 0 ≤ f ∧ ∀ x ∈ Ioo (0 : ℝ) e, (⨍ t in Ico (0 : ℝ) x, f t) = 0)}) : Set (ℝ → ℝ) ), EqOn f g (Ico 0 e))) ∧
|
| 731 |
+
∀ f ∈ (({f | (∃ a c : ℝ, 0 ≤ a ∧ f = (fun x : ℝ ↦ a / (1 - c * x) ^ 2)) ∨ (∃ a c : ℝ, 0 ≤ a ∧ 0 < c ∧ f = (fun x : ℝ ↦ if x < 1 / c then a / (1 - c * x) ^ 2 else 0)) ∨ (0 ≤ f ∧ ∀ x : ℝ, 0 < x → f x = 0) ∨ (∃ e : ℝ, 0 < e ∧ f 0 = 0 ∧ 0 ≤ f ∧ ∀ x ∈ Ioo (0 : ℝ) e, (⨍ t in Ico (0 : ℝ) x, f t) = 0)}) : Set (ℝ → ℝ) ), P (Ioi 0) f ∨ (∃ e > 0, P (Ioo 0 e) f) := by
|
| 732 |
+
classical
|
| 733 |
+
constructor
|
| 734 |
+
· intro f
|
| 735 |
+
constructor
|
| 736 |
+
· intro hf
|
| 737 |
+
by_cases h0 : f 0 = 0
|
| 738 |
+
· refine ⟨f, ?_, ?_⟩
|
| 739 |
+
· right; right; right
|
| 740 |
+
refine ⟨1, by norm_num, h0, ((P_def (Ioi 0) f).mp hf).1, ?_⟩
|
| 741 |
+
intro x hx
|
| 742 |
+
have h := ((P_def (Ioi 0) f).mp hf).2 x hx.1
|
| 743 |
+
simpa [h0] using h
|
| 744 |
+
· intro x hx
|
| 745 |
+
rfl
|
| 746 |
+
· have hfdata := ((P_def (Ioi 0) f).mp hf)
|
| 747 |
+
by_cases hpos : ∃ x : ℝ, 0 < x ∧ f x ≠ 0
|
| 748 |
+
· have ha : 0 < f 0 := lt_of_le_of_ne (hfdata.1 0) (Ne.symm h0)
|
| 749 |
+
rcases hpos with ⟨x1, hx1pos, hfx1⟩
|
| 750 |
+
let B1 : ℝ := x1 + 1
|
| 751 |
+
have hx1B1 : x1 ∈ Ioo (0 : ℝ) B1 := ⟨hx1pos, by dsimp [B1]; linarith⟩
|
| 752 |
+
rcases putnam_1962_a2_exists_ne_before (f := f) (a := f 0) (b := B1)
|
| 753 |
+
ha hx1B1 hfdata.1 (fun x hx => hfdata.2 x hx.1) hfx1 with
|
| 754 |
+
⟨p, hp0, hpx1, hfp⟩
|
| 755 |
+
let B2 : ℝ := x1 + 2
|
| 756 |
+
let u1 : ℝ := x1 + 1
|
| 757 |
+
have hx1B2 : x1 ∈ Ioo (0 : ℝ) B2 := ⟨hx1pos, by dsimp [B2]; linarith⟩
|
| 758 |
+
have hx1u1 : x1 < u1 := by dsimp [u1]; linarith
|
| 759 |
+
have hu1B2 : u1 < B2 := by dsimp [u1, B2]; linarith
|
| 760 |
+
rcases putnam_1962_a2_exists_ne_between_right (f := f) (a := f 0) (b := B2)
|
| 761 |
+
ha hx1B2 hx1u1 hu1B2 hfdata.1 (fun x hx => hfdata.2 x hx.1) hfx1 with
|
| 762 |
+
⟨y0, hy0, hfy0⟩
|
| 763 |
+
have hpy0 : p < y0 := lt_trans hpx1 hy0.1
|
| 764 |
+
let F : ℝ → ℝ := fun x => ∫ t in (0 : ℝ)..x, f t
|
| 765 |
+
let c : ℝ := f 0 * ((f 0 * p)⁻¹ - (F p)⁻¹)
|
| 766 |
+
have hformula_ne : ∀ x : ℝ, 0 < x → f x ≠ 0 →
|
| 767 |
+
0 < 1 - c * x ∧ f x = f 0 / (1 - c * x) ^ 2 := by
|
| 768 |
+
intro x hx0 hfx
|
| 769 |
+
let B : ℝ := max x y0 + 1
|
| 770 |
+
have hy0B : y0 < B := by dsimp [B]; linarith [le_max_right x y0]
|
| 771 |
+
have hxB : x ∈ Ioo (0 : ℝ) B := ⟨hx0, by dsimp [B]; linarith [le_max_left x y0]⟩
|
| 772 |
+
have h := putnam_1962_a2_formula_of_ne_in_interval (f := f) (a := f 0)
|
| 773 |
+
(b := B) (p := p) (y0 := y0) ha hp0 hpy0 hy0B hfp hfy0 hfdata.1
|
| 774 |
+
(fun t ht => hfdata.2 t ht.1)
|
| 775 |
+
simpa [F, c] using h x hxB hfx
|
| 776 |
+
have hne_of_lt_ne_global : ∀ x y : ℝ, 0 < x → x < y → f y ≠ 0 → f x ≠ 0 := by
|
| 777 |
+
intro x y hx0 hxy hfy
|
| 778 |
+
let B : ℝ := y + 1
|
| 779 |
+
have hyB : y ∈ Ioo (0 : ℝ) B := by
|
| 780 |
+
have hy0 : 0 < y := lt_trans hx0 hxy
|
| 781 |
+
exact ⟨hy0, by dsimp [B]; linarith⟩
|
| 782 |
+
exact putnam_1962_a2_ne_of_lt_ne (f := f) (a := f 0) (b := B)
|
| 783 |
+
ha hyB hx0 hxy hfdata.1 (fun t ht => hfdata.2 t ht.1) hfy
|
| 784 |
+
let S : Set ℝ := {x | 0 < x ∧ f x ≠ 0}
|
| 785 |
+
have hS_nonempty : S.Nonempty := ⟨y0, ⟨lt_trans hx1pos hy0.1, hfy0⟩⟩
|
| 786 |
+
by_cases hS_bdd : BddAbove S
|
| 787 |
+
· let r : ℝ := sSup S
|
| 788 |
+
have hy0_le_r : y0 ≤ r := le_csSup hS_bdd ⟨lt_trans hx1pos hy0.1, hfy0⟩
|
| 789 |
+
have hrpos : 0 < r := lt_of_lt_of_le (lt_trans hx1pos hy0.1) hy0_le_r
|
| 790 |
+
have hne_of_lt_r : ∀ x : ℝ, 0 < x → x < r → f x ≠ 0 := by
|
| 791 |
+
intro x hx0 hxr
|
| 792 |
+
rcases exists_lt_of_lt_csSup hS_nonempty hxr with ⟨y, hyS, hxy⟩
|
| 793 |
+
exact hne_of_lt_ne_global x y hx0 hxy hyS.2
|
| 794 |
+
have hden_left : ∀ x : ℝ, 0 < x → x < r → 0 < 1 - c * x := by
|
| 795 |
+
intro x hx0 hxr
|
| 796 |
+
exact (hformula_ne x hx0 (hne_of_lt_r x hx0 hxr)).1
|
| 797 |
+
have hleft : ∀ x : ℝ, 0 < x → x < r → f x = f 0 / (1 - c * x) ^ 2 := by
|
| 798 |
+
intro x hx0 hxr
|
| 799 |
+
exact (hformula_ne x hx0 (hne_of_lt_r x hx0 hxr)).2
|
| 800 |
+
have hzero_of_r_lt : ∀ x : ℝ, r < x → f x = 0 := by
|
| 801 |
+
intro x hrx
|
| 802 |
+
by_contra hfx
|
| 803 |
+
have hxS : x ��� S := ⟨lt_trans hrpos hrx, hfx⟩
|
| 804 |
+
have hxle : x ≤ r := le_csSup hS_bdd hxS
|
| 805 |
+
linarith
|
| 806 |
+
have hzero_of_r_le : ∀ x : ℝ, r ≤ x → f x = 0 := by
|
| 807 |
+
intro x hrx
|
| 808 |
+
rcases lt_or_eq_of_le hrx with hrx' | rfl
|
| 809 |
+
· exact hzero_of_r_lt x hrx'
|
| 810 |
+
· by_contra hfr
|
| 811 |
+
let B : ℝ := r + 2
|
| 812 |
+
let u : ℝ := r + 1
|
| 813 |
+
have hrB : r ∈ Ioo (0 : ℝ) B := ⟨hrpos, by dsimp [B]; linarith⟩
|
| 814 |
+
have hru : r < u := by dsimp [u]; linarith
|
| 815 |
+
have huB : u < B := by dsimp [u, B]; linarith
|
| 816 |
+
rcases putnam_1962_a2_exists_ne_between_right (f := f) (a := f 0) (b := B)
|
| 817 |
+
ha hrB hru huB hfdata.1 (fun t ht => hfdata.2 t ht.1) hfr with
|
| 818 |
+
⟨z, hz, hfz⟩
|
| 819 |
+
have hzS : z ∈ S := ⟨lt_trans hrpos hz.1, hfz⟩
|
| 820 |
+
have hzle : z ≤ r := le_csSup hS_bdd hzS
|
| 821 |
+
exact (not_lt_of_ge hzle) hz.1
|
| 822 |
+
have hdenr_nonneg : 0 ≤ 1 - c * r := by
|
| 823 |
+
by_contra hnot
|
| 824 |
+
have hneg : 1 - c * r < 0 := lt_of_not_ge hnot
|
| 825 |
+
have hcpos : 0 < c := by nlinarith [hrpos]
|
| 826 |
+
let x : ℝ := (r + 1 / c) / 2
|
| 827 |
+
have hinv_lt_r : 1 / c < r := by
|
| 828 |
+
field_simp [hcpos.ne']
|
| 829 |
+
nlinarith
|
| 830 |
+
have hx0 : 0 < x := by
|
| 831 |
+
dsimp [x]
|
| 832 |
+
positivity
|
| 833 |
+
have hxr : x < r := by dsimp [x]; linarith
|
| 834 |
+
have hxdenneg : 1 - c * x < 0 := by
|
| 835 |
+
dsimp [x]
|
| 836 |
+
field_simp [hcpos.ne']
|
| 837 |
+
nlinarith
|
| 838 |
+
have hxdenpos := hden_left x hx0 hxr
|
| 839 |
+
linarith
|
| 840 |
+
have hdenr_notpos : ¬ 0 < 1 - c * r := by
|
| 841 |
+
intro hdenrpos
|
| 842 |
+
exact putnam_1962_a2_no_stop_before_pole (f := f) (a := f 0) (c := c)
|
| 843 |
+
(e := r + 1) (r := r) ha hrpos (by linarith) hden_left hleft
|
| 844 |
+
(fun x hrx hxlt => hzero_of_r_le x hrx) hdenrpos
|
| 845 |
+
(fun x hx => hfdata.2 x hx.1)
|
| 846 |
+
have hdenr_eq : 1 - c * r = 0 := le_antisymm (le_of_not_gt hdenr_notpos) hdenr_nonneg
|
| 847 |
+
have hcr : c * r = 1 := by nlinarith
|
| 848 |
+
have hcpos : 0 < c := by nlinarith [hrpos, hcr]
|
| 849 |
+
have hr_eq : r = 1 / c := by
|
| 850 |
+
field_simp [hcpos.ne']
|
| 851 |
+
nlinarith
|
| 852 |
+
refine ⟨(fun x : ℝ => if x < 1 / c then f 0 / (1 - c * x) ^ 2 else 0), ?_, ?_⟩
|
| 853 |
+
· right; left
|
| 854 |
+
exact ⟨f 0, c, ha.le, hcpos, rfl⟩
|
| 855 |
+
· intro x hx
|
| 856 |
+
rcases eq_or_lt_of_le (show (0 : ℝ) ≤ x by simpa using hx) with rfl | hx0
|
| 857 |
+
· have h0cut : (0 : ℝ) < 1 / c := one_div_pos.mpr hcpos
|
| 858 |
+
change f 0 = (if (0 : ℝ) < 1 / c then f 0 / (1 - c * 0) ^ 2 else 0)
|
| 859 |
+
rw [if_pos h0cut]
|
| 860 |
+
ring
|
| 861 |
+
· by_cases hxr : x < r
|
| 862 |
+
· have hxcut : x < 1 / c := by rwa [← hr_eq]
|
| 863 |
+
change f x = (if x < 1 / c then f 0 / (1 - c * x) ^ 2 else 0)
|
| 864 |
+
rw [if_pos hxcut]
|
| 865 |
+
exact hleft x hx0 hxr
|
| 866 |
+
· have hrx : r ≤ x := le_of_not_gt hxr
|
| 867 |
+
have hxcut : ¬ x < 1 / c := by rwa [← hr_eq]
|
| 868 |
+
change f x = (if x < 1 / c then f 0 / (1 - c * x) ^ 2 else 0)
|
| 869 |
+
rw [if_neg hxcut, hzero_of_r_le x hrx]
|
| 870 |
+
· refine ⟨(fun x : ℝ => f 0 / (1 - c * x) ^ 2), ?_, ?_⟩
|
| 871 |
+
· left
|
| 872 |
+
exact ⟨f 0, c, ha.le, rfl⟩
|
| 873 |
+
· intro x hx
|
| 874 |
+
rcases eq_or_lt_of_le (show (0 : ℝ) ≤ x by simpa using hx) with rfl | hx0
|
| 875 |
+
· ring
|
| 876 |
+
· have hnot_bound : ¬ ∀ z ∈ S, z ≤ max x y0 := by
|
| 877 |
+
intro hb
|
| 878 |
+
exact hS_bdd ⟨max x y0, hb⟩
|
| 879 |
+
push_neg at hnot_bound
|
| 880 |
+
rcases hnot_bound with ⟨z, hzS, hzgt⟩
|
| 881 |
+
have hxz : x < z := lt_of_le_of_lt (le_max_left x y0) hzgt
|
| 882 |
+
have hfx : f x ≠ 0 := hne_of_lt_ne_global x z hx0 hxz hzS.2
|
| 883 |
+
exact (hformula_ne x hx0 hfx).2
|
| 884 |
+
· refine ⟨(fun x : ℝ => if x = 0 then f 0 else 0), ?_, ?_⟩
|
| 885 |
+
· exact putnam_1962_a2_point_zero_branch_mem (f 0) (hfdata.1 0)
|
| 886 |
+
· intro x hx
|
| 887 |
+
rcases eq_or_lt_of_le (show (0 : ℝ) ≤ x by simpa using hx) with rfl | hxpos
|
| 888 |
+
· simp
|
| 889 |
+
· have hfx : f x = 0 := by
|
| 890 |
+
by_contra hne
|
| 891 |
+
exact hpos ⟨x, hxpos, hne⟩
|
| 892 |
+
simp [hxpos.ne', hfx]
|
| 893 |
+
· intro e he hf
|
| 894 |
+
by_cases h0 : f 0 = 0
|
| 895 |
+
· refine ⟨f, ?_, ?_⟩
|
| 896 |
+
· right; right; right
|
| 897 |
+
refine ⟨e, he, h0, ((P_def (Ioo 0 e) f).mp hf).1, ?_⟩
|
| 898 |
+
intro x hx
|
| 899 |
+
have h := ((P_def (Ioo 0 e) f).mp hf).2 x hx
|
| 900 |
+
simpa [h0] using h
|
| 901 |
+
· intro x hx
|
| 902 |
+
rfl
|
| 903 |
+
· have hfdata := ((P_def (Ioo 0 e) f).mp hf)
|
| 904 |
+
by_cases hpos : ∃ x ∈ Ioo (0 : ℝ) e, f x �� 0
|
| 905 |
+
· have ha : 0 < f 0 := lt_of_le_of_ne (hfdata.1 0) (Ne.symm h0)
|
| 906 |
+
rcases hpos with ⟨x1, hx1, hfx1⟩
|
| 907 |
+
rcases putnam_1962_a2_exists_ne_before (f := f) (a := f 0) (b := e)
|
| 908 |
+
ha hx1 hfdata.1 hfdata.2 hfx1 with ⟨p, hp0, hpx1, hfp⟩
|
| 909 |
+
let u1 : ℝ := (x1 + e) / 2
|
| 910 |
+
have hx1u1 : x1 < u1 := by dsimp [u1]; linarith [hx1.2]
|
| 911 |
+
have hu1e : u1 < e := by dsimp [u1]; linarith [hx1.2]
|
| 912 |
+
rcases putnam_1962_a2_exists_ne_between_right (f := f) (a := f 0) (b := e)
|
| 913 |
+
ha hx1 hx1u1 hu1e hfdata.1 hfdata.2 hfx1 with ⟨y0, hy0, hfy0⟩
|
| 914 |
+
have hy0e : y0 < e := lt_trans hy0.2 hu1e
|
| 915 |
+
have hpy0 : p < y0 := lt_trans hpx1 hy0.1
|
| 916 |
+
let F : ℝ → ℝ := fun x => ∫ t in (0 : ℝ)..x, f t
|
| 917 |
+
let c : ℝ := f 0 * ((f 0 * p)⁻¹ - (F p)⁻¹)
|
| 918 |
+
have hformula_ne :
|
| 919 |
+
∀ x ∈ Ioo (0 : ℝ) e, f x ≠ 0 →
|
| 920 |
+
0 < 1 - c * x ∧ f x = f 0 / (1 - c * x) ^ 2 := by
|
| 921 |
+
simpa [F, c] using
|
| 922 |
+
putnam_1962_a2_formula_of_ne_in_interval (f := f) (a := f 0) (b := e)
|
| 923 |
+
(p := p) (y0 := y0) ha hp0 hpy0 hy0e hfp hfy0 hfdata.1 hfdata.2
|
| 924 |
+
let S : Set ℝ := {x | x ∈ Ioo (0 : ℝ) e ∧ f x ≠ 0}
|
| 925 |
+
have hS_nonempty : S.Nonempty := ⟨y0, ⟨⟨lt_trans hx1.1 hy0.1, hy0e⟩, hfy0⟩⟩
|
| 926 |
+
have hS_bdd : BddAbove S := ⟨e, by intro x hx; exact hx.1.2.le⟩
|
| 927 |
+
let r : ℝ := sSup S
|
| 928 |
+
have hy0_le_r : y0 ≤ r := le_csSup hS_bdd ⟨⟨lt_trans hx1.1 hy0.1, hy0e⟩, hfy0⟩
|
| 929 |
+
have hrpos : 0 < r := lt_of_lt_of_le (lt_trans hx1.1 hy0.1) hy0_le_r
|
| 930 |
+
have hre_le : r ≤ e := csSup_le hS_nonempty (by intro x hx; exact hx.1.2.le)
|
| 931 |
+
have hne_of_lt_r : ∀ x : ℝ, 0 < x → x < r → f x ≠ 0 := by
|
| 932 |
+
intro x hx0 hxr
|
| 933 |
+
rcases exists_lt_of_lt_csSup hS_nonempty hxr with ⟨y, hyS, hxy⟩
|
| 934 |
+
exact putnam_1962_a2_ne_of_lt_ne (f := f) (a := f 0) (b := e)
|
| 935 |
+
ha hyS.1 hx0 hxy hfdata.1 hfdata.2 hyS.2
|
| 936 |
+
have hden_left : ∀ x : ℝ, 0 < x → x < r → 0 < 1 - c * x := by
|
| 937 |
+
intro x hx0 hxr
|
| 938 |
+
exact (hformula_ne x ⟨hx0, lt_of_lt_of_le hxr hre_le⟩
|
| 939 |
+
(hne_of_lt_r x hx0 hxr)).1
|
| 940 |
+
have hleft : ∀ x : ℝ, 0 < x → x < r → f x = f 0 / (1 - c * x) ^ 2 := by
|
| 941 |
+
intro x hx0 hxr
|
| 942 |
+
exact (hformula_ne x ⟨hx0, lt_of_lt_of_le hxr hre_le⟩
|
| 943 |
+
(hne_of_lt_r x hx0 hxr)).2
|
| 944 |
+
have hzero_of_r_lt : ∀ x : ℝ, r < x → x < e → f x = 0 := by
|
| 945 |
+
intro x hrx hxe
|
| 946 |
+
by_contra hfx
|
| 947 |
+
have hxS : x ∈ S := ⟨⟨lt_trans hrpos hrx, hxe⟩, hfx⟩
|
| 948 |
+
have hxle : x ≤ r := le_csSup hS_bdd hxS
|
| 949 |
+
linarith
|
| 950 |
+
have hzero_of_r_le : ∀ x : ℝ, r ≤ x → x < e → f x = 0 := by
|
| 951 |
+
intro x hrx hxe
|
| 952 |
+
rcases lt_or_eq_of_le hrx with hrx' | rfl
|
| 953 |
+
· exact hzero_of_r_lt x hrx' hxe
|
| 954 |
+
· by_contra hfr
|
| 955 |
+
let u : ℝ := (r + e) / 2
|
| 956 |
+
have hru : r < u := by dsimp [u]; linarith
|
| 957 |
+
have hue : u < e := by dsimp [u]; linarith
|
| 958 |
+
rcases putnam_1962_a2_exists_ne_between_right (f := f) (a := f 0) (b := e)
|
| 959 |
+
ha ⟨hrpos, hxe⟩ hru hue hfdata.1 hfdata.2 hfr with ⟨z, hz, hfz⟩
|
| 960 |
+
have hzS : z ∈ S := ⟨⟨lt_trans hrpos hz.1, lt_trans hz.2 hue⟩, hfz⟩
|
| 961 |
+
have hzle : z ≤ r := le_csSup hS_bdd hzS
|
| 962 |
+
exact (not_lt_of_ge hzle) hz.1
|
| 963 |
+
have hdenr_nonneg : 0 ≤ 1 - c * r := by
|
| 964 |
+
by_contra hnot
|
| 965 |
+
have hneg : 1 - c * r < 0 := lt_of_not_ge hnot
|
| 966 |
+
have hcpos : 0 < c := by nlinarith [hrpos]
|
| 967 |
+
let x : ℝ := (r + 1 / c) / 2
|
| 968 |
+
have hinv_lt_r : 1 / c < r := by
|
| 969 |
+
field_simp [hcpos.ne']
|
| 970 |
+
nlinarith
|
| 971 |
+
have hx0 : 0 < x := by
|
| 972 |
+
dsimp [x]
|
| 973 |
+
positivity
|
| 974 |
+
have hxr : x < r := by dsimp [x]; linarith
|
| 975 |
+
have hxdenneg : 1 - c * x < 0 := by
|
| 976 |
+
dsimp [x]
|
| 977 |
+
field_simp [hcpos.ne']
|
| 978 |
+
nlinarith
|
| 979 |
+
have hxdenpos := hden_left x hx0 hxr
|
| 980 |
+
linarith
|
| 981 |
+
by_cases hre : r < e
|
| 982 |
+
· have hdenr_notpos : ¬ 0 < 1 - c * r := by
|
| 983 |
+
intro hdenrpos
|
| 984 |
+
exact putnam_1962_a2_no_stop_before_pole (f := f) (a := f 0) (c := c)
|
| 985 |
+
(e := e) (r := r) ha hrpos hre hden_left hleft hzero_of_r_le hdenrpos
|
| 986 |
+
hfdata.2
|
| 987 |
+
have hdenr_eq : 1 - c * r = 0 := le_antisymm (le_of_not_gt hdenr_notpos) hdenr_nonneg
|
| 988 |
+
have hcr : c * r = 1 := by nlinarith
|
| 989 |
+
have hcpos : 0 < c := by nlinarith [hrpos, hcr]
|
| 990 |
+
have hr_eq : r = 1 / c := by
|
| 991 |
+
field_simp [hcpos.ne']
|
| 992 |
+
nlinarith
|
| 993 |
+
refine ⟨(fun x : ℝ => if x < 1 / c then f 0 / (1 - c * x) ^ 2 else 0), ?_, ?_⟩
|
| 994 |
+
· right; left
|
| 995 |
+
exact ⟨f 0, c, ha.le, hcpos, rfl⟩
|
| 996 |
+
· intro x hx
|
| 997 |
+
rcases eq_or_lt_of_le hx.1 with rfl | hx0
|
| 998 |
+
· have h0cut : (0 : ℝ) < 1 / c := one_div_pos.mpr hcpos
|
| 999 |
+
change f 0 = (if (0 : ℝ) < 1 / c then f 0 / (1 - c * 0) ^ 2 else 0)
|
| 1000 |
+
rw [if_pos h0cut]
|
| 1001 |
+
ring
|
| 1002 |
+
· by_cases hxr : x < r
|
| 1003 |
+
· have hxcut : x < 1 / c := by rwa [← hr_eq]
|
| 1004 |
+
change f x = (if x < 1 / c then f 0 / (1 - c * x) ^ 2 else 0)
|
| 1005 |
+
rw [if_pos hxcut]
|
| 1006 |
+
exact hleft x hx0 hxr
|
| 1007 |
+
· have hrx : r ≤ x := le_of_not_gt hxr
|
| 1008 |
+
have hxcut : ¬ x < 1 / c := by rwa [← hr_eq]
|
| 1009 |
+
change f x = (if x < 1 / c then f 0 / (1 - c * x) ^ 2 else 0)
|
| 1010 |
+
rw [if_neg hxcut, hzero_of_r_le x hrx hx.2]
|
| 1011 |
+
· have hre_eq : r = e := le_antisymm hre_le (le_of_not_gt hre)
|
| 1012 |
+
refine ⟨(fun x : ℝ => f 0 / (1 - c * x) ^ 2), ?_, ?_⟩
|
| 1013 |
+
· left
|
| 1014 |
+
exact ⟨f 0, c, ha.le, rfl⟩
|
| 1015 |
+
· intro x hx
|
| 1016 |
+
rcases eq_or_lt_of_le hx.1 with rfl | hx0
|
| 1017 |
+
· ring
|
| 1018 |
+
· have hxr : x < r := by
|
| 1019 |
+
rw [hre_eq]
|
| 1020 |
+
exact hx.2
|
| 1021 |
+
exact hleft x hx0 hxr
|
| 1022 |
+
· refine ⟨(fun x : ℝ => if x = 0 then f 0 else 0), ?_, ?_⟩
|
| 1023 |
+
· exact putnam_1962_a2_point_zero_branch_mem (f 0) (hfdata.1 0)
|
| 1024 |
+
· intro x hx
|
| 1025 |
+
rcases eq_or_lt_of_le hx.1 with rfl | hxpos
|
| 1026 |
+
· simp
|
| 1027 |
+
· have hfx : f x = 0 := by
|
| 1028 |
+
by_contra hne
|
| 1029 |
+
exact hpos ⟨x, ⟨hxpos, hx.2⟩, hne⟩
|
| 1030 |
+
simp [hxpos.ne', hfx]
|
| 1031 |
+
· intro f hf
|
| 1032 |
+
rcases hf with hrat | hcut | hzero | hfourth
|
| 1033 |
+
· rcases hrat with ⟨a, c, ha, rfl⟩
|
| 1034 |
+
right
|
| 1035 |
+
by_cases hc : 0 < c
|
| 1036 |
+
· refine ⟨1 / (2 * c), by positivity, ?_⟩
|
| 1037 |
+
refine putnam_1962_a2_rational_P P P_def ha ?_
|
| 1038 |
+
intro x hx
|
| 1039 |
+
have hcx : c * x < c * (1 / (2 * c)) := mul_lt_mul_of_pos_left hx.2 hc
|
| 1040 |
+
have hcne : c ≠ 0 := ne_of_gt hc
|
| 1041 |
+
have hcval : c * (1 / (2 * c)) = 1 / 2 := by
|
| 1042 |
+
field_simp [hcne]
|
| 1043 |
+
nlinarith
|
| 1044 |
+
· refine ⟨1, zero_lt_one, ?_⟩
|
| 1045 |
+
refine putnam_1962_a2_rational_P P P_def ha ?_
|
| 1046 |
+
intro x hx
|
| 1047 |
+
have hc_le : c ≤ 0 := le_of_not_gt hc
|
| 1048 |
+
have hcx_nonpos : c * x ≤ 0 := mul_nonpos_of_nonpos_of_nonneg hc_le hx.1.le
|
| 1049 |
+
nlinarith
|
| 1050 |
+
· rcases hcut with ⟨a, c, ha, hc, rfl⟩
|
| 1051 |
+
right
|
| 1052 |
+
refine ⟨1 / (2 * c), by positivity, ?_⟩
|
| 1053 |
+
refine putnam_1962_a2_cutoff_P P P_def ha hc ?_ ?_
|
| 1054 |
+
· have hcne : c ≠ 0 := ne_of_gt hc
|
| 1055 |
+
field_simp [hcne]
|
| 1056 |
+
nlinarith
|
| 1057 |
+
· intro x hx
|
| 1058 |
+
have hcx : c * x < c * (1 / (2 * c)) := mul_lt_mul_of_pos_left hx.2 hc
|
| 1059 |
+
have hcne : c ≠ 0 := ne_of_gt hc
|
| 1060 |
+
have hcval : c * (1 / (2 * c)) = 1 / 2 := by
|
| 1061 |
+
field_simp [hcne]
|
| 1062 |
+
nlinarith
|
| 1063 |
+
· rcases hzero with ⟨hf_nonneg, hfzero⟩
|
| 1064 |
+
left
|
| 1065 |
+
exact putnam_1962_a2_zero_on_pos_P P P_def hf_nonneg hfzero
|
| 1066 |
+
· rcases hfourth with ⟨e, he, h0, hf_nonneg, havg⟩
|
| 1067 |
+
right
|
| 1068 |
+
exact ⟨e, he, putnam_1962_a2_fourth_P P P_def h0 hf_nonneg havg⟩
|
Putnam-bench-verified/1962/Putnam1962A3.lean
ADDED
|
@@ -0,0 +1,382 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
open MeasureTheory
|
| 4 |
+
|
| 5 |
+
set_option maxHeartbeats 1000000
|
| 6 |
+
|
| 7 |
+
private lemma lineMap_eq_of_mem_segment_dist_ratio
|
| 8 |
+
{x y z : EuclideanSpace ℝ (Fin 2)} {k : ℝ}
|
| 9 |
+
(hxz : x ≠ z) (hk : 0 < k)
|
| 10 |
+
(hyseg : y ∈ segment ℝ x z)
|
| 11 |
+
(hratio : dist z y / dist y x = k) :
|
| 12 |
+
y = AffineMap.lineMap x z (1 / (k + 1)) := by
|
| 13 |
+
rw [segment_eq_image_lineMap] at hyseg
|
| 14 |
+
rcases hyseg with ⟨t, ht, hty⟩
|
| 15 |
+
have ht0 : 0 ≤ t := ht.1
|
| 16 |
+
have ht1 : t ≤ 1 := ht.2
|
| 17 |
+
have hd : dist x z ≠ 0 := by
|
| 18 |
+
simpa [dist_eq_zero] using hxz
|
| 19 |
+
have hratio_dist : ‖1 - t‖ * dist x z / (‖t‖ * dist x z) = k := by
|
| 20 |
+
rw [← hty] at hratio
|
| 21 |
+
rwa [dist_right_lineMap, dist_lineMap_left] at hratio
|
| 22 |
+
have ht_ne : t ≠ 0 := by
|
| 23 |
+
intro ht_eq
|
| 24 |
+
rw [ht_eq] at hratio_dist
|
| 25 |
+
simp at hratio_dist
|
| 26 |
+
linarith
|
| 27 |
+
have hratio' : (1 - t) / t = k := by
|
| 28 |
+
rw [Real.norm_of_nonneg (sub_nonneg.mpr ht1), Real.norm_of_nonneg ht0] at hratio_dist
|
| 29 |
+
field_simp [hd, ht_ne] at hratio_dist ⊢
|
| 30 |
+
linarith
|
| 31 |
+
have hk1 : k + 1 ≠ 0 := by linarith
|
| 32 |
+
have ht_eq : t = 1 / (k + 1) := by
|
| 33 |
+
have hlin : 1 - t = k * t := by
|
| 34 |
+
field_simp [ht_ne] at hratio'
|
| 35 |
+
linarith
|
| 36 |
+
rw [eq_div_iff hk1]
|
| 37 |
+
linarith
|
| 38 |
+
rw [← hty, ht_eq]
|
| 39 |
+
|
| 40 |
+
private lemma coord_eq_smul_coord_of_mem_segment
|
| 41 |
+
{b : AffineBasis (Fin 3) ℝ (EuclideanSpace ℝ (Fin 2))}
|
| 42 |
+
{x y p : EuclideanSpace ℝ (Fin 2)} {i j : Fin 3} {c : ℝ}
|
| 43 |
+
(hp : p ∈ segment ℝ x y)
|
| 44 |
+
(hx : b.coord i x = c * b.coord j x)
|
| 45 |
+
(hy : b.coord i y = c * b.coord j y) :
|
| 46 |
+
b.coord i p = c * b.coord j p := by
|
| 47 |
+
rw [segment_eq_image_lineMap] at hp
|
| 48 |
+
rcases hp with ⟨t, -, htp⟩
|
| 49 |
+
rw [← htp]
|
| 50 |
+
rw [(b.coord i).apply_lineMap x y t, (b.coord j).apply_lineMap x y t]
|
| 51 |
+
rw [hx, hy]
|
| 52 |
+
rw [AffineMap.lineMap_apply_ring, AffineMap.lineMap_apply_ring]
|
| 53 |
+
ring
|
| 54 |
+
|
| 55 |
+
private lemma bary_coords_of_relations {a b c k : ℝ}
|
| 56 |
+
(hk : 0 < k) (hsum : a + b + c = 1)
|
| 57 |
+
(ha : a = k * b) (hc : c = k * a) :
|
| 58 |
+
b = 1 / (k ^ 2 + k + 1) ∧
|
| 59 |
+
a = k / (k ^ 2 + k + 1) ∧
|
| 60 |
+
c = k ^ 2 / (k ^ 2 + k + 1) := by
|
| 61 |
+
let D := k ^ 2 + k + 1
|
| 62 |
+
have hDpos : 0 < D := by
|
| 63 |
+
nlinarith [sq_nonneg k]
|
| 64 |
+
have hDne : D ≠ 0 := hDpos.ne'
|
| 65 |
+
have hbD : D * b = 1 := by
|
| 66 |
+
dsimp [D]
|
| 67 |
+
nlinarith
|
| 68 |
+
have hb : b = 1 / D := by
|
| 69 |
+
rw [eq_div_iff hDne]
|
| 70 |
+
simpa [mul_comm] using hbD
|
| 71 |
+
have ha' : a = k / D := by
|
| 72 |
+
rw [ha, hb]
|
| 73 |
+
field_simp [hDne]
|
| 74 |
+
have hc' : c = k ^ 2 / D := by
|
| 75 |
+
rw [hc, ha']
|
| 76 |
+
field_simp [hDne]
|
| 77 |
+
exact ⟨by simpa [D] using hb, by simpa [D] using ha', by simpa [D] using hc'⟩
|
| 78 |
+
|
| 79 |
+
private lemma affineMap_image_eq_translate_linear_image
|
| 80 |
+
(f : EuclideanSpace ℝ (Fin 2) →ᵃ[ℝ] EuclideanSpace ℝ (Fin 2))
|
| 81 |
+
(s : Set (EuclideanSpace ℝ (Fin 2))) :
|
| 82 |
+
f '' s = (fun y => f 0 + y) '' (f.linear '' s) := by
|
| 83 |
+
ext y
|
| 84 |
+
constructor
|
| 85 |
+
· rintro ⟨x, hx, rfl⟩
|
| 86 |
+
refine ⟨f.linear x, ⟨x, hx, rfl⟩, ?_⟩
|
| 87 |
+
simpa [add_comm] using (f.map_vadd (0 : EuclideanSpace ℝ (Fin 2)) x).symm
|
| 88 |
+
· rintro ⟨_, ⟨x, hx, rfl⟩, hy⟩
|
| 89 |
+
refine ⟨x, hx, ?_⟩
|
| 90 |
+
rw [← hy]
|
| 91 |
+
simpa [add_comm] using (f.map_vadd (0 : EuclideanSpace ℝ (Fin 2)) x)
|
| 92 |
+
|
| 93 |
+
private def fin2EquivFin3NeZero : Fin 2 ≃ {j : Fin 3 // j ≠ 0} where
|
| 94 |
+
toFun
|
| 95 |
+
| 0 => ⟨1, by decide⟩
|
| 96 |
+
| 1 => ⟨2, by decide⟩
|
| 97 |
+
invFun j := if (j : Fin 3) = 1 then 0 else 1
|
| 98 |
+
left_inv i := by
|
| 99 |
+
fin_cases i <;> simp
|
| 100 |
+
right_inv j := by
|
| 101 |
+
rcases j with ⟨j, hj⟩
|
| 102 |
+
fin_cases j <;> simp at hj ⊢
|
| 103 |
+
|
| 104 |
+
/--
|
| 105 |
+
Let $\triangle ABC$ be a triangle in the Euclidean plane, with points $P$, $Q$, and $R$ lying on segments $\overline{BC}$, $\overline{CA}$, $\overline{AB}$ respectively such that $$\frac{AQ}{QC} = \frac{BR}{RA} = \frac{CP}{PB} = k$$ for some positive constant $k$. If $\triangle UVW$ is the triangle formed by parts of segments $\overline{AP}$, $\overline{BQ}$, and $\overline{CR}$, prove that $$\frac{[\triangle UVW]}{[\triangle ABC]} = \frac{(k - 1)^2}{k^2 + k + 1},$$ where $[\triangle]$ denotes the area of the triangle $\triangle$.
|
| 106 |
+
-/
|
| 107 |
+
theorem putnam_1962_a3
|
| 108 |
+
(A B C A' B' C' P Q R : EuclideanSpace ℝ (Fin 2))
|
| 109 |
+
(k : ℝ)
|
| 110 |
+
(hk : k > 0)
|
| 111 |
+
(hABC : ¬Collinear ℝ {A, B, C})
|
| 112 |
+
(hA' : A' ∈ segment ℝ B C ∧ dist C A' / dist A' B = k)
|
| 113 |
+
(hB' : B' ∈ segment ℝ C A ∧ dist A B' / dist B' C = k)
|
| 114 |
+
(hC' : C' ∈ segment ℝ A B ∧ dist B C' / dist C' A = k)
|
| 115 |
+
(hP : P ∈ segment ℝ B B' ∧ P ∈ segment ℝ C C')
|
| 116 |
+
(hQ : Q ∈ segment ℝ C C' ∧ Q ∈ segment ℝ A A')
|
| 117 |
+
(hR : R ∈ segment ℝ A A' ∧ R ∈ segment ℝ B B')
|
| 118 |
+
: (volume (convexHull ℝ {P, Q, R})).toReal / (volume (convexHull ℝ {A, B, C})).toReal = (k - 1)^2 / (k^2 + k + 1) :=
|
| 119 |
+
by
|
| 120 |
+
classical
|
| 121 |
+
let X : Fin 3 → EuclideanSpace ℝ (Fin 2) := ![A, B, C]
|
| 122 |
+
have hAI : AffineIndependent ℝ X := by
|
| 123 |
+
simpa [X] using (affineIndependent_iff_not_collinear_set (k := ℝ)).2 hABC
|
| 124 |
+
have hcard : Fintype.card (Fin 3) = Module.finrank ℝ (EuclideanSpace ℝ (Fin 2)) + 1 := by
|
| 125 |
+
norm_num
|
| 126 |
+
have htop : affineSpan ℝ (Set.range X) = (⊤ : AffineSubspace ℝ (EuclideanSpace ℝ (Fin 2))) := by
|
| 127 |
+
exact (hAI.affineSpan_eq_top_iff_card_eq_finrank_add_one).2 hcard
|
| 128 |
+
let b : AffineBasis (Fin 3) ℝ (EuclideanSpace ℝ (Fin 2)) :=
|
| 129 |
+
{ toFun := X, ind' := hAI, tot' := htop }
|
| 130 |
+
have hcoordA (i : Fin 3) : b.coord i A = if i = 0 then 1 else 0 := by
|
| 131 |
+
simpa [b, X] using b.coord_apply i 0
|
| 132 |
+
have hcoordB (i : Fin 3) : b.coord i B = if i = 1 then 1 else 0 := by
|
| 133 |
+
simpa [b, X] using b.coord_apply i 1
|
| 134 |
+
have hcoordC (i : Fin 3) : b.coord i C = if i = 2 then 1 else 0 := by
|
| 135 |
+
simpa [b, X] using b.coord_apply i 2
|
| 136 |
+
have hAB : A ≠ B := ne₁₂_of_not_collinear hABC
|
| 137 |
+
have hAC : A ≠ C := ne₁₃_of_not_collinear hABC
|
| 138 |
+
have hBC : B ≠ C := ne₂₃_of_not_collinear hABC
|
| 139 |
+
have hk1 : k + 1 ≠ 0 := by linarith
|
| 140 |
+
have hAline : A' = AffineMap.lineMap B C (1 / (k + 1)) :=
|
| 141 |
+
lineMap_eq_of_mem_segment_dist_ratio hBC hk hA'.1 hA'.2
|
| 142 |
+
have hBline : B' = AffineMap.lineMap C A (1 / (k + 1)) :=
|
| 143 |
+
lineMap_eq_of_mem_segment_dist_ratio hAC.symm hk hB'.1 hB'.2
|
| 144 |
+
have hCline : C' = AffineMap.lineMap A B (1 / (k + 1)) :=
|
| 145 |
+
lineMap_eq_of_mem_segment_dist_ratio hAB hk hC'.1 hC'.2
|
| 146 |
+
have hArel : b.coord 1 A' = k * b.coord 2 A' := by
|
| 147 |
+
rw [hAline]
|
| 148 |
+
rw [(b.coord 1).apply_lineMap B C (1 / (k + 1)),
|
| 149 |
+
(b.coord 2).apply_lineMap B C (1 / (k + 1))]
|
| 150 |
+
simp [hcoordB, hcoordC, AffineMap.lineMap_apply_ring]
|
| 151 |
+
field_simp [hk1]
|
| 152 |
+
ring
|
| 153 |
+
have hBrel : b.coord 2 B' = k * b.coord 0 B' := by
|
| 154 |
+
rw [hBline]
|
| 155 |
+
rw [(b.coord 2).apply_lineMap C A (1 / (k + 1)),
|
| 156 |
+
(b.coord 0).apply_lineMap C A (1 / (k + 1))]
|
| 157 |
+
simp [hcoordC, hcoordA, AffineMap.lineMap_apply_ring]
|
| 158 |
+
field_simp [hk1]
|
| 159 |
+
ring
|
| 160 |
+
have hCrel : b.coord 0 C' = k * b.coord 1 C' := by
|
| 161 |
+
rw [hCline]
|
| 162 |
+
rw [(b.coord 0).apply_lineMap A B (1 / (k + 1)),
|
| 163 |
+
(b.coord 1).apply_lineMap A B (1 / (k + 1))]
|
| 164 |
+
simp [hcoordA, hcoordB, AffineMap.lineMap_apply_ring]
|
| 165 |
+
field_simp [hk1]
|
| 166 |
+
ring
|
| 167 |
+
have hP20 : b.coord 2 P = k * b.coord 0 P :=
|
| 168 |
+
coord_eq_smul_coord_of_mem_segment (b := b) hP.1 (by simp [hcoordB]) hBrel
|
| 169 |
+
have hP01 : b.coord 0 P = k * b.coord 1 P :=
|
| 170 |
+
coord_eq_smul_coord_of_mem_segment (b := b) hP.2 (by simp [hcoordC]) hCrel
|
| 171 |
+
have hQ01 : b.coord 0 Q = k * b.coord 1 Q :=
|
| 172 |
+
coord_eq_smul_coord_of_mem_segment (b := b) hQ.1 (by simp [hcoordC]) hCrel
|
| 173 |
+
have hQ12 : b.coord 1 Q = k * b.coord 2 Q :=
|
| 174 |
+
coord_eq_smul_coord_of_mem_segment (b := b) hQ.2 (by simp [hcoordA]) hArel
|
| 175 |
+
have hR12 : b.coord 1 R = k * b.coord 2 R :=
|
| 176 |
+
coord_eq_smul_coord_of_mem_segment (b := b) hR.1 (by simp [hcoordA]) hArel
|
| 177 |
+
have hR20 : b.coord 2 R = k * b.coord 0 R :=
|
| 178 |
+
coord_eq_smul_coord_of_mem_segment (b := b) hR.2 (by simp [hcoordB]) hBrel
|
| 179 |
+
have hcoord_sum (x : EuclideanSpace ℝ (Fin 2)) :
|
| 180 |
+
b.coord 0 x + b.coord 1 x + b.coord 2 x = 1 := by
|
| 181 |
+
have hsum := b.sum_coord_apply_eq_one x
|
| 182 |
+
rw [Fin.sum_univ_three] at hsum
|
| 183 |
+
exact hsum
|
| 184 |
+
have hPcoords := bary_coords_of_relations hk (hcoord_sum P) hP01 hP20
|
| 185 |
+
have hQcoords := bary_coords_of_relations hk
|
| 186 |
+
(a := b.coord 1 Q) (b := b.coord 2 Q) (c := b.coord 0 Q)
|
| 187 |
+
(by linarith [hcoord_sum Q])
|
| 188 |
+
hQ12 hQ01
|
| 189 |
+
have hRcoords := bary_coords_of_relations hk
|
| 190 |
+
(a := b.coord 2 R) (b := b.coord 0 R) (c := b.coord 1 R)
|
| 191 |
+
(by linarith [hcoord_sum R])
|
| 192 |
+
hR20 hR12
|
| 193 |
+
let Y : Fin 3 → EuclideanSpace ℝ (Fin 2) := ![P, Q, R]
|
| 194 |
+
let F : EuclideanSpace ℝ (Fin 2) →ᵃ[ℝ] EuclideanSpace ℝ (Fin 2) :=
|
| 195 |
+
(Finset.univ.affineCombination ℝ Y).comp b.coords
|
| 196 |
+
have hFA : F A = P := by
|
| 197 |
+
simp [F, Y, hcoordA]
|
| 198 |
+
have hFB : F B = Q := by
|
| 199 |
+
simp [F, Y, hcoordB]
|
| 200 |
+
have hFC : F C = R := by
|
| 201 |
+
simp [F, Y, hcoordC]
|
| 202 |
+
have hFverts :
|
| 203 |
+
F '' ({A, B, C} : Set (EuclideanSpace ℝ (Fin 2))) =
|
| 204 |
+
({P, Q, R} : Set (EuclideanSpace ℝ (Fin 2))) := by
|
| 205 |
+
ext x
|
| 206 |
+
constructor
|
| 207 |
+
· rintro ⟨y, hy, rfl⟩
|
| 208 |
+
simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hy ⊢
|
| 209 |
+
rcases hy with rfl | rfl | rfl <;> simp [hFA, hFB, hFC]
|
| 210 |
+
· intro hx
|
| 211 |
+
simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hx
|
| 212 |
+
rcases hx with rfl | rfl | rfl
|
| 213 |
+
· exact ⟨A, by simp, hFA⟩
|
| 214 |
+
· exact ⟨B, by simp, hFB⟩
|
| 215 |
+
· exact ⟨C, by simp, hFC⟩
|
| 216 |
+
have hHullImage :
|
| 217 |
+
(convexHull ℝ ({P, Q, R} : Set (EuclideanSpace ℝ (Fin 2)))) =
|
| 218 |
+
F '' (convexHull ℝ ({A, B, C} : Set (EuclideanSpace ℝ (Fin 2)))) := by
|
| 219 |
+
rw [← hFverts, ← F.image_convexHull]
|
| 220 |
+
have hmeasure_image (s : Set (EuclideanSpace ℝ (Fin 2))) :
|
| 221 |
+
volume (F '' s) = ENNReal.ofReal |LinearMap.det F.linear| * volume s := by
|
| 222 |
+
rw [affineMap_image_eq_translate_linear_image F s]
|
| 223 |
+
rw [Set.image_add_left]
|
| 224 |
+
rw [MeasureTheory.measure_preimage_add]
|
| 225 |
+
exact MeasureTheory.Measure.addHaar_image_linearMap volume F.linear s
|
| 226 |
+
have hvol :
|
| 227 |
+
volume (convexHull ℝ ({P, Q, R} : Set (EuclideanSpace ℝ (Fin 2)))) =
|
| 228 |
+
ENNReal.ofReal |LinearMap.det F.linear| *
|
| 229 |
+
volume (convexHull ℝ ({A, B, C} : Set (EuclideanSpace ℝ (Fin 2)))) := by
|
| 230 |
+
rw [hHullImage]
|
| 231 |
+
exact hmeasure_image _
|
| 232 |
+
have hDpos : 0 < k ^ 2 + k + 1 := by
|
| 233 |
+
nlinarith [sq_nonneg k]
|
| 234 |
+
have hDne : k ^ 2 + k + 1 ≠ 0 := hDpos.ne'
|
| 235 |
+
let e : Module.Basis (Fin 2) ℝ (EuclideanSpace ℝ (Fin 2)) :=
|
| 236 |
+
(b.basisOf 0).reindex fin2EquivFin3NeZero.symm
|
| 237 |
+
have he0 : e 0 = B -ᵥ A := by
|
| 238 |
+
rw [Module.Basis.reindex_apply, AffineBasis.basisOf_apply]
|
| 239 |
+
change X 1 -ᵥ X 0 = B -ᵥ A
|
| 240 |
+
simp [X]
|
| 241 |
+
have he1 : e 1 = C -ᵥ A := by
|
| 242 |
+
rw [Module.Basis.reindex_apply, AffineBasis.basisOf_apply]
|
| 243 |
+
change X 2 -ᵥ X 0 = C -ᵥ A
|
| 244 |
+
simp [X]
|
| 245 |
+
have hvector_from_A (x : EuclideanSpace ℝ (Fin 2)) :
|
| 246 |
+
x -ᵥ A = b.coord 1 x • (B -ᵥ A) + b.coord 2 x • (C -ᵥ A) := by
|
| 247 |
+
have hx : b.coord 0 x • A + b.coord 1 x • B + b.coord 2 x • C = x := by
|
| 248 |
+
have h := b.linear_combination_coord_eq_self x
|
| 249 |
+
rw [Fin.sum_univ_three] at h
|
| 250 |
+
simpa [b, X] using h
|
| 251 |
+
have hsum : b.coord 0 x + b.coord 1 x + b.coord 2 x = 1 := hcoord_sum x
|
| 252 |
+
calc
|
| 253 |
+
x -ᵥ A =
|
| 254 |
+
(b.coord 0 x • A + b.coord 1 x • B + b.coord 2 x • C) -ᵥ A := by
|
| 255 |
+
exact (congrArg (fun y => y -ᵥ A) hx).symm
|
| 256 |
+
_ = b.coord 1 x • (B -ᵥ A) + b.coord 2 x • (C -ᵥ A) := by
|
| 257 |
+
have h0 : b.coord 0 x = 1 - b.coord 1 x - b.coord 2 x := by
|
| 258 |
+
linarith
|
| 259 |
+
rw [vsub_eq_sub, vsub_eq_sub, vsub_eq_sub, h0]
|
| 260 |
+
module
|
| 261 |
+
have hQPvec :
|
| 262 |
+
Q -ᵥ P =
|
| 263 |
+
(b.coord 1 Q - b.coord 1 P) • e 0 + (b.coord 2 Q - b.coord 2 P) • e 1 := by
|
| 264 |
+
calc
|
| 265 |
+
Q -ᵥ P = (Q -ᵥ A) - (P -ᵥ A) := by
|
| 266 |
+
rw [vsub_eq_sub, vsub_eq_sub, vsub_eq_sub]
|
| 267 |
+
abel
|
| 268 |
+
_ = (b.coord 1 Q - b.coord 1 P) • e 0 +
|
| 269 |
+
(b.coord 2 Q - b.coord 2 P) • e 1 := by
|
| 270 |
+
rw [hvector_from_A Q, hvector_from_A P, ← he0, ← he1]
|
| 271 |
+
module
|
| 272 |
+
have hRPvec :
|
| 273 |
+
R -ᵥ P =
|
| 274 |
+
(b.coord 1 R - b.coord 1 P) • e 0 + (b.coord 2 R - b.coord 2 P) • e 1 := by
|
| 275 |
+
calc
|
| 276 |
+
R -ᵥ P = (R -ᵥ A) - (P -ᵥ A) := by
|
| 277 |
+
rw [vsub_eq_sub, vsub_eq_sub, vsub_eq_sub]
|
| 278 |
+
abel
|
| 279 |
+
_ = (b.coord 1 R - b.coord 1 P) • e 0 +
|
| 280 |
+
(b.coord 2 R - b.coord 2 P) • e 1 := by
|
| 281 |
+
rw [hvector_from_A R, hvector_from_A P, ← he0, ← he1]
|
| 282 |
+
module
|
| 283 |
+
have hFe0 : F.linear (e 0) = Q -ᵥ P := by
|
| 284 |
+
rw [he0, F.linearMap_vsub, hFB, hFA]
|
| 285 |
+
have hFe1 : F.linear (e 1) = R -ᵥ P := by
|
| 286 |
+
rw [he1, F.linearMap_vsub, hFC, hFA]
|
| 287 |
+
have hm00 : LinearMap.toMatrix e e F.linear 0 0 = (k - 1) / (k ^ 2 + k + 1) := by
|
| 288 |
+
rw [LinearMap.toMatrix_apply, hFe0, hQPvec]
|
| 289 |
+
rw [map_add, map_smul, map_smul]
|
| 290 |
+
change (b.coord 1 Q - b.coord 1 P) * e.repr (e 0) 0 +
|
| 291 |
+
(b.coord 2 Q - b.coord 2 P) * e.repr (e 1) 0 = (k - 1) / (k ^ 2 + k + 1)
|
| 292 |
+
norm_num [e.repr_self_apply]
|
| 293 |
+
ring_nf
|
| 294 |
+
rw [hQcoords.2.1, hPcoords.1]
|
| 295 |
+
field_simp [hDne]
|
| 296 |
+
ring
|
| 297 |
+
have hm10 : LinearMap.toMatrix e e F.linear 1 0 = (1 - k ^ 2) / (k ^ 2 + k + 1) := by
|
| 298 |
+
rw [LinearMap.toMatrix_apply, hFe0, hQPvec]
|
| 299 |
+
rw [map_add, map_smul, map_smul]
|
| 300 |
+
change (b.coord 1 Q - b.coord 1 P) * e.repr (e 0) 1 +
|
| 301 |
+
(b.coord 2 Q - b.coord 2 P) * e.repr (e 1) 1 = (1 - k ^ 2) / (k ^ 2 + k + 1)
|
| 302 |
+
norm_num [e.repr_self_apply]
|
| 303 |
+
ring_nf
|
| 304 |
+
rw [hQcoords.1, hPcoords.2.2]
|
| 305 |
+
field_simp [hDne]
|
| 306 |
+
ring
|
| 307 |
+
have hm01 : LinearMap.toMatrix e e F.linear 0 1 = (k ^ 2 - 1) / (k ^ 2 + k + 1) := by
|
| 308 |
+
rw [LinearMap.toMatrix_apply, hFe1, hRPvec]
|
| 309 |
+
rw [map_add, map_smul, map_smul]
|
| 310 |
+
change (b.coord 1 R - b.coord 1 P) * e.repr (e 0) 0 +
|
| 311 |
+
(b.coord 2 R - b.coord 2 P) * e.repr (e 1) 0 = (k ^ 2 - 1) / (k ^ 2 + k + 1)
|
| 312 |
+
norm_num [e.repr_self_apply]
|
| 313 |
+
ring_nf
|
| 314 |
+
rw [hRcoords.2.2, hPcoords.1]
|
| 315 |
+
field_simp [hDne]
|
| 316 |
+
ring
|
| 317 |
+
have hm11 : LinearMap.toMatrix e e F.linear 1 1 = (k - k ^ 2) / (k ^ 2 + k + 1) := by
|
| 318 |
+
rw [LinearMap.toMatrix_apply, hFe1, hRPvec]
|
| 319 |
+
rw [map_add, map_smul, map_smul]
|
| 320 |
+
change (b.coord 1 R - b.coord 1 P) * e.repr (e 0) 1 +
|
| 321 |
+
(b.coord 2 R - b.coord 2 P) * e.repr (e 1) 1 = (k - k ^ 2) / (k ^ 2 + k + 1)
|
| 322 |
+
norm_num [e.repr_self_apply]
|
| 323 |
+
ring_nf
|
| 324 |
+
rw [hRcoords.2.1, hPcoords.2.2]
|
| 325 |
+
field_simp [hDne]
|
| 326 |
+
ring
|
| 327 |
+
have hdet : LinearMap.det F.linear = (k - 1) ^ 2 / (k ^ 2 + k + 1) := by
|
| 328 |
+
rw [← LinearMap.det_toMatrix e F.linear, Matrix.det_fin_two]
|
| 329 |
+
rw [hm00, hm01, hm10, hm11]
|
| 330 |
+
field_simp [hDne]
|
| 331 |
+
ring
|
| 332 |
+
have hdet_abs : |LinearMap.det F.linear| = (k - 1) ^ 2 / (k ^ 2 + k + 1) := by
|
| 333 |
+
rw [hdet]
|
| 334 |
+
exact abs_of_nonneg (div_nonneg (sq_nonneg _) hDpos.le)
|
| 335 |
+
have hXverts :
|
| 336 |
+
Set.range X = ({A, B, C} : Set (EuclideanSpace ℝ (Fin 2))) := by
|
| 337 |
+
ext x
|
| 338 |
+
constructor
|
| 339 |
+
· rintro ⟨i, rfl⟩
|
| 340 |
+
fin_cases i <;> simp [X]
|
| 341 |
+
· intro hx
|
| 342 |
+
simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hx
|
| 343 |
+
rcases hx with rfl | rfl | rfl
|
| 344 |
+
· exact ⟨0, by simp [X]⟩
|
| 345 |
+
· exact ⟨1, by simp [X]⟩
|
| 346 |
+
· exact ⟨2, by simp [X]⟩
|
| 347 |
+
have hspanABC :
|
| 348 |
+
affineSpan ℝ ({A, B, C} : Set (EuclideanSpace ℝ (Fin 2))) = ⊤ := by
|
| 349 |
+
rw [← hXverts]
|
| 350 |
+
exact htop
|
| 351 |
+
have hbase_interior :
|
| 352 |
+
(interior (convexHull ℝ ({A, B, C} : Set (EuclideanSpace ℝ (Fin 2))))).Nonempty := by
|
| 353 |
+
exact interior_convexHull_nonempty_iff_affineSpan_eq_top.mpr hspanABC
|
| 354 |
+
have hbase_pos :
|
| 355 |
+
0 < volume (convexHull ℝ ({A, B, C} : Set (EuclideanSpace ℝ (Fin 2)))) := by
|
| 356 |
+
exact Measure.measure_pos_of_nonempty_interior (μ := volume) hbase_interior
|
| 357 |
+
have hbase_ne_zero :
|
| 358 |
+
volume (convexHull ℝ ({A, B, C} : Set (EuclideanSpace ℝ (Fin 2)))) ≠ 0 :=
|
| 359 |
+
hbase_pos.ne'
|
| 360 |
+
have hbase_ne_top :
|
| 361 |
+
volume (convexHull ℝ ({A, B, C} : Set (EuclideanSpace ℝ (Fin 2)))) ≠ ⊤ := by
|
| 362 |
+
exact (by simp : ({A, B, C} : Set (EuclideanSpace ℝ (Fin 2))).Finite).isCompact_convexHull.measure_ne_top
|
| 363 |
+
have hbase_toReal_pos :
|
| 364 |
+
0 < (volume (convexHull ℝ ({A, B, C} : Set (EuclideanSpace ℝ (Fin 2))))).toReal :=
|
| 365 |
+
ENNReal.toReal_pos hbase_ne_zero hbase_ne_top
|
| 366 |
+
have hvol_toReal :
|
| 367 |
+
(volume (convexHull ℝ ({P, Q, R} : Set (EuclideanSpace ℝ (Fin 2))))).toReal =
|
| 368 |
+
((k - 1) ^ 2 / (k ^ 2 + k + 1)) *
|
| 369 |
+
(volume (convexHull ℝ ({A, B, C} : Set (EuclideanSpace ℝ (Fin 2))))).toReal := by
|
| 370 |
+
calc
|
| 371 |
+
(volume (convexHull ℝ ({P, Q, R} : Set (EuclideanSpace ℝ (Fin 2))))).toReal =
|
| 372 |
+
(ENNReal.ofReal |LinearMap.det F.linear| *
|
| 373 |
+
volume (convexHull ℝ ({A, B, C} : Set (EuclideanSpace ℝ (Fin 2))))).toReal := by
|
| 374 |
+
rw [hvol]
|
| 375 |
+
_ = |LinearMap.det F.linear| *
|
| 376 |
+
(volume (convexHull ℝ ({A, B, C} : Set (EuclideanSpace ℝ (Fin 2))))).toReal := by
|
| 377 |
+
rw [ENNReal.toReal_ofReal_mul (h := abs_nonneg (LinearMap.det F.linear))]
|
| 378 |
+
_ = ((k - 1) ^ 2 / (k ^ 2 + k + 1)) *
|
| 379 |
+
(volume (convexHull ℝ ({A, B, C} : Set (EuclideanSpace ℝ (Fin 2))))).toReal := by
|
| 380 |
+
rw [hdet_abs]
|
| 381 |
+
rw [hvol_toReal]
|
| 382 |
+
field_simp [hbase_toReal_pos.ne']
|
Putnam-bench-verified/1962/Putnam1962A4.lean
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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riv (deriv f) y| ≤ 1)
|
| 9 |
+
(hux : u ≤ x) (hxv : x ≤ v) (huv : v - u = 2) :
|
| 10 |
+
deriv f x ≤ 2 := by
|
| 11 |
+
have huv_le : u ≤ v := le_trans hux hxv
|
| 12 |
+
have hright_nonneg : 0 ≤ v - x := sub_nonneg.mpr hxv
|
| 13 |
+
have hleft_nonneg : 0 ≤ x - u := sub_nonneg.mpr hux
|
| 14 |
+
have hsum_len : (v - x) + (x - u) = 2 := by linarith
|
| 15 |
+
have hderivLowerRight : ∀ t ∈ Set.Icc x v, deriv f x - (t - x) ≤ deriv f t := by
|
| 16 |
+
intro t ht
|
| 17 |
+
have hge : ∀ y ∈ interior (Set.Icc x v), (-1 : ℝ) ≤ deriv (deriv f) y := by
|
| 18 |
+
intro y hy
|
| 19 |
+
have hyIoo : y ∈ Set.Ioo x v := by simpa [interior_Icc] using hy
|
| 20 |
+
have hyuv : y ∈ Set.Icc u v := ⟨le_trans hux hyIoo.1.le, hyIoo.2.le⟩
|
| 21 |
+
exact (abs_le.mp (hsec y hyuv)).1
|
| 22 |
+
have hmv := (convex_Icc x v).mul_sub_le_image_sub_of_le_deriv
|
| 23 |
+
hdf.continuous.continuousOn hdf.differentiableOn hge
|
| 24 |
+
x ⟨le_rfl, hxv⟩ t ht ht.1
|
| 25 |
+
nlinarith
|
| 26 |
+
let R : ℝ → ℝ := fun t => f t - (deriv f x * (t - x) - (t - x) ^ 2 / 2)
|
| 27 |
+
have hRcont : ContinuousOn R (Set.Icc x v) := by
|
| 28 |
+
dsimp [R]
|
| 29 |
+
exact hf.continuous.continuousOn.sub (by fun_prop)
|
| 30 |
+
have hRdiff : DifferentiableOn ℝ R (interior (Set.Icc x v)) := by
|
| 31 |
+
dsimp [R]
|
| 32 |
+
exact hf.differentiableOn.sub (by fun_prop)
|
| 33 |
+
have hRderiv_nonneg : ∀ t ∈ interior (Set.Icc x v), (0 : ℝ) ≤ deriv R t := by
|
| 34 |
+
intro t ht
|
| 35 |
+
have hlow := hderivLowerRight t (interior_subset ht)
|
| 36 |
+
have hpoly :
|
| 37 |
+
HasDerivAt (fun y : ℝ => deriv f x * (y - x) - (y - x) ^ 2 / 2)
|
| 38 |
+
(deriv f x - (t - x)) t := by
|
| 39 |
+
have hlin : HasDerivAt (fun y : ℝ => y - x) 1 t := (hasDerivAt_id t).sub_const x
|
| 40 |
+
have hterm1 : HasDerivAt (fun y : ℝ => deriv f x * (y - x)) (deriv f x) t := by
|
| 41 |
+
simpa using hlin.const_mul (deriv f x)
|
| 42 |
+
have hsq : HasDerivAt (fun y : ℝ => (y - x) ^ 2) (2 * (t - x)) t := by
|
| 43 |
+
simpa using hlin.pow 2
|
| 44 |
+
have hterm2 : HasDerivAt (fun y : ℝ => (y - x) ^ 2 / 2) (t - x) t := by
|
| 45 |
+
convert hsq.const_mul (1 / 2 : ℝ) using 1
|
| 46 |
+
· ext y
|
| 47 |
+
ring_nf
|
| 48 |
+
· ring
|
| 49 |
+
convert hterm1.sub hterm2 using 1
|
| 50 |
+
have hRderiv : deriv R t = deriv f t - (deriv f x - (t - x)) :=
|
| 51 |
+
((hf t).hasDerivAt.sub hpoly).deriv
|
| 52 |
+
rw [hRderiv]
|
| 53 |
+
linarith
|
| 54 |
+
have hRmv := (convex_Icc x v).mul_sub_le_image_sub_of_le_deriv
|
| 55 |
+
hRcont hRdiff hRderiv_nonneg x ⟨le_rfl, hxv⟩ v ⟨hxv, le_rfl⟩ hxv
|
| 56 |
+
have hright : deriv f x * (v - x) - (v - x) ^ 2 / 2 ≤ f v - f x := by
|
| 57 |
+
dsimp [R] at hRmv
|
| 58 |
+
nlinarith
|
| 59 |
+
have hderivLowerLeft : ∀ t ∈ Set.Icc u x, deriv f x - (x - t) ≤ deriv f t := by
|
| 60 |
+
intro t ht
|
| 61 |
+
have hle : ∀ y ∈ interior (Set.Icc t x), deriv (deriv f) y ≤ (1 : ℝ) := by
|
| 62 |
+
intro y hy
|
| 63 |
+
have hyIoo : y ∈ Set.Ioo t x := by simpa [interior_Icc] using hy
|
| 64 |
+
have hyuv : y ∈ Set.Icc u v := ⟨le_trans ht.1 hyIoo.1.le, le_trans hyIoo.2.le hxv⟩
|
| 65 |
+
exact (abs_le.mp (hsec y hyuv)).2
|
| 66 |
+
have hmv := (convex_Icc t x).image_sub_le_mul_sub_of_deriv_le
|
| 67 |
+
hdf.continuous.continuousOn hdf.differentiableOn hle
|
| 68 |
+
t ⟨le_rfl, ht.2⟩ x ⟨ht.2, le_rfl⟩ ht.2
|
| 69 |
+
nlinarith
|
| 70 |
+
let L : ℝ → ℝ := fun t => f t -
|
| 71 |
+
(deriv f x * (t - u) - ((x - u) ^ 2 - (x - t) ^ 2) / 2)
|
| 72 |
+
have hLcont : ContinuousOn L (Set.Icc u x) := by
|
| 73 |
+
dsimp [L]
|
| 74 |
+
exact hf.continuous.continuousOn.sub (by fun_prop)
|
| 75 |
+
have hLdiff : DifferentiableOn ℝ L (interior (Set.Icc u x)) := by
|
| 76 |
+
dsimp [L]
|
| 77 |
+
exact hf.differentiableOn.sub (by fun_prop)
|
| 78 |
+
have hLderiv_nonneg : ∀ t ∈ interior (Set.Icc u x), (0 : ℝ) ≤ deriv L t := by
|
| 79 |
+
intro t ht
|
| 80 |
+
have hlow := hderivLowerLeft t (interior_subset ht)
|
| 81 |
+
have hpoly :
|
| 82 |
+
HasDerivAt (fun y : ℝ =>
|
| 83 |
+
deriv f x * (y - u) - ((x - u) ^ 2 - (x - y) ^ 2) / 2)
|
| 84 |
+
(deriv f x - (x - t)) t := by
|
| 85 |
+
have hlin : HasDerivAt (fun y : ℝ => y - u) 1 t := (hasDerivAt_id t).sub_const u
|
| 86 |
+
have hterm1 : HasDerivAt (fun y : ℝ => deriv f x * (y - u)) (deriv f x) t := by
|
| 87 |
+
simpa using hlin.const_mul (deriv f x)
|
| 88 |
+
have hxmy : HasDerivAt (fun y : ℝ => x - y) (-1) t := by
|
| 89 |
+
simpa using (hasDerivAt_const t (x : ℝ)).sub (hasDerivAt_id t)
|
| 90 |
+
have hsq : HasDerivAt (fun y : ℝ => (x - y) ^ 2) (-2 * (x - t)) t := by
|
| 91 |
+
convert hxmy.pow 2 using 1
|
| 92 |
+
ring
|
| 93 |
+
have hterm2 :
|
| 94 |
+
HasDerivAt (fun y : ℝ => ((x - u) ^ 2 - (x - y) ^ 2) / 2) (x - t) t := by
|
| 95 |
+
have hconst : HasDerivAt (fun _ : ℝ => (x - u) ^ 2) 0 t := hasDerivAt_const _ _
|
| 96 |
+
convert (hconst.sub hsq).const_mul (1 / 2 : ℝ) using 1
|
| 97 |
+
· ext y
|
| 98 |
+
simp
|
| 99 |
+
ring_nf
|
| 100 |
+
· ring
|
| 101 |
+
convert hterm1.sub hterm2 using 1
|
| 102 |
+
have hLderiv : deriv L t = deriv f t - (deriv f x - (x - t)) :=
|
| 103 |
+
((hf t).hasDerivAt.sub hpoly).deriv
|
| 104 |
+
rw [hLderiv]
|
| 105 |
+
linarith
|
| 106 |
+
have hLmv := (convex_Icc u x).mul_sub_le_image_sub_of_le_deriv
|
| 107 |
+
hLcont hLdiff hLderiv_nonneg u ⟨le_rfl, hux⟩ x ⟨hux, le_rfl⟩ hux
|
| 108 |
+
have hleft : deriv f x * (x - u) - (x - u) ^ 2 / 2 ≤ f x - f u := by
|
| 109 |
+
dsimp [L] at hLmv
|
| 110 |
+
nlinarith
|
| 111 |
+
have hsum :
|
| 112 |
+
deriv f x * (v - u) - ((v - x) ^ 2 + (x - u) ^ 2) / 2 ≤ f v - f u := by
|
| 113 |
+
nlinarith
|
| 114 |
+
have hfun_diff_le : f v - f u ≤ 2 := by
|
| 115 |
+
have hvabs := hfabs v ⟨huv_le, le_rfl⟩
|
| 116 |
+
have huabs := hfabs u ⟨le_rfl, huv_le⟩
|
| 117 |
+
have hvle : f v ≤ 1 := (le_abs_self (f v)).trans hvabs
|
| 118 |
+
have hule : -f u ≤ 1 := (neg_le_abs (f u)).trans huabs
|
| 119 |
+
linarith
|
| 120 |
+
have hsquares : ((v - x) ^ 2 + (x - u) ^ 2) / 2 ≤ 2 := by
|
| 121 |
+
have hprod_nonneg : 0 ≤ (v - x) * (x - u) := mul_nonneg hright_nonneg hleft_nonneg
|
| 122 |
+
nlinarith
|
| 123 |
+
nlinarith
|
| 124 |
+
|
| 125 |
+
/--
|
| 126 |
+
Assume that $\lvert f(x) \rvert \le 1$ and $\lvert f''(x) \rvert \le 1$ for all $x$ on an interval of length at least 2. Show that $\lvert f'(x) \rvert \le 2$ on the interval.
|
| 127 |
+
-/
|
| 128 |
+
theorem putnam_1962_a4
|
| 129 |
+
(f : ℝ → ℝ)
|
| 130 |
+
(a b : ℝ)
|
| 131 |
+
(hdiff : Differentiable ℝ f ∧ (Differentiable ℝ (deriv f)))
|
| 132 |
+
(hfabs : ∀ x ∈ Set.Icc a b, |f x| ≤ 1)
|
| 133 |
+
(hfppabs : ∀ x ∈ Set.Icc a b, |(iteratedDeriv 2 f) x| ≤ 1)
|
| 134 |
+
(hlen2 : b - a ≥ 2)
|
| 135 |
+
: ∀ x ∈ Set.Icc a b, |(iteratedDeriv 1 f) x| ≤ 2 :=
|
| 136 |
+
by
|
| 137 |
+
intro x hx
|
| 138 |
+
let u : ℝ := max a (x - 2)
|
| 139 |
+
let v : ℝ := u + 2
|
| 140 |
+
have hf : Differentiable ℝ f := hdiff.1
|
| 141 |
+
have hdf : Differentiable ℝ (deriv f) := hdiff.2
|
| 142 |
+
have hux : u ≤ x := by
|
| 143 |
+
dsimp [u]
|
| 144 |
+
exact max_le hx.1 (by linarith)
|
| 145 |
+
have hxv : x ≤ v := by
|
| 146 |
+
dsimp [v, u]
|
| 147 |
+
have h : x - 2 ≤ max a (x - 2) := le_max_right a (x - 2)
|
| 148 |
+
linarith
|
| 149 |
+
have huv : v - u = 2 := by
|
| 150 |
+
dsimp [v]
|
| 151 |
+
ring
|
| 152 |
+
have ha_le_u : a ≤ u := by
|
| 153 |
+
dsimp [u]
|
| 154 |
+
exact le_max_left a (x - 2)
|
| 155 |
+
have hv_le_b : v ≤ b := by
|
| 156 |
+
have ha_le_bsub : a ≤ b - 2 := by linarith
|
| 157 |
+
have hx_le_bsub : x - 2 ≤ b - 2 := by linarith [hx.2]
|
| 158 |
+
have hu_le : u ≤ b - 2 := by
|
| 159 |
+
dsimp [u]
|
| 160 |
+
exact max_le ha_le_bsub hx_le_bsub
|
| 161 |
+
dsimp [v]
|
| 162 |
+
linarith
|
| 163 |
+
have hsub : Set.Icc u v ⊆ Set.Icc a b := by
|
| 164 |
+
intro y hy
|
| 165 |
+
exact ⟨le_trans ha_le_u hy.1, le_trans hy.2 hv_le_b⟩
|
| 166 |
+
have hfabs_uv : ∀ y ∈ Set.Icc u v, |f y| ≤ 1 := by
|
| 167 |
+
intro y hy
|
| 168 |
+
exact hfabs y (hsub hy)
|
| 169 |
+
have hsec_uv : ∀ y ∈ Set.Icc u v, |deriv (deriv f) y| ≤ 1 := by
|
| 170 |
+
intro y hy
|
| 171 |
+
simpa [iteratedDeriv_succ] using hfppabs y (hsub hy)
|
| 172 |
+
have hupper :=
|
| 173 |
+
putnam_1962_a4_deriv_le_two_on_len_two f u v x hf hdf
|
| 174 |
+
hfabs_uv hsec_uv hux hxv huv
|
| 175 |
+
have hfabs_neg_uv : ∀ y ∈ Set.Icc u v, |(-f y)| ≤ 1 := by
|
| 176 |
+
intro y hy
|
| 177 |
+
simpa using hfabs_uv y hy
|
| 178 |
+
have hsec_neg_uv :
|
| 179 |
+
∀ y ∈ Set.Icc u v, |deriv (deriv (fun y : ℝ => -f y)) y| ≤ 1 := by
|
| 180 |
+
intro y hy
|
| 181 |
+
simpa [deriv.fun_neg] using hsec_uv y hy
|
| 182 |
+
have hupper_neg :=
|
| 183 |
+
putnam_1962_a4_deriv_le_two_on_len_two (fun y : ℝ => -f y) u v x hf.neg
|
| 184 |
+
(by simpa [deriv.fun_neg] using hdf.neg) hfabs_neg_uv hsec_neg_uv hux hxv huv
|
| 185 |
+
have hlower : -2 ≤ deriv f x := by
|
| 186 |
+
simpa [deriv.fun_neg] using (neg_le_neg hupper_neg)
|
| 187 |
+
simpa [iteratedDeriv_succ] using (abs_le.mpr ⟨hlower, hupper⟩)
|
Putnam-bench-verified/1962/Putnam1962A5.lean
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
abbrev putnam_1962_a5_solution : ℕ → ℕ := fun n : ℕ => n * (n + 1) * 2^(n - 2)
|
| 4 |
+
|
| 5 |
+
private lemma putnam_1962_a5_sum_range_choose_mul (n : ℕ) :
|
| 6 |
+
(∑ k ∈ Finset.range (n + 1), Nat.choose n k * k) = n * 2 ^ (n - 1) := by
|
| 7 |
+
cases n with
|
| 8 |
+
| zero => simp
|
| 9 |
+
| succ m =>
|
| 10 |
+
rw [Finset.sum_range_succ']
|
| 11 |
+
simp_rw [show ∀ k, Nat.choose (m + 1) (k + 1) * (k + 1) =
|
| 12 |
+
(m + 1) * Nat.choose m k from
|
| 13 |
+
fun k => (Nat.add_one_mul_choose_eq m k).symm]
|
| 14 |
+
rw [(Finset.mul_sum (s := Finset.range (m + 1)) (a := m + 1)
|
| 15 |
+
(f := fun x => Nat.choose m x)).symm]
|
| 16 |
+
rw [Nat.sum_range_choose]
|
| 17 |
+
simp
|
| 18 |
+
|
| 19 |
+
private lemma putnam_1962_a5_sum_range_choose_mul_sq_add_two (r : ℕ) :
|
| 20 |
+
(∑ k ∈ Finset.range (r + 2 + 1), Nat.choose (r + 2) k * k ^ 2) =
|
| 21 |
+
(r + 2) * (r + 3) * 2 ^ r := by
|
| 22 |
+
rw [Finset.sum_range_succ']
|
| 23 |
+
simp
|
| 24 |
+
have hterm : ∀ j,
|
| 25 |
+
Nat.choose (r + 2) (j + 1) * (j + 1) ^ 2 =
|
| 26 |
+
(r + 2) * (Nat.choose (r + 1) j * (j + 1)) := by
|
| 27 |
+
intro j
|
| 28 |
+
have h := (Nat.add_one_mul_choose_eq (r + 1) j).symm
|
| 29 |
+
calc
|
| 30 |
+
Nat.choose (r + 2) (j + 1) * (j + 1) ^ 2
|
| 31 |
+
= (Nat.choose (r + 2) (j + 1) * (j + 1)) * (j + 1) := by ring
|
| 32 |
+
_ = ((r + 2) * Nat.choose (r + 1) j) * (j + 1) := by rw [h]
|
| 33 |
+
_ = (r + 2) * (Nat.choose (r + 1) j * (j + 1)) := by ring
|
| 34 |
+
simp_rw [hterm]
|
| 35 |
+
rw [(Finset.mul_sum (s := Finset.range (r + 2)) (a := r + 2)
|
| 36 |
+
(f := fun j => Nat.choose (r + 1) j * (j + 1))).symm]
|
| 37 |
+
have hsplit :
|
| 38 |
+
(∑ j ∈ Finset.range (r + 2), Nat.choose (r + 1) j * (j + 1)) =
|
| 39 |
+
(∑ j ∈ Finset.range (r + 2), Nat.choose (r + 1) j * j) +
|
| 40 |
+
(∑ j ∈ Finset.range (r + 2), Nat.choose (r + 1) j) := by
|
| 41 |
+
simp [Nat.mul_add, Finset.sum_add_distrib]
|
| 42 |
+
rw [hsplit, putnam_1962_a5_sum_range_choose_mul (r + 1), Nat.sum_range_choose]
|
| 43 |
+
have hsub : r + 1 - 1 = r := by omega
|
| 44 |
+
rw [hsub, pow_succ]
|
| 45 |
+
ring
|
| 46 |
+
|
| 47 |
+
/--
|
| 48 |
+
Evaluate in closed form \[ \sum_{k=1}^n {n \choose k} k^2. \]
|
| 49 |
+
-/
|
| 50 |
+
theorem putnam_1962_a5
|
| 51 |
+
: ∀ n ≥ 2, putnam_1962_a5_solution n = ∑ k ∈ Finset.Icc 1 n, Nat.choose n k * k^2 :=
|
| 52 |
+
by
|
| 53 |
+
intro n hn
|
| 54 |
+
cases Nat.exists_eq_add_of_le' hn with
|
| 55 |
+
| intro r hr =>
|
| 56 |
+
rw [hr]
|
| 57 |
+
unfold putnam_1962_a5_solution
|
| 58 |
+
have hIcc : Finset.Icc 1 (r + 2) = (Finset.range (r + 2 + 1)).erase 0 := by
|
| 59 |
+
ext k
|
| 60 |
+
simp [Nat.succ_le_iff]
|
| 61 |
+
omega
|
| 62 |
+
rw [hIcc]
|
| 63 |
+
have hmem := Finset.mem_range.mpr (show 0 < r + 2 + 1 by omega)
|
| 64 |
+
have herase :
|
| 65 |
+
(∑ k ∈ (Finset.range (r + 2 + 1)).erase 0,
|
| 66 |
+
Nat.choose (r + 2) k * k ^ 2) =
|
| 67 |
+
∑ k ∈ Finset.range (r + 2 + 1), Nat.choose (r + 2) k * k ^ 2 := by
|
| 68 |
+
have h := Finset.sum_erase_add (s := Finset.range (r + 2 + 1))
|
| 69 |
+
(f := fun k => Nat.choose (r + 2) k * k ^ 2) hmem
|
| 70 |
+
simpa using h
|
| 71 |
+
rw [herase, putnam_1962_a5_sum_range_choose_mul_sq_add_two]
|
| 72 |
+
have hsub : r + 2 - 2 = r := by omega
|
| 73 |
+
rw [hsub]
|
Putnam-bench-verified/1962/Putnam1962A6.lean
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
/--
|
| 4 |
+
Let $S$ be a set of rational numbers such that whenever $a$ and $b$ are members of $S$, so are $a+b$ and $ab$, and having the property that for every rational number $r$ exactly one of the following three statements is true: \[ r \in S, -r \in S, r = 0. \] Prove that $S$ is the set of all positive rational numbers.
|
| 5 |
+
-/
|
| 6 |
+
theorem putnam_1962_a6
|
| 7 |
+
(S : Set ℚ)
|
| 8 |
+
(hSadd : ∀ a ∈ S, ∀ b ∈ S, a + b ∈ S)
|
| 9 |
+
(hSprod : ∀ a ∈ S, ∀ b ∈ S, a * b ∈ S)
|
| 10 |
+
(hScond : ∀ r : ℚ, (r ∈ S ∨ -r ∈ S ∨ r = 0) ∧ ¬(r ∈ S ∧ -r ∈ S) ∧ ¬(r ∈ S ∧ r = 0) ∧ ¬(-r ∈ S ∧ r = 0))
|
| 11 |
+
: S = { r : ℚ | r > 0 } :=
|
| 12 |
+
by
|
| 13 |
+
have hzero_not : (0 : ℚ) ∉ S := by
|
| 14 |
+
intro h0
|
| 15 |
+
exact (hScond (0 : ℚ)).2.2.1 ⟨h0, rfl⟩
|
| 16 |
+
have hnegone_not : (-1 : ℚ) ∉ S := by
|
| 17 |
+
intro hneg
|
| 18 |
+
have hone' : (1 : ℚ) ∈ S := by
|
| 19 |
+
have hprod := hSprod (-1 : ℚ) hneg (-1 : ℚ) hneg
|
| 20 |
+
norm_num at hprod
|
| 21 |
+
exact hprod
|
| 22 |
+
exact (hScond (1 : ℚ)).2.1 ⟨hone', by simpa using hneg⟩
|
| 23 |
+
have hOne : (1 : ℚ) ∈ S := by
|
| 24 |
+
rcases (hScond (1 : ℚ)).1 with h1 | hneg | hzero
|
| 25 |
+
· exact h1
|
| 26 |
+
· exact False.elim (hnegone_not hneg)
|
| 27 |
+
· norm_num at hzero
|
| 28 |
+
have hNatSucc : ∀ n : ℕ, ((n.succ : ℕ) : ℚ) ∈ S := by
|
| 29 |
+
intro n
|
| 30 |
+
induction n with
|
| 31 |
+
| zero => simpa using hOne
|
| 32 |
+
| succ n ih =>
|
| 33 |
+
have hsum := hSadd ((n.succ : ℕ) : ℚ) ih (1 : ℚ) hOne
|
| 34 |
+
simpa [Nat.cast_add, Nat.cast_one, Nat.succ_eq_add_one] using hsum
|
| 35 |
+
have hIntPos : ∀ z : ℤ, 0 < z → (z : ℚ) ∈ S := by
|
| 36 |
+
intro z hz
|
| 37 |
+
have hzInt : ((z.toNat : ℤ) = z) := Int.toNat_of_nonneg (le_of_lt hz)
|
| 38 |
+
cases hzn : z.toNat with
|
| 39 |
+
| zero =>
|
| 40 |
+
rw [hzn] at hzInt
|
| 41 |
+
omega
|
| 42 |
+
| succ n =>
|
| 43 |
+
have hmem := hNatSucc n
|
| 44 |
+
have hzInt' : ((Nat.succ n : ℤ) = z) := by simpa [hzn] using hzInt
|
| 45 |
+
have hcast : (((Nat.succ n : ℕ) : ℚ) = (z : ℚ)) := by exact_mod_cast hzInt'
|
| 46 |
+
simpa [hcast] using hmem
|
| 47 |
+
have hden_mem : ∀ r : ℚ, ((r.den : ℕ) : ℚ) ∈ S := by
|
| 48 |
+
intro r
|
| 49 |
+
obtain ⟨n, hdn⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt (Rat.den_pos r))
|
| 50 |
+
simpa [hdn] using hNatSucc n
|
| 51 |
+
have hneg_pos_not_mem : ∀ q : ℚ, 0 < q → -q ∉ S := by
|
| 52 |
+
intro q hq hnegS
|
| 53 |
+
have hnumpos : 0 < q.num := (Rat.num_pos).2 hq
|
| 54 |
+
have hnumS : (q.num : ℚ) ∈ S := hIntPos q.num hnumpos
|
| 55 |
+
have hprodS : (-q * (q.den : ℚ)) ∈ S :=
|
| 56 |
+
hSprod (-q) hnegS ((q.den : ℕ) : ℚ) (hden_mem q)
|
| 57 |
+
have hprod_eq : -q * (q.den : ℚ) = -(q.num : ℚ) := by
|
| 58 |
+
have hden_ne_nat : q.den ≠ 0 := Nat.ne_of_gt (Rat.den_pos q)
|
| 59 |
+
have hden_ne : (q.den : ℚ) ≠ 0 := by exact_mod_cast hden_ne_nat
|
| 60 |
+
have hrepr : (q.num : ℚ) / (q.den : ℚ) = q := Rat.num_div_den q
|
| 61 |
+
calc
|
| 62 |
+
-q * (q.den : ℚ) = -((q.num : ℚ) / (q.den : ℚ)) * (q.den : ℚ) := by rw [hrepr]
|
| 63 |
+
_ = -(q.num : ℚ) := by
|
| 64 |
+
field_simp [hden_ne]
|
| 65 |
+
have hnegnumS : -(q.num : ℚ) ∈ S := by simpa [hprod_eq] using hprodS
|
| 66 |
+
exact (hScond (q.num : ℚ)).2.1 ⟨hnumS, hnegnumS⟩
|
| 67 |
+
ext r
|
| 68 |
+
constructor
|
| 69 |
+
· intro hrS
|
| 70 |
+
change r > 0
|
| 71 |
+
by_contra hrnot
|
| 72 |
+
have hrle : r ≤ 0 := le_of_not_gt hrnot
|
| 73 |
+
rcases lt_or_eq_of_le hrle with hrlt | hreq
|
| 74 |
+
· have hnegpos : 0 < -r := by linarith
|
| 75 |
+
exact hneg_pos_not_mem (-r) hnegpos (by simpa using hrS)
|
| 76 |
+
· exact hzero_not (by simpa [hreq] using hrS)
|
| 77 |
+
· intro hrpos
|
| 78 |
+
change r > 0 at hrpos
|
| 79 |
+
rcases (hScond r).1 with hrS | hnegS | hrzero
|
| 80 |
+
· exact hrS
|
| 81 |
+
· exact False.elim (hneg_pos_not_mem r hrpos hnegS)
|
| 82 |
+
· linarith
|
Putnam-bench-verified/1962/Putnam1962B1.lean
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
/--
|
| 4 |
+
Let $x^{(n)} = x(x-1)\cdots(x-n+1)$ for $n$ a positive integer and let $x^{(0)} = 1.$ Prove that \[ (x+y)^{(n)} = \sum_{k=0}^n {n \choose k} x^{(k)} y^{(n-k)}. \]
|
| 5 |
+
-/
|
| 6 |
+
theorem putnam_1962_b1
|
| 7 |
+
(p : ℕ → ℝ → ℝ)
|
| 8 |
+
(x y : ℝ)
|
| 9 |
+
(n : ℕ)
|
| 10 |
+
(h0 : p 0 = fun x : ℝ => 1)
|
| 11 |
+
(hp : ∀ n > 0, p n = fun x : ℝ => ∏ i ∈ Finset.range n, (x - i))
|
| 12 |
+
: p n (x+y) = ∑ k ∈ Finset.range (n+1), Nat.choose n k * (p k x) * (p (n - k) y) :=
|
| 13 |
+
by
|
| 14 |
+
classical
|
| 15 |
+
have hp_eq : ∀ m z, p m z = (descPochhammer Real m).eval z := by
|
| 16 |
+
intro m z
|
| 17 |
+
cases m with
|
| 18 |
+
| zero =>
|
| 19 |
+
simpa using congr_fun h0 z
|
| 20 |
+
| succ m =>
|
| 21 |
+
simpa [descPochhammer_eval_eq_prod_range] using congr_fun (hp (m + 1) (by omega)) z
|
| 22 |
+
have hsmeval : ∀ m z, (descPochhammer Int m).smeval z = (descPochhammer Real m).eval z := by
|
| 23 |
+
intro m z
|
| 24 |
+
calc
|
| 25 |
+
(descPochhammer Int m).smeval z = (ascPochhammer Nat m).smeval (z - m + 1) := by
|
| 26 |
+
exact Polynomial.descPochhammer_smeval_eq_ascPochhammer z m
|
| 27 |
+
_ = (ascPochhammer Real m).eval (z - m + 1) := by
|
| 28 |
+
exact Polynomial.ascPochhammer_smeval_eq_eval (z - m + 1) m
|
| 29 |
+
_ = (descPochhammer Real m).eval z := by
|
| 30 |
+
exact (descPochhammer_eval_eq_ascPochhammer Real z m).symm
|
| 31 |
+
calc
|
| 32 |
+
p n (x + y) = (descPochhammer Real n).eval (x + y) := hp_eq n (x + y)
|
| 33 |
+
_ = (descPochhammer Int n).smeval (x + y) := (hsmeval n (x + y)).symm
|
| 34 |
+
_ = ∑ ij ∈ Finset.antidiagonal n,
|
| 35 |
+
Nat.choose n ij.1 *
|
| 36 |
+
((descPochhammer Int ij.1).smeval x * (descPochhammer Int ij.2).smeval y) := by
|
| 37 |
+
exact Ring.descPochhammer_smeval_add n (Commute.all x y)
|
| 38 |
+
_ = ∑ k ∈ Finset.range (n + 1),
|
| 39 |
+
Nat.choose n k *
|
| 40 |
+
((descPochhammer Int k).smeval x * (descPochhammer Int (n - k)).smeval y) := by
|
| 41 |
+
simpa [Nat.succ_eq_add_one] using
|
| 42 |
+
(Finset.Nat.sum_antidiagonal_eq_sum_range_succ
|
| 43 |
+
(fun i j => (Nat.choose n i : Real) *
|
| 44 |
+
((descPochhammer Int i).smeval x * (descPochhammer Int j).smeval y)) n)
|
| 45 |
+
_ = ∑ k ∈ Finset.range (n + 1), Nat.choose n k * (p k x) * (p (n - k) y) := by
|
| 46 |
+
refine Finset.sum_congr rfl ?_
|
| 47 |
+
intro k _hk
|
| 48 |
+
rw [hsmeval k x, hsmeval (n - k) y, (hp_eq k x).symm, (hp_eq (n - k) y).symm]
|
| 49 |
+
ring
|
Putnam-bench-verified/1962/Putnam1962B2.lean
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
open MeasureTheory
|
| 4 |
+
|
| 5 |
+
--Note: The original problem requires a function to be exhibited, but in the official archives the solution depends on an enumeration of the rationals, so we modify the problem to be an existential statement.
|
| 6 |
+
/--
|
| 7 |
+
Let $\mathbb{S}$ be the set of all subsets of the natural numbers. Prove the existence of a function $f : \mathbb{R} \to \mathbb{S}$ such that $f(a) \subset f(b)$ whenever $a < b$.
|
| 8 |
+
-/
|
| 9 |
+
theorem putnam_1962_b2
|
| 10 |
+
: ∃ f : ℝ → Set ℕ+, ∀ a b : ℝ, a < b → f a ⊂ f b :=
|
| 11 |
+
by
|
| 12 |
+
let f : ℝ → Set ℕ+ := fun x =>
|
| 13 |
+
{n | ∃ q : ℚ, (q : ℝ) < x ∧ n.natPred = Encodable.encode q}
|
| 14 |
+
refine ⟨f, ?_⟩
|
| 15 |
+
intro a b hab
|
| 16 |
+
rw [Set.ssubset_def]
|
| 17 |
+
constructor
|
| 18 |
+
· intro n hn
|
| 19 |
+
rcases hn with ⟨q, hqx, hcode⟩
|
| 20 |
+
exact ⟨q, hqx.trans hab, hcode⟩
|
| 21 |
+
· intro hba
|
| 22 |
+
rcases exists_rat_btwn hab with ⟨q, haq, hqb⟩
|
| 23 |
+
have hmem_b : Nat.succPNat (Encodable.encode q) ∈ f b := by
|
| 24 |
+
exact ⟨q, hqb, by simp⟩
|
| 25 |
+
have hmem_a : Nat.succPNat (Encodable.encode q) ∈ f a := hba hmem_b
|
| 26 |
+
rcases hmem_a with ⟨r, hra, hcode⟩
|
| 27 |
+
have hrq : r = q := Encodable.encode_injective (by simpa using hcode.symm)
|
| 28 |
+
have hqa : (q : ℝ) < a := by
|
| 29 |
+
simpa [hrq] using hra
|
| 30 |
+
exact (not_lt_of_ge haq.le) hqa
|
Putnam-bench-verified/1962/Putnam1962B3.lean
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
/--
|
| 4 |
+
Let $S$ be a convex region in the Euclidean plane, containing the origin, for which every ray from the origin has at least one point outside $S$. Assuming that either the origin is an interior point of $S$ or $S$ is topologically closed, prove that $S$ is bounded.
|
| 5 |
+
-/
|
| 6 |
+
theorem putnam_1962_b3
|
| 7 |
+
(S : Set (EuclideanSpace ℝ (Fin 2)))
|
| 8 |
+
(hS : Convex ℝ S ∧ 0 ∈ S)
|
| 9 |
+
(htopo : (0 ∈ interior S) ∨ IsClosed S)
|
| 10 |
+
(hray : ∀ P : EuclideanSpace ℝ (Fin 2), P ≠ 0 → ∃ Q : EuclideanSpace ℝ (Fin 2), SameRay ℝ P Q ∧ Q ∉ S)
|
| 11 |
+
: Bornology.IsBounded S :=
|
| 12 |
+
by
|
| 13 |
+
rcases hS with ⟨hconv, hzero⟩
|
| 14 |
+
by_contra h_unbdd
|
| 15 |
+
rcases (not_bounded_iff_exists_ne_zero_mem_asymptoticCone (s := S)).mp h_unbdd with
|
| 16 |
+
⟨v, hv_ne, hv_asymp⟩
|
| 17 |
+
rcases hray v hv_ne with ⟨Q, hsame, hQ_not_mem⟩
|
| 18 |
+
rcases hsame.exists_nonneg_left hv_ne with ⟨c, hc, hQ⟩
|
| 19 |
+
apply hQ_not_mem
|
| 20 |
+
rw [← hQ]
|
| 21 |
+
rcases htopo with h0int | hclosed
|
| 22 |
+
· simpa only [vadd_eq_add, add_zero] using
|
| 23 |
+
hconv.smul_vadd_mem_of_mem_nhds_of_mem_asymptoticCone hc
|
| 24 |
+
(mem_interior_iff_mem_nhds.mp h0int) hv_asymp
|
| 25 |
+
· simpa only [vadd_eq_add, add_zero] using
|
| 26 |
+
hconv.smul_vadd_mem_of_isClosed_of_mem_asymptoticCone hclosed hc hv_asymp hzero
|
Putnam-bench-verified/1962/Putnam1962B5.lean
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
open scoped BigOperators
|
| 4 |
+
|
| 5 |
+
private lemma putnam_1962_b5_pair_scaled {a b : ℝ} {p j : ℕ}
|
| 6 |
+
(_hb0 : 0 ≤ b) (hba : b ≤ a) (hj : j ≤ p) :
|
| 7 |
+
a ^ j * b ^ (p - j) + a ^ (p - j) * b ^ j ≤ a ^ p + b ^ p := by
|
| 8 |
+
have hbja : b ^ j ≤ a ^ j := by gcongr
|
| 9 |
+
have hbpja : b ^ (p - j) ≤ a ^ (p - j) := by gcongr
|
| 10 |
+
have h1 : 0 ≤ a ^ j - b ^ j := sub_nonneg.mpr hbja
|
| 11 |
+
have h2 : 0 ≤ a ^ (p - j) - b ^ (p - j) := sub_nonneg.mpr hbpja
|
| 12 |
+
have hprod : 0 ≤ (a ^ j - b ^ j) * (a ^ (p - j) - b ^ (p - j)) :=
|
| 13 |
+
mul_nonneg h1 h2
|
| 14 |
+
have hapow : a ^ j * a ^ (p - j) = a ^ p := by
|
| 15 |
+
rw [← pow_add]
|
| 16 |
+
exact congrArg (fun q => a ^ q) (Nat.add_sub_of_le hj)
|
| 17 |
+
have hbpow : b ^ j * b ^ (p - j) = b ^ p := by
|
| 18 |
+
rw [← pow_add]
|
| 19 |
+
exact congrArg (fun q => b ^ q) (Nat.add_sub_of_le hj)
|
| 20 |
+
ring_nf at hprod
|
| 21 |
+
rw [hapow, hbpow] at hprod
|
| 22 |
+
nlinarith
|
| 23 |
+
|
| 24 |
+
private lemma putnam_1962_b5_geom_trap_scaled (p : ℕ) {a b : ℝ}
|
| 25 |
+
(hb0 : 0 ≤ b) (hba : b ≤ a) :
|
| 26 |
+
2 * (∑ j ∈ Finset.range (p + 1), a ^ j * b ^ (p - j)) ≤
|
| 27 |
+
(p + 1 : ℝ) * (a ^ p + b ^ p) := by
|
| 28 |
+
let S : ℝ := ∑ j ∈ Finset.range (p + 1), a ^ j * b ^ (p - j)
|
| 29 |
+
have hterm : ∀ j, j ∈ Finset.range (p + 1) →
|
| 30 |
+
a ^ j * b ^ (p - j) + a ^ (p - j) * b ^ j ≤ a ^ p + b ^ p := by
|
| 31 |
+
intro j hj
|
| 32 |
+
exact putnam_1962_b5_pair_scaled hb0 hba
|
| 33 |
+
(Nat.lt_succ_iff.mp (Finset.mem_range.mp hj))
|
| 34 |
+
have hsum := Finset.sum_le_sum hterm
|
| 35 |
+
rw [Finset.sum_add_distrib] at hsum
|
| 36 |
+
have hreflect0 :=
|
| 37 |
+
Finset.sum_range_reflect (fun j => a ^ j * b ^ (p - j)) (p + 1)
|
| 38 |
+
have hswap : (∑ j ∈ Finset.range (p + 1), a ^ (p - j) * b ^ j) =
|
| 39 |
+
∑ j ∈ Finset.range (p + 1), a ^ (p - j) * b ^ (p - (p - j)) := by
|
| 40 |
+
apply Finset.sum_congr rfl
|
| 41 |
+
intro j hj
|
| 42 |
+
have hjle : j ≤ p := Nat.lt_succ_iff.mp (Finset.mem_range.mp hj)
|
| 43 |
+
have hsub : p - (p - j) = j := by omega
|
| 44 |
+
rw [hsub]
|
| 45 |
+
have hreflect : (∑ j ∈ Finset.range (p + 1), a ^ (p - j) * b ^ j) =
|
| 46 |
+
∑ j ∈ Finset.range (p + 1), a ^ j * b ^ (p - j) := by
|
| 47 |
+
rw [hswap]
|
| 48 |
+
simpa [Nat.add_sub_cancel_right] using hreflect0
|
| 49 |
+
have hleft : (∑ j ∈ Finset.range (p + 1), a ^ j * b ^ (p - j)) +
|
| 50 |
+
(∑ j ∈ Finset.range (p + 1), a ^ (p - j) * b ^ j) = 2 * S := by
|
| 51 |
+
dsimp [S]
|
| 52 |
+
rw [hreflect]
|
| 53 |
+
ring
|
| 54 |
+
have hright : (∑ _j ∈ Finset.range (p + 1), (a ^ p + b ^ p)) =
|
| 55 |
+
(p + 1 : ℝ) * (a ^ p + b ^ p) := by
|
| 56 |
+
simp
|
| 57 |
+
ring
|
| 58 |
+
calc
|
| 59 |
+
2 * S =
|
| 60 |
+
(∑ j ∈ Finset.range (p + 1), a ^ j * b ^ (p - j)) +
|
| 61 |
+
(∑ j ∈ Finset.range (p + 1), a ^ (p - j) * b ^ j) := hleft.symm
|
| 62 |
+
_ ≤ ∑ _j ∈ Finset.range (p + 1), (a ^ p + b ^ p) := hsum
|
| 63 |
+
_ = (p + 1 : ℝ) * (a ^ p + b ^ p) := hright
|
| 64 |
+
|
| 65 |
+
private lemma putnam_1962_b5_unit_power_upper (p k : ℕ) :
|
| 66 |
+
(p + 1 : ℝ) * (k : ℝ) ^ p ≤
|
| 67 |
+
((k + 1 : ℕ) : ℝ) ^ (p + 1) - (k : ℝ) ^ (p + 1) := by
|
| 68 |
+
have hgeom := geom_sum₂_mul_of_ge
|
| 69 |
+
(x := ((k + 1 : ℕ) : ℝ)) (y := (k : ℝ))
|
| 70 |
+
(by exact_mod_cast Nat.le_succ k : (k : ℝ) ≤ ((k + 1 : ℕ) : ℝ)) (p + 1)
|
| 71 |
+
have hterm : ∀ j, j ∈ Finset.range (p + 1) →
|
| 72 |
+
(k : ℝ) ^ p ≤ ((k + 1 : ℕ) : ℝ) ^ j * (k : ℝ) ^ (p - j) := by
|
| 73 |
+
intro j hj
|
| 74 |
+
have hjle : j ≤ p := Nat.lt_succ_iff.mp (Finset.mem_range.mp hj)
|
| 75 |
+
calc
|
| 76 |
+
(k : ℝ) ^ p = (k : ℝ) ^ j * (k : ℝ) ^ (p - j) := by
|
| 77 |
+
rw [← pow_add]
|
| 78 |
+
exact congrArg (fun q => (k : ℝ) ^ q) (Nat.add_sub_of_le hjle).symm
|
| 79 |
+
_ ≤ ((k + 1 : ℕ) : ℝ) ^ j * (k : ℝ) ^ (p - j) := by
|
| 80 |
+
gcongr
|
| 81 |
+
norm_num
|
| 82 |
+
have hsum := Finset.sum_le_sum hterm
|
| 83 |
+
have hconst : (∑ _j ∈ Finset.range (p + 1), (k : ℝ) ^ p) =
|
| 84 |
+
(p + 1 : ℝ) * (k : ℝ) ^ p := by
|
| 85 |
+
simp
|
| 86 |
+
have hdiff : (∑ j ∈ Finset.range (p + 1),
|
| 87 |
+
((k + 1 : ℕ) : ℝ) ^ j * (k : ℝ) ^ (p - j)) =
|
| 88 |
+
((k + 1 : ℕ) : ℝ) ^ (p + 1) - (k : ℝ) ^ (p + 1) := by
|
| 89 |
+
simpa using hgeom
|
| 90 |
+
rwa [hconst, hdiff] at hsum
|
| 91 |
+
|
| 92 |
+
private lemma putnam_1962_b5_unit_power_trapezoid (p k : ℕ) :
|
| 93 |
+
2 * (((k + 1 : ℕ) : ℝ) ^ (p + 1) - (k : ℝ) ^ (p + 1)) ≤
|
| 94 |
+
(p + 1 : ℝ) * (((k + 1 : ℕ) : ℝ) ^ p + (k : ℝ) ^ p) := by
|
| 95 |
+
have hgeom := geom_sum₂_mul_of_ge
|
| 96 |
+
(x := ((k + 1 : ℕ) : ℝ)) (y := (k : ℝ))
|
| 97 |
+
(by exact_mod_cast Nat.le_succ k : (k : ℝ) ≤ ((k + 1 : ℕ) : ℝ)) (p + 1)
|
| 98 |
+
have hdiff : (∑ j ∈ Finset.range (p + 1),
|
| 99 |
+
((k + 1 : ℕ) : ℝ) ^ j * (k : ℝ) ^ (p - j)) =
|
| 100 |
+
((k + 1 : ℕ) : ℝ) ^ (p + 1) - (k : ℝ) ^ (p + 1) := by
|
| 101 |
+
simpa using hgeom
|
| 102 |
+
have hscaled := putnam_1962_b5_geom_trap_scaled (p := p)
|
| 103 |
+
(a := ((k + 1 : ℕ) : ℝ)) (b := (k : ℝ)) (by positivity)
|
| 104 |
+
(by exact_mod_cast Nat.le_succ k : (k : ℝ) ≤ ((k + 1 : ℕ) : ℝ))
|
| 105 |
+
rwa [hdiff] at hscaled
|
| 106 |
+
|
| 107 |
+
private lemma putnam_1962_b5_power_sum_upper (p m : ℕ) :
|
| 108 |
+
(∑ j ∈ Finset.range m, (j : ℝ) ^ p) ≤ (m : ℝ) ^ (p + 1) / (p + 1) := by
|
| 109 |
+
induction m with
|
| 110 |
+
| zero =>
|
| 111 |
+
simp
|
| 112 |
+
| succ m ih =>
|
| 113 |
+
rw [Finset.sum_range_succ]
|
| 114 |
+
have hstep := putnam_1962_b5_unit_power_upper p m
|
| 115 |
+
have hp1pos : 0 < (p + 1 : ℝ) := by positivity
|
| 116 |
+
calc
|
| 117 |
+
(∑ j ∈ Finset.range m, (j : ℝ) ^ p) + (m : ℝ) ^ p
|
| 118 |
+
≤ (m : ℝ) ^ (p + 1) / (p + 1) + (m : ℝ) ^ p := by
|
| 119 |
+
exact add_le_add ih (le_refl _)
|
| 120 |
+
_ ≤ ((m + 1 : ℕ) : ℝ) ^ (p + 1) / (p + 1) := by
|
| 121 |
+
field_simp [hp1pos.ne']
|
| 122 |
+
ring_nf at hstep ⊢
|
| 123 |
+
nlinarith [hstep]
|
| 124 |
+
|
| 125 |
+
private lemma putnam_1962_b5_power_sum_lower (p m : ℕ) (hp : 2 ≤ p) (hm : 1 ≤ m) :
|
| 126 |
+
(m : ℝ) ^ (p + 1) / (p + 1) + (m : ℝ) ^ p / 2 <
|
| 127 |
+
∑ j ∈ Finset.range (m + 1), (j : ℝ) ^ p := by
|
| 128 |
+
refine Nat.le_induction ?base ?step m hm
|
| 129 |
+
· have hp0 : p ≠ 0 := by omega
|
| 130 |
+
have hp1gt : (2 : ℝ) < (p + 1 : ℝ) := by exact_mod_cast Nat.lt_succ_of_le hp
|
| 131 |
+
have hfrac : (1 : ℝ) / (p + 1) < 1 / 2 := by
|
| 132 |
+
have hp1pos : 0 < (p + 1 : ℝ) := by positivity
|
| 133 |
+
field_simp [hp1pos.ne']
|
| 134 |
+
linarith
|
| 135 |
+
have hbase : (1 : ℝ) / (p + 1) + 1 / 2 < 1 := by linarith
|
| 136 |
+
have hsum_base : (∑ j ∈ Finset.range (1 + 1), (j : ℝ) ^ p) = 1 := by
|
| 137 |
+
rw [show (1 + 1 : ℕ) = 1 + 1 by norm_num, Finset.sum_range_succ]
|
| 138 |
+
rw [show (1 : ℕ) = 0 + 1 by norm_num, Finset.sum_range_succ]
|
| 139 |
+
simp [hp0]
|
| 140 |
+
rw [hsum_base]
|
| 141 |
+
simpa [hp0] using hbase
|
| 142 |
+
· intro k hk ih
|
| 143 |
+
rw [Finset.sum_range_succ]
|
| 144 |
+
have hstep := putnam_1962_b5_unit_power_trapezoid p k
|
| 145 |
+
have hp1pos : 0 < (p + 1 : ℝ) := by positivity
|
| 146 |
+
have hLstep :
|
| 147 |
+
((k + 1 : ℕ) : ℝ) ^ (p + 1) / (p + 1) +
|
| 148 |
+
((k + 1 : ℕ) : ℝ) ^ p / 2 ≤
|
| 149 |
+
(k : ℝ) ^ (p + 1) / (p + 1) + (k : ℝ) ^ p / 2 +
|
| 150 |
+
((k + 1 : ℕ) : ℝ) ^ p := by
|
| 151 |
+
field_simp [hp1pos.ne']
|
| 152 |
+
ring_nf at hstep ⊢
|
| 153 |
+
nlinarith [hstep]
|
| 154 |
+
calc
|
| 155 |
+
((k + 1 : ℕ) : ℝ) ^ (p + 1) / (p + 1) +
|
| 156 |
+
((k + 1 : ℕ) : ℝ) ^ p / 2
|
| 157 |
+
≤ (k : ℝ) ^ (p + 1) / (p + 1) + (k : ℝ) ^ p / 2 +
|
| 158 |
+
((k + 1 : ℕ) : ℝ) ^ p := hLstep
|
| 159 |
+
_ < (∑ j ∈ Finset.range (k + 1), (j : ℝ) ^ p) +
|
| 160 |
+
((k + 1 : ℕ) : ℝ) ^ p := by
|
| 161 |
+
simpa [add_comm, add_left_comm, add_assoc] using
|
| 162 |
+
add_lt_add_right ih (((k + 1 : ℕ) : ℝ) ^ p)
|
| 163 |
+
_ = (∑ j ∈ Finset.range (k + 1), (j : ℝ) ^ p) +
|
| 164 |
+
((k + 1 : ℕ) : ℝ) ^ p := rfl
|
| 165 |
+
|
| 166 |
+
private lemma putnam_1962_b5_shifted_power_sum (m : ℕ) (hm0 : m ≠ 0) :
|
| 167 |
+
(∑ k ∈ Finset.range m, (((k + 1 : ℕ) : ℝ) ^ m)) =
|
| 168 |
+
∑ j ∈ Finset.range (m + 1), (j : ℝ) ^ m := by
|
| 169 |
+
rw [Finset.sum_range_succ']
|
| 170 |
+
simp [hm0]
|
| 171 |
+
|
| 172 |
+
private lemma putnam_1962_b5_nat (m : ℕ) (hm2 : 2 ≤ m) :
|
| 173 |
+
(3 * (m : ℝ) + 1) / (2 * m + 2) <
|
| 174 |
+
∑ k ∈ Finset.range m, ((((k + 1 : ℕ) : ℝ) / m) ^ m) ∧
|
| 175 |
+
∑ k ∈ Finset.range m, ((((k + 1 : ℕ) : ℝ) / m) ^ m) < 2 := by
|
| 176 |
+
have hm0 : m ≠ 0 := by omega
|
| 177 |
+
have hm1 : 1 ≤ m := by omega
|
| 178 |
+
have hmpos : 0 < (m : ℝ) := by positivity
|
| 179 |
+
have hmpowpos : 0 < (m : ℝ) ^ m := by positivity
|
| 180 |
+
let P : ℝ := ∑ j ∈ Finset.range (m + 1), (j : ℝ) ^ m
|
| 181 |
+
let S : ℝ := ∑ k ∈ Finset.range m, ((((k + 1 : ℕ) : ℝ) / m) ^ m)
|
| 182 |
+
have hshift := putnam_1962_b5_shifted_power_sum m hm0
|
| 183 |
+
have hS : S = P / (m : ℝ) ^ m := by
|
| 184 |
+
dsimp [S, P]
|
| 185 |
+
calc
|
| 186 |
+
(∑ k ∈ Finset.range m, ((((k + 1 : ℕ) : ℝ) / m) ^ m))
|
| 187 |
+
= ∑ k ∈ Finset.range m, (((k + 1 : ℕ) : ℝ) ^ m / (m : ℝ) ^ m) := by
|
| 188 |
+
apply Finset.sum_congr rfl
|
| 189 |
+
intro k _hk
|
| 190 |
+
rw [div_pow]
|
| 191 |
+
_ = (∑ k ∈ Finset.range m, (((k + 1 : ℕ) : ℝ) ^ m)) / (m : ℝ) ^ m := by
|
| 192 |
+
rw [Finset.sum_div]
|
| 193 |
+
_ = (∑ j ∈ Finset.range (m + 1), (j : ℝ) ^ m) / (m : ℝ) ^ m := by
|
| 194 |
+
rw [hshift]
|
| 195 |
+
have hlowerP := putnam_1962_b5_power_sum_lower m m hm2 hm1
|
| 196 |
+
have hupperRange := putnam_1962_b5_power_sum_upper m m
|
| 197 |
+
have hupperP : P ≤ (m : ℝ) ^ (m + 1) / (m + 1) + (m : ℝ) ^ m := by
|
| 198 |
+
dsimp [P]
|
| 199 |
+
rw [Finset.sum_range_succ]
|
| 200 |
+
exact add_le_add hupperRange (le_refl _)
|
| 201 |
+
have htarget :
|
| 202 |
+
(3 * (m : ℝ) + 1) / (2 * m + 2) =
|
| 203 |
+
(m : ℝ) / (m + 1) + 1 / 2 := by
|
| 204 |
+
have hm1ne : (m : ℝ) + 1 ≠ 0 := by positivity
|
| 205 |
+
field_simp [hm1ne]
|
| 206 |
+
ring
|
| 207 |
+
have hlowerScale :
|
| 208 |
+
((m : ℝ) / (m + 1) + 1 / 2) * (m : ℝ) ^ m =
|
| 209 |
+
(m : ℝ) ^ (m + 1) / (m + 1) + (m : ℝ) ^ m / 2 := by
|
| 210 |
+
rw [pow_succ]
|
| 211 |
+
ring_nf
|
| 212 |
+
have hupperScale :
|
| 213 |
+
(1 + (m : ℝ) / (m + 1)) * (m : ℝ) ^ m =
|
| 214 |
+
(m : ℝ) ^ (m + 1) / (m + 1) + (m : ℝ) ^ m := by
|
| 215 |
+
rw [pow_succ]
|
| 216 |
+
ring_nf
|
| 217 |
+
have hlower : (3 * (m : ℝ) + 1) / (2 * m + 2) < S := by
|
| 218 |
+
rw [htarget, hS]
|
| 219 |
+
rw [lt_div_iff₀ hmpowpos]
|
| 220 |
+
rw [hlowerScale]
|
| 221 |
+
exact hlowerP
|
| 222 |
+
have hupper_le : S ≤ 1 + (m : ℝ) / (m + 1) := by
|
| 223 |
+
rw [hS]
|
| 224 |
+
rw [div_le_iff₀ hmpowpos]
|
| 225 |
+
rw [hupperScale]
|
| 226 |
+
exact hupperP
|
| 227 |
+
have hupper_bound : 1 + (m : ℝ) / (m + 1) < 2 := by
|
| 228 |
+
have hm1pos : 0 < (m : ℝ) + 1 := by positivity
|
| 229 |
+
field_simp [hm1pos.ne']
|
| 230 |
+
nlinarith [hmpos]
|
| 231 |
+
exact ⟨hlower, lt_of_le_of_lt hupper_le hupper_bound⟩
|
| 232 |
+
|
| 233 |
+
/--
|
| 234 |
+
Prove that for every integer $n$ greater than 1: \[ \frac{3n+1}{2n+2} < \left( \frac{1}{n} \right)^n + \left(\frac{2}{n} \right)^n + \cdots + \left(\frac{n}{n} \right)^n < 2. \]
|
| 235 |
+
-/
|
| 236 |
+
theorem putnam_1962_b5
|
| 237 |
+
(n : ℤ)
|
| 238 |
+
(ng1 : n > 1)
|
| 239 |
+
: (3 * (n : ℝ) + 1) / (2 * n + 2) < ∑ i : Finset.Icc 1 n, ((i : ℝ) / n) ^ (n : ℝ) ∧ ∑ i : Finset.Icc 1 n, ((i : ℝ) / n) ^ (n : ℝ) < 2 :=
|
| 240 |
+
by
|
| 241 |
+
have hnnonneg : 0 ≤ n := by omega
|
| 242 |
+
let m : ℕ := n.toNat
|
| 243 |
+
have hm_int : (m : ℤ) = n := by
|
| 244 |
+
dsimp [m]
|
| 245 |
+
exact Int.toNat_of_nonneg hnnonneg
|
| 246 |
+
have hm2 : 2 ≤ m := by
|
| 247 |
+
have : (2 : ℤ) ≤ n := by omega
|
| 248 |
+
omega
|
| 249 |
+
have hn_real : (n : ℝ) = (m : ℝ) := by
|
| 250 |
+
rw [← hm_int]
|
| 251 |
+
norm_num
|
| 252 |
+
have hsum :
|
| 253 |
+
(∑ i : Finset.Icc 1 n, ((i : ℝ) / n) ^ (n : ℝ)) =
|
| 254 |
+
∑ k ∈ Finset.range m, ((((k + 1 : ℕ) : ℝ) / m) ^ m) := by
|
| 255 |
+
rw [Finset.univ_eq_attach]
|
| 256 |
+
symm
|
| 257 |
+
refine Finset.sum_bij
|
| 258 |
+
(fun k hk => (⟨((k : ℤ) + 1), by
|
| 259 |
+
rw [Finset.mem_Icc]
|
| 260 |
+
constructor
|
| 261 |
+
· omega
|
| 262 |
+
· have hklt : k < m := Finset.mem_range.mp hk
|
| 263 |
+
have : (k : ℤ) + 1 ≤ (m : ℤ) := by omega
|
| 264 |
+
rwa [hm_int] at this⟩ : Finset.Icc (1 : ℤ) n))
|
| 265 |
+
?mem ?inj ?surj ?term
|
| 266 |
+
· intro k hk
|
| 267 |
+
simp
|
| 268 |
+
· intro k₁ hk₁ k₂ hk₂ hmap
|
| 269 |
+
have hvals := congrArg Subtype.val hmap
|
| 270 |
+
change (k₁ : ℤ) + 1 = (k₂ : ℤ) + 1 at hvals
|
| 271 |
+
omega
|
| 272 |
+
· intro i hi
|
| 273 |
+
rcases i with ⟨z, hz⟩
|
| 274 |
+
have hz1 : 1 ≤ z := (Finset.mem_Icc.mp hz).1
|
| 275 |
+
have hzn : z ≤ n := (Finset.mem_Icc.mp hz).2
|
| 276 |
+
let k : ℕ := (z - 1).toNat
|
| 277 |
+
have hk_int : (k : ℤ) = z - 1 := by
|
| 278 |
+
dsimp [k]
|
| 279 |
+
exact Int.toNat_of_nonneg (by omega)
|
| 280 |
+
have hklt_int : (k : ℤ) < (m : ℤ) := by
|
| 281 |
+
rw [hk_int, hm_int]
|
| 282 |
+
omega
|
| 283 |
+
have hklt : k < m := by exact_mod_cast hklt_int
|
| 284 |
+
refine ⟨k, Finset.mem_range.mpr hklt, ?_⟩
|
| 285 |
+
apply Subtype.ext
|
| 286 |
+
dsimp [k]
|
| 287 |
+
rw [hk_int]
|
| 288 |
+
omega
|
| 289 |
+
· intro k hk
|
| 290 |
+
have hkcast : (((k : ℤ) + 1 : ℤ) : ℝ) = ((k + 1 : ℕ) : ℝ) := by
|
| 291 |
+
norm_num
|
| 292 |
+
simp [hn_real, Real.rpow_natCast, hkcast]
|
| 293 |
+
have hnat := putnam_1962_b5_nat m hm2
|
| 294 |
+
have hnat' :
|
| 295 |
+
(3 * (n : ℝ) + 1) / (2 * n + 2) <
|
| 296 |
+
∑ k ∈ Finset.range m, ((((k + 1 : ℕ) : ℝ) / m) ^ m) ∧
|
| 297 |
+
∑ k ∈ Finset.range m, ((((k + 1 : ℕ) : ℝ) / m) ^ m) < 2 := by
|
| 298 |
+
simpa [← hn_real] using hnat
|
| 299 |
+
change (3 * (n : ℝ) + 1) / (2 * n + 2) <
|
| 300 |
+
(∑ i : Finset.Icc 1 n, ((i : ℝ) / n) ^ (n : ℝ)) ∧
|
| 301 |
+
(∑ i : Finset.Icc 1 n, ((i : ℝ) / n) ^ (n : ℝ)) < 2
|
| 302 |
+
constructor
|
| 303 |
+
· rw [hsum]
|
| 304 |
+
exact hnat'.1
|
| 305 |
+
· rw [hsum]
|
| 306 |
+
exact hnat'.2
|
Putnam-bench-verified/1962/Putnam1962B6.lean
ADDED
|
@@ -0,0 +1,1550 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
open Real
|
| 4 |
+
|
| 5 |
+
private lemma putnam_1962_b6_constant_of_zero
|
| 6 |
+
(a b : ℕ → ℝ) (f : ℝ → ℝ)
|
| 7 |
+
(hf : f = fun x : ℝ =>
|
| 8 |
+
∑ k ∈ Finset.Icc 0 0, (a k * Real.sin (k * x) + b k * Real.cos (k * x))) :
|
| 9 |
+
∃ c : ℝ, f = fun _ : ℝ => c := by
|
| 10 |
+
refine ⟨b 0, ?_⟩
|
| 11 |
+
funext x
|
| 12 |
+
rw [hf]
|
| 13 |
+
simp
|
| 14 |
+
|
| 15 |
+
private lemma putnam_1962_b6_periodic
|
| 16 |
+
(n : ℕ) (a b : ℕ → ℝ) (f : ℝ → ℝ)
|
| 17 |
+
(hf : f = fun x : ℝ =>
|
| 18 |
+
∑ k ∈ Finset.Icc 0 n, (a k * Real.sin (k * x) + b k * Real.cos (k * x))) :
|
| 19 |
+
∀ x : ℝ, f (x + 2 * π) = f x := by
|
| 20 |
+
intro x
|
| 21 |
+
rw [hf]
|
| 22 |
+
refine Finset.sum_congr rfl ?_
|
| 23 |
+
intro k _hk
|
| 24 |
+
have harg : (k : ℝ) * (x + 2 * π) = (k : ℝ) * x + k * (2 * π) := by
|
| 25 |
+
ring
|
| 26 |
+
simp [harg, Real.sin_add_nat_mul_two_pi, Real.cos_add_nat_mul_two_pi]
|
| 27 |
+
|
| 28 |
+
private lemma putnam_1962_b6_hasDerivAt_term
|
| 29 |
+
(a b : ℕ → ℝ) (k : ℕ) (x : ℝ) :
|
| 30 |
+
HasDerivAt (fun y : ℝ => a k * Real.sin (k * y) + b k * Real.cos (k * y))
|
| 31 |
+
(a k * ((k : ℝ) * Real.cos (k * x)) -
|
| 32 |
+
b k * ((k : ℝ) * Real.sin (k * x))) x := by
|
| 33 |
+
have hk : HasDerivAt (fun y : ℝ => (k : ℝ) * y) (k : ℝ) x := by
|
| 34 |
+
simpa using (hasDerivAt_id x).const_mul (k : ℝ)
|
| 35 |
+
have hsin : HasDerivAt (fun y : ℝ => Real.sin ((k : ℝ) * y))
|
| 36 |
+
(Real.cos ((k : ℝ) * x) * (k : ℝ)) x := hk.sin
|
| 37 |
+
have hcos : HasDerivAt (fun y : ℝ => Real.cos ((k : ℝ) * y))
|
| 38 |
+
(-Real.sin ((k : ℝ) * x) * (k : ℝ)) x := hk.cos
|
| 39 |
+
have h := (hsin.const_mul (a k)).add (hcos.const_mul (b k))
|
| 40 |
+
simpa [sub_eq_add_neg, mul_comm, mul_left_comm, mul_assoc] using h
|
| 41 |
+
|
| 42 |
+
private lemma putnam_1962_b6_hasDerivAt_sum
|
| 43 |
+
(n : ℕ) (a b : ℕ → ℝ) (x : ℝ) :
|
| 44 |
+
HasDerivAt
|
| 45 |
+
(fun y : ℝ => ∑ k ∈ Finset.Icc 0 n,
|
| 46 |
+
(a k * Real.sin (k * y) + b k * Real.cos (k * y)))
|
| 47 |
+
(∑ k ∈ Finset.Icc 0 n,
|
| 48 |
+
(a k * ((k : ℝ) * Real.cos (k * x)) -
|
| 49 |
+
b k * ((k : ℝ) * Real.sin (k * x)))) x := by
|
| 50 |
+
simpa only [Finset.sum_apply] using
|
| 51 |
+
(HasDerivAt.fun_sum (u := Finset.Icc 0 n)
|
| 52 |
+
(fun k _hk => putnam_1962_b6_hasDerivAt_term a b k x))
|
| 53 |
+
|
| 54 |
+
private lemma putnam_1962_b6_deriv
|
| 55 |
+
(n : ℕ) (a b : ℕ → ℝ) (f : ℝ → ℝ)
|
| 56 |
+
(hf : f = fun x : ℝ => ∑ k ∈ Finset.Icc 0 n,
|
| 57 |
+
(a k * Real.sin (k * x) + b k * Real.cos (k * x))) :
|
| 58 |
+
∀ x : ℝ, deriv f x = ∑ k ∈ Finset.Icc 0 n,
|
| 59 |
+
(a k * ((k : ℝ) * Real.cos (k * x)) -
|
| 60 |
+
b k * ((k : ℝ) * Real.sin (k * x))) := by
|
| 61 |
+
intro x
|
| 62 |
+
rw [hf]
|
| 63 |
+
exact (putnam_1962_b6_hasDerivAt_sum n a b x).deriv
|
| 64 |
+
|
| 65 |
+
private lemma putnam_1962_b6_differentiable
|
| 66 |
+
(n : ℕ) (a b : ℕ → ℝ) (f : ℝ → ℝ)
|
| 67 |
+
(hf : f = fun x : ℝ => ∑ k ∈ Finset.Icc 0 n,
|
| 68 |
+
(a k * Real.sin (k * x) + b k * Real.cos (k * x))) :
|
| 69 |
+
Differentiable ℝ f := by
|
| 70 |
+
intro x
|
| 71 |
+
rw [hf]
|
| 72 |
+
exact (putnam_1962_b6_hasDerivAt_sum n a b x).differentiableAt
|
| 73 |
+
|
| 74 |
+
private lemma putnam_1962_b6_deriv_eq_zero_of_contact_interior
|
| 75 |
+
(f : ℝ → ℝ)
|
| 76 |
+
(hf1 : ∀ y ∈ Set.Icc 0 (2 * π), |f y| ≤ 1)
|
| 77 |
+
{x : ℝ} (hxI : x ∈ Set.Ioo 0 (2 * π))
|
| 78 |
+
(hxabs : |f x| = 1) :
|
| 79 |
+
deriv f x = 0 := by
|
| 80 |
+
have hnhds : Set.Ioo 0 (2 * π) ∈ nhds x := isOpen_Ioo.mem_nhds hxI
|
| 81 |
+
have hx_cases : f x = 1 ∨ f x = -1 := by
|
| 82 |
+
exact (abs_eq (show (0 : ℝ) ≤ 1 by norm_num)).mp hxabs
|
| 83 |
+
rcases hx_cases with hxone | hxneg
|
| 84 |
+
· have hmax : IsLocalMax f x := by
|
| 85 |
+
filter_upwards [hnhds] with y hy
|
| 86 |
+
have hycc : y ∈ Set.Icc 0 (2 * π) := ⟨le_of_lt hy.1, le_of_lt hy.2⟩
|
| 87 |
+
have hyb := (abs_le.mp (hf1 y hycc)).2
|
| 88 |
+
simpa [hxone] using hyb
|
| 89 |
+
exact hmax.deriv_eq_zero
|
| 90 |
+
· have hmin : IsLocalMin f x := by
|
| 91 |
+
filter_upwards [hnhds] with y hy
|
| 92 |
+
have hycc : y ∈ Set.Icc 0 (2 * π) := ⟨le_of_lt hy.1, le_of_lt hy.2⟩
|
| 93 |
+
have hyb := (abs_le.mp (hf1 y hycc)).1
|
| 94 |
+
have : -1 ≤ f y := by
|
| 95 |
+
simpa using hyb
|
| 96 |
+
simpa [hxneg] using this
|
| 97 |
+
exact hmin.deriv_eq_zero
|
| 98 |
+
|
| 99 |
+
private lemma putnam_1962_b6_deriv_eq_zero_of_contact_zero
|
| 100 |
+
(f : ℝ → ℝ)
|
| 101 |
+
(hper : ∀ y : ℝ, f (y + 2 * π) = f y)
|
| 102 |
+
(hf1 : ∀ y ∈ Set.Icc 0 (2 * π), |f y| ≤ 1)
|
| 103 |
+
(h0abs : |f 0| = 1) :
|
| 104 |
+
deriv f 0 = 0 := by
|
| 105 |
+
have htwopi_pos : 0 < 2 * π := by
|
| 106 |
+
positivity
|
| 107 |
+
have hnhds : Set.Ioo (-(2 * π)) (2 * π) ∈ nhds (0 : ℝ) := by
|
| 108 |
+
exact isOpen_Ioo.mem_nhds ⟨by linarith, htwopi_pos⟩
|
| 109 |
+
have bound_near : ∀ᶠ y in nhds (0 : ℝ), |f y| ≤ 1 := by
|
| 110 |
+
filter_upwards [hnhds] with y hy
|
| 111 |
+
by_cases hy0 : 0 ≤ y
|
| 112 |
+
· have hycc : y ∈ Set.Icc 0 (2 * π) := ⟨hy0, le_of_lt hy.2⟩
|
| 113 |
+
exact hf1 y hycc
|
| 114 |
+
· have hylt : y < 0 := lt_of_not_ge hy0
|
| 115 |
+
have hyleft : -(2 * π) < y := hy.1
|
| 116 |
+
have hycc : y + 2 * π ∈ Set.Icc 0 (2 * π) := by
|
| 117 |
+
constructor <;> linarith
|
| 118 |
+
have hb := hf1 (y + 2 * π) hycc
|
| 119 |
+
simpa [hper y] using hb
|
| 120 |
+
have h0_cases : f 0 = 1 ∨ f 0 = -1 := by
|
| 121 |
+
exact (abs_eq (show (0 : ℝ) ≤ 1 by norm_num)).mp h0abs
|
| 122 |
+
rcases h0_cases with h0one | h0neg
|
| 123 |
+
· have hmax : IsLocalMax f 0 := by
|
| 124 |
+
filter_upwards [bound_near] with y hy
|
| 125 |
+
exact (abs_le.mp hy).2.trans_eq h0one.symm
|
| 126 |
+
exact hmax.deriv_eq_zero
|
| 127 |
+
· have hmin : IsLocalMin f 0 := by
|
| 128 |
+
filter_upwards [bound_near] with y hy
|
| 129 |
+
have hle := (abs_le.mp hy).1
|
| 130 |
+
have : -1 ≤ f y := by
|
| 131 |
+
simpa using hle
|
| 132 |
+
exact h0neg.symm ▸ this
|
| 133 |
+
exact hmin.deriv_eq_zero
|
| 134 |
+
|
| 135 |
+
private lemma putnam_1962_b6_deriv_eq_zero_of_contact
|
| 136 |
+
(f : ℝ → ℝ)
|
| 137 |
+
(hper : ∀ y : ℝ, f (y + 2 * π) = f y)
|
| 138 |
+
(hf1 : ∀ y ∈ Set.Icc 0 (2 * π), |f y| ≤ 1)
|
| 139 |
+
{x : ℝ} (hxIco : x ∈ Set.Ico 0 (2 * π))
|
| 140 |
+
(hxabs : |f x| = 1) :
|
| 141 |
+
deriv f x = 0 := by
|
| 142 |
+
by_cases hx0 : x = 0
|
| 143 |
+
· subst x
|
| 144 |
+
exact putnam_1962_b6_deriv_eq_zero_of_contact_zero f hper hf1 hxabs
|
| 145 |
+
· have hxpos : 0 < x := lt_of_le_of_ne hxIco.1 (Ne.symm hx0)
|
| 146 |
+
exact putnam_1962_b6_deriv_eq_zero_of_contact_interior f hf1
|
| 147 |
+
⟨hxpos, hxIco.2⟩ hxabs
|
| 148 |
+
|
| 149 |
+
private noncomputable def putnam_1962_b6_complexPoly
|
| 150 |
+
(n : ℕ) (A B : ℕ → ℝ) : Polynomial ℂ :=
|
| 151 |
+
∑ k ∈ Finset.Icc 0 n,
|
| 152 |
+
(Polynomial.C (((B k : ℂ) - Complex.I * (A k : ℂ)) / 2) * Polynomial.X ^ (n + k) +
|
| 153 |
+
Polynomial.C (((B k : ℂ) + Complex.I * (A k : ℂ)) / 2) * Polynomial.X ^ (n - k))
|
| 154 |
+
|
| 155 |
+
private lemma putnam_1962_b6_trig_to_exp
|
| 156 |
+
(A B : ℝ) (k : ℕ) (x : ℝ) :
|
| 157 |
+
(A : ℂ) * (Real.sin (k * x) : ℂ) + (B : ℂ) * (Real.cos (k * x) : ℂ) =
|
| 158 |
+
(((B : ℂ) - Complex.I * (A : ℂ)) / 2) *
|
| 159 |
+
Complex.exp (((k : ℝ) * x) * Complex.I) +
|
| 160 |
+
(((B : ℂ) + Complex.I * (A : ℂ)) / 2) *
|
| 161 |
+
Complex.exp (-(((k : ℝ) * x) * Complex.I)) := by
|
| 162 |
+
rw [Complex.ofReal_sin, Complex.ofReal_cos]
|
| 163 |
+
simp [Complex.sin, Complex.cos]
|
| 164 |
+
ring
|
| 165 |
+
|
| 166 |
+
private lemma putnam_1962_b6_exp_pow (m : ℕ) (x : ℝ) :
|
| 167 |
+
(Complex.exp (x * Complex.I)) ^ m =
|
| 168 |
+
Complex.exp (((m : ℝ) * x) * Complex.I) := by
|
| 169 |
+
rw [← Complex.exp_nat_mul]
|
| 170 |
+
congr 1
|
| 171 |
+
push_cast
|
| 172 |
+
ring
|
| 173 |
+
|
| 174 |
+
private lemma putnam_1962_b6_complexPoly_eval_term
|
| 175 |
+
{n k : ℕ} (hk : k ≤ n) (A B : ℝ) (x : ℝ) :
|
| 176 |
+
(((B : ℂ) - Complex.I * (A : ℂ)) / 2) *
|
| 177 |
+
(Complex.exp (x * Complex.I)) ^ (n + k) +
|
| 178 |
+
(((B : ℂ) + Complex.I * (A : ℂ)) / 2) *
|
| 179 |
+
(Complex.exp (x * Complex.I)) ^ (n - k) =
|
| 180 |
+
(Complex.exp (x * Complex.I)) ^ n *
|
| 181 |
+
((A : ℂ) * (Real.sin (k * x) : ℂ) +
|
| 182 |
+
(B : ℂ) * (Real.cos (k * x) : ℂ)) := by
|
| 183 |
+
rw [putnam_1962_b6_trig_to_exp A B k x]
|
| 184 |
+
repeat rw [putnam_1962_b6_exp_pow]
|
| 185 |
+
have h1 : Complex.exp (((n + k : ℕ) : ℝ) * x * Complex.I) =
|
| 186 |
+
Complex.exp (((n : ℕ) : ℝ) * x * Complex.I) *
|
| 187 |
+
Complex.exp (((k : ℕ) : ℝ) * x * Complex.I) := by
|
| 188 |
+
rw [← Complex.exp_add]
|
| 189 |
+
congr 1
|
| 190 |
+
push_cast
|
| 191 |
+
ring
|
| 192 |
+
have h2 : Complex.exp (((n - k : ℕ) : ℝ) * x * Complex.I) =
|
| 193 |
+
Complex.exp (((n : ℕ) : ℝ) * x * Complex.I) *
|
| 194 |
+
Complex.exp (-(((k : ℕ) : ℝ) * x * Complex.I)) := by
|
| 195 |
+
rw [← Complex.exp_add]
|
| 196 |
+
congr 1
|
| 197 |
+
norm_num [Nat.cast_sub hk]
|
| 198 |
+
ring
|
| 199 |
+
rw [h1, h2]
|
| 200 |
+
ring
|
| 201 |
+
|
| 202 |
+
private lemma putnam_1962_b6_complexPoly_eval
|
| 203 |
+
(n : ℕ) (A B : ℕ → ℝ) (x : ℝ) :
|
| 204 |
+
(putnam_1962_b6_complexPoly n A B).eval (Complex.exp (x * Complex.I)) =
|
| 205 |
+
(Complex.exp (x * Complex.I)) ^ n *
|
| 206 |
+
(∑ k ∈ Finset.Icc 0 n,
|
| 207 |
+
((A k : ℂ) * (Real.sin (k * x) : ℂ) +
|
| 208 |
+
(B k : ℂ) * (Real.cos (k * x) : ℂ))) := by
|
| 209 |
+
simp only [putnam_1962_b6_complexPoly, Polynomial.eval_finset_sum,
|
| 210 |
+
Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_pow,
|
| 211 |
+
Polynomial.eval_X]
|
| 212 |
+
rw [Finset.mul_sum]
|
| 213 |
+
refine Finset.sum_congr rfl ?_
|
| 214 |
+
intro k hk
|
| 215 |
+
have hk_le : k ≤ n := (Finset.mem_Icc.mp hk).2
|
| 216 |
+
exact putnam_1962_b6_complexPoly_eval_term hk_le (A k) (B k) x
|
| 217 |
+
|
| 218 |
+
private lemma putnam_1962_b6_complexPoly_natDegree_le
|
| 219 |
+
(n : ℕ) (A B : ℕ → ℝ) :
|
| 220 |
+
(putnam_1962_b6_complexPoly n A B).natDegree ≤ 2 * n := by
|
| 221 |
+
dsimp [putnam_1962_b6_complexPoly]
|
| 222 |
+
refine Polynomial.natDegree_sum_le_of_forall_le (Finset.Icc 0 n)
|
| 223 |
+
(f := fun k =>
|
| 224 |
+
Polynomial.C (((B k : ℂ) - Complex.I * (A k : ℂ)) / 2) * Polynomial.X ^ (n + k) +
|
| 225 |
+
Polynomial.C (((B k : ℂ) + Complex.I * (A k : ℂ)) / 2) * Polynomial.X ^ (n - k)) ?_
|
| 226 |
+
intro k hk
|
| 227 |
+
have hk_le : k ≤ n := (Finset.mem_Icc.mp hk).2
|
| 228 |
+
have hleft :
|
| 229 |
+
(Polynomial.C (((B k : ℂ) - Complex.I * (A k : ℂ)) / 2) *
|
| 230 |
+
Polynomial.X ^ (n + k)).natDegree ≤ 2 * n := by
|
| 231 |
+
exact (Polynomial.natDegree_C_mul_X_pow_le
|
| 232 |
+
(((B k : ℂ) - Complex.I * (A k : ℂ)) / 2) (n + k)).trans (by omega)
|
| 233 |
+
have hright :
|
| 234 |
+
(Polynomial.C (((B k : ℂ) + Complex.I * (A k : ℂ)) / 2) *
|
| 235 |
+
Polynomial.X ^ (n - k)).natDegree ≤ 2 * n := by
|
| 236 |
+
exact (Polynomial.natDegree_C_mul_X_pow_le
|
| 237 |
+
(((B k : ℂ) + Complex.I * (A k : ℂ)) / 2) (n - k)).trans (by omega)
|
| 238 |
+
exact (Polynomial.natDegree_add_le _ _).trans (max_le hleft hright)
|
| 239 |
+
|
| 240 |
+
private lemma putnam_1962_b6_complexPoly_coeff_two_mul
|
| 241 |
+
{n : ℕ} (hnpos : 0 < n) (A B : ℕ → ℝ) :
|
| 242 |
+
(putnam_1962_b6_complexPoly n A B).coeff (2 * n) =
|
| 243 |
+
(((B n : ℂ) - Complex.I * (A n : ℂ)) / 2) := by
|
| 244 |
+
dsimp [putnam_1962_b6_complexPoly]
|
| 245 |
+
rw [Polynomial.finset_sum_coeff]
|
| 246 |
+
rw [Finset.sum_eq_single_of_mem n (Finset.mem_Icc.mpr ⟨Nat.zero_le n, le_rfl⟩)]
|
| 247 |
+
· simp [Polynomial.coeff_add, Polynomial.coeff_C, two_mul, Nat.ne_of_gt hnpos]
|
| 248 |
+
· intro k hk hkn
|
| 249 |
+
have hleft : 2 * n ≠ n + k := by omega
|
| 250 |
+
have hright : 2 * n ≠ n - k := by omega
|
| 251 |
+
simp [Polynomial.coeff_add, hleft, hright]
|
| 252 |
+
|
| 253 |
+
private lemma putnam_1962_b6_complexPoly_coeff_zero
|
| 254 |
+
{n : ℕ} (hnpos : 0 < n) (A B : ℕ → ℝ) :
|
| 255 |
+
(putnam_1962_b6_complexPoly n A B).coeff 0 =
|
| 256 |
+
(((B n : ℂ) + Complex.I * (A n : ℂ)) / 2) := by
|
| 257 |
+
dsimp [putnam_1962_b6_complexPoly]
|
| 258 |
+
rw [Polynomial.finset_sum_coeff]
|
| 259 |
+
rw [Finset.sum_eq_single_of_mem n (Finset.mem_Icc.mpr ⟨Nat.zero_le n, le_rfl⟩)]
|
| 260 |
+
· have hleft : 0 ≠ n + n := by omega
|
| 261 |
+
simp [Polynomial.coeff_add, hleft]
|
| 262 |
+
· intro k hk hkn
|
| 263 |
+
have hk_le : k ≤ n := (Finset.mem_Icc.mp hk).2
|
| 264 |
+
have hleft : 0 ≠ n + k := by omega
|
| 265 |
+
have hright : 0 ≠ n - k := by
|
| 266 |
+
have hklt : k < n := lt_of_le_of_ne hk_le hkn
|
| 267 |
+
omega
|
| 268 |
+
simp [Polynomial.coeff_add, hleft, hright]
|
| 269 |
+
|
| 270 |
+
private lemma putnam_1962_b6_z_mul_derivative_pow_eval
|
| 271 |
+
(m : ℕ) (z : ℂ) :
|
| 272 |
+
z * ((m : ℂ) * z ^ (m - 1)) = (m : ℂ) * z ^ m := by
|
| 273 |
+
cases m with
|
| 274 |
+
| zero => simp
|
| 275 |
+
| succ m =>
|
| 276 |
+
simp only [Nat.succ_sub_one]
|
| 277 |
+
rw [pow_succ]
|
| 278 |
+
ring
|
| 279 |
+
|
| 280 |
+
private lemma putnam_1962_b6_complexPoly_derivative_relation_eval
|
| 281 |
+
(n : ℕ) (A B : ℕ → ℝ) (z : ℂ) :
|
| 282 |
+
(putnam_1962_b6_complexPoly n
|
| 283 |
+
(fun k => -(B k * (k : ℝ))) (fun k => A k * (k : ℝ))).eval z =
|
| 284 |
+
Complex.I * (z * (putnam_1962_b6_complexPoly n A B).derivative.eval z -
|
| 285 |
+
(n : ℂ) * (putnam_1962_b6_complexPoly n A B).eval z) := by
|
| 286 |
+
simp only [putnam_1962_b6_complexPoly, Polynomial.eval_finset_sum,
|
| 287 |
+
Polynomial.derivative_sum, Polynomial.derivative_add,
|
| 288 |
+
Polynomial.derivative_C_mul_X_pow, Polynomial.eval_add, Polynomial.eval_mul,
|
| 289 |
+
Polynomial.eval_C, Polynomial.eval_pow, Polynomial.eval_X]
|
| 290 |
+
rw [Finset.mul_sum, Finset.mul_sum, ← Finset.sum_sub_distrib, Finset.mul_sum]
|
| 291 |
+
refine Finset.sum_congr rfl ?_
|
| 292 |
+
intro k hk
|
| 293 |
+
have hk_le : k ≤ n := (Finset.mem_Icc.mp hk).2
|
| 294 |
+
have hpow_add :
|
| 295 |
+
z * (((n + k : ℕ) : ℂ) * z ^ (n + k - 1)) =
|
| 296 |
+
((n + k : ℕ) : ℂ) * z ^ (n + k) :=
|
| 297 |
+
putnam_1962_b6_z_mul_derivative_pow_eval (n + k) z
|
| 298 |
+
have hpow_sub :
|
| 299 |
+
z * (((n - k : ℕ) : ℂ) * z ^ (n - k - 1)) =
|
| 300 |
+
((n - k : ℕ) : ℂ) * z ^ (n - k) :=
|
| 301 |
+
putnam_1962_b6_z_mul_derivative_pow_eval (n - k) z
|
| 302 |
+
have hpow_add_coeff (c : ℂ) :
|
| 303 |
+
z * (c * ((n + k : ℕ) : ℂ) * z ^ (n + k - 1)) =
|
| 304 |
+
c * (((n + k : ℕ) : ℂ) * z ^ (n + k)) := by
|
| 305 |
+
calc
|
| 306 |
+
z * (c * ((n + k : ℕ) : ℂ) * z ^ (n + k - 1)) =
|
| 307 |
+
c * (z * (((n + k : ℕ) : ℂ) * z ^ (n + k - 1))) := by ring
|
| 308 |
+
_ = c * (((n + k : ℕ) : ℂ) * z ^ (n + k)) := by rw [hpow_add]
|
| 309 |
+
have hpow_sub_coeff (c : ℂ) :
|
| 310 |
+
z * (c * ((n - k : ℕ) : ℂ) * z ^ (n - k - 1)) =
|
| 311 |
+
c * (((n - k : ℕ) : ℂ) * z ^ (n - k)) := by
|
| 312 |
+
calc
|
| 313 |
+
z * (c * ((n - k : ℕ) : ℂ) * z ^ (n - k - 1)) =
|
| 314 |
+
c * (z * (((n - k : ℕ) : ℂ) * z ^ (n - k - 1))) := by ring
|
| 315 |
+
_ = c * (((n - k : ℕ) : ℂ) * z ^ (n - k)) := by rw [hpow_sub]
|
| 316 |
+
rw [mul_add, hpow_add_coeff, hpow_sub_coeff]
|
| 317 |
+
norm_num [Nat.cast_sub hk_le]
|
| 318 |
+
ring_nf
|
| 319 |
+
rw [Complex.I_sq]
|
| 320 |
+
ring_nf
|
| 321 |
+
|
| 322 |
+
private lemma putnam_1962_b6_complexPoly_derivative_relation_poly
|
| 323 |
+
(n : ℕ) (A B : ℕ → ℝ) :
|
| 324 |
+
putnam_1962_b6_complexPoly n
|
| 325 |
+
(fun k => -(B k * (k : ℝ))) (fun k => A k * (k : ℝ)) =
|
| 326 |
+
Polynomial.C Complex.I *
|
| 327 |
+
(Polynomial.X * (putnam_1962_b6_complexPoly n A B).derivative -
|
| 328 |
+
Polynomial.C (n : ℂ) * putnam_1962_b6_complexPoly n A B) := by
|
| 329 |
+
apply Polynomial.funext
|
| 330 |
+
intro z
|
| 331 |
+
simpa [Polynomial.eval_mul, Polynomial.eval_sub, Polynomial.eval_C, Polynomial.eval_X] using
|
| 332 |
+
putnam_1962_b6_complexPoly_derivative_relation_eval n A B z
|
| 333 |
+
|
| 334 |
+
private noncomputable def putnam_1962_b6_oneSubSqPoly
|
| 335 |
+
(n : ℕ) (A B : ℕ → ℝ) : Polynomial ℂ :=
|
| 336 |
+
Polynomial.X ^ (2 * n) - (putnam_1962_b6_complexPoly n A B) ^ 2
|
| 337 |
+
|
| 338 |
+
private lemma putnam_1962_b6_oneSubSqPoly_eval
|
| 339 |
+
(n : ℕ) (A B : ℕ → ℝ) (x : ℝ) :
|
| 340 |
+
(putnam_1962_b6_oneSubSqPoly n A B).eval (Complex.exp (x * Complex.I)) =
|
| 341 |
+
(Complex.exp (x * Complex.I)) ^ (2 * n) *
|
| 342 |
+
(1 - (∑ k ∈ Finset.Icc 0 n,
|
| 343 |
+
((A k : ℂ) * (Real.sin (k * x) : ℂ) +
|
| 344 |
+
(B k : ℂ) * (Real.cos (k * x) : ℂ))) ^ 2) := by
|
| 345 |
+
simp only [putnam_1962_b6_oneSubSqPoly, Polynomial.eval_sub,
|
| 346 |
+
Polynomial.eval_pow, Polynomial.eval_X]
|
| 347 |
+
rw [putnam_1962_b6_complexPoly_eval]
|
| 348 |
+
set z := Complex.exp (x * Complex.I)
|
| 349 |
+
set S := ∑ k ∈ Finset.Icc 0 n,
|
| 350 |
+
((A k : ℂ) * (Real.sin (k * x) : ℂ) +
|
| 351 |
+
(B k : ℂ) * (Real.cos (k * x) : ℂ))
|
| 352 |
+
calc
|
| 353 |
+
z ^ (2 * n) - (z ^ n * S) ^ 2 =
|
| 354 |
+
z ^ (2 * n) - (z ^ n * z ^ n) * S ^ 2 := by ring
|
| 355 |
+
_ = z ^ (2 * n) * (1 - S ^ 2) := by
|
| 356 |
+
rw [← pow_add]
|
| 357 |
+
have hpow : n + n = 2 * n := by omega
|
| 358 |
+
rw [hpow]
|
| 359 |
+
ring
|
| 360 |
+
|
| 361 |
+
private lemma putnam_1962_b6_oneSubSqPoly_natDegree_le
|
| 362 |
+
(n : ℕ) (A B : ℕ → ℝ) :
|
| 363 |
+
(putnam_1962_b6_oneSubSqPoly n A B).natDegree ≤ 4 * n := by
|
| 364 |
+
dsimp [putnam_1962_b6_oneSubSqPoly]
|
| 365 |
+
have hX : (Polynomial.X ^ (2 * n) : Polynomial ℂ).natDegree ≤ 4 * n := by
|
| 366 |
+
rw [Polynomial.natDegree_X_pow]
|
| 367 |
+
omega
|
| 368 |
+
have hF :
|
| 369 |
+
((putnam_1962_b6_complexPoly n A B) ^ 2).natDegree ≤ 4 * n := by
|
| 370 |
+
have hpow := Polynomial.natDegree_pow_le_of_le (p := putnam_1962_b6_complexPoly n A B)
|
| 371 |
+
2 (putnam_1962_b6_complexPoly_natDegree_le n A B)
|
| 372 |
+
exact hpow.trans (by omega)
|
| 373 |
+
exact (Polynomial.natDegree_sub_le _ _).trans (max_le hX hF)
|
| 374 |
+
|
| 375 |
+
private lemma putnam_1962_b6_oneSubSqPoly_eq_zero_of_contact
|
| 376 |
+
(n : ℕ) (a b : ℕ → ℝ) (f : ℝ → ℝ)
|
| 377 |
+
(hf : f = fun x : ℝ => ∑ k ∈ Finset.Icc 0 n,
|
| 378 |
+
(a k * Real.sin (k * x) + b k * Real.cos (k * x)))
|
| 379 |
+
{x : ℝ} (hxabs : |f x| = 1) :
|
| 380 |
+
(putnam_1962_b6_oneSubSqPoly n a b).eval (Complex.exp (x * Complex.I)) = 0 := by
|
| 381 |
+
rw [putnam_1962_b6_oneSubSqPoly_eval]
|
| 382 |
+
have hsum_real :
|
| 383 |
+
∑ k ∈ Finset.Icc 0 n,
|
| 384 |
+
(a k * Real.sin (k * x) + b k * Real.cos (k * x)) = f x := by
|
| 385 |
+
rw [hf]
|
| 386 |
+
have hsum_complex :
|
| 387 |
+
(∑ k ∈ Finset.Icc 0 n,
|
| 388 |
+
((a k : ℂ) * (Real.sin (k * x) : ℂ) +
|
| 389 |
+
(b k : ℂ) * (Real.cos (k * x) : ℂ))) = (f x : ℂ) := by
|
| 390 |
+
rw [← hsum_real]
|
| 391 |
+
push_cast
|
| 392 |
+
rfl
|
| 393 |
+
have hfx_sq : f x ^ 2 = 1 := by
|
| 394 |
+
rcases (abs_eq (show (0 : ℝ) ≤ 1 by norm_num)).mp hxabs with hfx | hfx <;>
|
| 395 |
+
simp [hfx]
|
| 396 |
+
have hsum_sq :
|
| 397 |
+
(∑ k ∈ Finset.Icc 0 n,
|
| 398 |
+
((a k : ℂ) * (Real.sin (k * x) : ℂ) +
|
| 399 |
+
(b k : ℂ) * (Real.cos (k * x) : ℂ))) ^ 2 = 1 := by
|
| 400 |
+
rw [hsum_complex]
|
| 401 |
+
exact_mod_cast hfx_sq
|
| 402 |
+
rw [hsum_sq]
|
| 403 |
+
ring
|
| 404 |
+
|
| 405 |
+
private lemma putnam_1962_b6_oneSubSqPoly_derivative_eq_zero_of_contact
|
| 406 |
+
(n : ℕ) (a b : ℕ → ℝ) {z : ℂ}
|
| 407 |
+
(hz : z ≠ 0)
|
| 408 |
+
(hcontact :
|
| 409 |
+
(putnam_1962_b6_oneSubSqPoly n a b).eval z = 0)
|
| 410 |
+
(hderiv :
|
| 411 |
+
(putnam_1962_b6_complexPoly n
|
| 412 |
+
(fun k => -(b k * (k : ℝ))) (fun k => a k * (k : ℝ))).eval z = 0) :
|
| 413 |
+
(putnam_1962_b6_oneSubSqPoly n a b).derivative.eval z = 0 := by
|
| 414 |
+
let F := putnam_1962_b6_complexPoly n a b
|
| 415 |
+
have hrel := putnam_1962_b6_complexPoly_derivative_relation_eval n a b z
|
| 416 |
+
have hzdiff : z * F.derivative.eval z - (n : ℂ) * F.eval z = 0 := by
|
| 417 |
+
have hmul :
|
| 418 |
+
Complex.I * (z * F.derivative.eval z - (n : ℂ) * F.eval z) = 0 := by
|
| 419 |
+
rw [← hrel]
|
| 420 |
+
exact hderiv
|
| 421 |
+
exact (mul_eq_zero.mp hmul).resolve_left Complex.I_ne_zero
|
| 422 |
+
have hzFderiv : z * F.derivative.eval z = (n : ℂ) * F.eval z := by
|
| 423 |
+
exact sub_eq_zero.mp hzdiff
|
| 424 |
+
have hFsq : F.eval z ^ 2 = z ^ (2 * n) := by
|
| 425 |
+
have htmp : z ^ (2 * n) - F.eval z ^ 2 = 0 := by
|
| 426 |
+
simpa [putnam_1962_b6_oneSubSqPoly, F] using hcontact
|
| 427 |
+
exact (sub_eq_zero.mp htmp).symm
|
| 428 |
+
have hz_deriv :
|
| 429 |
+
z * (putnam_1962_b6_oneSubSqPoly n a b).derivative.eval z = 0 := by
|
| 430 |
+
simp only [putnam_1962_b6_oneSubSqPoly, Polynomial.derivative_sub,
|
| 431 |
+
Polynomial.derivative_pow, Polynomial.derivative_X, Polynomial.eval_sub,
|
| 432 |
+
Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_pow, Polynomial.eval_X,
|
| 433 |
+
Polynomial.eval_one]
|
| 434 |
+
rw [show (2 : ℕ) - 1 = 1 by norm_num, pow_one]
|
| 435 |
+
simp only [mul_one]
|
| 436 |
+
change z *
|
| 437 |
+
(((2 * n : ℕ) : ℂ) * z ^ (2 * n - 1) -
|
| 438 |
+
((2 : ℂ) * F.eval z * F.derivative.eval z)) = 0
|
| 439 |
+
rw [mul_sub, putnam_1962_b6_z_mul_derivative_pow_eval (2 * n) z]
|
| 440 |
+
rw [show z * ((2 : ℂ) * F.eval z * F.derivative.eval z) =
|
| 441 |
+
(2 : ℂ) * F.eval z * (z * F.derivative.eval z) by ring]
|
| 442 |
+
rw [hzFderiv]
|
| 443 |
+
rw [← hFsq]
|
| 444 |
+
norm_num
|
| 445 |
+
ring
|
| 446 |
+
exact (mul_eq_zero.mp hz_deriv).resolve_left hz
|
| 447 |
+
|
| 448 |
+
private lemma putnam_1962_b6_constant_of_forall_sq_one
|
| 449 |
+
(n : ℕ) (a b : ℕ → ℝ) (f : ℝ → ℝ)
|
| 450 |
+
(hf : f = fun x : ℝ => ∑ k ∈ Finset.Icc 0 n,
|
| 451 |
+
(a k * Real.sin (k * x) + b k * Real.cos (k * x)))
|
| 452 |
+
(hsq : ∀ x : ℝ, f x ^ 2 = 1) :
|
| 453 |
+
∃ c : ℝ, f = fun _ : ℝ => c := by
|
| 454 |
+
have hcont : ContinuousOn f Set.univ :=
|
| 455 |
+
(putnam_1962_b6_differentiable n a b f hf).continuous.continuousOn
|
| 456 |
+
have hsq_on : Set.EqOn (f ^ 2) 1 Set.univ := by
|
| 457 |
+
intro x _hx
|
| 458 |
+
exact hsq x
|
| 459 |
+
rcases isPreconnected_univ.eq_one_or_eq_neg_one_of_sq_eq hcont hsq_on with hone | hneg
|
| 460 |
+
· refine ⟨1, ?_⟩
|
| 461 |
+
funext x
|
| 462 |
+
exact hone trivial
|
| 463 |
+
· refine ⟨-1, ?_⟩
|
| 464 |
+
funext x
|
| 465 |
+
exact hneg trivial
|
| 466 |
+
|
| 467 |
+
private lemma putnam_1962_b6_constant_of_oneSubSqPoly_zero
|
| 468 |
+
(n : ℕ) (a b : ℕ → ℝ) (f : ℝ → ℝ)
|
| 469 |
+
(hf : f = fun x : ℝ => ∑ k ∈ Finset.Icc 0 n,
|
| 470 |
+
(a k * Real.sin (k * x) + b k * Real.cos (k * x)))
|
| 471 |
+
(hpoly : putnam_1962_b6_oneSubSqPoly n a b = 0) :
|
| 472 |
+
∃ c : ℝ, f = fun _ : ℝ => c := by
|
| 473 |
+
apply putnam_1962_b6_constant_of_forall_sq_one n a b f hf
|
| 474 |
+
intro x
|
| 475 |
+
have heval :
|
| 476 |
+
(putnam_1962_b6_oneSubSqPoly n a b).eval (Complex.exp (x * Complex.I)) = 0 := by
|
| 477 |
+
rw [hpoly]
|
| 478 |
+
simp
|
| 479 |
+
rw [putnam_1962_b6_oneSubSqPoly_eval] at heval
|
| 480 |
+
have hexp_ne : (Complex.exp (x * Complex.I)) ^ (2 * n) ≠ 0 :=
|
| 481 |
+
pow_ne_zero _ (Complex.exp_ne_zero _)
|
| 482 |
+
have hfactor := (mul_eq_zero.mp heval).resolve_left hexp_ne
|
| 483 |
+
have hsum_real :
|
| 484 |
+
∑ k ∈ Finset.Icc 0 n,
|
| 485 |
+
(a k * Real.sin (k * x) + b k * Real.cos (k * x)) = f x := by
|
| 486 |
+
rw [hf]
|
| 487 |
+
have hsum_complex :
|
| 488 |
+
(∑ k ∈ Finset.Icc 0 n,
|
| 489 |
+
((a k : ℂ) * (Real.sin (k * x) : ℂ) +
|
| 490 |
+
(b k : ℂ) * (Real.cos (k * x) : ℂ))) = (f x : ℂ) := by
|
| 491 |
+
rw [← hsum_real]
|
| 492 |
+
push_cast
|
| 493 |
+
rfl
|
| 494 |
+
have hsq_complex : (f x : ℂ) ^ 2 = 1 := by
|
| 495 |
+
rw [← hsum_complex]
|
| 496 |
+
exact (sub_eq_zero.mp hfactor).symm
|
| 497 |
+
exact_mod_cast hsq_complex
|
| 498 |
+
|
| 499 |
+
private lemma putnam_1962_b6_two_le_rootMultiplicity_of_eval_derivative_eq_zero
|
| 500 |
+
{p : Polynomial ℂ} {z : ℂ} (hp : p ≠ 0)
|
| 501 |
+
(hpz : p.eval z = 0) (hdz : p.derivative.eval z = 0) :
|
| 502 |
+
2 ≤ p.rootMultiplicity z := by
|
| 503 |
+
have hlt : 1 < p.rootMultiplicity z := by
|
| 504 |
+
exact (Polynomial.one_lt_rootMultiplicity_iff_isRoot (p := p) (t := z) hp).2
|
| 505 |
+
⟨hpz, hdz⟩
|
| 506 |
+
omega
|
| 507 |
+
|
| 508 |
+
private lemma putnam_1962_b6_two_mul_card_le_natDegree_of_double_roots
|
| 509 |
+
{p : Polynomial ℂ} (s : Finset ℂ)
|
| 510 |
+
(hroot : ∀ z ∈ s, 2 ≤ p.rootMultiplicity z) :
|
| 511 |
+
2 * s.card ≤ p.natDegree := by
|
| 512 |
+
calc
|
| 513 |
+
2 * s.card = ∑ _z ∈ s, 2 := by simp [mul_comm]
|
| 514 |
+
_ ≤ ∑ z ∈ s, p.roots.count z := by
|
| 515 |
+
refine Finset.sum_le_sum ?_
|
| 516 |
+
intro z hz
|
| 517 |
+
simpa [Polynomial.count_roots] using hroot z hz
|
| 518 |
+
_ ≤ ∑ z ∈ p.roots.toFinset, p.roots.count z := by
|
| 519 |
+
refine Finset.sum_le_sum_of_subset_of_nonneg ?_ ?_
|
| 520 |
+
· intro z hz
|
| 521 |
+
rw [Multiset.mem_toFinset]
|
| 522 |
+
rw [← Multiset.count_pos]
|
| 523 |
+
exact lt_of_lt_of_le (by norm_num : 0 < 2) (by
|
| 524 |
+
simpa [Polynomial.count_roots] using hroot z hz)
|
| 525 |
+
· intro z _hzroot _hznot
|
| 526 |
+
exact Nat.zero_le _
|
| 527 |
+
_ = p.roots.card := by
|
| 528 |
+
exact Multiset.toFinset_sum_count_eq p.roots
|
| 529 |
+
_ ≤ p.natDegree := Polynomial.card_roots' p
|
| 530 |
+
|
| 531 |
+
private lemma putnam_1962_b6_eq_zero_of_natDegree_lt_two_mul_card_of_double_roots
|
| 532 |
+
{p : Polynomial ℂ} (s : Finset ℂ)
|
| 533 |
+
(hroot : ∀ z ∈ s, 2 ≤ p.rootMultiplicity z)
|
| 534 |
+
(hdeg : p.natDegree < 2 * s.card) :
|
| 535 |
+
p = 0 := by
|
| 536 |
+
have hle := putnam_1962_b6_two_mul_card_le_natDegree_of_double_roots
|
| 537 |
+
(p := p) s hroot
|
| 538 |
+
omega
|
| 539 |
+
|
| 540 |
+
private lemma putnam_1962_b6_scaled_eq_of_same_double_roots
|
| 541 |
+
{p q : Polynomial ℂ} (s : Finset ℂ)
|
| 542 |
+
(hp0 : p ≠ 0) (hq0 : q ≠ 0)
|
| 543 |
+
(hpdeg : p.natDegree = 2 * s.card)
|
| 544 |
+
(hqdeg : q.natDegree = 2 * s.card)
|
| 545 |
+
(hproot : ∀ z ∈ s, 2 ≤ p.rootMultiplicity z)
|
| 546 |
+
(hqroot : ∀ z ∈ s, 2 ≤ q.rootMultiplicity z) :
|
| 547 |
+
Polynomial.C q.leadingCoeff * p = Polynomial.C p.leadingCoeff * q := by
|
| 548 |
+
let r : Polynomial ℂ := Polynomial.C q.leadingCoeff * p - Polynomial.C p.leadingCoeff * q
|
| 549 |
+
have hp_lc_ne : p.leadingCoeff ≠ 0 := Polynomial.leadingCoeff_ne_zero.mpr hp0
|
| 550 |
+
have hq_lc_ne : q.leadingCoeff ≠ 0 := Polynomial.leadingCoeff_ne_zero.mpr hq0
|
| 551 |
+
have hp_scaled_ne : Polynomial.C q.leadingCoeff * p ≠ 0 := by
|
| 552 |
+
exact mul_ne_zero (Polynomial.C_ne_zero.mpr hq_lc_ne) hp0
|
| 553 |
+
have hq_scaled_ne : Polynomial.C p.leadingCoeff * q ≠ 0 := by
|
| 554 |
+
exact mul_ne_zero (Polynomial.C_ne_zero.mpr hp_lc_ne) hq0
|
| 555 |
+
have hp_scaled_degree :
|
| 556 |
+
(Polynomial.C q.leadingCoeff * p).degree = ((2 * s.card : ℕ) : WithBot ℕ) := by
|
| 557 |
+
rw [Polynomial.degree_C_mul hq_lc_ne, Polynomial.degree_eq_natDegree hp0, hpdeg]
|
| 558 |
+
have hq_scaled_degree :
|
| 559 |
+
(Polynomial.C p.leadingCoeff * q).degree = ((2 * s.card : ℕ) : WithBot ℕ) := by
|
| 560 |
+
rw [Polynomial.degree_C_mul hp_lc_ne, Polynomial.degree_eq_natDegree hq0, hqdeg]
|
| 561 |
+
have hp_scaled_lc :
|
| 562 |
+
(Polynomial.C q.leadingCoeff * p).leadingCoeff =
|
| 563 |
+
q.leadingCoeff * p.leadingCoeff := by
|
| 564 |
+
rw [Polynomial.leadingCoeff_mul']
|
| 565 |
+
· rw [Polynomial.leadingCoeff_C]
|
| 566 |
+
· simpa [Polynomial.leadingCoeff_C] using mul_ne_zero hq_lc_ne hp_lc_ne
|
| 567 |
+
have hq_scaled_lc :
|
| 568 |
+
(Polynomial.C p.leadingCoeff * q).leadingCoeff =
|
| 569 |
+
p.leadingCoeff * q.leadingCoeff := by
|
| 570 |
+
rw [Polynomial.leadingCoeff_mul']
|
| 571 |
+
· rw [Polynomial.leadingCoeff_C]
|
| 572 |
+
· simpa [Polynomial.leadingCoeff_C] using mul_ne_zero hp_lc_ne hq_lc_ne
|
| 573 |
+
have hr_degree_lt :
|
| 574 |
+
r.degree < ((2 * s.card : ℕ) : WithBot ℕ) := by
|
| 575 |
+
have h := Polynomial.degree_sub_lt
|
| 576 |
+
(p := Polynomial.C q.leadingCoeff * p)
|
| 577 |
+
(q := Polynomial.C p.leadingCoeff * q)
|
| 578 |
+
(by rw [hp_scaled_degree, hq_scaled_degree])
|
| 579 |
+
hp_scaled_ne
|
| 580 |
+
(by rw [hp_scaled_lc, hq_scaled_lc, mul_comm])
|
| 581 |
+
simpa [r, hp_scaled_degree] using h
|
| 582 |
+
have hr_eq_zero : r = 0 := by
|
| 583 |
+
by_contra hr0
|
| 584 |
+
have hr_natDegree_lt : r.natDegree < 2 * s.card := by
|
| 585 |
+
have hdeg := hr_degree_lt
|
| 586 |
+
rw [Polynomial.degree_eq_natDegree hr0] at hdeg
|
| 587 |
+
exact WithBot.coe_lt_coe.mp hdeg
|
| 588 |
+
have hr_double_roots :
|
| 589 |
+
∀ z ∈ s, 2 ≤ r.rootMultiplicity z := by
|
| 590 |
+
intro z hz
|
| 591 |
+
have hp_pair :
|
| 592 |
+
p.IsRoot z ∧ p.derivative.IsRoot z := by
|
| 593 |
+
exact (Polynomial.one_lt_rootMultiplicity_iff_isRoot hp0).mp
|
| 594 |
+
(lt_of_lt_of_le (by norm_num : 1 < 2) (hproot z hz))
|
| 595 |
+
have hq_pair :
|
| 596 |
+
q.IsRoot z ∧ q.derivative.IsRoot z := by
|
| 597 |
+
exact (Polynomial.one_lt_rootMultiplicity_iff_isRoot hq0).mp
|
| 598 |
+
(lt_of_lt_of_le (by norm_num : 1 < 2) (hqroot z hz))
|
| 599 |
+
have hp_eval : p.eval z = 0 := by
|
| 600 |
+
simpa [Polynomial.IsRoot.def] using hp_pair.1
|
| 601 |
+
have hq_eval : q.eval z = 0 := by
|
| 602 |
+
simpa [Polynomial.IsRoot.def] using hq_pair.1
|
| 603 |
+
have hp_deriv_eval : p.derivative.eval z = 0 := by
|
| 604 |
+
simpa [Polynomial.IsRoot.def] using hp_pair.2
|
| 605 |
+
have hq_deriv_eval : q.derivative.eval z = 0 := by
|
| 606 |
+
simpa [Polynomial.IsRoot.def] using hq_pair.2
|
| 607 |
+
have hr_eval : r.eval z = 0 := by
|
| 608 |
+
simp [r, hp_eval, hq_eval]
|
| 609 |
+
have hr_deriv_eval : r.derivative.eval z = 0 := by
|
| 610 |
+
simp [r, hp_deriv_eval, hq_deriv_eval]
|
| 611 |
+
exact putnam_1962_b6_two_le_rootMultiplicity_of_eval_derivative_eq_zero
|
| 612 |
+
hr0 hr_eval hr_deriv_eval
|
| 613 |
+
exact hr0 (putnam_1962_b6_eq_zero_of_natDegree_lt_two_mul_card_of_double_roots
|
| 614 |
+
s hr_double_roots hr_natDegree_lt)
|
| 615 |
+
exact sub_eq_zero.mp hr_eq_zero
|
| 616 |
+
|
| 617 |
+
private lemma putnam_1962_b6_coeff_sq_of_decomp_top
|
| 618 |
+
{L : Polynomial ℂ} {N d : ℕ} (c : ℂ)
|
| 619 |
+
(hdN : d < N) (hLdeg : L.natDegree ≤ d) :
|
| 620 |
+
((L + Polynomial.C c * Polynomial.X ^ N) ^ 2).coeff (N + d) =
|
| 621 |
+
2 * c * L.coeff d := by
|
| 622 |
+
have hLsq_zero : (L ^ 2).coeff (N + d) = 0 := by
|
| 623 |
+
apply Polynomial.coeff_eq_zero_of_natDegree_lt
|
| 624 |
+
have hsq : (L ^ 2).natDegree ≤ 2 * d := by
|
| 625 |
+
rw [Polynomial.natDegree_pow]
|
| 626 |
+
omega
|
| 627 |
+
exact lt_of_le_of_lt hsq (by omega)
|
| 628 |
+
have hTsq_zero :
|
| 629 |
+
((Polynomial.C c * Polynomial.X ^ N) ^ 2).coeff (N + d) = 0 := by
|
| 630 |
+
rw [Polynomial.C_mul_X_pow_eq_monomial]
|
| 631 |
+
rw [pow_two, Polynomial.monomial_mul_monomial]
|
| 632 |
+
rw [← Polynomial.C_mul_X_pow_eq_monomial]
|
| 633 |
+
rw [Polynomial.coeff_C_mul_X_pow]
|
| 634 |
+
rw [if_neg (show N + d ≠ N + N by omega)]
|
| 635 |
+
have hcross_left :
|
| 636 |
+
(L * (Polynomial.C c * Polynomial.X ^ N)).coeff (N + d) = L.coeff d * c := by
|
| 637 |
+
rw [Polynomial.C_mul_X_pow_eq_monomial]
|
| 638 |
+
rw [show N + d = d + N by omega]
|
| 639 |
+
exact Polynomial.coeff_mul_monomial L N d c
|
| 640 |
+
have hcross_right :
|
| 641 |
+
((Polynomial.C c * Polynomial.X ^ N) * L).coeff (N + d) = c * L.coeff d := by
|
| 642 |
+
rw [Polynomial.C_mul_X_pow_eq_monomial]
|
| 643 |
+
rw [show N + d = d + N by omega]
|
| 644 |
+
exact Polynomial.coeff_monomial_mul L N d c
|
| 645 |
+
calc
|
| 646 |
+
((L + Polynomial.C c * Polynomial.X ^ N) ^ 2).coeff (N + d)
|
| 647 |
+
= (L ^ 2 + (L * (Polynomial.C c * Polynomial.X ^ N) +
|
| 648 |
+
(Polynomial.C c * Polynomial.X ^ N) * L) +
|
| 649 |
+
(Polynomial.C c * Polynomial.X ^ N) ^ 2).coeff (N + d) := by
|
| 650 |
+
ring_nf
|
| 651 |
+
_ = (L * (Polynomial.C c * Polynomial.X ^ N)).coeff (N + d) +
|
| 652 |
+
((Polynomial.C c * Polynomial.X ^ N) * L).coeff (N + d) := by
|
| 653 |
+
simp [Polynomial.coeff_add, hLsq_zero, hTsq_zero]
|
| 654 |
+
_ = L.coeff d * c + c * L.coeff d := by rw [hcross_left, hcross_right]
|
| 655 |
+
_ = 2 * c * L.coeff d := by ring
|
| 656 |
+
|
| 657 |
+
private lemma putnam_1962_b6_X_derivative_sub_nat_mul_coeff_natDegree
|
| 658 |
+
(M : ℕ) {R : Polynomial ℂ} (hpos : 0 < R.natDegree) :
|
| 659 |
+
(Polynomial.X * R.derivative - Polynomial.C (M : ℂ) * R).coeff R.natDegree =
|
| 660 |
+
R.leadingCoeff * ((R.natDegree : ℂ) - (M : ℂ)) := by
|
| 661 |
+
cases hd : R.natDegree with
|
| 662 |
+
| zero => omega
|
| 663 |
+
| succ e =>
|
| 664 |
+
rw [Polynomial.coeff_sub, Polynomial.coeff_X_mul, Polynomial.coeff_derivative,
|
| 665 |
+
Polynomial.coeff_C_mul]
|
| 666 |
+
rw [show e + 1 = R.natDegree by omega]
|
| 667 |
+
rw [Polynomial.coeff_natDegree]
|
| 668 |
+
rw [hd]
|
| 669 |
+
norm_num [Nat.cast_add, Nat.cast_one]
|
| 670 |
+
ring
|
| 671 |
+
|
| 672 |
+
private lemma putnam_1962_b6_derivative_top_decomp
|
| 673 |
+
(n : ℕ) (hnpos : 0 < n) (F R : Polynomial ℂ) (c : ℂ)
|
| 674 |
+
(hF : F = R + Polynomial.C c * Polynomial.X ^ (2 * n)) :
|
| 675 |
+
Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F =
|
| 676 |
+
(Polynomial.X * R.derivative - Polynomial.C (n : ℂ) * R) +
|
| 677 |
+
Polynomial.C ((n : ℂ) * c) * Polynomial.X ^ (2 * n) := by
|
| 678 |
+
rw [hF]
|
| 679 |
+
rw [Polynomial.derivative_add, Polynomial.derivative_C_mul_X_pow]
|
| 680 |
+
have htop :
|
| 681 |
+
Polynomial.X *
|
| 682 |
+
(Polynomial.C (c * ((2 * n : ℕ) : ℂ)) * Polynomial.X ^ (2 * n - 1)) =
|
| 683 |
+
Polynomial.C (c * ((2 * n : ℕ) : ℂ)) * Polynomial.X ^ (2 * n) := by
|
| 684 |
+
cases n with
|
| 685 |
+
| zero => cases hnpos
|
| 686 |
+
| succ m =>
|
| 687 |
+
rw [show 2 * (m + 1) - 1 = 2 * m + 1 by omega]
|
| 688 |
+
rw [show 2 * (m + 1) = 2 * m + 2 by omega]
|
| 689 |
+
ring_nf
|
| 690 |
+
have hconst :
|
| 691 |
+
Polynomial.C (c * ((2 * n : ℕ) : ℂ)) =
|
| 692 |
+
(2 : Polynomial ℂ) * Polynomial.C ((n : ℂ) * c) := by
|
| 693 |
+
ext k
|
| 694 |
+
by_cases hk : k = 0
|
| 695 |
+
· subst k
|
| 696 |
+
simp [Nat.cast_mul]
|
| 697 |
+
ring
|
| 698 |
+
· simp [Polynomial.coeff_C, hk]
|
| 699 |
+
have hmul_top :
|
| 700 |
+
Polynomial.C (n : ℂ) * (Polynomial.C c * Polynomial.X ^ (2 * n)) =
|
| 701 |
+
Polynomial.C ((n : ℂ) * c) * Polynomial.X ^ (2 * n) := by
|
| 702 |
+
rw [← mul_assoc, ← Polynomial.C_mul]
|
| 703 |
+
rw [mul_add, htop, hconst]
|
| 704 |
+
rw [mul_add, hmul_top]
|
| 705 |
+
ring
|
| 706 |
+
|
| 707 |
+
private lemma putnam_1962_b6_complexPoly_eq_zero_of_card_lt_roots
|
| 708 |
+
(n : ℕ) (A B : ℕ → ℝ) (s : Finset ℂ)
|
| 709 |
+
(hroots : ∀ z ∈ s, (putnam_1962_b6_complexPoly n A B).eval z = 0)
|
| 710 |
+
(hcard : 2 * n < s.card) :
|
| 711 |
+
putnam_1962_b6_complexPoly n A B = 0 := by
|
| 712 |
+
exact Polynomial.eq_zero_of_natDegree_lt_card_of_eval_eq_zero'
|
| 713 |
+
(putnam_1962_b6_complexPoly n A B) s hroots
|
| 714 |
+
(lt_of_le_of_lt (putnam_1962_b6_complexPoly_natDegree_le n A B) hcard)
|
| 715 |
+
|
| 716 |
+
private lemma putnam_1962_b6_constant_of_deriv_poly_zero
|
| 717 |
+
(n : ℕ) (a b : ℕ → ℝ) (f : ℝ → ℝ)
|
| 718 |
+
(hf : f = fun x : ℝ => ∑ k ∈ Finset.Icc 0 n,
|
| 719 |
+
(a k * Real.sin (k * x) + b k * Real.cos (k * x)))
|
| 720 |
+
(hpoly : putnam_1962_b6_complexPoly n
|
| 721 |
+
(fun k => -(b k * (k : ℝ))) (fun k => a k * (k : ℝ)) = 0) :
|
| 722 |
+
∃ c : ℝ, f = fun _ : ℝ => c := by
|
| 723 |
+
have hdiff : Differentiable ℝ f := putnam_1962_b6_differentiable n a b f hf
|
| 724 |
+
have hderiv_formula :
|
| 725 |
+
∀ x : ℝ, deriv f x = ∑ k ∈ Finset.Icc 0 n,
|
| 726 |
+
(a k * ((k : ℝ) * Real.cos (k * x)) -
|
| 727 |
+
b k * ((k : ℝ) * Real.sin (k * x))) :=
|
| 728 |
+
putnam_1962_b6_deriv n a b f hf
|
| 729 |
+
have hderiv_zero : ∀ x : ℝ, deriv f x = 0 := by
|
| 730 |
+
intro x
|
| 731 |
+
have heval :
|
| 732 |
+
(putnam_1962_b6_complexPoly n
|
| 733 |
+
(fun k => -(b k * (k : ℝ))) (fun k => a k * (k : ℝ))).eval
|
| 734 |
+
(Complex.exp (x * Complex.I)) = 0 := by
|
| 735 |
+
rw [hpoly]
|
| 736 |
+
simp
|
| 737 |
+
rw [putnam_1962_b6_complexPoly_eval] at heval
|
| 738 |
+
have hexp_ne : (Complex.exp (x * Complex.I)) ^ n ≠ 0 :=
|
| 739 |
+
pow_ne_zero _ (Complex.exp_ne_zero _)
|
| 740 |
+
have hsumC := (mul_eq_zero.mp heval).resolve_left hexp_ne
|
| 741 |
+
have hcast_sum : ((∑ k ∈ Finset.Icc 0 n,
|
| 742 |
+
(a k * ((k : ℝ) * Real.cos (k * x)) -
|
| 743 |
+
b k * ((k : ℝ) * Real.sin (k * x)))) : ℂ) =
|
| 744 |
+
∑ k ∈ Finset.Icc 0 n,
|
| 745 |
+
(((-(b k * (k : ℝ))) : ℂ) * (Real.sin (k * x) : ℂ) +
|
| 746 |
+
((a k * (k : ℝ)) : ℂ) * (Real.cos (k * x) : ℂ)) := by
|
| 747 |
+
push_cast
|
| 748 |
+
simp [sub_eq_add_neg, add_comm, mul_comm, mul_left_comm]
|
| 749 |
+
have hcast : ((∑ k ∈ Finset.Icc 0 n,
|
| 750 |
+
(a k * ((k : ℝ) * Real.cos (k * x)) -
|
| 751 |
+
b k * ((k : ℝ) * Real.sin (k * x)))) : ℂ) = 0 := by
|
| 752 |
+
rw [hcast_sum]
|
| 753 |
+
simpa [sub_eq_add_neg, add_comm, add_left_comm, add_assoc,
|
| 754 |
+
mul_comm, mul_left_comm, mul_assoc] using hsumC
|
| 755 |
+
have hreal :
|
| 756 |
+
∑ k ∈ Finset.Icc 0 n,
|
| 757 |
+
(a k * ((k : ℝ) * Real.cos (k * x)) -
|
| 758 |
+
b k * ((k : ℝ) * Real.sin (k * x))) = 0 := by
|
| 759 |
+
exact_mod_cast hcast
|
| 760 |
+
rw [hderiv_formula x, hreal]
|
| 761 |
+
refine ⟨f 0, ?_⟩
|
| 762 |
+
funext x
|
| 763 |
+
exact is_const_of_deriv_eq_zero hdiff hderiv_zero x 0
|
| 764 |
+
|
| 765 |
+
private lemma putnam_1962_b6_exp_inj_on_Ico {x y : ℝ}
|
| 766 |
+
(hx : x ∈ Set.Ico 0 (2 * π)) (hy : y ∈ Set.Ico 0 (2 * π))
|
| 767 |
+
(h : Complex.exp (x * Complex.I) = Complex.exp (y * Complex.I)) :
|
| 768 |
+
x = y := by
|
| 769 |
+
rw [Complex.exp_eq_exp_iff_exists_int] at h
|
| 770 |
+
rcases h with ⟨m, hm⟩
|
| 771 |
+
have him := congrArg Complex.im hm
|
| 772 |
+
simp at him
|
| 773 |
+
have hdiff : x - y = (m : ℝ) * (2 * π) := by
|
| 774 |
+
linarith
|
| 775 |
+
have hbound_lower : -(2 * π) < x - y := by
|
| 776 |
+
linarith [hx.1, hy.2]
|
| 777 |
+
have hbound_upper : x - y < 2 * π := by
|
| 778 |
+
linarith [hx.2, hy.1]
|
| 779 |
+
have hmzero : (m : ℝ) = 0 := by
|
| 780 |
+
by_contra hm0
|
| 781 |
+
have h_abs_ge : 2 * π ≤ |(m : ℝ) * (2 * π)| := by
|
| 782 |
+
have h_int_abs : 1 ≤ |(m : ℝ)| := by
|
| 783 |
+
have hmi : m ≠ 0 := by
|
| 784 |
+
intro hmi
|
| 785 |
+
apply hm0
|
| 786 |
+
simp [hmi]
|
| 787 |
+
have : (1 : ℤ) ≤ |m| := Int.one_le_abs hmi
|
| 788 |
+
exact_mod_cast this
|
| 789 |
+
rw [abs_mul, abs_of_pos (by positivity : 0 < 2 * π)]
|
| 790 |
+
nlinarith [Real.pi_pos]
|
| 791 |
+
have h_abs_lt : |x - y| < 2 * π := by
|
| 792 |
+
rw [abs_lt]
|
| 793 |
+
exact ⟨hbound_lower, hbound_upper⟩
|
| 794 |
+
rw [hdiff] at h_abs_lt
|
| 795 |
+
exact not_le_of_gt h_abs_lt h_abs_ge
|
| 796 |
+
rw [hmzero, zero_mul] at hdiff
|
| 797 |
+
linarith
|
| 798 |
+
|
| 799 |
+
/--
|
| 800 |
+
Let \[ f(x) = \sum_{k=0}^n a_k \sin kx + b_k \cos kx, \] where $a_k$ and $b_k$ are constants. Show that, if $\lvert f(x) \rvert \le 1$ for $0 \le x \le 2 \pi$ and $\lvert f(x_i) \rvert = 1$ for $0 \le x_1 < x_2 < \cdots < x_{2n} < 2 \pi$, then $f(x) = \cos (nx + a)$ for some constant $a$.
|
| 801 |
+
-/
|
| 802 |
+
theorem putnam_1962_b6
|
| 803 |
+
(n : ℕ)
|
| 804 |
+
(a b : ℕ → ℝ)
|
| 805 |
+
(xs : Set ℝ)
|
| 806 |
+
(f : ℝ → ℝ)
|
| 807 |
+
(hf : f = fun x : ℝ => ∑ k ∈ Finset.Icc 0 n, ((a k) * Real.sin (k * x) + (b k) * Real.cos (k * x)))
|
| 808 |
+
(hf1 : ∀ x ∈ Set.Icc 0 (2 * π), |f x| ≤ 1)
|
| 809 |
+
(hxs : xs.ncard = 2 * n ∧ xs ⊆ Set.Ico 0 (2 * π))
|
| 810 |
+
(hfxs : ∀ x ∈ xs, |f x| = 1)
|
| 811 |
+
: (¬∃ c : ℝ, f = fun x : ℝ => c) → ∃ a : ℝ, f = fun x : ℝ => Real.cos (n * x + a) :=
|
| 812 |
+
by
|
| 813 |
+
intro hnonconst
|
| 814 |
+
by_cases hn : n = 0
|
| 815 |
+
· exfalso
|
| 816 |
+
apply hnonconst
|
| 817 |
+
subst n
|
| 818 |
+
exact putnam_1962_b6_constant_of_zero a b f hf
|
| 819 |
+
· have hper : ∀ x : ℝ, f (x + 2 * π) = f x :=
|
| 820 |
+
putnam_1962_b6_periodic n a b f hf
|
| 821 |
+
have hderiv_formula :
|
| 822 |
+
∀ x : ℝ, deriv f x = ∑ k ∈ Finset.Icc 0 n,
|
| 823 |
+
(a k * ((k : ℝ) * Real.cos (k * x)) -
|
| 824 |
+
b k * ((k : ℝ) * Real.sin (k * x))) :=
|
| 825 |
+
putnam_1962_b6_deriv n a b f hf
|
| 826 |
+
have hderiv_xs : ∀ x ∈ xs, deriv f x = 0 := by
|
| 827 |
+
intro x hx
|
| 828 |
+
exact putnam_1962_b6_deriv_eq_zero_of_contact f hper hf1
|
| 829 |
+
(hxs.2 hx) (hfxs x hx)
|
| 830 |
+
have hderiv_sum_xs :
|
| 831 |
+
∀ x ∈ xs, ∑ k ∈ Finset.Icc 0 n,
|
| 832 |
+
(a k * ((k : ℝ) * Real.cos (k * x)) -
|
| 833 |
+
b k * ((k : ℝ) * Real.sin (k * x))) = 0 := by
|
| 834 |
+
intro x hx
|
| 835 |
+
rw [← hderiv_formula x]
|
| 836 |
+
exact hderiv_xs x hx
|
| 837 |
+
have hnpos : 0 < n := Nat.pos_of_ne_zero hn
|
| 838 |
+
have hxs_card_pos : 0 < xs.ncard := by
|
| 839 |
+
rw [hxs.1]
|
| 840 |
+
exact Nat.mul_pos (by norm_num) hnpos
|
| 841 |
+
have hxs_finite : xs.Finite := Set.finite_of_ncard_pos hxs_card_pos
|
| 842 |
+
let xfin : Finset ℝ := hxs_finite.toFinset
|
| 843 |
+
have hxfin_mem : ∀ x : ℝ, x ∈ xfin ↔ x ∈ xs := by
|
| 844 |
+
intro x
|
| 845 |
+
exact hxs_finite.mem_toFinset
|
| 846 |
+
have hxfin_card : xfin.card = 2 * n := by
|
| 847 |
+
dsimp [xfin]
|
| 848 |
+
rw [← Set.ncard_eq_toFinset_card xs hxs_finite, hxs.1]
|
| 849 |
+
have hxfin_nonempty : xfin.Nonempty := by
|
| 850 |
+
exact Finset.card_pos.mp (by
|
| 851 |
+
rw [hxfin_card]
|
| 852 |
+
exact Nat.mul_pos (by norm_num) hnpos)
|
| 853 |
+
have hxfin_subset_Ico : ∀ x ∈ xfin, x ∈ Set.Ico 0 (2 * π) := by
|
| 854 |
+
intro x hx
|
| 855 |
+
exact hxs.2 ((hxfin_mem x).mp hx)
|
| 856 |
+
have hxfin_deriv_sum :
|
| 857 |
+
∀ x ∈ xfin, ∑ k ∈ Finset.Icc 0 n,
|
| 858 |
+
(a k * ((k : ℝ) * Real.cos (k * x)) -
|
| 859 |
+
b k * ((k : ℝ) * Real.sin (k * x))) = 0 := by
|
| 860 |
+
intro x hx
|
| 861 |
+
exact hderiv_sum_xs x ((hxfin_mem x).mp hx)
|
| 862 |
+
let dA : ℕ → ℝ := fun k => -(b k * (k : ℝ))
|
| 863 |
+
let dB : ℕ → ℝ := fun k => a k * (k : ℝ)
|
| 864 |
+
have hderiv_complex_sum_xs :
|
| 865 |
+
∀ x ∈ xfin, ∑ k ∈ Finset.Icc 0 n,
|
| 866 |
+
((dA k : ℂ) * (Real.sin (k * x) : ℂ) +
|
| 867 |
+
(dB k : ℂ) * (Real.cos (k * x) : ℂ)) = 0 := by
|
| 868 |
+
intro x hx
|
| 869 |
+
have hreal := hxfin_deriv_sum x hx
|
| 870 |
+
have hcast : ((∑ k ∈ Finset.Icc 0 n,
|
| 871 |
+
(a k * ((k : ℝ) * Real.cos (k * x)) -
|
| 872 |
+
b k * ((k : ℝ) * Real.sin (k * x)))) : ℂ) = 0 := by
|
| 873 |
+
exact_mod_cast hreal
|
| 874 |
+
simpa [dA, dB, sub_eq_add_neg, add_comm, add_left_comm, add_assoc,
|
| 875 |
+
mul_comm, mul_left_comm, mul_assoc] using hcast
|
| 876 |
+
have hderiv_poly_xs :
|
| 877 |
+
∀ x ∈ xfin,
|
| 878 |
+
(putnam_1962_b6_complexPoly n dA dB).eval
|
| 879 |
+
(Complex.exp (x * Complex.I)) = 0 := by
|
| 880 |
+
intro x hx
|
| 881 |
+
rw [putnam_1962_b6_complexPoly_eval]
|
| 882 |
+
rw [hderiv_complex_sum_xs x hx, mul_zero]
|
| 883 |
+
have hderiv_poly_of_deriv_zero :
|
| 884 |
+
∀ y : ℝ, deriv f y = 0 →
|
| 885 |
+
(putnam_1962_b6_complexPoly n dA dB).eval
|
| 886 |
+
(Complex.exp (y * Complex.I)) = 0 := by
|
| 887 |
+
intro y hyderiv
|
| 888 |
+
have hreal : ∑ k ∈ Finset.Icc 0 n,
|
| 889 |
+
(a k * ((k : ℝ) * Real.cos (k * y)) -
|
| 890 |
+
b k * ((k : ℝ) * Real.sin (k * y))) = 0 := by
|
| 891 |
+
rw [← hderiv_formula y]
|
| 892 |
+
exact hyderiv
|
| 893 |
+
have hcast : ((∑ k ∈ Finset.Icc 0 n,
|
| 894 |
+
(a k * ((k : ℝ) * Real.cos (k * y)) -
|
| 895 |
+
b k * ((k : ℝ) * Real.sin (k * y)))) : ℂ) = 0 := by
|
| 896 |
+
exact_mod_cast hreal
|
| 897 |
+
have hcomplex : ∑ k ∈ Finset.Icc 0 n,
|
| 898 |
+
((dA k : ℂ) * (Real.sin (k * y) : ℂ) +
|
| 899 |
+
(dB k : ℂ) * (Real.cos (k * y) : ℂ)) = 0 := by
|
| 900 |
+
simpa [dA, dB, sub_eq_add_neg, add_comm, add_left_comm, add_assoc,
|
| 901 |
+
mul_comm, mul_left_comm, mul_assoc] using hcast
|
| 902 |
+
rw [putnam_1962_b6_complexPoly_eval]
|
| 903 |
+
rw [hcomplex, mul_zero]
|
| 904 |
+
let zfin : Finset ℂ := xfin.image (fun x : ℝ => Complex.exp (x * Complex.I))
|
| 905 |
+
have hzfin_card : zfin.card = 2 * n := by
|
| 906 |
+
dsimp [zfin]
|
| 907 |
+
rw [Finset.card_image_of_injOn]
|
| 908 |
+
· exact hxfin_card
|
| 909 |
+
· intro x hx y hy hxy
|
| 910 |
+
exact putnam_1962_b6_exp_inj_on_Ico
|
| 911 |
+
(hxfin_subset_Ico x hx) (hxfin_subset_Ico y hy) hxy
|
| 912 |
+
have hzfin_roots :
|
| 913 |
+
∀ z ∈ zfin, (putnam_1962_b6_complexPoly n dA dB).eval z = 0 := by
|
| 914 |
+
intro z hz
|
| 915 |
+
simp only [zfin, Finset.mem_image] at hz
|
| 916 |
+
rcases hz with ⟨x, hx, rfl⟩
|
| 917 |
+
exact hderiv_poly_xs x hx
|
| 918 |
+
have honeSubSq_poly_xs :
|
| 919 |
+
∀ x ∈ xfin,
|
| 920 |
+
(putnam_1962_b6_oneSubSqPoly n a b).eval
|
| 921 |
+
(Complex.exp (x * Complex.I)) = 0 := by
|
| 922 |
+
intro x hx
|
| 923 |
+
exact putnam_1962_b6_oneSubSqPoly_eq_zero_of_contact
|
| 924 |
+
n a b f hf (hfxs x ((hxfin_mem x).mp hx))
|
| 925 |
+
have honeSubSq_zfin_roots :
|
| 926 |
+
∀ z ∈ zfin, (putnam_1962_b6_oneSubSqPoly n a b).eval z = 0 := by
|
| 927 |
+
intro z hz
|
| 928 |
+
simp only [zfin, Finset.mem_image] at hz
|
| 929 |
+
rcases hz with ⟨x, hx, rfl⟩
|
| 930 |
+
exact honeSubSq_poly_xs x hx
|
| 931 |
+
have honeSubSq_zfin_deriv_roots :
|
| 932 |
+
∀ z ∈ zfin,
|
| 933 |
+
(putnam_1962_b6_oneSubSqPoly n a b).derivative.eval z = 0 := by
|
| 934 |
+
intro z hz
|
| 935 |
+
simp only [zfin, Finset.mem_image] at hz
|
| 936 |
+
rcases hz with ⟨x, hx, rfl⟩
|
| 937 |
+
exact putnam_1962_b6_oneSubSqPoly_derivative_eq_zero_of_contact
|
| 938 |
+
n a b (Complex.exp_ne_zero _) (honeSubSq_poly_xs x hx)
|
| 939 |
+
(hderiv_poly_xs x hx)
|
| 940 |
+
have honeSubSq_ne_zero : putnam_1962_b6_oneSubSqPoly n a b ≠ 0 := by
|
| 941 |
+
intro hpoly_zero
|
| 942 |
+
exact hnonconst
|
| 943 |
+
(putnam_1962_b6_constant_of_oneSubSqPoly_zero n a b f hf hpoly_zero)
|
| 944 |
+
have honeSubSq_zfin_double_roots :
|
| 945 |
+
∀ z ∈ zfin,
|
| 946 |
+
2 ≤ (putnam_1962_b6_oneSubSqPoly n a b).rootMultiplicity z := by
|
| 947 |
+
intro z hz
|
| 948 |
+
exact putnam_1962_b6_two_le_rootMultiplicity_of_eval_derivative_eq_zero
|
| 949 |
+
honeSubSq_ne_zero (honeSubSq_zfin_roots z hz)
|
| 950 |
+
(honeSubSq_zfin_deriv_roots z hz)
|
| 951 |
+
have honeSubSq_natDegree_ge :
|
| 952 |
+
4 * n ≤ (putnam_1962_b6_oneSubSqPoly n a b).natDegree := by
|
| 953 |
+
have hle := putnam_1962_b6_two_mul_card_le_natDegree_of_double_roots
|
| 954 |
+
(p := putnam_1962_b6_oneSubSqPoly n a b) zfin
|
| 955 |
+
honeSubSq_zfin_double_roots
|
| 956 |
+
rw [hzfin_card] at hle
|
| 957 |
+
omega
|
| 958 |
+
have honeSubSq_natDegree_eq :
|
| 959 |
+
(putnam_1962_b6_oneSubSqPoly n a b).natDegree = 4 * n := by
|
| 960 |
+
exact le_antisymm (putnam_1962_b6_oneSubSqPoly_natDegree_le n a b)
|
| 961 |
+
honeSubSq_natDegree_ge
|
| 962 |
+
let D : Polynomial ℂ := putnam_1962_b6_complexPoly n dA dB
|
| 963 |
+
have hD_ne_zero : D ≠ 0 := by
|
| 964 |
+
intro hD_zero
|
| 965 |
+
have hpoly_zero' :
|
| 966 |
+
putnam_1962_b6_complexPoly n
|
| 967 |
+
(fun k => -(b k * (k : ℝ))) (fun k => a k * (k : ℝ)) = 0 := by
|
| 968 |
+
simpa [D, dA, dB] using hD_zero
|
| 969 |
+
exact hnonconst
|
| 970 |
+
(putnam_1962_b6_constant_of_deriv_poly_zero n a b f hf hpoly_zero')
|
| 971 |
+
have hDsq_ne_zero : D ^ 2 ≠ 0 := pow_ne_zero _ hD_ne_zero
|
| 972 |
+
have hDsq_zfin_roots : ∀ z ∈ zfin, (D ^ 2).eval z = 0 := by
|
| 973 |
+
intro z hz
|
| 974 |
+
have hzD : D.eval z = 0 := by
|
| 975 |
+
simpa [D] using hzfin_roots z hz
|
| 976 |
+
simp [Polynomial.eval_pow, hzD]
|
| 977 |
+
have hDsq_zfin_deriv_roots :
|
| 978 |
+
∀ z ∈ zfin, (D ^ 2).derivative.eval z = 0 := by
|
| 979 |
+
intro z hz
|
| 980 |
+
have hzD : D.eval z = 0 := by
|
| 981 |
+
simpa [D] using hzfin_roots z hz
|
| 982 |
+
simp [Polynomial.derivative_pow, hzD]
|
| 983 |
+
have hDsq_zfin_double_roots :
|
| 984 |
+
∀ z ∈ zfin, 2 ≤ (D ^ 2).rootMultiplicity z := by
|
| 985 |
+
intro z hz
|
| 986 |
+
exact putnam_1962_b6_two_le_rootMultiplicity_of_eval_derivative_eq_zero
|
| 987 |
+
hDsq_ne_zero (hDsq_zfin_roots z hz) (hDsq_zfin_deriv_roots z hz)
|
| 988 |
+
have hDsq_natDegree_ge : 4 * n ≤ (D ^ 2).natDegree := by
|
| 989 |
+
have hle := putnam_1962_b6_two_mul_card_le_natDegree_of_double_roots
|
| 990 |
+
(p := D ^ 2) zfin hDsq_zfin_double_roots
|
| 991 |
+
rw [hzfin_card] at hle
|
| 992 |
+
omega
|
| 993 |
+
have hDsq_natDegree_le : (D ^ 2).natDegree ≤ 4 * n := by
|
| 994 |
+
have hpow := Polynomial.natDegree_pow_le_of_le (p := D) 2
|
| 995 |
+
(by
|
| 996 |
+
dsimp [D]
|
| 997 |
+
exact putnam_1962_b6_complexPoly_natDegree_le n dA dB)
|
| 998 |
+
exact hpow.trans (by omega)
|
| 999 |
+
have hDsq_natDegree_eq : (D ^ 2).natDegree = 4 * n :=
|
| 1000 |
+
le_antisymm hDsq_natDegree_le hDsq_natDegree_ge
|
| 1001 |
+
let P : Polynomial ℂ := putnam_1962_b6_oneSubSqPoly n a b
|
| 1002 |
+
let Q : Polynomial ℂ := D ^ 2
|
| 1003 |
+
have hP_natDegree_two_card : P.natDegree = 2 * zfin.card := by
|
| 1004 |
+
dsimp [P]
|
| 1005 |
+
rw [honeSubSq_natDegree_eq, hzfin_card]
|
| 1006 |
+
omega
|
| 1007 |
+
have hQ_natDegree_two_card : Q.natDegree = 2 * zfin.card := by
|
| 1008 |
+
dsimp [Q]
|
| 1009 |
+
rw [hDsq_natDegree_eq, hzfin_card]
|
| 1010 |
+
omega
|
| 1011 |
+
have hscaled_poly_eq :
|
| 1012 |
+
Polynomial.C Q.leadingCoeff * P = Polynomial.C P.leadingCoeff * Q := by
|
| 1013 |
+
exact putnam_1962_b6_scaled_eq_of_same_double_roots zfin
|
| 1014 |
+
(by simpa [P] using honeSubSq_ne_zero)
|
| 1015 |
+
(by simpa [Q] using hDsq_ne_zero)
|
| 1016 |
+
hP_natDegree_two_card hQ_natDegree_two_card
|
| 1017 |
+
(by simpa [P] using honeSubSq_zfin_double_roots)
|
| 1018 |
+
(by simpa [Q] using hDsq_zfin_double_roots)
|
| 1019 |
+
have hscaled_eval_identity :
|
| 1020 |
+
∀ x : ℝ,
|
| 1021 |
+
Q.leadingCoeff * (1 - (f x : ℂ) ^ 2) =
|
| 1022 |
+
P.leadingCoeff * (((deriv f x : ℝ) : ℂ) ^ 2) := by
|
| 1023 |
+
intro x
|
| 1024 |
+
let z : ℂ := Complex.exp (x * Complex.I)
|
| 1025 |
+
have hsum_f :
|
| 1026 |
+
(∑ k ∈ Finset.Icc 0 n,
|
| 1027 |
+
((a k : ℂ) * (Real.sin (k * x) : ℂ) +
|
| 1028 |
+
(b k : ℂ) * (Real.cos (k * x) : ℂ))) = (f x : ℂ) := by
|
| 1029 |
+
have hsum_real :
|
| 1030 |
+
∑ k ∈ Finset.Icc 0 n,
|
| 1031 |
+
(a k * Real.sin (k * x) + b k * Real.cos (k * x)) = f x := by
|
| 1032 |
+
rw [hf]
|
| 1033 |
+
rw [← hsum_real]
|
| 1034 |
+
push_cast
|
| 1035 |
+
rfl
|
| 1036 |
+
have hderiv_complex :
|
| 1037 |
+
(∑ k ∈ Finset.Icc 0 n,
|
| 1038 |
+
((dA k : ℂ) * (Real.sin (k * x) : ℂ) +
|
| 1039 |
+
(dB k : ℂ) * (Real.cos (k * x) : ℂ))) = ((deriv f x : ℝ) : ℂ) := by
|
| 1040 |
+
have hcast : ((∑ k ∈ Finset.Icc 0 n,
|
| 1041 |
+
(a k * ((k : ℝ) * Real.cos (k * x)) -
|
| 1042 |
+
b k * ((k : ℝ) * Real.sin (k * x)))) : ℂ) = ((deriv f x : ℝ) : ℂ) := by
|
| 1043 |
+
exact_mod_cast (hderiv_formula x).symm
|
| 1044 |
+
simpa [dA, dB, sub_eq_add_neg, add_comm, add_left_comm, add_assoc,
|
| 1045 |
+
mul_comm, mul_left_comm, mul_assoc] using hcast
|
| 1046 |
+
have hP_eval :
|
| 1047 |
+
P.eval z = z ^ (2 * n) * (1 - (f x : ℂ) ^ 2) := by
|
| 1048 |
+
dsimp [P, z]
|
| 1049 |
+
rw [putnam_1962_b6_oneSubSqPoly_eval, hsum_f]
|
| 1050 |
+
have hD_eval : D.eval z = z ^ n * ((deriv f x : ℝ) : ℂ) := by
|
| 1051 |
+
dsimp [D, z]
|
| 1052 |
+
rw [putnam_1962_b6_complexPoly_eval, hderiv_complex]
|
| 1053 |
+
have hQ_eval :
|
| 1054 |
+
Q.eval z = z ^ (2 * n) * (((deriv f x : ℝ) : ℂ) ^ 2) := by
|
| 1055 |
+
dsimp [Q]
|
| 1056 |
+
rw [Polynomial.eval_pow, hD_eval]
|
| 1057 |
+
calc
|
| 1058 |
+
(z ^ n * ((deriv f x : ℝ) : ℂ)) ^ 2 =
|
| 1059 |
+
(z ^ n * z ^ n) * (((deriv f x : ℝ) : ℂ) ^ 2) := by ring
|
| 1060 |
+
_ = z ^ (2 * n) * (((deriv f x : ℝ) : ℂ) ^ 2) := by
|
| 1061 |
+
rw [← pow_add]
|
| 1062 |
+
rw [show n + n = 2 * n by omega]
|
| 1063 |
+
have heval_scaled :
|
| 1064 |
+
Q.leadingCoeff * P.eval z = P.leadingCoeff * Q.eval z := by
|
| 1065 |
+
have h := congrArg (fun R : Polynomial ℂ => R.eval z) hscaled_poly_eq
|
| 1066 |
+
simpa [Polynomial.eval_mul, Polynomial.eval_C] using h
|
| 1067 |
+
rw [hP_eval, hQ_eval] at heval_scaled
|
| 1068 |
+
have hzpow_ne : z ^ (2 * n) ≠ 0 := pow_ne_zero _ (Complex.exp_ne_zero _)
|
| 1069 |
+
have hcancel :
|
| 1070 |
+
z ^ (2 * n) * (Q.leadingCoeff * (1 - (f x : ℂ) ^ 2)) =
|
| 1071 |
+
z ^ (2 * n) * (P.leadingCoeff * (((deriv f x : ℝ) : ℂ) ^ 2)) := by
|
| 1072 |
+
calc
|
| 1073 |
+
z ^ (2 * n) * (Q.leadingCoeff * (1 - (f x : ℂ) ^ 2)) =
|
| 1074 |
+
Q.leadingCoeff * (z ^ (2 * n) * (1 - (f x : ℂ) ^ 2)) := by ring
|
| 1075 |
+
_ = P.leadingCoeff * (z ^ (2 * n) * (((deriv f x : ℝ) : ℂ) ^ 2)) :=
|
| 1076 |
+
heval_scaled
|
| 1077 |
+
_ = z ^ (2 * n) * (P.leadingCoeff * (((deriv f x : ℝ) : ℂ) ^ 2)) := by ring
|
| 1078 |
+
exact mul_left_cancel₀ hzpow_ne hcancel
|
| 1079 |
+
let F : Polynomial ℂ := putnam_1962_b6_complexPoly n a b
|
| 1080 |
+
have hP_natDegree_eq_four : P.natDegree = 4 * n := by
|
| 1081 |
+
dsimp [P]
|
| 1082 |
+
exact honeSubSq_natDegree_eq
|
| 1083 |
+
have hF_natDegree_eq : F.natDegree = 2 * n := by
|
| 1084 |
+
have hP_le :
|
| 1085 |
+
P.natDegree ≤ max (2 * n) ((F ^ 2).natDegree) := by
|
| 1086 |
+
have h := Polynomial.natDegree_sub_le (Polynomial.X ^ (2 * n) : Polynomial ℂ)
|
| 1087 |
+
((putnam_1962_b6_complexPoly n a b) ^ 2)
|
| 1088 |
+
rw [Polynomial.natDegree_X_pow] at h
|
| 1089 |
+
simpa only [P, F, putnam_1962_b6_oneSubSqPoly] using h
|
| 1090 |
+
have hF_le : F.natDegree ≤ 2 * n := by
|
| 1091 |
+
dsimp [F]
|
| 1092 |
+
exact putnam_1962_b6_complexPoly_natDegree_le n a b
|
| 1093 |
+
have hP_le' : 4 * n ≤ max (2 * n) (2 * F.natDegree) := by
|
| 1094 |
+
simpa [hP_natDegree_eq_four, Polynomial.natDegree_pow] using hP_le
|
| 1095 |
+
have hF_ge : 2 * n ≤ F.natDegree := by omega
|
| 1096 |
+
exact le_antisymm hF_le hF_ge
|
| 1097 |
+
have hD_natDegree_eq : D.natDegree = 2 * n := by
|
| 1098 |
+
have hpow : (D ^ 2).natDegree = 2 * D.natDegree := by
|
| 1099 |
+
simp
|
| 1100 |
+
rw [hpow] at hDsq_natDegree_eq
|
| 1101 |
+
omega
|
| 1102 |
+
have hF_leadingCoeff :
|
| 1103 |
+
F.leadingCoeff = (((b n : ℂ) - Complex.I * (a n : ℂ)) / 2) := by
|
| 1104 |
+
rw [← Polynomial.coeff_natDegree, hF_natDegree_eq]
|
| 1105 |
+
dsimp [F]
|
| 1106 |
+
exact putnam_1962_b6_complexPoly_coeff_two_mul hnpos a b
|
| 1107 |
+
have hD_leadingCoeff_top :
|
| 1108 |
+
D.leadingCoeff = (((dB n : ℂ) - Complex.I * (dA n : ℂ)) / 2) := by
|
| 1109 |
+
rw [← Polynomial.coeff_natDegree, hD_natDegree_eq]
|
| 1110 |
+
dsimp [D]
|
| 1111 |
+
exact putnam_1962_b6_complexPoly_coeff_two_mul hnpos dA dB
|
| 1112 |
+
have hD_leadingCoeff :
|
| 1113 |
+
D.leadingCoeff = Complex.I * (n : ℂ) * F.leadingCoeff := by
|
| 1114 |
+
rw [hD_leadingCoeff_top, hF_leadingCoeff]
|
| 1115 |
+
simp [dA, dB]
|
| 1116 |
+
ring_nf
|
| 1117 |
+
rw [Complex.I_sq]
|
| 1118 |
+
ring_nf
|
| 1119 |
+
have hF_ne_zero : F ≠ 0 := by
|
| 1120 |
+
intro hF_zero
|
| 1121 |
+
have hdeg_zero : F.natDegree = 0 := by simp [hF_zero]
|
| 1122 |
+
rw [hF_natDegree_eq] at hdeg_zero
|
| 1123 |
+
omega
|
| 1124 |
+
have hP_leadingCoeff :
|
| 1125 |
+
P.leadingCoeff = -F.leadingCoeff ^ 2 := by
|
| 1126 |
+
have hFsq_ne_zero : F ^ 2 ≠ 0 := pow_ne_zero _ hF_ne_zero
|
| 1127 |
+
have hdeg_lt : (Polynomial.X ^ (2 * n) : Polynomial ℂ).degree < (F ^ 2).degree := by
|
| 1128 |
+
rw [Polynomial.degree_X_pow, Polynomial.degree_eq_natDegree hFsq_ne_zero,
|
| 1129 |
+
Polynomial.natDegree_pow, hF_natDegree_eq]
|
| 1130 |
+
exact_mod_cast (by omega : 2 * n < 2 * (2 * n))
|
| 1131 |
+
change (Polynomial.X ^ (2 * n) - F ^ 2).leadingCoeff = -F.leadingCoeff ^ 2
|
| 1132 |
+
rw [Polynomial.leadingCoeff_sub_of_degree_lt' hdeg_lt, Polynomial.leadingCoeff_pow]
|
| 1133 |
+
have hQ_leadingCoeff :
|
| 1134 |
+
Q.leadingCoeff = D.leadingCoeff ^ 2 := by
|
| 1135 |
+
dsimp [Q]
|
| 1136 |
+
rw [Polynomial.leadingCoeff_pow]
|
| 1137 |
+
have hQ_leadingCoeff_eq :
|
| 1138 |
+
Q.leadingCoeff = (n : ℂ) ^ 2 * P.leadingCoeff := by
|
| 1139 |
+
rw [hQ_leadingCoeff, hD_leadingCoeff, hP_leadingCoeff]
|
| 1140 |
+
calc
|
| 1141 |
+
(Complex.I * (n : ℂ) * F.leadingCoeff) ^ 2 =
|
| 1142 |
+
Complex.I ^ 2 * (n : ℂ) ^ 2 * F.leadingCoeff ^ 2 := by ring
|
| 1143 |
+
_ = (n : ℂ) ^ 2 * -F.leadingCoeff ^ 2 := by
|
| 1144 |
+
rw [Complex.I_sq]
|
| 1145 |
+
ring
|
| 1146 |
+
have hP_leadingCoeff_ne_zero : P.leadingCoeff ≠ 0 :=
|
| 1147 |
+
Polynomial.leadingCoeff_ne_zero.mpr (by simpa [P] using honeSubSq_ne_zero)
|
| 1148 |
+
have henergy_complex :
|
| 1149 |
+
∀ x : ℝ,
|
| 1150 |
+
(((deriv f x : ℝ) : ℂ) ^ 2) =
|
| 1151 |
+
(n : ℂ) ^ 2 * (1 - (f x : ℂ) ^ 2) := by
|
| 1152 |
+
intro x
|
| 1153 |
+
have h := hscaled_eval_identity x
|
| 1154 |
+
have hcancel :
|
| 1155 |
+
P.leadingCoeff * ((n : ℂ) ^ 2 * (1 - (f x : ℂ) ^ 2)) =
|
| 1156 |
+
P.leadingCoeff * (((deriv f x : ℝ) : ℂ) ^ 2) := by
|
| 1157 |
+
calc
|
| 1158 |
+
P.leadingCoeff * ((n : ℂ) ^ 2 * (1 - (f x : ℂ) ^ 2)) =
|
| 1159 |
+
((n : ℂ) ^ 2 * P.leadingCoeff) * (1 - (f x : ℂ) ^ 2) := by ring
|
| 1160 |
+
_ = Q.leadingCoeff * (1 - (f x : ℂ) ^ 2) := by rw [hQ_leadingCoeff_eq]
|
| 1161 |
+
_ = P.leadingCoeff * (((deriv f x : ℝ) : ℂ) ^ 2) := h
|
| 1162 |
+
exact (mul_left_cancel₀ hP_leadingCoeff_ne_zero hcancel).symm
|
| 1163 |
+
have henergy_real :
|
| 1164 |
+
∀ x : ℝ, (deriv f x) ^ 2 = (n : ℝ) ^ 2 * (1 - (f x) ^ 2) := by
|
| 1165 |
+
intro x
|
| 1166 |
+
have h := henergy_complex x
|
| 1167 |
+
exact_mod_cast h
|
| 1168 |
+
have hno_extra_deriv_zero :
|
| 1169 |
+
∀ y ∈ Set.Ico 0 (2 * π), deriv f y = 0 → y ∈ xs := by
|
| 1170 |
+
intro y hyIco hyderiv
|
| 1171 |
+
by_contra hynot
|
| 1172 |
+
have hz_not : Complex.exp (y * Complex.I) ∉ zfin := by
|
| 1173 |
+
intro hz
|
| 1174 |
+
simp only [zfin, Finset.mem_image] at hz
|
| 1175 |
+
rcases hz with ⟨x, hx, hxy⟩
|
| 1176 |
+
have hyx : y = x :=
|
| 1177 |
+
putnam_1962_b6_exp_inj_on_Ico hyIco (hxfin_subset_Ico x hx) hxy.symm
|
| 1178 |
+
apply hynot
|
| 1179 |
+
rw [hyx]
|
| 1180 |
+
exact (hxfin_mem x).mp hx
|
| 1181 |
+
have hroots_insert :
|
| 1182 |
+
∀ z ∈ insert (Complex.exp (y * Complex.I)) zfin,
|
| 1183 |
+
(putnam_1962_b6_complexPoly n dA dB).eval z = 0 := by
|
| 1184 |
+
intro z hz
|
| 1185 |
+
rw [Finset.mem_insert] at hz
|
| 1186 |
+
rcases hz with rfl | hz
|
| 1187 |
+
· exact hderiv_poly_of_deriv_zero y hyderiv
|
| 1188 |
+
· exact hzfin_roots z hz
|
| 1189 |
+
have hcard_insert : 2 * n < (insert (Complex.exp (y * Complex.I)) zfin).card := by
|
| 1190 |
+
rw [Finset.card_insert_of_notMem hz_not, hzfin_card]
|
| 1191 |
+
omega
|
| 1192 |
+
have hpoly_zero :
|
| 1193 |
+
putnam_1962_b6_complexPoly n dA dB = 0 :=
|
| 1194 |
+
putnam_1962_b6_complexPoly_eq_zero_of_card_lt_roots
|
| 1195 |
+
n dA dB (insert (Complex.exp (y * Complex.I)) zfin)
|
| 1196 |
+
hroots_insert hcard_insert
|
| 1197 |
+
have hpoly_zero' :
|
| 1198 |
+
putnam_1962_b6_complexPoly n
|
| 1199 |
+
(fun k => -(b k * (k : ℝ))) (fun k => a k * (k : ℝ)) = 0 := by
|
| 1200 |
+
simpa [dA, dB] using hpoly_zero
|
| 1201 |
+
exact hnonconst
|
| 1202 |
+
(putnam_1962_b6_constant_of_deriv_poly_zero n a b f hf hpoly_zero')
|
| 1203 |
+
have hQ_eq_nP : Q = Polynomial.C ((n : ℂ) ^ 2) * P := by
|
| 1204 |
+
have h := hscaled_poly_eq
|
| 1205 |
+
rw [hQ_leadingCoeff_eq] at h
|
| 1206 |
+
have hleft :
|
| 1207 |
+
Polynomial.C P.leadingCoeff * Q =
|
| 1208 |
+
Polynomial.C P.leadingCoeff * (Polynomial.C ((n : ℂ) ^ 2) * P) := by
|
| 1209 |
+
calc
|
| 1210 |
+
Polynomial.C P.leadingCoeff * Q =
|
| 1211 |
+
Polynomial.C (((n : ℂ) ^ 2) * P.leadingCoeff) * P := by
|
| 1212 |
+
exact h.symm
|
| 1213 |
+
_ = Polynomial.C P.leadingCoeff * (Polynomial.C ((n : ℂ) ^ 2) * P) := by
|
| 1214 |
+
calc
|
| 1215 |
+
Polynomial.C (((n : ℂ) ^ 2) * P.leadingCoeff) * P =
|
| 1216 |
+
(Polynomial.C P.leadingCoeff * Polynomial.C ((n : ℂ) ^ 2)) * P := by
|
| 1217 |
+
rw [← Polynomial.C_mul]
|
| 1218 |
+
congr 1
|
| 1219 |
+
ring_nf
|
| 1220 |
+
_ = Polynomial.C P.leadingCoeff * (Polynomial.C ((n : ℂ) ^ 2) * P) := by
|
| 1221 |
+
rw [mul_assoc]
|
| 1222 |
+
exact mul_left_cancel₀ (Polynomial.C_ne_zero.mpr hP_leadingCoeff_ne_zero) hleft
|
| 1223 |
+
have hD_poly_relation :
|
| 1224 |
+
D = Polynomial.C Complex.I *
|
| 1225 |
+
(Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F) := by
|
| 1226 |
+
dsimp [D, F, dA, dB]
|
| 1227 |
+
exact putnam_1962_b6_complexPoly_derivative_relation_poly n a b
|
| 1228 |
+
have hA_energy :
|
| 1229 |
+
(Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F) ^ 2 +
|
| 1230 |
+
Polynomial.C ((n : ℂ) ^ 2) * (Polynomial.X ^ (2 * n) - F ^ 2) = 0 := by
|
| 1231 |
+
have hDsq :
|
| 1232 |
+
(Polynomial.C Complex.I *
|
| 1233 |
+
(Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F)) ^ 2 =
|
| 1234 |
+
Polynomial.C ((n : ℂ) ^ 2) * (Polynomial.X ^ (2 * n) - F ^ 2) := by
|
| 1235 |
+
simpa [Q, P, D, F, hD_poly_relation] using hQ_eq_nP
|
| 1236 |
+
have hIsq :
|
| 1237 |
+
(Polynomial.C Complex.I *
|
| 1238 |
+
(Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F)) ^ 2 =
|
| 1239 |
+
-((Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F) ^ 2) := by
|
| 1240 |
+
rw [pow_two]
|
| 1241 |
+
calc
|
| 1242 |
+
(Polynomial.C Complex.I *
|
| 1243 |
+
(Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F)) *
|
| 1244 |
+
(Polynomial.C Complex.I *
|
| 1245 |
+
(Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F)) =
|
| 1246 |
+
Polynomial.C (Complex.I * Complex.I) *
|
| 1247 |
+
((Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F) *
|
| 1248 |
+
(Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F)) := by
|
| 1249 |
+
rw [mul_assoc (Polynomial.C Complex.I)
|
| 1250 |
+
(Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F)
|
| 1251 |
+
(Polynomial.C Complex.I *
|
| 1252 |
+
(Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F))]
|
| 1253 |
+
rw [mul_comm
|
| 1254 |
+
(Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F)
|
| 1255 |
+
(Polynomial.C Complex.I *
|
| 1256 |
+
(Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F))]
|
| 1257 |
+
rw [← mul_assoc (Polynomial.C Complex.I)
|
| 1258 |
+
(Polynomial.C Complex.I *
|
| 1259 |
+
(Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F))
|
| 1260 |
+
(Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F)]
|
| 1261 |
+
rw [← mul_assoc (Polynomial.C Complex.I) (Polynomial.C Complex.I)
|
| 1262 |
+
(Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F)]
|
| 1263 |
+
rw [← Polynomial.C_mul]
|
| 1264 |
+
ring
|
| 1265 |
+
_ = -((Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F) ^ 2) := by
|
| 1266 |
+
rw [show Complex.I * Complex.I = -1 by simp]
|
| 1267 |
+
simp [pow_two]
|
| 1268 |
+
rw [← hDsq, hIsq]
|
| 1269 |
+
abel
|
| 1270 |
+
let N : ℕ := 2 * n
|
| 1271 |
+
let R : Polynomial ℂ := F.eraseLead
|
| 1272 |
+
let ctop : ℂ := F.leadingCoeff
|
| 1273 |
+
have hF_decomp : F = R + Polynomial.C ctop * Polynomial.X ^ N := by
|
| 1274 |
+
dsimp [R, ctop, N]
|
| 1275 |
+
simpa [hF_natDegree_eq] using (Polynomial.eraseLead_add_C_mul_X_pow F).symm
|
| 1276 |
+
have hR_natDegree_lt_N : R.natDegree < N := by
|
| 1277 |
+
dsimp [R, N]
|
| 1278 |
+
have hle := Polynomial.eraseLead_natDegree_le F
|
| 1279 |
+
rw [hF_natDegree_eq] at hle
|
| 1280 |
+
omega
|
| 1281 |
+
have hR_natDegree_zero : R.natDegree = 0 := by
|
| 1282 |
+
by_contra hRdeg_ne
|
| 1283 |
+
have hRpos : 0 < R.natDegree := Nat.pos_of_ne_zero hRdeg_ne
|
| 1284 |
+
have hR_ne_zero : R ≠ 0 := by
|
| 1285 |
+
intro hRzero
|
| 1286 |
+
rw [hRzero] at hRpos
|
| 1287 |
+
simp at hRpos
|
| 1288 |
+
let L : Polynomial ℂ := Polynomial.X * R.derivative - Polynomial.C (n : ℂ) * R
|
| 1289 |
+
have hL_natDegree_le : L.natDegree ≤ R.natDegree := by
|
| 1290 |
+
dsimp [L]
|
| 1291 |
+
apply (Polynomial.natDegree_sub_le _ _).trans
|
| 1292 |
+
apply max_le
|
| 1293 |
+
· by_cases hder : R.derivative = 0
|
| 1294 |
+
· simp [hder]
|
| 1295 |
+
· have hder_le : R.derivative.natDegree ≤ R.natDegree - 1 :=
|
| 1296 |
+
Polynomial.natDegree_derivative_le R
|
| 1297 |
+
rw [Polynomial.natDegree_mul (by simp) hder]
|
| 1298 |
+
rw [Polynomial.natDegree_X]
|
| 1299 |
+
omega
|
| 1300 |
+
· exact Polynomial.natDegree_C_mul_le _ _
|
| 1301 |
+
have hL_coeff :
|
| 1302 |
+
L.coeff R.natDegree =
|
| 1303 |
+
R.leadingCoeff * ((R.natDegree : ℂ) - (n : ℂ)) := by
|
| 1304 |
+
dsimp [L]
|
| 1305 |
+
exact putnam_1962_b6_X_derivative_sub_nat_mul_coeff_natDegree n hRpos
|
| 1306 |
+
have hA_decomp :
|
| 1307 |
+
Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F =
|
| 1308 |
+
L + Polynomial.C ((n : ℂ) * ctop) * Polynomial.X ^ N := by
|
| 1309 |
+
dsimp [L, N]
|
| 1310 |
+
exact putnam_1962_b6_derivative_top_decomp n hnpos F R ctop hF_decomp
|
| 1311 |
+
have hF_sq_coeff :
|
| 1312 |
+
(F ^ 2).coeff (N + R.natDegree) =
|
| 1313 |
+
2 * ctop * R.leadingCoeff := by
|
| 1314 |
+
rw [hF_decomp]
|
| 1315 |
+
simpa [Polynomial.coeff_natDegree] using
|
| 1316 |
+
putnam_1962_b6_coeff_sq_of_decomp_top ctop
|
| 1317 |
+
hR_natDegree_lt_N (le_rfl : R.natDegree ≤ R.natDegree)
|
| 1318 |
+
have hA_sq_coeff :
|
| 1319 |
+
((Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F) ^ 2).coeff
|
| 1320 |
+
(N + R.natDegree) =
|
| 1321 |
+
2 * ((n : ℂ) * ctop) *
|
| 1322 |
+
(R.leadingCoeff * ((R.natDegree : ℂ) - (n : ℂ))) := by
|
| 1323 |
+
rw [hA_decomp]
|
| 1324 |
+
rw [putnam_1962_b6_coeff_sq_of_decomp_top ((n : ℂ) * ctop)
|
| 1325 |
+
hR_natDegree_lt_N hL_natDegree_le]
|
| 1326 |
+
rw [hL_coeff]
|
| 1327 |
+
have hA_sq_coeff_poly :
|
| 1328 |
+
((Polynomial.X * F.derivative - (n : Polynomial ℂ) * F) ^ 2).coeff
|
| 1329 |
+
(N + R.natDegree) =
|
| 1330 |
+
2 * ((n : ℂ) * ctop) *
|
| 1331 |
+
(R.leadingCoeff * ((R.natDegree : ℂ) - (n : ℂ))) := by
|
| 1332 |
+
change ((Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F) ^ 2).coeff
|
| 1333 |
+
(N + R.natDegree) =
|
| 1334 |
+
2 * ((n : ℂ) * ctop) *
|
| 1335 |
+
(R.leadingCoeff * ((R.natDegree : ℂ) - (n : ℂ)))
|
| 1336 |
+
exact hA_sq_coeff
|
| 1337 |
+
have henergy_coeff :=
|
| 1338 |
+
congrArg (fun p : Polynomial ℂ => p.coeff (N + R.natDegree)) hA_energy
|
| 1339 |
+
have hX_coeff :
|
| 1340 |
+
(Polynomial.X ^ (2 * n) : Polynomial ℂ).coeff (N + R.natDegree) = 0 := by
|
| 1341 |
+
dsimp [N]
|
| 1342 |
+
rw [Polynomial.coeff_X_pow]
|
| 1343 |
+
rw [if_neg (show 2 * n + R.natDegree ≠ 2 * n by omega)]
|
| 1344 |
+
have hsecond_coeff :
|
| 1345 |
+
(((n : Polynomial ℂ) ^ 2) * (Polynomial.X ^ (2 * n) - F ^ 2)).coeff
|
| 1346 |
+
(N + R.natDegree) =
|
| 1347 |
+
(n : ℂ) ^ 2 * (0 - 2 * ctop * R.leadingCoeff) := by
|
| 1348 |
+
rw [← Polynomial.C_eq_natCast (R := ℂ) n, ← Polynomial.C_pow]
|
| 1349 |
+
rw [Polynomial.coeff_C_mul, Polynomial.coeff_sub, hX_coeff, hF_sq_coeff]
|
| 1350 |
+
have hcontr :
|
| 1351 |
+
2 * ((n : ℂ) * ctop) *
|
| 1352 |
+
(R.leadingCoeff * ((R.natDegree : ℂ) - (n : ℂ))) +
|
| 1353 |
+
(n : ℂ) ^ 2 * (0 - 2 * ctop * R.leadingCoeff) = 0 := by
|
| 1354 |
+
simpa [Polynomial.coeff_add, hA_sq_coeff_poly, hsecond_coeff] using henergy_coeff
|
| 1355 |
+
have hnC_ne : (n : ℂ) ≠ 0 := by exact_mod_cast (ne_of_gt hnpos)
|
| 1356 |
+
have hctop_ne : ctop ≠ 0 := by
|
| 1357 |
+
dsimp [ctop]
|
| 1358 |
+
exact Polynomial.leadingCoeff_ne_zero.mpr hF_ne_zero
|
| 1359 |
+
have hR_lc_ne : R.leadingCoeff ≠ 0 :=
|
| 1360 |
+
Polynomial.leadingCoeff_ne_zero.mpr hR_ne_zero
|
| 1361 |
+
have hfactor_ne :
|
| 1362 |
+
2 * (n : ℂ) * ctop * R.leadingCoeff *
|
| 1363 |
+
((R.natDegree : ℂ) - (2 * n : ℕ)) ≠ 0 := by
|
| 1364 |
+
refine mul_ne_zero ?_ ?_
|
| 1365 |
+
· refine mul_ne_zero ?_ hR_lc_ne
|
| 1366 |
+
refine mul_ne_zero ?_ hctop_ne
|
| 1367 |
+
exact mul_ne_zero (by norm_num) hnC_ne
|
| 1368 |
+
· exact sub_ne_zero.mpr (by
|
| 1369 |
+
exact_mod_cast (ne_of_lt hR_natDegree_lt_N))
|
| 1370 |
+
apply hfactor_ne
|
| 1371 |
+
calc
|
| 1372 |
+
2 * (n : ℂ) * ctop * R.leadingCoeff *
|
| 1373 |
+
((R.natDegree : ℂ) - (2 * n : ℕ)) =
|
| 1374 |
+
2 * ((n : ℂ) * ctop) *
|
| 1375 |
+
(R.leadingCoeff * ((R.natDegree : ℂ) - (n : ℂ))) +
|
| 1376 |
+
(n : ℂ) ^ 2 * (0 - 2 * ctop * R.leadingCoeff) := by
|
| 1377 |
+
dsimp [N] at hR_natDegree_lt_N
|
| 1378 |
+
norm_num [Nat.cast_mul]
|
| 1379 |
+
ring
|
| 1380 |
+
_ = 0 := hcontr
|
| 1381 |
+
let c0 : ℂ := R.coeff 0
|
| 1382 |
+
have hR_eq_C : R = Polynomial.C c0 := by
|
| 1383 |
+
dsimp [c0]
|
| 1384 |
+
exact Polynomial.eq_C_of_natDegree_eq_zero hR_natDegree_zero
|
| 1385 |
+
have hF_two : F = Polynomial.C c0 + Polynomial.C ctop * Polynomial.X ^ N := by
|
| 1386 |
+
rw [hF_decomp, hR_eq_C]
|
| 1387 |
+
have hctop_eq :
|
| 1388 |
+
ctop = (((b n : ℂ) - Complex.I * (a n : ℂ)) / 2) := by
|
| 1389 |
+
dsimp [ctop]
|
| 1390 |
+
exact hF_leadingCoeff
|
| 1391 |
+
have hc0_eq :
|
| 1392 |
+
c0 = (((b n : ℂ) + Complex.I * (a n : ℂ)) / 2) := by
|
| 1393 |
+
have hc0_F : c0 = F.coeff 0 := by
|
| 1394 |
+
dsimp [c0, R]
|
| 1395 |
+
rw [Polynomial.eraseLead_coeff_of_ne]
|
| 1396 |
+
rw [hF_natDegree_eq]
|
| 1397 |
+
omega
|
| 1398 |
+
rw [hc0_F]
|
| 1399 |
+
dsimp [F]
|
| 1400 |
+
exact putnam_1962_b6_complexPoly_coeff_zero hnpos a b
|
| 1401 |
+
have hN_pos : 0 < N := by
|
| 1402 |
+
dsimp [N]
|
| 1403 |
+
omega
|
| 1404 |
+
have hF_sq_coeff_N :
|
| 1405 |
+
(F ^ 2).coeff N = 2 * ctop * c0 := by
|
| 1406 |
+
rw [hF_two]
|
| 1407 |
+
have h := putnam_1962_b6_coeff_sq_of_decomp_top
|
| 1408 |
+
(L := Polynomial.C c0) (N := N) (d := 0) ctop hN_pos (by simp)
|
| 1409 |
+
simpa using h
|
| 1410 |
+
have hL_const :
|
| 1411 |
+
Polynomial.X * R.derivative - Polynomial.C (n : ℂ) * R =
|
| 1412 |
+
Polynomial.C (-(n : ℂ) * c0) := by
|
| 1413 |
+
rw [hR_eq_C]
|
| 1414 |
+
simp
|
| 1415 |
+
have hA_decomp_const :
|
| 1416 |
+
Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F =
|
| 1417 |
+
Polynomial.C (-(n : ℂ) * c0) +
|
| 1418 |
+
Polynomial.C ((n : ℂ) * ctop) * Polynomial.X ^ N := by
|
| 1419 |
+
have h := putnam_1962_b6_derivative_top_decomp n hnpos F R ctop hF_decomp
|
| 1420 |
+
rwa [hL_const] at h
|
| 1421 |
+
have hA_sq_coeff_N :
|
| 1422 |
+
((Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F) ^ 2).coeff N =
|
| 1423 |
+
2 * ((n : ℂ) * ctop) * (-(n : ℂ) * c0) := by
|
| 1424 |
+
rw [hA_decomp_const]
|
| 1425 |
+
have h := putnam_1962_b6_coeff_sq_of_decomp_top
|
| 1426 |
+
(L := Polynomial.C (-(n : ℂ) * c0)) (N := N) (d := 0)
|
| 1427 |
+
((n : ℂ) * ctop) hN_pos (by rw [Polynomial.natDegree_C])
|
| 1428 |
+
simpa using h
|
| 1429 |
+
have hA_sq_coeff_N_poly :
|
| 1430 |
+
((Polynomial.X * F.derivative - (n : Polynomial ℂ) * F) ^ 2).coeff N =
|
| 1431 |
+
2 * ((n : ℂ) * ctop) * (-(n : ℂ) * c0) := by
|
| 1432 |
+
change ((Polynomial.X * F.derivative - Polynomial.C (n : ℂ) * F) ^ 2).coeff N =
|
| 1433 |
+
2 * ((n : ℂ) * ctop) * (-(n : ℂ) * c0)
|
| 1434 |
+
exact hA_sq_coeff_N
|
| 1435 |
+
have hX_coeff_N : (Polynomial.X ^ (2 * n) : Polynomial ℂ).coeff N = 1 := by
|
| 1436 |
+
dsimp [N]
|
| 1437 |
+
simp
|
| 1438 |
+
have hsecond_coeff_N :
|
| 1439 |
+
(((n : Polynomial ℂ) ^ 2) * (Polynomial.X ^ (2 * n) - F ^ 2)).coeff N =
|
| 1440 |
+
(n : ℂ) ^ 2 * (1 - 2 * ctop * c0) := by
|
| 1441 |
+
rw [← Polynomial.C_eq_natCast (R := ℂ) n, ← Polynomial.C_pow]
|
| 1442 |
+
rw [Polynomial.coeff_C_mul, Polynomial.coeff_sub, hX_coeff_N, hF_sq_coeff_N]
|
| 1443 |
+
have henergy_coeff_N :=
|
| 1444 |
+
congrArg (fun p : Polynomial ℂ => p.coeff N) hA_energy
|
| 1445 |
+
have hcoeff_relation :
|
| 1446 |
+
2 * ((n : ℂ) * ctop) * (-(n : ℂ) * c0) +
|
| 1447 |
+
(n : ℂ) ^ 2 * (1 - 2 * ctop * c0) = 0 := by
|
| 1448 |
+
simpa [Polynomial.coeff_add, hA_sq_coeff_N_poly, hsecond_coeff_N] using
|
| 1449 |
+
henergy_coeff_N
|
| 1450 |
+
have hnC_ne : (n : ℂ) ≠ 0 := by exact_mod_cast (ne_of_gt hnpos)
|
| 1451 |
+
have hprod : 4 * ctop * c0 = 1 := by
|
| 1452 |
+
have hmain : (n : ℂ) ^ 2 * (1 - 4 * ctop * c0) = 0 := by
|
| 1453 |
+
calc
|
| 1454 |
+
(n : ℂ) ^ 2 * (1 - 4 * ctop * c0) =
|
| 1455 |
+
2 * ((n : ℂ) * ctop) * (-(n : ℂ) * c0) +
|
| 1456 |
+
(n : ℂ) ^ 2 * (1 - 2 * ctop * c0) := by ring
|
| 1457 |
+
_ = 0 := hcoeff_relation
|
| 1458 |
+
have hone : 1 - 4 * ctop * c0 = 0 :=
|
| 1459 |
+
(mul_eq_zero.mp hmain).resolve_left (pow_ne_zero _ hnC_ne)
|
| 1460 |
+
exact (sub_eq_zero.mp hone).symm
|
| 1461 |
+
have hABsq : (a n) ^ 2 + (b n) ^ 2 = 1 := by
|
| 1462 |
+
have hprod' :
|
| 1463 |
+
4 * (((b n : ℂ) - Complex.I * (a n : ℂ)) / 2) *
|
| 1464 |
+
(((b n : ℂ) + Complex.I * (a n : ℂ)) / 2) = 1 := by
|
| 1465 |
+
simpa [hctop_eq, hc0_eq] using hprod
|
| 1466 |
+
have hC : (((a n) ^ 2 + (b n) ^ 2 : ℝ) : ℂ) = 1 := by
|
| 1467 |
+
calc
|
| 1468 |
+
(((a n) ^ 2 + (b n) ^ 2 : ℝ) : ℂ) =
|
| 1469 |
+
4 * (((b n : ℂ) - Complex.I * (a n : ℂ)) / 2) *
|
| 1470 |
+
(((b n : ℂ) + Complex.I * (a n : ℂ)) / 2) := by
|
| 1471 |
+
ring_nf
|
| 1472 |
+
rw [Complex.I_sq]
|
| 1473 |
+
push_cast
|
| 1474 |
+
ring
|
| 1475 |
+
_ = 1 := hprod'
|
| 1476 |
+
exact_mod_cast hC
|
| 1477 |
+
have htop_function :
|
| 1478 |
+
f = fun x : ℝ => a n * Real.sin (n * x) + b n * Real.cos (n * x) := by
|
| 1479 |
+
funext x
|
| 1480 |
+
let z : ℂ := Complex.exp (x * Complex.I)
|
| 1481 |
+
have hsum_f :
|
| 1482 |
+
(∑ k ∈ Finset.Icc 0 n,
|
| 1483 |
+
((a k : ℂ) * (Real.sin (k * x) : ℂ) +
|
| 1484 |
+
(b k : ℂ) * (Real.cos (k * x) : ℂ))) = (f x : ℂ) := by
|
| 1485 |
+
have hsum_real :
|
| 1486 |
+
∑ k ∈ Finset.Icc 0 n,
|
| 1487 |
+
(a k * Real.sin (k * x) + b k * Real.cos (k * x)) = f x := by
|
| 1488 |
+
rw [hf]
|
| 1489 |
+
rw [← hsum_real]
|
| 1490 |
+
push_cast
|
| 1491 |
+
rfl
|
| 1492 |
+
have hevalF : F.eval z = z ^ n * (f x : ℂ) := by
|
| 1493 |
+
dsimp [F, z]
|
| 1494 |
+
rw [putnam_1962_b6_complexPoly_eval, hsum_f]
|
| 1495 |
+
have heval_two : F.eval z = c0 + ctop * z ^ N := by
|
| 1496 |
+
rw [hF_two]
|
| 1497 |
+
simp [z]
|
| 1498 |
+
have hterm := putnam_1962_b6_complexPoly_eval_term (n := n) (k := n)
|
| 1499 |
+
(le_rfl : n ≤ n) (a n) (b n) x
|
| 1500 |
+
have htop_eval :
|
| 1501 |
+
ctop * z ^ N + c0 =
|
| 1502 |
+
z ^ n * ((a n : ℂ) * (Real.sin (n * x) : ℂ) +
|
| 1503 |
+
(b n : ℂ) * (Real.cos (n * x) : ℂ)) := by
|
| 1504 |
+
dsimp [z, N]
|
| 1505 |
+
rw [show n + n = 2 * n by omega] at hterm
|
| 1506 |
+
simpa [hctop_eq, hc0_eq, Nat.sub_self, pow_zero] using hterm
|
| 1507 |
+
have hzpow_ne : z ^ n ≠ 0 := pow_ne_zero _ (Complex.exp_ne_zero _)
|
| 1508 |
+
have hmul :
|
| 1509 |
+
z ^ n * (f x : ℂ) =
|
| 1510 |
+
z ^ n * ((a n : ℂ) * (Real.sin (n * x) : ℂ) +
|
| 1511 |
+
(b n : ℂ) * (Real.cos (n * x) : ℂ)) := by
|
| 1512 |
+
calc
|
| 1513 |
+
z ^ n * (f x : ℂ) = F.eval z := hevalF.symm
|
| 1514 |
+
_ = c0 + ctop * z ^ N := heval_two
|
| 1515 |
+
_ = ctop * z ^ N + c0 := by ring
|
| 1516 |
+
_ = z ^ n * ((a n : ℂ) * (Real.sin (n * x) : ℂ) +
|
| 1517 |
+
(b n : ℂ) * (Real.cos (n * x) : ℂ)) := htop_eval
|
| 1518 |
+
have hcomplex :
|
| 1519 |
+
(f x : ℂ) =
|
| 1520 |
+
(a n : ℂ) * (Real.sin (n * x) : ℂ) +
|
| 1521 |
+
(b n : ℂ) * (Real.cos (n * x) : ℂ) :=
|
| 1522 |
+
mul_left_cancel₀ hzpow_ne hmul
|
| 1523 |
+
exact_mod_cast hcomplex
|
| 1524 |
+
let w : ℂ := (b n : ℂ) - Complex.I * (a n : ℂ)
|
| 1525 |
+
have hw_normSq : Complex.normSq w = 1 := by
|
| 1526 |
+
dsimp [w]
|
| 1527 |
+
rw [Complex.normSq_apply]
|
| 1528 |
+
simp
|
| 1529 |
+
calc
|
| 1530 |
+
(b n) * (b n) + (a n) * (a n) = (a n) ^ 2 + (b n) ^ 2 := by ring
|
| 1531 |
+
_ = 1 := hABsq
|
| 1532 |
+
have hw_norm : ‖w‖ = 1 := by
|
| 1533 |
+
have hsq : ‖w‖ ^ 2 = 1 := by
|
| 1534 |
+
rw [Complex.sq_norm, hw_normSq]
|
| 1535 |
+
have hnonneg : 0 ≤ ‖w‖ := norm_nonneg _
|
| 1536 |
+
rcases (sq_eq_one_iff.mp hsq) with hposnorm | hnegnorm
|
| 1537 |
+
· exact hposnorm
|
| 1538 |
+
· linarith
|
| 1539 |
+
rcases (Complex.norm_eq_one_iff w).mp hw_norm with ⟨theta, htheta_exp⟩
|
| 1540 |
+
refine ⟨theta, ?_⟩
|
| 1541 |
+
have hcos_theta : Real.cos theta = b n := by
|
| 1542 |
+
have hre := congrArg Complex.re htheta_exp
|
| 1543 |
+
simpa [w, Complex.exp_mul_I] using hre
|
| 1544 |
+
have hsin_theta : Real.sin theta = -(a n) := by
|
| 1545 |
+
have him := congrArg Complex.im htheta_exp
|
| 1546 |
+
simpa [w, Complex.exp_mul_I] using him
|
| 1547 |
+
funext x
|
| 1548 |
+
rw [htop_function]
|
| 1549 |
+
rw [Real.cos_add, hcos_theta, hsin_theta]
|
| 1550 |
+
ring
|
Putnam-bench-verified/1963/Putnam1963A2.lean
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Mathlib
|
| 2 |
+
|
| 3 |
+
open Topology Filter
|
| 4 |
+
|
| 5 |
+
/--
|
| 6 |
+
Let $\{f(n)\}$ be a strictly increasing sequence of positive integers such that $f(2)=2$ and $f(mn)=f(m)f(n)$ for every relatively prime pair of positive integers $m$ and $n$ (the greatest common divisor of $m$ and $n$ is equal to $1$). Prove that $f(n)=n$ for every positive integer $n$.
|
| 7 |
+
-/
|
| 8 |
+
theorem putnam_1963_a2
|
| 9 |
+
(f : ℕ → ℕ)
|
| 10 |
+
(hfpos : ∀ n, f n > 0)
|
| 11 |
+
(hfinc : StrictMonoOn f (Set.Ici 1))
|
| 12 |
+
(hf2 : f 2 = 2)
|
| 13 |
+
(hfmn : ∀ m n, m > 0 → n > 0 → IsRelPrime m n → f (m * n) = f m * f n)
|
| 14 |
+
: ∀ n > 0, f n = n :=
|
| 15 |
+
by
|
| 16 |
+
have hstep (a : ℕ) (ha : 0 < a) : f a + 1 ≤ f (a + 1) := by
|
| 17 |
+
have hlt : f a < f (a + 1) := by
|
| 18 |
+
exact hfinc (a := a) (b := a + 1) (by exact ha) (by exact Nat.succ_pos a) (Nat.lt_succ_self a)
|
| 19 |
+
omega
|
| 20 |
+
have hf1 : f 1 = 1 := by
|
| 21 |
+
have hlt : f 1 < f 2 := by
|
| 22 |
+
exact hfinc (by norm_num) (by norm_num) (by norm_num)
|
| 23 |
+
have hpos : 0 < f 1 := hfpos 1
|
| 24 |
+
omega
|
| 25 |
+
have hslope (a d : ℕ) (ha : 0 < a) : f a + d ≤ f (a + d) := by
|
| 26 |
+
induction d with
|
| 27 |
+
| zero =>
|
| 28 |
+
simp
|
| 29 |
+
| succ d ih =>
|
| 30 |
+
have hnext : f (a + d) + 1 ≤ f (a + (d + 1)) := by
|
| 31 |
+
simpa [Nat.add_assoc] using hstep (a + d) (by omega)
|
| 32 |
+
omega
|
| 33 |
+
have hge_id (n : ℕ) (hn : 0 < n) : n ≤ f n := by
|
| 34 |
+
have h := hslope 1 (n - 1) (by norm_num)
|
| 35 |
+
have hsum : 1 + (n - 1) = n := by omega
|
| 36 |
+
rw [hf1, hsum] at h
|
| 37 |
+
simpa using h
|
| 38 |
+
have hle_of_endpoint (n b : ℕ) (hn : 0 < n) (hnb : n ≤ b) (hb : f b = b) : f n ≤ n := by
|
| 39 |
+
have h := hslope n (b - n) hn
|
| 40 |
+
have hsum : n + (b - n) = b := by omega
|
| 41 |
+
rw [hsum, hb] at h
|
| 42 |
+
omega
|
| 43 |
+
have heq_of_endpoint (n b : ℕ) (hn : 0 < n) (hnb : n ≤ b) (hb : f b = b) : f n = n := by
|
| 44 |
+
exact le_antisymm (hle_of_endpoint n b hn hnb hb) (hge_id n hn)
|
| 45 |
+
have hf3 : f 3 = 3 := by
|
| 46 |
+
let m : ℕ := f 3
|
| 47 |
+
have hm_ge : 3 ≤ m := by
|
| 48 |
+
have hlt : f 2 < f 3 := by
|
| 49 |
+
exact hfinc (by norm_num) (by norm_num) (by norm_num)
|
| 50 |
+
omega
|
| 51 |
+
have hf6 : f 6 = 2 * m := by
|
| 52 |
+
have h := hfmn 2 3 (by norm_num) (by norm_num)
|
| 53 |
+
(Nat.coprime_iff_isRelPrime.mp (by norm_num : Nat.Coprime 2 3))
|
| 54 |
+
norm_num [hf2, m] at h
|
| 55 |
+
exact h
|
| 56 |
+
have hf5_lower : m + 2 ≤ f 5 := by
|
| 57 |
+
simpa [m] using hslope 3 2 (by norm_num)
|
| 58 |
+
have hf5_upper : f 5 + 1 ≤ 2 * m := by
|
| 59 |
+
simpa [hf6] using hslope 5 1 (by norm_num)
|
| 60 |
+
have hf10 : f 10 = 2 * f 5 := by
|
| 61 |
+
have h := hfmn 2 5 (by norm_num) (by norm_num)
|
| 62 |
+
(Nat.coprime_iff_isRelPrime.mp (by norm_num : Nat.Coprime 2 5))
|
| 63 |
+
norm_num [hf2] at h
|
| 64 |
+
exact h
|
| 65 |
+
have hf10_upper : f 10 + 2 ≤ 4 * m := by
|
| 66 |
+
rw [hf10]
|
| 67 |
+
omega
|
| 68 |
+
have hf9_upper : f 9 + 3 ≤ 4 * m := by
|
| 69 |
+
have h : f 9 + 1 ≤ f 10 := by
|
| 70 |
+
simpa using hslope 9 1 (by norm_num)
|
| 71 |
+
omega
|
| 72 |
+
have hf18 : f 18 = 2 * f 9 := by
|
| 73 |
+
have h := hfmn 2 9 (by norm_num) (by norm_num)
|
| 74 |
+
(Nat.coprime_iff_isRelPrime.mp (by norm_num : Nat.Coprime 2 9))
|
| 75 |
+
norm_num [hf2] at h
|
| 76 |
+
exact h
|
| 77 |
+
have hf18_upper : f 18 + 6 ≤ 8 * m := by
|
| 78 |
+
rw [hf18]
|
| 79 |
+
omega
|
| 80 |
+
have hf15_upper : f 15 + 9 ≤ 8 * m := by
|
| 81 |
+
have h : f 15 + 3 ≤ f 18 := by
|
| 82 |
+
simpa using hslope 15 3 (by norm_num)
|
| 83 |
+
omega
|
| 84 |
+
have hf15 : f 15 = m * f 5 := by
|
| 85 |
+
have h := hfmn 3 5 (by norm_num) (by norm_num)
|
| 86 |
+
(Nat.coprime_iff_isRelPrime.mp (by norm_num : Nat.Coprime 3 5))
|
| 87 |
+
norm_num [m] at h
|
| 88 |
+
exact h
|
| 89 |
+
have hf15_lower : m * (m + 2) ≤ f 15 := by
|
| 90 |
+
rw [hf15]
|
| 91 |
+
exact Nat.mul_le_mul_left m hf5_lower
|
| 92 |
+
have hpoly : m * (m + 2) + 9 ≤ 8 * m :=
|
| 93 |
+
le_trans (Nat.add_le_add_right hf15_lower 9) hf15_upper
|
| 94 |
+
have hpoly_int : (m : ℤ) * ((m : ℤ) + 2) + 9 ≤ 8 * (m : ℤ) := by
|
| 95 |
+
exact_mod_cast hpoly
|
| 96 |
+
have hm_ge_int : (3 : ℤ) ≤ m := by
|
| 97 |
+
exact_mod_cast hm_ge
|
| 98 |
+
have hm_le_int : (m : ℤ) ≤ 3 := by
|
| 99 |
+
nlinarith [hpoly_int, hm_ge_int, sq_nonneg ((m : ℤ) - 3)]
|
| 100 |
+
have hm_le : m ≤ 3 := by
|
| 101 |
+
exact_mod_cast hm_le_int
|
| 102 |
+
have hm : m = 3 := le_antisymm hm_le hm_ge
|
| 103 |
+
simpa [m] using hm
|
| 104 |
+
have hmul_two_odd (N : ℕ) (hNpos : 0 < N) (hNodd : Odd N) (hN : f N = N) :
|
| 105 |
+
f (2 * N) = 2 * N := by
|
| 106 |
+
have hcop : IsRelPrime 2 N :=
|
| 107 |
+
Nat.coprime_iff_isRelPrime.mp (Nat.coprime_two_left.mpr hNodd)
|
| 108 |
+
have h := hfmn 2 N (by norm_num) hNpos hcop
|
| 109 |
+
simpa [hf2, hN] using h
|
| 110 |
+
have hmain : ∀ n, 0 < n → f n = n := by
|
| 111 |
+
intro n
|
| 112 |
+
induction n using Nat.strong_induction_on with
|
| 113 |
+
| h n ih =>
|
| 114 |
+
intro hn
|
| 115 |
+
by_cases h1 : n = 1
|
| 116 |
+
· subst n
|
| 117 |
+
exact hf1
|
| 118 |
+
by_cases h2n : n = 2
|
| 119 |
+
· subst n
|
| 120 |
+
exact hf2
|
| 121 |
+
by_cases h3n : n = 3
|
| 122 |
+
· subst n
|
| 123 |
+
exact hf3
|
| 124 |
+
have hn4 : 4 ≤ n := by omega
|
| 125 |
+
rcases Nat.even_or_odd n with hneven | hnodd
|
| 126 |
+
· let N : ℕ := n - 1
|
| 127 |
+
have hNpos : 0 < N := by
|
| 128 |
+
dsimp [N]
|
| 129 |
+
omega
|
| 130 |
+
have hNlt : N < n := by
|
| 131 |
+
dsimp [N]
|
| 132 |
+
omega
|
| 133 |
+
have hNle : n ≤ 2 * N := by
|
| 134 |
+
dsimp [N]
|
| 135 |
+
omega
|
| 136 |
+
have hNodd : Odd N := by
|
| 137 |
+
dsimp [N]
|
| 138 |
+
rcases hneven with ⟨k, hk⟩
|
| 139 |
+
use k - 1
|
| 140 |
+
omega
|
| 141 |
+
have hN : f N = N := ih N hNlt hNpos
|
| 142 |
+
have hb : f (2 * N) = 2 * N := hmul_two_odd N hNpos hNodd hN
|
| 143 |
+
exact heq_of_endpoint n (2 * N) hn hNle hb
|
| 144 |
+
· let N : ℕ := n - 2
|
| 145 |
+
have hNpos : 0 < N := by
|
| 146 |
+
dsimp [N]
|
| 147 |
+
omega
|
| 148 |
+
have hNlt : N < n := by
|
| 149 |
+
dsimp [N]
|
| 150 |
+
omega
|
| 151 |
+
have hNle : n ≤ 2 * N := by
|
| 152 |
+
dsimp [N]
|
| 153 |
+
omega
|
| 154 |
+
have hNodd : Odd N := by
|
| 155 |
+
dsimp [N]
|
| 156 |
+
rcases hnodd with ⟨k, hk⟩
|
| 157 |
+
use k - 1
|
| 158 |
+
omega
|
| 159 |
+
have hN : f N = N := ih N hNlt hNpos
|
| 160 |
+
have hb : f (2 * N) = 2 * N := hmul_two_odd N hNpos hNodd hN
|
| 161 |
+
exact heq_of_endpoint n (2 * N) hn hNle hb
|
| 162 |
+
exact hmain
|
README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pretty_name: PutnamBench Solution Preview
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
tags:
|
| 6 |
+
- lean
|
| 7 |
+
- theorem-proving
|
| 8 |
+
- mathematics
|
| 9 |
+
- putnam
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# PutnamBench Solution Preview
|
| 13 |
+
|
| 14 |
+
This dataset contains the first 12 verified Lean solution files from
|
| 15 |
+
[`humanfia-lab/putnambench-solution`](https://huggingface.co/datasets/humanfia-lab/putnambench-solution),
|
| 16 |
+
sorted in ascending order by repository path.
|
| 17 |
+
|
| 18 |
+
Source revision: `17c2f7165d3b94630ed4a6ffa83cbff773ce6ba0`
|
| 19 |
+
|
| 20 |
+
## Files
|
| 21 |
+
|
| 22 |
+
1. `Putnam-bench-verified/1962/Putnam1962A1.lean`
|
| 23 |
+
2. `Putnam-bench-verified/1962/Putnam1962A2.lean`
|
| 24 |
+
3. `Putnam-bench-verified/1962/Putnam1962A3.lean`
|
| 25 |
+
4. `Putnam-bench-verified/1962/Putnam1962A4.lean`
|
| 26 |
+
5. `Putnam-bench-verified/1962/Putnam1962A5.lean`
|
| 27 |
+
6. `Putnam-bench-verified/1962/Putnam1962A6.lean`
|
| 28 |
+
7. `Putnam-bench-verified/1962/Putnam1962B1.lean`
|
| 29 |
+
8. `Putnam-bench-verified/1962/Putnam1962B2.lean`
|
| 30 |
+
9. `Putnam-bench-verified/1962/Putnam1962B3.lean`
|
| 31 |
+
10. `Putnam-bench-verified/1962/Putnam1962B5.lean`
|
| 32 |
+
11. `Putnam-bench-verified/1962/Putnam1962B6.lean`
|
| 33 |
+
12. `Putnam-bench-verified/1963/Putnam1963A2.lean`
|
| 34 |
+
|
| 35 |
+
The original paths and file contents are preserved.
|