Acciones

Diferencia entre revisiones de «Relación 4»

De Lógica matemática y fundamentos (2014-15)

m (Texto reemplazado: «isar» por «isabelle»)
 
(No se muestran 23 ediciones intermedias de 5 usuarios)
Línea 1: Línea 1:
<source lang ="isar">
+
<source lang ="isabelle">
 
header {* R4: Deducción natural de primer orden *}
 
header {* R4: Deducción natural de primer orden *}
  
Línea 99: Línea 99:
 
   assumes "∀x. P x"
 
   assumes "∀x. P x"
 
   shows  "∀y. P y"
 
   shows  "∀y. P y"
oops
+
proof
 +
{ fix a
 +
  show "P a" using assms by (rule allE)}
 +
qed
 +
 
 +
-María Dolores Mateo
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 109: Línea 114:
 
   assumes "∀x. P x ⟶ Q x"
 
   assumes "∀x. P x ⟶ Q x"
 
   shows  "(∀x. ¬(Q x)) ⟶ (∀x. ¬ (P x))"
 
   shows  "(∀x. ¬(Q x)) ⟶ (∀x. ¬ (P x))"
oops
+
proof
 +
assume "∀x. ¬(Q x)"
 +
  { fix a
 +
    have "P a ⟶ Q a" using assms by (rule allE)
 +
    have "¬ (Q a)" using `∀x. ¬(Q x)` by (rule allE)
 +
    have "¬(P a)" using `P a ⟶ Q a` `¬ (Q a)` by (rule mt)}
 +
thus "∀x. ¬ (P x)" by (rule allI)
 +
qed
 +
 
 +
-María Dolores Mateo
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 119: Línea 133:
 
   assumes "∀x. P x  ⟶ ¬(Q x)"
 
   assumes "∀x. P x  ⟶ ¬(Q x)"
 
   shows  "¬(∃x. P x ∧ Q x)"
 
   shows  "¬(∃x. P x ∧ Q x)"
oops
+
proof
 +
assume "∃x. P x ∧ Q x"
 +
  obtain a where "P a ∧ Q a" using `∃x. P x ∧ Q x` by (rule exE)
 +
  have "P a" using `P a ∧ Q a` by (rule conjE)
 +
  have "Q a" using `P a ∧ Q a` by (rule conjE)
 +
  have "P a  ⟶ ¬(Q a)" using assms by (rule allE)
 +
  have "¬(Q a)" using `P a  ⟶ ¬(Q a)` `P a` by (rule mp)
 +
show "False" using `¬(Q a)` `Q a` by (rule notE)
 +
qed
 +
 
 +
-María Dolores Mateo
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 129: Línea 153:
 
   assumes "∀x y. P x y"
 
   assumes "∀x y. P x y"
 
   shows  "∀u v. P u v"
 
   shows  "∀u v. P u v"
oops
+
 
 +
proof (rule allI)+
 +
fix a b
 +
have  "∀y. P a y" using assms by (rule allE)
 +
thus " P a b" by (rule allE)
 +
qed
 +
 
 +
--Jaime Alberto
 +
 
 +
 
 +
lemma ejercicio_6b:
 +
  assumes 1: "∀x y. P x y"
 +
  shows  "∀u v. P u v"
 +
proof -
 +
{fix u0
 +
{fix v0
 +
  have 2: "∀y. P u0 y" using 1  by (rule allE)
 +
  have 3: "P u0 v0" using 2 by (rule allE)}
 +
then have 4: "∀v. P u0 v" by (rule allI)}
 +
then show "∀u v. P u v" by (rule allI)
 +
qed
 +
 
 +
-- Rocio Rodriguez
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 139: Línea 185:
 
   assumes "∃x y. P x y"
 
   assumes "∃x y. P x y"
 
   shows  "∃u v. P u v"
 
   shows  "∃u v. P u v"
oops
+
 
 +
proof -
 +
obtain a where "∃y. P a y" using assms 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
 +
 
 +
--Jaime Alberto
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 149: Línea 203:
 
   assumes "∃x. ∀y. P x y"
 
   assumes "∃x. ∀y. P x y"
 
   shows  "∀y. ∃x. P x y"
 
   shows  "∀y. ∃x. P x y"
oops
+
 
 +
proof
 +
obtain a where "∀y. P a y" using assms by (rule exE)
 +
fix b
 +
have "P a b" using `∀y. P a y` by (rule allE)
 +
thus "∃x. P x b" by (rule exI)
 +
qed
 +
 
 +
--Jaime Alberto
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 159: Línea 221:
 
   assumes "∃x. P a ⟶ Q x"
 
   assumes "∃x. P a ⟶ Q x"
 
   shows  "P a ⟶ (∃x. Q x)"
 
   shows  "P a ⟶ (∃x. Q x)"
oops
+
 
 +
proof
 +
assume "P a"
 +
obtain b where "P a ⟶ Q b" using assms by (rule exE)
 +
have "Q b" using `P a ⟶ Q b` `P a` by (rule mp)
 +
thus "∃x. Q x" by (rule exI)
 +
qed
 +
 
 +
--Jaime Alberto
  
  
Línea 182: Línea 252:
 
   assumes "(∃x. P x) ⟶ Q a"
 
   assumes "(∃x. P x) ⟶ Q a"
 
   shows  "∀x. P x ⟶ Q a"
 
   shows  "∀x. P x ⟶ Q a"
oops
+
 
 +
proof
 +
fix b
 +
show "P b ⟶ Q a" 
 +
proof
 +
assume "P b"
 +
hence "∃x. P x" by (rule exI)
 +
show "Q a" using assms `∃x. P x` by (rule mp)
 +
qed
 +
qed
 +
 
 +
-- Jaime Alberto
  
  
Línea 193: Línea 274:
 
   assumes "∀x. P x ⟶ Q a"
 
   assumes "∀x. P x ⟶ Q a"
 
   shows  "∃x. P x ⟶ Q a"
 
   shows  "∃x. P x ⟶ Q a"
oops
+
 
 +
proof -
 +
fix b
 +
have "P b ⟶ Q a" using assms by (rule allE)
 +
thus "∃x. P x ⟶ Q a" by (rule exI)
 +
qed
 +
 
 +
-- Jaime Alberto
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 203: Línea 291:
 
   assumes "(∀x. P x) ∨ (∀x. Q x)"
 
   assumes "(∀x. P x) ∨ (∀x. Q x)"
 
   shows  "∀x. P x ∨ Q x"
 
   shows  "∀x. P x ∨ Q x"
oops
+
 
 +
proof
 +
fix a
 +
show "P a ∨ Q a" using assms
 +
proof
 +
assume "∀x. P x"
 +
hence "P a" by (rule allE)
 +
thus "P a ∨ Q a" by (rule disjI1)
 +
next
 +
assume "∀x. Q x"
 +
hence "Q a" by (rule allE)
 +
thus "P a ∨ Q a" by (rule disjI2)
 +
qed
 +
qed
 +
 
 +
-- Jaime Alberto
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 213: Línea 316:
 
   assumes "∃x. P x ∧ Q x"
 
   assumes "∃x. P x ∧ Q x"
 
   shows  "(∃x. P x) ∧ (∃x. Q x)"
 
   shows  "(∃x. P x) ∧ (∃x. Q x)"
