-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImagen_de_la_diferencia_de_conjuntos.lean
140 lines (121 loc) · 3.47 KB
/
Imagen_de_la_diferencia_de_conjuntos.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
-- Imagen_de_la_diferencia_de_conjuntos.lean
-- f[s] \ f[t] ⊆ f[s \ t].
-- José A. Alonso Jiménez <https://jaalonso.github.io>
-- Sevilla, 16-abril-2024
-- ---------------------------------------------------------------------
-- ---------------------------------------------------------------------
-- Demostrar que
-- f '' s \ f '' t ⊆ f '' (s \ t)
-- ----------------------------------------------------------------------
-- Demostración en lenguaje natural
-- ================================
-- Sea y ∈ f[s] \ f[t]. Entonces,
-- y ∈ f[s] (1)
-- y ∉ f[t] (2)
-- Por (1), existe un x tal que
-- x ∈ s (3)
-- f(x) = y (4)
-- Por tanto, para demostrar que y ∈ f[s \ t], basta probar que
-- x ∉ t. Para ello, supongamos que x ∈ t. Entonces, por (4),
-- y ∈ f[t] en contradicción con (2).
-- Demostraciones con Lean4
-- ========================
import Mathlib.Data.Set.Function
import Mathlib.Tactic
open Set
variable {α β : Type _}
variable (f : α → β)
variable (s t : Set α)
-- 1ª demostración
-- ===============
example : f '' s \ f '' t ⊆ f '' (s \ t) :=
by
intros y hy
-- y : β
-- hy : y ∈ f '' s \ f '' t
-- ⊢ y ∈ f '' (s \ t)
rcases hy with ⟨yfs, ynft⟩
-- yfs : y ∈ f '' s
-- ynft : ¬y ∈ f '' t
rcases yfs with ⟨x, hx⟩
-- x : α
-- hx : x ∈ s ∧ f x = y
rcases hx with ⟨xs, fxy⟩
-- xs : x ∈ s
-- fxy : f x = y
have h1 : x ∉ t := by
intro xt
-- xt : x ∈ t
-- ⊢ False
have h2 : f x ∈ f '' t := mem_image_of_mem f xt
have h3 : y ∈ f '' t := by rwa [fxy] at h2
show False
exact ynft h3
have h4 : x ∈ s \ t := mem_diff_of_mem xs h1
have h5 : f x ∈ f '' (s \ t) := mem_image_of_mem f h4
show y ∈ f '' (s \ t)
rwa [fxy] at h5
-- 2ª demostración
-- ===============
example : f '' s \ f '' t ⊆ f '' (s \ t) :=
by
intros y hy
-- y : β
-- hy : y ∈ f '' s \ f '' t
-- ⊢ y ∈ f '' (s \ t)
rcases hy with ⟨yfs, ynft⟩
-- yfs : y ∈ f '' s
-- ynft : ¬y ∈ f '' t
rcases yfs with ⟨x, hx⟩
-- x : α
-- hx : x ∈ s ∧ f x = y
rcases hx with ⟨xs, fxy⟩
-- xs : x ∈ s
-- fxy : f x = y
use x
-- ⊢ x ∈ s \ t ∧ f x = y
constructor
. -- ⊢ x ∈ s \ t
constructor
. -- ⊢ x ∈ s
exact xs
. -- ⊢ ¬x ∈ t
intro xt
-- xt : x ∈ t
-- ⊢ False
apply ynft
-- ⊢ y ∈ f '' t
rw [←fxy]
-- ⊢ f x ∈ f '' t
apply mem_image_of_mem
-- ⊢ x ∈ t
exact xt
. -- ⊢ f x = y
exact fxy
-- 3ª demostración
-- ===============
example : f '' s \ f '' t ⊆ f '' (s \ t) :=
by
rintro y ⟨⟨x, xs, fxy⟩, ynft⟩
-- y : β
-- ynft : ¬y ∈ f '' t
-- x : α
-- xs : x ∈ s
-- fxy : f x = y
-- ⊢ y ∈ f '' (s \ t)
use x
-- ⊢ x ∈ s \ t ∧ f x = y
aesop
-- 4ª demostración
-- ===============
example : f '' s \ f '' t ⊆ f '' (s \ t) :=
fun y ⟨⟨x, xs, fxy⟩, ynft⟩ ↦ ⟨x, by aesop⟩
-- 5ª demostración
-- ===============
example : f '' s \ f '' t ⊆ f '' (s \ t) :=
subset_image_diff f s t
-- Lemmas usados
-- =============
-- variable (x : α)
-- #check (mem_image_of_mem f : x ∈ s → f x ∈ f '' s)
-- #check (subset_image_diff f s t : f '' s \ f '' t ⊆ f '' (s \ t))