-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLas_funciones_con_inversa_son_biyectivas.lean
156 lines (134 loc) · 3.92 KB
/
Las_funciones_con_inversa_son_biyectivas.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
144
145
146
147
148
149
150
151
152
153
154
155
156
-- Las_funciones_con_inversa_son_biyectivas.lean
-- Las funciones con inversa son biyectivas.
-- José A. Alonso Jiménez <https://jaalonso.github.io>
-- Sevilla, 14-junio-2024
-- ---------------------------------------------------------------------
-- ---------------------------------------------------------------------
-- En Lean4 se puede definir que g es una inversa de f por
-- def inversa (f : X → Y) (g : Y → X) :=
-- (∀ x, (g ∘ f) x = x) ∧ (∀ y, (f ∘ g) y = y)
-- y que f tiene inversa por
-- def tiene_inversa (f : X → Y) :=
-- ∃ g, inversa g f
--
-- Demostrar que si la función f tiene inversa, entonces f es biyectiva.
-- ---------------------------------------------------------------------
-- Demostración en lenguaje natural
-- ================================
-- Puesto que f tiene inversa, existe una g: Y → X tal que
-- (∀x)[(g ∘ f)(x) = x] (1)
-- (∀y)[(f ∘ g)(y) = y] (2)
--
-- Para demostrar que f es inyectiva, sean a, b ∈ X tales que
-- f(a) = f(b) (3)
-- entonces
-- a = g(f(a)) [por (1)]
-- = g(f(b)) [por (3)]
-- = b [por (1)]
--
-- Para demostrar que f es suprayectiva, sea y ∈ Y. Entonces, existe
-- a = g(y) ∈ X tal que
-- f(a) = f(g(y))
-- = y [por (2)]
--
-- Como f es inyectiva y suprayectiva, entonces es biyectiva.
-- Demostraciones con Lean4
-- ========================
import Mathlib.Tactic
open Function
variable {X Y : Type _}
variable (f : X → Y)
def inversa (f : X → Y) (g : Y → X) :=
(∀ x, (g ∘ f) x = x) ∧ (∀ y, (f ∘ g) y = y)
def tiene_inversa (f : X → Y) :=
∃ g, inversa g f
-- 1ª demostración
-- ===============
example
(hf : tiene_inversa f)
: Bijective f :=
by
rcases hf with ⟨g, ⟨h1, h2⟩⟩
-- g : Y → X
-- h1 : ∀ (x : Y), (f ∘ g) x = x
-- h2 : ∀ (y : X), (g ∘ f) y = y
constructor
. -- ⊢ Injective f
intros a b hab
-- a b : X
-- hab : f a = f b
-- ⊢ a = b
calc a = g (f a) := (h2 a).symm
_ = g (f b) := congr_arg g hab
_ = b := h2 b
. -- ⊢ Surjective f
intro y
-- y : Y
-- ⊢ ∃ a, f a = y
use g y
-- ⊢ f (g y) = y
exact h1 y
-- 2ª demostración
-- ===============
example
(hf : tiene_inversa f)
: Bijective f :=
by
rcases hf with ⟨g, ⟨h1, h2⟩⟩
-- g : Y → X
-- h1 : ∀ (x : Y), (f ∘ g) x = x
-- h2 : ∀ (y : X), (g ∘ f) y = y
constructor
. -- ⊢ Injective f
intros a b hab
-- a b : X
-- hab : f a = f b
-- ⊢ a = b
calc a = g (f a) := (h2 a).symm
_ = g (f b) := congr_arg g hab
_ = b := h2 b
. -- ⊢ Surjective f
intro y
-- y : Y
-- ⊢ ∃ a, f a = y
exact ⟨g y, h1 y⟩
-- 3ª demostración
-- ===============
example
(hf : tiene_inversa f)
: Bijective f :=
by
rcases hf with ⟨g, ⟨h1, h2⟩⟩
constructor
. exact LeftInverse.injective h2
. exact RightInverse.surjective h1
-- 4ª demostración
-- ===============
example
(hf : tiene_inversa f)
: Bijective f :=
by
rcases hf with ⟨g, ⟨h1, h2⟩⟩
exact ⟨LeftInverse.injective h2,
RightInverse.surjective h1⟩
-- 5ª demostración
-- ===============
example :
tiene_inversa f → Bijective f :=
by
rintro ⟨g, ⟨h1, h2⟩⟩
exact ⟨LeftInverse.injective h2,
RightInverse.surjective h1⟩
-- 6ª demostración
-- ===============
example :
tiene_inversa f → Bijective f :=
fun ⟨_, ⟨h1, h2⟩⟩ ↦ ⟨LeftInverse.injective h2,
RightInverse.surjective h1⟩
-- Lemas usados
-- ============
-- variable (x y : X)
-- variable (g : Y → X)
-- #check (congr_arg f : x = y → f x = f y)
-- #check (LeftInverse.injective : LeftInverse g f → Injective f)
-- #check (RightInverse.surjective : RightInverse g f → Surjective f)