Acciones

Diferencia entre revisiones de «Tema 8»

De Lógica matemática y fundamentos (2012-13)

(Página creada con '<source lang="Isar"> header {* Tema 8: Deducción natural en lógica de primer orden *} theory Tema8 imports Main begin text {* El objetivo de este tema es presentar la ded...')
 
 
Línea 20: Línea 20:
 
text {*
 
text {*
 
   Las reglas del cuantificador universal son
 
   Las reglas del cuantificador universal son
   · allE:    \<lbrakk>\<forall>x. P x; P a \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R
+
   · allE:    ⟦∀x. P x; P a ⟹ R⟧ ⟹ R
   · allI:    (\<And>x. P x) \<Longrightarrow> \<forall>x. P x
+
   · allI:    (⋀x. P x) ⟹ ∀x. P x
 
   *}
 
   *}
  
 
text {*  
 
text {*  
 
   Ejemplo 1 (p. 10). Demostrar que
 
   Ejemplo 1 (p. 10). Demostrar que
     P(c), \<forall>x. (P(x) \<longrightarrow> \<not>Q(x)) \<turnstile> \<not>Q(c)
+
     P(c), ∀x. (P(x) ⟶ ¬Q(x)) ⊢ ¬Q(c)
 
*}
 
*}
  
Línea 32: Línea 32:
 
lemma ejemplo_1a:  
 
lemma ejemplo_1a:  
 
   assumes 1: "P(c)" and
 
   assumes 1: "P(c)" and
           2: "\<forall>x. (P(x) \<longrightarrow> \<not>Q(x))"
+
           2: "∀x. (P(x) ⟶ ¬Q(x))"
   shows "\<not>Q(c)"
+
   shows "¬Q(c)"
 
proof -
 
proof -
   have 3: "P(c) \<longrightarrow> \<not>Q(c)" using 2 by (rule allE)
+
   have 3: "P(c) ⟶ ¬Q(c)" using 2 by (rule allE)
   show 4: "\<not>Q(c)" using 3 1 by (rule mp)
+
   show 4: "¬Q(c)" using 3 1 by (rule mp)
 
qed
 
qed
  
Línea 42: Línea 42:
 
lemma ejemplo_1b:  
 
lemma ejemplo_1b:  
 
   assumes "P(c)"
 
   assumes "P(c)"
           "\<forall>x. (P(x) \<longrightarrow> \<not>Q(x))"
+
           "∀x. (P(x) ⟶ ¬Q(x))"
   shows "\<not>Q(c)"
+
   shows "¬Q(c)"
 
proof -
 
proof -
   have "P(c) \<longrightarrow> \<not>Q(c)" using assms(2) ..
+
   have "P(c) ⟶ ¬Q(c)" using assms(2) ..
   thus "\<not>Q(c)" using assms(1) ..
+
   thus "¬Q(c)" using assms(1) ..
 
qed
 
qed
  
Línea 52: Línea 52:
 
lemma ejemplo_1c:  
 
lemma ejemplo_1c:  
 
   assumes "P(c)"
 
   assumes "P(c)"
           "\<forall>x. (P(x) \<longrightarrow> \<not>Q(x))"
+
           "∀x. (P(x) ⟶ ¬Q(x))"
   shows "\<not>Q(c)"
+
   shows "¬Q(c)"
 
using assms
 
using assms
 
by auto
 
by auto
Línea 59: Línea 59:
 
text {*  
 
text {*  
 
   Ejemplo 2 (p. 11). Demostrar que
 
   Ejemplo 2 (p. 11). Demostrar que
     \<forall>x. (P x \<longrightarrow> \<not>(Q x)), \<forall>x. P x \<turnstile> \<forall>x. \<not>(Q x)
+
     ∀x. (P x ⟶ ¬(Q x)), ∀x. P x ⊢ ∀x. ¬(Q x)
 
*}
 
*}
  
 
-- "La demostración detallada es"
 
-- "La demostración detallada es"
 
lemma ejemplo_2a:  
 
lemma ejemplo_2a:  
   assumes 1: "\<forall>x. (P x \<longrightarrow> \<not>(Q x))" and
+
   assumes 1: "∀x. (P x ⟶ ¬(Q x))" and
           2: "\<forall>x. P x"
+
           2: "∀x. P x"
   shows "\<forall>x. \<not>(Q x)"
+
   shows "∀x. ¬(Q x)"
 
proof -
 
proof -
 
   { fix a
 
   { fix a
     have 3: "P a \<longrightarrow> \<not>(Q a)" using 1 by (rule allE)
+
     have 3: "P a ⟶ ¬(Q a)" using 1 by (rule allE)
 
     have 4: "P a" using 2 by (rule allE)
 
     have 4: "P a" using 2 by (rule allE)
     have 5: "\<not>(Q a)" using 3 4 by (rule mp) }
+
     have 5: "¬(Q a)" using 3 4 by (rule mp) }
   thus "\<forall>x. \<not>(Q x)" by (rule allI)
+
   thus "∀x. ¬(Q x)" by (rule allI)
 
qed
 
qed
  
 
-- "La demostración detallada hacia atrás es"
 
-- "La demostración detallada hacia atrás es"
 
lemma ejemplo_2b:  
 
lemma ejemplo_2b:  
   assumes 1: "\<forall>x. (P x \<longrightarrow> \<not>(Q x))" and
+
   assumes 1: "∀x. (P x ⟶ ¬(Q x))" and
           2: "\<forall>x. P x"
+
           2: "∀x. P x"
   shows "\<forall>x. \<not>(Q x)"
+
   shows "∀x. ¬(Q x)"
 
proof (rule allI)
 
proof (rule allI)
 
   fix a
 
   fix a
   have 3: "P a \<longrightarrow> \<not>(Q a)" using 1 by (rule allE)
+
   have 3: "P a ⟶ ¬(Q a)" using 1 by (rule allE)
 
   have 4: "P a" using 2 by (rule allE)
 
   have 4: "P a" using 2 by (rule allE)
   show 5: "\<not>(Q a)" using 3 4 by (rule mp)  
+
   show 5: "¬(Q a)" using 3 4 by (rule mp)  
 
qed
 
qed
  
 
-- "La demostración estructurada es"
 
-- "La demostración estructurada es"
 
lemma ejemplo_2c:  
 
lemma ejemplo_2c:  
   assumes "\<forall>x. (P x \<longrightarrow> \<not>(Q x))"
+
   assumes "∀x. (P x ⟶ ¬(Q x))"
           "\<forall>x. P x"
+
           "∀x. P x"
   shows "\<forall>x. \<not>(Q x)"
+
   shows "∀x. ¬(Q x)"
 
proof  
 
proof  
 
   fix a
 
   fix a
 
   have "P a" using assms(2) ..
 
   have "P a" using assms(2) ..
   have "P a \<longrightarrow> \<not>(Q a)" using assms(1) ..
+
   have "P a ⟶ ¬(Q a)" using assms(1) ..
   thus "\<not>(Q a)" using `P a` ..
+
   thus "¬(Q a)" using `P a` ..
 
qed
 
qed
  
 
-- "La demostración automática es"
 
-- "La demostración automática es"
 
lemma ejemplo_2d:  
 
lemma ejemplo_2d:  
   assumes "\<forall>x. (P x \<longrightarrow> \<not>(Q x))"
+
   assumes "∀x. (P x ⟶ ¬(Q x))"
           "\<forall>x. P x"
+
           "∀x. P x"
   shows  "\<forall>x. \<not>(Q x)"