oops
+
 
 +
proof
 +
obtain a where "P a ∧ Q a" using assms by (rule exE)
 +
hence "P a" by (rule conjunct1)
 +
thus "∃x. P x" by (rule exI)
 +
have "Q a" using  `P a ∧ Q a` by (rule conjunct2)
 +
thus "∃x. Q x" by (rule exI)
 +
qed
 +
 
 +
-- Jaime Alberto
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 223: Línea 335:
 
   assumes "∀x y. P y ⟶ Q x"
 
   assumes "∀x y. P y ⟶ Q x"
 
   shows  "(∃y. P y) ⟶ (∀x. Q x)"
 
   shows  "(∃y. P y) ⟶ (∀x. Q x)"
oops
+
 
 +
proof
 +
assume "∃y. P y"
 +
then obtain b where "P b" by (rule exE)
 +
{fix a
 +
have "∀y. P y ⟶ Q a" using assms by (rule allE)
 +
hence "P b ⟶ Q a" by (rule allE)
 +
have "Q a" using `P b ⟶ Q a` `P b` by (rule mp)}
 +
thus "∀x. Q x" by (rule allI)
 +
qed
 +
 
 +
-- Jaime Alberto
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 231: Línea 354:
  
 
lemma ejercicio_16a:  
 
lemma ejercicio_16a:  
   assumes "¬(∀x. ¬(P x))"
+
   assumes 1:"¬(∀x. ¬(P x))"
 
   shows  "∃x. P x"
 
   shows  "∃x. P x"
oops
+
 
 +
proof-
 +
fix x0
 +
{assume 2: "¬(∃x. P x)"
 +
{fix x1
 +
  {assume 3: "P x1"
 +
  have 4: "∃x. P x" using 3 by (rule exI)
 +
  have 5: "False" using 2 4 by (rule notE)}
 +
then have 6: "¬ P x1" by (rule notI)}
 +
then have 7: "∀x. ¬ P x" by (rule allI)
 +
have 8: "False" using 1 7 by (rule notE)}
 +
then show "∃x. P x" by (rule ccontr)
 +
qed
 +
 
 +
-- Rocio Rodriguez
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 243: Línea 380:
 
   assumes "∀x. ¬(P x)"
 
   assumes "∀x. ¬(P x)"
 
   shows  "¬(∃x. P x)"
 
   shows  "¬(∃x. P x)"
oops
+
 
 +
proof
 +
assume "∃x. P x"
 +
then obtain a where "P a" by (rule exE)
 +
have " ¬ (P a)" using assms by (rule allE)
 +
show False using `¬(P a)` `P a` by (rule notE)
 +
qed
 +
 
 +
--Jaime Alberto
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 253: Línea 398:
 
   assumes "∃x. P x"
 
   assumes "∃x. P x"
 
   shows  "¬(∀x. ¬(P x))"
 
   shows  "¬(∀x. ¬(P x))"
oops
+
 
 +
proof
 +
assume "∀x. ¬(P x)"
 +
obtain a where "P a" using assms by (rule exE)
 +
have "¬(P a)" using `∀x. ¬(P x)`  by (rule allE)
 +
show False using `¬(P a)` `P a`by (rule notE)
 +
qed
 +
 
 +
-- Jaime Alberto
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 263: Línea 416:
 
   assumes "P a ⟶ (∀x. Q x)"
 
   assumes "P a ⟶ (∀x. Q x)"
 
   shows  "∀x. P a ⟶ Q x"
 
   shows  "∀x. P a ⟶ Q x"
oops
+
 
 +
proof
 +
fix b
 +
show "P a ⟶ Q b"
 +
proof
 +
assume "P a"
 +
have "∀x. Q x" using assms `P a` by (rule mp)
 +
thus "Q b" by (rule allE)
 +
qed
 +
qed
 +
 
 +
--Jaime Alberto
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 276: Línea 440:
 
           "∀x. ¬(R x x)"  
 
           "∀x. ¬(R x x)"  
 
   shows  "∀x y. R x y ⟶ ¬(R y x)"
 
   shows  "∀x y. R x y ⟶ ¬(R y x)"
oops
+
 
 +
proof (rule allI)+
 +
fix  a b
 +
show "R a b ⟶ ¬(R b a )"
 +
proof
 +
assume 1:"R a b"
 +
show"¬(R b a)"
 +
proof
 +
assume 2:"R b a"
 +
have 3:"R a b ∧ R b a" using 1 2..
 +
have  "∀y z. R a y ∧ R y z ⟶ R a z" using assms(1)..
 +
hence  "∀z. R a b ∧ R b z ⟶ R a z"..
 +
hence 4:"R a b ∧ R b a ⟶ R a a"..
 +
have 5:"R a a" using 4 3..
 +
have 6:" ¬(R a a)" using assms(2)..
 +
show False using 6 5..
 +
qed
 +
qed
 +
qed
 +
--Jaime Alberto
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 288: Línea 471:
 
           "∀x. R x ⟶ ¬(P x)"
 
           "∀x. R x ⟶ ¬(P x)"
 
   shows  "∃x. ¬(R x)"  
 
   shows  "∃x. ¬(R x)"  
oops
+
 
 +
proof-
 +
obtain a where "¬(Q a)" using assms(2) by (rule exE)
 +
have "P a ∨ Q a" using assms(1) by (rule allE)
 +
show "∃x. ¬(R x)" using `P a ∨ Q a`
 +
proof
 +
assume "P a"
 +
hence 1:"¬¬(P a)" by (rule notnotI)
 +
have 2:"R a ⟶ ¬(P a)" using assms(3) by (rule allE)
 +
have "¬(R a)" using 2 1 by (rule mt)
 +
thus "∃x. ¬(R x)" by (rule exI)
 +
next
 +
assume "Q a"
 +
have False using `¬(Q a)` `Q a` by (rule notE)
 +
thus "∃x. ¬(R x)" by (rule ccontr)
 +
qed
 +
qed
 +
 
 +
-Jaime Alberto
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 299: Línea 500:
 
           "¬(∃x. P x ∧ R x)"
 
           "¬(∃x. P x ∧ R x)"
 
   shows  "∀x. P x ⟶ Q x"
 
   shows  "∀x. P x ⟶ Q x"
oops
+
 
 +
proof
 +
fix a
 +
show "P a ⟶ Q a"
 +
proof
 +
assume 1:"P a"
 +
have 2:"P a ⟶ Q a ∨ R a" using assms(1) by (rule allE)
 +
have 3:"Q a ∨ R a" using  2 1 by (rule mp)
 +
show "Q a" using 3
 +
proof
 +
assume "Q a"
 +
next
 +
assume 4:"R a"
 +
have "P a ∧ R a" using 1 4 by (rule conjI)
 +
hence 5:"∃x. P x ∧ R x" by (rule exI)
 +
have False using assms(2) 5 by (rule notE)
 +
thus "Q a" by (rule ccontr)
 +
qed
 +
qed
 +
qed
 +
 
 +
--Jaime Alberto
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 309: Línea 531:
 
   assumes "∃x y. R x y ∨ R y x"
 
   assumes "∃x y. R x y ∨ R y x"
 
   shows  "∃x y. R x y"
 
   shows  "∃x y. R x y"
oops
+
 
 +
