Skip to content

Commit 5876928

Browse files
committed
feat: formalize IMO 1959 Q2 (leanprover-community#9884)
1 parent 4b4c1a3 commit 5876928

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

Archive.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Archive.Examples.MersennePrimes
66
import Archive.Examples.PropEncodable
77
import Archive.Hairer
88
import Archive.Imo.Imo1959Q1
9+
import Archive.Imo.Imo1959Q2
910
import Archive.Imo.Imo1960Q1
1011
import Archive.Imo.Imo1962Q1
1112
import Archive.Imo.Imo1962Q4

Archive/Imo/Imo1959Q2.lean

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/-
2+
Copyright (c) 2024 Yury Kudryashov. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Yury Kudryashov
5+
-/
6+
import Mathlib.Data.Real.Sqrt
7+
8+
/-!
9+
# IMO 1959 Q2
10+
11+
For what real values of $x$ is
12+
13+
$\sqrt{x+\sqrt{2x-1}} + \sqrt{x-\sqrt{2x-1}} = A,$
14+
15+
given (a) $A=\sqrt{2}$, (b) $A=1$, (c) $A=2$,
16+
where only non-negative real numbers are admitted for square roots?
17+
18+
We encode the equation as a predicate saying both that the equation holds
19+
and that all arguments of square roots are nonnegative.
20+
21+
Then we follow second solution from the
22+
[Art of Problem Solving](https://artofproblemsolving.com/wiki/index.php/1959_IMO_Problems/Problem_2)
23+
website.
24+
Namely, we rewrite the equation as $\sqrt{2x-1}+1+|\sqrt{2x-1}-1|=A\sqrt{2}$,
25+
then consider the cases $\sqrt{2x-1}\le 1$ and $1 < \sqrt{2x-1}$ separately.
26+
-/
27+
28+
open Set Real
29+
30+
namespace Imo1959Q2
31+
32+
def IsGood (x A : ℝ) : Prop :=
33+
sqrt (x + sqrt (2 * x - 1)) + sqrt (x - sqrt (2 * x - 1)) = A ∧ 02 * x - 1
34+
0 ≤ x + sqrt (2 * x - 1) ∧ 0 ≤ x - sqrt (2 * x - 1)
35+
36+
variable {x A : ℝ}
37+
38+
theorem isGood_iff : IsGood x A ↔
39+
sqrt (2 * x - 1) + 1 + |sqrt (2 * x - 1) - 1| = A * sqrt 21 / 2 ≤ x := by
40+
cases le_or_lt (1 / 2) x with
41+
| inl hx =>
42+
have hx' : 02 * x - 1 := by linarith
43+
have h₁ : x + sqrt (2 * x - 1) = (sqrt (2 * x - 1) + 1) ^ 2 / 2 := by
44+
rw [add_sq, sq_sqrt hx']; field_simp; ring
45+
have h₂ : x - sqrt (2 * x - 1) = (sqrt (2 * x - 1) - 1) ^ 2 / 2 := by
46+
rw [sub_sq, sq_sqrt hx']; field_simp; ring
47+
simp only [IsGood, *, div_nonneg (sq_nonneg _) (zero_le_two (α := ℝ)), sqrt_div (sq_nonneg _),
48+
and_true]
49+
rw [sqrt_sq, sqrt_sq_eq_abs] <;> [skip; positivity]
50+
field_simp
51+
| inr hx =>
52+
have : 2 * x - 1 < 0 := by linarith
53+
simp only [IsGood, this.not_le, hx.not_le]; simp
54+
55+
theorem IsGood.one_half_le (h : IsGood x A) : 1 / 2 ≤ x := (isGood_iff.1 h).2
56+
57+
theorem sqrt_two_mul_sub_one_le_one : sqrt (2 * x - 1) ≤ 1 ↔ x ≤ 1 := by
58+
simp [sqrt_le_iff, ← two_mul]
59+
60+
theorem isGood_iff_eq_sqrt_two (hx : x ∈ Icc (1 / 2) 1) : IsGood x A ↔ A = sqrt 2 := by
61+
have : sqrt (2 * x - 1) ≤ 1 := sqrt_two_mul_sub_one_le_one.2 hx.2
62+
simp only [isGood_iff, hx.1, abs_sub_comm _ (1 : ℝ), abs_of_nonneg (sub_nonneg.2 this), and_true]
63+
suffices 2 = A * sqrt 2 ↔ A = sqrt 2 by convert this using 2; ring
64+
rw [← div_eq_iff, div_sqrt, eq_comm]
65+
positivity
66+
67+
theorem isGood_iff_eq_sqrt (hx : 1 < x) : IsGood x A ↔ A = sqrt (4 * x - 2) := by
68+
have h₁ : 1 < sqrt (2 * x - 1) := by simpa only [← not_le, sqrt_two_mul_sub_one_le_one] using hx
69+
have h₂ : 1 / 2 ≤ x := by linarith
70+
simp only [isGood_iff, h₂, abs_of_pos (sub_pos.2 h₁), add_add_sub_cancel, and_true]
71+
rw [← mul_two, ← div_eq_iff (by positivity), mul_div_assoc, div_sqrt, ← sqrt_mul' _ zero_le_two,
72+
eq_comm]
73+
ring_nf
74+
75+
theorem IsGood.sqrt_two_lt_of_one_lt (h : IsGood x A) (hx : 1 < x) : sqrt 2 < A := by
76+
rw [(isGood_iff_eq_sqrt hx).1 h]
77+
refine sqrt_lt_sqrt zero_le_two ?_
78+
linarith
79+
80+
theorem IsGood.eq_sqrt_two_iff_le_one (h : IsGood x A) : A = sqrt 2 ↔ x ≤ 1 :=
81+
fun hA ↦ not_lt.1 fun hx ↦ (h.sqrt_two_lt_of_one_lt hx).ne' hA, fun hx ↦
82+
(isGood_iff_eq_sqrt_two ⟨h.one_half_le, hx⟩).1 h⟩
83+
84+
theorem IsGood.sqrt_two_lt_iff_one_lt (h : IsGood x A) : sqrt 2 < A ↔ 1 < x :=
85+
fun hA ↦ not_le.1 fun hx ↦ hA.ne' <| h.eq_sqrt_two_iff_le_one.2 hx, h.sqrt_two_lt_of_one_lt⟩
86+
87+
theorem IsGood.sqrt_two_le (h : IsGood x A) : sqrt 2 ≤ A :=
88+
(le_or_lt x 1).elim (fun hx ↦ (h.eq_sqrt_two_iff_le_one.2 hx).ge) fun hx ↦
89+
(h.sqrt_two_lt_of_one_lt hx).le
90+
91+
theorem isGood_iff_of_sqrt_two_lt (hA : sqrt 2 < A) : IsGood x A ↔ x = (A / 2) ^ 2 + 1 / 2 := by
92+
have : 0 < A := lt_trans (by simp) hA
93+
constructor
94+
· intro h
95+
have hx : 1 < x := by rwa [h.sqrt_two_lt_iff_one_lt] at hA
96+
rw [isGood_iff_eq_sqrt hx, eq_comm, sqrt_eq_iff_sq_eq] at h <;> linarith
97+
· rintro rfl
98+
rw [isGood_iff_eq_sqrt]
99+
· conv_lhs => rw [← sqrt_sq this.le]
100+
ring_nf
101+
· rw [sqrt_lt' this] at hA
102+
linarith
103+
104+
theorem isGood_sqrt2_iff : IsGood x (sqrt 2) ↔ x ∈ Icc (1 / 2) 1 := by
105+
refine ⟨fun h ↦ ?_, fun h ↦ (isGood_iff_eq_sqrt_two h).2 rfl⟩
106+
exact ⟨h.one_half_le, not_lt.1 fun h₁ ↦ (h.sqrt_two_lt_of_one_lt h₁).false
107+
108+
theorem not_isGood_one : ¬IsGood x 1 := fun h ↦
109+
h.sqrt_two_le.not_lt <| (lt_sqrt zero_le_one).2 (by norm_num)
110+
111+
theorem isGood_two_iff : IsGood x 2 ↔ x = 3 / 2 :=
112+
(isGood_iff_of_sqrt_two_lt <| (sqrt_lt' two_pos).2 (by norm_num)).trans <| by norm_num

0 commit comments

Comments
 (0)