+
   shows  "∀x. ¬(Q x)"
 
using assms
 
using assms
 
by auto
 
by auto
Línea 111: Línea 111:
 
text {*
 
text {*
 
   Las reglas del cuantificador existencial son
 
   Las reglas del cuantificador existencial son
   · exI:    P a \<Longrightarrow> \<exists>x. P x
+
   · exI:    P a ⟹ ∃x. P x
   · exE:    \<lbrakk>\<exists>x. P x; \<And>x. P x \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q
+
   · exE:    ⟦∃x. P x; ⋀x. P x ⟹ Q⟧ ⟹ Q
  
 
   En la regla exE la nueva variable se introduce mediante la declaración  
 
   En la regla exE la nueva variable se introduce mediante la declaración  
Línea 120: Línea 120:
 
text {*  
 
text {*  
 
   Ejemplo  (p. 12). Demostrar que
 
   Ejemplo  (p. 12). Demostrar que
     \<forall>x. P x \<turnstile> \<exists>x. P x
+
     ∀x. P x ⊢ ∃x. P x
 
*}
 
*}
  
 
-- "La demostración detallada es"
 
-- "La demostración detallada es"
 
lemma ejemplo_3a:
 
lemma ejemplo_3a:
   assumes "\<forall>x. P x"
+
   assumes "∀x. P x"
   shows "\<exists>x. P x"
+
   shows "∃x. P x"
 
proof -
 
proof -
 
   fix a
 
   fix a
 
   have "P a" using assms by (rule allE)
 
   have "P a" using assms by (rule allE)
   thus "\<exists>x. P x" by (rule exI)
+
   thus "∃x. P x" by (rule exI)
 
qed
 
qed
  
 
-- "La demostración estructurada es"
 
-- "La demostración estructurada es"
 
lemma ejemplo_3b:
 
lemma ejemplo_3b:
   assumes "\<forall>x. P x"
+
   assumes "∀x. P x"
   shows "\<exists>x. P x"
+
   shows "∃x. P x"
 
proof -
 
proof -
 
   fix a
 
   fix a
 
   have "P a" using assms ..
 
   have "P a" using assms ..
   thus "\<exists>x. P x" ..
+
   thus "∃x. P x" ..
 
qed
 
qed
  
 
-- "La demostración estructurada se puede simplificar"
 
-- "La demostración estructurada se puede simplificar"
 
lemma ejemplo_3c:
 
lemma ejemplo_3c:
   assumes "\<forall>x. P x"
+
   assumes "∀x. P x"
   shows "\<exists>x. P x"
+
   shows "∃x. P x"
 
proof (rule exI)
 
proof (rule exI)
 
   fix a
 
   fix a
Línea 154: Línea 154:
 
-- "La demostración estructurada se puede simplificar aún más"
 
-- "La demostración estructurada se puede simplificar aún más"
 
lemma ejemplo_3d:
 
lemma ejemplo_3d:
   assumes "\<forall>x. P x"
+
   assumes "∀x. P x"
   shows "\<exists>x. P x"
+
   shows "∃x. P x"
 
proof  
 
proof  
 
   fix a
 
   fix a
Línea 163: Línea 163:
 
-- "La demostración automática es"
 
-- "La demostración automática es"
 
lemma ejemplo_3e:
 
lemma ejemplo_3e:
   assumes "\<forall>x. P x"
+
   assumes "∀x. P x"
   shows "\<exists>x. P x"
+
   shows "∃x. P x"
 
using assms
 
using assms
 
by auto
 
by auto
Línea 170: Línea 170:
 
text {*  
 
text {*  
 
   Ejemplo 4 (p. 13). Demostrar
 
   Ejemplo 4 (p. 13). Demostrar
     \<forall>x. (P x \<longrightarrow> Q x), \<exists>x. P x \<turnstile> \<exists>x. Q x
+
     ∀x. (P x Q x), ∃x. P x ⊢ ∃x. Q x
 
*}
 
*}
  
 
-- "La demostración detallada es"
 
-- "La demostración detallada es"
 
lemma ejemplo_4a:
 
lemma ejemplo_4a:
   assumes 1: "\<forall>x. (P x \<longrightarrow> Q x)" and
+
   assumes 1: "∀x. (P x Q x)" and
           2: "\<exists>x. P x"
+
           2: "∃x. P x"
   shows "\<exists>x. Q x"
+
   shows "∃x. Q x"
 
proof -
 
proof -
 
   obtain a where 3: "P a" using 2 by (rule exE)
 
   obtain a where 3: "P a" using 2 by (rule exE)
   have 4: "P a \<longrightarrow> Q a" using 1 by (rule allE)
+
   have 4: "P a Q a" using 1 by (rule allE)
 
   have 5: "Q a" using 4 3 by (rule mp)
 
   have 5: "Q a" using 4 3 by (rule mp)
   thus 6: "\<exists>x. Q x" by (rule exI)
+
   thus 6: "∃x. Q x" by (rule exI)
 
qed
 
qed
  
 
-- "La demostración estructurada es"
 
-- "La demostración estructurada es"
 
lemma ejemplo_4b:
 
lemma ejemplo_4b:
   assumes "\<forall>x. (P x \<longrightarrow> Q x)"
+
   assumes "∀x. (P x Q x)"
           "\<exists>x. P x"
+
           "∃x. P x"
   shows "\<exists>x. Q x"
+
   shows "∃x. Q x"
 
proof -
 
proof -
 
   obtain a where "P a" using assms(2) ..
 
   obtain a where "P a" using assms(2) ..
   have "P a \<longrightarrow> Q a" using assms(1) ..
+
   have "P a Q a" using assms(1) ..
 
   hence "Q a" using `P a` ..
 
   hence "Q a" using `P a` ..
   thus "\<exists>x. Q x" ..
+
   thus "∃x. Q x" ..
 
qed
 
qed
  
 
-- "La demostración automática es"
 
-- "La demostración automática es"
 
lemma ejemplo_4c:
 
lemma ejemplo_4c:
   assumes "\<forall>x. (P x \<longrightarrow> Q x)"
+
   assumes "∀x. (P x Q x)"
           "\<exists>x. P x"
+
           "∃x. P x"
   shows "\<exists>x. Q x"
+
   shows "∃x. Q x"
 
using assms
 
using assms
 
by auto
 
by auto
Línea 209: Línea 209:
 
text {*  
 
text {*  
 
   Ejemplo 5.1 (p. 15). Demostrar
 
   Ejemplo 5.1 (p. 15). Demostrar
     \<not>\<forall>x. P x  \<turnstile> \<exists>x. \<not>(P x) *}
+
     ¬∀x. P x  ⊢ ∃x. ¬(P x) *}
  
 
-- "La demostración detallada es"
 
-- "La demostración detallada es"
 
lemma ejemplo_5_1a:
 
lemma ejemplo_5_1a:
   assumes "\<not>(\<forall>x. P(x))"
+
   assumes "¬(∀x. P(x))"
   shows  "\<exists>x. \<not>P(x)"
+
   shows  "∃x. ¬P(x)"
 
proof (rule ccontr)
 
proof (rule ccontr)
   assume "\<not>(\<exists>x. \<not>P(x))"
+
   assume "¬(∃x. ¬P(x))"
   have "\<forall>x. P(x)"
+
   have "∀x. P(x)"
 
   proof (rule allI)
 
   proof (rule allI)
 
     fix a
 
     fix a
 
     show "P(a)"
 
     show "P(a)"
 
     proof (rule ccontr)
 
     proof (rule ccontr)
       assume "\<not>P(a)"
+
       assume "¬P(a)"
       hence "\<exists>x. \<not>P(x)" by (rule exI)
+
       hence "∃x. ¬P(x)" by (rule exI)
       with `\<not>(\<exists>x. \<not>P(x))` show False by (rule notE)
+
       with `¬(∃x. ¬P(x))` show False by (rule notE)
 
     qed
 
     qed
 
   qed
 
   qed
Línea 232: Línea 232:
 
-- "La demostración estructurada es"
 
-- "La demostración estructurada es"
 
lemma ejemplo_5_1b:
 
lemma ejemplo_5_1b:
   assumes "\<not>(\<forall>x. P(x))"
+
   assumes "¬(∀x. P(x))"
   shows  "\<exists>x. \<not>P(x)"
+
   shows  "∃x. ¬P(x)"
 
proof (rule ccontr)
 
proof (rule ccontr)
   assume "\<not>(\<exists>x. \<not>P(x))"
+
   assume "¬(∃x. ¬P(x))"
   have "\<forall>x. P(x)"
+
   have "∀x. P(x)"
 
   proof  
 
   proof  
 
     fix a
 
     fix a
 
     show "P(a)"
 
     show "P(a)"
 
     proof (rule ccontr)
 
     proof (rule ccontr)
       assume "\<not>P(a)"
+
       assume "¬P(a)"
       hence "\<exists>x. \<not>P(x)" ..
+
       hence "∃x. ¬P(x)" ..
       with `\<not>(\<exists>x. \<not>P(x))` show False ..
+
       with `¬(∃x. ¬P(x))` show False ..
 
     qed
 
     qed
 
   qed
 
   qed
Línea 251: Línea 251:
 
-- "La demostración automática es"
 
-- "La demostración automática es"
 
lemma ejemplo_5_1c:
 
lemma ejemplo_5_1c:
   assumes "\<not>(\<forall>x. P(x))"
+
   assumes "¬(∀x. P(x))"
   shows  "\<exists>x. \<not>P(x)"
+
   shows  "∃x. ¬P(x)"
 
using assms
 
using assms
 
by auto
 
by auto
Línea 258: Línea 258:
 
text {*  
 
text {*  
 
   Ejemplo 5.2 (p. 16). Demostrar
 
   Ejemplo 5.2 (p. 16). Demostrar
     \<exists>x. \<not>(P x)  \<turnstile> \<not>\<forall>x. P x *}
+
     ∃x. ¬(P x)  ⊢ ¬∀x. P x *}
  
 
-- "La demostración detallada es"
 
-- "La demostración detallada es"
 
lemma ejemplo_5_2a:
 
lemma ejemplo_5_2a:
   assumes "\<exists>x. \<not>P(x)"
+
   assumes "∃x. ¬P(x)"
   shows  "\<not>(\<forall>x. P(x))"
+
   shows  "¬(∀x. P(x))"
 
proof (rule notI)
 
proof (rule notI)
   assume "\<forall>x. P(x)"
+
   assume "∀x. P(x)"
   obtain a where "\<not>P(a)" using assms by (rule exE)
+
   obtain a where "¬P(a)" using assms by (rule exE)
   have "P(a)" using `\<forall>x. P(x)` by (rule allE)
+
   have "P(a)" using `∀x. P(x)` by (rule allE)
   with `\<not>P(a)` show False by (rule notE)
+
   with `¬P(a)` show False by (rule notE)
 
qed
 
qed
  
 
-- "La demostración estructurada es"
 
-- "La demostración estructurada es"
 
lemma ejemplo_5_2b:
 
lemma ejemplo_5_2b:
   assumes "\<exists>x. \<not>P(x)"
+
   assumes "∃x. ¬P(x)"
   shows  "\<not>(\<forall>x. P(x))"
+
   shows  "¬(∀x. P(x))"
 
proof  
 
proof  
   assume "\<forall>x. P(x)"
+
   assume "∀x. P(x)"
   obtain a where "\<not>P(a)" using assms ..
+
   obtain a where "¬P(a)" using assms ..
   have "P(a)" using `\<forall>x. P(x)` ..
+
   have "P(a)" using `∀x. P(x)` ..
   with `\<not>P(a)` show False ..
+
   with `¬P(a)` show False ..
 
qed
 
qed
  
 
-- "La demostración automática es"
 
-- "La demostración automática es"
 
lemma ejemplo_5_2c:
 
lemma ejemplo_5_2c:
   assumes "\<exists>x. \<not>P(x)"
+
   assumes "∃x. ¬P(x)"
   shows  "\<not>(\<forall>x. P(x))"
+
   shows  "¬(∀x. P(x))"
 
using assms
 
using assms
 
by auto
 
by auto
Línea 291: Línea 291:
 
text {*  
 
text {*  
 
   Ejemplo 5.3 (p. 17). Demostrar
 
   Ejemplo 5.3 (p. 17). Demostrar
     \<turnstile> \<not>\<forall>x. P x  \<longleftrightarrow> \<exists>x. \<not>(P x) *}
+
     ⊢ ¬∀x. P x  ⟷ ∃x. ¬(P x) *}
  
 
-- "La demostración detallada es"
 
-- "La demostración detallada es"
 
lemma ejemplo_5_3a:
 
lemma ejemplo_5_3a:
   "(\<not>(\<forall>x. P(x))) \<longleftrightarrow> (\<exists>x. \<not>P(x))"
+
   "(¬(∀x. P(x))) (∃x. ¬P(x))"
 
proof (rule iffI)
 
proof (rule iffI)
   assume "\<not>(\<forall>x. P(x))"
+
   assume "¬(∀x. P(x))"
   thus "\<exists>x. \<not>P(x)" by (rule ejemplo_5_1a)
+
   thus "∃x. ¬P(x)" by (rule ejemplo_5_1a)
 
next
 
next
   assume "\<exists>x. \<not>P(x)"
+
   assume "∃x. ¬P(x)"
   thus "\<not>(\<forall>x. P(x))" by (rule ejemplo_5_2a)
+
   thus "¬(∀x. P(x))" by (rule ejemplo_5_2a)
 
qed
 
qed
  
 
-- "La demostración automática es"
 
-- "La demostración automática es"
 
lemma ejemplo_5_3b:
 
lemma ejemplo_5_3b:
   "(\<not>(\<forall>x. P(x))) \<longleftrightarrow> (\<exists>x. \<not>P(x))"
+
   "(¬(∀x. P(x))) (∃x. ¬P(x))"
 
by auto
 
by auto
  
 
text {*  
 
text {*  
 
   Ejemplo 6.1 (p. 18). Demostrar
 
   Ejemplo 6.1 (p. 18). Demostrar
     \<forall>x. P(x) \<and> Q(x) \<turnstile> (\<forall>x. P(x)) \<and> (\<forall>x. Q(x)) *}
+
     ∀x. P(x) Q(x) (∀x. P(x)) (∀x. Q(x)) *}
  
 
-- "La demostración detallada es"
 
-- "La demostración detallada es"
 
lemma ejemplo_6_1a:
 
lemma ejemplo_6_1a:
   assumes "\<forall>x. P(x) \<and> Q(x)"
+
   assumes "∀x. P(x) Q(x)"
   shows  "(\<forall>x. P(x)) \<and> (\<forall>x. Q(x))"
+
   shows  "(∀x. P(x)) (∀x. Q(x))"
 
proof (rule conjI)
 
proof (rule conjI)
   show "\<forall>x. P(x)"
+
   show "∀x. P(x)"
 
   proof (rule allI)
 
   proof (rule allI)
 
     fix a
 
     fix a
     have "P(a) \<and> Q(a)" using assms by (rule allE)
+
     have "P(a) Q(a)" using assms by (rule allE)
 
     thus "P(a)" by (rule conjunct1)
 
     thus "P(a)" by (rule conjunct1)
 
   qed
 
   qed
 
next
 
next
   show "\<forall>x. Q(x)"
+
   show "∀x. Q(x)"
 
   proof (rule allI)
 
   proof (rule allI)
 
     fix a
 
     fix a
     have "P(a) \<and> Q(a)" using assms by (rule allE)
+
     have "P(a) Q(a)" using assms by (rule allE)
 
     thus "Q(a)" by (rule conjunct2)
 
     thus "Q(a)" by (rule conjunct2)
 
   qed
 
   qed
Línea 335: Línea 335:
 
-- "La demostración estructurada es"
 
-- "La demostración estructurada es"
 
lemma ejemplo_6_1b:
 
lemma ejemplo_6_1b:
   assumes "\<forall>x. P(x) \<and> Q(x)"
+
   assumes "∀x. P(x) Q(x)"
   shows  "(\<forall>x. P(x)) \<and> (\<forall>x. Q(x))"
+
   shows  "(∀x. P(x)) (∀x. Q(x))"
 
proof  
 
proof  
   show "\<forall>x. P(x)"
+
   show "∀x. P(x)"
 
   proof  
 
   proof  
 
     fix a
 
     fix a
     have "P(a) \<and> Q(a)" using assms ..
+
     have "P(a) Q(a)" using assms ..
 
     thus "P(a)" ..
 
     thus "P(a)" ..
 
   qed
 
   qed
 
next
 
next
   show "\<forall>x. Q(x)"
+
   show "∀x. Q(x)"
 
   proof  
 
   proof  
 
     fix a
 
     fix a
     have "P(a) \<and> Q(a)" using assms ..
+
     have "P(a) Q(a)" using assms ..
 
     thus "Q(a)" ..
 
     thus "Q(a)" ..
 
   qed
 
   qed
Línea 355: Línea 355:
 
-- "La demostración automática es"
 
-- "La demostración automática es"
 
lemma ejemplo_6_1c:
 
lemma ejemplo_6_1c:
   assumes "\<forall>x. P(x) \<and> Q(x)"
+
   assumes "∀x. P(x) Q(x)"
   shows  "(\<forall>x. P(x)) \<and> (\<forall>x. Q(x))"
+
   shows  "(∀x. P(x)) (∀x. Q(x))"
 
using assms
 
using assms
 
by auto
 
by auto
Línea 362: Línea 362:
 
text {*  
 
text {*  
 
   Ejemplo 6.2 (p. 19). Demostrar
 
   Ejemplo 6.2 (p. 19). Demostrar
     (\<forall>x. P(x)) \<and> (\<forall>x. Q(x)) \<turnstile> \<forall>x. P(x) \<and> Q(x)  *}
+
     (∀x. P(x)) (∀x. Q(x)) ⊢ ∀x. P(x) Q(x)  *}
  
 
-- "La demostración detallada es"
 
-- "La demostración detallada es"
 
lemma ejemplo_6_2a:
 
lemma ejemplo_6_2a:
   assumes "(\<forall>x. P(x)) \<and> (\<forall>x. Q(x))"
+
   assumes "(∀x. P(x)) (∀x. Q(x))"
   shows  "\<forall>x. P(x) \<and> Q(x)"
+
   shows  "∀x. P(x) Q(x)"
 
proof (rule allI)
 
proof (rule allI)
 
   fix a
 
   fix a
   have "\<forall>x. P(x)" using assms by (rule conjunct1)
+
   have "∀x. P(x)" using assms by (rule conjunct1)
 
   hence "P(a)" by (rule allE)
 
   hence "P(a)" by (rule allE)
   have "\<forall>x. Q(x)" using assms by (rule conjunct2)
+
   have "∀x. Q(x)" using assms by (rule conjunct2)
 
   hence "Q(a)" by (rule allE)
 
   hence "Q(a)" by (rule allE)
   with `P(a)` show "P(a) \<and> Q(a)" by (rule conjI)
+
   with `P(a)` show "P(a) Q(a)" by (rule conjI)
 
qed
 
qed
  
 
-- "La demostración estructurada es"
 
-- "La demostración estructurada es"
 
lemma ejemplo_6_2b:
 
lemma ejemplo_6_2b:
   assumes "(\<forall>x. P(x)) \<and> (\<forall>x. Q(x))"
+
   assumes "(∀x. P(x)) (∀x. Q(x))"
   shows  "\<forall>x. P(x) \<and> Q(x)"
+
   shows  "∀x. P(x) Q(x)"
 
proof
 
proof
 
   fix a
 
   fix a
   have "\<forall>x. P(x)" using assms ..
+
   have "∀x. P(x)" using assms ..
 
   hence "P(a)" by (rule allE)
 
   hence "P(a)" by (rule allE)
   have "\<forall>x. Q(x)" using assms ..
+
   have "∀x. Q(x)" using assms ..
 
   hence "Q(a)" ..
 
   hence "Q(a)" ..
   with `P(a)` show "P(a) \<and> Q(a)" ..
+
   with `P(a)` show "P(a) Q(a)" ..
 
qed
 
qed
  
 
-- "La demostración automática es"
 
-- "La demostración automática es"
 
lemma ejemplo_6_2c:
 
lemma ejemplo_6_2c:
   assumes "(\<forall>x. P(x)) \<and> (\<forall>x. Q(x))"
+
   assumes "(∀x. P(x)) (∀x. Q(x))"
   shows  "\<forall>x. P(x) \<and> Q(x)"
+
   shows  "∀x. P(x) Q(x)"
 
using assms
 
using assms
 
by auto
 
by auto
Línea 399: Línea 399:
 
text {*  
 
text {*  
 
   Ejemplo 6.3 (p. 20). Demostrar
 
   Ejemplo 6.3 (p. 20). Demostrar
     \<turnstile> \<forall>x. P(x) \<and> Q(x) \<longleftrightarrow> (\<forall>x. P(x)) \<and> (\<forall>x. Q(x)) *}
+
     ⊢ ∀x. P(x) Q(x) (∀x. P(x)) (∀x. Q(x)) *}
  
 
-- "La demostración detallada es"
 
-- "La demostración detallada es"
 
lemma ejemplo_6_3a:
 
lemma ejemplo_6_3a:
   "(\<forall>x. P(x) \<and> Q(x)) \<longleftrightarrow> ((\<forall>x. P(x)) \<and> (\<forall>x. Q(x)))"
+
   "(∀x. P(x) Q(x)) ((∀x. P(x)) (∀x. Q(x)))"
 
proof (rule iffI)
 
proof (rule iffI)
   assume "\<forall>x. P(x) \<and> Q(x)"
+
   assume "∀x. P(x) Q(x)"
   thus "(\<forall>x. P(x)) \<and> (\<forall>x. Q(x))" by (rule ejemplo_6_1a)
+
   thus "(∀x. P(x)) (∀x. Q(x))" by (rule ejemplo_6_1a)
 
next
 
next
   assume "(\<forall>x. P(x)) \<and> (\<forall>x. Q(x))"
+
   assume "(∀x. P(x)) (∀x. Q(x))"
   thus "\<forall>x. P(x) \<and> Q(x)" by (rule ejemplo_6_2a)
+
   thus "∀x. P(x) Q(x)" by (rule ejemplo_6_2a)
 
qed
 
qed
  
 
text {*  
 
text {*  
 
   Ejemplo 7.1 (p. 21). Demostrar
 
   Ejemplo 7.1 (p. 21). Demostrar
     (\<exists>x. P(x)) \<or> (\<exists>x. Q(x)) \<turnstile> \<exists>x. P(x) \<or> Q(x)  *}
+
     (∃x. P(x)) (∃x. Q(x)) ⊢ ∃x. P(x) Q(x)  *}
  
 
-- "La demostración detallada es"
 
-- "La demostración detallada es"
 
lemma ejemplo_7_1a:
 
lemma ejemplo_7_1a:
   assumes "(\<exists>x. P(x)) \<or> (\<exists>x. Q(x))"
+
   assumes "(∃x. P(x)) (∃x. Q(x))"
   shows  "\<exists>x. P(x) \<or> Q(x)"
+
   shows  "∃x. P(x) Q(x)"
 
using assms
 
using assms
 
proof (rule disjE)
 
proof (rule disjE)
   assume "\<exists>x. P(x)"
+
   assume "∃x. P(x)"
 
   then obtain a where "P(a)" by (rule exE)
 
   then obtain a where "P(a)" by (rule exE)
   hence "P(a) \<or> Q(a)" by (rule disjI1)
+
   hence "P(a) Q(a)" by (rule disjI1)
   thus "\<exists>x. P(x) \<or> Q(x)" by (rule exI)
+
   thus "∃x. P(x) Q(x)" by (rule exI)
 
next
 
next
   assume "\<exists>x. Q(x)"
+
   assume "∃x. Q(x)"
 
   then obtain a where "Q(a)" by (rule exE)
 
   then obtain a where "Q(a)" by (rule exE)
   hence "P(a) \<or> Q(a)" by (rule disjI2)
+
   hence "P(a) Q(a)" by (rule disjI2)
   thus "\<exists>x. P(x) \<or> Q(x)" by (rule exI)
+
   thus "∃x. P(x) Q(x)" by (rule exI)
 
qed
 
qed
  
 
-- "La demostración estructurada es"
 
-- "La demostración estructurada es"
 
lemma ejemplo_7_1b:
 
lemma ejemplo_7_1b:
   assumes "(\<exists>x. P(x)) \<or> (\<exists>x. Q(x))"
+
   assumes "(∃x. P(x)) (∃x. Q(x))"
   shows  "\<exists>x. P(x) \<or> Q(x)"
+
   shows  "∃x. P(x) Q(x)"
 
using assms
 
using assms
 
proof
 
proof
   assume "\<exists>x. P(x)"
+
   assume "∃x. P(x)"
 
   then obtain a where "P(a)" ..
 
   then obtain a where "P(a)" ..
   hence "P(a) \<or> Q(a)" ..
+
   hence "P(a) Q(a)" ..
   thus "\<exists>x. P(x) \<or> Q(x)" ..
+
   thus "∃x. P(x) Q(x)" ..
 
next
 
next
   assume "\<exists>x. Q(x)"
+
   assume "∃x. Q(x)"
 
   then obtain a where "Q(a)" ..
 
   then obtain a where "Q(a)" ..
   hence "P(a) \<or> Q(a)" ..
+
   hence "P(a) Q(a)" ..
   thus "\<exists>x. P(x) \<or> Q(x)" ..
+
   thus "∃x. P(x) Q(x)" ..
 
qed
 
qed
  
 
-- "La demostración automática es"
 
-- "La demostración automática es"
 
lemma ejemplo_7_1c:
 
lemma ejemplo_7_1c:
   assumes "(\<exists>x. P(x)) \<or> (\<exists>x. Q(x))"
+
   assumes "(∃x. P(x)) (∃x. Q(x))"
   shows  "\<exists>x. P(x) \<or> Q(x)"
+
   shows  "∃x. P(x) Q(x)"
 
using assms
 
using assms
 
by auto
 
by auto
Línea 459: Línea 459:
 
text {*  
 
text {*  
 
   Ejemplo 7.2 (p. 22). Demostrar
 
   Ejemplo 7.2 (p. 22). Demostrar
     \<exists>x. P(x) \<or> Q(x) \<turnstile> (\<exists>x. P(x)) \<or> (\<exists>x. Q(x))  *}
+
     ∃x. P(x) Q(x) (∃x. P(x)) (∃x. Q(x))  *}
  
 
-- "La demostración detallada es"
 
-- "La demostración detallada es"
 
lemma ejemplo_7_2a:
 
lemma ejemplo_7_2a:
   assumes "\<exists>x. P(x) \<or> Q(x)"
+
   assumes "∃x. P(x) Q(x)"
   shows  "(\<exists>x. P(x)) \<or> (\<exists>x. Q(x))"
+
   shows  "(∃x. P(x)) (∃x. Q(x))"
 
proof -
 
proof -
   obtain a where "P(a) \<or> Q(a)" using assms by (rule exE)
+
   obtain a where "P(a) Q(a)" using assms by (rule exE)
   thus "(\<exists>x. P(x)) \<or> (\<exists>x. Q(x))"
+
   thus "(∃x. P(x)) (∃x. Q(x))"
 
   proof (rule disjE)
 
   proof (rule disjE)
 
     assume "P(a)"
 
     assume "P(a)"
     hence "\<exists>x. P(x)" by (rule exI)
+
     hence "∃x. P(x)" by (rule exI)
     thus "(\<exists>x. P(x)) \<or> (\<exists>x. Q(x))" by (rule disjI1)
+
     thus "(∃x. P(x)) (∃x. Q(x))" by (rule disjI1)
 
   next
 
   next
 
     assume "Q(a)"
 
     assume "Q(a)"
     hence "\<exists>x. Q(x)" by (rule exI)
+
     hence "∃x. Q(x)" by (rule exI)
     thus "(\<exists>x. P(x)) \<or> (\<exists>x. Q(x))" by (rule disjI2)
+
     thus "(∃x. P(x)) (∃x. Q(x))" by (rule disjI2)
 
   qed
 
   qed
 
qed
 
qed
Línea 481: Línea 481:
 
-- "La demostración estructurada es"
 
-- "La demostración estructurada es"
 
lemma ejercicio_7_2b:
 
lemma ejercicio_7_2b:
   assumes "\<exists>x. P(x) \<or> Q(x)"
+
   assumes "∃x. P(x) Q(x)"
   shows  "(\<exists>x. P(x)) \<or> (\<exists>x. Q(x))"
+
   shows  "(∃x. P(x)) (∃x. Q(x))"
 
proof -
 
proof -
   obtain a where "P(a) \<or> Q(a)" using assms ..
+
   obtain a where "P(a) Q(a)" using assms ..
   thus "(\<exists>x. P(x)) \<or> (\<exists>x. Q(x))"
+
   thus "(∃x. P(x)) (∃x. Q(x))"
 
   proof  
 
   proof  
 
     assume "P(a)"
 
     assume "P(a)"
     hence "\<exists>x. P(x)" ..
+
     hence "∃x. P(x)" ..
     thus "(\<exists>x. P(x)) \<or> (\<exists>x. Q(x))" ..
+
     thus "(∃x. P(x)) (∃x. Q(x))" ..
 
   next
 
   next
 
     assume "Q(a)"
 
     assume "Q(a)"
     hence "\<exists>x. Q(x)" ..
+
     hence "∃x. Q(x)" ..
     thus "(\<exists>x. P(x)) \<or> (\<exists>x. Q(x))" ..
+
     thus "(∃x. P(x)) (∃x. Q(x))" ..
 
   qed
 
   qed
 
qed
 
qed
Línea 499: Línea 499:
 
-- "La demostración automática es"
 
-- "La demostración automática es"
 
lemma ejercicio_7_2c:
 
lemma ejercicio_7_2c:
   assumes "\<exists>x. P(x) \<or> Q(x)"
+
   assumes "∃x. P(x) Q(x)"
   shows  "(\<exists>x. P(x)) \<or> (\<exists>x. Q(x))"
+
   shows  "(∃x. P(x)) (∃x. Q(x))"
 
using assms
 
using assms
 
by auto
 
by auto
Línea 506: Línea 506:
 
text {*  
 
text {*  
 
   Ejemplo 7.3 (p. 23). Demostrar
 
   Ejemplo 7.3 (p. 23). Demostrar
     \<turnstile> ((\<exists>x. P(x)) \<or> (\<exists>x. Q(x))) \<longleftrightarrow> (\<exists>x. P(x) \<or> Q(x))  *}
+
     ((∃x. P(x)) (∃x. Q(x))) (∃x. P(x) Q(x))  *}
  
 
-- "La demostración detallada es"
 
-- "La demostración detallada es"
 
lemma ejemplo_7_3a:
 
lemma ejemplo_7_3a:
   "((\<exists>x. P(x)) \<or> (\<exists>x. Q(x))) \<longleftrightarrow> (\<exists>x. P(x) \<or> Q(x))"
+
   "((∃x. P(x)) (∃x. Q(x))) (∃x. P(x) Q(x))"
 
proof (rule iffI)
 
proof (rule iffI)
   assume "(\<exists>x. P(x)) \<or> (\<exists>x. Q(x))"
+
   assume "(∃x. P(x)) (∃x. Q(x))"
   thus "\<exists>x. P(x) \<or> Q(x)" by (rule ejemplo_7_1a)
+
   thus "∃x. P(x) Q(x)" by (rule ejemplo_7_1a)
 
next
 
next
   assume "\<exists>x. P(x) \<or> Q(x)"
+
   assume "∃x. P(x) Q(x)"
   thus "(\<exists>x. P(x)) \<or> (\<exists>x. Q(x))" by (rule ejemplo_7_2a)
+
   thus "(∃x. P(x)) (∃x. Q(x))" by (rule ejemplo_7_2a)
 
qed
 
qed
  
 
-- "La demostración automática es"
 
-- "La demostración automática es"
 
lemma ejemplo_7_3b:
 
lemma ejemplo_7_3b:
   "((\<exists>x. P(x)) \<or> (\<exists>x. Q(x))) \<longleftrightarrow> (\<exists>x. P(x) \<or> Q(x))"
+
   "((∃x. P(x)) (∃x. Q(x))) (∃x. P(x) Q(x))"
 
using assms
 
using assms
 
by auto
 
by auto
Línea 527: Línea 527:
 
text {*  
 
text {*  
 
   Ejemplo 8.1 (p. 24). Demostrar
 
   Ejemplo 8.1 (p. 24). Demostrar
     \<exists>x y. P(x,y) \<turnstile> \<exists>y x. P(x,y)  *}
+
     ∃x y. P(x,y) ⊢ ∃y x. P(x,y)  *}
  
 
-- "La demostración detallada es"
 
-- "La demostración detallada es"
 
lemma ejemplo_8_1a:
 
lemma ejemplo_8_1a:
   assumes "\<exists>x y. P(x,y)"
+
   assumes "∃x y. P(x,y)"
   shows  "\<exists>y x. P(x,y)"
+
   shows  "∃y x. P(x,y)"
 
proof -
 
proof -
   obtain a where "\<exists>y. P(a,y)" using assms by (rule exE)
+
   obtain a where "∃y. P(a,y)" using assms by (rule exE)
 
   then obtain b where "P(a,b)" by (rule exE)
 
   then obtain b where "P(a,b)" by (rule exE)
   hence "\<exists>x. P(x,b)" by (rule exI)
+
   hence "∃x. P(x,b)" by (rule exI)
   thus "\<exists>y x. P(x,y)" by (rule exI)
+
   thus "∃y x. P(x,y)" by (rule exI)
 
qed
 
qed
  
 
-- "La demostración estructurada es"
 
-- "La demostración estructurada es"
 
lemma ejemplo_8_1b:
 
lemma ejemplo_8_1b:
   assumes "\<exists>x y. P(x,y)"
+
   assumes "∃x y. P(x,y)"
   shows  "\<exists>y x. P(x,y)"
+
   shows  "∃y x. P(x,y)"
 
proof -
 
proof -
   obtain a where "\<exists>y. P(a,y)" using assms ..
+
   obtain a where "∃y. P(a,y)" using assms ..
 
   then obtain b where "P(a,b)" ..
 
   then obtain b where "P(a,b)" ..
   hence "\<exists>x. P(x,b)" ..
+
   hence "∃x. P(x,b)" ..
   thus "\<exists>y x. P(x,y)" ..
+
   thus "∃y x. P(x,y)" ..
 
qed
 
qed
  
 
-- "La demostración automática es"
 
-- "La demostración automática es"
 
lemma ejemplo_8_1c:
 
lemma ejemplo_8_1c:
   assumes "\<exists>x y. P(x,y)"
+
   assumes "∃x y. P(x,y)"
   shows  "\<exists>y x. P(x,y)"
+
   shows  "∃y x. P(x,y)"
 
using assms
 
using assms
 
by auto
 
by auto
Línea 560: Línea 560:
 
text {*  
 
text {*  
 
   Ejemplo 8.2. Demostrar
 
   Ejemplo 8.2. Demostrar
     \<exists>y x. P(x,y) \<turnstile> \<exists>x y. P(x,y)  *}
+
     ∃y x. P(x,y) ⊢ ∃x y. P(x,y)  *}
  
 
-- "La demostración detallada es"
 
-- "La demostración detallada es"
 
lemma ejemplo_8_2a:
 
lemma ejemplo_8_2a:
   assumes "\<exists>y x. P(x,y)"
+
   assumes "∃y x. P(x,y)"
   shows  "\<exists>x y. P(x,y)"
+
   shows  "∃x y. P(x,y)"
 
proof -
 
proof -
   obtain b where "\<exists>x. P(x,b)" using assms by (rule exE)
+
   obtain b where "∃x. P(x,b)" using assms by (rule exE)
 
   then obtain a where "P(a,b)" by (rule exE)
 
   then obtain a where "P(a,b)" by (rule exE)
   hence "\<exists>y. P(a,y)" by (rule exI)
+
   hence "∃y. P(a,y)" by (rule exI)
   thus "\<exists>x y. P(x,y)" by (rule exI)
+
   thus "∃x y. P(x,y)" by (rule exI)
 
qed
 
qed
  
 
-- "La demostración estructurada es"
 
-- "La demostración estructurada es"
 
lemma ejemplo_8_2b:
 
lemma ejemplo_8_2b:
   assumes "\<exists>y x. P(x,y)"
+
   assumes "∃y x. P(x,y)"
   shows  "\<exists>x y. P(x,y)"
+
   shows  "∃x y. P(x,y)"
 
proof -
 
proof -
   obtain b where "\<exists>x. P(x,b)" using assms ..
+
   obtain b where "∃x. P(x,b)" using assms ..
 
   then obtain a where "P(a,b)" ..
 
   then obtain a where "P(a,b)" ..
   hence "\<exists>y. P(a,y)" ..
+
   hence "∃y. P(a,y)" ..
   thus "\<exists>x y. P(x,y)" ..
+
   thus "∃x y. P(x,y)" ..
 
qed
 
qed
  
 
-- "La demostración estructurada es"
 
-- "La demostración estructurada es"
 
lemma ejemplo_8_2c:
 
lemma ejemplo_8_2c:
   assumes "\<exists>y x. P(x,y)"
+
   assumes "∃y x. P(x,y)"
   shows  "\<exists>x y. P(x,y)"
+
   shows  "∃x y. P(x,y)"
 
using assms
 
using assms
 
by auto
 
by auto
Línea 593: Línea 593:
 
text {*  
 
text {*  
 
   Ejemplo 8.3 (p. 25). Demostrar
 
   Ejemplo 8.3 (p. 25). Demostrar
     \<turnstile> (\<exists>x y. P(x,y)) \<longleftrightarrow> (\<exists>y x. P(x,y))  *}
+
     (∃x y. P(x,y)) (∃y x. P(x,y))  *}
  
 
-- "La demostración detallada es"
 
-- "La demostración detallada es"
 
lemma ejemplo_8_3a:
 
lemma ejemplo_8_3a:
   "(\<exists>x y. P(x,y)) \<longleftrightarrow> (\<exists>y x. P(x,y))"
+
   "(∃x y. P(x,y)) (∃y x. P(x,y))"
 
proof (rule iffI)
 
proof (rule iffI)
   assume "\<exists>x y. P(x,y)"
+
   assume "∃x y. P(x,y)"
   thus "\<exists>y x. P(x,y)" by (rule ejemplo_8_1a)
+
   thus "∃y x. P(x,y)" by (rule ejemplo_8_1a)
 
next
 
next
   assume "\<exists>y x. P(x,y)"
+
   assume "∃y x. P(x,y)"
   thus "\<exists>x y. P(x,y)" by (rule ejemplo_8_2a)
+
   thus "∃x y. P(x,y)" by (rule ejemplo_8_2a)
 
qed
 
qed
  
 
-- "La demostración automática es"
 
-- "La demostración automática es"
 
lemma ejemplo_8_3b:
 
lemma ejemplo_8_3b:
   "(\<exists>x y. P(x,y)) \<longleftrightarrow> (\<exists>y x. P(x,y))"
+
   "(∃x y. P(x,y)) (∃y x. P(x,y))"
 
by auto
 
by auto
  
Línea 616: Línea 616:
 
   Las reglas básicas de la igualdad son:
 
   Las reglas básicas de la igualdad son:
 
   · refl:  t = t
 
   · refl:  t = t
   · subst: \<lbrakk>s = t; P s\<rbrakk> \<Longrightarrow> P t
+
   · subst: ⟦s = t; P s⟧ ⟹ P t
 
*}
 
*}
  
 
text {*  
 
text {*  
 
   Ejemplo 9 (p. 27). Demostrar
 
   Ejemplo 9 (p. 27). Demostrar
     x+1 = 1+x, x+1 > 1 \<longrightarrow> x+1 > 0 \<turnstile> 1+x > 1 \<longrightarrow> 1+x > 0
+
     x+1 = 1+x, x+1 > 1 x+1 > 0 1+x > 1 1+x > 0
 
*}
 
*}
  