proof -
 +
obtain a where "∃y. R a y ∨ R y a " using assms by (rule exE)
 +
then obtain b where 1:"R a b ∨ R b a" by (rule exE)
 +
show "∃x y. R x y" using 1
 +
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
 +
 
 +
--Jaime Alberto
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 318: Línea 556:
 
lemma ejercicio_24a:  
 
lemma ejercicio_24a:  
 
   "(∃x. ∀y. P x y) ⟶ (∀y. ∃x. P x y)"
 
   "(∃x. ∀y. P x y) ⟶ (∀y. ∃x. P x y)"
oops
+
 
 +
proof
 +
assume "∃x. ∀y. P x y"
 +
then obtain a where 1:"∀y. P a y" by (rule exE)
 +
{fix b
 +
have "P a b" using 1 by (rule allE)
 +
hence "∃x. P x b" by (rule exI)}
 +
thus "∀y. ∃x. P x y" by (rule allI)
 +
qed
 +
 
 +
-- Jaime Alberto
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 327: Línea 575:
 
lemma ejercicio_25a:  
 
lemma ejercicio_25a:  
 
   "(∀x. P x ⟶ Q) ⟷ ((∃x. P x) ⟶ Q)"
 
   "(∀x. P x ⟶ Q) ⟷ ((∃x. P x) ⟶ Q)"
oops
 
  
 +
proof
 +
assume 1:"∀x. P x ⟶ Q"
 +
show "(∃x. P x) ⟶ Q"
 +
proof
 +
assume "∃x. P x"
 +
then obtain a where 3:"P a" by (rule exE)
 +
have 4:"P a ⟶ Q"using 1 by (rule allE)
 +
show "Q" using 4 3 by (rule mp)
 +
qed
 +
next
 +
assume 5:"(∃x. P x) ⟶ Q"
 +
show "∀x. P x ⟶ Q"
 +
proof
 +
fix a
 +
show "P a⟶Q"
 +
proof
 +
assume "P a"
 +
hence 6:"∃x. P x" by (rule exI)
 +
show "Q" using 5 6 by (rule mp)
 +
qed
 +
qed
 +
qed
 +
 +
--Jaime Alberto
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
 
   Ejercicio 26. Demostrar
 
   Ejercicio 26. Demostrar
Línea 336: Línea 607:
 
lemma ejercicio_26a:  
 
lemma ejercicio_26a:  
 
   "((∀x. P x) ∧ (∀x. Q x)) ⟷ (∀x. P x ∧ Q x)"
 
   "((∀x. P x) ∧ (∀x. Q x)) ⟷ (∀x. P x ∧ Q x)"
oops
+
  "((∀x. P x) ∧ (∀x. Q x)) ⟷ (∀x. P x ∧ Q x)"
 +
proof
 +
  assume 0: "(∀x. P x) ∧ (∀x. Q x)"
 +
  have 1: "∀x. P x" using 0 by (rule conjunct1)
 +
  have 2: "∀x. Q x" using 0 by (rule conjunct2)
 +
  {fix a
 +
    have 3: "P a" using 1 by (rule allE)
 +
    have 4: "Q a" using 2 by (rule allE)
 +
    have 5: "P a ∧ Q a" using 3 4 by (rule conjI)}
 +
  thus "∀x. P x ∧ Q x" by (rule allI)
 +
next
 +
  assume 0: "∀x. P x ∧ Q x"
 +
  {fix a
 +
    have 1: "P a ∧ Q a" using 0 by (rule allE)
 +
    have 2: "P a" using 1 by (rule conjunct1)}
 +
  hence 3: "∀x. P x" by (rule allI)
 +
{fix a
 +
    have 4: "P a ∧ Q a" using 0 by (rule allE)
 +
    have 5: "Q a" using 4 by (rule conjunct2)}
 +
  hence 6: "∀x. Q x" by (rule allI)
 +
show "(∀x. P x) ∧ (∀x. Q x)" using 3 6 by (rule conjI)
 +
qed
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 345: Línea 637:
 
lemma ejercicio_27a:  
 
lemma ejercicio_27a:  
 
   "((∀x. P x) ∨ (∀x. Q x)) ⟷ (∀x. P x ∨ Q x)"
 
   "((∀x. P x) ∨ (∀x. Q x)) ⟷ (∀x. P x ∨ Q x)"
 +
proof
 +
  assume  "(∀x. P x) ∨ (∀x. Q x)"
 +
    moreover
 +
      {assume  "∀x. P x"
 +
        {fix a
 +
          have "P a" using `∀x. P x` by (rule allE)
 +
          have  "P a ∨ Q a" using `P a` by (rule disjI1)}
 +
        hence "∀x. P x ∨ Q x" by (rule allI)}
 +
      moreover
 +
        {assume  "∀x. Q x"
 +
          {fix a
 +
            have "Q a" using `∀x. Q x` by (rule allE)
 +
            have  "P a ∨ Q a" using `Q a` by (rule disjI2)}
 +
        hence "∀x. P x ∨ Q x" by (rule allI)}
 +
      ultimately show "∀x. P x ∨ Q x" by (rule disjE)
 +
next
 +
  assume  "∀x. P x ∨ Q x"
 
oops
 
oops
 +
 +
text{*
 +
Consideremos los números naturales, ℕ. Sea P = "Ser par" y Q = "Ser impar". Claramente
 +
∀x, P x ∨ Q x, pero es falso  (∀x P x)∨(∀x Q x), pues no todo número es par
 +
y no todo número es impar. Por tanto la propiedad, en general, es falsa. Es decir,
 +
((∀x. P x) ∨ (∀x. Q x)) ⟶ (∀x. P x ∨ Q x) pero en general
 +
(∀x. P x ∨ Q x) no implica ((∀x. P x) ∨ (∀x. Q x))
 +
*}
  
  
Línea 355: Línea 672:
 
lemma ejercicio_28a:  
 
lemma ejercicio_28a:  
 
   "((∃x. P x) ∨ (∃x. Q x)) ⟷ (∃x. P x ∨ Q x)"
 
   "((∃x. P x) ∨ (∃x. Q x)) ⟷ (∃x. P x ∨ Q x)"
oops
+
 
 +
proof
 +
assume 1:"(∃x. P x) ∨ (∃x. Q x)"
 +
show "∃x. P x ∨ Q x" using 1
 +
proof
 +
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 2:"P a ∨ Q a" by (rule exE)
 +
show "(∃x. P x) ∨ (∃x. Q x)" using 2
 +
proof
 +
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
 +
 
 +
-- Jaime Alberto
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 366: Línea 713:
 
   "(∀x. ∃y. P x y) ⟶ (∃y. ∀x. P x y)"
 
   "(∀x. ∃y. P x y) ⟶ (∃y. ∀x. P x y)"
 
oops
 
oops
 +
text{*
 +
Propiedad en general falsa. Sean los números naturales, y la propiedad P x y = "x + y es par". Claramente, para todo x, existe un y tal que P x y se verifica (baste tomar y = x). Pero, sea cual sea el y natural que tomemos, da igual el y que tomemos: no para todo elemento que le sumemos la suma será par.
 +
*}
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 371: Línea 721:
 
       (¬(∀x. P x)) ⟷ (∃x. ¬P x)
 
       (¬(∀x. P x)) ⟷ (∃x. ¬P x)
 
   ------------------------------------------------------------------ *}
 
   ------------------------------------------------------------------ *}
 +
 +
