LMF2019: Deducción natural en lógica de primer orden (2/2)
En la clase de hoy del curso Lógica matemática y fundamentos se ha completado el estudio del cálculo de deducción natural proposional para la lógica de primer orden demostrando algunas equivalencias notables y presentando las reglas de la igualdad
La clase se ha dado mediante videoconferencia y el correspondiente vídeo es
Las transparencias de esta clase son las páginas 14 a 29 del tema 4.
A la vez que se han ido haciendo las demostraciones se ha explicado cómo hacerlas en Isabelle/HOL.
La teoría con los ejemplos presentados en la clase es la siguiente:
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 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
chapter ‹Tema 4a: Deducción natural en lógica de primer orden› theory T4a_Deduccion_natural_en_logica_de_primer_orden imports Main begin chapter ‹Tema 4a: Deducción natural en lógica de primer orden› theory T4a_Deduccion_natural_en_logica_de_primer_orden imports Main begin section ‹Demostración de equivalencias› subsection ‹Ejemplo 5.1› text ‹Ejemplo 5.1 (p. 15). Demostrar ¬∀x. P x ⊢ ∃x. ¬(P x)› subsubsection ‹Demostración detallada› ― ‹La demostración detallada es› lemma ejemplo_5_1a: assumes "¬(∀x. P(x))" shows "∃x. ¬P(x)" proof (rule ccontr) assume "¬(∃x. ¬P(x))" have "∀x. P(x)" proof (rule allI) fix a show "P(a)" proof (rule ccontr) assume "¬P(a)" then have "∃x. ¬P(x)" by (rule exI) with ‹¬(∃x. ¬P(x))› show False by (rule notE) qed qed with assms show False by (rule notE) qed subsubsection ‹Demostración estructurada› ― ‹La demostración estructurada es› lemma ejemplo_5_1b: assumes "¬(∀x. P(x))" shows "∃x. ¬P(x)" proof (rule ccontr) assume "¬(∃x. ¬P(x))" have "∀x. P(x)" proof fix a show "P(a)" proof (rule ccontr) assume "¬P(a)" then have "∃x. ¬P(x)" .. with ‹¬(∃x. ¬P(x))› show False .. qed qed with assms show False .. qed subsubsection ‹Demostración automática› ― ‹La demostración automática es› lemma ejemplo_5_1c: assumes "¬(∀x. P(x))" shows "∃x. ¬P(x)" using assms by auto subsubsection ‹Demostración aplicativa› lemma ejemplo_5_1d: "¬(∀x. P x) ⟹ ∃y. ¬P y" apply (rule ccontr) (* da ⟦¬ (∀x. P x); ∄y. ¬ P y⟧ ⟹ False *) apply (erule notE) (* da ∄y. ¬ P y ⟹ ∀x. P x *) apply (rule allI) (* da ⋀x. ∄y. ¬ P y ⟹ P x *) apply (rule ccontr) (* da ⋀x. ⟦∄y. ¬ P y; ¬ P x⟧ ⟹ False *) apply (erule notE) (* da ⋀x. ¬ P x ⟹ ∃y. ¬ P y *) apply (erule exI) (* da No subgoals! *) done text ‹ Ejemplo 5.2 (p. 16). Demostrar ∃x. ¬(P x) ⊢ ¬∀x. P x› ― ‹La demostración detallada es› lemma ejemplo_5_2a: assumes "∃x. ¬P(x)" shows "¬(∀x. P(x))" proof (rule notI) assume "∀x. P(x)" obtain a where "¬P(a)" using assms by (rule exE) have "P(a)" using ‹∀x. P(x)› by (rule allE) with ‹¬P(a)› show False by (rule notE) qed ― ‹La demostración estructurada es› lemma ejemplo_5_2b: assumes "∃x. ¬P(x)" shows "¬(∀x. P(x))" proof assume "∀x. P(x)" obtain a where "¬P(a)" using assms .. have "P(a)" using ‹∀x. P(x)› .. with ‹¬P(a)› show False .. qed ― ‹La demostración automática es› lemma ejemplo_5_2c: assumes "∃x. ¬P(x)" shows "¬(∀x. P(x))" using assms by auto text ‹ Ejemplo 5.3 (p. 17). Demostrar ⊢ ¬∀x. P x ⟷ ∃x. ¬(P x)› ― ‹La demostración detallada es› lemma ejemplo_5_3a: "(¬(∀x. P(x))) ⟷ (∃x. ¬P(x))" proof (rule iffI) assume "¬(∀x. P(x))" then show "∃x. ¬P(x)" by (rule ejemplo_5_1a) next assume "∃x. ¬P(x)" then show "¬(∀x. P(x))" by (rule ejemplo_5_2a) qed ― ‹La demostración automática es› lemma ejemplo_5_3b: "(¬(∀x. P(x))) ⟷ (∃x. ¬P(x))" by auto text ‹Ejemplo 6.1 (p. 18). Demostrar ∀x. P(x) ∧ Q(x) ⊢ (∀x. P(x)) ∧ (∀x. Q(x))› ― ‹La demostración detallada es› lemma ejemplo_6_1a: assumes "∀x. P(x) ∧ Q(x)" shows "(∀x. P(x)) ∧ (∀x. Q(x))" proof (rule conjI) show "∀x. P(x)" proof (rule allI) fix a have "P(a) ∧ Q(a)" using assms by (rule allE) then show "P(a)" by (rule conjunct1) qed next show "∀x. Q(x)" proof (rule allI) fix a have "P(a) ∧ Q(a)" using assms by (rule allE) then show "Q(a)" by (rule conjunct2) qed qed ― ‹La demostración estructurada es› lemma ejemplo_6_1b: assumes "∀x. P(x) ∧ Q(x)" shows "(∀x. P(x)) ∧ (∀x. Q(x))" proof show "∀x. P(x)" proof fix a have "P(a) ∧ Q(a)" using assms .. then show "P(a)" .. qed next show "∀x. Q(x)" proof fix a have "P(a) ∧ Q(a)" using assms .. then show "Q(a)" .. qed qed ― ‹La demostración automática es› lemma ejemplo_6_1c: assumes "∀x. P(x) ∧ Q(x)" shows "(∀x. P(x)) ∧ (∀x. Q(x))" using assms by auto text ‹Ejemplo 6.2 (p. 19). Demostrar (∀x. P(x)) ∧ (∀x. Q(x)) ⊢ ∀x. P(x) ∧ Q(x)› ― ‹La demostración detallada es› lemma ejemplo_6_2a: assumes "(∀x. P(x)) ∧ (∀x. Q(x))" shows "∀x. P(x) ∧ Q(x)" proof (rule allI) fix a have "∀x. P(x)" using assms by (rule conjunct1) then have "P(a)" by (rule allE) have "∀x. Q(x)" using assms by (rule conjunct2) then have "Q(a)" by (rule allE) with ‹P(a)› show "P(a) ∧ Q(a)" by (rule conjI) qed ― ‹La demostración estructurada es› lemma ejemplo_6_2b: assumes "(∀x. P(x)) ∧ (∀x. Q(x))" shows "∀x. P(x) ∧ Q(x)" proof fix a have "∀x. P(x)" using assms .. then have "P(a)" .. have "∀x. Q(x)" using assms .. then have "Q(a)" .. with ‹P(a)› show "P(a) ∧ Q(a)" .. qed ― ‹La demostración automática es› lemma ejemplo_6_2c: assumes "(∀x. P(x)) ∧ (∀x. Q(x))" shows "∀x. P(x) ∧ Q(x)" using assms by simp text ‹Ejemplo 6.3 (p. 20). Demostrar ⊢ ∀x. P(x) ∧ Q(x) ⟷ (∀x. P(x)) ∧ (∀x. Q(x))› ― ‹La demostración detallada es› lemma ejemplo_6_3a: "(∀x. P(x) ∧ Q(x)) ⟷ ((∀x. P(x)) ∧ (∀x. Q(x)))" proof (rule iffI) assume "∀x. P(x) ∧ Q(x)" then show "(∀x. P(x)) ∧ (∀x. Q(x))" by (rule ejemplo_6_1a) next assume "(∀x. P(x)) ∧ (∀x. Q(x))" then show "∀x. P(x) ∧ Q(x)" by (rule ejemplo_6_2a) qed lemma "(∀x. P(x) ∨ Q(x)) ⟷ ((∀x. P(x)) ∨ (∀x. Q(x)))" oops text ‹Ejemplo 7.1 (p. 21). Demostrar (∃x. P(x)) ∨ (∃x. Q(x)) ⊢ ∃x. P(x) ∨ Q(x)› ― ‹La demostración detallada es› lemma ejemplo_7_1a: assumes "(∃x. P(x)) ∨ (∃x. Q(x))" shows "∃x. P(x) ∨ Q(x)" using assms proof (rule disjE) assume "∃x. P(x)" then obtain a where "P(a)" by (rule exE) then have "P(a) ∨ Q(a)" by (rule disjI1) then show "∃x. P(x) ∨ Q(x)" by (rule exI) next assume "∃x. Q(x)" then obtain a where "Q(a)" by (rule exE) then have "P(a) ∨ Q(a)" by (rule disjI2) then show "∃x. P(x) ∨ Q(x)" by (rule exI) qed ― ‹La demostración estructurada es› lemma ejemplo_7_1b: assumes "(∃x. P(x)) ∨ (∃x. Q(x))" shows "∃x. P(x) ∨ Q(x)" using assms proof assume "∃x. P(x)" then obtain a where "P(a)" .. then have "P(a) ∨ Q(a)" .. then show "∃x. P(x) ∨ Q(x)" .. next assume "∃x. Q(x)" then obtain a where "Q(a)" .. then have "P(a) ∨ Q(a)" .. then show "∃x. P(x) ∨ Q(x)" .. qed ― ‹La demostración automática es› lemma ejemplo_7_1c: assumes "(∃x. P(x)) ∨ (∃x. Q(x))" shows "∃x. P(x) ∨ Q(x)" using assms by auto text ‹Ejemplo 7.2 (p. 22). Demostrar ∃x. P(x) ∨ Q(x) ⊢ (∃x. P(x)) ∨ (∃x. Q(x))› ― ‹La demostración detallada es› lemma ejemplo_7_2a: assumes "∃x. P(x) ∨ Q(x)" shows "(∃x. P(x)) ∨ (∃x. Q(x))" proof - obtain a where "P(a) ∨ Q(a)" using assms by (rule exE) then show "(∃x. P(x)) ∨ (∃x. Q(x))" proof (rule disjE) assume "P(a)" then have "∃x. P(x)" by (rule exI) then show "(∃x. P(x)) ∨ (∃x. Q(x))" by (rule disjI1) next assume "Q(a)" then have "∃x. Q(x)" by (rule exI) then show "(∃x. P(x)) ∨ (∃x. Q(x))" by (rule disjI2) qed qed ― ‹La demostración estructurada es› lemma ejercicio_7_2b: assumes "∃x. P(x) ∨ Q(x)" shows "(∃x. P(x)) ∨ (∃x. Q(x))" proof - obtain a where "P(a) ∨ Q(a)" using assms .. then show "(∃x. P(x)) ∨ (∃x. Q(x))" proof assume "P(a)" then have "∃x. P(x)" .. then show "(∃x. P(x)) ∨ (∃x. Q(x))" .. next assume "Q(a)" then have "∃x. Q(x)" .. then show "(∃x. P(x)) ∨ (∃x. Q(x))" .. qed qed ― ‹La demostración automática es› lemma ejercicio_7_2c: assumes "∃x. P(x) ∨ Q(x)" shows "(∃x. P(x)) ∨ (∃x. Q(x))" using assms by auto text ‹Ejemplo 7.3 (p. 23). Demostrar ⊢ ((∃x. P(x)) ∨ (∃x. Q(x))) ⟷ (∃x. P(x) ∨ Q(x))› ― ‹La demostración detallada es› lemma ejemplo_7_3a: "((∃x. P(x)) ∨ (∃x. Q(x))) ⟷ (∃x. P(x) ∨ Q(x))" proof (rule iffI) assume "(∃x. P(x)) ∨ (∃x. Q(x))" then show "∃x. P(x) ∨ Q(x)" by (rule ejemplo_7_1a) next assume "∃x. P(x) ∨ Q(x)" then show "(∃x. P(x)) ∨ (∃x. Q(x))" by (rule ejemplo_7_2a) qed ― ‹La demostración automática es› lemma ejemplo_7_3b: "((∃x. P(x)) ∨ (∃x. Q(x))) ⟷ (∃x. P(x) ∨ Q(x))" by auto lemma "((∃x. P(x)) ∧ (∃x. Q(x))) ⟷ (∃x. P(x) ∧ Q(x))" oops text ‹Ejemplo 8.1 (p. 24). Demostrar ∃x y. P(x,y) ⊢ ∃y x. P(x,y)› ― ‹La demostración detallada es› lemma ejemplo_8_1a: assumes "∃x y. P(x,y)" shows "∃y x. P(x,y)" proof - obtain a where "∃y. P(a,y)" using assms by (rule exE) then obtain b where "P(a,b)" by (rule exE) then have "∃x. P(x,b)" by (rule exI) then show "∃y x. P(x,y)" by (rule exI) qed ― ‹La demostración estructurada es› lemma ejemplo_8_1b: assumes "∃x y. P(x,y)" shows "∃y x. P(x,y)" proof - obtain a where "∃y. P(a,y)" using assms .. then obtain b where "P(a,b)" .. then have "∃x. P(x,b)" .. then show "∃y x. P(x,y)" .. qed ― ‹La demostración automática es› lemma ejemplo_8_1c: assumes "∃x y. P(x,y)" shows "∃y x. P(x,y)" using assms by auto text ‹Ejemplo 8.2. Demostrar ∃y x. P(x,y) ⊢ ∃x y. P(x,y)› ― ‹La demostración detallada es› lemma ejemplo_8_2a: assumes "∃y x. P(x,y)" shows "∃x y. P(x,y)" proof - obtain b where "∃x. P(x,b)" using assms by (rule exE) then obtain a where "P(a,b)" by (rule exE) then have "∃y. P(a,y)" by (rule exI) then show "∃x y. P(x,y)" by (rule exI) qed ― ‹La demostración estructurada es› lemma ejemplo_8_2b: assumes "∃y x. P(x,y)" shows "∃x y. P(x,y)" proof - obtain b where "∃x. P(x,b)" using assms .. then obtain a where "P(a,b)" .. then have "∃y. P(a,y)" .. then show "∃x y. P(x,y)" .. qed ― ‹La demostración estructurada es› lemma ejemplo_8_2c: assumes "∃y x. P(x,y)" shows "∃x y. P(x,y)" using assms by auto text ‹Ejemplo 8.3 (p. 25). Demostrar ⊢ (∃x y. P(x,y)) ⟷ (∃y x. P(x,y))› ― ‹La demostración detallada es› lemma ejemplo_8_3a: "(∃x y. P(x,y)) ⟷ (∃y x. P(x,y))" proof (rule iffI) assume "∃x y. P(x,y)" then show "∃y x. P(x,y)" by (rule ejemplo_8_1a) next assume "∃y x. P(x,y)" then show "∃x y. P(x,y)" by (rule ejemplo_8_2a) qed ― ‹La demostración automática es› lemma ejemplo_8_3b: "(∃x y. P(x,y)) ⟷ (∃y x. P(x,y))" by auto section ‹Reglas de la igualdad› text ‹ Las reglas básicas de la igualdad son: · refl: t = t · subst: ⟦s = t; P s⟧ ⟹ P t › text ‹Ejemplo 9 (p. 27). Demostrar x + 1 = 1 + x, x + 1 > 1 ⟶ x + 1 > 0 ⊢ 1 + x > 1 ⟶ 1 + x > 0 › ― ‹La demostración detallada es› lemma ejemplo_9a: assumes "x + 1 = 1 + x" "x + 1 > 1 ⟶ x + 1 > 0" shows "1 + x > 1 ⟶ 1 + x > 0" proof - show "1 + x > 1 ⟶ 1 + x > 0" using assms by (rule subst) qed ― ‹La demostración estructurada es› lemma ejemplo_9b: assumes "x + 1 = 1 + x" "x + 1 > 1 ⟶ x + 1 > 0" shows "1 + x > 1 ⟶ 1 + x > 0" using assms by (rule subst) ― ‹La demostración automática es› lemma ejemplo_9c: assumes "x + 1 = 1 + x" "x + 1 > 1 ⟶ x + 1 > 0" shows "1 + x > 1 ⟶ 1 + x > 0" using assms by auto text ‹Ejemplo 10 (p. 27). Demostrar x = y, y = z ⊢ x = z › ― ‹La demostración detallada es› lemma ejemplo_10a: assumes "x = y" "y = z" shows "x = z" proof - show "x = z" using assms(2, 1) by (rule subst) qed ― ‹La demostración estructurada es› lemma ejemplo_10b: assumes "x = y" "y = z" shows "x = z" using assms(2, 1) by (rule subst) ― ‹La demostración automática es› lemma ejemplo_10c: assumes "x = y" "y = z" shows "x = z" using assms by auto text ‹Ejemplo 11 (p. 28). Demostrar s = t ⊢ t = s › ― ‹La demostración detallada es› lemma ejemplo_11a: assumes "s = t" shows "t = s" proof - have "s = s" by (rule refl) with assms show "t = s" by (rule subst) qed ― ‹La demostración automática es› lemma ejemplo_11b: assumes "s = t" shows "t = s" using assms by auto end |