Línea 627: Línea 627:
 
lemma ejemplo_9a:  
 
lemma ejemplo_9a:  
 
   assumes "x+1 = 1+x"  
 
   assumes "x+1 = 1+x"  
           "x+1 > 1 \<longrightarrow> x+1 > 0"
+
           "x+1 > 1 x+1 > 0"
   shows  "1+x > 1 \<longrightarrow> 1+x > 0"
+
   shows  "1+x > 1 1+x > 0"
 
proof -
 
proof -
   show "1+x > 1 \<longrightarrow> 1+x > 0" using assms by (rule subst)
+
   show "1+x > 1 1+x > 0" using assms by (rule subst)
 
qed
 
qed
  
Línea 636: Línea 636:
 
lemma ejemplo_9b:  
 
lemma ejemplo_9b:  
 
   assumes "x+1 = 1+x"  
 
   assumes "x+1 = 1+x"  
           "x+1 > 1 \<longrightarrow> x+1 > 0"
+
           "x+1 > 1 x+1 > 0"
   shows  "1+x > 1 \<longrightarrow> 1+x > 0"
+
   shows  "1+x > 1 1+x > 0"
 
using assms  
 
using assms  
 
by (rule subst)
 
by (rule subst)
Línea 644: Línea 644:
 
lemma ejemplo_9c:  
 