-- Francisco Javier Carmona
  
 
lemma ejercicio_30a:  
 
lemma ejercicio_30a:  
 
   "(¬(∀x. P x)) ⟷ (∃x. ¬P x)"
 
   "(¬(∀x. P x)) ⟷ (∃x. ¬P x)"
oops
+
proof (rule iffI)
 +
  assume 1: "¬(∀x. P x)"
 +
  show  "∃x. ¬P x"
 +
  proof (rule ccontr)
 +
  assume 2: "¬(∃x. ¬P x)"
 +
  show "False"
 +
  proof -
 +
  { fix a
 +
    { assume 3: "¬P a"
 +
      have 4: "∃x.¬ P x" using 3 by (rule exI)
 +
      have 5: "False" using 2 4 by (rule notE)}
 +
    hence 6: "P a" by (rule ccontr)}
 +
  hence 7: "∀x. P x" by (rule allI)
 +
  show 8: "False" using 1 7 by (rule notE)
 +
qed
 +
qed
 +
next
 +
  assume 9: "∃x. ¬P x"
 +
  show "¬(∀x. P x)"
 +
  proof -
 +
  {assume 10: "¬¬(∀x. P x)"
 +
    have 11: "∀x. P x" using 10 by (rule notnotD)
 +
    obtain a where 12: "¬P a" using 9 by (rule exE)
 +
    have 13: "P a" using 11 by (rule allE)
 +
    have 14: "False" using 12 13 by (rule notE)}
 +
  thus 15: "¬(∀x. P x)" by (rule ccontr)
 +
qed
 +
qed
  
 
section {* Ejercicios sobre igualdad *}
 
section {* Ejercicios sobre igualdad *}
Línea 382: Línea 761:
 
       P a ⟹ ∀x. x = a ⟶ P x
 
       P a ⟹ ∀x. x = a ⟶ P x
 
   ------------------------------------------------------------------ *}
 
   ------------------------------------------------------------------ *}
 +
 +
-- Francisco Javier Carmona
  
 
lemma ejercicio_31a:
 
lemma ejercicio_31a:
 
   assumes "P a"
 
   assumes "P a"
 
   shows  "∀x. x = a ⟶ P x"
 
   shows  "∀x. x = a ⟶ P x"
oops
+
proof (rule allI)
 +
  fix b
 +
  show "b = a ⟶ P b"
 +
  proof (rule impI)
 +
  assume 1: "b = a"
 +
  show "P b"
 +
  proof -
 +
  have 2: "a = b" using 1 by (rule sym)
 +
  show 3: "P b" using 2 assms(1) by (rule subst)
 +
qed
 +
qed
 +
qed
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 406: Línea 798:
 
     ⊢ P (f a) a (f a)
 
     ⊢ P (f a) a (f a)
 
   ------------------------------------------------------------------ *}
 
   ------------------------------------------------------------------ *}
 +
 +
-- Francisco Javier Carmona
  
 
lemma ejercicio_33a:
 
lemma ejercicio_33a:
Línea 411: Línea 805:
 
           "∀x y z. P x y z ⟶ P (f x) y (f z)"
 
           "∀x y z. P x y z ⟶ P (f x) y (f z)"
 
   shows  "P (f a) a (f a)"
 
   shows  "P (f a) a (f a)"
oops
+
proof -
 +
    have 1: "P a a a" using assms(1) by (rule allE)
 +
    have 2: "∀y z. P a y z ⟶ P (f a) y (f z)" using assms(2) by (rule allE)
 +
    have 3: "∀z. P a a z ⟶ P (f a) a (f z)" using 2 by (rule allE)
 +
    have 4: "P a a a ⟶ P (f a) a (f a)" using 3 by (rule allE)
 +
    show 5: "P (f a) a (f a)" using 4 1 by (rule mp)
 +
qed
 +
 
 +
 
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 419: Línea 821:
 
     ⊢ ∃z. P (f a) z (f (f a))
 
     ⊢ ∃z. P (f a) z (f (f a))
 
   ------------------------------------------------------------------ *}
 
   ------------------------------------------------------------------ *}
 +
 +
-- Francisco Javier Carmona
  
 
lemma ejercicio_34a:
 
lemma ejercicio_34a:
Línea 424: Línea 828:
 
           "∀x y z. P x y z ⟶ P (f x) y (f z)"
 
           "∀x y z. P x y z ⟶ P (f x) y (f z)"
 
   shows  "∃z. P (f a) z (f (f a))"
 
   shows  "∃z. P (f a) z (f (f a))"
oops
+
proof -
 +
  have 1: "P a (f a) (f a)" using assms(1) by (rule allE)
 +
  have 2: "∀y z. P a y z ⟶ P (f a) y (f z)" using assms(2) by (rule allE)
 +
  have 3: "∀z. P a (f a) z ⟶ P (f a) (f a) (f z)" using 2 by (rule allE)
 +
  have 4: "P a (f a) (f a) ⟶ P (f a) (f a) (f (f a))" using 3 by (rule allE)
 +
  have 5: "P (f a) (f a) (f (f a))" using 4 1 by (rule mp)
 +
  show 6: "∃z. P (f a) z (f (f a))" using 5 by (rule exI)
 +
qed
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 432: Línea 843:
 
     ⊢ ∃z. Qa z ∧ Q z (s (s a))
 
     ⊢ ∃z. Qa z ∧ Q z (s (s a))
 
   ------------------------------------------------------------------ *}
 
   ------------------------------------------------------------------ *}
 +
 +
-- Francisco Javier Carmona
  
 
lemma ejercicio_35a:
 
lemma ejercicio_35a:
Línea 437: Línea 850:
 
           "∀x y. Q x y ⟶ Q (s x) (s y)"  
 
           "∀x y. Q x y ⟶ Q (s x) (s y)"  
 
   shows  "∃z. Q a z ∧ Q z (s (s a))"
 
   shows  "∃z. Q a z ∧ Q z (s (s a))"
oops
+
proof -
 +
    have 1: "Q a (s a)" using assms(1) by (rule allE)
 +
    have 2: "∀y. Q a y ⟶ Q (s a) (s y)" using assms(2) by (rule allE)
 +
    have 3: "Q a (s a) ⟶ Q (s a) (s (s a))" using 2 by (rule allE)
 +
    have 4: "Q (s a) (s (s a))" using 3 1 by (rule mp)
 +
    have 5: "Q a (s a) ∧ Q (s a) (s (s a))" using 1 4 by (rule conjI)
 +
    show 6: "∃z. Q a z ∧ Q z (s (s a))" using 5 by (rule exI)
 +
qed
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 443: Línea 863:
 
     {x = f x, odd (f x)} ⊢ odd x
 
     {x = f x, odd (f x)} ⊢ odd x
 
   ------------------------------------------------------------------ *}
 
   ------------------------------------------------------------------ *}
 +
 +
-- Francisco Javier Carmona
  
 
lemma ejercicio_36a:
 
lemma ejercicio_36a:
Línea 448: Línea 870:
 
           "odd (f x)"
 
           "odd (f x)"
 
   shows "odd x"
 
   shows "odd x"
