|
import Mathlib |
|
set_option linter.unusedVariables.analyzeTactics true |
|
|
|
|
|
theorem imo_2022_p2_simple |
|
(g: β β β) |
|
(hβ: β x, 0 < x β β y:β , (0 < y β§ g (x) + g (y) β€ 2 * x * y |
|
β§ (β z:β, (0 < z β§ z β y) β Β¬ g (x) + g (z) β€ 2 * x * z) )) : |
|
(β x:β , 0 < x β g x = x^2) := by |
|
have hβ: β x y:β , 0 < x β§ 0 < y β g x + g y β€ 2 * x * y β x = y := by |
|
intros x y hp hβ |
|
by_contra! hc |
|
have gβ: 2 * x * x < g x + g x := by |
|
let β¨p,hβββ© := hβ x hp.1 |
|
cases' hββ with hββ hββ |
|
cases' hββ with hββ hββ |
|
by_cases hxp: x β p |
|
. have hββ: Β¬ g x + g x β€ 2 * x * x := by |
|
refine hββ x ?_ |
|
constructor |
|
. exact hp.1 |
|
. exact hxp |
|
exact not_le.mp hββ |
|
. push_neg at hxp |
|
exfalso |
|
have hpy: y β p := by exact Ne.trans_eq (id (Ne.symm hc)) hxp |
|
have hcy: Β¬g x + g y β€ 2 * x * y := by |
|
refine hββ y ?_ |
|
constructor |
|
. exact hp.2 |
|
. exact hpy |
|
linarith |
|
have gβ: 2 * y * y < g y + g y := by |
|
let β¨p,hβββ© := hβ y hp.2 |
|
cases' hββ with hββ hββ |
|
cases' hββ with hββ hββ |
|
by_cases hyp: y β p |
|
. have hββ: Β¬ g y + g y β€ 2 * y * y := by |
|
refine hββ y ?_ |
|
constructor |
|
. exact hp.2 |
|
. exact hyp |
|
exact not_le.mp hββ |
|
. push_neg at hyp |
|
exfalso |
|
have hpx: x β p := by exact Ne.trans_eq hc hyp |
|
have hcy: Β¬g x + g y β€ 2 * x * y := by |
|
rw [add_comm, mul_right_comm] |
|
refine hββ x ?_ |
|
constructor |
|
. exact hp.1 |
|
. exact hpx |
|
linarith |
|
ring_nf at gβ gβ |
|
simp at gβ gβ |
|
have gβ: x ^ 2 + y ^ 2 < g x + g y := by exact add_lt_add gβ gβ |
|
have gβ: x ^ 2 + y ^ 2 < 2 * x * y := by exact LT.lt.trans_le gβ hβ |
|
have gβ
: (x - y) ^ 2 < 0 := by |
|
rw [sub_sq, sub_add_eq_add_sub] |
|
exact sub_neg.mpr gβ |
|
have gβ: (x - y) β 0 := by exact sub_ne_zero.mpr hc |
|
have gβ: 0 < (x - y) ^ 2 := by exact (sq_pos_iff).mpr gβ |
|
have gβ: (0:β) β 0 := by |
|
refine ne_of_lt ?_ |
|
exact lt_trans gβ gβ
|
|
refine false_of_ne gβ |
|
have hβ: β x:β , 0 < x β g x β€ x ^ 2 := by |
|
intros x hxp |
|
let β¨y,hβββ© := hβ x hxp |
|
cases' hββ with hββ hββ |
|
cases' hββ with hββ hββ |
|
have hxy: x = y := by |
|
apply hβ x y |
|
. exact |
|
. exact hββ |
|
rw [β hxy] at hββ |
|
linarith |
|
have hβ: β x:β , 0 < x β Β¬ g x < x ^ 2 := by |
|
simp |
|
by_contra! hc |
|
let β¨x,hxpβ© := hc |
|
cases' hxp with hxp hβ |
|
let dβ:β := x ^ 2 - g x |
|
have hdβ : g x = x ^ 2 - dβ := by exact (sub_sub_self (x ^ 2) (g x)).symm |
|
let z:β := x + Real.sqrt dβ |
|
have hz: z = x + Real.sqrt dβ := by exact rfl |
|
have hzp: 0 < z := by |
|
refine add_pos hxp ?_ |
|
refine Real.sqrt_pos_of_pos ?_ |
|
exact sub_pos.mpr hβ |
|
have hxz: z β x := by |
|
rw [hz] |
|
simp |
|
push_neg |
|
refine Real.sqrt_ne_zero'.mpr ?_ |
|
exact sub_pos.mpr hβ |
|
have hβ
: g x + g z β€ 2 * x * z := by |
|
rw [hdβ] |
|
have hβ
β: - dβ + Real.sqrt (x ^ 2 - (x ^ 2 - dβ)) ^ 2 β€ 0 := by |
|
simp |
|
rw [Real.sq_sqrt] |
|
exact sub_nonneg_of_le (hβ x hxp) |
|
have hβ
β: x ^ 2 - dβ + z ^ 2 β€ 2 * x * z := by |
|
rw [hz, mul_add, add_sq] |
|
ring_nf |
|
repeat rw [add_assoc] |
|
refine add_le_add_left ?_ (x * Real.sqrt (x ^ 2 - g x) * 2) |
|
rw [hdβ] |
|
linarith |
|
exact add_le_of_add_le_left hβ
β (hβ z hzp) |
|
let β¨y,hypβ© := hβ x hxp |
|
cases' hyp with hyp hβ |
|
cases' hβ with hβ hβ |
|
have hxy: x = y := by |
|
apply hβ |
|
. exact |
|
. exact hβ |
|
have hβ: Β¬g x + g z β€ 2 * x * z := by |
|
refine hβ z ?_ |
|
constructor |
|
. exact hzp |
|
. exact Ne.trans_eq hxz hxy |
|
linarith[hβ
,hβ] |
|
intros x hxp |
|
have gβ: g x β€ x ^ 2 := by exact hβ x hxp |
|
have gβ: Β¬ g x < x ^ 2 := by exact hβ x hxp |
|
linarith |
|
|
|
|
|
|
|
|
|
|
|
theorem imo_2022_p2 |
|
(f: β β β) |
|
(hfp: β x:β, 0 < x β 0 < f x) |
|
(hβ: β x:β , 0 < x β β! y:β , 0 < y β§ (x * f (y) + y * f (x) β€ 2) ): |
|
β x:β , 0 < x β f (x) = 1 / x := by |
|
have hβ: β x y:β , (0 < x β§ 0 < y) β (x * f (y) + y * f (x) β€ 2) β x = y := by |
|
intros x y hp hβ |
|
by_contra! hc |
|
have hββ: x * f x + x * f x > 2 := by |
|
let β¨z,hβββ© := hβ x hp.1 |
|
cases' hββ with hββ hββ |
|
have hββ: y = z := by |
|
apply hββ y |
|
constructor |
|
. exact hp.2 |
|
. exact hβ |
|
have hxz: Β¬ x = z := by exact Ne.trans_eq hc hββ |
|
have hββ: Β¬ (fun y => 0 < y β§ x * f y + y * f x β€ 2) x := by |
|
exact mt (hββ x) hxz |
|
have hββ: Β¬ (0 < x β§ x * f x + x * f x β€ 2) := by exact hββ |
|
push_neg at hββ |
|
exact hββ hp.1 |
|
have hββ: y * f y + y * f y > 2 := by |
|
let β¨z,hβββ© := hβ y hp.2 |
|
cases' hββ with hββ hββ |
|
have hββ: x = z := by |
|
apply hββ x |
|
constructor |
|
. exact hp.1 |
|
. rw [add_comm] |
|
exact hβ |
|
have hxz: Β¬ y = z := by exact Ne.trans_eq (id (Ne.symm hc)) hββ |
|
have hββ: Β¬ (fun y_2 => 0 < y_2 β§ y * f y_2 + y_2 * f y β€ 2) y := by |
|
exact mt (hββ y) hxz |
|
have hββ: Β¬ (0 < y β§ y * f y + y * f y β€ 2) := by exact hββ |
|
push_neg at hββ |
|
exact hββ hp.2 |
|
ring_nf at hββ hββ |
|
simp at hββ hββ |
|
have hββ
: 1 / x < f x := by exact (div_lt_iffβ' hp.1).mpr (hββ) |
|
have hββ: 1 / y < f y := by exact (div_lt_iffβ' hp.2).mpr (hββ) |
|
have hββ: x / y + y / x < 2 := by |
|
refine lt_of_le_of_lt' hβ ?_ |
|
refine add_lt_add ?_ ?_ |
|
. rw [β mul_one_div] |
|
exact (mul_lt_mul_left hp.1).mpr hββ |
|
. rw [β mul_one_div] |
|
exact (mul_lt_mul_left hp.2).mpr hββ
|
|
have hββ: 2 < x / y + y / x := by |
|
refine lt_of_mul_lt_mul_right ?_ (le_of_lt hp.1) |
|
refine lt_of_mul_lt_mul_right ?_ (le_of_lt hp.2) |
|
repeat rw [add_mul, mul_assoc] |
|
rw [mul_comm x y, β mul_assoc (x/y)] |
|
rw [div_mul_comm x y y, div_mul_comm y x x, div_self, div_self] |
|
. ring_nf |
|
refine lt_of_sub_pos ?_ |
|
rw [mul_comm _ 2, β mul_assoc] |
|
rw [β sub_sq'] |
|
refine sq_pos_of_ne_zero ?_ |
|
exact sub_ne_zero.mpr hc.symm |
|
. exact ne_of_gt hp.1 |
|
. exact ne_of_gt hp.2 |
|
linarith |
|
have hβ: β x:β , 0 < x β x * f x β€ 1 := by |
|
intros x hxp |
|
let β¨y,hβββ© := hβ x hxp |
|
cases' hββ with hββ hββ |
|
have hxy: x = y := by |
|
apply hβ x y |
|
. constructor |
|
. exact hxp |
|
. exact hββ.1 |
|
. exact hββ.2 |
|
rw [β hxy] at hββ |
|
linarith |
|
have hβ: β x:β , 0 < x β Β¬ x * f x < 1 := by |
|
by_contra! hc |
|
let β¨x,hxpβ© := hc |
|
cases' hxp with hxp hβ |
|
let dβ:β := 1 - x * f x |
|
have hdβ : x * f x = 1 - dβ := by exact (sub_sub_self 1 (x * f x)).symm |
|
let z:β := x + dβ / f x |
|
have hz: z = x + dβ / f x := by exact rfl |
|
have hzp: 0 < z := by |
|
refine add_pos hxp ?_ |
|
refine div_pos ?_ ?_ |
|
. exact sub_pos.mpr hβ |
|
. exact hfp x hxp |
|
have hxz: Β¬ x = z := by |
|
by_contra! hczβ |
|
rw [β hczβ] at hz |
|
have hczβ: 0 < dβ / f x := by |
|
refine div_pos ?_ (hfp x hxp) |
|
exact sub_pos.mpr hβ |
|
linarith |
|
have hβ: Β¬ (x * f z + z * f x β€ 2) := by |
|
have hββ: x * f z + z * f x β€ 2 β x = z := by |
|
exact hβ x z |
|
exact mt hββ hxz |
|
have hβ
: x * f z < 1 := by |
|
suffices hβ
β: z * f z β€ 1 by |
|
refine lt_of_lt_of_le ?_ hβ
β |
|
refine (mul_lt_mul_right (hfp z hzp)).mpr ?_ |
|
rw [hz] |
|
refine lt_add_of_pos_right x ?_ |
|
refine div_pos ?_ (hfp x hxp) |
|
exact sub_pos.mpr hβ |
|
exact hβ z hzp |
|
have hβ: x * f z + z * f x < 2 := by |
|
suffices hβ: z * f x β€ 1 by |
|
linarith |
|
rw [hz, add_mul, hdβ] |
|
rw [div_mul_comm dβ (f x) (f x)] |
|
rw [div_self] |
|
. rw [one_mul, sub_add_cancel] |
|
. exact Ne.symm (ne_of_lt (hfp x hxp)) |
|
linarith |
|
intros x hxp |
|
have hβ: x * f x β€ 1 := by exact hβ x hxp |
|
have hβ
: Β¬ x * f x < 1 := by exact hβ x hxp |
|
refine eq_div_of_mul_eq ?_ ?_ |
|
. exact ne_of_gt hxp |
|
. push_neg at hβ
|
|
linarith |
|
|