lemma ejemplo_9c:  
 
   assumes "x+1 = 1+x"  
 
   assumes "x+1 = 1+x"  
           "x+1 > 1 \<longrightarrow> x+1 > 0"
+
           "x+1 > 1 x+1 > 0"
   shows  "1+x > 1 \<longrightarrow> 1+x > 0"
+
   shows  "1+x > 1 1+x > 0"
 
using assms  
 
using assms  
 
by auto
 
by auto
Línea 651: Línea 651:
 
text {*  
 
text {*  
 
   Ejemplo 10 (p. 27). Demostrar
 
   Ejemplo 10 (p. 27). Demostrar
     x = y, y = z \<turnstile> x = z
+
     x = y, y = z x = z
 
*}
 
*}
  
Línea 681: Línea 681:
 
text {*  
 
text {*  
 
   Ejemplo 11 (p. 28). Demostrar
 
   Ejemplo 11 (p. 28). Demostrar
     s = t \<turnstile> t = s
+
     s = t t = s
 
*}
 
*}
  

Revisión actual del 17:48 1 abr 2013

header {* Tema 8: Deducción natural en lógica de primer orden *}

theory Tema8
imports Main 
begin

text {*
  El objetivo de este tema es presentar la deducción natural en 
  lógica de primer orden con Isabelle/HOL. La presentación se 
  basa en los ejemplos de tema 8 del curso LMF que se encuentra 
  en http://goo.gl/uJj8d (que a su vez se basa en el libro de 
  Huth y Ryan "Logic in Computer Science" http://goo.gl/qsVpY ). 

  La página al lado de cada ejemplo indica la página de las 
  transparencias de LMF donde se encuentra la demostración. *}