oops
+
proof -
 +
  show "odd x" using assms(1) assms(2) by (rule ssubst)
 +
qed
  
 
text {* ---------------------------------------------------------------  
 
text {* ---------------------------------------------------------------  
Línea 454: Línea 878:
 
     {x = f x, triple (f x) (f x) x} ⊢ triple x x x
 
     {x = f x, triple (f x) (f x) x} ⊢ triple x x x
 
   ------------------------------------------------------------------ *}
 
   ------------------------------------------------------------------ *}
 +
 +
-- Francisco Javier Carmona
  
 
lemma ejercicio_37a:
 
lemma ejercicio_37a:
Línea 459: Línea 885:
 
           "triple (f x) (f x) x"
 
           "triple (f x) (f x) x"
 
   shows "triple x x x"
 
   shows "triple x x x"
oops
+
proof -
 
+
  show "triple x x x" using assms(1) assms(2) by (rule ssubst)
 +
qed
  
 
end
 
end

Revisión actual del 14:27 16 jul 2018

header {* R4: Deducción natural de primer orden *}

theory R4
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
  · excluded_middel:(¬P ∨ 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 y mt que demostramos a continuación.
  *}

lemma notnotI: "P ⟹ ¬¬ P"
by auto

lemma mt: "⟦F ⟶ G; ¬G⟧ ⟹ ¬F"
by auto

text {* --------------------------------------------------------------- 
  Ejercicio 1. Demostrar
       ∀x. P x ⟶ Q x ⊢ (∀x. P x) ⟶ (∀x. Q x)
  ------------------------------------------------------------------ *}

lemma ejercicio_1a: 
  assumes "∀x. P x ⟶ Q x"
  shows   "(∀x. P x) ⟶ (∀x. Q x)"
proof (rule impI)
assume "∀x. P x"
  { fix a
    have "P a ⟶ Q a" using assms by (rule allE)
    have "P a" using `∀x. P x` by (rule allE)
    have "Q a" using `P a ⟶ Q a` `P a` by (rule mp)}
thus "∀x. Q x" by (rule allI)
qed

-María Dolores Mateo

text {* --------------------------------------------------------------- 
  Ejercicio 2. Demostrar
       ∃x. ¬(P x) ⊢ ¬(∀x. P x)
  ------------------------------------------------------------------ *}

lemma ejercicio_2a: 
  assumes "∃x. ¬(P x)"
  shows   "¬(∀x. P x)"
proof 
assume "∀x. P x" 
  obtain a where "¬ (P a)" using assms by (rule exE)
  have "P a" using `∀x. P x` by (rule allE)
  show "False" using `¬ (P a)` `P a` by (rule notE)
qed

-María Dolores Mateo

text {* --------------------------------------------------------------- 
  Ejercicio 3. Demostrar
       ∀x. P x ⊢ ∀y. P y
  ------------------------------------------------------------------ *}

lemma ejercicio_3a: 
  assumes "∀x. P x"
  shows   "∀y. P y"
proof 
{ fix a
  show "P a" using assms by (rule allE)}
qed

-María Dolores Mateo

text {* --------------------------------------------------------------- 
  Ejercicio 4. Demostrar
       ∀x. P x ⟶ Q x ⊢ (∀x. ¬(Q x)) ⟶ (∀x. ¬ (P x))
  ------------------------------------------------------------------ *}

lemma ejercicio_4: 
  assumes "∀x. P x ⟶ Q x"
  shows   "(∀x. ¬(Q x)) ⟶ (∀x. ¬ (P x))"
proof 
assume "∀x. ¬(Q x)"
  { fix a
    have "P a ⟶ Q a" using assms by (rule allE)
    have "¬ (Q a)" using `∀x. ¬(Q x)` by (rule allE)
    have "¬(P a)" using `P a ⟶ Q a` `¬ (Q a)` by (rule mt)}
thus "∀x. ¬ (P x)" by (rule allI)
qed

-María Dolores Mateo

text {* --------------------------------------------------------------- 
  Ejercicio 5. Demostrar
       ∀x. P x  ⟶ ¬(Q x) ⊢ ¬(∃x. P x ∧ Q x)
  ------------------------------------------------------------------ *}

lemma ejercicio_5: 
  assumes "∀x. P x  ⟶ ¬(Q x)"
  shows   "¬(∃x. P x ∧ Q x)"
proof 
assume "∃x. P x ∧ Q x" 
  obtain a where "P a ∧ Q a" using `∃x. P x ∧ Q x` by (rule exE)
  have "P a" using `P a ∧ Q a` by (rule conjE)
  have "Q a" using `P a ∧ Q a` by (rule conjE)
  have "P a  ⟶ ¬(Q a)" using assms by (rule allE)
  have "¬(Q a)" using `P a  ⟶ ¬(Q a)` `P a` by (rule mp)
show "False" using `¬(Q a)` `Q a` by (rule notE)
qed

-María Dolores Mateo

text {* --------------------------------------------------------------- 
  Ejercicio 6. Demostrar
       ∀x y. P x y ⊢ ∀u v. P u v
  ------------------------------------------------------------------ *}

lemma ejercicio_6: 
  assumes "∀x y. P x y"
  shows   "∀u v. P u v"

proof (rule allI)+
fix a b 
have  "∀y. P a y" using assms by (rule allE)
thus " P a b" by (rule allE)
qed

--Jaime Alberto 


lemma ejercicio_6b: 
  assumes 1: "∀x y. P x y"
  shows   "∀u v. P u v"
proof -
{fix u0 
 {fix v0
  have 2: "∀y. P u0 y" using 1  by (rule allE)
  have 3: "P u0 v0" using 2 by (rule allE)}
 then have 4: "∀v. P u0 v" by (rule allI)}
then show "∀u v. P u v" by (rule allI)
qed

-- Rocio Rodriguez

text {* --------------------------------------------------------------- 
  Ejercicio 7. Demostrar
       ∃x y. P x y ⟹ ∃u v. P u v
  ------------------------------------------------------------------ *}

lemma ejercicio_7: 
  assumes "∃x y. P x y"
  shows   "∃u v. P u v"

proof -
obtain a where "∃y. P a y" using assms 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

--Jaime Alberto

text {* --------------------------------------------------------------- 
  Ejercicio 8. Demostrar
       ∃x. ∀y. P x y ⊢ ∀y. ∃x. P x y
  ------------------------------------------------------------------ *}

lemma ejercicio_8: 
  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)
fix b 
have "P a b" using `∀y. P a y` by (rule allE)
thus "∃x. P x b" by (rule exI)
qed

--Jaime Alberto

text {* --------------------------------------------------------------- 
  Ejercicio 9. Demostrar
       ∃x. P a ⟶ Q x ⊢ P a ⟶ (∃x. Q x)
  ------------------------------------------------------------------ *}

lemma ejercicio_9: 
  assumes "∃x. P a ⟶ Q x"
  shows   "P a ⟶ (∃x. Q x)"

proof
assume "P a"
obtain b where "P a ⟶ Q b" using assms by (rule exE)
have "Q b" using `P a ⟶ Q b` `P a` by (rule mp)
thus "∃x. Q x" by (rule exI)
qed

--Jaime Alberto


