La semana en Calculemus (16 de marzo de 2024)
Esta semana he publicado en Calculemus las demostraciones con Lean4 de las siguientes propiedades:
- 1. s ∪ (⋂ᵢ Aᵢ) = ⋂ᵢ (Aᵢ ∪ s)
- 2. f⁻¹(u ∩ v) = f⁻¹(u) ∩ f⁻¹(v)
- 3. f(s ∪ t) = f(s) ∪ f(t)
- 4. s ⊆ f⁻¹(f(s))
- 5. f(s) ⊆ u ↔ s ⊆ f⁻¹(u)
A continuación se muestran las soluciones.
1. s ∪ (⋂ᵢ Aᵢ) = ⋂ᵢ (Aᵢ ∪ s)
Demostrar con Lean4 que
\[ s ∪ (⋂_i A_i) = ⋂_i (A_i ∪ s) \]
Para ello, completar la siguiente teoría de Lean4:
1 2 3 4 5 6 7 8 9 |
import Mathlib.Data.Set.Basic import Mathlib.Tactic open Set variable {α : Type} variable (s : Set α) variable (A : ℕ → Set α) example : s ∪ (⋂ i, A i) = ⋂ i, (A i ∪ s) := by sorry |
1.1. Demostración en lenguaje natural
Tenemos que demostrar que para todo \(x\),
\[ x ∈ s ∪ ⋂_i A_i ↔ x ∈ ⋂_i (A i ∪ s) \]
Lo haremos mediante la siguiente cadena de equivalencias
\begin{align}
x ∈ s ∪ ⋂_i A_i &↔ x ∈ s ∨ x ∈ ⋂_i A_i \\
&↔ x ∈ s ∨ (∀ i)[x ∈ A_i] \\
&↔ (∀ i)[x ∈ s ∨ x ∈ A_i] \\
&↔ (∀ i)[x ∈ A_i ∨ x ∈ s] \\
&↔ (∀ i)[x ∈ A_i ∪ s] \\
&↔ x ∈ ⋂_i (A_i ∪ s)
\end{align}
1.2. Demostraciones con Lean4
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 |
import Mathlib.Data.Set.Basic import Mathlib.Tactic open Set variable {α : Type} variable (s : Set α) variable (A : ℕ → Set α) -- 1ª demostración -- =============== example : s ∪ (⋂ i, A i) = ⋂ i, (A i ∪ s) := by ext x -- x : α -- ⊢ x ∈ s ∪ ⋂ (i : ℕ), A i ↔ x ∈ ⋂ (i : ℕ), A i ∪ s calc x ∈ s ∪ ⋂ i, A i ↔ x ∈ s ∨ x ∈ ⋂ i, A i := by simp only [mem_union] _ ↔ x ∈ s ∨ ∀ i, x ∈ A i := by simp only [mem_iInter] _ ↔ ∀ i, x ∈ s ∨ x ∈ A i := by simp only [forall_or_left] _ ↔ ∀ i, x ∈ A i ∨ x ∈ s := by simp only [or_comm] _ ↔ ∀ i, x ∈ A i ∪ s := by simp only [mem_union] _ ↔ x ∈ ⋂ i, A i ∪ s := by simp only [mem_iInter] -- 2ª demostración -- =============== example : s ∪ (⋂ i, A i) = ⋂ i, (A i ∪ s) := by ext x -- x : α -- ⊢ x ∈ s ∪ ⋂ (i : ℕ), A i ↔ x ∈ ⋂ (i : ℕ), A i ∪ s simp only [mem_union, mem_iInter] -- ⊢ (x ∈ s ∨ ∀ (i : ℕ), x ∈ A i) ↔ ∀ (i : ℕ), x ∈ A i ∨ x ∈ s constructor . -- ⊢ (x ∈ s ∨ ∀ (i : ℕ), x ∈ A i) → ∀ (i : ℕ), x ∈ A i ∨ x ∈ s intros h i -- h : x ∈ s ∨ ∀ (i : ℕ), x ∈ A i -- i : ℕ -- ⊢ x ∈ A i ∨ x ∈ s rcases h with (xs | xAi) . -- xs : x ∈ s right -- ⊢ x ∈ s exact xs . -- xAi : ∀ (i : ℕ), x ∈ A i left -- ⊢ x ∈ A i exact xAi i . -- ⊢ (∀ (i : ℕ), x ∈ A i ∨ x ∈ s) → x ∈ s ∨ ∀ (i : ℕ), x ∈ A i intro h -- h : ∀ (i : ℕ), x ∈ A i ∨ x ∈ s -- ⊢ x ∈ s ∨ ∀ (i : ℕ), x ∈ A i by_cases cxs : x ∈ s . -- cxs : x ∈ s left -- ⊢ x ∈ s exact cxs . -- cns : ¬x ∈ s right -- ⊢ ∀ (i : ℕ), x ∈ A i intro i -- i : ℕ -- ⊢ x ∈ A i rcases h i with (xAi | xs) . -- ⊢ x ∈ A i exact xAi . -- xs : x ∈ s exact absurd xs cxs -- 3ª demostración -- =============== example : s ∪ (⋂ i, A i) = ⋂ i, (A i ∪ s) := by ext x -- x : α -- ⊢ x ∈ s ∪ ⋂ (i : ℕ), A i ↔ x ∈ ⋂ (i : ℕ), A i ∪ s simp only [mem_union, mem_iInter] -- ⊢ (x ∈ s ∨ ∀ (i : ℕ), x ∈ A i) ↔ ∀ (i : ℕ), x ∈ A i ∨ x ∈ s constructor . -- ⊢ (x ∈ s ∨ ∀ (i : ℕ), x ∈ A i) → ∀ (i : ℕ), x ∈ A i ∨ x ∈ s rintro (xs | xI) i . -- xs : x ∈ s -- i : ℕ -- ⊢ x ∈ A i ∨ x ∈ s right -- ⊢ x ∈ s exact xs . -- xI : ∀ (i : ℕ), x ∈ A i -- i : ℕ -- ⊢ x ∈ A i ∨ x ∈ s left -- ⊢ x ∈ A i exact xI i . -- ⊢ (∀ (i : ℕ), x ∈ A i ∨ x ∈ s) → x ∈ s ∨ ∀ (i : ℕ), x ∈ A i intro h -- h : ∀ (i : ℕ), x ∈ A i ∨ x ∈ s -- ⊢ x ∈ s ∨ ∀ (i : ℕ), x ∈ A i by_cases cxs : x ∈ s . -- cxs : x ∈ s left -- ⊢ x ∈ s exact cxs . -- cxs : ¬x ∈ s right -- ⊢ ∀ (i : ℕ), x ∈ A i intro i -- i : ℕ -- ⊢ x ∈ A i cases h i . -- h : x ∈ A i assumption . -- h : x ∈ s contradiction -- Lemas usados -- ============ -- variable (x : α) -- variable (s t : Set α) -- variable (a b q : Prop) -- variable (p : ℕ → Prop) -- #check (absurd : a → ¬a → b) -- #check (forall_or_left : (∀ x, q ∨ p x) ↔ q ∨ ∀ x, p x) -- #check (mem_iInter : x ∈ ⋂ i, A i ↔ ∀ i, x ∈ A i) -- #check (mem_union x a b : x ∈ s ∪ t ↔ x ∈ s ∨ x ∈ t) -- #check (or_comm : a ∨ b ↔ b ∨ a) |
Se puede interactuar con las demostraciones anteriores en Lean 4 Web.
1.3. Demostraciones con Isabelle/HOL
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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
theory Union_con_interseccion_general imports Main begin (* 1ª demostración *) lemma "s ∪ (⋂ i ∈ I. A i) = (⋂ i ∈ I. A i ∪ s)" proof (rule equalityI) show "s ∪ (⋂ i ∈ I. A i) ⊆ (⋂ i ∈ I. A i ∪ s)" proof (rule subsetI) fix x assume "x ∈ s ∪ (⋂ i ∈ I. A i)" then show "x ∈ (⋂ i ∈ I. A i ∪ s)" proof (rule UnE) assume "x ∈ s" show "x ∈ (⋂ i ∈ I. A i ∪ s)" proof (rule INT_I) fix i assume "i ∈ I" show "x ∈ A i ∪ s" using ‹x ∈ s› by (rule UnI2) qed next assume h1 : "x ∈ (⋂ i ∈ I. A i)" show "x ∈ (⋂ i ∈ I. A i ∪ s)" proof (rule INT_I) fix i assume "i ∈ I" with h1 have "x ∈ A i" by (rule INT_D) then show "x ∈ A i ∪ s" by (rule UnI1) qed qed qed next show "(⋂ i ∈ I. A i ∪ s) ⊆ s ∪ (⋂ i ∈ I. A i)" proof (rule subsetI) fix x assume h2 : "x ∈ (⋂ i ∈ I. A i ∪ s)" show "x ∈ s ∪ (⋂ i ∈ I. A i)" proof (cases "x ∈ s") assume "x ∈ s" then show "x ∈ s ∪ (⋂ i ∈ I. A i)" by (rule UnI1) next assume "x ∉ s" have "x ∈ (⋂ i ∈ I. A i)" proof (rule INT_I) fix i assume "i ∈ I" with h2 have "x ∈ A i ∪ s" by (rule INT_D) then show "x ∈ A i" proof (rule UnE) assume "x ∈ A i" then show "x ∈ A i" by this next assume "x ∈ s" with ‹x ∉ s› show "x ∈ A i" by (rule notE) qed qed then show "x ∈ s ∪ (⋂ i ∈ I. A i)" by (rule UnI2) qed qed qed (* 2ª demostración *) lemma "s ∪ (⋂ i ∈ I. A i) = (⋂ i ∈ I. A i ∪ s)" proof show "s ∪ (⋂ i ∈ I. A i) ⊆ (⋂ i ∈ I. A i ∪ s)" proof fix x assume "x ∈ s ∪ (⋂ i ∈ I. A i)" then show "x ∈ (⋂ i ∈ I. A i ∪ s)" proof assume "x ∈ s" show "x ∈ (⋂ i ∈ I. A i ∪ s)" proof fix i assume "i ∈ I" show "x ∈ A i ∪ s" using ‹x ∈ s› by simp qed next assume h1 : "x ∈ (⋂ i ∈ I. A i)" show "x ∈ (⋂ i ∈ I. A i ∪ s)" proof fix i assume "i ∈ I" with h1 have "x ∈ A i" by simp then show "x ∈ A i ∪ s" by simp qed qed qed next show "(⋂ i ∈ I. A i ∪ s) ⊆ s ∪ (⋂ i ∈ I. A i)" proof fix x assume h2 : "x ∈ (⋂ i ∈ I. A i ∪ s)" show "x ∈ s ∪ (⋂ i ∈ I. A i)" proof (cases "x ∈ s") assume "x ∈ s" then show "x ∈ s ∪ (⋂ i ∈ I. A i)" by simp next assume "x ∉ s" have "x ∈ (⋂ i ∈ I. A i)" proof fix i assume "i ∈ I" with h2 have "x ∈ A i ∪ s" by (rule INT_D) then show "x ∈ A i" proof assume "x ∈ A i" then show "x ∈ A i" by this next assume "x ∈ s" with ‹x ∉ s› show "x ∈ A i" by simp qed qed then show "x ∈ s ∪ (⋂ i ∈ I. A i)" by simp qed qed qed (* 3ª demostración *) lemma "s ∪ (⋂ i ∈ I. A i) = (⋂ i ∈ I. A i ∪ s)" proof show "s ∪ (⋂ i ∈ I. A i) ⊆ (⋂ i ∈ I. A i ∪ s)" proof fix x assume "x ∈ s ∪ (⋂ i ∈ I. A i)" then show "x ∈ (⋂ i ∈ I. A i ∪ s)" proof assume "x ∈ s" then show "x ∈ (⋂ i ∈ I. A i ∪ s)" by simp next assume "x ∈ (⋂ i ∈ I. A i)" then show "x ∈ (⋂ i ∈ I. A i ∪ s)" by simp qed qed next show "(⋂ i ∈ I. A i ∪ s) ⊆ s ∪ (⋂ i ∈ I. A i)" proof fix x assume h2 : "x ∈ (⋂ i ∈ I. A i ∪ s)" show "x ∈ s ∪ (⋂ i ∈ I. A i)" proof (cases "x ∈ s") assume "x ∈ s" then show "x ∈ s ∪ (⋂ i ∈ I. A i)" by simp next assume "x ∉ s" then show "x ∈ s ∪ (⋂ i ∈ I. A i)" using h2 by simp qed qed qed (* 4ª demostración *) lemma "s ∪ (⋂ i ∈ I. A i) = (⋂ i ∈ I. A i ∪ s)" proof show "s ∪ (⋂ i ∈ I. A i) ⊆ (⋂ i ∈ I. A i ∪ s)" proof fix x assume "x ∈ s ∪ (⋂ i ∈ I. A i)" then show "x ∈ (⋂ i ∈ I. A i ∪ s)" proof assume "x ∈ s" then show ?thesis by simp next assume "x ∈ (⋂ i ∈ I. A i)" then show ?thesis by simp qed qed next show "(⋂ i ∈ I. A i ∪ s) ⊆ s ∪ (⋂ i ∈ I. A i)" proof fix x assume h2 : "x ∈ (⋂ i ∈ I. A i ∪ s)" show "x ∈ s ∪ (⋂ i ∈ I. A i)" proof (cases "x ∈ s") case True then show ?thesis by simp next case False then show ?thesis using h2 by simp qed qed qed (* 5ª demostración *) lemma "s ∪ (⋂ i ∈ I. A i) = (⋂ i ∈ I. A i ∪ s)" by auto end |
2. f⁻¹[u ∩ v] = f⁻¹[u] ∩ f⁻¹[v]
En Lean, la imagen inversa de un conjunto s
(de elementos de tipo β
) por la función f
(de tipo α → β
) es el conjunto f ⁻¹' s
de elementos x
(de tipo α
) tales que f x ∈ s
.
Demostrar con Lean4 que
1 |
f ⁻¹' (u ∩ v) = f ⁻¹' u ∩ f ⁻¹' v |
Para ello, completar la siguiente teoría de Lean4:
1 2 3 4 5 6 7 8 |
import Mathlib.Data.Set.Function variable {α β : Type _} variable (f : α → β) variable (u v : Set β) open Set example : f ⁻¹' (u ∩ v) = f ⁻¹' u ∩ f ⁻¹' v := by sorry |
2.1. Demostración en lenguaje natural
Tenemos que demostrar que, para todo \(x\),
\[ x ∈ f⁻¹[u ∩ v] ↔ x ∈ f⁻¹[u] ∩ f⁻¹[v] \]
Lo haremos mediante la siguiente cadena de equivalencias
\begin{align}
x ∈ f⁻¹[u ∩ v] &↔ f x ∈ u ∩ v \\
&↔ f x ∈ u ∧ f x ∈ v \\
&↔ x ∈ f⁻¹[u] ∧ x ∈ f⁻¹[v] \\
&↔ x ∈ f⁻¹[u] ∩ f⁻¹[v] \\
\end{align}
2.2. Demostraciones con Lean4
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 |
import Mathlib.Data.Set.Function variable {α β : Type _} variable (f : α → β) variable (u v : Set β) open Set -- 1ª demostración -- =============== example : f ⁻¹' (u ∩ v) = f ⁻¹' u ∩ f ⁻¹' v := by ext x -- x : α -- ⊢ x ∈ f ⁻¹' (u ∩ v) ↔ x ∈ f ⁻¹' u ∩ f ⁻¹' v calc x ∈ f ⁻¹' (u ∩ v) ↔ f x ∈ u ∩ v := by simp only [mem_preimage] _ ↔ f x ∈ u ∧ f x ∈ v := by simp only [mem_inter_iff] _ ↔ x ∈ f ⁻¹' u ∧ x ∈ f ⁻¹' v := by simp only [mem_preimage] _ ↔ x ∈ f ⁻¹' u ∩ f ⁻¹' v := by simp only [mem_inter_iff] -- 2ª demostración -- =============== example : f ⁻¹' (u ∩ v) = f ⁻¹' u ∩ f ⁻¹' v := by ext x -- x : α -- ⊢ x ∈ f ⁻¹' (u ∩ v) ↔ x ∈ f ⁻¹' u ∩ f ⁻¹' v constructor . -- ⊢ x ∈ f ⁻¹' (u ∩ v) → x ∈ f ⁻¹' u ∩ f ⁻¹' v intro h -- h : x ∈ f ⁻¹' (u ∩ v) -- ⊢ x ∈ f ⁻¹' u ∩ f ⁻¹' v constructor . -- ⊢ x ∈ f ⁻¹' u apply mem_preimage.mpr -- ⊢ f x ∈ u rw [mem_preimage] at h -- h : f x ∈ u ∩ v exact mem_of_mem_inter_left h . -- ⊢ x ∈ f ⁻¹' v apply mem_preimage.mpr -- ⊢ f x ∈ v rw [mem_preimage] at h -- h : f x ∈ u ∩ v exact mem_of_mem_inter_right h . -- ⊢ x ∈ f ⁻¹' u ∩ f ⁻¹' v → x ∈ f ⁻¹' (u ∩ v) intro h -- h : x ∈ f ⁻¹' u ∩ f ⁻¹' v -- ⊢ x ∈ f ⁻¹' (u ∩ v) apply mem_preimage.mpr -- ⊢ f x ∈ u ∩ v constructor . -- ⊢ f x ∈ u apply mem_preimage.mp -- ⊢ x ∈ f ⁻¹' u exact mem_of_mem_inter_left h . -- ⊢ f x ∈ v apply mem_preimage.mp -- ⊢ x ∈ f ⁻¹' v exact mem_of_mem_inter_right h -- 3ª demostración -- =============== example : f ⁻¹' (u ∩ v) = f ⁻¹' u ∩ f ⁻¹' v := by ext x -- x : α -- ⊢ x ∈ f ⁻¹' (u ∩ v) ↔ x ∈ f ⁻¹' u ∩ f ⁻¹' v constructor . -- ⊢ x ∈ f ⁻¹' (u ∩ v) → x ∈ f ⁻¹' u ∩ f ⁻¹' v intro h -- h : x ∈ f ⁻¹' (u ∩ v) -- ⊢ x ∈ f ⁻¹' u ∩ f ⁻¹' v constructor . -- ⊢ x ∈ f ⁻¹' u simp at * -- h : f x ∈ u ∧ f x ∈ v -- ⊢ f x ∈ u exact h.1 . -- ⊢ x ∈ f ⁻¹' v simp at * -- h : f x ∈ u ∧ f x ∈ v -- ⊢ f x ∈ v exact h.2 . -- ⊢ x ∈ f ⁻¹' u ∩ f ⁻¹' v → x ∈ f ⁻¹' (u ∩ v) intro h -- h : x ∈ f ⁻¹' u ∩ f ⁻¹' v -- ⊢ x ∈ f ⁻¹' (u ∩ v) simp at * -- h : f x ∈ u ∧ f x ∈ v -- ⊢ f x ∈ u ∧ f x ∈ v exact h -- 4ª demostración -- =============== example : f ⁻¹' (u ∩ v) = f ⁻¹' u ∩ f ⁻¹' v := by aesop -- 5ª demostración -- =============== example : f ⁻¹' (u ∩ v) = f ⁻¹' u ∩ f ⁻¹' v := preimage_inter -- 6ª demostración -- =============== example : f ⁻¹' (u ∩ v) = f ⁻¹' u ∩ f ⁻¹' v := rfl -- Lemas usados -- ============ -- variable (x : α) -- variable (s t : Set α) -- #check (mem_of_mem_inter_left : x ∈ s ∩ t → x ∈ s) -- #check (mem_of_mem_inter_right : x ∈ s ∩ t → x ∈ t) -- #check (mem_preimage : x ∈ f ⁻¹' u ↔ f x ∈ u) -- #check (preimage_inter : f ⁻¹' (u ∩ v) = f ⁻¹' u ∩ f ⁻¹' v) |
Se puede interactuar con las demostraciones anteriores en Lean 4 Web.
2.3. Demostraciones con Isabelle/HOL
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 |
theory Imagen_inversa_de_la_interseccion imports Main begin (* 1ª demostración *) lemma "f -` (u ∩ v) = f -` u ∩ f -` v" proof (rule equalityI) show "f -` (u ∩ v) ⊆ f -` u ∩ f -` v" proof (rule subsetI) fix x assume "x ∈ f -` (u ∩ v)" then have h : "f x ∈ u ∩ v" by (simp only: vimage_eq) have "x ∈ f -` u" proof - have "f x ∈ u" using h by (rule IntD1) then show "x ∈ f -` u" by (rule vimageI2) qed moreover have "x ∈ f -` v" proof - have "f x ∈ v" using h by (rule IntD2) then show "x ∈ f -` v" by (rule vimageI2) qed ultimately show "x ∈ f -` u ∩ f -` v" by (rule IntI) qed next show "f -` u ∩ f -` v ⊆ f -` (u ∩ v)" proof (rule subsetI) fix x assume h2 : "x ∈ f -` u ∩ f -` v" have "f x ∈ u" proof - have "x ∈ f -` u" using h2 by (rule IntD1) then show "f x ∈ u" by (rule vimageD) qed moreover have "f x ∈ v" proof - have "x ∈ f -` v" using h2 by (rule IntD2) then show "f x ∈ v" by (rule vimageD) qed ultimately have "f x ∈ u ∩ v" by (rule IntI) then show "x ∈ f -` (u ∩ v)" by (rule vimageI2) qed qed (* 2ª demostración *) lemma "f -` (u ∩ v) = f -` u ∩ f -` v" proof show "f -` (u ∩ v) ⊆ f -` u ∩ f -` v" proof fix x assume "x ∈ f -` (u ∩ v)" then have h : "f x ∈ u ∩ v" by simp have "x ∈ f -` u" proof - have "f x ∈ u" using h by simp then show "x ∈ f -` u" by simp qed moreover have "x ∈ f -` v" proof - have "f x ∈ v" using h by simp then show "x ∈ f -` v" by simp qed ultimately show "x ∈ f -` u ∩ f -` v" by simp qed next show "f -` u ∩ f -` v ⊆ f -` (u ∩ v)" proof fix x assume h2 : "x ∈ f -` u ∩ f -` v" have "f x ∈ u" proof - have "x ∈ f -` u" using h2 by simp then show "f x ∈ u" by simp qed moreover have "f x ∈ v" proof - have "x ∈ f -` v" using h2 by simp then show "f x ∈ v" by simp qed ultimately have "f x ∈ u ∩ v" by simp then show "x ∈ f -` (u ∩ v)" by simp qed qed (* 3ª demostración *) lemma "f -` (u ∩ v) = f -` u ∩ f -` v" proof show "f -` (u ∩ v) ⊆ f -` u ∩ f -` v" proof fix x assume h1 : "x ∈ f -` (u ∩ v)" have "x ∈ f -` u" using h1 by simp moreover have "x ∈ f -` v" using h1 by simp ultimately show "x ∈ f -` u ∩ f -` v" by simp qed next show "f -` u ∩ f -` v ⊆ f -` (u ∩ v)" proof fix x assume h2 : "x ∈ f -` u ∩ f -` v" have "f x ∈ u" using h2 by simp moreover have "f x ∈ v" using h2 by simp ultimately have "f x ∈ u ∩ v" by simp then show "x ∈ f -` (u ∩ v)" by simp qed qed (* 4ª demostración *) lemma "f -` (u ∩ v) = f -` u ∩ f -` v" by (simp only: vimage_Int) (* 5ª demostración *) lemma "f -` (u ∩ v) = f -` u ∩ f -` v" by auto end |
3. f[s ∪ t] = f[s] ∪ f[t]
En Lean4, la imagen de un conjunto s por una función f se representa por f '' s
; es decir,
1 |
f '' s = {y | ∃ x, x ∈ s ∧ f x = y} |
Demostrar con Lean4 que
1 |
f '' (s ∪ t) = f '' s ∪ f '' t |
Para ello, completar la siguiente teoría de Lean4:
1 2 3 4 5 6 7 8 |
import Mathlib.Data.Set.Function variable {α β : Type _} variable (f : α → β) variable (s t : Set α) open Set example : f '' (s ∪ t) = f '' s ∪ f '' t := by sorry |
2.1. Demostración en lenguaje natural
Tenemos que demostrar, para todo \(y\), que
\[ y ∈ f[s ∪ t] ↔ y ∈ f[s] ∪ f[t] \]
Lo haremos mediante la siguiente cadena de equivalencias
\begin{align}
y ∈ f[s ∪ t] &↔ (∃x)(x ∈ s ∪ t ∧ f x = y) \\
&↔ (∃x)((x ∈ s ∨ x ∈ t) ∧ f x = y) \\
&↔ (∃x)((x ∈ s ∧ f x = y) ∨ (x ∈ t ∧ f x = y)) \\
&↔ (∃x)(x ∈ s ∧ f x = y) ∨ (∃x)(x ∈ t ∧ f x = y) \\
&↔ y ∈ f[s] ∨ y ∈ f[t] \\
&↔ y ∈ f[s] ∪ f[t]
\end{align}
3.2. Demostraciones con Lean4
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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
import Mathlib.Data.Set.Function variable {α β : Type _} variable (f : α → β) variable (s t : Set α) open Set -- 1ª demostración -- =============== example : f '' (s ∪ t) = f '' s ∪ f '' t := by ext y -- y : β -- ⊢ y ∈ f '' (s ∪ t) ↔ y ∈ f '' s ∪ f '' t calc y ∈ f '' (s ∪ t) ↔ ∃ x, x ∈ s ∪ t ∧ f x = y := by simp only [mem_image] _ ↔ ∃ x, (x ∈ s ∨ x ∈ t) ∧ f x = y := by simp only [mem_union] _ ↔ ∃ x, (x ∈ s ∧ f x = y) ∨ (x ∈ t ∧ f x = y) := by simp only [or_and_right] _ ↔ (∃ x, x ∈ s ∧ f x = y) ∨ (∃ x, x ∈ t ∧ f x = y) := by simp only [exists_or] _ ↔ y ∈ f '' s ∨ y ∈ f '' t := by simp only [mem_image] _ ↔ y ∈ f '' s ∪ f '' t := by simp only [mem_union] -- 2ª demostración -- =============== example : f '' (s ∪ t) = f '' s ∪ f '' t := by ext y -- y : β -- ⊢ y ∈ f '' (s ∪ t) ↔ y ∈ f '' s ∪ f '' t constructor . -- ⊢ y ∈ f '' (s ∪ t) → y ∈ f '' s ∪ f '' t intro h -- h : y ∈ f '' (s ∪ t) -- ⊢ y ∈ f '' s ∪ f '' t rw [mem_image] at h -- h : ∃ x, x ∈ s ∪ t ∧ f x = y rcases h with ⟨x, hx⟩ -- x : α -- hx : x ∈ s ∪ t ∧ f x = y rcases hx with ⟨xst, fxy⟩ -- xst : x ∈ s ∪ t -- fxy : f x = y rw [←fxy] -- ⊢ f x ∈ f '' s ∪ f '' t rw [mem_union] at xst -- xst : x ∈ s ∨ x ∈ t rcases xst with (xs | xt) . -- xs : x ∈ s apply mem_union_left -- ⊢ f x ∈ f '' s apply mem_image_of_mem -- ⊢ x ∈ s exact xs . -- xt : x ∈ t apply mem_union_right -- ⊢ f x ∈ f '' t apply mem_image_of_mem -- ⊢ x ∈ t exact xt . -- ⊢ y ∈ f '' s ∪ f '' t → y ∈ f '' (s ∪ t) intro h -- h : y ∈ f '' s ∪ f '' t -- ⊢ y ∈ f '' (s ∪ t) rw [mem_union] at h -- h : y ∈ f '' s ∨ y ∈ f '' t rcases h with (yfs | yft) . -- yfs : y ∈ f '' s rw [mem_image] -- ⊢ ∃ x, x ∈ s ∪ t ∧ f x = y rw [mem_image] at yfs -- yfs : ∃ x, x ∈ s ∧ f x = y 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 apply mem_union_left -- ⊢ x ∈ s exact xs . -- ⊢ f x = y exact fxy . -- yft : y ∈ f '' t rw [mem_image] -- ⊢ ∃ x, x ∈ s ∪ t ∧ f x = y rw [mem_image] at yft -- yft : ∃ x, x ∈ t ∧ f x = y rcases yft with ⟨x, hx⟩ -- x : α -- hx : x ∈ t ∧ f x = y rcases hx with ⟨xt, fxy⟩ -- xt : x ∈ t -- fxy : f x = y use x -- ⊢ x ∈ s ∪ t ∧ f x = y constructor . -- ⊢ x ∈ s ∪ t apply mem_union_right -- ⊢ x ∈ t exact xt . -- ⊢ f x = y exact fxy -- 3ª demostración -- =============== example : f '' (s ∪ t) = f '' s ∪ f '' t := by ext y -- y : β -- ⊢ y ∈ f '' (s ∪ t) ↔ y ∈ f '' s ∪ f '' t constructor . -- ⊢ y ∈ f '' (s ∪ t) → y ∈ f '' s ∪ f '' t rintro ⟨x, xst, rfl⟩ -- x : α -- xst : x ∈ s ∪ t -- ⊢ f x ∈ f '' s ∪ f '' t rcases xst with (xs | xt) . -- xs : x ∈ s left -- ⊢ f x ∈ f '' s exact mem_image_of_mem f xs . -- xt : x ∈ t right -- ⊢ f x ∈ f '' t exact mem_image_of_mem f xt . -- ⊢ y ∈ f '' s ∪ f '' t → y ∈ f '' (s ∪ t) rintro (yfs | yft) . -- yfs : y ∈ f '' s rcases yfs with ⟨x, xs, rfl⟩ -- x : α -- xs : x ∈ s -- ⊢ f x ∈ f '' (s ∪ t) apply mem_image_of_mem -- ⊢ x ∈ s ∪ t left -- ⊢ x ∈ s exact xs . -- yft : y ∈ f '' t rcases yft with ⟨x, xt, rfl⟩ -- x : α -- xs : x ∈ s -- ⊢ f x ∈ f '' (s ∪ t) apply mem_image_of_mem -- ⊢ x ∈ s ∪ t right -- ⊢ x ∈ t exact xt -- 4ª demostración -- =============== example : f '' (s ∪ t) = f '' s ∪ f '' t := by ext y -- y : β -- ⊢ y ∈ f '' (s ∪ t) ↔ y ∈ f '' s ∪ f '' t constructor . -- ⊢ y ∈ f '' (s ∪ t) → y ∈ f '' s ∪ f '' t rintro ⟨x, xst, rfl⟩ -- x : α -- xst : x ∈ s ∪ t -- ⊢ f x ∈ f '' s ∪ f '' t rcases xst with (xs | xt) . -- xs : x ∈ s left -- ⊢ f x ∈ f '' s use x, xs . -- xt : x ∈ t right -- ⊢ f x ∈ f '' t use x, xt . rintro (yfs | yft) . -- yfs : y ∈ f '' s rcases yfs with ⟨x, xs, rfl⟩ -- x : α -- xs : x ∈ s -- ⊢ f x ∈ f '' (s ∪ t) use x, Or.inl xs . -- yft : y ∈ f '' t rcases yft with ⟨x, xt, rfl⟩ -- x : α -- xt : x ∈ t -- ⊢ f x ∈ f '' (s ∪ t) use x, Or.inr xt -- 5ª demostración -- =============== example : f '' (s ∪ t) = f '' s ∪ f '' t := by ext y -- y : β -- ⊢ y ∈ f '' (s ∪ t) ↔ y ∈ f '' s ∪ f '' t constructor . -- ⊢ y ∈ f '' (s ∪ t) → y ∈ f '' s ∪ f '' t rintro ⟨x, xs | xt, rfl⟩ . -- x : α -- xs : x ∈ s -- ⊢ f x ∈ f '' s ∪ f '' t left -- ⊢ f x ∈ f '' s use x, xs . -- x : α -- xt : x ∈ t -- ⊢ f x ∈ f '' s ∪ f '' t right -- ⊢ f x ∈ f '' t use x, xt . -- ⊢ y ∈ f '' s ∪ f '' t → y ∈ f '' (s ∪ t) rintro (⟨x, xs, rfl⟩ | ⟨x, xt, rfl⟩) . -- x : α -- xs : x ∈ s -- ⊢ f x ∈ f '' (s ∪ t) use x, Or.inl xs . -- x : α -- xt : x ∈ t -- ⊢ f x ∈ f '' (s ∪ t) use x, Or.inr xt -- 6ª demostración -- =============== example : f '' (s ∪ t) = f '' s ∪ f '' t := by ext y -- y : β -- ⊢ y ∈ f '' (s ∪ t) ↔ y ∈ f '' s ∪ f '' t constructor . -- ⊢ y ∈ f '' (s ∪ t) → y ∈ f '' s ∪ f '' t aesop . -- ⊢ y ∈ f '' s ∪ f '' t → y ∈ f '' (s ∪ t) aesop -- 7ª demostración -- =============== example : f '' (s ∪ t) = f '' s ∪ f '' t := by ext y constructor <;> aesop -- 8ª demostración -- =============== example : f '' (s ∪ t) = f '' s ∪ f '' t := by ext y -- y : β -- ⊢ y ∈ f '' (s ∪ t) ↔ y ∈ f '' s ∪ f '' t rw [iff_def] -- ⊢ (y ∈ f '' (s ∪ t) → y ∈ f '' s ∪ f '' t) ∧ (y ∈ f '' s ∪ f '' t → y ∈ f '' (s ∪ t)) aesop -- 9ª demostración -- =============== example : f '' (s ∪ t) = f '' s ∪ f '' t := image_union f s t -- Lemas usados -- ============ -- variable (x : α) -- variable (y : β) -- variable (a b c : Prop) -- variable (p q : α → Prop) -- #check (Or.inl : a → a ∨ b) -- #check (Or.inr : b → a ∨ b) -- #check (exists_or : (∃ x, p x ∨ q x) ↔ (∃ x, p x) ∨ ∃ x, q x) -- #check (iff_def : (a ↔ b) ↔ (a → b) ∧ (b → a)) -- #check (image_union f s t : f '' (s ∪ t) = f '' s ∪ f '' t) -- #check (mem_image f s y : (y ∈ f '' s ↔ ∃ (x : α), x ∈ s ∧ f x = y)) -- #check (mem_image_of_mem f : x ∈ s → f x ∈ f '' s) -- #check (mem_union x s t : x ∈ s ∪ t ↔ x ∈ s ∨ x ∈ t) -- #check (mem_union_left t : x ∈ s → x ∈ s ∪ t) -- #check (mem_union_right s : x ∈ t → x ∈ s ∪ t) -- #check (or_and_right : (a ∨ b) ∧ c ↔ a ∧ c ∨ b ∧ c) |
Se puede interactuar con las demostraciones anteriores en Lean 4 Web.
3.3. Demostraciones con Isabelle/HOL
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 |
theory Imagen_de_la_union imports Main begin (* 1ª demostración *) lemma "f ` (s ∪ t) = f ` s ∪ f ` t" proof (rule equalityI) show "f ` (s ∪ t) ⊆ f ` s ∪ f ` t" proof (rule subsetI) fix y assume "y ∈ f ` (s ∪ t)" then show "y ∈ f ` s ∪ f ` t" proof (rule imageE) fix x assume "y = f x" assume "x ∈ s ∪ t" then show "y ∈ f ` s ∪ f ` t" proof (rule UnE) assume "x ∈ s" with ‹y = f x› have "y ∈ f ` s" by (simp only: image_eqI) then show "y ∈ f ` s ∪ f ` t" by (rule UnI1) next assume "x ∈ t" with ‹y = f x› have "y ∈ f ` t" by (simp only: image_eqI) then show "y ∈ f ` s ∪ f ` t" by (rule UnI2) qed qed qed next show "f ` s ∪ f ` t ⊆ f ` (s ∪ t)" proof (rule subsetI) fix y assume "y ∈ f ` s ∪ f ` t" then show "y ∈ f ` (s ∪ t)" proof (rule UnE) assume "y ∈ f ` s" then show "y ∈ f ` (s ∪ t)" proof (rule imageE) fix x assume "y = f x" assume "x ∈ s" then have "x ∈ s ∪ t" by (rule UnI1) with ‹y = f x› show "y ∈ f ` (s ∪ t)" by (simp only: image_eqI) qed next assume "y ∈ f ` t" then show "y ∈ f ` (s ∪ t)" proof (rule imageE) fix x assume "y = f x" assume "x ∈ t" then have "x ∈ s ∪ t" by (rule UnI2) with ‹y = f x› show "y ∈ f ` (s ∪ t)" by (simp only: image_eqI) qed qed qed qed (* 2ª demostración *) lemma "f ` (s ∪ t) = f ` s ∪ f ` t" proof show "f ` (s ∪ t) ⊆ f ` s ∪ f ` t" proof fix y assume "y ∈ f ` (s ∪ t)" then show "y ∈ f ` s ∪ f ` t" proof fix x assume "y = f x" assume "x ∈ s ∪ t" then show "y ∈ f ` s ∪ f ` t" proof assume "x ∈ s" with ‹y = f x› have "y ∈ f ` s" by simp then show "y ∈ f ` s ∪ f ` t" by simp next assume "x ∈ t" with ‹y = f x› have "y ∈ f ` t" by simp then show "y ∈ f ` s ∪ f ` t" by simp qed qed qed next show "f ` s ∪ f ` t ⊆ f ` (s ∪ t)" proof fix y assume "y ∈ f ` s ∪ f ` t" then show "y ∈ f ` (s ∪ t)" proof assume "y ∈ f ` s" then show "y ∈ f ` (s ∪ t)" proof fix x assume "y = f x" assume "x ∈ s" then have "x ∈ s ∪ t" by simp with ‹y = f x› show "y ∈ f ` (s ∪ t)" by simp qed next assume "y ∈ f ` t" then show "y ∈ f ` (s ∪ t)" proof fix x assume "y = f x" assume "x ∈ t" then have "x ∈ s ∪ t" by simp with ‹y = f x› show "y ∈ f ` (s ∪ t)" by simp qed qed qed qed (* 3ª demostración *) lemma "f ` (s ∪ t) = f ` s ∪ f ` t" by (simp only: image_Un) (* 4ª demostración *) lemma "f ` (s ∪ t) = f ` s ∪ f ` t" by auto end |
4. s ⊆ f⁻¹[f[s]]
Demostrar que si \(s\) es un subconjunto del dominio de la función \(f\), entonces \(s\) está contenido en la imagen inversa de la imagen de \(s\) por \(f\); es decir,
\[ s ⊆ f⁻¹[f[s]] \]
Para ello, completar la siguiente teoría de Lean4:
1 2 3 4 5 6 7 8 |
import Mathlib.Data.Set.Function open Set variable {α β : Type _} variable (f : α → β) variable (s : Set α) example : s ⊆ f ⁻¹' (f '' s) := by sorry |
4.1. Demostración en lenguaje natural
Se demuestra mediante la siguiente cadena de implicaciones
\begin{align}
x ∈ s &⟹ f(x) ∈ f[s] \\
&⟹ x ∈ f⁻¹[f[s]]
\end{align}
4.2. Demostraciones con Lean4
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 |
import Mathlib.Data.Set.Function open Set variable {α β : Type _} variable (f : α → β) variable (s : Set α) -- 1ª demostración -- =============== example : s ⊆ f ⁻¹' (f '' s) := by intros x xs -- x : α -- xs : x ∈ s -- ⊢ x ∈ f ⁻¹' (f '' s) have h1 : f x ∈ f '' s := mem_image_of_mem f xs show x ∈ f ⁻¹' (f '' s) exact mem_preimage.mp h1 -- 2ª demostración -- =============== example : s ⊆ f ⁻¹' (f '' s) := by intros x xs -- x : α -- xs : x ∈ s -- ⊢ x ∈ f ⁻¹' (f '' s) apply mem_preimage.mpr -- ⊢ f x ∈ f '' s apply mem_image_of_mem -- ⊢ x ∈ s exact xs -- 3ª demostración -- =============== example : s ⊆ f ⁻¹' (f '' s) := by intros x xs -- x : α -- xs : x ∈ s -- ⊢ x ∈ f ⁻¹' (f '' s) apply mem_image_of_mem -- ⊢ x ∈ s exact xs -- 4ª demostración -- =============== example : s ⊆ f ⁻¹' (f '' s) := fun _ ↦ mem_image_of_mem f -- 5ª demostración -- =============== example : s ⊆ f ⁻¹' (f '' s) := by intros x xs -- x : α -- xs : x ∈ s -- ⊢ x ∈ f ⁻¹' (f '' s) show f x ∈ f '' s use x, xs -- 6ª demostración -- =============== example : s ⊆ f ⁻¹' (f '' s) := by intros x xs -- x : α -- xs : x ∈ s -- ⊢ x ∈ f ⁻¹' (f '' s) use x, xs -- 7ª demostración -- =============== example : s ⊆ f ⁻¹' (f '' s) := subset_preimage_image f s -- Lemas usados -- ============ -- variable (x : α) -- variable (t : Set β) -- #check (mem_preimage : x ∈ f ⁻¹' t ↔ f x ∈ t) -- #check (mem_image_of_mem f : x ∈ s → f x ∈ f '' s) -- #check (subset_preimage_image f s : s ⊆ f ⁻¹' (f '' s)) |
Se puede interactuar con las demostraciones anteriores en Lean 4 Web.
4.3. Demostraciones con Isabelle/HOL
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 |
theory Imagen_inversa_de_la_imagen imports Main begin (* 1ª demostración *) lemma "s ⊆ f -` (f ` s)" proof (rule subsetI) fix x assume "x ∈ s" then have "f x ∈ f ` s" by (simp only: imageI) then show "x ∈ f -` (f ` s)" by (simp only: vimageI) qed (* 2ª demostración *) lemma "s ⊆ f -` (f ` s)" proof fix x assume "x ∈ s" then have "f x ∈ f ` s" by simp then show "x ∈ f -` (f ` s)" by simp qed (* 3ª demostración *) lemma "s ⊆ f -` (f ` s)" by auto end |
5. f[s] ⊆ u ↔ s ⊆ f⁻¹[u]
Demostrar con Lean4 que
\[ f[s] ⊆ u ↔ s ⊆ f⁻¹[u] \]
Para ello, completar la siguiente teoría de Lean4:
1 2 3 4 5 6 7 8 9 |
import Mathlib.Data.Set.Function open Set variable {α β : Type _} variable (f : α → β) variable (s : Set α) variable (u : Set β) example : f '' s ⊆ u ↔ s ⊆ f ⁻¹' u := by sorry |
5.1. Demostración en lenguaje natural
Los demostraremos probando las dos implicaciones.
(⟹) Supongamos que
\[ f[s] ⊆ u \tag{1} \]
y tenemos que demostrar que
\[ s ⊆ f⁻¹[u] \]
Se prueba mediante las siguientes implicaciones
\begin{align}
x ∈ s &⟹ f(x) ∈ f[s] \\
&⟹ f(x) ∈ u &&\text{[por (1)]} \\
&⟹ x ∈ f⁻¹[u]
\end{align}
(⟸) Supongamos que
\[ s ⊆ f⁻¹[u] \tag{2} \]
y tenemos que demostrar que
\[ f[s] ⊆ u \]
Para ello, sea \(y ∈ f[s]\). Entonces, existe un
\[ x ∈ s \tag{3} \]
tal que
\[ y = f(x) \tag{4} \]
Entonces,
\begin{align}
&x ∈ f⁻¹[u] &&\text{[por (2) y (3)]} \\
⟹ &f(x) ∈ u \\
⟹ &y ∈ u &&\text{[por (4)]}
\end{align}
5.2. Demostraciones con Lean4
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 157 158 159 160 161 162 |
import Mathlib.Data.Set.Function open Set variable {α β : Type _} variable (f : α → β) variable (s : Set α) variable (u : Set β) -- 1ª demostración -- =============== example : f '' s ⊆ u ↔ s ⊆ f ⁻¹' u := calc f '' s ⊆ u ↔ ∀ y, y ∈ f '' s → y ∈ u := by simp only [subset_def] _ ↔ ∀ y, (∃ x, x ∈ s ∧ f x = y) → y ∈ u := by simp only [mem_image] _ ↔ ∀ x, x ∈ s → f x ∈ u := by constructor . -- (∀ y, (∃ x, x ∈ s ∧ f x = y) → y ∈ u) → (∀ x, x ∈ s → f x ∈ u) intro h x xs -- h : ∀ (y : β), (∃ x, x ∈ s ∧ f x = y) → y ∈ u -- x : α -- xs : x ∈ s -- ⊢ f x ∈ u exact h (f x) (by use x, xs) . -- (∀ x, x ∈ s → f x ∈ u) → (∀ y, (∃ x, x ∈ s ∧ f x = y) → y ∈ u) intro h y hy -- h : ∀ (x : α), x ∈ s → f x ∈ u -- y : β -- hy : ∃ x, x ∈ s ∧ f x = y -- ⊢ y ∈ u obtain ⟨x, hx⟩ := hy -- x : α -- hx : x ∈ s ∧ f x = y have h1 : y = f x := hx.2.symm have h2 : f x ∈ u := h x hx.1 show y ∈ u exact mem_of_eq_of_mem h1 h2 _ ↔ ∀ x, x ∈ s → x ∈ f ⁻¹' u := by simp only [mem_preimage] _ ↔ s ⊆ f ⁻¹' u := by simp only [subset_def] -- 2ª demostración -- =============== example : f '' s ⊆ u ↔ s ⊆ f ⁻¹' u := calc f '' s ⊆ u ↔ ∀ y, y ∈ f '' s → y ∈ u := by simp only [subset_def] _ ↔ ∀ y, (∃ x, x ∈ s ∧ f x = y) → y ∈ u := by simp only [mem_image] _ ↔ ∀ x, x ∈ s → f x ∈ u := by constructor . -- (∀ y, (∃ x, x ∈ s ∧ f x = y) → y ∈ u) → (∀ x, x ∈ s → f x ∈ u) intro h x xs -- h : ∀ (y : β), (∃ x, x ∈ s ∧ f x = y) → y ∈ u -- x : α -- xs : x ∈ s -- ⊢ f x ∈ u apply h (f x) -- ⊢ ∃ x_1, x_1 ∈ s ∧ f x_1 = f x use x, xs . -- (∀ x, x ∈ s → f x ∈ u) → (∀ y, (∃ x, x ∈ s ∧ f x = y) → y ∈ u) intro h y hy -- h : ∀ (x : α), x ∈ s → f x ∈ u -- y : β -- hy : ∃ x, x ∈ s ∧ f x = y -- ⊢ y ∈ u obtain ⟨x, hx⟩ := hy -- x : α -- hx : x ∈ s ∧ f x = y rw [←hx.2] -- ⊢ f x ∈ u apply h x -- ⊢ x ∈ s exact hx.1 _ ↔ ∀ x, x ∈ s → x ∈ f ⁻¹' u := by simp only [mem_preimage] _ ↔ s ⊆ f ⁻¹' u := by simp only [subset_def] -- 3ª demostración -- =============== example : f '' s ⊆ u ↔ s ⊆ f ⁻¹' u := by constructor . -- ⊢ f '' s ⊆ u → s ⊆ f ⁻¹' u intros h x xs -- h : f '' s ⊆ u -- x : α -- xs : x ∈ s -- ⊢ x ∈ f ⁻¹' u apply mem_preimage.mpr -- ⊢ f x ∈ u apply h -- ⊢ f x ∈ f '' s apply mem_image_of_mem -- ⊢ x ∈ s exact xs . -- ⊢ s ⊆ f ⁻¹' u → f '' s ⊆ u intros h y hy -- h : s ⊆ f ⁻¹' u -- y : β -- hy : y ∈ f '' s -- ⊢ y ∈ u rcases hy with ⟨x, xs, fxy⟩ -- x : α -- xs : x ∈ s -- fxy : f x = y rw [←fxy] -- ⊢ f x ∈ u exact h xs -- 4ª demostración -- =============== example : f '' s ⊆ u ↔ s ⊆ f ⁻¹' u := by constructor . -- ⊢ f '' s ⊆ u → s ⊆ f ⁻¹' u intros h x xs -- h : f '' s ⊆ u -- x : α -- xs : x ∈ s -- ⊢ x ∈ f ⁻¹' u apply h -- ⊢ f x ∈ f '' s apply mem_image_of_mem -- ⊢ x ∈ s exact xs . -- ⊢ s ⊆ f ⁻¹' u → f '' s ⊆ u rintro h y ⟨x, xs, rfl⟩ -- h : s ⊆ f ⁻¹' u -- x : α -- xs : x ∈ s -- ⊢ f x ∈ u exact h xs -- 5ª demostración -- =============== example : f '' s ⊆ u ↔ s ⊆ f ⁻¹' u := image_subset_iff -- 4ª demostración -- =============== example : f '' s ⊆ u ↔ s ⊆ f ⁻¹' u := by simp -- Lemas usados -- ============ -- variable (x y : α) -- #check (image_subset_iff : f '' s ⊆ u ↔ s ⊆ f ⁻¹' u) -- #check (mem_image_of_mem f : x ∈ s → f x ∈ f '' s) -- #check (mem_of_eq_of_mem : x = y → y ∈ s → x ∈ s) -- #check (mem_preimage : x ∈ f ⁻¹' u ↔ f x ∈ u) |
Se puede interactuar con las demostraciones anteriores en Lean 4 Web.
5.3. Demostraciones con Isabelle/HOL
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 |
theory Subconjunto_de_la_imagen_inversa imports Main begin (* 1ª demostración *) lemma "f ` s ⊆ u ⟷ s ⊆ f -` u" proof (rule iffI) assume "f ` s ⊆ u" show "s ⊆ f -` u" proof (rule subsetI) fix x assume "x ∈ s" then have "f x ∈ f ` s" by (simp only: imageI) then have "f x ∈ u" using ‹f ` s ⊆ u› by (rule set_rev_mp) then show "x ∈ f -` u" by (simp only: vimageI) qed next assume "s ⊆ f -` u" show "f ` s ⊆ u" proof (rule subsetI) fix y assume "y ∈ f ` s" then show "y ∈ u" proof fix x assume "y = f x" assume "x ∈ s" then have "x ∈ f -` u" using ‹s ⊆ f -` u› by (rule set_rev_mp) then have "f x ∈ u" by (rule vimageD) with ‹y = f x› show "y ∈ u" by (rule ssubst) qed qed qed (* 2ª demostración *) lemma "f ` s ⊆ u ⟷ s ⊆ f -` u" proof assume "f ` s ⊆ u" show "s ⊆ f -` u" proof fix x assume "x ∈ s" then have "f x ∈ f ` s" by simp then have "f x ∈ u" using ‹f ` s ⊆ u› by (simp add: set_rev_mp) then show "x ∈ f -` u" by simp qed next assume "s ⊆ f -` u" show "f ` s ⊆ u" proof fix y assume "y ∈ f ` s" then show "y ∈ u" proof fix x assume "y = f x" assume "x ∈ s" then have "x ∈ f -` u" using ‹s ⊆ f -` u› by (simp only: set_rev_mp) then have "f x ∈ u" by simp with ‹y = f x› show "y ∈ u" by simp qed qed qed (* 3ª demostración *) lemma "f ` s ⊆ u ⟷ s ⊆ f -` u" by (simp only: image_subset_iff_subset_vimage) (* 4ª demostración *) lemma "f ` s ⊆ u ⟷ s ⊆ f -` u" by auto end |