section {* Reglas del cuantificador universal *}

text {*
  Las reglas del cuantificador universal son
  · allE:    ⟦∀x. P x; P a ⟹ R⟧ ⟹ R
  · allI:    (⋀x. P x) ⟹ ∀x. P x
  *}

text {* 
  Ejemplo 1 (p. 10). Demostrar que
     P(c), ∀x. (P(x) ⟶ ¬Q(x)) ⊢ ¬Q(c)
*}

-- "La demostración detallada es"
lemma ejemplo_1a: 
  assumes 1: "P(c)" and
          2: "∀x. (P(x) ⟶ ¬Q(x))"
  shows "¬Q(c)"
proof -
  have 3: "P(c) ⟶ ¬Q(c)" using 2 by (rule allE)
  show 4: "¬Q(c)" using 3 1 by (rule mp)
qed

-- "La demostración estructurada es"
lemma ejemplo_1b: 
  assumes "P(c)"
          "∀x. (P(x) ⟶ ¬Q(x))"
  shows "¬Q(c)"
proof -
  have "P(c) ⟶ ¬Q(c)" using assms(2) ..
  thus "¬Q(c)" using assms(1) ..
qed

-- "La demostración automática es"
lemma ejemplo_1c: 
  assumes "P(c)"
          "∀x. (P(x) ⟶ ¬Q(x))"
  shows "¬Q(c)"