text {* --------------------------------------------------------------- 
  Ejercicio 10. Demostrar
       P a ⟶ (∃x. Q x) ⊢ ∃x. P a ⟶ Q x 
  ------------------------------------------------------------------ *}

lemma ejercicio_10a: 
  fixes P Q :: "'b ⇒ bool" 
  assumes "P a ⟶ (∃x. Q x)"
  shows   "∃x. P a ⟶ Q x"
oops


text {* --------------------------------------------------------------- 
  Ejercicio 11. Demostrar
       (∃x. P x) ⟶ Q a ⊢ ∀x. P x ⟶ Q a
  ------------------------------------------------------------------ *}

lemma ejercicio_11a: 
  assumes "(∃x. P x) ⟶ Q a"
  shows   "∀x. P x ⟶ Q a"

proof 
fix b
show "P b ⟶ Q a"  
proof
assume "P b"
hence "∃x. P x" by (rule exI)
show "Q a" using assms `∃x. P x` by (rule mp)
qed
qed

-- Jaime Alberto


text {* --------------------------------------------------------------- 
  Ejercicio 12. Demostrar
       ∀x. P x ⟶ Q a ⊢ ∃ x. P x ⟶ Q a
  ------------------------------------------------------------------ *}

lemma ejercicio_12a: 
  assumes "∀x. P x ⟶ Q a"
  shows   "∃x. P x ⟶ Q a"

proof -
fix b
have "P b ⟶ Q a" using assms by (rule allE)
thus "∃x. P x ⟶ Q a" by (rule exI)
qed

-- Jaime Alberto

text {* --------------------------------------------------------------- 
  Ejercicio 13. Demostrar
       (∀x. P x) ∨ (∀x. Q x) ⊢ ∀x. P x ∨ Q x
  ------------------------------------------------------------------ *}

lemma ejercicio_13a: 
  assumes "(∀x. P x) ∨ (∀x. Q x)"
  shows   "∀x. P x ∨ Q x"

proof 
fix a
show "P a ∨ Q a" using assms
proof
assume "∀x. P x"
hence "P a" by (rule allE)
thus "P a ∨ Q a" by (rule disjI1)
next
assume "∀x. Q x"
hence "Q a" by (rule allE)
thus "P a ∨ Q a" by (rule disjI2)
qed
qed

-- Jaime Alberto

text {* --------------------------------------------------------------- 
  Ejercicio 14. Demostrar
       ∃x. P x ∧ Q x ⊢ (∃x. P x) ∧ (∃x. Q x)
  ------------------------------------------------------------------ *}

lemma ejercicio_14a: 
  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)
hence "P a" by (rule conjunct1)
thus "∃x. P x" by (rule exI)
have "Q a" using  `P a ∧ Q a` by (rule conjunct2)
thus "∃x. Q x" by (rule exI)
qed

-- Jaime Alberto

text {* --------------------------------------------------------------- 
  Ejercicio 15. Demostrar
       ∀x y. P y ⟶ Q x ⊢ (∃y. P y) ⟶ (∀x. Q x)
  ------------------------------------------------------------------ *}

lemma ejercicio_15a: 
  assumes "∀x y. P y ⟶ Q x"
  shows   "(∃y. P y) ⟶ (∀x. Q x)"

proof
assume "∃y. P y"
then obtain b where "P b" by (rule exE)
{fix a 
have "∀y. P y ⟶ Q a" using assms by (rule allE)
hence "P b ⟶ Q a" by (rule allE)
have "Q a" using `P b ⟶ Q a` `P b` by (rule mp)}
thus "∀x. Q x" by (rule allI)
qed

-- Jaime Alberto

text {* --------------------------------------------------------------- 
  Ejercicio 16. Demostrar
       ¬(∀x. ¬(P x)) ⊢ ∃x. P x
  ------------------------------------------------------------------ *}

lemma ejercicio_16a: 
  assumes 1:"¬(∀x. ¬(P x))"
  shows   "∃x. P x"

proof-
fix x0
{assume 2: "¬(∃x. P x)" 
 {fix x1
  {assume 3: "P x1"
   have 4: "∃x. P x" using 3 by (rule exI)
   have 5: "False" using 2 4 by (rule notE)}
 then have 6: "¬ P x1" by (rule notI)}
then have 7: "∀x. ¬ P x" by (rule allI)
have 8: "False" using 1 7 by (rule notE)}
then show "∃x. P x" by (rule ccontr)
qed 

-- Rocio Rodriguez

text {* --------------------------------------------------------------- 
  Ejercicio 17. Demostrar
       ∀x. ¬(P x) ⊢ ¬(∃x. P x)
  ------------------------------------------------------------------ *}

lemma ejercicio_17a: 
  assumes "∀x. ¬(P x)"
  shows   "¬(∃x. P x)"

proof
assume "∃x. P x"
then obtain a where "P a" by (rule exE)
have " ¬ (P a)" using assms by (rule allE)
show False using `¬(P a)` `P a` by (rule notE)
qed

--Jaime Alberto

text {* --------------------------------------------------------------- 
  Ejercicio 18. Demostrar
       ∃x. P x ⊢ ¬(∀x. ¬(P x))
  ------------------------------------------------------------------ *}

lemma ejercicio_18a: 
  assumes "∃x. P x"
  shows   "¬(∀x. ¬(P x))"

proof 
assume "∀x. ¬(P x)"
obtain a where "P a" using assms by (rule exE)
have "¬(P a)" using `∀x. ¬(P x)`  by (rule allE)
show False using `¬(P a)` `P a`by (rule notE)
qed

-- Jaime Alberto

text {* --------------------------------------------------------------- 
  Ejercicio 19. Demostrar
       P a ⟶ (∀x. Q x) ⊢ ∀x. P a ⟶ Q x
  ------------------------------------------------------------------ *}

lemma ejercicio_19a: 
  assumes "P a ⟶ (∀x. Q x)"
  shows   "∀x. P a ⟶ Q x"

proof 
fix b
show "P a ⟶ Q b"
proof 
assume "P a" 
have "∀x. Q x" using assms `P a` by (rule mp)
thus "Q b" by (rule allE)
qed
qed

--Jaime Alberto

text {* --------------------------------------------------------------- 
  Ejercicio 20. Demostrar
       {∀x y z. R x y ∧ R y z ⟶ R x z, 
        ∀x. ¬(R x x)}
       ⊢ ∀x y. R x y ⟶ ¬(R y x)
  ------------------------------------------------------------------ *}

lemma ejercicio_20a: 
  assumes "∀x y z. R x y ∧ R y z ⟶ R x z"
          "∀x. ¬(R x x)" 
  shows   "∀x y. R x y ⟶ ¬(R y x)"

proof (rule allI)+
fix  a b 
show "R a b ⟶ ¬(R b a )" 
proof 
assume 1:"R a b"
show"¬(R b a)"
proof
assume 2:"R b a" 
have 3:"R a b ∧ R b a" using 1 2..
have  "∀y z. R a y ∧ R y z ⟶ R a z" using assms(1)..
hence  "∀z. R a b ∧ R b z ⟶ R a z"..
hence 4:"R a b ∧ R b a ⟶ R a a"..
have 5:"R a a" using 4 3..
have 6:" ¬(R a a)" using assms(2)..
show False using 6 5..
qed
qed
qed
--Jaime Alberto

