Diferencia entre revisiones de «Relación 7»
De Razonamiento automático (2017-18)
Línea 61: | Línea 61: | ||
¬q ⟶ ¬p ⊢ p ⟶ q | ¬q ⟶ ¬p ⊢ p ⟶ q | ||
------------------------------------------------------------------ *} | ------------------------------------------------------------------ *} | ||
+ | |||
+ | (*anddonram*) | ||
+ | lemma ej_1: | ||
+ | assumes 1: "¬q ⟶ ¬p" | ||
+ | shows "p ⟶ q" | ||
+ | proof (rule impI) | ||
+ | assume 2: "p" | ||
+ | show 3: "q" | ||
+ | proof (rule ccontr) | ||
+ | assume 4: "¬q" | ||
+ | have 5: "¬p" using 1 4 by (rule impE) | ||
+ | then show False using 2 by (rule notE) | ||
+ | qed | ||
+ | qed | ||
text {* --------------------------------------------------------------- | text {* --------------------------------------------------------------- | ||
Línea 66: | Línea 80: | ||
¬(¬p ∧ ¬q) ⊢ p ∨ q | ¬(¬p ∧ ¬q) ⊢ p ∨ q | ||
------------------------------------------------------------------ *} | ------------------------------------------------------------------ *} | ||
+ | |||
+ | (*anddonram*) | ||
+ | lemma l_e_m: | ||
+ | "F ∨ ¬F" | ||
+ | by auto | ||
+ | |||
+ | lemma ej_2: | ||
+ | assumes 1:"¬(¬p ∧ ¬q)" | ||
+ | shows "p ∨ q" | ||
+ | proof (rule disjE) | ||
+ | { | ||
+ | assume 2: "q" | ||
+ | show "p ∨ q" using 2 by (rule disjI2) | ||
+ | } | ||
+ | moreover{ | ||
+ | assume 4:"¬q" | ||
+ | show "p ∨ q" | ||
+ | proof(rule disjI1) | ||
+ | show "p" | ||
+ | proof (rule ccontr) | ||
+ | assume 5:"¬p" | ||
+ | then have "¬p ∧ ¬q" using 4 by (rule conjI) | ||
+ | with 1 show False by (rule notE) | ||
+ | qed | ||
+ | qed | ||
+ | } | ||
+ | moreover | ||
+ | show 1: "q ∨ ¬q" by (rule l_e_m) | ||
+ | qed | ||
text {* --------------------------------------------------------------- | text {* --------------------------------------------------------------- | ||
Línea 71: | Línea 114: | ||
¬(¬p ∨ ¬q) ⊢ p ∧ q | ¬(¬p ∨ ¬q) ⊢ p ∧ q | ||
------------------------------------------------------------------ *} | ------------------------------------------------------------------ *} | ||
+ | |||
+ | (*anddonram*) | ||
+ | lemma ej_3: | ||
+ | assumes 1:" ¬(¬p ∨ ¬q)" | ||
+ | shows "p ∧ q" | ||
+ | proof (rule conjI) | ||
+ | show "p" | ||
+ | proof (rule ccontr) | ||
+ | assume "¬p" | ||
+ | then have "(¬p ∨ ¬q)" by (rule disjI1) | ||
+ | with 1 show False by (rule notE) | ||
+ | qed | ||
+ | next | ||
+ | show "q" | ||
+ | proof (rule ccontr) | ||
+ | assume "¬q" | ||
+ | then have "(¬p ∨ ¬q)" by (rule disjI2) | ||
+ | with 1 show False by (rule notE) | ||
+ | qed | ||
+ | qed | ||
text {* --------------------------------------------------------------- | text {* --------------------------------------------------------------- | ||
Línea 76: | Línea 139: | ||
¬(p ∧ q) ⊢ ¬p ∨ ¬q | ¬(p ∧ q) ⊢ ¬p ∨ ¬q | ||
------------------------------------------------------------------ *} | ------------------------------------------------------------------ *} | ||
+ | |||
+ | (*anddonram*) | ||
+ | lemma ej_4: | ||
+ | assumes 1: "¬(p ∧ q)" | ||
+ | shows "¬p ∨ ¬q" | ||
+ | proof(rule disjE) | ||
+ | { | ||
+ | assume 2:"p" | ||
+ | show "¬p ∨ ¬q" | ||
+ | proof (rule disjI2) | ||
+ | show "¬q" | ||
+ | proof (rule notI) | ||
+ | assume "q" | ||
+ | with 2 have "p∧q" by (rule conjI) | ||
+ | with 1 show False by (rule notE) | ||
+ | qed | ||
+ | qed | ||
+ | } | ||
+ | moreover | ||
+ | { | ||
+ | assume "¬p" | ||
+ | then show "¬p ∨ ¬q" by (rule disjI1) | ||
+ | } | ||
+ | moreover | ||
+ | show 1: "p ∨ ¬p" by (rule l_e_m) | ||
+ | qed | ||
text {* --------------------------------------------------------------- | text {* --------------------------------------------------------------- | ||
Línea 81: | Línea 170: | ||
⊢ (p ⟶ q) ∨ (q ⟶ p) | ⊢ (p ⟶ q) ∨ (q ⟶ p) | ||
------------------------------------------------------------------ *} | ------------------------------------------------------------------ *} | ||
+ | |||
+ | (*anddonram*) | ||
+ | lemma ej_5: | ||
+ | shows "(p ⟶ q) ∨ (q ⟶ p)" | ||
+ | proof (rule disjE) | ||
+ | |||
+ | { | ||
+ | assume 2: "q" | ||
+ | show "(p ⟶ q) ∨ (q ⟶ p)" | ||
+ | proof(rule disjI1) | ||
+ | show "p ⟶ q" using 2 by (rule impI) | ||
+ | qed | ||
+ | } | ||
+ | moreover{ | ||
+ | assume 4:" ¬q" | ||
+ | show "(p ⟶ q) ∨ (q ⟶ p)" | ||
+ | proof(rule disjI2) | ||
+ | show "q ⟶ p" | ||
+ | proof (rule impI) | ||
+ | assume 5:"q" | ||
+ | with 4 show "p" by (rule notE) | ||
+ | qed | ||
+ | qed | ||
+ | } | ||
+ | moreover | ||
+ | show 1: "q ∨ ¬q" by (rule l_e_m) | ||
+ | qed | ||
end | end | ||
</source> | </source> |
Revisión del 00:06 2 feb 2018
chapter {* R7: Deducción natural proposicional en Isabelle/HOL *}
theory R7_Deduccion_natural_proposicional
imports Main
begin
text {*
Demostrar o refutar los siguientes lemas usando sólo las reglas
básicas de deducción natural de la lógica proposicional, de los
cuantificadores y de la igualdad:
· conjI: ⟦P; Q⟧ ⟹ P ∧ Q
· conjunct1: P ∧ Q ⟹ P
· conjunct2: P ∧ Q ⟹ Q
· notnotD: ¬¬ P ⟹ P
· mp: ⟦P ⟶ Q; P⟧ ⟹ Q
· impI: (P ⟹ Q) ⟹ P ⟶ Q
· disjI1: P ⟹ P ∨ Q
· disjI2: Q ⟹ P ∨ Q
· disjE: ⟦P ∨ Q; P ⟹ R; Q ⟹ R⟧ ⟹ R
· FalseE: False ⟹ P
· notE: ⟦¬P; P⟧ ⟹ R
· notI: (P ⟹ False) ⟹ ¬P
· iffI: ⟦P ⟹ Q; Q ⟹ P⟧ ⟹ P = Q
· iffD1: ⟦Q = P; Q⟧ ⟹ P
· iffD2: ⟦P = Q; Q⟧ ⟹ P
· ccontr: (¬P ⟹ False) ⟹ P
· allI: ⟦∀x. P x; P x ⟹ R⟧ ⟹ R
· allE: (⋀x. P x) ⟹ ∀x. P x
· exI: P x ⟹ ∃x. P x
· exE: ⟦∃x. P x; ⋀x. P x ⟹ Q⟧ ⟹ Q
· refl: t = t
· subst: ⟦s = t; P s⟧ ⟹ P t
· trans: ⟦r = s; s = t⟧ ⟹ r = t
· sym: s = t ⟹ t = s
· not_sym: t ≠ s ⟹ s ≠ t
· ssubst: ⟦t = s; P s⟧ ⟹ P t
· box_equals: ⟦a = b; a = c; b = d⟧ ⟹ a: = d
· arg_cong: x = y ⟹ f x = f y
· fun_cong: f = g ⟹ f x = g x
· cong: ⟦f = g; x = y⟧ ⟹ f x = g y
*}
text {*
Se usarán las reglas notnotI, mt y not_ex que demostramos a continuación.
*}
lemma notnotI: "P ⟹ ¬¬ P"
by auto
lemma mt: "⟦F ⟶ G; ¬G⟧ ⟹ ¬F"
by auto
lemma no_ex: "¬(∃x. P(x)) ⟹ ∀x. ¬P(x)"
by auto
text {* ---------------------------------------------------------------
Ejercicio 1. Demostrar
¬q ⟶ ¬p ⊢ p ⟶ q
------------------------------------------------------------------ *}
(*anddonram*)
lemma ej_1:
assumes 1: "¬q ⟶ ¬p"
shows "p ⟶ q"
proof (rule impI)
assume 2: "p"
show 3: "q"
proof (rule ccontr)
assume 4: "¬q"
have 5: "¬p" using 1 4 by (rule impE)
then show False using 2 by (rule notE)
qed
qed
text {* ---------------------------------------------------------------
Ejercicio 2. Demostrar
¬(¬p ∧ ¬q) ⊢ p ∨ q
------------------------------------------------------------------ *}
(*anddonram*)
lemma l_e_m:
"F ∨ ¬F"
by auto
lemma ej_2:
assumes 1:"¬(¬p ∧ ¬q)"
shows "p ∨ q"
proof (rule disjE)
{
assume 2: "q"
show "p ∨ q" using 2 by (rule disjI2)
}
moreover{
assume 4:"¬q"
show "p ∨ q"
proof(rule disjI1)
show "p"
proof (rule ccontr)
assume 5:"¬p"
then have "¬p ∧ ¬q" using 4 by (rule conjI)
with 1 show False by (rule notE)
qed
qed
}
moreover
show 1: "q ∨ ¬q" by (rule l_e_m)
qed
text {* ---------------------------------------------------------------
Ejercicio 3. Demostrar
¬(¬p ∨ ¬q) ⊢ p ∧ q
------------------------------------------------------------------ *}
(*anddonram*)
lemma ej_3:
assumes 1:" ¬(¬p ∨ ¬q)"
shows "p ∧ q"
proof (rule conjI)
show "p"
proof (rule ccontr)
assume "¬p"
then have "(¬p ∨ ¬q)" by (rule disjI1)
with 1 show False by (rule notE)
qed
next
show "q"
proof (rule ccontr)
assume "¬q"
then have "(¬p ∨ ¬q)" by (rule disjI2)
with 1 show False by (rule notE)
qed
qed
text {* ---------------------------------------------------------------
Ejercicio 4. Demostrar
¬(p ∧ q) ⊢ ¬p ∨ ¬q
------------------------------------------------------------------ *}
(*anddonram*)
lemma ej_4:
assumes 1: "¬(p ∧ q)"
shows "¬p ∨ ¬q"
proof(rule disjE)
{
assume 2:"p"
show "¬p ∨ ¬q"
proof (rule disjI2)
show "¬q"
proof (rule notI)
assume "q"
with 2 have "p∧q" by (rule conjI)
with 1 show False by (rule notE)
qed
qed
}
moreover
{
assume "¬p"
then show "¬p ∨ ¬q" by (rule disjI1)
}
moreover
show 1: "p ∨ ¬p" by (rule l_e_m)
qed
text {* ---------------------------------------------------------------
Ejercicio 5. Demostrar
⊢ (p ⟶ q) ∨ (q ⟶ p)
------------------------------------------------------------------ *}
(*anddonram*)
lemma ej_5:
shows "(p ⟶ q) ∨ (q ⟶ p)"
proof (rule disjE)
{
assume 2: "q"
show "(p ⟶ q) ∨ (q ⟶ p)"
proof(rule disjI1)
show "p ⟶ q" using 2 by (rule impI)
qed
}
moreover{
assume 4:" ¬q"
show "(p ⟶ q) ∨ (q ⟶ p)"
proof(rule disjI2)
show "q ⟶ p"
proof (rule impI)
assume 5:"q"
with 4 show "p" by (rule notE)
qed
qed
}
moreover
show 1: "q ∨ ¬q" by (rule l_e_m)
qed
end