using assms
by auto

text {* 
  Ejemplo 2 (p. 11). Demostrar que
     ∀x. (P x ⟶ ¬(Q x)), ∀x. P x ⊢ ∀x. ¬(Q x)
*}

-- "La demostración detallada es"
lemma ejemplo_2a: 
  assumes 1: "∀x. (P x ⟶ ¬(Q x))" and
          2: "∀x. P x"
  shows "∀x. ¬(Q x)"
proof -
  { fix a
    have 3: "P a ⟶ ¬(Q a)" using 1 by (rule allE)
    have 4: "P a" using 2 by (rule allE)
    have 5: "¬(Q a)" using 3 4 by (rule mp) }
  thus "∀x. ¬(Q x)" by (rule allI)
qed

-- "La demostración detallada hacia atrás es"
lemma ejemplo_2b: 
  assumes 1: "∀x. (P x ⟶ ¬(Q x))" and
          2: "∀x. P x"
  shows "∀x. ¬(Q x)"
proof (rule allI)
  fix a
  have 3: "P a ⟶ ¬(Q a)" using 1 by (rule allE)
  have 4: "P a" using 2 by (rule allE)
  show 5: "¬(Q a)" using 3 4 by (rule mp) 
qed

-- "La demostración estructurada es"
lemma ejemplo_2c: 
  assumes "∀x. (P x ⟶ ¬(Q x))"
          "∀x. P x"
  shows "∀x. ¬(Q x)"