text {* --------------------------------------------------------------- 
  Ejercicio 21. Demostrar
     {∀x. P x ∨ Q x, ∃x. ¬(Q x), ∀x. R x ⟶ ¬(P x)} ⊢ ∃x. ¬(R x)
  ------------------------------------------------------------------ *}

lemma ejercicio_21a:
  assumes "∀x. P x ∨ Q x" 
          "∃x. ¬(Q x)" 
          "∀x. R x ⟶ ¬(P x)"
  shows   "∃x. ¬(R x)" 

proof-
obtain a where "¬(Q a)" using assms(2) by (rule exE)
have "P a ∨ Q a" using assms(1) by (rule allE)
show "∃x. ¬(R x)" using `P a ∨ Q a`
proof
assume "P a"
hence 1:"¬¬(P a)" by (rule notnotI)
have 2:"R a ⟶ ¬(P a)" using assms(3) by (rule allE)
have "¬(R a)" using 2 1 by (rule mt)
thus "∃x. ¬(R x)" by (rule exI)
next
assume "Q a"
have False using `¬(Q a)` `Q a` by (rule notE) 
thus "∃x. ¬(R x)" by (rule ccontr)
qed
qed

-Jaime Alberto

text {* --------------------------------------------------------------- 
  Ejercicio 22. Demostrar
     {∀x. P x ⟶ Q x ∨ R x, ¬(∃x. P x ∧ R x)} ⊢ ∀x. P x ⟶ Q x
  ------------------------------------------------------------------ *}

lemma ejercicio_22a:
  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 1:"P a"
have 2:"P a ⟶ Q a ∨ R a" using assms(1) by (rule allE)
have 3:"Q a ∨ R a" using  2 1 by (rule mp)
show "Q a" using 3 
proof
assume "Q a"
next 
assume 4:"R a"
have "P a ∧ R a" using 1 4 by (rule conjI)
hence 5:"∃x. P x ∧ R x" by (rule exI)
have False using assms(2) 5 by (rule notE)
thus "Q a" by (rule ccontr)
qed
qed
qed

--Jaime Alberto

text {* --------------------------------------------------------------- 
  Ejercicio 23. Demostrar
     ∃x y. R x y ∨ R y x ⊢ ∃x y. R x y
  ------------------------------------------------------------------ *}

lemma ejercicio_23a:
  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 by (rule exE)
then obtain b where 1:"R a b ∨ R b a" by (rule exE)
show "∃x y. R x y" using 1
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

--Jaime Alberto 

text {* --------------------------------------------------------------- 
  Ejercicio 24. Demostrar
       (∃x. ∀y. P x y) ⟶ (∀y. ∃x. P x y)
  ------------------------------------------------------------------ *}

lemma ejercicio_24a: 
  "(∃x. ∀y. P x y) ⟶ (∀y. ∃x. P x y)"

proof 
assume "∃x. ∀y. P x y"
then obtain a where 1:"∀y. P a y" by (rule exE)
{fix b 
have "P a b" using 1 by (rule allE)
hence "∃x. P x b" by (rule exI)}
thus "∀y. ∃x. P x y" by (rule allI)
qed

-- Jaime Alberto 

text {* --------------------------------------------------------------- 
  Ejercicio 25. Demostrar
       (∀x. P x ⟶ Q) ⟷ ((∃x. P x) ⟶ Q)
  ------------------------------------------------------------------ *}

lemma ejercicio_25a: 
  "(∀x. P x ⟶ Q) ⟷ ((∃x. P x) ⟶ Q)"

proof
assume 1:"∀x. P x ⟶ Q"
show "(∃x. P x) ⟶ Q"
proof
assume "∃x. P x" 
then obtain a where 3:"P a" by (rule exE)
have 4:"P a ⟶ Q"using 1 by (rule allE)
show "Q" using 4 3 by (rule mp)
qed
next 
assume 5:"(∃x. P x) ⟶ Q"
show "∀x. P x ⟶ Q"
proof
fix a
show "P a⟶Q"
proof 
assume "P a"
hence 6:"∃x. P x" by (rule exI)
show "Q" using 5 6 by (rule mp)
qed
qed
qed

--Jaime Alberto
text {* --------------------------------------------------------------- 
  Ejercicio 26. Demostrar
       ((∀x. P x) ∧ (∀x. Q x)) ⟷ (∀x. P x ∧ Q x)
  ------------------------------------------------------------------ *}

lemma ejercicio_26a: 
  "((∀x. P x) ∧ (∀x. Q x)) ⟷ (∀x. P x ∧ Q x)"
  "((∀x. P x) ∧ (∀x. Q x)) ⟷ (∀x. P x ∧ Q x)"
proof
  assume 0: "(∀x. P x) ∧ (∀x. Q x)"
  have 1: "∀x. P x" using 0 by (rule conjunct1)
  have 2: "∀x. Q x" using 0 by (rule conjunct2)
  {fix a
    have 3: "P a" using 1 by (rule allE)
    have 4: "Q a" using 2 by (rule allE)
    have 5: "P a ∧ Q a" using 3 4 by (rule conjI)}
  thus "∀x. P x ∧ Q x" by (rule allI)
next
  assume 0: "∀x. P x ∧ Q x"
  {fix a
    have 1: "P a ∧ Q a" using 0 by (rule allE)
    have 2: "P a" using 1 by (rule conjunct1)}
  hence 3: "∀x. P x" by (rule allI)
 {fix a
    have 4: "P a ∧ Q a" using 0 by (rule allE)
    have 5: "Q a" using 4 by (rule conjunct2)}
  hence 6: "∀x. Q x" by (rule allI)
show "(∀x. P x) ∧ (∀x. Q x)" using 3 6 by (rule conjI)
qed

text {* --------------------------------------------------------------- 
  Ejercicio 27. Demostrar o refutar
       ((∀x. P x) ∨ (∀x. Q x)) ⟷ (∀x. P x ∨ Q x)
  ------------------------------------------------------------------ *}

lemma ejercicio_27a: 
  "((∀x. P x) ∨ (∀x. Q x)) ⟷ (∀x. P x ∨ Q x)"
proof
  assume  "(∀x. P x) ∨ (∀x. Q x)"
    moreover
      {assume  "∀x. P x"
        {fix a
          have "P a" using `∀x. P x` by (rule allE)
          have  "P a ∨ Q a" using `P a` by (rule disjI1)}
        hence "∀x. P x ∨ Q x" by (rule allI)}
      moreover
        {assume  "∀x. Q x"
          {fix a
            have "Q a" using `∀x. Q x` by (rule allE)
            have  "P a ∨ Q a" using `Q a` by (rule disjI2)}
        hence "∀x. P x ∨ Q x" by (rule allI)}
      ultimately show "∀x. P x ∨ Q x" by (rule disjE)
next
  assume  "∀x. P x ∨ Q x"
oops

text{* 
Consideremos los números naturales, ℕ. Sea P = "Ser par" y Q = "Ser impar". Claramente 
∀x, P x ∨ Q x, pero es falso  (∀x P x)∨(∀x Q x), pues no todo número es par
 y no todo número es impar. Por tanto la propiedad, en general, es falsa. Es decir, 
((∀x. P x) ∨ (∀x. Q x)) ⟶ (∀x. P x ∨ Q x) pero en general
 (∀x. P x ∨ Q x) no implica ((∀x. P x) ∨ (∀x. Q x))
*}


