Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit a6024f1

Browse files
feat(archive/imo): formalize IMO 2008 Q4 (#7039)
feat(archive/imo): formalize IMO 2008 Q4
1 parent 7e71849 commit a6024f1

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

archive/imo/imo2008_q4.lean

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/-
2+
Copyright (c) 2021 Manuel Candales. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Manuel Candales
5+
-/
6+
import data.real.basic
7+
import data.real.sqrt
8+
import data.real.nnreal
9+
10+
/-!
11+
# IMO 2008 Q4
12+
Find all functions `f : (0,∞) → (0,∞)` (so, `f` is a function from the positive real
13+
numbers to the positive real numbers) such that
14+
```
15+
(f(w)^2 + f(x)^2)/(f(y^2) + f(z^2)) = (w^2 + x^2)/(y^2 + z^2)
16+
```
17+
for all positive real numbers `w`, `x`, `y`, `z`, satisfying `wx = yz`.
18+
19+
# Solution
20+
The desired theorem is that either `f = λ x, x` or `f = λ x, 1/x`
21+
-/
22+
23+
open real
24+
25+
lemma abs_eq_one_of_pow_eq_one (x : ℝ) (n : ℕ) (hn : n ≠ 0) (h : x ^ n = 1) : abs x = 1 :=
26+
begin
27+
let x₀ := nnreal.of_real (abs x),
28+
have h' : (abs x) ^ n = 1, { rwa [pow_abs, h, abs_one] },
29+
have : (x₀ : ℝ) ^ n = 1, rw (nnreal.coe_of_real (abs x) (abs_nonneg x)), exact h',
30+
have : x₀ = 1 := eq_one_of_pow_eq_one hn (show x₀ ^ n = 1, by assumption_mod_cast),
31+
rwa ← nnreal.coe_of_real (abs x) (abs_nonneg x), assumption_mod_cast,
32+
end
33+
34+
theorem imo2008_q4
35+
(f : ℝ → ℝ)
36+
(H₁ : ∀ x > 0, f(x) > 0) :
37+
(∀ w x y z : ℝ, 0 < w → 0 < x → 0 < y → 0 < z → w * x = y * z →
38+
(f(w) ^ 2 + f(x) ^ 2) / (f(y ^ 2) + f(z ^ 2)) = (w ^ 2 + x ^ 2) / (y ^ 2 + z ^ 2)) ↔
39+
((∀ x > 0, f(x) = x) ∨ (∀ x > 0, f(x) = 1 / x)) :=
40+
begin
41+
split, swap,
42+
-- proof that f(x) = x and f(x) = 1/x satisfy the condition
43+
{ rintros (h | h),
44+
{ intros w x y z hw hx hy hz hprod,
45+
rw [h w hw, h x hx, h (y ^ 2) (pow_pos hy 2), h (z ^ 2) (pow_pos hz 2)] },
46+
{ intros w x y z hw hx hy hz hprod,
47+
rw [h w hw, h x hx, h (y ^ 2) (pow_pos hy 2), h (z ^ 2) (pow_pos hz 2)],
48+
have hy2z2 : y ^ 2 + z ^ 20 := ne_of_gt (add_pos (pow_pos hy 2) (pow_pos hz 2)),
49+
have hz2y2 : z ^ 2 + y ^ 20 := ne_of_gt (add_pos (pow_pos hz 2) (pow_pos hy 2)),
50+
have hp2 : w ^ 2 * x ^ 2 = y ^ 2 * z ^ 2,
51+
{ rw [← mul_pow w x 2, ← mul_pow y z 2, hprod] },
52+
field_simp [ne_of_gt hw, ne_of_gt hx, ne_of_gt hy, ne_of_gt hz, hy2z2, hz2y2, hp2],
53+
ring } },
54+
55+
-- proof that the only solutions are f(x) = x or f(x) = 1/x
56+
intro H₂,
57+
have h₀ : f(1) ≠ 0, { specialize H₁ 1 zero_lt_one, exact ne_of_gt H₁ },
58+
59+
have h₁ : f(1) = 1,
60+
{ specialize H₂ 1 1 1 1 zero_lt_one zero_lt_one zero_lt_one zero_lt_one rfl,
61+
norm_num at H₂,
62+
simp only [← two_mul] at H₂,
63+
rw mul_div_mul_left (f(1) ^ 2) (f 1) two_ne_zero at H₂,
64+
rwa ← (div_eq_iff h₀).mpr (pow_two (f 1)) },
65+
66+
have h₂ : ∀ x > 0, (f(x) - x) * (f(x) - 1 / x) = 0,
67+
{ intros x hx,
68+
have h1xss : 1 * x = (sqrt x) * (sqrt x), { rw [one_mul, mul_self_sqrt (le_of_lt hx)] },
69+
specialize H₂ 1 x (sqrt x) (sqrt x) zero_lt_one hx (sqrt_pos.mpr hx) (sqrt_pos.mpr hx) h1xss,
70+
rw [h₁, one_pow 2, sqr_sqrt (le_of_lt hx), ← two_mul (f(x)), ← two_mul x] at H₂,
71+
have hx_ne_0 : x ≠ 0 := ne_of_gt hx,
72+
have hfx_ne_0 : f(x) ≠ 0, { specialize H₁ x hx, exact ne_of_gt H₁ },
73+
field_simp at H₂,
74+
75+
have h1 : (2 * x) * ((f(x) - x) * (f(x) - 1 / x)) = 0,
76+
{ calc (2 * x) * ((f(x) - x) * (f(x) - 1 / x))
77+
= 2 * (f(x) - x) * (x * f(x) - x * 1 / x) : by ring
78+
... = 2 * (f(x) - x) * (x * f(x) - 1) : by rw (mul_div_cancel_left 1 hx_ne_0)
79+
... = ((1 + f(x) ^ 2) * (2 * x) - (1 + x ^ 2) * (2 * f(x))) : by ring
80+
... = 0 : sub_eq_zero.mpr H₂ },
81+
82+
have h2x_ne_0 : 2 * x ≠ 0 := mul_ne_zero two_ne_zero hx_ne_0,
83+
84+
calc ((f(x) - x) * (f(x) - 1 / x))
85+
= (2 * x) * ((f(x) - x) * (f(x) - 1 / x)) / (2 * x) : (mul_div_cancel_left _ h2x_ne_0).symm
86+
... = 0 : by { rw h1, exact zero_div (2 * x) } },
87+
88+
have h₃ : ∀ x > 0, f(x) = x ∨ f(x) = 1 / x, { simpa [sub_eq_zero] using h₂ },
89+
90+
by_contradiction,
91+
push_neg at h,
92+
rcases h with ⟨⟨b, hb, hfb₁⟩, ⟨a, ha, hfa₁⟩⟩,
93+
obtain hfa₂ := or.resolve_right (h₃ a ha) hfa₁, -- f(a) ≠ 1/a, f(a) = a
94+
obtain hfb₂ := or.resolve_left (h₃ b hb) hfb₁, -- f(b) ≠ b, f(b) = 1/b
95+
96+
have hab : a * b > 0 := mul_pos ha hb,
97+
have habss : a * b = sqrt(a * b) * sqrt(a * b) := (mul_self_sqrt (le_of_lt hab)).symm,
98+
99+
specialize H₂ a b (sqrt (a * b)) (sqrt (a * b)) ha hb (sqrt_pos.mpr hab) (sqrt_pos.mpr hab) habss,
100+
rw [sqr_sqrt (le_of_lt hab), ← two_mul (f(a * b)), ← two_mul (a * b)] at H₂,
101+
rw [hfa₂, hfb₂] at H₂,
102+
103+
have h2ab_ne_0 : 2 * (a * b) ≠ 0 := mul_ne_zero two_ne_zero (ne_of_gt hab),
104+
105+
specialize h₃ (a * b) hab,
106+
cases h₃ with hab₁ hab₂,
107+
108+
-- f(ab) = ab → b^4 = 1 → b = 1 → f(b) = b → false
109+
{ rw hab₁ at H₂, field_simp at H₂,
110+
obtain hb₁ := or.resolve_right H₂ h2ab_ne_0,
111+
field_simp [ne_of_gt hb] at hb₁,
112+
rw (show b ^ 2 * b ^ 2 = b ^ 4, by ring) at hb₁,
113+
obtain hb₂ := abs_eq_one_of_pow_eq_one b 4 (show 40, by norm_num) hb₁.symm,
114+
rw abs_of_pos hb at hb₂, rw hb₂ at hfb₁, exact hfb₁ h₁ },
115+
116+
-- f(ab) = 1/ab → a^4 = 1 → a = 1 → f(a) = 1/a → false
117+
{ have hb_ne_0 : b ≠ 0 := ne_of_gt hb,
118+
rw hab₂ at H₂, field_simp at H₂,
119+
rw ← sub_eq_zero at H₂,
120+
rw (show (a ^ 2 * b ^ 2 + 1) * (a * b) * (2 * (a * b)) - (a ^ 2 + b ^ 2) * (b ^ 2 * 2)
121+
= 2 * (b ^ 4) * (a ^ 4 - 1), by ring) at H₂,
122+
have h2b4_ne_0 : 2 * (b ^ 4) ≠ 0 := mul_ne_zero two_ne_zero (pow_ne_zero 4 hb_ne_0),
123+
have ha₁ : a ^ 4 = 1, { simpa [sub_eq_zero, h2b4_ne_0] using H₂ },
124+
obtain ha₂ := abs_eq_one_of_pow_eq_one a 4 (show 40, by norm_num) ha₁,
125+
rw abs_of_pos ha at ha₂, rw ha₂ at hfa₁, norm_num at hfa₁ },
126+
end

0 commit comments

Comments
 (0)