proof 
  fix a
  have "P a" using assms(2) ..
  have "P a ⟶ ¬(Q a)" using assms(1) ..
  thus "¬(Q a)" using `P a` ..
qed

-- "La demostración automática es"
lemma ejemplo_2d: 
  assumes "∀x. (P x ⟶ ¬(Q x))"
          "∀x. P x"
  shows   "∀x. ¬(Q x)"
using assms
by auto

section {* Reglas del cuantificador existencial *}

text {*
  Las reglas del cuantificador existencial son
  · exI:     P a ⟹ ∃x. P x
  · exE:     ⟦∃x. P x; ⋀x. P x ⟹ Q⟧ ⟹ Q

  En la regla exE la nueva variable se introduce mediante la declaración 
  "obtain ... where ... by (rule exE)" 
  *}

text {* 
  Ejemplo  (p. 12). Demostrar que
     ∀x. P x ⊢ ∃x. P x
*}

-- "La demostración detallada es"
lemma ejemplo_3a:
  assumes "∀x. P x"
  shows "∃x. P x"
proof -
  fix a
  have "P a" using assms by (rule allE)
  thus "∃x. P x" by (rule exI)
qed

-- "La demostración estructurada es"
lemma ejemplo_3b:
  assumes "∀x. P x"
  shows "∃x. P x"