text {* --------------------------------------------------------------- 
  Ejercicio 28. Demostrar o refutar
       ((∃x. P x) ∨ (∃x. Q x)) ⟷ (∃x. P x ∨ Q x)
  ------------------------------------------------------------------ *}

lemma ejercicio_28a: 
  "((∃x. P x) ∨ (∃x. Q x)) ⟷ (∃x. P x ∨ Q x)"

proof
assume 1:"(∃x. P x) ∨ (∃x. Q x)" 
show "∃x. P x ∨ Q x" using 1
proof
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 2:"P a ∨ Q a" by (rule exE)
show "(∃x. P x) ∨ (∃x. Q x)" using 2
proof
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

-- Jaime Alberto 

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)"
oops
text{*
Propiedad en general falsa. Sean los números naturales, y la propiedad P x y = "x + y es par". Claramente, para todo x, existe un y tal que P x y se verifica (baste tomar y = x). Pero, sea cual sea el y natural que tomemos, da igual el y que tomemos: no para todo elemento que le sumemos la suma será par. 
*}

text {* --------------------------------------------------------------- 
  Ejercicio 30. Demostrar o refutar
       (¬(∀x. P x)) ⟷ (∃x. ¬P x)
  ------------------------------------------------------------------ *}

-- Francisco Javier Carmona

lemma ejercicio_30a: 
  "(¬(∀x. P x)) ⟷ (∃x. ¬P x)"
proof (rule iffI)
   assume 1: "¬(∀x. P x)"
   show  "∃x. ¬P x"
   proof (rule ccontr)
   assume 2: "¬(∃x. ¬P x)"
   show "False"
   proof -
   { fix a
     { assume 3: "¬P a"
       have 4: "∃x.¬ P x" using 3 by (rule exI)
       have 5: "False" using 2 4 by (rule notE)}
    hence 6: "P a" by (rule ccontr)}
   hence 7: "∀x. P x" by (rule allI)
   show 8: "False" using 1 7 by (rule notE)
qed
qed
next
   assume 9: "∃x. ¬P x"
   show "¬(∀x. P x)"
   proof -
   {assume 10: "¬¬(∀x. P x)"
    have 11: "∀x. P x" using 10 by (rule notnotD)
    obtain a where 12: "¬P a" using 9 by (rule exE)
    have 13: "P a" using 11 by (rule allE)
    have 14: "False" using 12 13 by (rule notE)}
   thus 15: "¬(∀x. P x)" by (rule ccontr)
qed
qed

section {* Ejercicios sobre igualdad *}

text {* --------------------------------------------------------------- 
  Ejercicio 31. Demostrar o refutar
       P a ⟹ ∀x. x = a ⟶ P x
  ------------------------------------------------------------------ *}

-- Francisco Javier Carmona

lemma ejercicio_31a:
  assumes "P a"
  shows   "∀x. x = a ⟶ P x"
proof (rule allI)
  fix b
  show "b = a ⟶ P b"
  proof (rule impI)
  assume 1: "b = a"
  show "P b"
  proof -
  have 2: "a = b" using 1 by (rule sym)
  show 3: "P b" using 2 assms(1) by (rule subst)
qed
qed
qed

text {* --------------------------------------------------------------- 
  Ejercicio 32. Demostrar o refutar
       ∃x y. R x y ∨ R y x; ¬(∃x. R x x)⟧ ⟹ ∃x y. x ≠ y
  ------------------------------------------------------------------ *}

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

text {* --------------------------------------------------------------- 
  Ejercicio 33. Demostrar o refutar
     {∀x. P a x x, 
      ∀x y z. P x y z ⟶ P (f x) y (f z)} 
     ⊢ P (f a) a (f a)
  ------------------------------------------------------------------ *}

-- Francisco Javier Carmona

lemma ejercicio_33a:
  assumes "∀x. P a x x"
          "∀x y z. P x y z ⟶ P (f x) y (f z)"
  shows   "P (f a) a (f a)"
proof -
    have 1: "P a a a" using assms(1) by (rule allE)
    have 2: "∀y z. P a y z ⟶ P (f a) y (f z)" using assms(2) by (rule allE)
    have 3: "∀z. P a a z ⟶ P (f a) a (f z)" using 2 by (rule allE)
    have 4: "P a a a ⟶ P (f a) a (f a)" using 3 by (rule allE)
    show 5: "P (f a) a (f a)" using 4 1 by (rule mp)
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))
  ------------------------------------------------------------------ *}

-- Francisco Javier Carmona

lemma ejercicio_34a:
  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 1: "P a (f a) (f a)" using assms(1) by (rule allE)
   have 2: "∀y z. P a y z ⟶ P (f a) y (f z)" using assms(2) by (rule allE)
   have 3: "∀z. P a (f a) z ⟶ P (f a) (f a) (f z)" using 2 by (rule allE)
   have 4: "P a (f a) (f a) ⟶ P (f a) (f a) (f (f a))" using 3 by (rule allE)
   have 5: "P (f a) (f a) (f (f a))" using 4 1 by (rule mp)
   show 6: "∃z. P (f a) z (f (f a))" using 5 by (rule exI)
qed

text {* --------------------------------------------------------------- 
  Ejercicio 35. Demostrar o refutar
     {∀y. Q a y, 
      ∀x y. Q x y ⟶ Q (s x) (s y)} 
     ⊢ ∃z. Qa z ∧ Q z (s (s a))
  ------------------------------------------------------------------ *}

-- Francisco Javier Carmona

lemma ejercicio_35a:
  assumes "∀y. Q a y" 
          "∀x y. Q x y ⟶ Q (s x) (s y)" 
  shows   "∃z. Q a z ∧ Q z (s (s a))"
proof -
    have 1: "Q a (s a)" using assms(1) by (rule allE)
    have 2: "∀y. Q a y ⟶ Q (s a) (s y)" using assms(2) by (rule allE)
    have 3: "Q a (s a) ⟶ Q (s a) (s (s a))" using 2 by (rule allE)
    have 4: "Q (s a) (s (s a))" using 3 1 by (rule mp)
    have 5: "Q a (s a) ∧ Q (s a) (s (s a))" using 1 4 by (rule conjI)
    show 6: "∃z. Q a z ∧ Q z (s (s a))" using 5 by (rule exI)
qed

text {* --------------------------------------------------------------- 
  Ejercicio 36. Demostrar o refutar
     {x = f x, odd (f x)} ⊢ odd x
  ------------------------------------------------------------------ *}

-- Francisco Javier Carmona

lemma ejercicio_36a:
  assumes "x = f x" and
          "odd (f x)"
  shows "odd x"
proof -
  show "odd x" using assms(1) assms(2) by (rule ssubst)
qed

text {* --------------------------------------------------------------- 
  Ejercicio 37. Demostrar o refutar
     {x = f x, triple (f x) (f x) x} ⊢ triple x x x
  ------------------------------------------------------------------ *}

-- Francisco Javier Carmona

lemma ejercicio_37a:
  assumes "x = f x" and
          "triple (f x) (f x) x"
  shows "triple x x x"
proof -
   show "triple x x x" using assms(1) assms(2) by (rule ssubst)
qed

end