DAO2011: Ejercicios de deducción natural en lógica de primer orden con Isabelle/HOL
En la clase de hoy del curso de Demostración asistida por ordenador se han comentado las soluciones de los ejercicios de deducción natural en lógica de primer orden con Isabelle/HOL/Isar.
A continuación se muestra la teoría correspondiente a las soluciones de los ejercicios
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 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
header {* Deducción natural en la lógica de primer orden (Ejercicios) *} theory LogicaDePrimerOrdenEj imports Main begin text {* Los siguientes ejercicios son los del tema 7 del curso de LI demostrado usando las reglas de deducción natural. *} text {* Se usarán las reglas del modus tollens y de la introducción de la doble negación. *} lemma mt: "⟦F ⟶ G; ¬G⟧ ⟹ ¬F" by auto lemma notnotI: "P ⟹ ¬¬P" by auto lemma assumes "∀x. P x ⟶ Q x" shows "(∀x. P x) ⟶ (∀x. Q x)" proof (rule impI) assume 1: "∀x. P x" show "∀x. Q x" proof (rule allI) fix x have 2: "P x ⟶ Q x" using assms by (rule allE) have 3: "P x" using 1 by (rule allE) show "Q x" using 2 3 by (rule mp) qed qed lemma assumes "∃x. ¬P x" shows " ¬(∀x. P x)" proof (rule notI) assume 1: "∀x. P x" obtain a where 2: "¬P a" using assms(1) by (rule exE) have 3: "P a" using 1 by (rule allE) show False using 2 3 by (rule notE) qed lemma assumes "∀x. P x" shows "∀y. P y" proof (rule allI) fix a show "P a" using assms(1) by (rule allE) qed lemma assumes "∀x. P x ⟶ Q x" shows "(∀x. ¬Q x) ⟶ (∀x. ¬P x)" proof (rule impI) assume 1: "∀x. ¬Q x" show "∀x. ¬P x" proof (rule allI) fix x have 2: "P x ⟶ Q x" using assms(1) by (rule allE) have 3: "¬Q x" using 1 by (rule allE) show "¬P x" using 2 3 by (rule mt) qed qed lemma assumes "∀x. P x ⟶ ¬Q x" shows "¬(∃x. P x ∧ Q x)" proof (rule notI) assume "∃x. P x ∧ Q x" then obtain a where 1: "P a ∧ Q a" by (rule exE) have 2: "P a ⟶ ¬Q a" using assms(1) by (rule allE) have 3: "P a" using 1 by (rule conjunct1) have 4: "¬Q a" using 2 3 by (rule mp) have 5: "Q a" using 1 by (rule conjunct2) show False using 4 5 by (rule notE) qed lemma assumes "∀x. ∀y. P x y" shows "∀u. ∀v. P u v" proof (rule allI) fix u show "∀v. P u v" proof (rule allI) fix v have "∀y. P u y" using assms(1) by (rule allE) thus "P u v" by (rule allE) qed qed lemma assumes "∃x. ∃y. P x y" shows "∃u. ∃v. P u v" proof - obtain a where "∃y. P a y" using assms(1) by (rule exE) then obtain b where "P a b" by (rule exE) hence "∃v. P a v" by (rule exI) thus "∃u. ∃v. P u v" by (rule exI) qed lemma assumes "∃x. ∀y. P x y" shows "∀y. ∃x. P x y" proof (rule allI) fix y obtain a where "∀y. P a y" using assms(1) by (rule exE) hence "P a y" by (rule allE) thus "∃x. P x y" by (rule exI) qed lemma assumes "∃x. P a ⟶ Q x" shows "P a ⟶ (∃x. Q x)" proof (rule impI) assume 1: "P a" obtain b where "P a ⟶ Q b" using assms(1) by (rule exE) hence "Q b" using 1 by (rule mp) thus "∃x. Q x" by (rule exI) qed lemma assumes "P a ⟶ (∃x. Q x)" shows "∃x. P a ⟶ Q x" proof - have "¬P a ∨ P a" by (rule excluded_middle) thus "∃x. P a ⟶ Q x" proof (rule disjE) { assume "¬P a" hence "P a ⟶ Q b" by simp thus "∃x. P a ⟶ Q x" by (rule exI) } next { assume "P a" hence "∃x. Q x" using assms(1) by simp then obtain c where "Q c" by (rule exE) hence "P a ⟶ Q c" by simp thus "∃x. P a ⟶ Q x" by (rule exI) } qed qed lemma assumes "(∃x. P x) ⟶ Q a" shows "∀x. P x ⟶ Q a" proof (rule allI) fix x show "P x ⟶ Q a" proof assume "P x" hence 1: "∃x. P x" by (rule exI) show "Q a" using assms(1) 1 by (rule mp) qed qed lemma assumes "∀x. P x ⟶ Q a" shows "∃x. P x ⟶ Q a" proof (rule exI) show "P b ⟶ Q a" using assms(1) .. qed lemma assumes "(∀x. P x) ∨ (∀x. Q x)" shows "∀x. P x ∨ Q x" using assms proof (rule disjE) { assume 1: "∀x. P x" show "∀x. P x ∨ Q x" proof (rule allI) fix x have "P x" using 1 by (rule allE) thus "P x ∨ Q x" by (rule disjI1) qed } next { assume 2: "∀x. Q x" show "∀x. P x ∨ Q x" proof (rule allI) fix x have "Q x" using 2 by (rule allE) thus "P x ∨ Q x" by (rule disjI2) qed } qed lemma assumes "∃x. P x ∧ Q x" shows "(∃x. P x) ∧ (∃x. Q x)" proof - obtain a where 1: "P a ∧ Q a" using assms(1) by (rule exE) hence "P a" by (rule conjunct1) hence 2: "∃x. P x" by (rule exI) have "Q a" using 1 by (rule conjunct2) hence 3: "∃x. Q x" by (rule exI) show "(∃x. P x) ∧ (∃x. Q x)" using 2 3 by (rule conjI) qed lemma assumes "∀x.∀y. P y ⟶ Q x" shows "(∃y. P y) ⟶ (∀x. Q x)" proof (rule impI) assume 1: "∃y. P y" show "∀x. Q x" proof (rule allI) fix x have 2: "∀y. P y ⟶ Q x" using assms by (rule allE) obtain b where 3: "P b" using 1 by (rule exE) have "P b ⟶ Q x" using 2 by (rule allE) thus "Q x" using 3 by (rule mp) qed qed lemma assumes "¬(∀x. ¬P x)" shows "∃x. P x" proof (rule ccontr) assume 1: "¬(∃x. P x)" have 2: "∀x. ¬P x" proof fix x show "¬P x" proof assume "P x" hence 3: "∃x. P x" by (rule exI) show False using 1 3 by (rule notE) qed qed show False using assms(1) 2 by (rule notE) qed lemma assumes "∀x. ¬P x" shows "¬(∃x. P x)" proof (rule notI) assume "∃x. P x" then obtain a where 1: "P a" by (rule exE) have "¬P a" using assms(1) by (rule allE) thus False using 1 by (rule notE) qed lemma assumes "∃x. P x" shows "¬(∀x. ¬P x)" proof (rule notI) assume 1: "∀x. ¬P x" obtain a where 2: "P a" using assms(1) by (rule exE) have "¬P a" using 1 by (rule allE) thus False using 2 by (rule notE) qed lemma assumes "P a ⟶ (∀x. Q x)" shows "∀x. P a ⟶ Q x" proof (rule allI) fix x show "P a ⟶ Q x" proof assume 1: "P a" have "∀x. Q x" using assms(1) 1 by (rule mp) thus "Q x" by (rule allE) qed qed lemma assumes "∀x.∀y.∀z. R x y ∧ R y z ⟶ R x z" and "∀x. ¬R x x" shows "∀x.∀y. R x y ⟶ ¬R y x" proof (rule allI) fix x show "∀y. R x y ⟶ ¬R y x" proof (rule allI) fix y show "R x y ⟶ ¬R y x" proof (rule impI) assume 1: "R x y" show "¬R y x" proof assume 2: "R y x" have "∀y.∀z. R x y ∧ R y z ⟶ R x z" using assms(1) by (rule allE) hence "∀z. R x y ∧ R y z ⟶ R x z" by (rule allE) hence 3: "R x y ∧ R y x ⟶ R x x" by (rule allE) have 4: "R x y ∧ R y x" using 1 2 by (rule conjI) have 5: "R x x" using 3 4 by (rule mp) have "¬R x x" using assms(2) by (rule allE) thus False using 5 by (rule notE) qed qed qed qed lemma assumes "∀x. P x ∨ Q x" and "∃x. ¬Q x" and "∀x. R x ⟶ ¬P x" shows "∃x. ¬R x" proof - obtain a where 1: "¬Q a" using assms(2) .. have "P a ∨ Q a" using assms(1) .. thus "∃x. ¬R x" proof (rule disjE) { assume "P a" hence 2: "¬¬P a" by (rule notnotI) have "R a ⟶ ¬P a" using assms(3) by (rule allE) hence "¬R a" using 2 by (rule mt) thus "∃x. ¬R x" by (rule exI) } next { assume 3: "Q a" show "∃x. ¬R x" using 1 3 by (rule notE) } qed qed lemma assumes "∀x. P x ⟶ Q x ∨ R x" and "¬(∃x. P x ∧ R x)" shows "∀x. P x ⟶ Q x" proof fix x show "P x ⟶ Q x" proof assume 1: "P x" have "P x ⟶ Q x ∨ R x" using assms(1) by (rule allE) hence "Q x ∨ R x" using 1 by (rule mp) thus "Q x" proof (rule disjE) { assume "Q x" thus "Q x" by this } next { assume 2: "R x" have "P x ∧ R x" using 1 2 by (rule conjI) hence 3: "∃x. P x ∧ R x" by (rule exI) show "Q x" using assms(2) 3 by (rule notE) } qed qed qed lemma assumes "∃x.∃y. R x y ∨ R y x" shows "∃x.∃y. R 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) thus "∃x.∃y. R x y" proof { assume "R a b" hence "∃y. R a y" by (rule exI) thus "∃x.∃y. R x y" by (rule exI) } next { assume "R b a" hence "∃y. R b y" by (rule exI) thus "∃x.∃y. R x y" by (rule exI) } qed qed end |