-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLas_funciones_suprayectivas_tienen_inversa_por_la_derecha.lean
144 lines (122 loc) · 3.55 KB
/
Las_funciones_suprayectivas_tienen_inversa_por_la_derecha.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
-- Las_funciones_suprayectivas_tienen_inversa_por_la_derecha.lean
-- Las funciones suprayectivas tienen inversa por la derecha.
-- José A. Alonso Jiménez <https://jaalonso.github.io>
-- Sevilla, 13-junio-2024
-- ---------------------------------------------------------------------
-- ---------------------------------------------------------------------
-- En Lean4, que g es una inversa por la izquierda de f está definido
-- por
-- LeftInverse (g : β → α) (f : α → β) : Prop :=
-- ∀ x, g (f x) = x
-- que g es una inversa por la derecha de f está definido por
-- RightInverse (g : β → α) (f : α → β) : Prop :=
-- LeftInverse f g
-- y que f tenga inversa por la derecha está definido por
-- HasRightInverse (f : α → β) : Prop :=
-- ∃ g : β → α, RightInverse g f
-- Finalmente, que f es suprayectiva está definido por
-- def Surjective (f : α → β) : Prop :=
-- ∀ b, ∃ a, f a = b
--
-- Demostrar que si f es una función suprayectiva, entonces f tiene
-- inversa por la derecha.
-- ---------------------------------------------------------------------
-- Demostración en lenguaje natural
-- ================================
-- Sea f: A → B una función suprayectiva. Sea g: B → A la función
-- definida por
-- g(y) = x, donde x es un elemento tal que f(x) = y
--
-- Veamos que g es una inversa por la derecha de f; es decir,
-- (∀y ∈ B)[f(g(y)) = y
-- Para ello, sea b ∈ B. Entonces,
-- f(g(b)) = f(a)
-- donde a es un elemento tal que
-- f(a) = b
-- Por tanto,
-- f(g(b)) = b
-- Demostraciones con Lean4
-- ========================
import Mathlib.Tactic
open Function Classical
variable {α β: Type _}
variable {f : α → β}
-- 1ª demostración
-- ===============
example
(hf : Surjective f)
: HasRightInverse f :=
by
unfold HasRightInverse
-- ⊢ ∃ finv, Function.RightInverse finv f
let g := fun y ↦ Classical.choose (hf y)
use g
-- ⊢ Function.RightInverse g f
unfold Function.RightInverse
-- ⊢ LeftInverse f g
unfold Function.LeftInverse
-- ⊢ ∀ (x : β), f (g x) = x
intro b
-- ⊢ f (g b) = b
exact Classical.choose_spec (hf b)
-- 2ª demostración
-- ===============
example
(hf : Surjective f)
: HasRightInverse f :=
by
let g := fun y ↦ Classical.choose (hf y)
use g
-- ⊢ Function.RightInverse g f
intro b
-- ⊢ f (g b) = b
exact Classical.choose_spec (hf b)
-- 3ª demostración
-- ===============
example
(hf : Surjective f)
: HasRightInverse f :=
by
use surjInv hf
-- ⊢ Function.RightInverse (surjInv hf) f
intro b
-- ⊢ f (surjInv hf b) = b
exact surjInv_eq hf b
-- 4ª demostración
-- ===============
example
(hf : Surjective f)
: HasRightInverse f :=
by
use surjInv hf
-- ⊢ Function.RightInverse (surjInv hf) f
exact surjInv_eq hf
-- 5ª demostración
-- ===============
example
(hf : Surjective f)
: HasRightInverse f :=
⟨surjInv hf, surjInv_eq hf⟩
-- 6ª demostración
-- ===============
example
(hf : Surjective f)
: HasRightInverse f :=
⟨_, rightInverse_surjInv hf⟩
-- 7ª demostración
-- ===============
example
(hf : Surjective f)
: HasRightInverse f :=
Surjective.hasRightInverse hf
-- Lemas usados
-- ============
-- variable (p : α -> Prop)
-- #check (Classical.choose_spec : (h : ∃ x, p x) → p (Classical.choose h))
--
-- variable (h : Surjective f)
-- variable (b : β)
-- #check (surjInv_eq h b : f (surjInv h b) = b)
-- #check (rightInverse_surjInv h : RightInverse (surjInv h) f)
--
-- #check (Surjective.hasRightInverse : Surjective f → HasRightInverse f)