LMF2013: Ejercicios de deducción natural en lógica de primer orden con Isabelle/HOL (2)
En la clase de hoy del curso Lógica matemática y fundamentos se han resuelto los ejercicios 22, 27, 28, 29, 32 y 34 de la relación 7 sobre deducción natural en lógica de primer orden con Isabelle/HOL.
Las soluciones de los ejercicios resueltos se muestran a continuación:
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 |
text {* --------------------------------------------------------------- Ejercicio 22. Demostrar {∀x. P x ⟶ Q x ∨ R x, ¬(∃x. P x ∧ R x)} ⊢ ∀x. P x ⟶ Q x ------------------------------------------------------------------ *} -- "La demostración automática es" lemma ejercicio_22a: "⟦∀x. P x ⟶ Q x ∨ R x; ¬(∃x. P x ∧ R x)⟧ ⟹ ∀x. P x ⟶ Q x" by auto -- "La demostración estructurada es" lemma ejercicio_22b: assumes "∀x. P x ⟶ Q x ∨ R x" "¬(∃x. P x ∧ R x)" shows "∀x. P x ⟶ Q x" proof fix a show "P a ⟶ Q a" proof assume "P a" have "P a ⟶ Q a ∨ R a" using assms(1) .. hence "Q a ∨ R a" using `P a` .. thus "Q a" proof assume "Q a" thus "Q a" . next assume "R a" with `P a` have "P a ∧ R a" .. hence "∃x. P x ∧ R x" .. with assms(2) show "Q a" .. qed qed qed -- "La demostración detallada es" lemma ejercicio_22c: assumes "∀x. P x ⟶ Q x ∨ R x" "¬(∃x. P x ∧ R x)" shows "∀x. P x ⟶ Q x" proof (rule allI) fix a show "P a ⟶ Q a" proof (rule impI) assume "P a" have "P a ⟶ Q a ∨ R a" using assms(1) by (rule allE) hence "Q a ∨ R a" using `P a` by (rule mp) thus "Q a" proof (rule disjE) assume "Q a" thus "Q a" by this next assume "R a" with `P a` have "P a ∧ R a" by (rule conjI) hence "∃x. P x ∧ R x" by (rule exI) with assms(2) show "Q a" by (rule notE) qed qed qed text {* --------------------------------------------------------------- Ejercicio 27. Demostrar o refutar ((∀x. P x) ∨ (∀x. Q x)) ⟷ (∀x. P x ∨ Q x) ------------------------------------------------------------------ *} lemma ejercicio_27: "((∀x. P x) ∨ (∀x. Q x)) ⟷ (∀x. P x ∨ Q x)" oops (* Auto Quickcheck found a counterexample: P = {a\<^isub>1} Q = {a\<^isub>2} *) text {* --------------------------------------------------------------- Ejercicio 28. Demostrar o refutar ((∃x. P x) ∨ (∃x. Q x)) ⟷ (∃x. P x ∨ Q x) ------------------------------------------------------------------ *} -- "La demostración automática es" lemma ejercicio_28a: "((∃x. P x) ∨ (∃x. Q x)) ⟷ (∃x. P x ∨ Q x)" by auto -- "La demostración estructurada es" lemma ejercicio_28b: "((∃x. P x) ∨ (∃x. Q x)) ⟷ (∃x. P x ∨ Q x)" proof assume "(∃x. P x) ∨ (∃x. Q x)" thus "∃x. P x ∨ Q x" proof assume "∃x. P x" then obtain a where "P a" .. hence "P a ∨ Q a" .. thus "∃x. P x ∨ Q x" .. next assume "∃x. Q x" then obtain a where "Q a" .. hence "P a ∨ Q a" .. thus "∃x. P x ∨ Q x" .. qed next assume "∃x. P x ∨ Q x" then obtain a where "P a ∨ Q a" .. thus "(∃x. P x) ∨ (∃x. Q x)" proof assume "P a" hence "∃x. P x" .. thus "(∃x. P x) ∨ (∃x. Q x)" .. next assume "Q a" hence "∃x. Q x" .. thus "(∃x. P x) ∨ (∃x. Q x)" .. qed qed -- "La demostración detallada es" lemma ejercicio_28c: "((∃x. P x) ∨ (∃x. Q x)) ⟷ (∃x. P x ∨ Q x)" proof (rule iffI) assume "(∃x. P x) ∨ (∃x. Q x)" thus "∃x. P x ∨ Q x" proof (rule disjE) assume "∃x. P x" then obtain a where "P a" by (rule exE) hence "P a ∨ Q a" by (rule disjI1) thus "∃x. P x ∨ Q x" by (rule exI) next assume "∃x. Q x" then obtain a where "Q a" by (rule exE) hence "P a ∨ Q a" by (rule disjI2) thus "∃x. P x ∨ Q x" by (rule exI) qed next assume "∃x. P x ∨ Q x" then obtain a where "P a ∨ Q a" by (rule exE) thus "(∃x. P x) ∨ (∃x. Q x)" proof (rule disjE) assume "P a" hence "∃x. P x" by (rule exI) thus "(∃x. P x) ∨ (∃x. Q x)" by (rule disjI1) next assume "Q a" hence "∃x. Q x" by (rule exI) thus "(∃x. P x) ∨ (∃x. Q x)" by (rule disjI2) qed qed text {* --------------------------------------------------------------- Ejercicio 29. Demostrar o refutar (∀x. ∃y. P x y) ⟶ (∃y. ∀x. P x y) ------------------------------------------------------------------ *} lemma ejercicio_29: "(∀x. ∃y. P x y) ⟶ (∃y. ∀x. P x y)" quickcheck (* Quickcheck found a counterexample: P = (λx. undefined)(a\<^isub> := {b}, b := {a}) *) oops text {* --------------------------------------------------------------- Ejercicio 32. Demostrar o refutar ∃x y. R x y ∨ R y x; ¬(∃x. R x x)⟧ ⟹ ∃x y. x ≠ y ------------------------------------------------------------------ *} -- "La demostración automática es" lemma ejercicio_32a: fixes R :: "'c ⇒ 'c ⇒ bool" assumes "∃x y. R x y ∨ R y x" "¬(∃x. R x x)" shows "∃(x::'c) y. x ≠ y" using assms by metis -- "La demostración estructurada es" lemma ejercicio_32b: fixes R :: "'c ⇒ 'c ⇒ bool" assumes "∃x y. R x y ∨ R y x" "¬(∃x. R x x)" shows "∃(x::'c) y. x ≠ y" proof - obtain a where "∃y. R a y ∨ R y a" using assms(1) .. then obtain b where "R a b ∨ R b a" .. hence "a ≠ b" proof assume "R a b" show "a ≠ b" proof assume "a = b" hence "R b b" using `R a b` by (rule subst) hence "∃x. R x x" .. with assms(2) show False .. qed next assume "R b a" show "a ≠ b" proof assume "a = b" hence "R a a" using `R b a` by (rule ssubst) hence "∃x. R x x" .. with assms(2) show False .. qed qed hence "∃y. a ≠ y" .. thus "∃(x::'c) y. x ≠ y" .. qed -- "La demostración detallada es" lemma ejercicio_32c: fixes R :: "'c ⇒ 'c ⇒ bool" assumes "∃x y. R x y ∨ R y x" "¬(∃x. R x x)" shows "∃(x::'c) y. x ≠ y" proof - obtain a where "∃y. R a y ∨ R y a" using assms(1) by (rule exE) then obtain b where "R a b ∨ R b a" by (rule exE) hence "a ≠ b" proof (rule disjE) assume "R a b" show "a ≠ b" proof (rule notI) assume "a = b" hence "R b b" using `R a b` by (rule subst) hence "∃x. R x x" by (rule exI) with assms(2) show False by (rule notE) qed next assume "R b a" show "a ≠ b" proof (rule notI) assume "a = b" hence "R a a" using `R b a` by (rule ssubst) hence "∃x. R x x" by (rule exI) with assms(2) show False by (rule notE) qed qed hence "∃y. a ≠ y" by (rule exI) thus "∃(x::'c) y. x ≠ y" by (rule exI) qed text {* --------------------------------------------------------------- Ejercicio 34. Demostrar o refutar {∀x. P a x x, ∀x y z. P x y z ⟶ P (f x) y (f z)⟧ ⊢ ∃z. P (f a) z (f (f a)) ------------------------------------------------------------------ *} -- "La demostración automática es" lemma ejercicio_34a: "⟦∀x. P a x x; ∀x y z. P x y z ⟶ P (f x) y (f z)⟧ ⟹ ∃z. P (f a) z (f (f a))" by metis -- "La demostración estructura es" lemma ejercicio_34b: assumes "∀x. P a x x" "∀x y z. P x y z ⟶ P (f x) y (f z)" shows "∃z. P (f a) z (f (f a))" proof - have "P a (f a) (f a)" using assms(1) .. have "∀y z. P a y z ⟶ P (f a) y (f z)" using assms(2) .. hence "∀z. P a (f a) z ⟶ P (f a) (f a) (f z)" .. hence "P a (f a) (f a) ⟶ P (f a) (f a) (f (f a))" .. hence "P (f a) (f a) (f (f a))" using `P a (f a) (f a)` .. thus "∃z. P (f a) z (f (f a))" .. qed -- "La demostración detallada es" lemma ejercicio_34c: assumes "∀x. P a x x" "∀x y z. P x y z ⟶ P (f x) y (f z)" shows "∃z. P (f a) z (f (f a))" proof - have "P a (f a) (f a)" using assms(1) by (rule allE) have "∀y z. P a y z ⟶ P (f a) y (f z)" using assms(2) by (rule allE) hence "∀z. P a (f a) z ⟶ P (f a) (f a) (f z)" by (rule allE) hence "P a (f a) (f a) ⟶ P (f a) (f a) (f (f a))" by (rule allE) hence "P (f a) (f a) (f (f a))" using `P a (f a) (f a)` by (rule mp) thus "∃z. P (f a) z (f (f a))" by (rule exI) qed |