proof -
  fix a
  have "P a" using assms ..
  thus "∃x. P x" ..
qed

-- "La demostración estructurada se puede simplificar"
lemma ejemplo_3c:
  assumes "∀x. P x"
  shows "∃x. P x"
proof (rule exI)
  fix a
  show "P a" using assms ..
qed

-- "La demostración estructurada se puede simplificar aún más"
lemma ejemplo_3d:
  assumes "∀x. P x"
  shows "∃x. P x"
proof 
  fix a
  show "P a" using assms ..
qed

-- "La demostración automática es"
lemma ejemplo_3e:
  assumes "∀x. P x"
  shows "∃x. P x"
using assms
by auto

text {* 
  Ejemplo 4 (p. 13). Demostrar
     ∀x. (P x ⟶ Q x), ∃x. P x ⊢ ∃x. Q x
*}

-- "La demostración detallada es"
lemma ejemplo_4a:
  assumes 1: "∀x. (P x ⟶ Q x)" and
          2: "∃x. P x"
  shows "∃x. Q x"
proof -
  obtain a where 3: "P a" using 2 by (rule exE)
  have 4: "P a ⟶ Q a" using 1 by (rule allE)
  have 5: "Q a" using 4 3 by (rule mp)
  thus 6: "∃x. Q x" by (rule exI)
qed

-- "La demostración estructurada es"
lemma ejemplo_4b:
  assumes "∀x. (P x ⟶ Q x)"
          "∃x. P x"
  shows "∃x. Q x"
proof -
  obtain a where "P a" using assms(2) ..
  have "P a ⟶ Q a" using assms(1) ..
  hence "Q a" using `P a` ..
  thus "∃x. Q x" ..
qed

-- "La demostración automática es"
lemma ejemplo_4c:
  assumes "∀x. (P x ⟶ Q x)"
          "∃x. P x"
  shows "∃x. Q x"
using assms
by auto

section {* Demostración de equivalencias *}

text {* 
  Ejemplo 5.1 (p. 15). Demostrar
     ¬∀x. P x  ⊢ ∃x. ¬(P x) *}

-- "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)"
      hence "∃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

-- "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)"
      hence "∃x. ¬P(x)" ..
      with `¬(∃x. ¬P(x))` show False ..
    qed
  qed
  with assms show False ..
qed

-- "La demostración automática es"
lemma ejemplo_5_1c:
  assumes "¬(∀x. P(x))"
  shows   "∃x. ¬P(x)"
using assms
by auto

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))"
  thus "∃x. ¬P(x)" by (rule ejemplo_5_1a)
next
  assume "∃x. ¬P(x)"
  thus "¬(∀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)
    thus "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)
    thus "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 ..
    thus "P(a)" ..
  qed
next
  show "∀x. Q(x)"
  proof 
    fix a
    have "P(a) ∧ Q(a)" using assms ..
    thus "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)
  hence "P(a)" by (rule allE)
  have "∀x. Q(x)" using assms by (rule conjunct2)
  hence "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 ..
  hence "P(a)" by (rule allE)
  have "∀x. Q(x)" using assms ..
  hence "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 auto

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)"
  thus "(∀x. P(x)) ∧ (∀x. Q(x))" by (rule ejemplo_6_1a)
next
  assume "(∀x. P(x)) ∧ (∀x. Q(x))"
  thus "∀x. P(x) ∧ Q(x)" by (rule ejemplo_6_2a)
qed

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)
  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

-- "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)" ..
  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

-- "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)
  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

-- "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 ..
  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 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))"
  thus "∃x. P(x) ∨ Q(x)" by (rule ejemplo_7_1a)
next
  assume "∃x. P(x) ∨ Q(x)"
  thus "(∃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))"
using assms
by auto

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)
  hence "∃x. P(x,b)" by (rule exI)
  thus "∃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)" ..
  hence "∃x. P(x,b)" ..
  thus "∃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)
  hence "∃y. P(a,y)" by (rule exI)
  thus "∃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)" ..
  hence "∃y. P(a,y)" ..
  thus "∃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)"
  thus "∃y x. P(x,y)" by (rule ejemplo_8_1a)
next
  assume "∃y x. P(x,y)"
  thus "∃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 ejemlo_11b:
  assumes "s = t"
  shows   "t = s"
using assms
by auto

end