-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConmutatividad_de_la_interseccion.lean
150 lines (126 loc) · 3.49 KB
/
Conmutatividad_de_la_interseccion.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
-- Conmutatividad_de_la_interseccion.lean
-- s ∩ t = t ∩ s
-- José A. Alonso Jiménez <https://jaalonso.github.io>
-- Sevilla, 27-febrero-2024
-- ---------------------------------------------------------------------
-- ---------------------------------------------------------------------
-- Demostrar que
-- s ∩ t = t ∩ s
-- ----------------------------------------------------------------------
-- Demostración en lenguaje natural
-- ================================
-- Tenemos que demostrar que
-- (∀ x)[x ∈ s ∩ t ↔ x ∈ t ∩ s]
-- Demostratemos la equivalencia por la doble implicación.
--
-- Sea x ∈ s ∩ t. Entonces, se tiene
-- x ∈ s (1)
-- x ∈ t (2)
-- Luego x ∈ t ∩ s (por (2) y (1)).
--
-- La segunda implicación se demuestra análogamente.
-- Demostraciones con Lean4
-- ========================
import Mathlib.Data.Set.Basic
open Set
variable {α : Type}
variable (s t : Set α)
-- 1ª demostración
-- ===============
example : s ∩ t = t ∩ s :=
by
ext x
-- x : α
-- ⊢ x ∈ s ∩ t ↔ x ∈ t ∩ s
simp only [mem_inter_iff]
-- ⊢ x ∈ s ∧ x ∈ t ↔ x ∈ t ∧ x ∈ s
constructor
. -- ⊢ x ∈ s ∧ x ∈ t → x ∈ t ∧ x ∈ s
intro h
-- h : x ∈ s ∧ x ∈ t
-- ⊢ x ∈ t ∧ x ∈ s
constructor
. -- ⊢ x ∈ t
exact h.2
. -- ⊢ x ∈ s
exact h.1
. -- ⊢ x ∈ t ∧ x ∈ s → x ∈ s ∧ x ∈ t
intro h
-- h : x ∈ t ∧ x ∈ s
-- ⊢ x ∈ s ∧ x ∈ t
constructor
. -- ⊢ x ∈ s
exact h.2
. -- ⊢ x ∈ t
exact h.1
-- 2ª demostración
-- ===============
example : s ∩ t = t ∩ s :=
by
ext
-- x : α
-- ⊢ x ∈ s ∩ t ↔ x ∈ t ∩ s
simp only [mem_inter_iff]
-- ⊢ x ∈ s ∧ x ∈ t ↔ x ∈ t ∧ x ∈ s
exact ⟨fun h ↦ ⟨h.2, h.1⟩,
fun h ↦ ⟨h.2, h.1⟩⟩
-- 3ª demostración
-- ===============
example : s ∩ t = t ∩ s :=
by
ext
-- x : α
-- ⊢ x ∈ s ∩ t ↔ x ∈ t ∩ s
exact ⟨fun h ↦ ⟨h.2, h.1⟩,
fun h ↦ ⟨h.2, h.1⟩⟩
-- 4ª demostración
-- ===============
example : s ∩ t = t ∩ s :=
by
ext x
-- x : α
-- ⊢ x ∈ s ∩ t ↔ x ∈ t ∩ s
simp only [mem_inter_iff]
-- ⊢ x ∈ s ∧ x ∈ t ↔ x ∈ t ∧ x ∈ s
constructor
. -- ⊢ x ∈ s ∧ x ∈ t → x ∈ t ∧ x ∈ s
rintro ⟨xs, xt⟩
-- xs : x ∈ s
-- xt : x ∈ t
-- ⊢ x ∈ t ∧ x ∈ s
exact ⟨xt, xs⟩
. -- ⊢ x ∈ t ∧ x ∈ s → x ∈ s ∧ x ∈ t
rintro ⟨xt, xs⟩
-- xt : x ∈ t
-- xs : x ∈ s
-- ⊢ x ∈ s ∧ x ∈ t
exact ⟨xs, xt⟩
-- 5ª demostración
-- ===============
example : s ∩ t = t ∩ s :=
by
ext x
-- x : α
-- ⊢ x ∈ s ∩ t ↔ x ∈ t ∩ s
simp only [mem_inter_iff]
-- ⊢ x ∈ s ∧ x ∈ t ↔ x ∈ t ∧ x ∈ s
simp only [And.comm]
-- 6ª demostración
-- ===============
example : s ∩ t = t ∩ s :=
ext (fun _ ↦ And.comm)
-- 7ª demostración
-- ===============
example : s ∩ t = t ∩ s :=
by ext ; simp [And.comm]
-- 8ª demostración
-- ===============
example : s ∩ t = t ∩ s :=
inter_comm s t
-- Lemas usados
-- ============
-- variable (x : α)
-- variable (a b : Prop)
-- #check (And.comm : a ∧ b ↔ b ∧ a)
-- #check (inter_comm s t : s ∩ t = t ∩ s)
-- #check (mem_inter_iff x s t : x ∈ s ∩ t ↔ x ∈ s ∧ x ∈ t)