forked from ImperialCollegeLondon/M40001_lean
-
Notifications
You must be signed in to change notification settings - Fork 0
/
two_sided_inverse.lean
52 lines (46 loc) · 955 Bytes
/
two_sided_inverse.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
import tactic
/-! # Two-sided inverses
We define two-sided inverses, and prove that a function
is a bijection if and only if it has a two-sided inverse.
-/
-- let X and Y be types, and let f be a function.
variables {X Y : Type} (f : X → Y)
-- two-sided inverse
structure two_sided_inverse (f : X → Y) :=
(g : Y → X)
(hX : ∀ x : X, g (f x) = x)
(hY : ∀ y : Y, f (g y) = y)
open function
example : bijective f ↔ nonempty (two_sided_inverse f) :=
begin
split,
{ intro hf,
cases hf with hi hs,
choose g hg using hs,
let G : two_sided_inverse f :=
{ g := g,
hX := begin
intro x,
apply hi,
rw hg,
end,
hY := begin
exact hg,
end
},
use G,
},
{ rintro ⟨g, hX, hY⟩,
split,
{ intros a b hab,
apply_fun g at hab,
rw hX at hab,
rw hX at hab,
assumption
},
{ intro y,
use (g(y)),
apply hY,
}
}
end