-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rango_del_cuadrado.lean
143 lines (130 loc) · 3.27 KB
/
Rango_del_cuadrado.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import data.real.basic
import data.real.sqrt
open set real
-- ---------------------------------------------------------------------
-- Ejercicio. Demostrar que
-- sqrt '' { x | x ≥ 0 } = {y | y ≥ 0}
-- ----------------------------------------------------------------------
example : sqrt '' { x | x ≥ 0 } = {y | y ≥ 0} :=
begin
ext,
split,
{ intro h,
rcases h with ⟨y,hy,eq⟩,
simp at *,
rw ← eq,
exact sqrt_nonneg y },
{ intro h,
use x ^ 2,
simp at *,
split,
{ exact pow_nonneg h 2 },
{ finish }},
end
-- Prueba
-- ======
/-
⊢ sqrt '' {x : ℝ | x ≥ 0} = {y : ℝ | y ≥ 0}
>> ext,
x : ℝ
⊢ x ∈ sqrt '' {x : ℝ | x ≥ 0} ↔ x ∈ {y : ℝ | y ≥ 0}
>> split,
| x : ℝ
| ⊢ x ∈ sqrt '' {x : ℝ | x ≥ 0} → x ∈ {y : ℝ | y ≥ 0}
| >> { intro h,
| h : x ∈ sqrt '' {x : ℝ | x ≥ 0}
| ⊢ x ∈ {y : ℝ | y ≥ 0}
| >> rcases h with ⟨y,hy,eq⟩,
| x y : ℝ,
| hy : y ∈ {x : ℝ | x ≥ 0},
| eq : y.sqrt = x
| ⊢ x ∈ {y : ℝ | y ≥ 0}
| >> simp at *,
| hy : 0 ≤ y
| ⊢ 0 ≤ x
| >> rw ← eq,
| ⊢ 0 ≤ y.sqrt
| >> exact sqrt_nonneg y },
x : ℝ
⊢ x ∈ {y : ℝ | y ≥ 0} → x ∈ sqrt '' {x : ℝ | x ≥ 0}
>> { intro h,
h : x ∈ {y : ℝ | y ≥ 0}
⊢ x ∈ sqrt '' {x : ℝ | x ≥ 0}
>> use x ^ 2,
⊢ x ^ 2 ∈ {x : ℝ | x ≥ 0} ∧ (x ^ 2).sqrt = x
>> simp at *,
h : 0 ≤ x
⊢ 0 ≤ x ^ 2 ∧ (x ^ 2).sqrt = x
>> split,
| ⊢ 0 ≤ x ^ 2
| >> { exact pow_nonneg h 2 },
⊢ (x ^ 2).sqrt = x
>> { exact sqrt_sqr h }},
no goals
-/
-- Comentario: Se han usado los lemas
-- + x.sqrt_nonneg : 0 ≤ x.sqrt
-- + pow_nonneg : 0 ≤ x → ∀ (n : ℕ), 0 ≤ x ^ n
-- Comprobación:
-- variable (x : ℝ)
-- #check @sqrt_nonneg x
-- #check @pow_nonneg _ _ x
-- ---------------------------------------------------------------------
-- Ejercicio. Demostrar que
-- range (λ (x : ℝ), x^2) = {y | y ≥ 0} :=
-- ----------------------------------------------------------------------
example : range (λ (x : ℝ), x^2) = {y | y ≥ 0} :=
begin
ext,
split,
{ intro h,
simp at *,
rcases h with ⟨y,hy⟩,
rw ← hy,
exact pow_two_nonneg y },
{ intro h,
use sqrt x,
simp at *,
by finish, },
end
-- Prueba
-- ======
/-
⊢ range (λ (x : ℝ), x ^ 2) = {y : ℝ | y ≥ 0}
>> ext,
x : ℝ
⊢ x ∈ range (λ (x : ℝ), x ^ 2) ↔ x ∈ {y : ℝ | y ≥ 0}
>> split,
| ⊢ x ∈ range (λ (x : ℝ), x ^ 2) → x ∈ {y : ℝ | y ≥ 0}
| >> { intro h,
| h : x ∈ range (λ (x : ℝ), x ^ 2)
| ⊢ x ∈ {y : ℝ | y ≥ 0}
| >> simp at *,
| h : ∃ (y : ℝ), y ^ 2 = x
| ⊢ 0 ≤ x
| >> rcases h with ⟨y,hy⟩,
| x y : ℝ,
| hy : y ^ 2 = x
| ⊢ 0 ≤ x
| >> rw ← hy,
| ⊢ 0 ≤ y ^ 2
| >> exact pow_two_nonneg y },
x : ℝ
⊢ x ∈ {y : ℝ | y ≥ 0} → x ∈ range (λ (x : ℝ), x ^ 2)
>> { intro h,
h : x ∈ {y : ℝ | y ≥ 0}
⊢ x ∈ range (λ (x : ℝ), x ^ 2)
>> use sqrt x,
⊢ (λ (x : ℝ), x ^ 2) x.sqrt = x
>> simp at *,
h : 0 ≤ x
⊢ x.sqrt ^ 2 = x
>> exact sqr_sqrt h },
no goals
-/
-- Comentario: Se han usado los lemas
-- + pow_two_nonneg x : 0 ≤ x ^ 2
-- + sqr_sqrt : 0 ≤ x → (sqrt x) ^ 2 = x
-- Comprobación:
-- #check @pow_two_nonneg _ _ x
-- #check @sqr_sqrt x