-
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
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
-
168
-
169
-
170
-
171
-
172
-
173
-
174
-
175
-
176
-
177
-
178
-
179
-
180
-
181
-
182
-
183
-
184
-
185
-
186
-
187
-
188
-
189
-
190
-
191
-
192
-
193
-
194
-
195
-
196
-
197
-
198
-
199
-
200
-
201
-
202
-
203
-
204
-
205
-
206
-
207
-
208
-
209
-
210
-
211
-
212
-
213
-
214
-
215
-
216
-
217
-
218
-
219
-
220
-
221
-
222
-
223
-
224
-
225
-
226
-
227
-
228
-
229
-
230
-
231
-
232
-
233
-
234
-
235
-
236
-
237
-
238
-
239
-
240
-
241
-
242
-
243
-
244
-
245
-
246
-
247
-
248
-
249
-
250
-
251
-
252
-
253
-
254
-
255
-
256
-
257
-
258
-
259
-
260
-
261
-
262
-
263
-
264
-
265
-
266
-
267
-
268
-
269
-
270
-
271
-
272
-
273
-
274
-
275
-
276
-
277
-
278
-
279
-
280
-
281
import data.set.lattice
import data.set.function
import analysis.special_functions.log.basic
section
variables {α β : Type*}
variable f : α → β
variables s t : set α
variables u v : set β
open function
open set
example : f '' s ⊆ v ↔ s ⊆ f ⁻¹' v :=
begin
split,
{ intros h x xs,
have : f x ∈ f '' s,
from mem_image_of_mem _ xs,
exact h this },
intros h y ymem,
rcases ymem with ⟨x, xs, fxeq⟩,
rw ← fxeq,
apply h xs
end
example (h : injective f) : f ⁻¹' (f '' s) ⊆ s :=
begin
rintros x ⟨y, ys, fxeq⟩,
rw ← h fxeq,
exact ys
end
example : f '' (f⁻¹' u) ⊆ u :=
begin
rintros y ⟨x, xmem, rfl⟩,
exact xmem
end
example (h : surjective f) : u ⊆ f '' (f⁻¹' u) :=
begin
intros y yu,
rcases h y with ⟨x, fxeq⟩,
use x,
split,
{ show f x ∈ u,
rw fxeq, exact yu },
exact fxeq
end
example (h : s ⊆ t) : f '' s ⊆ f '' t :=
begin
rintros y ⟨x, xs, fxeq⟩,
use [x, h xs, fxeq]
end
example (h : u ⊆ v) : f ⁻¹' u ⊆ f ⁻¹' v :=
by intro x; apply h
example : f ⁻¹' (u ∪ v) = f ⁻¹' u ∪ f ⁻¹' v :=
by ext x; refl
example : f '' (s ∩ t) ⊆ f '' s ∩ f '' t :=
begin
rintros y ⟨x, ⟨xs, xt⟩, rfl⟩,
use [x, xs, rfl, x, xt, rfl]
end
example (h : injective f) : f '' s ∩ f '' t ⊆ f '' (s ∩ t) :=
begin
rintros y ⟨⟨x₁, x₁s, rfl⟩, ⟨x₂, x₂t, fx₂eq⟩⟩,
use [x₁, x₁s],
rw ← h fx₂eq,
exact x₂t
end
example : f '' s \ f '' t ⊆ f '' (s \ t) :=
begin
rintros y ⟨⟨x₁, x₁s, rfl⟩, h⟩,
use [x₁, x₁s],
intro h',
apply h,
use [x₁, h', rfl]
end
example : f ⁻¹' u \ f ⁻¹' v ⊆ f ⁻¹' (u \ v) :=
λ x, id
example : f '' s ∩ v = f '' (s ∩ f ⁻¹' v) :=
begin
ext y, split,
{ rintros ⟨⟨x, xs, rfl⟩, fxv⟩,
use [x, xs, fxv] },
rintros ⟨x, ⟨⟨xs, fxv⟩, rfl⟩⟩,
use [x, xs, rfl, fxv],
end
example : f '' (s ∩ f ⁻¹' u) ⊆ f '' s ∩ u :=
begin
rintros y ⟨x, ⟨xs, fxu⟩, rfl⟩,
use [x, xs, rfl, fxu],
end
example : s ∩ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∩ u) :=
begin
rintros x ⟨xs, fxu⟩,
use [x, xs, rfl, fxu],
end
example : s ∪ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∪ u) :=
begin
rintros x (xs | fxu),
{ left, use [x, xs, rfl] },
right, use fxu
end
variables {I : Type*} (A : I → set α) (B : I → set β)
example : f '' (⋃ i, A i) = ⋃ i, f '' A i :=
begin
ext y, simp,
split,
{ rintros ⟨x, ⟨i, xAi⟩, fxeq⟩,
use [i, x, xAi, fxeq] },
rintros ⟨i, x, xAi, fxeq⟩,
exact ⟨x, ⟨i, xAi⟩, fxeq⟩
end
example : f '' (⋂ i, A i) ⊆ ⋂ i, f '' A i :=
begin
intro y, simp,
intros x h fxeq i,
use [x, h i, fxeq],
end
example (i : I) (injf : injective f) : (⋂ i, f '' A i) ⊆ f '' (⋂ i, A i) :=
begin
intro y, simp,
intro h,
rcases h i with ⟨x, xAi, fxeq⟩,
use x, split,
{ intro i',
rcases h i' with ⟨x', x'Ai, fx'eq⟩,
have : f x = f x', by rw [fxeq, fx'eq],
have : x = x', from injf this,
rw this,
exact x'Ai },
exact fxeq
end
example : f ⁻¹' (⋃ i, B i) = ⋃ i, f ⁻¹' (B i) :=
by { ext x, simp }
example : f ⁻¹' (⋂ i, B i) = ⋂ i, f ⁻¹' (B i) :=
by { ext x, simp }
end
section
open set real
example : inj_on sqrt { x | x ≥ 0 } :=
begin
intros x xnonneg y ynonneg,
intro e,
calc
x = (sqrt x)^2 : by rw sq_sqrt xnonneg
... = (sqrt y)^2 : by rw e
... = y : by rw sq_sqrt ynonneg
end
example : inj_on (λ x, x^2) { x : ℝ | x ≥ 0 } :=
begin
intros x xnonneg y ynonneg,
intro e,
dsimp at *,
calc
x = sqrt (x^2) : by rw sqrt_sq xnonneg
... = sqrt (y^2) : by rw e
... = y : by rw sqrt_sq ynonneg,
end
example : sqrt '' { x | x ≥ 0 } = {y | y ≥ 0} :=
begin
ext y, split,
{ rintros ⟨x, ⟨xnonneg, rfl⟩⟩,
apply sqrt_nonneg },
intro ynonneg,
use y^2,
dsimp at *,
split,
apply pow_nonneg ynonneg,
apply sqrt_sq,
assumption,
end
example : range (λ x, x^2) = {y : ℝ | y ≥ 0} :=
begin
ext y,
split,
{ rintros ⟨x, rfl⟩,
dsimp at *,
apply pow_two_nonneg },
intro ynonneg,
use sqrt y,
exact sq_sqrt ynonneg,
end
end
section
variables {α β : Type*} [inhabited α]
noncomputable theory
open_locale classical
def inverse (f : α → β) : β → α :=
λ y : β, if h : ∃ x, f x = y then classical.some h else default
theorem inverse_spec {f : α → β} (y : β) (h : ∃ x, f x = y) :
f (inverse f y) = y :=
begin
rw inverse, dsimp, rw dif_pos h,
exact classical.some_spec h
end
variable f : α → β
open function
example : injective f ↔ left_inverse (inverse f) f :=
begin
split,
{ intros h y,
apply h,
apply inverse_spec,
use y },
intros h x1 x2 e,
rw [←h x1, ←h x2, e]
end
example : injective f ↔ left_inverse (inverse f) f :=
⟨λ h y, h (inverse_spec _ ⟨y, rfl⟩), λ h x1 x2 e, by rw [←h x1, ←h x2, e]⟩
example : surjective f ↔ right_inverse (inverse f) f :=
begin
split,
{ intros h y,
apply inverse_spec,
apply h },
intros h y,
use (inverse f y),
apply h
end
example : surjective f ↔ right_inverse (inverse f) f :=
⟨λ h y, inverse_spec _ (h _), λ h y, ⟨inverse f y, h _⟩⟩
end
section
variable {α : Type*}
open function
theorem Cantor : ∀ f : α → set α, ¬ surjective f :=
begin
intros f surjf,
let S := { i | i ∉ f i},
rcases surjf S with ⟨j, h⟩,
have h₁ : j ∉ f j,
{ intro h',
have : j ∉ f j,
by rwa h at h',
contradiction },
have h₂ : j ∈ S,
from h₁,
have h₃ : j ∉ S,
by rwa h at h₁,
contradiction
end
end