Skip to content

Commit 6100c33

Browse files
committed
chore(Data/Real/GoldenRatio): namespace, fix names (#28815)
The defs are called `goldenRatio`/`goldenConj` but were confusingly referred to as `gold`/`goldConj` in all lemma names.
1 parent 204fe09 commit 6100c33

File tree

1 file changed

+101
-43
lines changed

1 file changed

+101
-43
lines changed

Mathlib/Data/Real/GoldenRatio.lean

Lines changed: 101 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,112 +27,156 @@ noncomputable section
2727

2828
open Polynomial
2929

30+
namespace Real
31+
3032
/-- The golden ratio `φ := (1 + √5)/2`. -/
3133
abbrev goldenRatio : ℝ := (1 + √5) / 2
3234

3335
/-- The conjugate of the golden ratio `ψ := (1 - √5)/2`. -/
3436
abbrev goldenConj : ℝ := (1 - √5) / 2
3537

36-
@[inherit_doc goldenRatio] scoped[goldenRatio] notation "φ" => goldenRatio
37-
@[inherit_doc goldenConj] scoped[goldenRatio] notation "ψ" => goldenConj
38-
open Real goldenRatio
38+
@[inherit_doc] scoped[goldenRatio] notation "φ" => Real.goldenRatio
39+
@[inherit_doc] scoped[goldenRatio] notation "ψ" => Real.goldenConj
40+
41+
open goldenRatio
3942

4043
/-- The inverse of the golden ratio is the opposite of its conjugate. -/
41-
theorem inv_gold : φ⁻¹ = -ψ := by
44+
theorem inv_goldenRatio : φ⁻¹ = -ψ := by
4245
have : 1 + √50 := by positivity
4346
field_simp [sub_mul, mul_add]
4447
norm_num
4548

49+
@[deprecated (since := "2025-08-23")] alias _root_.inv_gold := inv_goldenRatio
50+
4651
/-- The opposite of the golden ratio is the inverse of its conjugate. -/
47-
theorem inv_goldConj : ψ⁻¹ = -φ := by
52+
theorem inv_goldenConj : ψ⁻¹ = -φ := by
4853
rw [inv_eq_iff_eq_inv, ← neg_inv, ← neg_eq_iff_eq_neg]
49-
exact inv_gold.symm
54+
exact inv_goldenRatio.symm
55+
56+
@[deprecated (since := "2025-08-23")] alias _root_.inv_goldConj := inv_goldenConj
5057

5158
@[simp]
52-
theorem gold_mul_goldConj : φ * ψ = -1 := by
59+
theorem goldenRatio_mul_goldenConj : φ * ψ = -1 := by
5360
field_simp
5461
rw [← sq_sub_sq]
5562
norm_num
5663

64+
@[deprecated (since := "2025-08-23")] alias _root_.gold_mul_goldConj := goldenRatio_mul_goldenConj
65+
5766
@[simp]
58-
theorem goldConj_mul_gold : ψ * φ = -1 := by
67+
theorem goldenConj_mul_goldenRatio : ψ * φ = -1 := by
5968
rw [mul_comm]
60-
exact gold_mul_goldConj
69+
exact goldenRatio_mul_goldenConj
70+
71+
@[deprecated (since := "2025-08-23")] alias _root_.goldConj_mul_gold := goldenConj_mul_goldenRatio
6172

6273
@[simp]
63-
theorem gold_add_goldConj : φ + ψ = 1 := by
74+
theorem goldenRatio_add_goldenConj : φ + ψ = 1 := by
6475
rw [goldenRatio, goldenConj]
6576
ring
6677

67-
theorem one_sub_goldConj : 1 - φ = ψ := by
68-
linarith [gold_add_goldConj]
78+
@[deprecated (since := "2025-08-23")] alias _root_.gold_add_goldConj := goldenRatio_add_goldenConj
79+
80+
theorem one_sub_goldenConj : 1 - φ = ψ := by
81+
linarith [goldenRatio_add_goldenConj]
6982

70-
theorem one_sub_gold : 1 - ψ = φ := by
71-
linarith [gold_add_goldConj]
83+
@[deprecated (since := "2025-08-23")] alias _root_.one_sub_goldConj := one_sub_goldenConj
84+
85+
theorem one_sub_goldenRatio : 1 - ψ = φ := by
86+
linarith [goldenRatio_add_goldenConj]
87+
88+
@[deprecated (since := "2025-08-23")] alias _root_.one_sub_gold := one_sub_goldenRatio
7289

7390
@[simp]
74-
theorem gold_sub_goldConj : φ - ψ = √5 := by ring
91+
theorem goldenRatio_sub_goldenConj : φ - ψ = √5 := by ring
7592

76-
theorem gold_pow_sub_gold_pow (n : ℕ) : φ ^ (n + 2) - φ ^ (n + 1) = φ ^ n := by
93+
@[deprecated (since := "2025-08-23")] alias _root_.gold_sub_goldConj := goldenRatio_sub_goldenConj
94+
95+
theorem goldenRatio_pow_sub_goldenRatio_pow (n : ℕ) : φ ^ (n + 2) - φ ^ (n + 1) = φ ^ n := by
7796
rw [goldenRatio]; ring_nf; norm_num; ring
7897

98+
@[deprecated (since := "2025-08-23")]
99+
alias gold_pow_sub_gold_pow := goldenRatio_pow_sub_goldenRatio_pow
100+
79101
@[simp 1200]
80-
theorem gold_sq : φ ^ 2 = φ + 1 := by
102+
theorem goldenRatio_sq : φ ^ 2 = φ + 1 := by
81103
rw [goldenRatio, ← sub_eq_zero]
82104
ring_nf
83105
rw [Real.sq_sqrt] <;> norm_num
84106

107+
@[deprecated (since := "2025-08-23")] alias _root_.gold_sq := goldenRatio_sq
108+
85109
@[simp 1200]
86-
theorem goldConj_sq : ψ ^ 2 = ψ + 1 := by
110+
theorem goldenConj_sq : ψ ^ 2 = ψ + 1 := by
87111
rw [goldenConj, ← sub_eq_zero]
88112
ring_nf
89113
rw [Real.sq_sqrt] <;> norm_num
90114

91-
theorem gold_pos : 0 < φ :=
115+
@[deprecated (since := "2025-08-23")] alias _root_.goldConj_sq := goldenConj_sq
116+
117+
theorem goldenRatio_pos : 0 < φ :=
92118
mul_pos (by apply add_pos <;> norm_num) <| inv_pos.2 zero_lt_two
93119

94-
theorem gold_ne_zero : φ ≠ 0 :=
95-
ne_of_gt gold_pos
120+
@[deprecated (since := "2025-08-23")] alias _root_.gold_pos := goldenRatio_pos
121+
122+
theorem goldenRatio_ne_zero : φ ≠ 0 :=
123+
ne_of_gt goldenRatio_pos
96124

97-
theorem one_lt_gold : 1 < φ := by
98-
refine lt_of_mul_lt_mul_left ?_ (le_of_lt gold_pos)
125+
@[deprecated (since := "2025-08-23")] alias _root_.gold_ne_zero := goldenRatio_ne_zero
126+
127+
theorem one_lt_goldenRatio : 1 < φ := by
128+
refine lt_of_mul_lt_mul_left ?_ (le_of_lt goldenRatio_pos)
99129
simp [← sq, zero_lt_one]
100130

101-
theorem gold_lt_two : φ < 2 := by calc
131+
@[deprecated (since := "2025-08-23")] alias _root_.one_lt_gold := one_lt_goldenRatio
132+
133+
theorem goldenRatio_lt_two : φ < 2 := by calc
102134
(1 + √5) / 2 < (1 + 3) / 2 := by gcongr; rw [sqrt_lt'] <;> norm_num
103135
_ = 2 := by norm_num
104136

105-
theorem goldConj_neg : ψ < 0 := by
106-
linarith [one_sub_goldConj, one_lt_gold]
137+
@[deprecated (since := "2025-08-23")] alias _root_.gold_lt_two := goldenRatio_lt_two
138+
139+
theorem goldenConj_neg : ψ < 0 := by
140+
linarith [one_sub_goldenConj, one_lt_goldenRatio]
141+
142+
@[deprecated (since := "2025-08-23")] alias _root_.goldConj_neg := goldenConj_neg
107143

108-
theorem goldConj_ne_zero : ψ ≠ 0 :=
109-
ne_of_lt goldConj_neg
144+
theorem goldenConj_ne_zero : ψ ≠ 0 :=
145+
ne_of_lt goldenConj_neg
110146

111-
theorem neg_one_lt_goldConj : -1 < ψ := by
112-
rw [neg_lt, ← inv_gold]
113-
exact inv_lt_one_of_one_lt₀ one_lt_gold
147+
@[deprecated (since := "2025-08-23")] alias _root_.goldConj_ne_zero := goldenConj_ne_zero
148+
149+
theorem neg_one_lt_goldenConj : -1 < ψ := by
150+
rw [neg_lt, ← inv_goldenRatio]
151+
exact inv_lt_one_of_one_lt₀ one_lt_goldenRatio
152+
153+
@[deprecated (since := "2025-08-23")] alias _root_.neg_one_lt_goldConj := neg_one_lt_goldenConj
114154

115155
/-!
116156
## Irrationality
117157
-/
118158

119159

120160
/-- The golden ratio is irrational. -/
121-
theorem gold_irrational : Irrational φ := by
161+
theorem goldenRatio_irrational : Irrational φ := by
122162
have := Nat.Prime.irrational_sqrt (show Nat.Prime 5 by norm_num)
123163
have := this.ratCast_add 1
124164
convert this.ratCast_mul (show (0.5 : ℚ) ≠ 0 by norm_num)
125165
norm_num
126166
field_simp
127167

168+
@[deprecated (since := "2025-08-23")] alias _root_.gold_irrational := goldenRatio_irrational
169+
128170
/-- The conjugate of the golden ratio is irrational. -/
129-
theorem goldConj_irrational : Irrational ψ := by
171+
theorem goldenConj_irrational : Irrational ψ := by
130172
have := Nat.Prime.irrational_sqrt (show Nat.Prime 5 by norm_num)
131173
have := this.ratCast_sub 1
132174
convert this.ratCast_mul (show (0.5 : ℚ) ≠ 0 by norm_num)
133175
norm_num
134176
field_simp
135177

178+
@[deprecated (since := "2025-08-23")] alias _root_.goldConj_irrational := goldenConj_irrational
179+
136180
/-!
137181
## Links with Fibonacci sequence
138182
-/
@@ -167,19 +211,25 @@ theorem fib_isSol_fibRec : fibRec.IsSolution (fun x => x.fib : ℕ → α) := by
167211
simp [Finset.sum_fin_eq_sum_range, Finset.sum_range_succ']
168212

169213
/-- The geometric sequence `fun n ↦ φ^n` is a solution of `fibRec`. -/
170-
theorem geom_gold_isSol_fibRec : fibRec.IsSolution (φ ^ ·) := by
214+
theorem geom_goldenRatio_isSol_fibRec : fibRec.IsSolution (φ ^ ·) := by
171215
rw [fibRec.geom_sol_iff_root_charPoly, fibRec_charPoly_eq]
172216
simp
173217

218+
@[deprecated (since := "2025-08-23")]
219+
alias _root_.geom_gold_isSol_fibRec := geom_goldenRatio_isSol_fibRec
220+
174221
/-- The geometric sequence `fun n ↦ ψ^n` is a solution of `fibRec`. -/
175-
theorem geom_goldConj_isSol_fibRec : fibRec.IsSolution (ψ ^ ·) := by
222+
theorem geom_goldenConj_isSol_fibRec : fibRec.IsSolution (ψ ^ ·) := by
176223
rw [fibRec.geom_sol_iff_root_charPoly, fibRec_charPoly_eq]
177224
simp
178225

226+
@[deprecated (since := "2025-08-23")]
227+
alias geom_goldConj_isSol_fibRec := geom_goldenConj_isSol_fibRec
228+
179229
end Fibrec
180230

181231
/-- Binet's formula as a function equality. -/
182-
theorem Real.coe_fib_eq' :
232+
theorem coe_fib_eq' :
183233
(fun n => Nat.fib n : ℕ → ℝ) = fun n => (φ ^ n - ψ ^ n) / √5 := by
184234
rw [fibRec.sol_eq_of_eq_init]
185235
· intro i hi
@@ -196,29 +246,37 @@ theorem Real.coe_fib_eq' :
196246
rw [Pi.sub_apply]
197247
ring
198248
apply (@fibRec ℝ _).solSpace.sub_mem
199-
· exact Submodule.smul_mem fibRec.solSpace (√5)⁻¹ geom_gold_isSol_fibRec
200-
· exact Submodule.smul_mem fibRec.solSpace (√5)⁻¹ geom_goldConj_isSol_fibRec
249+
· exact Submodule.smul_mem fibRec.solSpace (√5)⁻¹ geom_goldenRatio_isSol_fibRec
250+
· exact Submodule.smul_mem fibRec.solSpace (√5)⁻¹ geom_goldenConj_isSol_fibRec
201251

202-
/-- Binet's formula as a dependent equality. -/
203-
theorem Real.coe_fib_eq : ∀ n, (Nat.fib n : ℝ) = (φ ^ n - ψ ^ n) / √5 := by
252+
/-- **Binet's formula** as a dependent equality. -/
253+
theorem coe_fib_eq : ∀ n, (Nat.fib n : ℝ) = (φ ^ n - ψ ^ n) / √5 := by
204254
rw [← funext_iff, Real.coe_fib_eq']
205255

206256
/-- Relationship between the Fibonacci Sequence, Golden Ratio and its conjugate's exponents -/
207-
theorem fib_golden_conj_exp (n : ℕ) : Nat.fib (n + 1) - φ * Nat.fib n = ψ ^ n := by
257+
theorem fib_succ_sub_goldenRatio_mul_fib (n : ℕ) : Nat.fib (n + 1) - φ * Nat.fib n = ψ ^ n := by
208258
repeat rw [coe_fib_eq]
209259
rw [mul_div, div_sub_div_same, mul_sub, ← pow_succ']
210260
ring_nf
211261
have nz : √50 := by norm_num
212262
rw [← (mul_inv_cancel₀ nz).symm, one_mul]
213263

264+
@[deprecated (since := "2025-08-23")]
265+
alias _root_.fib_golden_conj_exp := fib_succ_sub_goldenRatio_mul_fib
266+
214267
/-- Relationship between the Fibonacci Sequence, Golden Ratio and its exponents -/
215-
theorem fib_golden_exp' (n : ℕ) : φ * Nat.fib (n + 1) + Nat.fib n = φ ^ (n + 1) := by
268+
lemma goldenRatio_mul_fib_succ_add_fib (n : ℕ) : φ * Nat.fib (n + 1) + Nat.fib n = φ ^ (n + 1) := by
216269
induction n with
217270
| zero => norm_num
218271
| succ n ih =>
219272
calc
220273
_ = φ * (Nat.fib n) + φ ^ 2 * (Nat.fib (n + 1)) := by
221274
simp only [Nat.fib_add_one (Nat.succ_ne_zero n), Nat.succ_sub_succ_eq_sub, tsub_zero,
222-
Nat.cast_add, gold_sq]; ring
275+
Nat.cast_add, goldenRatio_sq]; ring
223276
_ = φ * ((Nat.fib n) + φ * (Nat.fib (n + 1))) := by ring
224277
_ = φ ^ (n + 2) := by rw [add_comm, ih]; ring
278+
279+
@[deprecated (since := "2025-08-23")]
280+
alias _root_.fib_golden_exp' := goldenRatio_mul_fib_succ_add_fib
281+
282+
end Real

0 commit comments

Comments
 (0)