<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="es">
	<id>https://www.glc.us.es/~jalonso/RA2016/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Pabrodmac</id>
	<title>Razonamiento automático (2016-17) - Contribuciones del usuario [es]</title>
	<link rel="self" type="application/atom+xml" href="https://www.glc.us.es/~jalonso/RA2016/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Pabrodmac"/>
	<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php/Especial:Contribuciones/Pabrodmac"/>
	<updated>2026-07-17T07:00:57Z</updated>
	<subtitle>Contribuciones del usuario</subtitle>
	<generator>MediaWiki 1.31.14</generator>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_10&amp;diff=1420</id>
		<title>Relación 10</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_10&amp;diff=1420"/>
		<updated>2017-01-31T15:53:17Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R10: Formalización y argumentación con Isabelle/HOL *}&lt;br /&gt;
&lt;br /&gt;
theory R10_Formalizacion_y_argmentacion&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  El objetivo de esta es relación formalizar y demostrar la corrección&lt;br /&gt;
  de los argumentos automáticamente y detalladamente usando sólo las reglas&lt;br /&gt;
  básicas de deducción natural. &lt;br /&gt;
&lt;br /&gt;
  · conjI:      ⟦P; Q⟧ ⟹ P ∧ Q&lt;br /&gt;
  · conjunct1:  P ∧ Q ⟹ P&lt;br /&gt;
  · conjunct2:  P ∧ Q ⟹ Q  &lt;br /&gt;
  · notnotD:    ¬¬ P ⟹ P&lt;br /&gt;
  · mp:         ⟦P ⟶ Q; P⟧ ⟹ Q &lt;br /&gt;
  · impI:       (P ⟹ Q) ⟹ P ⟶ Q&lt;br /&gt;
  · disjI1:     P ⟹ P ∨ Q&lt;br /&gt;
  · disjI2:     Q ⟹ P ∨ Q&lt;br /&gt;
  · disjE:      ⟦P ∨ Q; P ⟹ R; Q ⟹ R⟧ ⟹ R &lt;br /&gt;
  · FalseE:     False ⟹ P&lt;br /&gt;
  · notE:       ⟦¬P; P⟧ ⟹ R&lt;br /&gt;
  · notI:       (P ⟹ False) ⟹ ¬P&lt;br /&gt;
  · iffI:       ⟦P ⟹ Q; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
  · iffD1:      ⟦Q = P; Q⟧ ⟹ P &lt;br /&gt;
  · iffD2:      ⟦P = Q; Q⟧ ⟹ P&lt;br /&gt;
  · ccontr:     (¬P ⟹ False) ⟹ P&lt;br /&gt;
&lt;br /&gt;
  · allI:       ⟦∀x. P x; P x ⟹ R⟧ ⟹ R&lt;br /&gt;
  · allE:       (⋀x. P x) ⟹ ∀x. P x&lt;br /&gt;
  · exI:        P x ⟹ ∃x. P x&lt;br /&gt;
  · exE:        ⟦∃x. P x; ⋀x. P x ⟹ Q⟧ ⟹ Q&lt;br /&gt;
&lt;br /&gt;
  · refl:       t = t&lt;br /&gt;
  · subst:      ⟦s = t; P s⟧ ⟹ P t&lt;br /&gt;
  · trans:      ⟦r = s; s = t⟧ ⟹ r = t&lt;br /&gt;
  · sym:        s = t ⟹ t = s&lt;br /&gt;
  · not_sym:    t ≠ s ⟹ s ≠ t&lt;br /&gt;
  · ssubst:     ⟦t = s; P s⟧ ⟹ P t&lt;br /&gt;
  · box_equals: ⟦a = b; a = c; b = d⟧ ⟹ a: = d&lt;br /&gt;
  · arg_cong:   x = y ⟹ f x = f y&lt;br /&gt;
  · fun_cong:   f = g ⟹ f x = g x&lt;br /&gt;
  · cong:       ⟦f = g; x = y⟧ ⟹ f x = g y&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  Se usarán las reglas notnotI, mt, no_ex y no_para_todo que demostramos&lt;br /&gt;
  a continuación. &lt;br /&gt;
  *}&lt;br /&gt;
&lt;br /&gt;
lemma notnotI: &amp;quot;P ⟹ ¬¬ P&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma mt: &amp;quot;⟦F ⟶ G; ¬G⟧ ⟹ ¬F&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma no_ex: &amp;quot;¬(∃x. P(x)) ⟹ ∀x. ¬P(x)&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma no_para_todo: &amp;quot;¬(∀x. P(x)) ⟹ ∃x. ¬P(x)&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Formalizar, y demostrar la corrección, del siguiente&lt;br /&gt;
  argumento &lt;br /&gt;
     Si la válvula está abierta o la monitorización está preparada,&lt;br /&gt;
     entonces se envía una señal de reconocimiento y un mensaje de&lt;br /&gt;
     funcionamiento al controlador del ordenador. Si se envía un mensaje &lt;br /&gt;
     de funcionamiento al controlador del ordenador o el sistema está en &lt;br /&gt;
     estado normal, entonces se aceptan las órdenes del operador. Por lo&lt;br /&gt;
     tanto, si la válvula está abierta, entonces se aceptan las órdenes&lt;br /&gt;
     del operador. &lt;br /&gt;
  Usar A : La válvula está abierta.&lt;br /&gt;
       P : La monitorización está preparada.&lt;br /&gt;
       R : Envía una señal de reconocimiento.&lt;br /&gt;
       F : Envía un mensaje de funcionamiento.&lt;br /&gt;
       N : El sistema está en estado normal.&lt;br /&gt;
       O, AO, OK : Se aceptan órdenes del operador.&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim manmorjim1 crigomgom migtermor serrodcal *)&lt;br /&gt;
(* Buscando, he detectado que &amp;#039;O&amp;#039; es un carácter especial en Isabelle y que forma parte de su&lt;br /&gt;
sintaxis pre-definida, por lo que da problemas a la hora de formalizar y demostrar &lt;br /&gt;
el argumento planteado. Por lo tanto, en su lugar he usado &amp;quot;AO: Se aceptan órdenes del operador&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_1:&lt;br /&gt;
  assumes 1: &amp;quot;(A ∨ P) ⟶ (R ∧ F)&amp;quot; &lt;br /&gt;
  assumes 2: &amp;quot;(F ∨ N) ⟶ AO&amp;quot;&lt;br /&gt;
  shows &amp;quot;A ⟶ AO&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  {assume 3: &amp;quot;A&amp;quot;&lt;br /&gt;
   have 4: &amp;quot;A ∨ P&amp;quot; using 3 by (rule disjI1)&lt;br /&gt;
   have 5: &amp;quot;R ∧ F&amp;quot; using 1 4 by (rule mp)&lt;br /&gt;
   have 6: &amp;quot;F&amp;quot; using 5 by (rule conjunct2)&lt;br /&gt;
   have 7: &amp;quot;F ∨ N&amp;quot; using 6 by (rule disjI1)&lt;br /&gt;
   have 8: &amp;quot;AO&amp;quot; using 2 7 by (rule mp)}&lt;br /&gt;
  then show &amp;quot;A ⟶ AO&amp;quot; by (rule impI)&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(*danrodcha ferrenseg anaprarod marcarmor13*)&lt;br /&gt;
&lt;br /&gt;
lemma ej_1: &lt;br /&gt;
  assumes &amp;quot;A ∨ P ⟶ R ∧ F&amp;quot; and &lt;br /&gt;
          &amp;quot;F ∨ N ⟶ OK&amp;quot;&lt;br /&gt;
  shows &amp;quot;A ⟶ OK&amp;quot;&lt;br /&gt;
proof (rule impI)&lt;br /&gt;
{assume &amp;quot;A&amp;quot;&lt;br /&gt;
  hence &amp;quot;A ∨ P&amp;quot; by (rule disjI1)&lt;br /&gt;
  with assms(1) have &amp;quot;R ∧ F&amp;quot; by (rule mp)&lt;br /&gt;
  hence &amp;quot;F&amp;quot; by (rule conjE)&lt;br /&gt;
  hence &amp;quot;F ∨ N&amp;quot; by (rule disjI1)&lt;br /&gt;
  with assms(2) show &amp;quot;OK&amp;quot; by (rule mp)}&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
lemma ejercicio_1_1: &lt;br /&gt;
  assumes &amp;quot;A ∨ P ⟶ R ∧ F&amp;quot;&lt;br /&gt;
          &amp;quot;F ∨ N ⟶ Op&amp;quot;&lt;br /&gt;
  shows   &amp;quot;A ⟶ Op&amp;quot;&lt;br /&gt;
proof&lt;br /&gt;
 assume &amp;quot;A&amp;quot;&lt;br /&gt;
 hence &amp;quot;A ∨ P&amp;quot; by (rule disjI1)&lt;br /&gt;
 have &amp;quot;R ∧ F&amp;quot; using `A ∨ P ⟶ R ∧ F` `A ∨ P` by (rule mp)&lt;br /&gt;
 hence &amp;quot;F&amp;quot; by (rule conjE)&lt;br /&gt;
 hence &amp;quot;F ∨ N&amp;quot;  by (rule disjI1)&lt;br /&gt;
 show &amp;quot;Op&amp;quot;  using `F ∨ N ⟶ Op` `F ∨ N` by (rule mp)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*josgarsan*)&lt;br /&gt;
lemma ejericio_1_2:&lt;br /&gt;
  assumes 1: &amp;quot;(A ∨ P) ⟶ (R ∧ F)&amp;quot; and&lt;br /&gt;
          2: &amp;quot;(F ∨ N) ⟶ Op&amp;quot;&lt;br /&gt;
  shows &amp;quot;A ⟶ Op&amp;quot;&lt;br /&gt;
proof&lt;br /&gt;
  assume 3: A&lt;br /&gt;
  have 4:&amp;quot;(A ∨ P)&amp;quot; using 3 by (rule disjI1)&lt;br /&gt;
  have &amp;quot;(R ∧ F)&amp;quot; using 1 4 by (rule mp)&lt;br /&gt;
  then have &amp;quot;F&amp;quot; by (rule conjunct2)&lt;br /&gt;
  then have 5: &amp;quot;(F ∨ N)&amp;quot; by (rule disjI1)&lt;br /&gt;
  show &amp;quot;Op&amp;quot; using 2 5 by (rule mp)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Formalizar, y decidir la corrección, del siguiente&lt;br /&gt;
  argumento &lt;br /&gt;
     Hay estudiantes inteligentes y hay estudiantes trabajadores. Por&lt;br /&gt;
     tanto, hay estudiantes inteligentes y trabajadores.&lt;br /&gt;
  Usar I(x) para x es inteligente&lt;br /&gt;
       T(x) para x es trabajador&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg danrodcha anaprarod crigomgom marcarmor13 pabrodmac migtermor josgarsan serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_2:&lt;br /&gt;
  assumes &amp;quot;(∃x. I(x)) ∧ (∃x. T(x))&amp;quot;&lt;br /&gt;
  shows   &amp;quot;∃x. (I(x) ∧ T(x))&amp;quot;&lt;br /&gt;
  quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* Encontrando el contraejemplo: &lt;br /&gt;
   I = {a1} &lt;br /&gt;
   x = a1&lt;br /&gt;
   T = {a2}&lt;br /&gt;
   xa = a2 &lt;br /&gt;
*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Formalizar, y decidir la corrección, del siguiente&lt;br /&gt;
  argumento &lt;br /&gt;
     Los hermanos tienen el mismo padre. Juan es hermano de Luis. Carlos&lt;br /&gt;
     es padre de Luis. Por tanto, Carlos es padre de Juan.&lt;br /&gt;
  Usar H(x,y) para x es hermano de y&lt;br /&gt;
       P(x,y) para x es padre de y&lt;br /&gt;
       j      para Juan&lt;br /&gt;
       l      para Luis&lt;br /&gt;
       c      para Carlos&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom serrodcal*)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_3:&lt;br /&gt;
  assumes 1: &amp;quot;∀x y. P(x,y) ⟶ (∀z. (H(z,y) ⟶ P(x,z)))&amp;quot; &lt;br /&gt;
  assumes 2: &amp;quot;H(j,l)&amp;quot;&lt;br /&gt;
  assumes 3: &amp;quot;P(c,l)&amp;quot;&lt;br /&gt;
  shows &amp;quot;P(c,j)&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have 4 : &amp;quot;∀y. P(c,y) ⟶ (∀z. (H(z,y) ⟶ P(c,z)))&amp;quot; using 1 by (rule allE)&lt;br /&gt;
  have 5 : &amp;quot;P(c,l) ⟶ (∀z. (H(z,l) ⟶ P(c,z)))&amp;quot; using 4 by (rule allE)&lt;br /&gt;
  then have 6 : &amp;quot;(∀z. (H(z,l) ⟶ P(c,z)))&amp;quot; using 3 by (rule mp)&lt;br /&gt;
  have 7 : &amp;quot;H(j,l) ⟶ P(c,j)&amp;quot; using 6 by (rule allE)&lt;br /&gt;
  then show &amp;quot;P(c,j)&amp;quot; using 2 by (rule mp)&lt;br /&gt;
qed    &lt;br /&gt;
&lt;br /&gt;
(* danrodcha anaprarod ferrenseg marcarmor13*)&lt;br /&gt;
(* es casi igual que la anterior *)&lt;br /&gt;
lemma ej_3:&lt;br /&gt;
  assumes &amp;quot;∀x y. P(x,y) ⟶ (∀z. (H(z,y) ⟶ P(x,z)))&amp;quot; &lt;br /&gt;
  assumes &amp;quot;H(j,l)&amp;quot;&lt;br /&gt;
  assumes &amp;quot;P(c,l)&amp;quot;&lt;br /&gt;
  shows &amp;quot;P(c,j)&amp;quot;&lt;br /&gt;
proof (rule mp)&lt;br /&gt;
  have 4 : &amp;quot;∀y. P(c,y) ⟶ (∀z. (H(z,y) ⟶ P(c,z)))&amp;quot; using assms(1) by (rule allE)&lt;br /&gt;
  hence &amp;quot;P(c,l) ⟶ (∀z. (H(z,l) ⟶ P(c,z)))&amp;quot; by (rule allE)&lt;br /&gt;
  hence &amp;quot;(∀z. (H(z,l) ⟶ P(c,z)))&amp;quot; using assms(3) by (rule mp)&lt;br /&gt;
  thus &amp;quot;H(j,l) ⟶ P(c,j)&amp;quot; by (rule allE)&lt;br /&gt;
  next&lt;br /&gt;
  show &amp;quot;H(j,l)&amp;quot; using assms(2) by this&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
lemma ejercicio_3_1: &lt;br /&gt;
  assumes &amp;quot;∀x y. H(x,y) ⟶ (∀ z. (P(z,y) ⟶ P(z,x)))&amp;quot;&lt;br /&gt;
          &amp;quot;H(j,l)&amp;quot;&lt;br /&gt;
          &amp;quot;P(c,l)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;P(c,j)&amp;quot;&lt;br /&gt;
proof-&lt;br /&gt;
  have &amp;quot;∀y. H(j,y) ⟶ (∀ z. (P(z,y) ⟶ P(z,j)))&amp;quot; using assms(1) by (rule allE)&lt;br /&gt;
  hence &amp;quot;H(j,l) ⟶ (∀ z. (P(z,l) ⟶ P(z,j)))&amp;quot; by (rule allE)&lt;br /&gt;
  hence &amp;quot;∀z. (P(z,l) ⟶ P(z,j))&amp;quot; using assms(2) by (rule mp)&lt;br /&gt;
  hence &amp;quot;P(c,l) ⟶ P(c,j)&amp;quot; by (rule allE)&lt;br /&gt;
  thus &amp;quot;P(c,j)&amp;quot; using assms(3) by (rule mp)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_3_2:&lt;br /&gt;
  assumes  &amp;quot;∀x y z. (P(x,y) ∧ H(y,z)) ⟶  P(x,z)&amp;quot; &lt;br /&gt;
  assumes  &amp;quot;H(l,j)&amp;quot;&lt;br /&gt;
  assumes  &amp;quot;P(c,l)&amp;quot;&lt;br /&gt;
  shows &amp;quot;P(c,j)&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have 1: &amp;quot;P(c,l) ∧ H(l,j)&amp;quot; using assms(3) assms(2) by (rule conjI)&lt;br /&gt;
  have 2: &amp;quot;∀y z. (P(c,y) ∧ H(y,z)) ⟶  P(c,z)&amp;quot; using assms(1) by (rule allE)&lt;br /&gt;
  then have 3: &amp;quot;∀z. (P(c,l) ∧ H(l,z)) ⟶  P(c,z)&amp;quot; by (rule allE)&lt;br /&gt;
  then have 4: &amp;quot;(P(c,l) ∧ H(l,j)) ⟶  P(c,j)&amp;quot; by (rule allE)&lt;br /&gt;
  then show &amp;quot;P(c,j)&amp;quot; using 1 by (rule mp)&lt;br /&gt;
qed    &lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Formalizar, y decidir la corrección, del siguiente&lt;br /&gt;
  argumento &lt;br /&gt;
     Los aficionados al fútbol aplauden a cualquier futbolista&lt;br /&gt;
     extranjero. Juanito no aplaude a futbolistas extranjeros. Por&lt;br /&gt;
     tanto, si hay algún futbolista extranjero nacionalizado español,&lt;br /&gt;
     Juanito no es aficionado al fútbol.&lt;br /&gt;
  Usar Af(x)   para x es aficicionado al fútbol&lt;br /&gt;
       Ap(x,y) para x aplaude a y&lt;br /&gt;
       E(x)    para x es un futbolista extranjero&lt;br /&gt;
       N(x)    para x es un futbolista nacionalizado español&lt;br /&gt;
       j       para Juanito&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
(* danrodcha  ferrenseg *)&lt;br /&gt;
(* danrodcha: Me gusta más la formalización de ana prado, aunque &lt;br /&gt;
    son equivalentes *)&lt;br /&gt;
lemma ej_4:&lt;br /&gt;
  assumes &amp;quot;∀x y. Af(x) ∧ E(y) ⟶ Ap(x,y)&amp;quot;&lt;br /&gt;
          &amp;quot;∀x. Ap(j,x) ⟶ ¬ E(x)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;(∃x. E(x) ∧ N(x)) ⟶ ¬Af(j)&amp;quot;&lt;br /&gt;
  proof (rule impI)&lt;br /&gt;
  assume &amp;quot;∃x. E(x) ∧ N(x)&amp;quot;&lt;br /&gt;
    then obtain a where &amp;quot;E(a) ∧ N(a)&amp;quot; by (rule exE)&lt;br /&gt;
    hence &amp;quot;E(a)&amp;quot; by (rule conjE)&lt;br /&gt;
    show &amp;quot;¬ Af(j)&amp;quot;&lt;br /&gt;
    proof (rule notI)&lt;br /&gt;
      assume &amp;quot;Af(j)&amp;quot;&lt;br /&gt;
      hence &amp;quot;Af(j) ∧ E(a)&amp;quot; using `E(a)` by (rule conjI)&lt;br /&gt;
      have &amp;quot;∀y. Af(j) ∧ E(y) ⟶ Ap(j,y)&amp;quot; using assms(1) by (rule allE)&lt;br /&gt;
      hence &amp;quot;Af(j) ∧ E(a) ⟶ Ap(j,a)&amp;quot; by (rule allE)&lt;br /&gt;
      hence &amp;quot;Ap(j,a)&amp;quot; using `Af(j) ∧ E(a)` by (rule mp)&lt;br /&gt;
      have &amp;quot;Ap(j,a) ⟶ ¬ E(a)&amp;quot; using assms(2) by (rule allE)&lt;br /&gt;
      hence &amp;quot;¬ E(a)&amp;quot; using `Ap(j,a)` by (rule mp)&lt;br /&gt;
      thus False using `E(a)` by (rule notE)&lt;br /&gt;
    qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marcarmor13 serrodcal*)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_4:&lt;br /&gt;
  assumes 1: &amp;quot;∀x y. Af(x) ∧ E(y) ⟶ Ap(x,y)&amp;quot;&lt;br /&gt;
  assumes 2: &amp;quot;¬(∃x. E(x) ∧ Ap(j,x))&amp;quot;&lt;br /&gt;
  shows &amp;quot;(∃x. E(x) ∧ N(x)) ⟶ ¬Af(j)&amp;quot;  &lt;br /&gt;
  proof (rule impI)&lt;br /&gt;
  assume 3: &amp;quot;∃x. E(x) ∧ N(x)&amp;quot;&lt;br /&gt;
    then obtain a where 4: &amp;quot;E(a) ∧ N(a)&amp;quot; by (rule exE)&lt;br /&gt;
    then have 5: &amp;quot;E(a)&amp;quot; by (rule conjunct1)&lt;br /&gt;
    show 6: &amp;quot;¬Af(j)&amp;quot;&lt;br /&gt;
    proof (rule notI)&lt;br /&gt;
      assume 7: &amp;quot;Af(j)&amp;quot;&lt;br /&gt;
      then have 8: &amp;quot;Af(j) ∧ E(a)&amp;quot; using 5 by (rule conjI)&lt;br /&gt;
      have 9: &amp;quot;∀y. Af(j) ∧ E(y) ⟶ Ap(j,y)&amp;quot; using 1 by (rule allE)&lt;br /&gt;
      have 10: &amp;quot;Af(j) ∧ E(a) ⟶ Ap(j,a)&amp;quot; using 9 by (rule allE)&lt;br /&gt;
      have 11: &amp;quot;Ap(j,a)&amp;quot; using 10 8 by (rule mp)&lt;br /&gt;
      have 12: &amp;quot;E(a) ∧ Ap(j,a)&amp;quot; using 5 11 by (rule conjI)&lt;br /&gt;
      have 13: &amp;quot;∃x. E(x) ∧ Ap(j,x)&amp;quot; using 12 by (rule exI)&lt;br /&gt;
      show &amp;quot;False&amp;quot; using 2 13 by (rule notE)&lt;br /&gt;
    qed&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* anaprarod migtermor *)&lt;br /&gt;
&lt;br /&gt;
(* Este auxiliar ya se probó en el ejercicio 4 de la rel 8 *)&lt;br /&gt;
lemma aux4: &amp;quot;¬(p∧q) ⟹¬p ∨ ¬q&amp;quot;&lt;br /&gt;
by (auto)&lt;br /&gt;
&lt;br /&gt;
lemma ej_4:&lt;br /&gt;
  assumes &amp;quot;∀x y. Af(x) ∧ E(y) ⟶ Ap(x,y)&amp;quot;&lt;br /&gt;
          &amp;quot;∀ x.(E(x) ⟶ ¬ Ap(j,x))&amp;quot;&lt;br /&gt;
  shows   &amp;quot;(∃x. E(x) ∧ N(x)) ⟶ ¬Af(j)&amp;quot;&lt;br /&gt;
proof (rule impI)&lt;br /&gt;
  { assume &amp;quot;∃x. E(x) ∧ N(x)&amp;quot;&lt;br /&gt;
    then obtain a where 1: &amp;quot;E(a) ∧ N(a)&amp;quot; by (rule exE)&lt;br /&gt;
    have &amp;quot;∀ y. Af(j) ∧ E(y) ⟶ Ap(j,y)&amp;quot; using assms(1)  by (rule allE)&lt;br /&gt;
    hence 2: &amp;quot;Af(j) ∧ E(a) ⟶ Ap(j,a)&amp;quot; by (rule allE)&lt;br /&gt;
    have 3: &amp;quot;E(a)&amp;quot; using 1 by (rule conjunct1)&lt;br /&gt;
    have 4: &amp;quot;E(a) ⟶ ¬ Ap(j,a)&amp;quot; using assms(2) by (rule allE)&lt;br /&gt;
    have 5: &amp;quot;¬ Ap(j,a)&amp;quot; using 4 3 by (rule mp)&lt;br /&gt;
    have &amp;quot;¬(Af(j) ∧ E(a))&amp;quot; using 2 5 by (rule mt)&lt;br /&gt;
    hence &amp;quot;¬ Af(j) ∨ ¬ E(a)&amp;quot; by (rule aux4)&lt;br /&gt;
    thus &amp;quot; ¬Af(j)&amp;quot;&lt;br /&gt;
      proof (rule disjE)&lt;br /&gt;
      {assume &amp;quot;¬Af(j)&amp;quot;&lt;br /&gt;
        thus  &amp;quot;¬Af(j)&amp;quot; by this}&lt;br /&gt;
      next&lt;br /&gt;
      {assume 6: &amp;quot;¬ E(a)&amp;quot;&lt;br /&gt;
        show &amp;quot;¬ Af(j)&amp;quot; using 6 3 by (rule notE)}&lt;br /&gt;
      qed}&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_4_1: &lt;br /&gt;
  assumes &amp;quot;∀x y. Af(x) ∧ E(y) ⟶ Ap(x,y)&amp;quot;&lt;br /&gt;
          &amp;quot;∀x. E(x)⟶ ¬Ap(j,x)&amp;quot;          &lt;br /&gt;
  shows   &amp;quot;(∃x. N(x) ∧ E(x)) ⟶ ¬Af(j)&amp;quot;&lt;br /&gt;
proof&lt;br /&gt;
  assume &amp;quot;∃x. N(x) ∧ E(x)&amp;quot;&lt;br /&gt;
  then obtain b where &amp;quot;N(b) ∧ E(b)&amp;quot; by (rule exE)&lt;br /&gt;
  hence &amp;quot;E(b)&amp;quot; by (rule conjunct2)&lt;br /&gt;
  have &amp;quot;E(b)⟶ ¬Ap(j,b)&amp;quot; using assms(2) by (rule allE)&lt;br /&gt;
  hence &amp;quot;¬Ap(j,b)&amp;quot; using `E(b)` by (rule mp)&lt;br /&gt;
  have &amp;quot;∀y. Af(j) ∧ E(y) ⟶ Ap(j,y)&amp;quot; using assms(1) by (rule allE)&lt;br /&gt;
  hence &amp;quot;Af(j) ∧ E(b) ⟶ Ap(j,b)&amp;quot;  by (rule allE)&lt;br /&gt;
  hence &amp;quot;¬Ap(j,b) ⟶ ¬(Af(j) ∧ E(b))&amp;quot; by (rule Set.not_mono)&lt;br /&gt;
  hence &amp;quot;¬(Af(j) ∧ E(b))&amp;quot;  using `¬Ap(j,b)`  by (rule mp)&lt;br /&gt;
  show &amp;quot;¬Af(j)&amp;quot; &lt;br /&gt;
  proof&lt;br /&gt;
  assume &amp;quot;Af(j)&amp;quot; &lt;br /&gt;
  hence &amp;quot;Af(j) ∧ E(b)&amp;quot; using `E(b)` by (rule  conjI)&lt;br /&gt;
  show False using `¬(Af(j) ∧ E(b))` `Af(j) ∧ E(b)` by (rule notE) &lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Formalizar, y decidir la corrección, del siguiente&lt;br /&gt;
  argumento &lt;br /&gt;
     El esposo de la hermana de Toni es Roberto. La hermana de Toni es&lt;br /&gt;
     María. Por tanto, el esposo de María es Roberto. &lt;br /&gt;
  Usar e(x) para el esposo de x&lt;br /&gt;
       h    para la hermana de Toni&lt;br /&gt;
       m    para María&lt;br /&gt;
       r    para Roberto&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_5:&lt;br /&gt;
  assumes 1: &amp;quot;e(h) = r&amp;quot; &lt;br /&gt;
  assumes 2: &amp;quot;h = m&amp;quot;&lt;br /&gt;
  shows &amp;quot;e(m) = r&amp;quot;   &lt;br /&gt;
proof -&lt;br /&gt;
  have 3: &amp;quot;e(h) = e(m)&amp;quot; using 2 by (rule arg_cong)&lt;br /&gt;
  have 4: &amp;quot;e(m) = e(h)&amp;quot; using 3 by (rule sym)&lt;br /&gt;
  then show &amp;quot;e(m) = r&amp;quot; using 1 by (rule trans)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha anaprarod crigomgom ferrenseg marcarmor13 migtermor serrodcal *)&lt;br /&gt;
lemma ej_5:&lt;br /&gt;
  assumes &amp;quot;e(h) = r&amp;quot; and&lt;br /&gt;
          &amp;quot;h = m&amp;quot;&lt;br /&gt;
  shows   &amp;quot;e(m) = r&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    show &amp;quot;e(m) = r&amp;quot; using assms(2) assms(1) by (rule subst)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
lemma ejercicio_5_1: &lt;br /&gt;
  assumes &amp;quot;e(h)=r&amp;quot;&lt;br /&gt;
          &amp;quot;h=m&amp;quot;          &lt;br /&gt;
  shows   &amp;quot;e(m)=r&amp;quot;&lt;br /&gt;
proof-&lt;br /&gt;
  show &amp;quot;e(m)=r&amp;quot; using assms(1) assms(2) by (rule HOL.back_subst)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
lemma ejercicio_5_2: &lt;br /&gt;
  assumes &amp;quot;e(h)=r&amp;quot;&lt;br /&gt;
          &amp;quot;h=m&amp;quot;          &lt;br /&gt;
  shows   &amp;quot;e(m)=r&amp;quot;&lt;br /&gt;
proof-&lt;br /&gt;
  show &amp;quot;e(m)=r&amp;quot; using assms(2) assms(1) by (rule HOL.subst)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
lemma ejercicio_5_3: &lt;br /&gt;
  assumes &amp;quot;e(h)=r&amp;quot;&lt;br /&gt;
          &amp;quot;h=m&amp;quot;          &lt;br /&gt;
  shows   &amp;quot;e(m)=r&amp;quot;&lt;br /&gt;
proof-&lt;br /&gt;
  have &amp;quot;e(h) = e(m)&amp;quot; using assms(2) by (rule arg_cong)&lt;br /&gt;
  show &amp;quot;e(m)=r&amp;quot; using `e(h)=r` `e(h) = e(m)` by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_10&amp;diff=1412</id>
		<title>Relación 10</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_10&amp;diff=1412"/>
		<updated>2017-01-31T09:40:58Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R10: Formalización y argumentación con Isabelle/HOL *}&lt;br /&gt;
&lt;br /&gt;
theory R10_Formalizacion_y_argmentacion&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  El objetivo de esta es relación formalizar y demostrar la corrección&lt;br /&gt;
  de los argumentos automáticamente y detalladamente usando sólo las reglas&lt;br /&gt;
  básicas de deducción natural. &lt;br /&gt;
&lt;br /&gt;
  · conjI:      ⟦P; Q⟧ ⟹ P ∧ Q&lt;br /&gt;
  · conjunct1:  P ∧ Q ⟹ P&lt;br /&gt;
  · conjunct2:  P ∧ Q ⟹ Q  &lt;br /&gt;
  · notnotD:    ¬¬ P ⟹ P&lt;br /&gt;
  · mp:         ⟦P ⟶ Q; P⟧ ⟹ Q &lt;br /&gt;
  · impI:       (P ⟹ Q) ⟹ P ⟶ Q&lt;br /&gt;
  · disjI1:     P ⟹ P ∨ Q&lt;br /&gt;
  · disjI2:     Q ⟹ P ∨ Q&lt;br /&gt;
  · disjE:      ⟦P ∨ Q; P ⟹ R; Q ⟹ R⟧ ⟹ R &lt;br /&gt;
  · FalseE:     False ⟹ P&lt;br /&gt;
  · notE:       ⟦¬P; P⟧ ⟹ R&lt;br /&gt;
  · notI:       (P ⟹ False) ⟹ ¬P&lt;br /&gt;
  · iffI:       ⟦P ⟹ Q; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
  · iffD1:      ⟦Q = P; Q⟧ ⟹ P &lt;br /&gt;
  · iffD2:      ⟦P = Q; Q⟧ ⟹ P&lt;br /&gt;
  · ccontr:     (¬P ⟹ False) ⟹ P&lt;br /&gt;
&lt;br /&gt;
  · allI:       ⟦∀x. P x; P x ⟹ R⟧ ⟹ R&lt;br /&gt;
  · allE:       (⋀x. P x) ⟹ ∀x. P x&lt;br /&gt;
  · exI:        P x ⟹ ∃x. P x&lt;br /&gt;
  · exE:        ⟦∃x. P x; ⋀x. P x ⟹ Q⟧ ⟹ Q&lt;br /&gt;
&lt;br /&gt;
  · refl:       t = t&lt;br /&gt;
  · subst:      ⟦s = t; P s⟧ ⟹ P t&lt;br /&gt;
  · trans:      ⟦r = s; s = t⟧ ⟹ r = t&lt;br /&gt;
  · sym:        s = t ⟹ t = s&lt;br /&gt;
  · not_sym:    t ≠ s ⟹ s ≠ t&lt;br /&gt;
  · ssubst:     ⟦t = s; P s⟧ ⟹ P t&lt;br /&gt;
  · box_equals: ⟦a = b; a = c; b = d⟧ ⟹ a: = d&lt;br /&gt;
  · arg_cong:   x = y ⟹ f x = f y&lt;br /&gt;
  · fun_cong:   f = g ⟹ f x = g x&lt;br /&gt;
  · cong:       ⟦f = g; x = y⟧ ⟹ f x = g y&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  Se usarán las reglas notnotI, mt, no_ex y no_para_todo que demostramos&lt;br /&gt;
  a continuación. &lt;br /&gt;
  *}&lt;br /&gt;
&lt;br /&gt;
lemma notnotI: &amp;quot;P ⟹ ¬¬ P&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma mt: &amp;quot;⟦F ⟶ G; ¬G⟧ ⟹ ¬F&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma no_ex: &amp;quot;¬(∃x. P(x)) ⟹ ∀x. ¬P(x)&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma no_para_todo: &amp;quot;¬(∀x. P(x)) ⟹ ∃x. ¬P(x)&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Formalizar, y demostrar la corrección, del siguiente&lt;br /&gt;
  argumento &lt;br /&gt;
     Si la válvula está abierta o la monitorización está preparada,&lt;br /&gt;
     entonces se envía una señal de reconocimiento y un mensaje de&lt;br /&gt;
     funcionamiento al controlador del ordenador. Si se envía un mensaje &lt;br /&gt;
     de funcionamiento al controlador del ordenador o el sistema está en &lt;br /&gt;
     estado normal, entonces se aceptan las órdenes del operador. Por lo&lt;br /&gt;
     tanto, si la válvula está abierta, entonces se aceptan las órdenes&lt;br /&gt;
     del operador. &lt;br /&gt;
  Usar A : La válvula está abierta.&lt;br /&gt;
       P : La monitorización está preparada.&lt;br /&gt;
       R : Envía una señal de reconocimiento.&lt;br /&gt;
       F : Envía un mensaje de funcionamiento.&lt;br /&gt;
       N : El sistema está en estado normal.&lt;br /&gt;
       O, AO, OK : Se aceptan órdenes del operador.&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim manmorjim1 crigomgom*)&lt;br /&gt;
(* Buscando, he detectado que &amp;#039;O&amp;#039; es un carácter especial en Isabelle y que forma parte de su&lt;br /&gt;
sintaxis pre-definida, por lo que da problemas a la hora de formalizar y demostrar &lt;br /&gt;
el argumento planteado. Por lo tanto, en su lugar he usado &amp;quot;AO: Se aceptan órdenes del operador&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_1:&lt;br /&gt;
  assumes 1: &amp;quot;(A ∨ P) ⟶ (R ∧ F)&amp;quot; &lt;br /&gt;
  assumes 2: &amp;quot;(F ∨ N) ⟶ AO&amp;quot;&lt;br /&gt;
  shows &amp;quot;A ⟶ AO&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  {assume 3: &amp;quot;A&amp;quot;&lt;br /&gt;
   have 4: &amp;quot;A ∨ P&amp;quot; using 3 by (rule disjI1)&lt;br /&gt;
   have 5: &amp;quot;R ∧ F&amp;quot; using 1 4 by (rule mp)&lt;br /&gt;
   have 6: &amp;quot;F&amp;quot; using 5 by (rule conjunct2)&lt;br /&gt;
   have 7: &amp;quot;F ∨ N&amp;quot; using 6 by (rule disjI1)&lt;br /&gt;
   have 8: &amp;quot;AO&amp;quot; using 2 7 by (rule mp)}&lt;br /&gt;
  then show &amp;quot;A ⟶ AO&amp;quot; by (rule impI)&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(*danrodcha ferrenseg anaprarod marcarmor13*)&lt;br /&gt;
&lt;br /&gt;
lemma ej_1: &lt;br /&gt;
  assumes &amp;quot;A ∨ P ⟶ R ∧ F&amp;quot; and &lt;br /&gt;
          &amp;quot;F ∨ N ⟶ OK&amp;quot;&lt;br /&gt;
  shows &amp;quot;A ⟶ OK&amp;quot;&lt;br /&gt;
proof (rule impI)&lt;br /&gt;
{assume &amp;quot;A&amp;quot;&lt;br /&gt;
  hence &amp;quot;A ∨ P&amp;quot; by (rule disjI1)&lt;br /&gt;
  with assms(1) have &amp;quot;R ∧ F&amp;quot; by (rule mp)&lt;br /&gt;
  hence &amp;quot;F&amp;quot; by (rule conjE)&lt;br /&gt;
  hence &amp;quot;F ∨ N&amp;quot; by (rule disjI1)&lt;br /&gt;
  with assms(2) show &amp;quot;OK&amp;quot; by (rule mp)}&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
lemma ejercicio_1_1: &lt;br /&gt;
  assumes &amp;quot;A ∨ P ⟶ R ∧ F&amp;quot;&lt;br /&gt;
          &amp;quot;F ∨ N ⟶ Op&amp;quot;&lt;br /&gt;
  shows   &amp;quot;A ⟶ Op&amp;quot;&lt;br /&gt;
proof&lt;br /&gt;
 assume &amp;quot;A&amp;quot;&lt;br /&gt;
 hence &amp;quot;A ∨ P&amp;quot; by (rule disjI1)&lt;br /&gt;
 have &amp;quot;R ∧ F&amp;quot; using `A ∨ P ⟶ R ∧ F` `A ∨ P` by (rule mp)&lt;br /&gt;
 hence &amp;quot;F&amp;quot; by (rule conjE)&lt;br /&gt;
 hence &amp;quot;F ∨ N&amp;quot;  by (rule disjI1)&lt;br /&gt;
 show &amp;quot;Op&amp;quot;  using `F ∨ N ⟶ Op` `F ∨ N` by (rule mp)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Formalizar, y decidir la corrección, del siguiente&lt;br /&gt;
  argumento &lt;br /&gt;
     Hay estudiantes inteligentes y hay estudiantes trabajadores. Por&lt;br /&gt;
     tanto, hay estudiantes inteligentes y trabajadores.&lt;br /&gt;
  Usar I(x) para x es inteligente&lt;br /&gt;
       T(x) para x es trabajador&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg danrodcha anaprarod crigomgom marcarmor13 pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_2:&lt;br /&gt;
  assumes &amp;quot;(∃x. I(x)) ∧ (∃x. T(x))&amp;quot;&lt;br /&gt;
  shows   &amp;quot;∃x. (I(x) ∧ T(x))&amp;quot;&lt;br /&gt;
  quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* Encontrando el contraejemplo: &lt;br /&gt;
   I = {a1} &lt;br /&gt;
   x = a1&lt;br /&gt;
   T = {a2}&lt;br /&gt;
   xa = a2 &lt;br /&gt;
*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Formalizar, y decidir la corrección, del siguiente&lt;br /&gt;
  argumento &lt;br /&gt;
     Los hermanos tienen el mismo padre. Juan es hermano de Luis. Carlos&lt;br /&gt;
     es padre de Luis. Por tanto, Carlos es padre de Juan.&lt;br /&gt;
  Usar H(x,y) para x es hermano de y&lt;br /&gt;
       P(x,y) para x es padre de y&lt;br /&gt;
       j      para Juan&lt;br /&gt;
       l      para Luis&lt;br /&gt;
       c      para Carlos&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom*)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_3:&lt;br /&gt;
  assumes 1: &amp;quot;∀x y. P(x,y) ⟶ (∀z. (H(z,y) ⟶ P(x,z)))&amp;quot; &lt;br /&gt;
  assumes 2: &amp;quot;H(j,l)&amp;quot;&lt;br /&gt;
  assumes 3: &amp;quot;P(c,l)&amp;quot;&lt;br /&gt;
  shows &amp;quot;P(c,j)&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have 4 : &amp;quot;∀y. P(c,y) ⟶ (∀z. (H(z,y) ⟶ P(c,z)))&amp;quot; using 1 by (rule allE)&lt;br /&gt;
  have 5 : &amp;quot;P(c,l) ⟶ (∀z. (H(z,l) ⟶ P(c,z)))&amp;quot; using 4 by (rule allE)&lt;br /&gt;
  then have 6 : &amp;quot;(∀z. (H(z,l) ⟶ P(c,z)))&amp;quot; using 3 by (rule mp)&lt;br /&gt;
  have 7 : &amp;quot;H(j,l) ⟶ P(c,j)&amp;quot; using 6 by (rule allE)&lt;br /&gt;
  then show &amp;quot;P(c,j)&amp;quot; using 2 by (rule mp)&lt;br /&gt;
qed    &lt;br /&gt;
&lt;br /&gt;
(* danrodcha anaprarod ferrenseg marcarmor13*)&lt;br /&gt;
(* es casi igual que la anterior *)&lt;br /&gt;
lemma ej_3:&lt;br /&gt;
  assumes &amp;quot;∀x y. P(x,y) ⟶ (∀z. (H(z,y) ⟶ P(x,z)))&amp;quot; &lt;br /&gt;
  assumes &amp;quot;H(j,l)&amp;quot;&lt;br /&gt;
  assumes &amp;quot;P(c,l)&amp;quot;&lt;br /&gt;
  shows &amp;quot;P(c,j)&amp;quot;&lt;br /&gt;
proof (rule mp)&lt;br /&gt;
  have 4 : &amp;quot;∀y. P(c,y) ⟶ (∀z. (H(z,y) ⟶ P(c,z)))&amp;quot; using assms(1) by (rule allE)&lt;br /&gt;
  hence &amp;quot;P(c,l) ⟶ (∀z. (H(z,l) ⟶ P(c,z)))&amp;quot; by (rule allE)&lt;br /&gt;
  hence &amp;quot;(∀z. (H(z,l) ⟶ P(c,z)))&amp;quot; using assms(3) by (rule mp)&lt;br /&gt;
  thus &amp;quot;H(j,l) ⟶ P(c,j)&amp;quot; by (rule allE)&lt;br /&gt;
  next&lt;br /&gt;
  show &amp;quot;H(j,l)&amp;quot; using assms(2) by this&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
lemma ejercicio_3_1: &lt;br /&gt;
  assumes &amp;quot;∀x y. H(x,y) ⟶ (∀ z. (P(z,y) ⟶ P(z,x)))&amp;quot;&lt;br /&gt;
          &amp;quot;H(j,l)&amp;quot;&lt;br /&gt;
          &amp;quot;P(c,l)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;P(c,j)&amp;quot;&lt;br /&gt;
proof-&lt;br /&gt;
  have &amp;quot;∀y. H(j,y) ⟶ (∀ z. (P(z,y) ⟶ P(z,j)))&amp;quot; using assms(1) by (rule allE)&lt;br /&gt;
  hence &amp;quot;H(j,l) ⟶ (∀ z. (P(z,l) ⟶ P(z,j)))&amp;quot; by (rule allE)&lt;br /&gt;
  hence &amp;quot;∀z. (P(z,l) ⟶ P(z,j))&amp;quot; using assms(2) by (rule mp)&lt;br /&gt;
  hence &amp;quot;P(c,l) ⟶ P(c,j)&amp;quot; by (rule allE)&lt;br /&gt;
  thus &amp;quot;P(c,j)&amp;quot; using assms(3) by (rule mp)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Formalizar, y decidir la corrección, del siguiente&lt;br /&gt;
  argumento &lt;br /&gt;
     Los aficionados al fútbol aplauden a cualquier futbolista&lt;br /&gt;
     extranjero. Juanito no aplaude a futbolistas extranjeros. Por&lt;br /&gt;
     tanto, si hay algún futbolista extranjero nacionalizado español,&lt;br /&gt;
     Juanito no es aficionado al fútbol.&lt;br /&gt;
  Usar Af(x)   para x es aficicionado al fútbol&lt;br /&gt;
       Ap(x,y) para x aplaude a y&lt;br /&gt;
       E(x)    para x es un futbolista extranjero&lt;br /&gt;
       N(x)    para x es un futbolista nacionalizado español&lt;br /&gt;
       j       para Juanito&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
(* danrodcha  ferrenseg *)&lt;br /&gt;
(* danrodcha: Me gusta más la formalización de ana prado, aunque &lt;br /&gt;
    son equivalentes *)&lt;br /&gt;
lemma ej_4:&lt;br /&gt;
  assumes &amp;quot;∀x y. Af(x) ∧ E(y) ⟶ Ap(x,y)&amp;quot;&lt;br /&gt;
          &amp;quot;∀x. Ap(j,x) ⟶ ¬ E(x)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;(∃x. E(x) ∧ N(x)) ⟶ ¬Af(j)&amp;quot;&lt;br /&gt;
  proof (rule impI)&lt;br /&gt;
  assume &amp;quot;∃x. E(x) ∧ N(x)&amp;quot;&lt;br /&gt;
    then obtain a where &amp;quot;E(a) ∧ N(a)&amp;quot; by (rule exE)&lt;br /&gt;
    hence &amp;quot;E(a)&amp;quot; by (rule conjE)&lt;br /&gt;
    show &amp;quot;¬ Af(j)&amp;quot;&lt;br /&gt;
    proof (rule notI)&lt;br /&gt;
      assume &amp;quot;Af(j)&amp;quot;&lt;br /&gt;
      hence &amp;quot;Af(j) ∧ E(a)&amp;quot; using `E(a)` by (rule conjI)&lt;br /&gt;
      have &amp;quot;∀y. Af(j) ∧ E(y) ⟶ Ap(j,y)&amp;quot; using assms(1) by (rule allE)&lt;br /&gt;
      hence &amp;quot;Af(j) ∧ E(a) ⟶ Ap(j,a)&amp;quot; by (rule allE)&lt;br /&gt;
      hence &amp;quot;Ap(j,a)&amp;quot; using `Af(j) ∧ E(a)` by (rule mp)&lt;br /&gt;
      have &amp;quot;Ap(j,a) ⟶ ¬ E(a)&amp;quot; using assms(2) by (rule allE)&lt;br /&gt;
      hence &amp;quot;¬ E(a)&amp;quot; using `Ap(j,a)` by (rule mp)&lt;br /&gt;
      thus False using `E(a)` by (rule notE)&lt;br /&gt;
    qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marcarmor13*)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_4:&lt;br /&gt;
  assumes 1: &amp;quot;∀x y. Af(x) ∧ E(y) ⟶ Ap(x,y)&amp;quot;&lt;br /&gt;
  assumes 2: &amp;quot;¬(∃x. E(x) ∧ Ap(j,x))&amp;quot;&lt;br /&gt;
  shows &amp;quot;(∃x. E(x) ∧ N(x)) ⟶ ¬Af(j)&amp;quot;  &lt;br /&gt;
  proof (rule impI)&lt;br /&gt;
  assume 3: &amp;quot;∃x. E(x) ∧ N(x)&amp;quot;&lt;br /&gt;
    then obtain a where 4: &amp;quot;E(a) ∧ N(a)&amp;quot; by (rule exE)&lt;br /&gt;
    then have 5: &amp;quot;E(a)&amp;quot; by (rule conjunct1)&lt;br /&gt;
    show 6: &amp;quot;¬Af(j)&amp;quot;&lt;br /&gt;
    proof (rule notI)&lt;br /&gt;
      assume 7: &amp;quot;Af(j)&amp;quot;&lt;br /&gt;
      then have 8: &amp;quot;Af(j) ∧ E(a)&amp;quot; using 5 by (rule conjI)&lt;br /&gt;
      have 9: &amp;quot;∀y. Af(j) ∧ E(y) ⟶ Ap(j,y)&amp;quot; using 1 by (rule allE)&lt;br /&gt;
      have 10: &amp;quot;Af(j) ∧ E(a) ⟶ Ap(j,a)&amp;quot; using 9 by (rule allE)&lt;br /&gt;
      have 11: &amp;quot;Ap(j,a)&amp;quot; using 10 8 by (rule mp)&lt;br /&gt;
      have 12: &amp;quot;E(a) ∧ Ap(j,a)&amp;quot; using 5 11 by (rule conjI)&lt;br /&gt;
      have 13: &amp;quot;∃x. E(x) ∧ Ap(j,x)&amp;quot; using 12 by (rule exI)&lt;br /&gt;
      show &amp;quot;False&amp;quot; using 2 13 by (rule notE)&lt;br /&gt;
    qed&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
&lt;br /&gt;
(* Este auxiliar ya se probó en el ejercicio 4 de la rel 8 *)&lt;br /&gt;
lemma aux4: &amp;quot;¬(p∧q) ⟹¬p ∨ ¬q&amp;quot;&lt;br /&gt;
by (auto)&lt;br /&gt;
&lt;br /&gt;
lemma ej_4:&lt;br /&gt;
  assumes &amp;quot;∀x y. Af(x) ∧ E(y) ⟶ Ap(x,y)&amp;quot;&lt;br /&gt;
          &amp;quot;∀ x.(E(x) ⟶ ¬ Ap(j,x))&amp;quot;&lt;br /&gt;
  shows   &amp;quot;(∃x. E(x) ∧ N(x)) ⟶ ¬Af(j)&amp;quot;&lt;br /&gt;
proof (rule impI)&lt;br /&gt;
  { assume &amp;quot;∃x. E(x) ∧ N(x)&amp;quot;&lt;br /&gt;
    then obtain a where 1: &amp;quot;E(a) ∧ N(a)&amp;quot; by (rule exE)&lt;br /&gt;
    have &amp;quot;∀ y. Af(j) ∧ E(y) ⟶ Ap(j,y)&amp;quot; using assms(1)  by (rule allE)&lt;br /&gt;
    hence 2: &amp;quot;Af(j) ∧ E(a) ⟶ Ap(j,a)&amp;quot; by (rule allE)&lt;br /&gt;
    have 3: &amp;quot;E(a)&amp;quot; using 1 by (rule conjunct1)&lt;br /&gt;
    have 4: &amp;quot;E(a) ⟶ ¬ Ap(j,a)&amp;quot; using assms(2) by (rule allE)&lt;br /&gt;
    have 5: &amp;quot;¬ Ap(j,a)&amp;quot; using 4 3 by (rule mp)&lt;br /&gt;
    have &amp;quot;¬(Af(j) ∧ E(a))&amp;quot; using 2 5 by (rule mt)&lt;br /&gt;
    hence &amp;quot;¬ Af(j) ∨ ¬ E(a)&amp;quot; by (rule aux4)&lt;br /&gt;
    thus &amp;quot; ¬Af(j)&amp;quot;&lt;br /&gt;
      proof (rule disjE)&lt;br /&gt;
      {assume &amp;quot;¬Af(j)&amp;quot;&lt;br /&gt;
        thus  &amp;quot;¬Af(j)&amp;quot; by this}&lt;br /&gt;
      next&lt;br /&gt;
      {assume 6: &amp;quot;¬ E(a)&amp;quot;&lt;br /&gt;
        show &amp;quot;¬ Af(j)&amp;quot; using 6 3 by (rule notE)}&lt;br /&gt;
      qed}&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_4_1: &lt;br /&gt;
  assumes &amp;quot;∀x y. Af(x) ∧ E(y) ⟶ Ap(x,y)&amp;quot;&lt;br /&gt;
          &amp;quot;∀x. E(x)⟶ ¬Ap(j,x)&amp;quot;          &lt;br /&gt;
  shows   &amp;quot;(∃x. N(x) ∧ E(x)) ⟶ ¬Af(j)&amp;quot;&lt;br /&gt;
proof&lt;br /&gt;
  assume &amp;quot;∃x. N(x) ∧ E(x)&amp;quot;&lt;br /&gt;
  then obtain b where &amp;quot;N(b) ∧ E(b)&amp;quot; by (rule exE)&lt;br /&gt;
  hence &amp;quot;E(b)&amp;quot; by (rule conjunct2)&lt;br /&gt;
  have &amp;quot;E(b)⟶ ¬Ap(j,b)&amp;quot; using assms(2) by (rule allE)&lt;br /&gt;
  hence &amp;quot;¬Ap(j,b)&amp;quot; using `E(b)` by (rule mp)&lt;br /&gt;
  have &amp;quot;∀y. Af(j) ∧ E(y) ⟶ Ap(j,y)&amp;quot; using assms(1) by (rule allE)&lt;br /&gt;
  hence &amp;quot;Af(j) ∧ E(b) ⟶ Ap(j,b)&amp;quot;  by (rule allE)&lt;br /&gt;
  hence &amp;quot;¬Ap(j,b) ⟶ ¬(Af(j) ∧ E(b))&amp;quot; by (rule Set.not_mono)&lt;br /&gt;
  hence &amp;quot;¬(Af(j) ∧ E(b))&amp;quot;  using `¬Ap(j,b)`  by (rule mp)&lt;br /&gt;
  show &amp;quot;¬Af(j)&amp;quot; &lt;br /&gt;
  proof&lt;br /&gt;
  assume &amp;quot;Af(j)&amp;quot; &lt;br /&gt;
  hence &amp;quot;Af(j) ∧ E(b)&amp;quot; using `E(b)` by (rule  conjI)&lt;br /&gt;
  show False using `¬(Af(j) ∧ E(b))` `Af(j) ∧ E(b)` by (rule notE) &lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Formalizar, y decidir la corrección, del siguiente&lt;br /&gt;
  argumento &lt;br /&gt;
     El esposo de la hermana de Toni es Roberto. La hermana de Toni es&lt;br /&gt;
     María. Por tanto, el esposo de María es Roberto. &lt;br /&gt;
  Usar e(x) para el esposo de x&lt;br /&gt;
       h    para la hermana de Toni&lt;br /&gt;
       m    para María&lt;br /&gt;
       r    para Roberto&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_5:&lt;br /&gt;
  assumes 1: &amp;quot;e(h) = r&amp;quot; &lt;br /&gt;
  assumes 2: &amp;quot;h = m&amp;quot;&lt;br /&gt;
  shows &amp;quot;e(m) = r&amp;quot;   &lt;br /&gt;
proof -&lt;br /&gt;
  have 3: &amp;quot;e(h) = e(m)&amp;quot; using 2 by (rule arg_cong)&lt;br /&gt;
  have 4: &amp;quot;e(m) = e(h)&amp;quot; using 3 by (rule sym)&lt;br /&gt;
  then show &amp;quot;e(m) = r&amp;quot; using 1 by (rule trans)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha anaprarod crigomgom ferrenseg marcarmor13*)&lt;br /&gt;
lemma ej_5:&lt;br /&gt;
  assumes &amp;quot;e(h) = r&amp;quot; and&lt;br /&gt;
          &amp;quot;h = m&amp;quot;&lt;br /&gt;
  shows   &amp;quot;e(m) = r&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    show &amp;quot;e(m) = r&amp;quot; using assms(2) assms(1) by (rule subst)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
lemma ejercicio_5_1: &lt;br /&gt;
  assumes &amp;quot;e(h)&amp;quot;&lt;br /&gt;
          &amp;quot;h=m&amp;quot;          &lt;br /&gt;
  shows   &amp;quot;e(m)&amp;quot;&lt;br /&gt;
proof-&lt;br /&gt;
  show &amp;quot;e(m)&amp;quot; using assms(1) assms(2) by (rule HOL.back_subst)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
emma ejercicio_5_2: &lt;br /&gt;
  assumes &amp;quot;e(h)&amp;quot;&lt;br /&gt;
          &amp;quot;h=m&amp;quot;          &lt;br /&gt;
  shows   &amp;quot;e(m)&amp;quot;&lt;br /&gt;
proof-&lt;br /&gt;
  show &amp;quot;e(m)&amp;quot; using assms(2) assms(1) by (rule HOL.subst)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
lemma ejercicio_5_3: &lt;br /&gt;
  assumes &amp;quot;e(h)&amp;quot;&lt;br /&gt;
          &amp;quot;h=m&amp;quot;          &lt;br /&gt;
  shows   &amp;quot;e(m)&amp;quot;&lt;br /&gt;
proof-&lt;br /&gt;
  have &amp;quot;e(h) = e(m)&amp;quot; using assms(2) by (rule arg_cong)&lt;br /&gt;
  show &amp;quot;e(m)&amp;quot; using `e(h)` `e(h) = e(m)` by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_9&amp;diff=1411</id>
		<title>Relación 9</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_9&amp;diff=1411"/>
		<updated>2017-01-31T09:36:24Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R9: Deducción natural LPO en Isabelle/HOL *}&lt;br /&gt;
&lt;br /&gt;
theory R9_Deduccion_natural_LPO&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  Demostrar o refutar los siguientes lemas usando sólo las reglas&lt;br /&gt;
  básicas de deducción natural de la lógica proposicional, de los&lt;br /&gt;
  cuantificadores y de la igualdad: &lt;br /&gt;
  · conjI:      ⟦P; Q⟧ ⟹ P ∧ Q&lt;br /&gt;
  · conjunct1:  P ∧ Q ⟹ P&lt;br /&gt;
  · conjunct2:  P ∧ Q ⟹ Q  &lt;br /&gt;
  · notnotD:    ¬¬ P ⟹ P&lt;br /&gt;
  · mp:         ⟦P ⟶ Q; P⟧ ⟹ Q &lt;br /&gt;
  · impI:       (P ⟹ Q) ⟹ P ⟶ Q&lt;br /&gt;
  · disjI1:     P ⟹ P ∨ Q&lt;br /&gt;
  · disjI2:     Q ⟹ P ∨ Q&lt;br /&gt;
  · disjE:      ⟦P ∨ Q; P ⟹ R; Q ⟹ R⟧ ⟹ R &lt;br /&gt;
  · FalseE:     False ⟹ P&lt;br /&gt;
  · notE:       ⟦¬P; P⟧ ⟹ R&lt;br /&gt;
  · notI:       (P ⟹ False) ⟹ ¬P&lt;br /&gt;
  · iffI:       ⟦P ⟹ Q; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
  · iffD1:      ⟦Q = P; Q⟧ ⟹ P &lt;br /&gt;
  · iffD2:      ⟦P = Q; Q⟧ ⟹ P&lt;br /&gt;
  · ccontr:     (¬P ⟹ False) ⟹ P&lt;br /&gt;
&lt;br /&gt;
  · allI:       ⟦∀x. P x; P x ⟹ R⟧ ⟹ R&lt;br /&gt;
  · allE:       (⋀x. P x) ⟹ ∀x. P x&lt;br /&gt;
  · exI:        P x ⟹ ∃x. P x&lt;br /&gt;
  · exE:        ⟦∃x. P x; ⋀x. P x ⟹ Q⟧ ⟹ Q&lt;br /&gt;
&lt;br /&gt;
  · refl:       t = t&lt;br /&gt;
  · subst:      ⟦s = t; P s⟧ ⟹ P t&lt;br /&gt;
  · trans:      ⟦r = s; s = t⟧ ⟹ r = t&lt;br /&gt;
  · sym:        s = t ⟹ t = s&lt;br /&gt;
  · not_sym:    t ≠ s ⟹ s ≠ t&lt;br /&gt;
  · ssubst:     ⟦t = s; P s⟧ ⟹ P t&lt;br /&gt;
  · box_equals: ⟦a = b; a = c; b = d⟧ ⟹ a: = d&lt;br /&gt;
  · arg_cong:   x = y ⟹ f x = f y&lt;br /&gt;
  · fun_cong:   f = g ⟹ f x = g x&lt;br /&gt;
  · cong:       ⟦f = g; x = y⟧ ⟹ f x = g y&lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  Se usarán las reglas notnotI, mt y not_ex que demostramos a continuación.&lt;br /&gt;
  *}&lt;br /&gt;
&lt;br /&gt;
lemma notnotI: &amp;quot;P ⟹ ¬¬ P&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma mt: &amp;quot;⟦F ⟶ G; ¬G⟧ ⟹ ¬F&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma no_ex: &amp;quot;¬(∃x. P(x)) ⟹ ∀x. ¬P(x)&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Demostrar&lt;br /&gt;
       P a ⟶ (∃x. Q x) ⊢ ∃x. P a ⟶ Q x &lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_1: &lt;br /&gt;
  fixes P Q :: &amp;quot;&amp;#039;b ⇒ bool&amp;quot; &lt;br /&gt;
  assumes &amp;quot;P a ⟶ (∃x. Q x)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;∃x. P a ⟶ Q x&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
(* migtermor ferrenseg juacabsou josgarsan pablucoto marcarmor13*)&lt;br /&gt;
lemma ejercicio_1: &lt;br /&gt;
  fixes P Q :: &amp;quot;&amp;#039;b ⇒ bool&amp;quot; &lt;br /&gt;
  assumes &amp;quot;P a ⟶ (∃x. Q x)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;∃x. P a ⟶ Q x&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
 { assume 1: &amp;quot;P a&amp;quot;&lt;br /&gt;
   have 2: &amp;quot;∃x. Q x&amp;quot; using assms 1 by (rule mp)} &lt;br /&gt;
 then obtain b where 3: &amp;quot;Q b&amp;quot; by (rule exE)          &lt;br /&gt;
   (* No sé por qué salta un aviso aquí. Aún así, sin esto no se&lt;br /&gt;
      finaliza correctamente la demostración, y con ello sí. *) &lt;br /&gt;
 then have 4: &amp;quot;(P a) ⟶ (Q b)&amp;quot; by (rule impI)&lt;br /&gt;
 then show 5: &amp;quot;∃x. P a ⟶ Q x&amp;quot; by (rule exI)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim bowma rubgonmar *)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_1_1:  &lt;br /&gt;
  assumes 1: &amp;quot;P a ⟶ (∃x. Q x)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;∃x. P a ⟶ Q x&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
   {assume 2: &amp;quot;P a&amp;quot;&lt;br /&gt;
    have 3: &amp;quot;(∃x. Q x)&amp;quot; using 1 2 by (rule mp)&lt;br /&gt;
    obtain b where 4: &amp;quot;Q b&amp;quot; using 3 by (rule exE)&lt;br /&gt;
    then have 5: &amp;quot;P a ⟶ Q b&amp;quot; by (rule impI)&lt;br /&gt;
    then have 6: &amp;quot;∃x. P a ⟶ Q x&amp;quot; by (rule exI)}&lt;br /&gt;
   then show &amp;quot;∃x. P a ⟶ Q x&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* crigomgom *)&lt;br /&gt;
lemma ejercicio_1_2: &lt;br /&gt;
  assumes 0: &amp;quot;P a ⟶ (∃x. Q x)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;∃x. P a ⟶ Q x&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;¬(P a) ∨ P a&amp;quot; by (rule excluded_middle)&lt;br /&gt;
  then show &amp;quot;∃x. P a ⟶ Q x&amp;quot;&lt;br /&gt;
  proof (rule disjE)&lt;br /&gt;
    assume 1 : &amp;quot;¬(P a)&amp;quot;&lt;br /&gt;
    {assume 2 : &amp;quot;P a&amp;quot;&lt;br /&gt;
     have  &amp;quot;Q b&amp;quot; using 1 2 by (rule notE)}&lt;br /&gt;
     then have &amp;quot;P a ⟶ Q b&amp;quot; by (rule impI)&lt;br /&gt;
     then show &amp;quot;∃x. P a ⟶ Q x&amp;quot; by (rule exI)&lt;br /&gt;
  next&lt;br /&gt;
    assume 3 : &amp;quot;P a&amp;quot;&lt;br /&gt;
    have  &amp;quot;∃x. Q x&amp;quot; using 0 3 by (rule mp)&lt;br /&gt;
    then obtain b where &amp;quot;Q b&amp;quot;  by (rule exE)&lt;br /&gt;
    then have  &amp;quot;P a ⟶ Q b&amp;quot; by (rule impI)&lt;br /&gt;
    then show  &amp;quot;∃x. P a ⟶ Q x&amp;quot; by (rule exI)&lt;br /&gt;
  qed&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 *)&lt;br /&gt;
(* Entre corchetes se demuestra que efectivamente existe un caso *)&lt;br /&gt;
lemma ejercicio_1_3: &lt;br /&gt;
  fixes P Q :: &amp;quot;&amp;#039;b ⇒ bool&amp;quot; &lt;br /&gt;
  assumes &amp;quot;P a ⟶ (∃x. Q x)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;∃x. P a ⟶ Q x&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
	{	&lt;br /&gt;
		assume &amp;quot;P a&amp;quot;&lt;br /&gt;
		with assms have &amp;quot;∃x. Q x&amp;quot; by (rule mp)&lt;br /&gt;
		then obtain x where &amp;quot;Q x&amp;quot; by (rule exE)&lt;br /&gt;
		hence &amp;quot;P a ⟶ Q x&amp;quot; by (rule impI)&lt;br /&gt;
		hence &amp;quot;∃x. P a ⟶ Q x&amp;quot; by (rule exI) &lt;br /&gt;
	}&lt;br /&gt;
  thus ?thesis by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Usa simp *)&lt;br /&gt;
&lt;br /&gt;
(* antsancab1 *)&lt;br /&gt;
lemma ejercicio_1_4:&lt;br /&gt;
  fixes P Q :: &amp;quot;&amp;#039;b ⇒ bool&amp;quot;&lt;br /&gt;
  assumes &amp;quot;P a ⟶ (∃x. Q x)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;∃x. P a ⟶ Q x&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  { assume 1: &amp;quot;P a&amp;quot;&lt;br /&gt;
    have 2: &amp;quot;∃x. Q x&amp;quot; using assms 1 by (rule mp)&lt;br /&gt;
    obtain b where &amp;quot;Q b&amp;quot; using 2 by (rule exE)&lt;br /&gt;
    then have &amp;quot;P a ⟶ Q b&amp;quot; by (rule impI)&lt;br /&gt;
    then have &amp;quot;∃x. P a ⟶ Q x&amp;quot; by (rule exI)&lt;br /&gt;
  }&lt;br /&gt;
  then show &amp;quot;∃x. P a ⟶ Q x&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
lemma ejercicio_1_5: &lt;br /&gt;
  fixes P Q :: &amp;quot;&amp;#039;b ⇒ bool&amp;quot; &lt;br /&gt;
  assumes &amp;quot;P a ⟶ (∃x. Q x)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;∃x. P a ⟶ Q x&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;¬(P a) ∨ P a&amp;quot; by (rule excluded_middle)&lt;br /&gt;
  thus &amp;quot;∃x. P a ⟶ Q x&amp;quot;&lt;br /&gt;
  proof (rule disjE)&lt;br /&gt;
    assume &amp;quot;¬(P a)&amp;quot;&lt;br /&gt;
    have &amp;quot;P a ⟶ Q a&amp;quot;&lt;br /&gt;
    proof (rule impI)&lt;br /&gt;
      assume &amp;quot;P a&amp;quot;&lt;br /&gt;
      with `¬(P a)` show &amp;quot;Q a&amp;quot; by (rule notE)&lt;br /&gt;
    qed&lt;br /&gt;
    thus &amp;quot;∃x. P a ⟶ Q x&amp;quot; by (rule exI)&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;P a&amp;quot;&lt;br /&gt;
    with assms have &amp;quot;∃x. Q x&amp;quot; by (rule mp)&lt;br /&gt;
    then obtain b where &amp;quot;Q b&amp;quot; by (rule exE)&lt;br /&gt;
    have &amp;quot;P a ⟶ Q b&amp;quot;&lt;br /&gt;
    proof (rule impI)&lt;br /&gt;
      assume &amp;quot;P a&amp;quot;&lt;br /&gt;
      note `Q b` &lt;br /&gt;
      thus &amp;quot;Q b&amp;quot; by this&lt;br /&gt;
    qed&lt;br /&gt;
    thus &amp;quot;∃x. P a ⟶ Q x&amp;quot; by (rule exI)&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Demostrar&lt;br /&gt;
       {∀x y z. R x y ∧ R y z ⟶ R x z, &lt;br /&gt;
        ∀x. ¬(R x x)}&lt;br /&gt;
       ⊢ ∀x y. R x y ⟶ ¬(R y x)&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* migtermor ferrenseg ivamenjim marcarmor13 serrodcal juacabsou&lt;br /&gt;
   marpoldia1 crigomgom bowma josgarsan rubgonmar pablucoto antsancab1 *) &lt;br /&gt;
lemma ejercicio_2: &lt;br /&gt;
  fixes R :: &amp;quot;&amp;#039;b ⇒ &amp;#039;b ⇒ bool&amp;quot; &lt;br /&gt;
  assumes 1: &amp;quot;∀x y z. R x y ∧ R y z ⟶ R x z&amp;quot;&lt;br /&gt;
  assumes 2: &amp;quot;∀x. ¬(R x x)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;∀x y. R x y ⟶ ¬(R y x)&amp;quot;&lt;br /&gt;
proof (rule allI)&lt;br /&gt;
fix x&lt;br /&gt;
show &amp;quot;∀y. R x y ⟶ ¬(R y x)&amp;quot; &lt;br /&gt;
 proof (rule allI) &lt;br /&gt;
  fix y&lt;br /&gt;
  {assume 3: &amp;quot;R x y&amp;quot;&lt;br /&gt;
   {assume 4: &amp;quot;R y x&amp;quot;&lt;br /&gt;
    have 5: &amp;quot;R x y ∧ R y x&amp;quot; using 3 4 by (rule conjI)&lt;br /&gt;
    also have 6: &amp;quot;∀ z1 z2. R x z1 ∧ R z1 z2 ⟶ R x z2&amp;quot; using 1 by (rule allE)&lt;br /&gt;
    then have 7: &amp;quot;∀ z. R x y ∧ R y z ⟶ R x z&amp;quot; by (rule allE)&lt;br /&gt;
    then have 8: &amp;quot;R x y ∧ R y x ⟶ R x x&amp;quot; by (rule allE)&lt;br /&gt;
    then have 9: &amp;quot;R x x&amp;quot; using 5 by (rule mp)&lt;br /&gt;
    have 10: &amp;quot;¬(R x x)&amp;quot; using 2 by (rule allE)&lt;br /&gt;
    then have 11: &amp;quot;False&amp;quot; using 9 by (rule notE)}&lt;br /&gt;
  then have 12: &amp;quot;¬ (R y x)&amp;quot; by (rule notI)}&lt;br /&gt;
  thus &amp;quot;R x y ⟶ ¬(R y x)&amp;quot; by (rule impI)&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Semejante al anterior, pero indicando que se pruebe por la regla&lt;br /&gt;
  correspondiente *) &lt;br /&gt;
lemma ejercicio_2_1: &lt;br /&gt;
  assumes 1: &amp;quot;∀x y z. R x y ∧ R y z ⟶ R x z&amp;quot;&lt;br /&gt;
  assumes 2: &amp;quot;∀x. ¬(R x x)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;∀x y. R x y ⟶ ¬(R y x)&amp;quot;&lt;br /&gt;
proof (rule allI)&lt;br /&gt;
fix x&lt;br /&gt;
show &amp;quot;∀y. R x y ⟶ ¬(R y x)&amp;quot; &lt;br /&gt;
 proof (rule allI) &lt;br /&gt;
  fix y&lt;br /&gt;
  {assume 3: &amp;quot;R x y&amp;quot;&lt;br /&gt;
   {assume 4: &amp;quot;R y x&amp;quot;&lt;br /&gt;
    have 5: &amp;quot;R x y ∧ R y x&amp;quot; using 3 4 ..&lt;br /&gt;
    have 6: &amp;quot;∀ y z. R x y ∧ R y z ⟶ R x z&amp;quot; using 1 ..&lt;br /&gt;
    then have 7: &amp;quot;∀ z. R x y ∧ R y z ⟶ R x z&amp;quot; ..&lt;br /&gt;
    then have 8: &amp;quot;R x y ∧ R y x ⟶ R x x&amp;quot; ..&lt;br /&gt;
    then have 9: &amp;quot;R x x&amp;quot; using 5 ..&lt;br /&gt;
    have 10: &amp;quot;¬(R x x)&amp;quot; using 2 ..&lt;br /&gt;
    then have 11: &amp;quot;False&amp;quot; using 9 ..}&lt;br /&gt;
  then have 12: &amp;quot;¬ (R y x)&amp;quot; ..}&lt;br /&gt;
  thus &amp;quot;R x y ⟶ ¬(R y x)&amp;quot; ..&lt;br /&gt;
 qed&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_2_2: &lt;br /&gt;
  assumes &amp;quot;∀x y z. R x y ∧ R y z ⟶ R x z&amp;quot;&lt;br /&gt;
          &amp;quot;∀x. ¬(R x x)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;∀x y. R x y ⟶ ¬(R y x)&amp;quot;&lt;br /&gt;
proof &lt;br /&gt;
  fix a&lt;br /&gt;
  show &amp;quot;∀y. R a y ⟶ ¬(R y a)&amp;quot;&lt;br /&gt;
    proof&lt;br /&gt;
    fix b&lt;br /&gt;
      show &amp;quot;R a b ⟶ ¬(R b a)&amp;quot;&lt;br /&gt;
      proof&lt;br /&gt;
      assume &amp;quot;R a b&amp;quot;&lt;br /&gt;
       show &amp;quot;¬(R b a)&amp;quot;&lt;br /&gt;
       proof&lt;br /&gt;
       assume &amp;quot;R b a&amp;quot;&lt;br /&gt;
         have &amp;quot;∀y z. R a y ∧ R y z ⟶ R a z&amp;quot; using assms(1) by (rule allE)&lt;br /&gt;
         hence &amp;quot;∀z. R a b ∧ R b z ⟶ R a z&amp;quot; by (rule allE)&lt;br /&gt;
         hence &amp;quot;R a b ∧ R b a ⟶ R a a&amp;quot; by (rule allE)&lt;br /&gt;
         have &amp;quot;R a b ∧ R b a&amp;quot; using `R a b` `R b a` by (rule conjI)&lt;br /&gt;
         have &amp;quot;R a a&amp;quot; using `R a b ∧ R b a ⟶ R a a` `R a b ∧ R b a` by (rule mp)&lt;br /&gt;
         have &amp;quot;¬(R a a)&amp;quot; using assms(2) by (rule allE)&lt;br /&gt;
         show False using `¬(R a a)` `R a a` by (rule notE) &lt;br /&gt;
       qed&lt;br /&gt;
     qed&lt;br /&gt;
   qed&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Demostrar o refutar&lt;br /&gt;
       (∀x. ∃y. P x y) ⟶ (∃y. ∀x. P x y)&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg paupeddeg serrodcal juacabsou marpoldia1&lt;br /&gt;
   crigomgom bowma josgarsan rubgonmar pablucoto marcarmor13 antsancab1 pabrodmac *) &lt;br /&gt;
lemma ejercicio_3: &lt;br /&gt;
  assumes &amp;quot;(∀x. ∃y. P x y)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;(∃y. ∀x. P x y)&amp;quot;&lt;br /&gt;
  quickcheck&lt;br /&gt;
oops  &lt;br /&gt;
&lt;br /&gt;
(* Y se encuentra el contraejemplo: P = (λx. undefined)(a1 := {a2}, a2 := {a1}) *)&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
fun P :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;P x y = (x=y)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio3:&lt;br /&gt;
 &amp;quot;(∀x. ∃y. P x y) ⟶ (∃y. ∀x. P x y)&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma ejercicio_3_3:&lt;br /&gt;
  shows   &amp;quot;(∀x. ∃y. P x y) ⟶ (∃y. ∀x. P x y)&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Demostrar o refutar&lt;br /&gt;
     {∀x. P a x x, &lt;br /&gt;
      ∀x y z. P x y z ⟶ P (f x) y (f z)⟧&lt;br /&gt;
     ⊢ ∃z. P (f a) z (f (f a))&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg ivamenjim *)&lt;br /&gt;
lemma ejercicio_4:&lt;br /&gt;
  fixes P :: &amp;quot;&amp;#039;b ⇒ &amp;#039;b ⇒ &amp;#039;b ⇒ bool&amp;quot; &lt;br /&gt;
  assumes 1: &amp;quot;∀x. P a x x&amp;quot; and &lt;br /&gt;
          2: &amp;quot;∀x y z. P x y z ⟶ P (f x) y (f z)&amp;quot;&lt;br /&gt;
  shows &amp;quot;∃z. P (f a) z (f (f a))&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have 4:&amp;quot;P a (f a) (f a)&amp;quot; using 1 ..&lt;br /&gt;
  also have 5:&amp;quot;∀y z. P a y z ⟶ P (f a) y (f z)&amp;quot; using 2 ..&lt;br /&gt;
  then have 6:&amp;quot;∀z. P a (f a) z ⟶ P (f a) (f a) (f z)&amp;quot; ..&lt;br /&gt;
  then have 7:&amp;quot;P a (f a) (f a) ⟶ P (f a) (f a) (f (f a))&amp;quot; ..&lt;br /&gt;
  also have 8:&amp;quot;P (f a) (f a) (f (f a))&amp;quot; using 7 4 by (rule mp)&lt;br /&gt;
  then show &amp;quot;∃z. P (f a) z (f (f a))&amp;quot; ..&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor serrodcal crigomgom pablucoto marcarmor13*)&lt;br /&gt;
lemma ejercicio_4_2: &lt;br /&gt;
  fixes P :: &amp;quot;&amp;#039;b ⇒ &amp;#039;b ⇒ &amp;#039;b ⇒ bool&amp;quot; &lt;br /&gt;
  assumes 1: &amp;quot;∀x. P a x x&amp;quot;&lt;br /&gt;
  assumes 2: &amp;quot;∀x y z.  P x y z ⟶ P (f x) y (f z)&amp;quot;&lt;br /&gt;
  shows   &amp;quot; ∃z. P (f a) z (f (f a))&amp;quot;&lt;br /&gt;
proof (rule exI)&lt;br /&gt;
 have 3: &amp;quot;P a (f a) (f a)&amp;quot; using 1 by (rule allE)&lt;br /&gt;
 have 4: &amp;quot;∀y z.  P a y z ⟶ P (f a) y (f z)&amp;quot; using 2 by (rule allE)&lt;br /&gt;
 then have 5: &amp;quot;∀z.  P a (f a) z ⟶ P (f a) (f a) (f z)&amp;quot; by (rule allE)&lt;br /&gt;
 then have 6: &amp;quot;P a (f a) (f a) ⟶ P (f a) (f a) (f (f a))&amp;quot; by (rule allE)&lt;br /&gt;
 then show &amp;quot;P (f a) (f a) (f (f a))&amp;quot; using 3 by (rule mp)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg juacabsou marpoldia1 bowma rubgonmar josgarsan*)&lt;br /&gt;
lemma ejercicio_4_3:&lt;br /&gt;
  fixes P :: &amp;quot;&amp;#039;b ⇒ &amp;#039;b ⇒ &amp;#039;b ⇒ bool&amp;quot; &lt;br /&gt;
  assumes &amp;quot; ∀x. P a x x &amp;quot; &lt;br /&gt;
          &amp;quot; ∀x y z. P x y z ⟶ P (f x) y (f z)&amp;quot;&lt;br /&gt;
  shows &amp;quot;∃z. P (f a) z (f (f a))&amp;quot;&lt;br /&gt;
proof&lt;br /&gt;
  have &amp;quot;∀ y z. P a y z ⟶ P (f a) y (f z)&amp;quot; using assms(2) by (rule allE)&lt;br /&gt;
  hence &amp;quot;∀z. P a (f a) z ⟶ P (f a) (f a) (f z)&amp;quot;  by (rule allE)&lt;br /&gt;
  hence &amp;quot;P a (f a) (f a) ⟶ P (f a) (f a) (f (f a))&amp;quot;  by (rule allE)&lt;br /&gt;
  have &amp;quot;P a (f a) (f a)&amp;quot; using assms(1) by (rule allE)&lt;br /&gt;
  show &amp;quot;P (f a) (f a) (f (f a))&amp;quot; &lt;br /&gt;
    using `P a (f a) (f a) ⟶ P (f a) (f a) (f (f a))` `P a (f a) (f a)`  &lt;br /&gt;
    by (rule mp)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* antsancab1 *)&lt;br /&gt;
lemma ejercicio_4:&lt;br /&gt;
  fixes P :: &amp;quot;&amp;#039;b ⇒ &amp;#039;b ⇒ &amp;#039;b ⇒ bool&amp;quot;&lt;br /&gt;
  assumes 1: &amp;quot;∀x. P a x x&amp;quot;&lt;br /&gt;
  assumes 2: &amp;quot;∀x y z. P x y z ⟶ P (f x) y (f z)&amp;quot;&lt;br /&gt;
  shows &amp;quot;∃z. P (f a) z (f (f a))&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have 3: &amp;quot;P a (f a) (f a)&amp;quot; using 1 by (rule allE)&lt;br /&gt;
  have 4: &amp;quot;∀y z. P a y z ⟶ P (f a) y (f z)&amp;quot; using 2 by (rule allE)&lt;br /&gt;
  then have 5: &amp;quot;∀z. P a (f a) z ⟶ P (f a) (f a) (f z)&amp;quot; by (rule allE)&lt;br /&gt;
  then have 6: &amp;quot;P a (f a) (f a) ⟶ P (f a) (f a) (f (f a))&amp;quot; by (rule allE)&lt;br /&gt;
  also have &amp;quot;P (f a) (f a) (f (f a))&amp;quot; using 6 3 by (rule mp)&lt;br /&gt;
  then show &amp;quot;∃z. P (f a) z (f (f a))&amp;quot; ..&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
lemma ejercicio_4_4: &lt;br /&gt;
  assumes &amp;quot;∀x. P a x x&amp;quot;&lt;br /&gt;
          &amp;quot;∀x y z. P x y z ⟶ P (f x) y (f z)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;∃z. P (f a) z (f (f a))&amp;quot;&lt;br /&gt;
proof&lt;br /&gt;
   have &amp;quot;P a (f a) (f a)&amp;quot; using assms(1) by (rule allE)&lt;br /&gt;
   have &amp;quot;∀y z. P a y z ⟶ P (f a) y (f z)&amp;quot; using assms(2) by (rule allE)&lt;br /&gt;
   hence &amp;quot;∀z. P a (f a) z ⟶ P (f a) (f a) (f z)&amp;quot; by (rule allE)&lt;br /&gt;
   hence &amp;quot;P a (f a) (f a) ⟶ P (f a) (f a) (f (f a))&amp;quot; by (rule allE)&lt;br /&gt;
   thus &amp;quot;P (f a) (f a) (f (f a))&amp;quot; using `P a (f a) (f a)` by (rule mp) &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Demostrar o refutar&lt;br /&gt;
     {∀y. Q a y, &lt;br /&gt;
      ∀x y. Q x y ⟶ Q (s x) (s y)} &lt;br /&gt;
     ⊢ ∃z. Qa z ∧ Q z (s (s a))&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg ivamenjim *)&lt;br /&gt;
lemma ejercicio_5:&lt;br /&gt;
  assumes 1: &amp;quot;∀y. Q a y&amp;quot; and &lt;br /&gt;
          2: &amp;quot;∀x y. Q x y ⟶ Q (s x) (s y)&amp;quot;&lt;br /&gt;
  shows &amp;quot;∃z. Q a z ∧ Q z (s (s a))&amp;quot;&lt;br /&gt;
proof&lt;br /&gt;
  have 3:&amp;quot;Q a (s a)&amp;quot; using 1 ..&lt;br /&gt;
  also have 4:&amp;quot;∀y. Q a y ⟶ Q (s a) (s y)&amp;quot; using 2 ..&lt;br /&gt;
  then have 5:&amp;quot;Q a (s a) ⟶ Q (s a) (s (s a))&amp;quot; ..&lt;br /&gt;
  then have 6:&amp;quot;Q (s a) (s (s a))&amp;quot; using 3 by (rule mp)&lt;br /&gt;
  show &amp;quot;Q a (s a) ∧ Q (s a) (s (s a))&amp;quot; using 3 6 by (rule conjI)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma ejercicio_5_2: &lt;br /&gt;
  fixes P :: &amp;quot;&amp;#039;b ⇒ &amp;#039;b ⇒ bool&amp;quot; &lt;br /&gt;
  assumes 1: &amp;quot;∀y. Q a y&amp;quot;&lt;br /&gt;
  assumes 2: &amp;quot;∀x y. Q x y ⟶ Q (s x) (s y)&amp;quot;&lt;br /&gt;
  shows   &amp;quot; ∃z. Q a z ∧ Q z (s (s a))&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
 have 3: &amp;quot;Q a (s a)&amp;quot; using 1 by (rule allE)&lt;br /&gt;
 have 4: &amp;quot;∀y. Q a y ⟶ Q (s a) (s y)&amp;quot; using 2 by (rule allE)&lt;br /&gt;
 then have 5: &amp;quot;Q a (s a) ⟶ Q (s a) (s (s a))&amp;quot; by (rule allE)&lt;br /&gt;
 then have 6: &amp;quot;Q (s a) (s (s a))&amp;quot; using 3 by (rule mp)&lt;br /&gt;
 have &amp;quot;Q a (s a) ∧ Q (s a) (s (s a))&amp;quot; using 3 6 by (rule conjI)&lt;br /&gt;
 then show &amp;quot;∃z. Q a z ∧ Q z (s (s a))&amp;quot; by (rule exI)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg serrodcal juacabsou marpoldia1 crigomgom bowma rubgonmar pablucoto marcarmor13 antsancab1 *)&lt;br /&gt;
lemma ejercicio_5_3:&lt;br /&gt;
  assumes &amp;quot;∀y. Q a y&amp;quot; &lt;br /&gt;
          &amp;quot;∀x y. Q x y ⟶ Q (s x) (s y)&amp;quot;&lt;br /&gt;
  shows &amp;quot;∃z. Q a z ∧ Q z (s (s a))&amp;quot;&lt;br /&gt;
proof &lt;br /&gt;
 have &amp;quot;∀y. Q a y ⟶ Q (s a) (s y)&amp;quot; using assms(2) by (rule allE)&lt;br /&gt;
 hence &amp;quot;Q a (s a) ⟶ Q (s a) (s (s a))&amp;quot; by (rule allE)&lt;br /&gt;
 have &amp;quot;Q a (s a)&amp;quot; using assms(1) by (rule allE)&lt;br /&gt;
 have &amp;quot;Q (s a) (s (s a))&amp;quot; using `Q a (s a) ⟶ Q (s a) (s (s a))` `Q a (s a)` by (rule mp)&lt;br /&gt;
 show &amp;quot;Q a (s a) ∧ Q (s a) (s (s a))&amp;quot; &lt;br /&gt;
   using `Q a (s a)` `Q (s a) (s (s a))` by (rule conjI)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
lemma ejercicio_5: &lt;br /&gt;
  assumes &amp;quot;∀y. Q a y&amp;quot;&lt;br /&gt;
          &amp;quot;∀x y. Q x y ⟶ Q (s x) (s y)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;∃z. Q a z ∧ Q z (s (s a))&amp;quot;&lt;br /&gt;
proof &lt;br /&gt;
  have &amp;quot;Q a (s a)&amp;quot; using assms(1) by (rule allE)&lt;br /&gt;
  have &amp;quot;∀y. Q a y ⟶ Q (s a) (s y)&amp;quot;  using assms(2) by (rule allE)&lt;br /&gt;
  hence &amp;quot;Q a (s a) ⟶ Q (s a) (s (s a))&amp;quot; by (rule allE)&lt;br /&gt;
  hence &amp;quot; Q (s a) (s (s a))&amp;quot; using `Q a (s a)` by (rule mp)&lt;br /&gt;
  show &amp;quot;Q a (s a) ∧ Q (s a) (s (s a))&amp;quot; using `Q a (s a)` `Q (s a) (s (s a))` by (rule conjI) &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_7&amp;diff=1410</id>
		<title>Relación 7</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_7&amp;diff=1410"/>
		<updated>2017-01-31T09:32:10Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R7: Árboles binarios completos *}&lt;br /&gt;
&lt;br /&gt;
theory R7_Arboles_binarios_completos&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  En esta relación se piden demostraciones automáticas (lo más cortas&lt;br /&gt;
  posibles). Para ello, en algunos casos es necesario incluir lemas&lt;br /&gt;
  auxiliares (que se demuestran automáticamente) y usar ejercicios&lt;br /&gt;
  anteriores. &lt;br /&gt;
&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que no tienen información ni en los nodos y ni en las&lt;br /&gt;
  hojas. Por ejemplo, el árbol&lt;br /&gt;
          ·&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       ·     ·&lt;br /&gt;
      / \   / \&lt;br /&gt;
     ·   · ·   · &lt;br /&gt;
  se representa por &amp;quot;N (N H H) (N H H)&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
datatype arbol = H | N arbol arbol&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N (N H H) (N H H) = (N (N H H) (N H H) :: arbol)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función&lt;br /&gt;
     hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (hojas a) es el número de hojas del árbol a. Por ejemplo,&lt;br /&gt;
     hojas (N (N H H) (N H H)) = 4&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marcarmor13 josgarsan fracorjim1 jeamacpov *)&lt;br /&gt;
fun hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas H       = Suc 0&amp;quot;&lt;br /&gt;
| &amp;quot;hojas (N a b) = hojas a + hojas b&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;hojas (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 anaprarod paupeddeg migtermor wilmorort pablucoto &lt;br /&gt;
   ivamenjim serrodcal crigomgom rubgonmar  danrodcha ferrenseg&lt;br /&gt;
   manmorjim1 juacabsou lucnovdos dancorgar bowma antsancab1 pabrodmac *)&lt;br /&gt;
(* Es muy parecida a la definición anterior *)&lt;br /&gt;
fun hojas2 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas2 H       = 1&amp;quot; &lt;br /&gt;
| &amp;quot;hojas2 (N i d) = hojas2 i + hojas2 d&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
value &amp;quot;hojas2 (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* Equivalencia de las definiciones *)&lt;br /&gt;
lemma &amp;quot;hojas a = hojas2 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función&lt;br /&gt;
     profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (profundidad a) es la profundidad del árbol a. Por ejemplo,&lt;br /&gt;
     profundidad (N (N H H) (N H H)) = 2&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 anaprarod migtermor wilmorort marcarmor13&lt;br /&gt;
   dancorgar antsancab1 jeamacpov pabrodmac *) &lt;br /&gt;
fun profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad (N a b) = (if profundidad a &amp;gt; profundidad b&lt;br /&gt;
                          then 1 + profundidad a &lt;br /&gt;
                          else 1 + profundidad b)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;profundidad (N (N H H) (N H H)) = 2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod wilmorort pablucoto ivamenjim serrodcal crigomgom rubgonmar &lt;br /&gt;
   danrodcha ferrenseg josgarsan juacabsou lucnovdos bowma pabrodmac *)&lt;br /&gt;
fun profundidad2 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad2 H       = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad2 (N i d) = 1 + (max (profundidad2 i) (profundidad2 d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;profundidad2 (N (N H H) (N H H)) = 2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* Equivalencia de las definiciones *)&lt;br /&gt;
lemma &amp;quot;profundidad a= profundidad2 a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
fun maximo :: &amp;quot;nat ×  nat =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;maximo (a,b) = (if a &amp;gt; b then a else b)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
fun profundidad3 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad3 H       = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad3 (N i d) = 1 + maximo (profundidad3 i, profundidad3 d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: llamando a la función anterior profundidad3 *)&lt;br /&gt;
lemma &amp;quot;profundidad a = profundidad3 a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim manmorjim1 fracorjim1 *)&lt;br /&gt;
fun profundidad4 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad4 H       = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad4 (N i d) = Suc (max (profundidad4 i) (profundidad4 d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;profundidad a = profundidad4 a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función&lt;br /&gt;
     abc :: &amp;quot;nat ⇒ arbol&amp;quot; &lt;br /&gt;
  tal que (abc n) es el árbol binario completo de profundidad n. Por&lt;br /&gt;
  ejemplo,  &lt;br /&gt;
     abc 3 = N (N (N H H) (N H H)) (N (N H H) (N H H))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 anaprarod paupeddeg migtermor  wilmorort &lt;br /&gt;
   serrodcal crigomgom rubgonmar danrodcha ferrenseg josgarsan&lt;br /&gt;
   manmorjim1 juacabsou fracorjim1 lucnovdos dancorgar bowma antsancab1 pabrodmac *)&lt;br /&gt;
fun abc :: &amp;quot;nat ⇒ arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;abc 0       = H&amp;quot;&lt;br /&gt;
| &amp;quot;abc (Suc n) = (N (abc n) (abc n))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;abc 3 = N (N (N H H) (N H H)) (N (N H H) (N H H))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim pablucoto marcarmor13 jeamacpov *)&lt;br /&gt;
fun abc2 :: &amp;quot;nat ⇒ arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;abc2 0 = H&amp;quot;&lt;br /&gt;
| &amp;quot;abc2 t = N (abc2 (t-1)) (abc2 (t-1))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;abc2 3 = N (N (N H H) (N H H)) (N (N H H) (N H H))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: Metaejercicio de demostración *)&lt;br /&gt;
lemma &amp;quot;abc t = abc2 t&amp;quot;&lt;br /&gt;
by (induct t) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Un árbol binario a es completo respecto de la medida f si&lt;br /&gt;
  a es una hoja o bien a es de la forma (N i d) y se cumple que tanto i&lt;br /&gt;
  como d son árboles binarios completos respecto de f y, además, &lt;br /&gt;
  f(i) = f(r).&lt;br /&gt;
&lt;br /&gt;
  Definir la función&lt;br /&gt;
     es_abc :: &amp;quot;(arbol =&amp;gt; &amp;#039;a) =&amp;gt; arbol =&amp;gt; bool&lt;br /&gt;
  tal que (es_abc f a) se verifica si a es un árbol binario completo&lt;br /&gt;
  respecto de f.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy anaprarod migtermor serrodcal crigomgom rubgonmar &lt;br /&gt;
   danrodcha ferrenseg juacabsou josgarsan fracorjim1 lucnovdos bowma *)&lt;br /&gt;
fun es_abc :: &amp;quot;(arbol =&amp;gt; &amp;#039;a) =&amp;gt; arbol =&amp;gt; bool&amp;quot; where&lt;br /&gt;
  &amp;quot;es_abc _ H       = True&amp;quot;&lt;br /&gt;
| &amp;quot;es_abc f (N a b) = (es_abc f a ∧ es_abc f b ∧ (f a = f b))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 paupeddeg ivamenjim pablucoto marcarmor13 manmorjim1&lt;br /&gt;
   dancorgar antsancab1 jeamacpov pabrodmac *) &lt;br /&gt;
fun es_abc2 :: &amp;quot;(arbol =&amp;gt; &amp;#039;a) =&amp;gt; arbol =&amp;gt; bool&amp;quot; where&lt;br /&gt;
  &amp;quot;es_abc2 f H       = True&amp;quot; &lt;br /&gt;
| &amp;quot;es_abc2 f (N i d) = ((f i = f d) ∧ (es_abc2 f i) ∧ (es_abc2 f d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* Equivalencia de las definiciones *)&lt;br /&gt;
lemma &amp;quot;es_abc f a = es_abc2 f a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Nota. (size a) es el número de nodos del árbol a. Por ejemplo,&lt;br /&gt;
     size (N (N H H) (N H H)) = 3&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;size (N (N H H) (N H H)) = 3&amp;quot;&lt;br /&gt;
value &amp;quot;size (N (N (N H H) (N H H)) (N (N H H) (N H H))) = 7&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Nota. Tenemos 3 funciones de medida sobre los árboles: número de&lt;br /&gt;
  hojas, número de nodos y profundidad. A cada una le corresponde un&lt;br /&gt;
  concepto de completitud. En los siguientes ejercicios demostraremos&lt;br /&gt;
  que los tres conceptos de completitud son iguales.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que un árbol binario a es completo respecto de&lt;br /&gt;
  la profundidad syss es completo respecto del número de hojas.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor wilmorort pablucoto serrodcal&lt;br /&gt;
   fracorjim1 josgarsan lucnovdos bowma antsancab1 jeamacpov *) &lt;br /&gt;
lemma abc_prof_num_hojas:&lt;br /&gt;
  assumes &amp;quot;es_abc profundidad a&amp;quot;&lt;br /&gt;
  shows   &amp;quot;hojas a = 2^(profundidad a)&amp;quot;&lt;br /&gt;
using assms&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* Otra forma de escribir lo mismo *)&lt;br /&gt;
(* anaprarod crigomgom ivamenjim paupeddeg juacabsou *)&lt;br /&gt;
lemma AUX7: &amp;quot;es_abc profundidad a ⟶ (hojas a = 2^(profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* Otra forma de escribir lo mismo *)&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux1: &amp;quot;es_abc profundidad (a::arbol) ⟹ (hojas a = 2^ (profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod wilmorort serrodcal&lt;br /&gt;
   crigomgom rubgonmar ivamenjim danrodcha marcarmor13 paupeddeg&lt;br /&gt;
   juacabsou bowma antsancab1 *) &lt;br /&gt;
(* También funciona con AUX7 *)&lt;br /&gt;
lemma lej7: &amp;quot;es_abc profundidad a = es_abc hojas a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: abc_prof_num_hojas)&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma 7: &amp;quot;es_abc profundidad a = es_abc hojas a&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply (auto simp add: aux1)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma [simp]: &amp;quot;es_abc profundidad a ⟶ hojas a = 2 ^ (profundidad a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Uso de la declaración simp *)&lt;br /&gt;
&lt;br /&gt;
theorem es_abc_profundidad_hojas: &lt;br /&gt;
  &amp;quot;es_abc profundidad a = es_abc hojas a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Dependencia de la declaración simp. *)&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma rel_hojas_prof: &amp;quot;es_abc hojas a ∧ es_abc profundidad a&lt;br /&gt;
      ⟹ hojas a = 2 ^ profundidad a&amp;quot;&lt;br /&gt;
by (induct a) (auto)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;es_abc hojas a = es_abc profundidad a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: rel_hojas_prof)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
lemma lemaaux1:&amp;quot;es_abc hojas a⟶(hojas a = 2^(profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
lemma 1:&amp;quot;es_abc profundidad a = es_abc hojas a &amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: lemaaux1)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que un árbol binario a es completo respecto del&lt;br /&gt;
  número de hojas syss es completo respecto del número de nodos.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor wilmorort pablucoto serrodcal&lt;br /&gt;
   marcarmor13 josgarsan lucnovdos bowma antsancab1 jeamacpov *) &lt;br /&gt;
lemma abc_hojas_num_nodos:&lt;br /&gt;
  assumes &amp;quot;es_abc hojas a&amp;quot;&lt;br /&gt;
  shows   &amp;quot;Suc (size a) = hojas a&amp;quot;&lt;br /&gt;
using assms&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* Comentario sobre orientación de igualdades. *)&lt;br /&gt;
&lt;br /&gt;
(* Otra forma de escribir lo mismo *)&lt;br /&gt;
(* anaprarod crigomgom paupeddeg juacabsou rubgonmar *)&lt;br /&gt;
lemma AUX8: &amp;quot;es_abc hojas a ⟶ (hojas a = (Suc (size a)))&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod wilmorort pablucoto&lt;br /&gt;
   serrodcal antsancab1 *) &lt;br /&gt;
lemma lej8: &amp;quot;es_abc hojas a = es_abc size a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add:abc_hojas_num_nodos [symmetric])&lt;br /&gt;
&lt;br /&gt;
(* Comentario sobre orientación de igualdades. *)&lt;br /&gt;
&lt;br /&gt;
(* anaprarod crigomgom paupeddeg juacabsou rubgonmar *)&lt;br /&gt;
(* Usando AUX8 *)&lt;br /&gt;
lemma L8: &amp;quot;es_abc hojas a = es_abc size a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: AUX8)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Teorema auxiliar *)&lt;br /&gt;
lemma auxEj8: &amp;quot;hojas a = size a + 1&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma lej8b: &amp;quot;es_abc hojas a = es_abc size a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: auxEj8)&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux3: &amp;quot;es_abc hojas a ⟹ (hojas a = 1 + size a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma 8: &amp;quot;es_abc hojas a = es_abc size a&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply (auto simp add: aux3)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma [simp]: &amp;quot;hojas a = size a + 1&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
 &lt;br /&gt;
theorem es_abc_hojas_size: &amp;quot;es_abc hojas a = es_abc size a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 *)&lt;br /&gt;
lemma aux10 : &amp;quot;hojas (a::arbol) = Suc(size a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
    &lt;br /&gt;
lemma es_abc_hojas_size_10 : &amp;quot;es_abc hojas (a::arbol) = es_abc size a&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply (auto simp add: aux10)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma rel_hojas_size: &amp;quot;es_abc hojas a ∧ es_abc size a&lt;br /&gt;
      ⟹ hojas a = (size a) + 1&amp;quot;&lt;br /&gt;
by (induct a) (auto)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;es_abc hojas a = es_abc size a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: rel_hojas_size)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma lemaaux2:&amp;quot;es_abc size a⟶(hojas a  = Suc(size a)) &amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
lemma 2:&amp;quot;es_abc hojas a = es_abc size a &amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: lemaaux2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Demostrar que un árbol binario a es completo respecto de&lt;br /&gt;
  la profundidad syss es completo respecto del número de nodos.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod  wilmorort pablucoto &lt;br /&gt;
   serrodcal crigomgom rubgonmar danrodcha ivamenjim marcarmor13&lt;br /&gt;
   paupeddeg juacabsou josgarsan bowma lucnovdos antsancab1 jeamacpov *)&lt;br /&gt;
lemma lej9:  &amp;quot;es_abc profundidad a = es_abc size a&amp;quot;&lt;br /&gt;
by (simp add: lej7 lej8)&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
corollary es_abc_size_profundidad: &amp;quot;es_abc size a = es_abc profundidad a&amp;quot;&lt;br /&gt;
by (simp add: es_abc_profundidad_hojas es_abc_hojas_size)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma lemaaux3:&amp;quot;es_abc profundidad a⟶(Suc(size a)= 2^(profundidad a)) &amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;es_abc profundidad a = es_abc size a &amp;quot;&lt;br /&gt;
by (simp add: 1 2 )&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Demostrar que (abc n) es un árbol binario completo.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor wilmorort pablucoto serrodcal&lt;br /&gt;
   crigomgom marcarmor13 paupeddeg juacabsou dancorgar lucnovdos jeamacpov pabrodmac  *)&lt;br /&gt;
lemma lej10: &amp;quot;es_abc profundidad (abc n)&amp;quot;&lt;br /&gt;
by (induct n) auto&lt;br /&gt;
&lt;br /&gt;
(* anaprarod rubgonmar danrodcha ferrenseg ivamenjim&lt;br /&gt;
   paupeddeg juacabsou bowma antsancab1 *)&lt;br /&gt;
(* con un demostrador más débil *)&lt;br /&gt;
(* y en general para cualquier medida *)&lt;br /&gt;
lemma L10:  &amp;quot;es_abc f (abc a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Igual que el anterior pero usando auto *)&lt;br /&gt;
lemma lej10b: &amp;quot;es_abc f (abc n)&amp;quot;&lt;br /&gt;
by (induct n) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Demostrar que si a es un árbolo binario completo&lt;br /&gt;
  respecto de la profundidad, entonces a es igual a&lt;br /&gt;
  (abc (profundidad a)).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor wilmorort pablucoto serrodcal&lt;br /&gt;
   marcarmor13 antsancab1 jeamacpov *) &lt;br /&gt;
lemma lej11: &lt;br /&gt;
  assumes &amp;quot;es_abc profundidad a&amp;quot;&lt;br /&gt;
  shows   &amp;quot;a = (abc (profundidad a))&amp;quot;&lt;br /&gt;
using assms&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* Otra forma de escribir lo mismo *)&lt;br /&gt;
(* anaprarod crigomgom rubgonmar ferrenseg ivamenjim paupeddeg juacabsou&lt;br /&gt;
   dancorgar bowma lucnovdos pabrodmac *) &lt;br /&gt;
lemma &amp;quot;es_abc profundidad a ⟶ (a = (abc (profundidad a)))&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* danrodcha*)&lt;br /&gt;
lemma 11:&amp;quot;es_abc profundidad a ⟹ (a = (abc (profundidad a)))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Encontrar una medida f tal que (es_abc f) es distinto de &lt;br /&gt;
  (es_abc size).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
fun medida_nula :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;medida_nula H       = 0&amp;quot;&lt;br /&gt;
| &amp;quot;medida_nula (N i d) = 0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;es_abc medida_nula a = es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo:&lt;br /&gt;
  a = N H (N H H) &lt;br /&gt;
  Tras evaluar:&lt;br /&gt;
  es_abc medida_nula a = True&lt;br /&gt;
  es_abc size a = False*)&lt;br /&gt;
&lt;br /&gt;
(* anaprarod  wilmorort pablucoto serrodcal danrodcha marcarmor13&lt;br /&gt;
   ferrenseg ivamenjim paupeddeg juacabsou rubgonmar bowma lucnovdos antsancab1 jeamacpov *) &lt;br /&gt;
lemma &amp;quot;es_abc f a =  es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
(* Quickcheck found a counterexample:&lt;br /&gt;
  f = λx. a⇩1   &lt;br /&gt;
  a = N H (N H H)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  es_abc f a = True&lt;br /&gt;
  es_abc size a = False *)&lt;br /&gt;
oops&lt;br /&gt;
(* el contraejemplo que encuentra es la medida constante a1 *)&lt;br /&gt;
&lt;br /&gt;
(*crigomgom *)&lt;br /&gt;
(* Como en la primera de las soluciones he usado la función constante 0&lt;br /&gt;
   pero he usado una expresión lambda *) &lt;br /&gt;
lemma &amp;quot;es_abc (λx. 0::nat) a = es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
fun medida :: &amp;quot;arbol =&amp;gt; bool&amp;quot; where&lt;br /&gt;
  &amp;quot;medida H       = True&amp;quot;&lt;br /&gt;
| &amp;quot;medida (N i d) = ((profundidad i) = (size d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;es_abc size a = es_abc medida a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun todossoniguales :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;todossoniguales H = 1&amp;quot;&lt;br /&gt;
| &amp;quot;todossoniguales (N i d) = 1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;todossoniguales (H) = 1&amp;quot;&lt;br /&gt;
value &amp;quot;todossoniguales (N (N H H) (N H H)) = 1&amp;quot;&lt;br /&gt;
value &amp;quot;todossoniguales (N (N (N H H) (N H H)) (N (N H H) (N H H))) = 1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;es_abc todossoniguales a = es_abc size a&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_7&amp;diff=1409</id>
		<title>Relación 7</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_7&amp;diff=1409"/>
		<updated>2017-01-31T09:28:37Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R7: Árboles binarios completos *}&lt;br /&gt;
&lt;br /&gt;
theory R7_Arboles_binarios_completos&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  En esta relación se piden demostraciones automáticas (lo más cortas&lt;br /&gt;
  posibles). Para ello, en algunos casos es necesario incluir lemas&lt;br /&gt;
  auxiliares (que se demuestran automáticamente) y usar ejercicios&lt;br /&gt;
  anteriores. &lt;br /&gt;
&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que no tienen información ni en los nodos y ni en las&lt;br /&gt;
  hojas. Por ejemplo, el árbol&lt;br /&gt;
          ·&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       ·     ·&lt;br /&gt;
      / \   / \&lt;br /&gt;
     ·   · ·   · &lt;br /&gt;
  se representa por &amp;quot;N (N H H) (N H H)&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
datatype arbol = H | N arbol arbol&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N (N H H) (N H H) = (N (N H H) (N H H) :: arbol)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función&lt;br /&gt;
     hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (hojas a) es el número de hojas del árbol a. Por ejemplo,&lt;br /&gt;
     hojas (N (N H H) (N H H)) = 4&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marcarmor13 josgarsan fracorjim1 jeamacpov *)&lt;br /&gt;
fun hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas H       = Suc 0&amp;quot;&lt;br /&gt;
| &amp;quot;hojas (N a b) = hojas a + hojas b&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;hojas (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 anaprarod paupeddeg migtermor wilmorort pablucoto &lt;br /&gt;
   ivamenjim serrodcal crigomgom rubgonmar  danrodcha ferrenseg&lt;br /&gt;
   manmorjim1 juacabsou lucnovdos dancorgar bowma antsancab1 pabrodmac *)&lt;br /&gt;
(* Es muy parecida a la definición anterior *)&lt;br /&gt;
fun hojas2 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas2 H       = 1&amp;quot; &lt;br /&gt;
| &amp;quot;hojas2 (N i d) = hojas2 i + hojas2 d&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
value &amp;quot;hojas2 (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* Equivalencia de las definiciones *)&lt;br /&gt;
lemma &amp;quot;hojas a = hojas2 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función&lt;br /&gt;
     profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (profundidad a) es la profundidad del árbol a. Por ejemplo,&lt;br /&gt;
     profundidad (N (N H H) (N H H)) = 2&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 anaprarod migtermor wilmorort marcarmor13&lt;br /&gt;
   dancorgar antsancab1 jeamacpov pabrodmac *) &lt;br /&gt;
fun profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad (N a b) = (if profundidad a &amp;gt; profundidad b&lt;br /&gt;
                          then 1 + profundidad a &lt;br /&gt;
                          else 1 + profundidad b)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;profundidad (N (N H H) (N H H)) = 2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod wilmorort pablucoto ivamenjim serrodcal crigomgom rubgonmar &lt;br /&gt;
   danrodcha ferrenseg josgarsan juacabsou lucnovdos bowma pabrodmac *)&lt;br /&gt;
fun profundidad2 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad2 H       = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad2 (N i d) = 1 + (max (profundidad2 i) (profundidad2 d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;profundidad2 (N (N H H) (N H H)) = 2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* Equivalencia de las definiciones *)&lt;br /&gt;
lemma &amp;quot;profundidad a= profundidad2 a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
fun maximo :: &amp;quot;nat ×  nat =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;maximo (a,b) = (if a &amp;gt; b then a else b)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
fun profundidad3 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad3 H       = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad3 (N i d) = 1 + maximo (profundidad3 i, profundidad3 d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: llamando a la función anterior profundidad3 *)&lt;br /&gt;
lemma &amp;quot;profundidad a = profundidad3 a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim manmorjim1 fracorjim1 *)&lt;br /&gt;
fun profundidad4 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad4 H       = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad4 (N i d) = Suc (max (profundidad4 i) (profundidad4 d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;profundidad a = profundidad4 a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función&lt;br /&gt;
     abc :: &amp;quot;nat ⇒ arbol&amp;quot; &lt;br /&gt;
  tal que (abc n) es el árbol binario completo de profundidad n. Por&lt;br /&gt;
  ejemplo,  &lt;br /&gt;
     abc 3 = N (N (N H H) (N H H)) (N (N H H) (N H H))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 anaprarod paupeddeg migtermor  wilmorort &lt;br /&gt;
   serrodcal crigomgom rubgonmar danrodcha ferrenseg josgarsan&lt;br /&gt;
   manmorjim1 juacabsou fracorjim1 lucnovdos dancorgar bowma antsancab1 pabrodmac *)&lt;br /&gt;
fun abc :: &amp;quot;nat ⇒ arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;abc 0       = H&amp;quot;&lt;br /&gt;
| &amp;quot;abc (Suc n) = (N (abc n) (abc n))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;abc 3 = N (N (N H H) (N H H)) (N (N H H) (N H H))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim pablucoto marcarmor13 jeamacpov *)&lt;br /&gt;
fun abc2 :: &amp;quot;nat ⇒ arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;abc2 0 = H&amp;quot;&lt;br /&gt;
| &amp;quot;abc2 t = N (abc2 (t-1)) (abc2 (t-1))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;abc2 3 = N (N (N H H) (N H H)) (N (N H H) (N H H))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: Metaejercicio de demostración *)&lt;br /&gt;
lemma &amp;quot;abc t = abc2 t&amp;quot;&lt;br /&gt;
by (induct t) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Un árbol binario a es completo respecto de la medida f si&lt;br /&gt;
  a es una hoja o bien a es de la forma (N i d) y se cumple que tanto i&lt;br /&gt;
  como d son árboles binarios completos respecto de f y, además, &lt;br /&gt;
  f(i) = f(r).&lt;br /&gt;
&lt;br /&gt;
  Definir la función&lt;br /&gt;
     es_abc :: &amp;quot;(arbol =&amp;gt; &amp;#039;a) =&amp;gt; arbol =&amp;gt; bool&lt;br /&gt;
  tal que (es_abc f a) se verifica si a es un árbol binario completo&lt;br /&gt;
  respecto de f.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy anaprarod migtermor serrodcal crigomgom rubgonmar &lt;br /&gt;
   danrodcha ferrenseg juacabsou josgarsan fracorjim1 lucnovdos bowma *)&lt;br /&gt;
fun es_abc :: &amp;quot;(arbol =&amp;gt; &amp;#039;a) =&amp;gt; arbol =&amp;gt; bool&amp;quot; where&lt;br /&gt;
  &amp;quot;es_abc _ H       = True&amp;quot;&lt;br /&gt;
| &amp;quot;es_abc f (N a b) = (es_abc f a ∧ es_abc f b ∧ (f a = f b))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 paupeddeg ivamenjim pablucoto marcarmor13 manmorjim1&lt;br /&gt;
   dancorgar antsancab1 jeamacpov pabrodmac *) &lt;br /&gt;
fun es_abc2 :: &amp;quot;(arbol =&amp;gt; &amp;#039;a) =&amp;gt; arbol =&amp;gt; bool&amp;quot; where&lt;br /&gt;
  &amp;quot;es_abc2 f H       = True&amp;quot; &lt;br /&gt;
| &amp;quot;es_abc2 f (N i d) = ((f i = f d) ∧ (es_abc2 f i) ∧ (es_abc2 f d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* Equivalencia de las definiciones *)&lt;br /&gt;
lemma &amp;quot;es_abc f a = es_abc2 f a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Nota. (size a) es el número de nodos del árbol a. Por ejemplo,&lt;br /&gt;
     size (N (N H H) (N H H)) = 3&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;size (N (N H H) (N H H)) = 3&amp;quot;&lt;br /&gt;
value &amp;quot;size (N (N (N H H) (N H H)) (N (N H H) (N H H))) = 7&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Nota. Tenemos 3 funciones de medida sobre los árboles: número de&lt;br /&gt;
  hojas, número de nodos y profundidad. A cada una le corresponde un&lt;br /&gt;
  concepto de completitud. En los siguientes ejercicios demostraremos&lt;br /&gt;
  que los tres conceptos de completitud son iguales.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que un árbol binario a es completo respecto de&lt;br /&gt;
  la profundidad syss es completo respecto del número de hojas.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor wilmorort pablucoto serrodcal&lt;br /&gt;
   fracorjim1 josgarsan lucnovdos bowma antsancab1 jeamacpov *) &lt;br /&gt;
lemma abc_prof_num_hojas:&lt;br /&gt;
  assumes &amp;quot;es_abc profundidad a&amp;quot;&lt;br /&gt;
  shows   &amp;quot;hojas a = 2^(profundidad a)&amp;quot;&lt;br /&gt;
using assms&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* Otra forma de escribir lo mismo *)&lt;br /&gt;
(* anaprarod crigomgom ivamenjim paupeddeg juacabsou *)&lt;br /&gt;
lemma AUX7: &amp;quot;es_abc profundidad a ⟶ (hojas a = 2^(profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* Otra forma de escribir lo mismo *)&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux1: &amp;quot;es_abc profundidad (a::arbol) ⟹ (hojas a = 2^ (profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod wilmorort serrodcal&lt;br /&gt;
   crigomgom rubgonmar ivamenjim danrodcha marcarmor13 paupeddeg&lt;br /&gt;
   juacabsou bowma antsancab1 *) &lt;br /&gt;
(* También funciona con AUX7 *)&lt;br /&gt;
lemma lej7: &amp;quot;es_abc profundidad a = es_abc hojas a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: abc_prof_num_hojas)&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma 7: &amp;quot;es_abc profundidad a = es_abc hojas a&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply (auto simp add: aux1)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma [simp]: &amp;quot;es_abc profundidad a ⟶ hojas a = 2 ^ (profundidad a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Uso de la declaración simp *)&lt;br /&gt;
&lt;br /&gt;
theorem es_abc_profundidad_hojas: &lt;br /&gt;
  &amp;quot;es_abc profundidad a = es_abc hojas a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Dependencia de la declaración simp. *)&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma rel_hojas_prof: &amp;quot;es_abc hojas a ∧ es_abc profundidad a&lt;br /&gt;
      ⟹ hojas a = 2 ^ profundidad a&amp;quot;&lt;br /&gt;
by (induct a) (auto)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;es_abc hojas a = es_abc profundidad a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: rel_hojas_prof)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
lemma lemaaux1:&amp;quot;es_abc hojas a⟶(hojas a = 2^(profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
lemma 1:&amp;quot;es_abc profundidad a = es_abc hojas a &amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: lemaaux1)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que un árbol binario a es completo respecto del&lt;br /&gt;
  número de hojas syss es completo respecto del número de nodos.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor wilmorort pablucoto serrodcal&lt;br /&gt;
   marcarmor13 josgarsan lucnovdos bowma antsancab1 jeamacpov *) &lt;br /&gt;
lemma abc_hojas_num_nodos:&lt;br /&gt;
  assumes &amp;quot;es_abc hojas a&amp;quot;&lt;br /&gt;
  shows   &amp;quot;Suc (size a) = hojas a&amp;quot;&lt;br /&gt;
using assms&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* Comentario sobre orientación de igualdades. *)&lt;br /&gt;
&lt;br /&gt;
(* Otra forma de escribir lo mismo *)&lt;br /&gt;
(* anaprarod crigomgom paupeddeg juacabsou rubgonmar *)&lt;br /&gt;
lemma AUX8: &amp;quot;es_abc hojas a ⟶ (hojas a = (Suc (size a)))&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod wilmorort pablucoto&lt;br /&gt;
   serrodcal antsancab1 *) &lt;br /&gt;
lemma lej8: &amp;quot;es_abc hojas a = es_abc size a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add:abc_hojas_num_nodos [symmetric])&lt;br /&gt;
&lt;br /&gt;
(* Comentario sobre orientación de igualdades. *)&lt;br /&gt;
&lt;br /&gt;
(* anaprarod crigomgom paupeddeg juacabsou rubgonmar *)&lt;br /&gt;
(* Usando AUX8 *)&lt;br /&gt;
lemma L8: &amp;quot;es_abc hojas a = es_abc size a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: AUX8)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Teorema auxiliar *)&lt;br /&gt;
lemma auxEj8: &amp;quot;hojas a = size a + 1&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma lej8b: &amp;quot;es_abc hojas a = es_abc size a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: auxEj8)&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux3: &amp;quot;es_abc hojas a ⟹ (hojas a = 1 + size a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma 8: &amp;quot;es_abc hojas a = es_abc size a&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply (auto simp add: aux3)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma [simp]: &amp;quot;hojas a = size a + 1&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
 &lt;br /&gt;
theorem es_abc_hojas_size: &amp;quot;es_abc hojas a = es_abc size a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 *)&lt;br /&gt;
lemma aux10 : &amp;quot;hojas (a::arbol) = Suc(size a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
    &lt;br /&gt;
lemma es_abc_hojas_size_10 : &amp;quot;es_abc hojas (a::arbol) = es_abc size a&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply (auto simp add: aux10)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma rel_hojas_size: &amp;quot;es_abc hojas a ∧ es_abc size a&lt;br /&gt;
      ⟹ hojas a = (size a) + 1&amp;quot;&lt;br /&gt;
by (induct a) (auto)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;es_abc hojas a = es_abc size a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: rel_hojas_size)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma lemaaux2:&amp;quot;es_abc size a⟶(hojas a  = Suc(size a)) &amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
lemma 2:&amp;quot;es_abc hojas a = es_abc size a &amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: lemaaux2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Demostrar que un árbol binario a es completo respecto de&lt;br /&gt;
  la profundidad syss es completo respecto del número de nodos.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod  wilmorort pablucoto &lt;br /&gt;
   serrodcal crigomgom rubgonmar danrodcha ivamenjim marcarmor13&lt;br /&gt;
   paupeddeg juacabsou josgarsan bowma lucnovdos antsancab1 jeamacpov *)&lt;br /&gt;
lemma lej9:  &amp;quot;es_abc profundidad a = es_abc size a&amp;quot;&lt;br /&gt;
by (simp add: lej7 lej8)&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
corollary es_abc_size_profundidad: &amp;quot;es_abc size a = es_abc profundidad a&amp;quot;&lt;br /&gt;
by (simp add: es_abc_profundidad_hojas es_abc_hojas_size)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma lemaaux3:&amp;quot;es_abc profundidad a⟶(Suc(size a)= 2^(profundidad a)) &amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;es_abc profundidad a = es_abc size a &amp;quot;&lt;br /&gt;
by (simp add: 1 2 )&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Demostrar que (abc n) es un árbol binario completo.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor wilmorort pablucoto serrodcal&lt;br /&gt;
   crigomgom marcarmor13 paupeddeg juacabsou dancorgar lucnovdos jeamacpov pabrodmac  *)&lt;br /&gt;
lemma lej10: &amp;quot;es_abc profundidad (abc n)&amp;quot;&lt;br /&gt;
by (induct n) auto&lt;br /&gt;
&lt;br /&gt;
(* anaprarod rubgonmar danrodcha ferrenseg ivamenjim&lt;br /&gt;
   paupeddeg juacabsou bowma antsancab1 *)&lt;br /&gt;
(* con un demostrador más débil *)&lt;br /&gt;
(* y en general para cualquier medida *)&lt;br /&gt;
lemma L10:  &amp;quot;es_abc f (abc a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Igual que el anterior pero usando auto *)&lt;br /&gt;
lemma lej10b: &amp;quot;es_abc f (abc n)&amp;quot;&lt;br /&gt;
by (induct n) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Demostrar que si a es un árbolo binario completo&lt;br /&gt;
  respecto de la profundidad, entonces a es igual a&lt;br /&gt;
  (abc (profundidad a)).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor wilmorort pablucoto serrodcal&lt;br /&gt;
   marcarmor13 antsancab1 jeamacpov *) &lt;br /&gt;
lemma lej11: &lt;br /&gt;
  assumes &amp;quot;es_abc profundidad a&amp;quot;&lt;br /&gt;
  shows   &amp;quot;a = (abc (profundidad a))&amp;quot;&lt;br /&gt;
using assms&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* Otra forma de escribir lo mismo *)&lt;br /&gt;
(* anaprarod crigomgom rubgonmar ferrenseg ivamenjim paupeddeg juacabsou&lt;br /&gt;
   dancorgar bowma lucnovdos *) &lt;br /&gt;
lemma &amp;quot;es_abc profundidad a ⟶ (a = (abc (profundidad a)))&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* danrodcha*)&lt;br /&gt;
lemma 11:&amp;quot;es_abc profundidad a ⟹ (a = (abc (profundidad a)))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Encontrar una medida f tal que (es_abc f) es distinto de &lt;br /&gt;
  (es_abc size).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
fun medida_nula :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;medida_nula H       = 0&amp;quot;&lt;br /&gt;
| &amp;quot;medida_nula (N i d) = 0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;es_abc medida_nula a = es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo:&lt;br /&gt;
  a = N H (N H H) &lt;br /&gt;
  Tras evaluar:&lt;br /&gt;
  es_abc medida_nula a = True&lt;br /&gt;
  es_abc size a = False*)&lt;br /&gt;
&lt;br /&gt;
(* anaprarod  wilmorort pablucoto serrodcal danrodcha marcarmor13&lt;br /&gt;
   ferrenseg ivamenjim paupeddeg juacabsou rubgonmar bowma lucnovdos antsancab1 jeamacpov *) &lt;br /&gt;
lemma &amp;quot;es_abc f a =  es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
(* Quickcheck found a counterexample:&lt;br /&gt;
  f = λx. a⇩1   &lt;br /&gt;
  a = N H (N H H)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  es_abc f a = True&lt;br /&gt;
  es_abc size a = False *)&lt;br /&gt;
oops&lt;br /&gt;
(* el contraejemplo que encuentra es la medida constante a1 *)&lt;br /&gt;
&lt;br /&gt;
(*crigomgom *)&lt;br /&gt;
(* Como en la primera de las soluciones he usado la función constante 0&lt;br /&gt;
   pero he usado una expresión lambda *) &lt;br /&gt;
lemma &amp;quot;es_abc (λx. 0::nat) a = es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
fun medida :: &amp;quot;arbol =&amp;gt; bool&amp;quot; where&lt;br /&gt;
  &amp;quot;medida H       = True&amp;quot;&lt;br /&gt;
| &amp;quot;medida (N i d) = ((profundidad i) = (size d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;es_abc size a = es_abc medida a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=1408</id>
		<title>Relación 4</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=1408"/>
		<updated>2017-01-31T09:06:56Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R4: Cuantificadores sobre listas *}&lt;br /&gt;
&lt;br /&gt;
theory R4_Cuantificadores_sobre_listas&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la función &lt;br /&gt;
     todos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (todos p xs) se verifica si todos los elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     todos (λx. 1&amp;lt;length x) [[2,1,4],[1,3]]&lt;br /&gt;
     ¬todos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función todos es equivalente a la predefinida list_all. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha ivamenjim migtermor dancorgar wilmorort marpoldia1&lt;br /&gt;
   ferrenseg paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou&lt;br /&gt;
   rubgonmar josgarsan fraortmoy lucnovdos pabrodmac fracorjim1&lt;br /&gt;
   marcarmor13 jeamacpov antsancab1 *)   &lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     algunos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (algunos p xs) se verifica si algunos elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     algunos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
     ¬algunos (λx. 1&amp;lt;length x) [[],[3]]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  Nota: La función algunos es equivalente a la predefinida list_ex. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg&lt;br /&gt;
   wilmorort paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou&lt;br /&gt;
   rubgonmar josgarsan fraortmoy lucnovdos pabrodmac marcarmor13 jeamacpov antsancab1*)  &lt;br /&gt;
fun algunos  :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;algunos p []     = False&amp;quot;&lt;br /&gt;
| &amp;quot;algunos p (x#xs) = (p x ∨ algunos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1. En esta versión el procesamiento se detiene al encontrar&lt;br /&gt;
   una coincidencia *) &lt;br /&gt;
fun algunos2  :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;algunos2 p [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;algunos2 p (x#xs) = (if p x then True else algunos2 p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg&lt;br /&gt;
   wilmorort paupeddeg pablucoto anaprarod serrodcal juacabsou rubgonmar&lt;br /&gt;
   josgarsan fraortmoy lucnovdos pabrodmac marcarmor13 jeamacpov antsancab1 *)  &lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fracorjim1 *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = &lt;br /&gt;
        (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (P a ∧ Q a ∧ (todos P xs ∧ todos Q xs))&amp;quot; &lt;br /&gt;
    using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?R (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Uso de blast. *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal josgarsan*)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = &lt;br /&gt;
        (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
    using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = &lt;br /&gt;
                (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Uso de auto. *)&lt;br /&gt;
&lt;br /&gt;
(* dancorgar paupeddeg *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix y xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = &lt;br /&gt;
        ((P y ∧ Q y) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ Q y) ∧ (todos P xs ∧ todos Q xs))&amp;quot; &lt;br /&gt;
    using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ todos P xs) ∧ (Q y ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = ((todos P (y#xs)) ∧ (todos Q (y#xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = &lt;br /&gt;
                (todos P (y#xs) ∧ todos Q (y#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
 next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
 have &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = &lt;br /&gt;
       (( P x ∧ Q x) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot;&lt;br /&gt;
   by (simp only: todos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs))&amp;quot; &lt;br /&gt;
   using HI by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x ∧ todos P xs) ∧ (Q x ∧ todos Q xs))&amp;quot; &lt;br /&gt;
   by arith&lt;br /&gt;
 also have &amp;quot;((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs)) = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot;&lt;br /&gt;
   by arith &lt;br /&gt;
   (* Este paso es exactamente el mismo que el anterior, pero sin&lt;br /&gt;
      cualquiera de los dos no funciona el &amp;quot;finally show&amp;quot; *) &lt;br /&gt;
 have &amp;quot;… = (((P x)∧(todos P xs))∧((Q x)∧(todos Q xs)))&amp;quot; by simp&lt;br /&gt;
 have &amp;quot;… = ((todos P (x#xs))∧(todos Q (x#xs)))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = &lt;br /&gt;
               ((todos P (x#xs)) ∧ (todos Q (x#xs)))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Comentarios: Ruptura de la cadena de igualdades y uso de arith. *)&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) =  &lt;br /&gt;
        ((P a ∧ Q a) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs) ∧ todos Q (a#xs)) &amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = &lt;br /&gt;
               (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = &lt;br /&gt;
        (P n ∧ Q n ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = P n ∧ Q n ∧ todos P xs ∧ todos Q xs&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;⋯ = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Demostración incompleta. *)&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) =  &lt;br /&gt;
        ((P n ∧ Q n) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P n ∧ todos P xs) ∧ (Q n ∧ todos Q xs))&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = ((todos P(n#xs)) ∧ (todos Q(n#xs)))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (n#xs) = &lt;br /&gt;
               (todos P (n#xs) ∧ todos Q (n#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* wilmorort pablucoto crigomgom anaprarod juacabsou rubgonmar fraortmoy&lt;br /&gt;
   marcarmor13 jeamacpov *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp   &lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = &lt;br /&gt;
        (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
    using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P xs ∧ Q a ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
  also have &amp;quot;... = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp &lt;br /&gt;
    (* Este paso se puede obviar *)&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = &lt;br /&gt;
                (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (x#xs) = &lt;br /&gt;
        (P x ∧ Q x  ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ Q x  ∧ (todos P xs ∧ todos Q xs))&amp;quot; &lt;br /&gt;
    using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ todos P xs ∧ Q x ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (x#xs) = &lt;br /&gt;
                (todos P (x#xs) ∧ todos Q (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* antsancab1 *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by auto&lt;br /&gt;
qe&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha ivamenjim marpoldia1 migtermor ferrenseg wilmorort&lt;br /&gt;
   paupeddeg crigomgom anaprarod serrodcal juacabsou rubgonmar pablucoto&lt;br /&gt;
   fraortmoy josgarsan lucnovdos pabrodmac marcarmor13 jeamacpov antsancab1 *) &lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
(* anaprarod dancorgar fracorjim1 *)&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
apply (induct x)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg wilmorort dancorgar fraortmoy josgarsan lucnovdos&lt;br /&gt;
 rubgonmar *) &lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor serrodcal antsancab1 *)&lt;br /&gt;
lemma todos_append1:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?P x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;?P x&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (a#x)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma todos_append2:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a#(x@y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
lemma todos_append3:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P (x @ y)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ (todos P x ∧ todos P y))&amp;quot; &lt;br /&gt;
    using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom juacabsou anaprarod*)&lt;br /&gt;
lemma todos_append4:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI:&amp;quot;todos P (xs @ y) = (todos P xs ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((x # xs) @ y) = (P x ∧ todos P (xs @ y ))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ (todos P xs ∧ todos P y)) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P x ∧ todos P xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((x # xs) @ y) = (todos P (x # xs) ∧ todos P y)&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marcarmor13 jeamacpov *)&lt;br /&gt;
lemma todos_append5:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x )&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a x&lt;br /&gt;
  assume HI:&amp;quot;todos P (x @ y) = (todos P x ∧ todos P y) &amp;quot; &lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = ( P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot; ... =( P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; &lt;br /&gt;
    by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Uso de auto. *)&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fracorjim1 *)&lt;br /&gt;
lemma todos_append6:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?Q x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix x a assume HI: &amp;quot;?Q x&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # x @ y)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?Q (a # x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
lemma todos_append7:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a#x) @ y) = (todos P (a#x) ∧ todos P y)&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim marpoldia1 serrodcal anaprarod paupeddeg&lt;br /&gt;
   dancorgar antsancab1 fracorjim1 *) &lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; &lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: todos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom rubgonmar fraortmoy josgarsan danrodcha lucnovdos&lt;br /&gt;
   pabrodmac *) &lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: todos_append)&lt;br /&gt;
 &lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs, simp, simp add: todos_append,auto)&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Pasos dentro de by *)&lt;br /&gt;
&lt;br /&gt;
(* juacabsou *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
apply (induct xs, simp, simp add: todos_append, auto) &lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Pasos dentro de apply *)&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marcarmor13 jeamacpov *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto, simp_all add: todos_append) &lt;br /&gt;
&lt;br /&gt;
(* Comentario: Uso de simp_all *)  &lt;br /&gt;
  &lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (simp_all add: todos_append, auto)&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Uso de add en simp_all *)  &lt;br /&gt;
  &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma auxiliar:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by (simp only: rev.simps(1))&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a#xs)) = (todos P (rev xs @ [a]))&amp;quot; &lt;br /&gt;
    by (simp add: &amp;quot;auxiliar&amp;quot;)&lt;br /&gt;
  have &amp;quot;… = ((todos P (rev xs)) ∧ (todos P [a]))&amp;quot; &lt;br /&gt;
    by (simp add: todos_append)&lt;br /&gt;
  have &amp;quot;… =  (todos P (rev xs) ∧ P a)&amp;quot; by simp&lt;br /&gt;
  also have Aux: &amp;quot;… = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
  have Aux1: &amp;quot;… = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  have &amp;quot;(todos P (rev xs) ∧ P a) = (P a ∧ todos P xs)&amp;quot; &lt;br /&gt;
    using Aux Aux1 by simp&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a#xs)) = todos P (a#xs)&amp;quot; &lt;br /&gt;
    by (simp add: todos_append)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Comentarios: &lt;br /&gt;
   + Ruptura de cadena de igualdades.&lt;br /&gt;
   + Uso de hechos auxiliares&lt;br /&gt;
   + Uso de arith&lt;br /&gt;
*)   &lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 ferrenseg crigomgom serrodcal juacabsou rubgonmar&lt;br /&gt;
   josgarsan pablucoto pabrodmac lucnovdos marcarmor13 jeamacpov *) &lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a])&amp;quot; &lt;br /&gt;
    by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = (todos P (a#xs))&amp;quot; by simp    &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((todos P (rev xs)) ∧ todos P [a])&amp;quot; &lt;br /&gt;
    by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy serrodcal *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume H1: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot; todos P (rev (a # xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; &lt;br /&gt;
    by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show  &amp;quot;todos P (rev (a # xs)) = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs &amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = todos P (rev(xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a]) &amp;quot; &lt;br /&gt;
    by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = todos P ([a] @ xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P(rev xs) ∧ todos P [a])&amp;quot; &lt;br /&gt;
    by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; &lt;br /&gt;
    by (simp add: HOL.conj_commute)&lt;br /&gt;
  also have &amp;quot;... = todos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
  finally show  &amp;quot;todos P (rev (a#xs))= todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Uso de HOL.conj_commute *)&lt;br /&gt;
&lt;br /&gt;
(* anaprarod fracorjim1 *)  &lt;br /&gt;
(* es igual que las anteriores pero con el final también con patrones *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by auto&lt;br /&gt;
  next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a#xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; &lt;br /&gt;
    by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;… = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; &lt;br /&gt;
    by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; &lt;br /&gt;
    by (simp add: HOL.conj_commute)&lt;br /&gt;
  also have &amp;quot;… = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* antsancab1 *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos P (rev[]) = todos P[]&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev(a#xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = (todos P ([a] @ xs))&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar o refutar:&lt;br /&gt;
    algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim ferrenseg paupeddeg crigomgom serrodcal wilmorort&lt;br /&gt;
   juacabsou rubgonmar anaprarod marpoldia1 fraortmoy josgarsan&lt;br /&gt;
   danrodcha pablucoto lucnovdos marcarmor13 jeamacpov antsancab1 fracorjim1 pabrodmac *)  &lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot; &lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo: &lt;br /&gt;
      P={a1}, Q={a2}, xs={a1,a2}. &lt;br /&gt;
   En este ejemplo:&lt;br /&gt;
   · &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot;&lt;br /&gt;
   · &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  assume H1: &amp;quot;xs = [a, b]&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;P a = True&amp;quot;&lt;br /&gt;
  assume H3: &amp;quot;Q a = False&amp;quot;&lt;br /&gt;
  assume H4: &amp;quot;P b = False&amp;quot;&lt;br /&gt;
  assume H5: &amp;quot;Q b = True&amp;quot; &lt;br /&gt;
  have F1: &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; &lt;br /&gt;
    using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
  have F2: &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot; &lt;br /&gt;
    using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∧ Q x) xs ≠ (algunos P xs ∧ algunos Q xs)&amp;quot; &lt;br /&gt;
    using F1 F2 by simp&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom rubgonmar wilmorort anaprarod &lt;br /&gt;
   fraortmoy juacabsou paupeddeg josgarsan danrodcha pablucoto lucnovdos&lt;br /&gt;
   marcarmor13 jeamacpov antsancab1 pabrodmac *) &lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
(* anaprarod dancorgar serrodcal fracorjim1 *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma AUX: &amp;quot;algunos (λa. P (f a)) xs = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x#xs)) = (algunos P ((f x)#(map f xs)))&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
  also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; &lt;br /&gt;
    by (simp only: algunos.simps(2))&lt;br /&gt;
  also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume C1: &amp;quot;(P (f x))&amp;quot;&lt;br /&gt;
    have Aux: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = True&amp;quot; &lt;br /&gt;
      using C1 by simp&lt;br /&gt;
    have  Aux1: &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
      using C1 by simp &lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = &lt;br /&gt;
               ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
      using Aux Aux1 by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume C2: &amp;quot;¬(P (f x))&amp;quot;&lt;br /&gt;
    have Aux2: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = &lt;br /&gt;
                (algunos P (map f xs))&amp;quot; using C2 by simp&lt;br /&gt;
    have Aux3: &amp;quot;… = (algunos (P o f) xs)&amp;quot; using HI by (simp add: AUX)&lt;br /&gt;
    also have &amp;quot;… =  ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
      using C2 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = &lt;br /&gt;
               ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
      using Aux2 Aux3 by simp&lt;br /&gt;
   qed&lt;br /&gt;
  also have &amp;quot;… = (((P o f) x) ∨ (algunos (P o f) xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x#xs)) = (algunos (P o f) (x#xs))&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Se puede simplificar. *)&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (map f (x # xs)) = algunos P ((f x) # (map f xs))&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
    also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (((P ∘ f) x) ∨ (algunos (P ∘ f) xs))&amp;quot; &lt;br /&gt;
      using HI by simp&lt;br /&gt;
    also have &amp;quot;… = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (a # xs)) = algunos P ((f a)#map f xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; &lt;br /&gt;
    by simp &lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos (P ∘ f) xs)&amp;quot; &lt;br /&gt;
    using HI by simp &lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar anaprarod marpoldia1 juacabsou danrodcha&lt;br /&gt;
   paupeddeg josgarsan lucnovdos pabrodmac *) &lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x # xs))  = algunos P ((f x) # (map f xs))&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P ∘ f) x ∨ algunos (P ∘ f) xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* wilmorort pablucoto marcarmor13 jeamacpov *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?P xs&amp;quot; )&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (a # xs))  = (P (f a) ∨ algunos P (map f xs))&amp;quot;  &lt;br /&gt;
    by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f a) ∨ algunos (P ∘ f) xs )&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P ∘ f) a ∨ algunos (P ∘ f)xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy serrodcal *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have  &amp;quot;algunos P (map f (a # xs)) = &lt;br /&gt;
         (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos (P ∘ f) [a] ∨  algunos (P ∘ f) xs )&amp;quot; &lt;br /&gt;
    using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a#xs)&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fracorjim1 *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
  have &amp;quot; algunos P (map f (a # xs)) = algunos P ((f a)#(map f xs))&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
  also have &amp;quot;… = (P (f a) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (P (f a) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by blast&lt;br /&gt;
  also have &amp;quot;… = ((P ∘ f) a ∨ algunos (P ∘ f) xs)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;… = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?Q (a # xs)&amp;quot; by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P o f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x#xs)) = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
  also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x#xs)) = algunos (P o f) (x#xs)&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* antsancab1 *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (a # xs)) = algunos P (f a # map f xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f a) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f a) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg crigomgom rubgonmar  wilmorort&lt;br /&gt;
   fraortmoy danrodcha pablucoto dancorgar josgarsan anaprarod juacabsou&lt;br /&gt;
   lucnovdos marcarmor13 jeamacpov antsancab1 pabrodmac *)  &lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
(* anaprarod fracorjim1 *)&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
apply (induct  xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg marpoldia1 wilmorort dancorgar josgarsan&lt;br /&gt;
   juacabsou serrodcal lucnovdos rubgonmar *) &lt;br /&gt;
lemma algunos_append:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (P a ∨ (algunos P (xs @ ys)))&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (algunos P xs ∨ algunos P ys))&amp;quot; &lt;br /&gt;
    using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = &lt;br /&gt;
                (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
lemma algunos_append2:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((x#xs) @ ys) = algunos P (x#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P x) ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P x) ∨ (algunos P xs) ∨ (algunos P ys))&amp;quot; &lt;br /&gt;
    using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((algunos P (x#xs)) ∨ (algunos P ys))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((x#xs) @ ys) = &lt;br /&gt;
                (algunos P (x#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg*)&lt;br /&gt;
lemma algunos_append3:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = &lt;br /&gt;
        (algunos P [a] ∨ ( algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ (algunos P xs ∨ algunos P ys))&amp;quot; &lt;br /&gt;
    using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = &lt;br /&gt;
                (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
lemma algunos_append4:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = &lt;br /&gt;
        (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; &lt;br /&gt;
    using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = ((algunos P [a] ∨ algunos P xs) ∨ algunos P ys)&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = &lt;br /&gt;
                (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto anaprarod marcarmor13 jeamacpov pabrodmac *)&lt;br /&gt;
lemma algunos_append5:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a#xs) @ ys) = algunos P (a#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; &lt;br /&gt;
    using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* antsancab1 *)&lt;br /&gt;
lemma algunos_append6: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (P a ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ algunos P xs ∨ algunos P ys)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 rubgonmar paupeddeg dancorgar&lt;br /&gt;
   anaprarod serrodcal antsancab1 fracorjim1 *) &lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: algunos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom danrodcha pablucoto josgarsan pabrodmac lucnovdos&lt;br /&gt;
   marcarmor13 jeamacpov *) &lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: algunos_append)&lt;br /&gt;
&lt;br /&gt;
(* wilmorort juacabsou *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: algunos_append,auto) &lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma auxiliar1:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto &lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (x#xs)) = (algunos P (rev xs @ [x]))&amp;quot; &lt;br /&gt;
    using auxiliar1 by simp&lt;br /&gt;
  also have &amp;quot;… = ((algunos P (rev xs)) ∨ (algunos P [x]))&amp;quot; &lt;br /&gt;
    by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;… = ((P x) ∨ (algunos P (rev xs)))&amp;quot; by simp arith&lt;br /&gt;
  also have &amp;quot;… = ((P x) ∨ (algunos P xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (x#xs)) = (algunos P (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [x])&amp;quot; &lt;br /&gt;
      by (simp add: algunos_append)&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P x ∨ algunos P xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
 &lt;br /&gt;
(* ivamenjim marpoldia1*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = (algunos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ algunos P [a])&amp;quot; &lt;br /&gt;
    by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar serrodcal lucnovdos*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI:&amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ (algunos P [a]))&amp;quot; &lt;br /&gt;
    by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = ((algunos P xs) ∨ (algunos P [a]))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P [a]) ∨ (algunos P xs))&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom pablucoto anaprarod rubgonmar juacabsou marcarmor13 jeamacpov pabrodmac *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot; algunos P (rev xs) = algunos P xs&amp;quot; &lt;br /&gt;
  have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (rev xs) ∨ algunos P [x])&amp;quot;  &lt;br /&gt;
    by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs  ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = algunos P (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;  (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P(rev xs) ∨ algunos P [a])&amp;quot; &lt;br /&gt;
    by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; &lt;br /&gt;
    by (simp add: HOL.disj_commute)&lt;br /&gt;
  also have &amp;quot;... = algunos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
  finally show  &amp;quot;algunos  P (rev (a#xs))= algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [a])&amp;quot; &lt;br /&gt;
    by (simp add:algunos_append)&lt;br /&gt;
  also have &amp;quot;… = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P [a] ∨ algunos P xs)&amp;quot; &lt;br /&gt;
    by (simp add: HOL.disj_commute)&lt;br /&gt;
  also have &amp;quot;… = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* antsancab1 *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = (algunos P ((rev xs) @ [a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (rev xs) ∨ algunos P [a])&amp;quot; by (simp add:algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by auto&lt;br /&gt;
  also have &amp;quot;... = algunos P (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Encontrar un término no trivial Z tal que sea cierta la &lt;br /&gt;
  siguiente ecuación:&lt;br /&gt;
     algunos (λx. P x ∨ Q x) xs = Z&lt;br /&gt;
  y demostrar la equivalencia de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = &lt;br /&gt;
       ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = &lt;br /&gt;
       ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∨ Q x) (x#xs) = &lt;br /&gt;
        (((λx. P x ∨ Q x) x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P x ∨ Q x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot; by simp&lt;br /&gt;
  also have H1: &amp;quot;… = ((((λx. P x) x) ∨ (algunos (λx. P x) xs)) ∨ &lt;br /&gt;
                       (((λx. Q x) x) ∨ (algunos (λx. Q x) xs)))&amp;quot;&lt;br /&gt;
    using HI by simp arith&lt;br /&gt;
  have H2: &amp;quot;… = ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
  have C: &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
           ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
    using H1 H2 by simp&lt;br /&gt;
  finally show &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
                ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
    using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* CComentario: Ruptura de la cadena de igualdades. *)&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos  (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. (P x ∨ Q x)) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = &lt;br /&gt;
        (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = &lt;br /&gt;
          ((P x) ∨ (Q x) ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ (Q x) ∨ algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
      using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (((P x) ∨ algunos P xs) ∨ ((Q x) ∨ algunos Q xs))&amp;quot; &lt;br /&gt;
      by auto&lt;br /&gt;
    also have &amp;quot;… = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis by simp &lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Uso de auto *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = &lt;br /&gt;
        (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
    using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = &lt;br /&gt;
                (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Uso de auto *)&lt;br /&gt;
&lt;br /&gt;
(* wilmorort danrodcha anaprarod juacabsou rubgonmar*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = &lt;br /&gt;
       (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = &lt;br /&gt;
       (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
      (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = &lt;br /&gt;
        (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨  &lt;br /&gt;
                    (¬ todos (λx. ¬ P x) xs ∨ ¬ todos (λx. ¬ Q x) xs))&amp;quot; &lt;br /&gt;
    using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ ¬ todos (λx. ¬ P x) xs ∨ &lt;br /&gt;
                    Q a ∨  ¬ todos (λx. ¬ Q x) xs )&amp;quot; by arith&lt;br /&gt;
  finally show  &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = &lt;br /&gt;
                 (~ todos (λx. ¬ P x) (a # xs) ∨ &lt;br /&gt;
                   ~ todos (λx. ¬ Q x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
      (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
    have 1:&amp;quot; (Q a ∨ algunos P xs) = (algunos P xs ∨ Q a)&amp;quot; &lt;br /&gt;
      by (simp add: HOL.disj_commute)&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = &lt;br /&gt;
          (algunos P [a] ∨ algunos Q [a] ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (Q a ∨ algunos P xs) ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
      using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ algunos P xs ∨ Q a ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
      using 1 by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?R (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) [] ⟹ (algunos P [] ∧ algunos Q [])&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
  have F1: &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ &lt;br /&gt;
            ((P xf ∧ Q xf) ∨ algunos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have F2: &amp;quot;… ⟹ (P xf ∧ Q xf ∨ (algunos P xs ∧ algunos Q xs))&amp;quot; &lt;br /&gt;
    using HI by simp&lt;br /&gt;
  have F3: &amp;quot;((P xf ∧ Q xf) ∨ (algunos P xs ∧ algunos Q xs)) ⟹ &lt;br /&gt;
            ((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs))&amp;quot; by blast&lt;br /&gt;
  have F4: &amp;quot;((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs)) ⟹ &lt;br /&gt;
     (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot; by simp&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ &lt;br /&gt;
        (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot;&lt;br /&gt;
    using F1 F2 F3 F4 by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom serrodcal marcarmor13 jeamacpov pabrodmac *)&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs) &amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q []) &amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = &lt;br /&gt;
        (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ (algunos P xs ∨ algunos Q xs))&amp;quot; &lt;br /&gt;
    using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (((P a) ∨ algunos P xs) ∨ ((Q a) ∨ algunos Q xs))&amp;quot; &lt;br /&gt;
    by arith &lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = &lt;br /&gt;
                (algunos P (a # xs) ∨ algunos Q (a # xs)) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod juacabsou rubgonmar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
      (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∨ Q x) (x#xs) =&lt;br /&gt;
        (P x ∨ Q x ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (P x ∨ Q x ∨ algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
    using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (P x ∨ algunos P xs ∨ Q x ∨ algunos Q xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* antsancab1 *)&lt;br /&gt;
lemma &amp;quot;algunos(λx. P x ∨ Q x) xs = algunos(λx. P x) xs ∨ algunos(λx. Q x) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos(λx. P x ∨ Q x) xs = (algunos(λx. P x) xs ∨ algunos(λx. Q x) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ algunos P xs ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort migtermor marpoldia1 crigomgom rubgonmar&lt;br /&gt;
   paupeddeg danrodcha pablucoto dancorgar josgarsan anaprarod juacabsou&lt;br /&gt;
   lucnovdos serrodcal marcarmor13 jeamacpov antsancab1 pabrodmac *)  &lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot; &lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.2. Demostrar o refutar datalladamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom paupeddeg josgarsan&lt;br /&gt;
   juacabsou serrodcal wilmorort *) &lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. ¬ P x) [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. ¬ P x) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (a # xs) = (P a ∨ (algunos P xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (¬ todos (λx. ¬ P x) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (a # xs) = (¬ todos (λx. ¬ P x) (a # xs))&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (x # xs) = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot;&lt;br /&gt;
  proof - &lt;br /&gt;
    have &amp;quot;algunos P (x # xs) = ((P x) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ ¬ todos (λx. (¬ P x)) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (¬ (P x) ∧ todos (λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto anaprarod rubgonmar marcarmor13 jeamacpov pabrodmac *)&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (a # xs) = (P a ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (P a ∨ (¬ todos (λx. (¬ P x)) xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (¬(¬(P a) ∧ todos(λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (¬ todos(λx. (¬ P x)) (a # xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar*)&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (xf#xs) = ((P xf) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ( (P xf) ∨ (¬ todos (λx. (¬ P x)) xs) )&amp;quot; &lt;br /&gt;
    using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (¬((¬P xf) ∧ (todos (λx. (¬ P x)) xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (xf#xs) = (¬todos (λx. (¬ P x)) (xf#xs))&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (n#xs) = ((P n) ∨ (algunos P xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P n) ∨ (¬ todos (λx. (¬ P x)) xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (¬((¬P n) ∧  todos (λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (¬ todos (λx. (¬ P x)) (n#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (n#xs) = (¬ todos (λx. (¬ P x)) (n#xs))&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* antsancab1 *)&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. ¬ P x) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. ¬ P x) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (a # xs) = (P a ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (¬ todos (λx. ¬ P x) xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (¬ todos (λx. ¬ P x) (a#xs)))&amp;quot; by auto&lt;br /&gt;
  finally show &amp;quot;algunos P (a # xs) = (¬ todos (λx. ¬ P x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg migtermor serrodcal crigomgom rubgonmar&lt;br /&gt;
   marpoldia1 paupeddeg danrodcha dancorgar pablucoto anaprarod&lt;br /&gt;
   juacabsou lucnovdos marcarmor13 wilmorort jeamacpov fracorjim1 pabrodmac *)  &lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn x []     = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* antsancab1 *)&lt;br /&gt;
fun estaEn1 :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn1 x [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn1 x (a#xs) = (if x = a then True else estaEn1 x xs )&amp;quot;   (* Se detiene al encontrar la primera coincidencia *)&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn1 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn1 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Expresar la relación existente entre estaEn y algunos. &lt;br /&gt;
  Demostrar dicha relación de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom  *)&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar13:&lt;br /&gt;
 &amp;quot;(x=a) = ((λa. a=x) a)&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a#xs) = ((a=x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
  also have H: &amp;quot;… = ((a=x) ∨ (algunos (λa. a=x) xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (((λa. a=x) a) ∨ (algunos (λa. a=x) xs))&amp;quot; &lt;br /&gt;
    using auxiliar13  by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos (λa. a=x) (a#xs))&amp;quot; by simp&lt;br /&gt;
  have C: &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using H by simp &lt;br /&gt;
  finally show &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; &lt;br /&gt;
    using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Ruptura de la cadena de igualdades. Se puede simplificar. *)&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma estaEn_algunos:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos_2:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x=y) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn y (x # xs) = algunos (λx. x=y) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;estaEn y (x # xs) = (y=x ∨ estaEn y xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (y=x ∨ algunos (λx. x=y) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (x=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos (λx. x=y) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Uso de auto *)&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg dancorgar juacabsou serrodcal lucnovdos wilmorort *)&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; &lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; estaEn x [] = algunos (λa. a = x) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (λa. a = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = (a = x ∨ estaEn x xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (a = x ∨ algunos (λa. a = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (λa. a = x) (a # xs)&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn x [] = algunos (op = x) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (op = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = ((a = x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  (a = x ∨ algunos (op = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (op = x) (a # xs)&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Comentarios:&lt;br /&gt;
   + Uso de (op = x)&lt;br /&gt;
   + Uso de auto&lt;br /&gt;
*)&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a [] = algunos (op = a) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs &lt;br /&gt;
  assume HI: &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn a (x # xs) = ((x = a) ∨ (estaEn a xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (x = a ∨ algunos (op = a) xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((op = a) x ∨ algunos (op = a) xs)&amp;quot; &lt;br /&gt;
    by (simp add:HOL.eq_commute)&lt;br /&gt;
  also have &amp;quot;… = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;estaEn a (x # xs) = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marcarmor13 jeamacpov pabrodmac *)&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x = y) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; estaEn y xs = algunos (λx. x = y) xs &amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn y (a # xs) = (y = a ∨ estaEn y xs)&amp;quot;  by simp &lt;br /&gt;
  also have &amp;quot;... = (y = a ∨ algunos (λx. x = y) xs) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (a=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
  also have &amp;quot;... = (algunos (λx. x = y) (a#xs))&amp;quot;  by simp&lt;br /&gt;
  finally show &amp;quot;estaEn y (a # xs) = algunos (λx. x = y) (a # xs) &amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Uso de auto *)&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* Automática*)&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (λx. a=x) xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* Detallada (igual que las anteriores pero obviando el paso previo al&lt;br /&gt;
   finally) *) &lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (λx. a=x) xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI : &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn a (x#xs) = (x=a ∨ estaEn a xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (x=a ∨ algunos (λx. a=x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (a=x ∨ algunos (λx. a=x) xs)&amp;quot; using HI by auto&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Uso de auto *)&lt;br /&gt;
&lt;br /&gt;
(* antsancab1 *)&lt;br /&gt;
(* Demostrar que&lt;br /&gt;
algunos (λa. a=x) xs = estaEn x xs&lt;br /&gt;
es lo mismo que demostrar&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (λx. a=x) xs&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λa. a=x) xs = estaEn x xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λa. a=x) xs = estaEn x xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λa. a = x) [] = estaEn x []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λa. a = x) xs = estaEn x xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λa. a = x) (a # xs) = ((λa. a = x) a ∨ algunos (λa. a = x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((λa. a = x) a ∨ estaEn x xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (estaEn x (a#xs))&amp;quot; by simp  (* no tengo claro cómo simplifica el &amp;quot;(λa. a = x) a&amp;quot; *)&lt;br /&gt;
  finally show &amp;quot;algunos (λa. a = x) (a # xs) = estaEn x (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 *)&lt;br /&gt;
lemma estaEnYAlgunos :&lt;br /&gt;
	&amp;quot;estaEn a xs = algunos (λx. x = a) xs&amp;quot; (is &amp;quot;?P a xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
	show &amp;quot;?P a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
	fix a x xs&lt;br /&gt;
	assume HI : &amp;quot;?P a xs&amp;quot;&lt;br /&gt;
	have &amp;quot;estaEn a (x#xs) = ((a = x) ∨ estaEn a xs)&amp;quot;&lt;br /&gt;
		by (simp only:estaEn.simps(2))&lt;br /&gt;
  also have &amp;quot;… = (a = x ∨ algunos (λx. x = a) xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((λx. x = a) x ∨ algunos (λx. x = a) xs)&amp;quot; by auto&lt;br /&gt;
  also have &amp;quot;… = algunos (λx. x = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P a (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_8&amp;diff=1303</id>
		<title>Relación 8</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_8&amp;diff=1303"/>
		<updated>2017-01-18T17:21:56Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R8: Deducción natural proposicional en Isabelle/HOL *}&lt;br /&gt;
&lt;br /&gt;
theory R8_Deduccion_natural_proposicional&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  Demostrar o refutar los siguientes lemas usando sólo las reglas&lt;br /&gt;
  básicas de deducción natural de la lógica proposicional, de los&lt;br /&gt;
  cuantificadores y de la igualdad: &lt;br /&gt;
  · conjI:      ⟦P; Q⟧ ⟹ P ∧ Q&lt;br /&gt;
  · conjunct1:  P ∧ Q ⟹ P&lt;br /&gt;
  · conjunct2:  P ∧ Q ⟹ Q  &lt;br /&gt;
  · notnotD:    ¬¬ P ⟹ P&lt;br /&gt;
  · mp:         ⟦P ⟶ Q; P⟧ ⟹ Q &lt;br /&gt;
  · impI:       (P ⟹ Q) ⟹ P ⟶ Q&lt;br /&gt;
  · disjI1:     P ⟹ P ∨ Q&lt;br /&gt;
  · disjI2:     Q ⟹ P ∨ Q&lt;br /&gt;
  · disjE:      ⟦P ∨ Q; P ⟹ R; Q ⟹ R⟧ ⟹ R &lt;br /&gt;
  · FalseE:     False ⟹ P&lt;br /&gt;
  · notE:       ⟦¬P; P⟧ ⟹ R&lt;br /&gt;
  · notI:       (P ⟹ False) ⟹ ¬P&lt;br /&gt;
  · iffI:       ⟦P ⟹ Q; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
  · iffD1:      ⟦Q = P; Q⟧ ⟹ P &lt;br /&gt;
  · iffD2:      ⟦P = Q; Q⟧ ⟹ P&lt;br /&gt;
  · ccontr:     (¬P ⟹ False) ⟹ P&lt;br /&gt;
&lt;br /&gt;
  · allI:       ⟦∀x. P x; P x ⟹ R⟧ ⟹ R&lt;br /&gt;
  · allE:       (⋀x. P x) ⟹ ∀x. P x&lt;br /&gt;
  · exI:        P x ⟹ ∃x. P x&lt;br /&gt;
  · exE:        ⟦∃x. P x; ⋀x. P x ⟹ Q⟧ ⟹ Q&lt;br /&gt;
&lt;br /&gt;
  · refl:       t = t&lt;br /&gt;
  · subst:      ⟦s = t; P s⟧ ⟹ P t&lt;br /&gt;
  · trans:      ⟦r = s; s = t⟧ ⟹ r = t&lt;br /&gt;
  · sym:        s = t ⟹ t = s&lt;br /&gt;
  · not_sym:    t ≠ s ⟹ s ≠ t&lt;br /&gt;
  · ssubst:     ⟦t = s; P s⟧ ⟹ P t&lt;br /&gt;
  · box_equals: ⟦a = b; a = c; b = d⟧ ⟹ a: = d&lt;br /&gt;
  · arg_cong:   x = y ⟹ f x = f y&lt;br /&gt;
  · fun_cong:   f = g ⟹ f x = g x&lt;br /&gt;
  · cong:       ⟦f = g; x = y⟧ ⟹ f x = g y&lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  Se usarán las reglas notnotI, mt y not_ex que demostramos a continuación.&lt;br /&gt;
  *}&lt;br /&gt;
&lt;br /&gt;
lemma notnotI: &amp;quot;P ⟹ ¬¬ P&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma mt: &amp;quot;⟦F ⟶ G; ¬G⟧ ⟹ ¬F&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma no_ex: &amp;quot;¬(∃x. P(x)) ⟹ ∀x. ¬P(x)&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Demostrar&lt;br /&gt;
     ¬q ⟶ ¬p ⊢ p ⟶ q&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
(* marcarmor13 *)&lt;br /&gt;
--&amp;quot;usando un supuesto ¬¬p&amp;quot;&lt;br /&gt;
lemma ejercicio_1:&lt;br /&gt;
 assumes 1: &amp;quot;¬q ⟶ ¬p&amp;quot; and &lt;br /&gt;
         2: &amp;quot;¬¬p&amp;quot;  &lt;br /&gt;
shows &amp;quot;p ⟶ q&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
 have 3: &amp;quot;¬¬q&amp;quot; using 1 2  by (rule mt)&lt;br /&gt;
 have 4: &amp;quot;q&amp;quot; using 3 by (rule  notnotD)&lt;br /&gt;
 show &amp;quot;p ⟶ q&amp;quot; using 4 by (rule impI)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto jeamacpov migtermor *)&lt;br /&gt;
lemma ejercicio_1_2:&lt;br /&gt;
  assumes &amp;quot;¬q ⟶ ¬p&amp;quot; &lt;br /&gt;
  shows &amp;quot;p ⟶ q&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  {assume &amp;quot;p&amp;quot;&lt;br /&gt;
  hence &amp;quot;¬¬p&amp;quot; by (rule notnotI)&lt;br /&gt;
  with `¬q ⟶ ¬p` have &amp;quot;¬¬q&amp;quot; by (rule mt)  &lt;br /&gt;
  hence &amp;quot;q&amp;quot; by (rule notnotD)}&lt;br /&gt;
  then show &amp;quot;p ⟶ q&amp;quot; by (rule impI)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim serrodcal anaprarod marpoldia1 manmorjim1 crigomgom juancabsou ferrenseg fraortmoy*)&lt;br /&gt;
lemma ejercicio_1_3:&lt;br /&gt;
  assumes 1: &amp;quot;¬q ⟶ ¬p&amp;quot; &lt;br /&gt;
  shows      &amp;quot;p ⟶ q&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  {assume 2:&amp;quot;p&amp;quot;&lt;br /&gt;
   then have 3: &amp;quot;¬¬p&amp;quot; by (rule notnotI)&lt;br /&gt;
   have 4: &amp;quot;¬¬q&amp;quot; using 1 3 by (rule mt)&lt;br /&gt;
   then have 5: &amp;quot;q&amp;quot; by (rule notnotD)}&lt;br /&gt;
  thus &amp;quot;p ⟶ q&amp;quot; by (rule impI)&lt;br /&gt;
qed   &lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma ejercicio_1_4:&lt;br /&gt;
 assumes &amp;quot;¬q ⟶ ¬p&amp;quot;&lt;br /&gt;
 shows &amp;quot;p ⟶ q&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
{assume &amp;quot;p&amp;quot;&lt;br /&gt;
hence &amp;quot;¬¬p&amp;quot; by (rule notnotI)&lt;br /&gt;
with assms have &amp;quot;¬¬q&amp;quot; by (rule mt)&lt;br /&gt;
then have &amp;quot;q&amp;quot; by (rule notnotD)}&lt;br /&gt;
thus &amp;quot;p ⟶ q&amp;quot; by (rule impI)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma danrodcha paupeddeg pabrodmac *)&lt;br /&gt;
&amp;quot;quita la limitación de -&amp;quot;&lt;br /&gt;
lemma ejercicio_1_5:&lt;br /&gt;
 assumes &amp;quot;¬q ⟶ ¬p&amp;quot;&lt;br /&gt;
 shows &amp;quot;p ⟶ q&amp;quot;&lt;br /&gt;
proof &lt;br /&gt;
assume &amp;quot;p&amp;quot;&lt;br /&gt;
hence &amp;quot;¬¬p&amp;quot; by (rule notnotI)&lt;br /&gt;
with assms have &amp;quot;¬¬q&amp;quot; by (rule mt)&lt;br /&gt;
thus &amp;quot;q&amp;quot; by (rule notnotD)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Demostrar&lt;br /&gt;
     ¬(¬p ∧ ¬q) ⊢ p ∨ q&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
(* marcarmor13 *)&lt;br /&gt;
--&amp;quot;usando un supuesto ¬p ∧ ¬q&amp;quot;&lt;br /&gt;
lemma ejercicio_2:&lt;br /&gt;
  assumes 1: &amp;quot;¬(¬p ∧ ¬q)&amp;quot; and&lt;br /&gt;
          2:&amp;quot;¬p ∧ ¬q&amp;quot;       &lt;br /&gt;
  shows &amp;quot;p ∨ q&amp;quot;&lt;br /&gt;
proof-&lt;br /&gt;
  have 3: &amp;quot;p&amp;quot;using 1 2 by (rule notE)&lt;br /&gt;
show &amp;quot;p ∨ q&amp;quot; using 3 by (rule disjI1)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim serrodcal marpoldia1 *)&lt;br /&gt;
lemma ejercicio_2_2:&lt;br /&gt;
  assumes 1: &amp;quot;¬(¬p ∧ ¬q)&amp;quot;&lt;br /&gt;
  shows      &amp;quot;p ∨ q&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
   {assume 2:&amp;quot;(¬p ∧ ¬q)&amp;quot;&lt;br /&gt;
   have &amp;quot;p&amp;quot; using 1 2 by (rule notE)&lt;br /&gt;
   then have &amp;quot;p ∨ q&amp;quot; by (rule disjI1)}&lt;br /&gt;
   thus &amp;quot;p ∨ q&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto jeamacpov *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ejercicio2:&lt;br /&gt;
  assumes &amp;quot;¬(p ∨ q)&amp;quot;&lt;br /&gt;
  shows &amp;quot;¬p ∧ ¬q&amp;quot;&lt;br /&gt;
proof&lt;br /&gt;
  {assume &amp;quot;p&amp;quot;&lt;br /&gt;
  hence &amp;quot;p ∨ q&amp;quot; by  (rule disjI1)  &lt;br /&gt;
  with  `¬(p ∨ q)` have &amp;quot;False&amp;quot; by (rule notE)}&lt;br /&gt;
  then show &amp;quot;¬p&amp;quot; ..&lt;br /&gt;
next&lt;br /&gt;
  {assume &amp;quot;q&amp;quot;&lt;br /&gt;
  hence &amp;quot;p ∨ q&amp;quot; by (rule disjI2)&lt;br /&gt;
  with  `¬(p ∨ q)` have &amp;quot;False&amp;quot; by (rule notE)}&lt;br /&gt;
  then show &amp;quot;¬q&amp;quot; ..&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 lemma ejercicio_2_3:&lt;br /&gt;
  assumes &amp;quot;¬(¬p ∧ ¬q)&amp;quot;&lt;br /&gt;
  shows &amp;quot;p ∨ q&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  {assume 2:&amp;quot;¬(p ∨ q)&amp;quot;  &lt;br /&gt;
  hence &amp;quot;¬p ∧ ¬q&amp;quot; by (rule  aux_ejercicio2)&lt;br /&gt;
  with  `¬(¬p ∧ ¬q)` have &amp;quot;False&amp;quot; ..}&lt;br /&gt;
  then show &amp;quot;p ∨ q&amp;quot; by (rule ccontr)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha bowma *)&lt;br /&gt;
lemma ej_2:&lt;br /&gt;
  assumes &amp;quot;¬(¬p ∧ ¬q)&amp;quot;&lt;br /&gt;
  shows &amp;quot;p ∨ q&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;¬p ∨ p&amp;quot; by (rule excluded_middle)&lt;br /&gt;
  thus &amp;quot;p ∨ q&amp;quot;&lt;br /&gt;
  proof (rule disjE)&lt;br /&gt;
    { assume &amp;quot;¬p&amp;quot;&lt;br /&gt;
      have &amp;quot;¬q ∨ q&amp;quot; by (rule excluded_middle)&lt;br /&gt;
      thus &amp;quot;p ∨ q&amp;quot;&lt;br /&gt;
      proof (rule disjE)&lt;br /&gt;
      { assume &amp;quot;¬q&amp;quot;&lt;br /&gt;
        with `¬p` have &amp;quot;¬p ∧ ¬q&amp;quot; by (rule conjI)&lt;br /&gt;
        with assms show &amp;quot;p ∨ q&amp;quot; by (rule notE)}&lt;br /&gt;
      next&lt;br /&gt;
      { assume &amp;quot;q&amp;quot;&lt;br /&gt;
        then show &amp;quot;p ∨ q&amp;quot; by (rule disjI2)}&lt;br /&gt;
      qed}&lt;br /&gt;
    next&lt;br /&gt;
    { assume &amp;quot;p&amp;quot;&lt;br /&gt;
      thus &amp;quot;p ∨ q&amp;quot; by (rule disjI1)}&lt;br /&gt;
    qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod crigomgom juancabsou ferrenseg *)&lt;br /&gt;
(* Igual que el anterior pero con etiquetas *)&lt;br /&gt;
lemma ejercicio_2_4:&lt;br /&gt;
  assumes 0:  &amp;quot;¬(¬p ∧ ¬q)&amp;quot;&lt;br /&gt;
  shows   &amp;quot;p ∨ q&amp;quot;&lt;br /&gt;
proof-&lt;br /&gt;
  have &amp;quot;¬p ∨ p&amp;quot; by (rule excluded_middle)&lt;br /&gt;
  thus &amp;quot;p ∨ q&amp;quot;&lt;br /&gt;
  proof (rule disjE)&lt;br /&gt;
    {assume 1: &amp;quot;¬p&amp;quot; &lt;br /&gt;
      have &amp;quot;¬q ∨ q&amp;quot; by (rule excluded_middle)&lt;br /&gt;
      thus &amp;quot;p ∨ q&amp;quot;&lt;br /&gt;
      proof (rule disjE)&lt;br /&gt;
        {assume 2: &amp;quot;¬q&amp;quot;&lt;br /&gt;
          have 3: &amp;quot;(¬p ∧ ¬q)&amp;quot; using 1 2 by (rule conjI)&lt;br /&gt;
          have &amp;quot;p ∨ q&amp;quot; using 0 3 by (rule notE)&lt;br /&gt;
          thus &amp;quot;p ∨ q&amp;quot; by this}&lt;br /&gt;
        next&lt;br /&gt;
        {assume 4: &amp;quot;q&amp;quot;&lt;br /&gt;
          have &amp;quot;p ∨ q&amp;quot; using 4 by (rule disjI2)&lt;br /&gt;
          thus &amp;quot;p ∨ q&amp;quot; by this}&lt;br /&gt;
        qed}&lt;br /&gt;
    next&lt;br /&gt;
    {assume 5: &amp;quot;p&amp;quot;&lt;br /&gt;
      have &amp;quot;p ∨ q&amp;quot; using 5 by (rule disjI1)&lt;br /&gt;
      thus &amp;quot;p ∨ q&amp;quot; by this}&lt;br /&gt;
   qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma lem:&lt;br /&gt;
 shows &amp;quot;p∨¬p&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
 {assume 1: &amp;quot;¬(p∨¬p)&amp;quot;&lt;br /&gt;
  {assume 2: &amp;quot;p&amp;quot;&lt;br /&gt;
   then have 3: &amp;quot;p∨¬p&amp;quot; by (rule disjI1)&lt;br /&gt;
   also have 4: &amp;quot;False&amp;quot; using 1 3 by (rule notE)}&lt;br /&gt;
  then have 5: &amp;quot;¬p&amp;quot; by (rule notI)&lt;br /&gt;
  then have 6: &amp;quot;p∨¬p&amp;quot; by (rule disjI2)&lt;br /&gt;
  also have 7: &amp;quot;False&amp;quot; using 1 6 by (rule notE)}&lt;br /&gt;
 thus &amp;quot;p∨¬p&amp;quot; by (rule ccontr)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_2_5:&lt;br /&gt;
 assumes 1: &amp;quot;¬(¬p∧¬q)&amp;quot;&lt;br /&gt;
 shows &amp;quot;p∨q&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
 have 2: &amp;quot;p∨¬p&amp;quot; by (rule lem)&lt;br /&gt;
 moreover&lt;br /&gt;
 {assume 3: p &lt;br /&gt;
  then have 4: &amp;quot;p∨q&amp;quot; by (rule disjI1)}&lt;br /&gt;
 moreover&lt;br /&gt;
 {assume 6: &amp;quot;¬p&amp;quot;&lt;br /&gt;
  {assume 7: &amp;quot;¬q&amp;quot;&lt;br /&gt;
   also have 8: &amp;quot;¬p∧¬q&amp;quot; using 6 7 by (rule conjI)&lt;br /&gt;
   have 9: &amp;quot;False&amp;quot; using 1 8 by (rule notE)}&lt;br /&gt;
  then have 10: &amp;quot;q&amp;quot; by (rule ccontr)&lt;br /&gt;
  then have 11: &amp;quot;p∨q&amp;quot; by (rule disjI2)}&lt;br /&gt;
 ultimately show &amp;quot;p∨q&amp;quot; by (rule disjE)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma aux1:&lt;br /&gt;
  assumes &amp;quot;¬(p ∧ q)&amp;quot;&lt;br /&gt;
  shows &amp;quot;¬p ∨ ¬q&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;¬p ∨ p&amp;quot; by (rule excluded_middle)&lt;br /&gt;
  thus &amp;quot;¬p ∨ ¬q&amp;quot;&lt;br /&gt;
  proof&lt;br /&gt;
    {assume &amp;quot;¬p&amp;quot;&lt;br /&gt;
    thus &amp;quot;¬p ∨ ¬q&amp;quot; by (rule disjI1)}&lt;br /&gt;
    next&lt;br /&gt;
    {assume &amp;quot;p&amp;quot;&lt;br /&gt;
      have &amp;quot;¬q&amp;quot;&lt;br /&gt;
      proof&lt;br /&gt;
      {assume &amp;quot;q&amp;quot;&lt;br /&gt;
      have &amp;quot;(p ∧ q)&amp;quot; using `p` `q`  by (rule conjI)&lt;br /&gt;
      show &amp;quot;False&amp;quot;  using `¬(p ∧ q)` `p ∧ q` by (rule notE)}&lt;br /&gt;
      qed&lt;br /&gt;
      thus &amp;quot;¬p ∨ ¬q&amp;quot; by (rule disjI2)}&lt;br /&gt;
      qed&lt;br /&gt;
qed&lt;br /&gt;
  &lt;br /&gt;
lemma ejercicio_2_5:&lt;br /&gt;
  assumes &amp;quot;¬(¬p ∧ ¬q)&amp;quot;&lt;br /&gt;
  shows &amp;quot;p ∨ q&amp;quot; &lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;¬¬p ∨ ¬¬q&amp;quot; using assms  by (rule aux1)&lt;br /&gt;
  moreover&lt;br /&gt;
  {assume &amp;quot;¬¬p&amp;quot;&lt;br /&gt;
    hence &amp;quot;p&amp;quot; by (rule notnotD)&lt;br /&gt;
    hence &amp;quot;p ∨ q&amp;quot; by (rule disjI1) }&lt;br /&gt;
  moreover&lt;br /&gt;
  {assume &amp;quot;¬¬q&amp;quot;&lt;br /&gt;
    hence &amp;quot;q&amp;quot; by (rule notnotD)&lt;br /&gt;
    hence &amp;quot;p ∨ q&amp;quot; by (rule disjI2) }&lt;br /&gt;
  ultimately show &amp;quot;p ∨ q&amp;quot; by (rule disjE)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_2_6:&lt;br /&gt;
assumes &amp;quot;¬(¬p ∧ ¬q)&amp;quot;&lt;br /&gt;
          &lt;br /&gt;
  shows &amp;quot;p ∨ q&amp;quot;     &lt;br /&gt;
proof -&lt;br /&gt;
have &amp;quot;¬¬p ∨ ¬¬q&amp;quot; using assms by (rule Meson.not_conjD)&lt;br /&gt;
  moreover&lt;br /&gt;
  { assume &amp;quot;¬¬p&amp;quot;&lt;br /&gt;
    hence &amp;quot;p&amp;quot; by (rule notnotD)&lt;br /&gt;
    hence &amp;quot;p ∨ q&amp;quot; by (rule disjI1) }&lt;br /&gt;
  moreover&lt;br /&gt;
  { assume &amp;quot;¬¬q&amp;quot;&lt;br /&gt;
    then have &amp;quot;q&amp;quot; by (rule notnotD)&lt;br /&gt;
    hence &amp;quot;p ∨ q&amp;quot; by (rule disjI2) }&lt;br /&gt;
  ultimately show &amp;quot;p ∨ q&amp;quot; by (rule disjE)&lt;br /&gt;
qed   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Demostrar&lt;br /&gt;
     ¬(¬p ∨ ¬q) ⊢ p ∧ q&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
(* marcarmor13 serrodcal marpoldia1 *)&lt;br /&gt;
--&amp;quot;usando un supuesto ¬p ∨ ¬q&amp;quot;&lt;br /&gt;
lemma ejercicio_3:&lt;br /&gt;
  assumes 1: &amp;quot;¬(¬p ∨ ¬q)&amp;quot; and&lt;br /&gt;
          2:&amp;quot;¬p ∨ ¬q&amp;quot;       &lt;br /&gt;
  shows &amp;quot;p ∧ q&amp;quot;&lt;br /&gt;
proof-&lt;br /&gt;
  have 3: &amp;quot;p&amp;quot;using 1 2 by (rule notE)&lt;br /&gt;
  have 4: &amp;quot;q&amp;quot;using 1 2 by (rule notE)&lt;br /&gt;
show &amp;quot;p ∧ q&amp;quot; using 3 4 by (rule conjI)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto jeamacpov *)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_3_2:  &lt;br /&gt;
  assumes &amp;quot;¬(¬p ∨ ¬q)&amp;quot;&lt;br /&gt;
  shows &amp;quot;p ∧ q&amp;quot;&lt;br /&gt;
proof  &lt;br /&gt;
  have &amp;quot;¬¬p ∧ ¬¬q&amp;quot; using assms(1) by (rule  aux_ejercicio2)  &lt;br /&gt;
  hence &amp;quot;¬¬p&amp;quot;  by (rule conjunct1)&lt;br /&gt;
  show &amp;quot;p&amp;quot; using `¬¬p` by (rule notnotD)&lt;br /&gt;
next &lt;br /&gt;
  have &amp;quot;¬¬p ∧ ¬¬q&amp;quot; using assms(1) by (rule  aux_ejercicio2)  &lt;br /&gt;
  have &amp;quot;¬¬q&amp;quot; using `¬¬p ∧ ¬¬q`  by (rule conjunct2) &lt;br /&gt;
  show &amp;quot;q&amp;quot; using `¬¬q` by (rule notnotD)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma aux: &amp;quot;¬(p ∨ q) ⟹ ¬p ∧ ¬q&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_3_3:&lt;br /&gt;
  assumes 1: &amp;quot;¬(¬p ∨ ¬q)&amp;quot;&lt;br /&gt;
  shows &amp;quot;p ∧ q&amp;quot;&lt;br /&gt;
proof&lt;br /&gt;
  have 2: &amp;quot;¬¬p ∧ ¬¬q&amp;quot; using 1 by (rule aux)&lt;br /&gt;
  have 3: &amp;quot;¬¬p&amp;quot; using 2 ..&lt;br /&gt;
  have 4: &amp;quot;¬¬q&amp;quot; using 2 ..&lt;br /&gt;
  show &amp;quot;p&amp;quot; using 3 by (rule notnotD)&lt;br /&gt;
  show &amp;quot;q&amp;quot; using 4 by (rule notnotD)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha migtermor bowma *)&lt;br /&gt;
lemma ej_3:&lt;br /&gt;
  assumes &amp;quot;¬(¬p ∨ ¬q)&amp;quot;&lt;br /&gt;
  shows &amp;quot;p ∧ q&amp;quot;&lt;br /&gt;
  proof (rule conjI)&lt;br /&gt;
  { assume &amp;quot;¬p&amp;quot;&lt;br /&gt;
    hence &amp;quot;¬p ∨ ¬q&amp;quot; by (rule disjI1)&lt;br /&gt;
    with assms have False by (rule notE)}&lt;br /&gt;
  then show &amp;quot;p&amp;quot; by (rule ccontr)&lt;br /&gt;
  { assume &amp;quot;¬q&amp;quot;&lt;br /&gt;
    hence &amp;quot;¬p ∨ ¬q&amp;quot; by (rule disjI2)&lt;br /&gt;
    with assms have False by (rule notE)}&lt;br /&gt;
  then show &amp;quot;q&amp;quot; by (rule ccontr)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod crigomgom juancabsou ferrenseg *)&lt;br /&gt;
(* Igual que el anterior pero con etiquetas *)&lt;br /&gt;
lemma ejercicio_3_4:&lt;br /&gt;
  assumes &amp;quot;¬(¬p ∨ ¬q)&amp;quot;&lt;br /&gt;
  shows &amp;quot;p ∧ q&amp;quot;&lt;br /&gt;
proof (rule conjI)  &lt;br /&gt;
  {assume 1: &amp;quot;¬p&amp;quot;&lt;br /&gt;
    hence 2: &amp;quot;¬p ∨ ¬q&amp;quot; by (rule disjI1)&lt;br /&gt;
    have &amp;quot;False&amp;quot; using assms 2 by (rule notE)}&lt;br /&gt;
  thus 3: &amp;quot;p&amp;quot; by (rule ccontr)&lt;br /&gt;
  {assume 4: &amp;quot;¬q&amp;quot;&lt;br /&gt;
    hence 5: &amp;quot;¬p ∨ ¬q&amp;quot; by (rule disjI2)&lt;br /&gt;
    have &amp;quot;False&amp;quot; using assms 5 by (rule notE)}&lt;br /&gt;
  thus 6: &amp;quot;q&amp;quot; by (rule ccontr)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma aux2:&lt;br /&gt;
  assumes &amp;quot;¬(p ∨ q)&amp;quot;&lt;br /&gt;
  shows &amp;quot;¬p ∧ ¬q&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;¬p ∨ p&amp;quot; by (rule excluded_middle)&lt;br /&gt;
  thus &amp;quot;¬p ∧ ¬q&amp;quot;&lt;br /&gt;
  proof&lt;br /&gt;
    {assume &amp;quot;¬p&amp;quot; &lt;br /&gt;
      have &amp;quot;¬q ∨ q&amp;quot; by (rule excluded_middle)&lt;br /&gt;
      thus &amp;quot;¬p ∧ ¬q&amp;quot;&lt;br /&gt;
      proof&lt;br /&gt;
        {assume &amp;quot;¬q&amp;quot;&lt;br /&gt;
          show &amp;quot;¬p ∧ ¬q&amp;quot; using `¬p` `¬q` by (rule conjI)}  &lt;br /&gt;
        {assume &amp;quot;q&amp;quot;&lt;br /&gt;
           hence &amp;quot;(p ∨ q)&amp;quot;  by (rule disjI2)&lt;br /&gt;
           have &amp;quot;False&amp;quot;  using `¬(p ∨ q)` `p ∨ q` by (rule notE)&lt;br /&gt;
           thus &amp;quot;¬p ∧ ¬q&amp;quot; by (rule FalseE) }&lt;br /&gt;
         qed}&lt;br /&gt;
    {assume &amp;quot;p&amp;quot;&lt;br /&gt;
        hence &amp;quot;(p ∨ q)&amp;quot;  by (rule disjI1)&lt;br /&gt;
        have &amp;quot;False&amp;quot;  using `¬(p ∨ q)` `p ∨ q` by (rule notE) &lt;br /&gt;
        thus &amp;quot;¬p ∧ ¬q&amp;quot; by (rule FalseE) }&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
      &lt;br /&gt;
lemma ejercicio_3_5:&lt;br /&gt;
  assumes  &amp;quot;¬(¬p ∨ ¬q)&amp;quot;&lt;br /&gt;
  shows &amp;quot;p ∧ q&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;¬¬p ∧ ¬¬q&amp;quot; using assms by (rule aux2)&lt;br /&gt;
  hence &amp;quot;¬¬p&amp;quot; by (rule conjunct1)&lt;br /&gt;
  hence &amp;quot;p&amp;quot; by (rule notnotD)&lt;br /&gt;
  have &amp;quot;¬¬q&amp;quot; using `¬¬p ∧ ¬¬q` by (rule conjunct2)&lt;br /&gt;
  hence &amp;quot;q&amp;quot; by (rule notnotD) &lt;br /&gt;
  show  &amp;quot;p ∧ q&amp;quot; using  `p` `q` by (rule conjI) &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_3_6:&lt;br /&gt;
assumes &amp;quot;¬(¬p ∨ ¬q)&amp;quot;&lt;br /&gt;
          &lt;br /&gt;
  shows &amp;quot;p ∧ q&amp;quot; &lt;br /&gt;
proof &lt;br /&gt;
  have &amp;quot;¬¬p ∧ ¬¬q&amp;quot; using assms by (rule Meson.not_disjD)&lt;br /&gt;
  hence &amp;quot;¬¬p&amp;quot;  by (rule conjunct1)&lt;br /&gt;
  show &amp;quot;p&amp;quot; using `¬¬p` by (rule notnotD)&lt;br /&gt;
  next&lt;br /&gt;
  have &amp;quot;¬¬p ∧ ¬¬q&amp;quot; using assms by (rule Meson.not_disjD)&lt;br /&gt;
  hence &amp;quot;¬¬q&amp;quot;  by (rule conjunct2)&lt;br /&gt;
  show &amp;quot;q&amp;quot; using `¬¬q` by (rule notnotD)&lt;br /&gt;
qed   &lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
lemma ejercicio_3_7:&lt;br /&gt;
assumes &amp;quot;¬(¬p ∨ ¬q)&amp;quot;&lt;br /&gt;
          &lt;br /&gt;
  shows &amp;quot;p ∧ q&amp;quot; &lt;br /&gt;
proof &lt;br /&gt;
  have &amp;quot;¬¬p ∧ ¬¬q&amp;quot; using assms by (rule Meson.not_disjD)&lt;br /&gt;
  have &amp;quot;¬¬p&amp;quot; using `¬¬p ∧ ¬¬q`  by (rule conjunct1)&lt;br /&gt;
  have &amp;quot;¬¬q&amp;quot; using `¬¬p ∧ ¬¬q`  by (rule conjunct2)&lt;br /&gt;
  show &amp;quot;p&amp;quot; using `¬¬p` by (rule notnotD)&lt;br /&gt;
  show &amp;quot;q&amp;quot; using `¬¬q` by (rule notnotD)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Demostrar&lt;br /&gt;
     ¬(p ∧ q) ⊢ ¬p ∨ ¬q&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
(* marcarmor13 serrodcal *)&lt;br /&gt;
--&amp;quot;usando un supuesto p ∧ q&amp;quot;&lt;br /&gt;
 lemma ejercicio_4_1:&lt;br /&gt;
  assumes 1: &amp;quot; ¬(p ∧ q)&amp;quot; and&lt;br /&gt;
          2:&amp;quot;p ∧ q&amp;quot;       &lt;br /&gt;
  shows &amp;quot;¬p ∨ ¬q&amp;quot;&lt;br /&gt;
proof-&lt;br /&gt;
  have 3: &amp;quot;¬p&amp;quot;using 1 2 by (rule notE)&lt;br /&gt;
show &amp;quot;¬p ∨ ¬q&amp;quot; using 3  by (rule disjI1)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 ferrenseg *)&lt;br /&gt;
lemma ejercicio_4_2:&lt;br /&gt;
  assumes 1: &amp;quot;¬(p ∧ q)&amp;quot;&lt;br /&gt;
  shows      &amp;quot;¬p ∨ ¬q&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
   {assume 2:&amp;quot;(p ∧ q)&amp;quot;&lt;br /&gt;
   have &amp;quot;¬p&amp;quot; using 1 2 by (rule notE)&lt;br /&gt;
   then have &amp;quot;¬p ∨ ¬q&amp;quot; by (rule disjI1)}&lt;br /&gt;
   thus &amp;quot;¬p ∨ ¬q&amp;quot; by auto&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
( * pablucoto jeamacpov crigomgom juancabsou *)&lt;br /&gt;
lemma ejercicio_4_3:&lt;br /&gt;
  assumes  &amp;quot; ¬(p ∧ q)&amp;quot;&lt;br /&gt;
  shows    &amp;quot; ¬p ∨ ¬q&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
{ assume 2: &amp;quot;¬(¬p ∨ ¬q)&amp;quot;&lt;br /&gt;
 hence &amp;quot;p ∧ q&amp;quot; by (rule ejercicio_3_2)  &lt;br /&gt;
 with assms(1) have  &amp;quot;False&amp;quot; .. } &lt;br /&gt;
 then show &amp;quot; ¬p ∨ ¬q&amp;quot; by (rule ccontr)&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha anaprarod*)&lt;br /&gt;
lemma ej_4:&lt;br /&gt;
  assumes &amp;quot;¬(p ∧ q)&amp;quot;&lt;br /&gt;
  shows &amp;quot;¬p ∨ ¬q&amp;quot;&lt;br /&gt;
  proof (rule ccontr)&lt;br /&gt;
    assume &amp;quot;¬ (¬ p ∨ ¬ q)&amp;quot;&lt;br /&gt;
    hence &amp;quot;p ∧ q&amp;quot; by (rule ej_3)&lt;br /&gt;
    with assms show False  by (rule notE)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* sin usar el ejercicio anterior *)&lt;br /&gt;
lemma ejercicio_4_4: &lt;br /&gt;
  assumes &amp;quot;¬(p ∧ q)&amp;quot;&lt;br /&gt;
  shows &amp;quot;¬p ∨ ¬q&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;¬p ∨ p&amp;quot; by (rule excluded_middle)&lt;br /&gt;
  thus &amp;quot;¬p ∨ ¬q&amp;quot;&lt;br /&gt;
  proof (rule disjE)&lt;br /&gt;
    {assume &amp;quot;¬p&amp;quot;&lt;br /&gt;
      thus &amp;quot;¬p ∨ ¬q&amp;quot; by (rule disjI1)}&lt;br /&gt;
    next&lt;br /&gt;
    {assume 1:&amp;quot;p&amp;quot;&lt;br /&gt;
      have &amp;quot;¬q ∨ q&amp;quot; by (rule excluded_middle)&lt;br /&gt;
      thus &amp;quot;¬p ∨ ¬q&amp;quot;&lt;br /&gt;
      proof (rule disjE)&lt;br /&gt;
        {assume &amp;quot;¬q&amp;quot;&lt;br /&gt;
          thus &amp;quot;¬p ∨ ¬q&amp;quot; by (rule disjI2)}&lt;br /&gt;
        next&lt;br /&gt;
        {assume 2:&amp;quot;q&amp;quot;&lt;br /&gt;
          have 3:&amp;quot;p ∧ q&amp;quot; using 1 2 by (rule conjI)&lt;br /&gt;
          have &amp;quot;¬p ∨ ¬q&amp;quot; using assms 3 by (rule notE)&lt;br /&gt;
          thus &amp;quot;¬p ∨ ¬q&amp;quot; by this}&lt;br /&gt;
      qed}&lt;br /&gt;
   qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma ejercicio_4_5:&lt;br /&gt;
 assumes 1: &amp;quot;¬(p∧q)&amp;quot;&lt;br /&gt;
 shows &amp;quot;¬p∨¬q&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
 have 2: &amp;quot;p∨¬p&amp;quot; by (rule lem)&lt;br /&gt;
 moreover&lt;br /&gt;
 {assume 3: &amp;quot;p&amp;quot; &lt;br /&gt;
  {assume 4: &amp;quot;q&amp;quot;&lt;br /&gt;
   also have 5: &amp;quot;p∧q&amp;quot; using 3 4 by (rule conjI)&lt;br /&gt;
   have 6: &amp;quot;False&amp;quot; using assms 5 by (rule notE)}&lt;br /&gt;
  then have 7: &amp;quot;¬q&amp;quot; by (rule notI)&lt;br /&gt;
  then have 8: &amp;quot;¬p∨¬q&amp;quot; by (rule disjI2)}&lt;br /&gt;
 moreover&lt;br /&gt;
 {assume 9: &amp;quot;¬p&amp;quot;&lt;br /&gt;
  then have &amp;quot;¬p∨¬q&amp;quot; by (rule disjI1)}&lt;br /&gt;
 ultimately show &amp;quot;¬p∨¬q&amp;quot; by (rule disjE)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg pabrodmac*)&lt;br /&gt;
lemma ejercicio_4_6:&lt;br /&gt;
  assumes &amp;quot;¬(p ∧ q)&amp;quot;&lt;br /&gt;
  shows &amp;quot;¬p ∨ ¬q&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;¬p ∨ p&amp;quot; by (rule excluded_middle)&lt;br /&gt;
  thus &amp;quot;¬p ∨ ¬q&amp;quot;&lt;br /&gt;
  proof&lt;br /&gt;
    {assume &amp;quot;¬p&amp;quot;&lt;br /&gt;
    thus &amp;quot;¬p ∨ ¬q&amp;quot; by (rule disjI1)}&lt;br /&gt;
    next&lt;br /&gt;
    {assume &amp;quot;p&amp;quot;&lt;br /&gt;
      have &amp;quot;¬q&amp;quot;&lt;br /&gt;
      proof&lt;br /&gt;
      {assume &amp;quot;q&amp;quot;&lt;br /&gt;
      have &amp;quot;(p ∧ q)&amp;quot; using `p` `q`  by (rule conjI)&lt;br /&gt;
      show &amp;quot;False&amp;quot;  using `¬(p ∧ q)` `p ∧ q` by (rule notE)}&lt;br /&gt;
      qed&lt;br /&gt;
      thus &amp;quot;¬p ∨ ¬q&amp;quot; by (rule disjI2)}&lt;br /&gt;
      qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac*)&lt;br /&gt;
lemma ejercicio_4_7:&lt;br /&gt;
assumes &amp;quot;¬(p ∧ q)&amp;quot;&lt;br /&gt;
          &lt;br /&gt;
  shows &amp;quot;¬p ∨ ¬q&amp;quot; &lt;br /&gt;
proof -&lt;br /&gt;
  show &amp;quot;¬p ∨ ¬q&amp;quot; using assms by (rule Meson.not_conjD)&lt;br /&gt;
qed   &lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Demostrar&lt;br /&gt;
     ⊢ (p ⟶ q) ∨ (q ⟶ p)&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
(* marcarmor13 jeamacpov serrodcal juancabsou *)&lt;br /&gt;
--&amp;quot;usando un supuesto q&amp;quot;&lt;br /&gt;
lemma ejercicio_5_1:&lt;br /&gt;
  assumes 1: &amp;quot;q&amp;quot; &lt;br /&gt;
               &lt;br /&gt;
  shows &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot;&lt;br /&gt;
proof-&lt;br /&gt;
  have 2: &amp;quot;p ⟶ q&amp;quot; using 1 by (rule impI)&lt;br /&gt;
show &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot; using 2  by (rule disjI1)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 ferrenseg *)&lt;br /&gt;
lemma ejercicio_5_2:&lt;br /&gt;
  shows &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot;     &lt;br /&gt;
proof -&lt;br /&gt;
  {assume 1:&amp;quot;q&amp;quot;&lt;br /&gt;
   have &amp;quot;(p ⟶ q)&amp;quot; using 1 by (rule impI)&lt;br /&gt;
   then have &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot; by (rule disjI1)}&lt;br /&gt;
   thus &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot; by auto&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto *)&lt;br /&gt;
lemma ej_5:&lt;br /&gt;
  shows &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
  have &amp;quot;¬p ∨ p&amp;quot; by (rule excluded_middle)&lt;br /&gt;
  thus &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot;&lt;br /&gt;
  proof (rule disjE)&lt;br /&gt;
    { assume &amp;quot;¬p&amp;quot; &lt;br /&gt;
      have &amp;quot;¬q ∨ q&amp;quot; by (rule excluded_middle)&lt;br /&gt;
      thus &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot;&lt;br /&gt;
      proof (rule disjE)&lt;br /&gt;
      {assume &amp;quot;¬q&amp;quot;&lt;br /&gt;
        hence &amp;quot;¬p ⟶ ¬q&amp;quot; by (rule impI)&lt;br /&gt;
         { assume &amp;quot;q&amp;quot;&lt;br /&gt;
           hence &amp;quot;¬¬q&amp;quot; by (rule notnotI)&lt;br /&gt;
           with `¬p ⟶ ¬q` have &amp;quot;¬¬p&amp;quot; by (rule mt) &lt;br /&gt;
           hence &amp;quot;p&amp;quot; by (rule notnotD)}&lt;br /&gt;
         hence &amp;quot;q ⟶ p&amp;quot; by (rule impI)&lt;br /&gt;
         thus &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot; by (rule disjI2)}&lt;br /&gt;
      next&lt;br /&gt;
      {assume &amp;quot;q&amp;quot;&lt;br /&gt;
        hence &amp;quot;(p ⟶ q)&amp;quot; by (rule impI)&lt;br /&gt;
        thus &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot; by (rule disjI1)}&lt;br /&gt;
      qed}&lt;br /&gt;
    next&lt;br /&gt;
    {assume &amp;quot;p&amp;quot;&lt;br /&gt;
     hence &amp;quot;q ⟶ p&amp;quot; by (rule impI)&lt;br /&gt;
     thus &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot; by (rule disjI2)}&lt;br /&gt;
    qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* Muy parecida a la anterior pero con algunas etiquetas&lt;br /&gt;
   y con algunas implicaciones más detalladas *)&lt;br /&gt;
lemma ejercicio_5_3:&lt;br /&gt;
  shows &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot;&lt;br /&gt;
proof-&lt;br /&gt;
  have &amp;quot;¬p ∨ p&amp;quot; by (rule excluded_middle)&lt;br /&gt;
  thus &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot;&lt;br /&gt;
  proof (rule disjE)&lt;br /&gt;
    {assume &amp;quot;¬p&amp;quot;&lt;br /&gt;
      have &amp;quot;¬q ∨ q&amp;quot; by (rule excluded_middle)&lt;br /&gt;
      thus &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot;&lt;br /&gt;
      proof (rule disjE)&lt;br /&gt;
        {assume  &amp;quot;¬q&amp;quot;&lt;br /&gt;
          hence 1: &amp;quot;¬p ⟶ ¬q&amp;quot; by (rule impI) &lt;br /&gt;
          {assume &amp;quot;q&amp;quot;&lt;br /&gt;
            hence 2: &amp;quot;¬¬q&amp;quot; by (rule notnotI)&lt;br /&gt;
            have &amp;quot;¬¬p&amp;quot; using 1 2 by (rule mt)&lt;br /&gt;
            hence &amp;quot;p&amp;quot; by (rule notnotD)}&lt;br /&gt;
          hence &amp;quot;q ⟶ p&amp;quot; by (rule impI)&lt;br /&gt;
          thus &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot; by (rule disjI2)}&lt;br /&gt;
        next&lt;br /&gt;
        {assume 3: &amp;quot;q&amp;quot;&lt;br /&gt;
          {assume &amp;quot;p&amp;quot;&lt;br /&gt;
            have &amp;quot;q&amp;quot; using 3 by this}&lt;br /&gt;
          hence &amp;quot;p ⟶ q&amp;quot; by (rule impI)&lt;br /&gt;
          thus &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot; by (rule disjI1)}&lt;br /&gt;
        qed}&lt;br /&gt;
    next&lt;br /&gt;
    {assume 4: &amp;quot;p&amp;quot;&lt;br /&gt;
      {assume &amp;quot;q&amp;quot;&lt;br /&gt;
        have &amp;quot;p&amp;quot; using 4 by this}&lt;br /&gt;
      hence &amp;quot;q ⟶ p&amp;quot; by (rule impI)&lt;br /&gt;
      thus &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot; by (rule disjI2)}&lt;br /&gt;
    qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_5_4:             &lt;br /&gt;
  shows &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot;&lt;br /&gt;
proof-&lt;br /&gt;
 have 1: &amp;quot;q∨¬q&amp;quot; by (rule lem)&lt;br /&gt;
 moreover &lt;br /&gt;
 {assume 2: &amp;quot;q&amp;quot;   &lt;br /&gt;
  have 3: &amp;quot;p ⟶ q&amp;quot; using 2 by (rule impI)&lt;br /&gt;
  then have 4: &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot; by (rule disjI1)}&lt;br /&gt;
 moreover&lt;br /&gt;
 {assume 5: &amp;quot;¬q&amp;quot;   &lt;br /&gt;
  have 6: &amp;quot;¬p⟶¬q&amp;quot; using 5 by (rule impI)&lt;br /&gt;
  then have 7: &amp;quot;q⟶p&amp;quot; by (rule ejercicio_1_2)&lt;br /&gt;
  then have &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot; by (rule disjI2)}&lt;br /&gt;
 ultimately show &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot; by (rule disjE)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg pabrodmac*)&lt;br /&gt;
lemma aux3:&lt;br /&gt;
  assumes &amp;quot;¬q ∨ p&amp;quot;&lt;br /&gt;
  shows &amp;quot;q ⟶ p&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
note `¬q ∨ p`&lt;br /&gt;
moreover&lt;br /&gt;
 {assume &amp;quot;¬q&amp;quot;&lt;br /&gt;
   have &amp;quot;q ⟶ p&amp;quot;&lt;br /&gt;
   proof&lt;br /&gt;
    assume &amp;quot;q&amp;quot; &lt;br /&gt;
    show &amp;quot;p&amp;quot; using `¬q``q`by (rule notE)&lt;br /&gt;
    qed} &lt;br /&gt;
moreover&lt;br /&gt;
 {assume &amp;quot;p&amp;quot;&lt;br /&gt;
   have &amp;quot;q ⟶ p&amp;quot;&lt;br /&gt;
   proof&lt;br /&gt;
    assume &amp;quot;q&amp;quot;&lt;br /&gt;
    show &amp;quot;p&amp;quot; using `p` by this&lt;br /&gt;
    qed}&lt;br /&gt;
ultimately show &amp;quot;q ⟶ p&amp;quot; by (rule disjE)&lt;br /&gt;
qed    &lt;br /&gt;
        &lt;br /&gt;
lemma ejercicio_5_5:&lt;br /&gt;
  shows &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;¬p ∨ p&amp;quot; by (rule excluded_middle) &lt;br /&gt;
  thus &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot;&lt;br /&gt;
  proof&lt;br /&gt;
    {assume &amp;quot;¬p&amp;quot;&lt;br /&gt;
     hence &amp;quot;¬p ∨ q&amp;quot; by (rule disjI1)&lt;br /&gt;
     hence &amp;quot;p ⟶ q&amp;quot; by (rule aux3)&lt;br /&gt;
     thus &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot; by (rule disjI1)} &lt;br /&gt;
    {assume &amp;quot;p&amp;quot;&lt;br /&gt;
     hence &amp;quot;¬q ∨ p&amp;quot; by (rule disjI2)&lt;br /&gt;
     hence &amp;quot;q ⟶ p&amp;quot; by (rule aux3)&lt;br /&gt;
     thus &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot; by (rule disjI2)} &lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)       &lt;br /&gt;
&lt;br /&gt;
lemma ejercicio_5_6: &lt;br /&gt;
  &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;¬(p ⟶ q) ∨ (p ⟶ q)&amp;quot; by (rule excluded_middle)&lt;br /&gt;
  thus &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot;&lt;br /&gt;
  proof &lt;br /&gt;
    { assume &amp;quot;¬(p ⟶ q)&amp;quot;&lt;br /&gt;
      hence &amp;quot;p ∧ ¬ q&amp;quot; by (rule Meson.not_impD)&lt;br /&gt;
      have &amp;quot;(q ⟶ p)&amp;quot;&lt;br /&gt;
      proof&lt;br /&gt;
      assume &amp;quot;q&amp;quot;&lt;br /&gt;
      show &amp;quot;p&amp;quot; using `p ∧ ¬ q` by (rule conjunct1)&lt;br /&gt;
      qed&lt;br /&gt;
      thus &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot; by (rule disjI2) }&lt;br /&gt;
  next&lt;br /&gt;
    { assume &amp;quot;p ⟶ q&amp;quot;&lt;br /&gt;
     then show &amp;quot;(p ⟶ q) ∨ (q ⟶ p)&amp;quot;  by (rule disjI1) }&lt;br /&gt;
  qed&lt;br /&gt;
qed    &lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=996</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=996"/>
		<updated>2016-12-06T19:09:42Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
 &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;preOrden (espejo (N x i d)) =  preOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = [x]@rev(postOrden d)@rev(postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev(postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;postOrden (espejo (N x i d)) =  postOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden d)@rev(preOrden i)@[x]&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis.&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos pabrodmac *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;inOrden (espejo (N x i d)) =  inOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden d)@[x]@rev(inOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal pabrodmac *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou pabrodmac *)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar patrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma Aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;last (inOrden (N x i d)) =  last((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =last(inOrden d)&amp;quot; by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha d&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (inOrden (N x i d)) =  hd((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = hd (inOrden i)&amp;quot;  by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda i&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pabrodmac *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto  &lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (preOrden (N x i d) )= x&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*Me he dado cuenta que no es necesario asumir ninguna hipótesis de inducción puesto que no es necesario utilizarlas, así que no se si está bien hecho puesto que no se aplicaría inducción *)  &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pabrodmac *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (preOrden (N x i d) )= x&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*Me he dado cuenta que no es necesario asumir ninguna hipótesis de inducción puesto que no es necesario utilizarlas, así que no se si está bien hecho puesto que no se aplicaría inducción *)  &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou pabrodmac *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pabrodmac*)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
 &lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;last (postOrden (N x i d))= x&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*Me he dado cuenta que no es necesario asumir ninguna hipótesis de inducción puesto que no es necesario utilizarlas, así que no se si está bien hecho puesto que no se aplicaría inducción *)  &lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=994</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=994"/>
		<updated>2016-12-06T18:59:42Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
 &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;preOrden (espejo (N x i d)) =  preOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = [x]@rev(postOrden d)@rev(postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev(postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;postOrden (espejo (N x i d)) =  postOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden d)@rev(preOrden i)@[x]&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis.&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos pabrodmac *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;inOrden (espejo (N x i d)) =  inOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden d)@[x]@rev(inOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal pabrodmac *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou pabrodmac *)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar patrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma Aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;last (inOrden (N x i d)) =  last((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =last(inOrden d)&amp;quot; by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha d&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (inOrden (N x i d)) =  hd((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = hd (inOrden i)&amp;quot;  by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda i&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pabrodmac *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto  &lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (preOrden (N x i d) )= x&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*Me he dado cuenta que no es necesario asumir ninguna hipótesis de inducción puesto que no es necesario utilizarlas, así que no se si está bien hecho puesto que no se aplicaría inducción *)  &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pabrodmac *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (preOrden (N x i d) )= x&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*Me he dado cuenta que no es necesario asumir ninguna hipótesis de inducción puesto que no es necesario utilizarlas, así que no se si está bien hecho puesto que no se aplicaría inducción *)  &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou pabrodmac *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=991</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=991"/>
		<updated>2016-12-06T18:51:11Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
 &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;preOrden (espejo (N x i d)) =  preOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = [x]@rev(postOrden d)@rev(postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev(postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;postOrden (espejo (N x i d)) =  postOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden d)@rev(preOrden i)@[x]&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis.&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos pabrodmac *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;inOrden (espejo (N x i d)) =  inOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden d)@[x]@rev(inOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal pabrodmac *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou pabrodmac *)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar patrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma Aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;last (inOrden (N x i d)) =  last((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =last(inOrden d)&amp;quot; by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha d&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (inOrden (N x i d)) =  hd((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = hd (inOrden i)&amp;quot;  by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda i&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pabrodmac *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto  &lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (preOrden (N x i d) )= x&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*Me he dado cuenta que no es necesario asumir ninguna hipótesis de inducción, así que no se si está bien hecho *)  &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pabrodmac *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (preOrden (N x i d) )= x&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou pabrodmac *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=989</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=989"/>
		<updated>2016-12-06T18:19:38Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
 &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;preOrden (espejo (N x i d)) =  preOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = [x]@rev(postOrden d)@rev(postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev(postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;postOrden (espejo (N x i d)) =  postOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden d)@rev(preOrden i)@[x]&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis.&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos pabrodmac *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;inOrden (espejo (N x i d)) =  inOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden d)@[x]@rev(inOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal pabrodmac *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou pabrodmac *)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar patrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma Aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;last (inOrden (N x i d)) =  last((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =last(inOrden d)&amp;quot; by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha d&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (inOrden (N x i d)) =  hd((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = hd (inOrden i)&amp;quot;  by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda i&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pabrodmac *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto  &lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (preOrden (N x i d) )= x&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*Me he dado cuenta que no es necesario asumir ninguna hipótesis de inducción*)  &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pabrodmac *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (preOrden (N x i d) )= x&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou pabrodmac *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=988</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=988"/>
		<updated>2016-12-06T18:13:10Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
 &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;preOrden (espejo (N x i d)) =  preOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = [x]@rev(postOrden d)@rev(postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev(postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;postOrden (espejo (N x i d)) =  postOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden d)@rev(preOrden i)@[x]&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis.&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos pabrodmac *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;inOrden (espejo (N x i d)) =  inOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden d)@[x]@rev(inOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal pabrodmac *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou pabrodmac *)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar patrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma Aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;last (inOrden (N x i d)) =  last((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =last(inOrden d)&amp;quot; by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha d&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (inOrden (N x i d)) =  hd((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = hd (inOrden i)&amp;quot;  by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda i&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pabrodmac *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto  &lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (preOrden (N x i d) )= x&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (preOrden (N x i d) )= x&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=987</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=987"/>
		<updated>2016-12-06T18:11:03Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
 &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;preOrden (espejo (N x i d)) =  preOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = [x]@rev(postOrden d)@rev(postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev(postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;postOrden (espejo (N x i d)) =  postOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden d)@rev(preOrden i)@[x]&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis.&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos pabrodmac *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;inOrden (espejo (N x i d)) =  inOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden d)@[x]@rev(inOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal pabrodmac *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou pabrodmac *)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar patrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma Aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;last (inOrden (N x i d)) =  last((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =last(inOrden d)&amp;quot; by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha d&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (inOrden (N x i d)) =  hd((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = hd (inOrden i)&amp;quot;  by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda i&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pabrodmac *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto  &lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (preOrden (N x i d) )= x&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=986</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=986"/>
		<updated>2016-12-06T18:09:00Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
 &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;preOrden (espejo (N x i d)) =  preOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = [x]@rev(postOrden d)@rev(postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev(postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;postOrden (espejo (N x i d)) =  postOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden d)@rev(preOrden i)@[x]&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis.&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos pabrodmac *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;inOrden (espejo (N x i d)) =  inOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden d)@[x]@rev(inOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal pabrodmac *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou pabrodmac *)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar patrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma Aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;last (inOrden (N x i d)) =  last((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =last(inOrden d)&amp;quot; by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha d&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (inOrden (N x i d)) =  hd((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = hd (inOrden i)&amp;quot;  by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda i&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pabrodmac *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto  &lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (preOrden (N x i d) )= x&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=985</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=985"/>
		<updated>2016-12-06T18:00:34Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
 &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;preOrden (espejo (N x i d)) =  preOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = [x]@rev(postOrden d)@rev(postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev(postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;postOrden (espejo (N x i d)) =  postOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden d)@rev(preOrden i)@[x]&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis.&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos pabrodmac *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;inOrden (espejo (N x i d)) =  inOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden d)@[x]@rev(inOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal pabrodmac *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou pabrodmac *)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar patrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma Aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;last (inOrden (N x i d)) =  last((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =last(inOrden d)&amp;quot; by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha d&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (inOrden (N x i d)) =  hd((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = hd (inOrden i)&amp;quot;  by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda i&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto  &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=984</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=984"/>
		<updated>2016-12-06T17:52:36Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
 &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;preOrden (espejo (N x i d)) =  preOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = [x]@rev(postOrden d)@rev(postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev(postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;postOrden (espejo (N x i d)) =  postOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden d)@rev(preOrden i)@[x]&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis.&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos pabrodmac *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;inOrden (espejo (N x i d)) =  inOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden d)@[x]@rev(inOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal pabrodmac *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou pabrodmac *)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar patrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma Aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;last (inOrden (N x i d)) =  last((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =last(inOrden d)&amp;quot; by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha d&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;hd (inOrden (N x i d)) =  hd((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = hd (inOrden i)&amp;quot;  by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda i&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=983</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=983"/>
		<updated>2016-12-06T17:47:45Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
 &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;preOrden (espejo (N x i d)) =  preOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = [x]@rev(postOrden d)@rev(postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev(postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;postOrden (espejo (N x i d)) =  postOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden d)@rev(preOrden i)@[x]&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis.&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos pabrodmac *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;inOrden (espejo (N x i d)) =  inOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden d)@[x]@rev(inOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal pabrodmac *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou pabrodmac *)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar patrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma Aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;last (inOrden (N x i d)) =  last((inOrden i)@ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =last(inOrden d)&amp;quot; by (simp add: Aux_ej12)&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha d&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=982</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=982"/>
		<updated>2016-12-06T17:43:15Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
 &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;preOrden (espejo (N x i d)) =  preOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = [x]@rev(postOrden d)@rev(postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev(postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;postOrden (espejo (N x i d)) =  postOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden d)@rev(preOrden i)@[x]&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis.&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos pabrodmac *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;inOrden (espejo (N x i d)) =  inOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden d)@[x]@rev(inOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal pabrodmac *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou pabrodmac *)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar patrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma Aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
by (induct a)(auto simp add: Aux_ej12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=981</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=981"/>
		<updated>2016-12-06T17:33:43Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
 &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;preOrden (espejo (N x i d)) =  preOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = [x]@rev(postOrden d)@rev(postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev(postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;postOrden (espejo (N x i d)) =  postOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden d)@rev(preOrden i)@[x]&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis.&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos pabrodmac *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;inOrden (espejo (N x i d)) =  inOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden d)@[x]@rev(inOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal pabrodmac *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou pabrodmac *)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar patrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=980</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=980"/>
		<updated>2016-12-06T17:23:38Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
 &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;preOrden (espejo (N x i d)) =  preOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = [x]@rev(postOrden d)@rev(postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev(postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;postOrden (espejo (N x i d)) =  postOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden d)@rev(preOrden i)@[x]&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis.&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos pabrodmac *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;inOrden (espejo (N x i d)) =  inOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden d)@[x]@rev(inOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou*)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar padrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=979</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=979"/>
		<updated>2016-12-06T17:21:19Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
 &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;preOrden (espejo (N x i d)) =  preOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = [x]@rev(postOrden d)@rev(postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev(postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis .&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma&lt;br /&gt;
  fixes a ::&amp;quot;&amp;#039;b arbol&amp;quot; &lt;br /&gt;
  shows &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x&lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot;   &lt;br /&gt;
  proof -               &lt;br /&gt;
    have &amp;quot;postOrden (espejo (N x i d)) =  postOrden(N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden d)@rev(preOrden i)@[x]&amp;quot; using h1 h2 by simp&lt;br /&gt;
    also have &amp;quot;… =rev(preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis.&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou*)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar padrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=978</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=978"/>
		<updated>2016-12-06T17:16:43Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
 &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou*)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar padrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=977</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=977"/>
		<updated>2016-12-06T17:14:33Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
 (*?thesis más corto*)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
  (*?thesis más corto aún *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou*)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar padrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=976</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=976"/>
		<updated>2016-12-06T17:06:01Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou*)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar padrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=975</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=975"/>
		<updated>2016-12-06T17:03:52Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou*)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar padrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=974</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=974"/>
		<updated>2016-12-06T16:56:38Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou*)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar padrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=973</id>
		<title>Relación 6</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=973"/>
		<updated>2016-12-06T16:55:31Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R6: Recorridos de árboles *}&lt;br /&gt;
&lt;br /&gt;
theory R6_Recorridos_de_arboles&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que tiene información en los nodos y en las hojas. &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
     a   d f   3&lt;br /&gt;
  se representa por &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 manmorjim1 bowma migtermor wilmorort juacabsou serrodcal pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H &amp;quot;&amp;#039;a&amp;quot; | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N e (N c (H a) (H d)) (N g (H f) (H h))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (preOrden a) es el recorrido pre orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos serrodcal *)&lt;br /&gt;
&lt;br /&gt;
fun preOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden (N t i d) = [t] @ (preOrden i) @ (preOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 bowma juacabsou *)&lt;br /&gt;
fun preOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;preOrden1 (H x) = [x]&amp;quot;&lt;br /&gt;
| &amp;quot;preOrden1 (N x i d) = x#preOrden1 i @ preOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;preOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
value &amp;quot;preOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))  &lt;br /&gt;
      = [e,c,a,d,g,f,h]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;preOrden a = preOrden1 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función &lt;br /&gt;
     postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (postOrden a) es el recorrido post orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [e,c,a,d,g,f,h] &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
fun postOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;postOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;postOrden (N t i d) = (postOrden i) @ (postOrden d) @ [t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;postOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,d,c,f,h,g,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función &lt;br /&gt;
     inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot;&lt;br /&gt;
  tal que (inOrden a) es el recorrido in orden del árbol a. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = [a,c,d,e,f,g,h]&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom marpoldia1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
fun inOrden :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden (N t i d) = (inOrden i) @ [t] @ (inOrden d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* danrodcha manmorjim1 *)&lt;br /&gt;
fun inOrden1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inOrden1 (H t) = [t]&amp;quot;&lt;br /&gt;
| &amp;quot;inOrden1 (N t i d) = inOrden1 i @ t#inOrden1 d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inOrden (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
value &amp;quot;inOrden1 (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
       = [a,c,d,e,f,g,h]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
lemma &amp;quot;inOrden t = inOrden1 t&amp;quot;&lt;br /&gt;
apply (induct t)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función &lt;br /&gt;
     espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot;&lt;br /&gt;
  tal que (espejo a) es la imagen especular del árbol a. Por ejemplo, &lt;br /&gt;
     espejo (N e (N c (H a) (H d)) (N g (H f) (H h)))&lt;br /&gt;
     = N e (N g (H h) (H f)) (N c (H d) (H a))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim danrodcha crigomgom marpoldia1 manmorjim1 pablucoto bowma fraortmoy migtermor wilmorort lucnovdos juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
fun espejo :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;espejo (H t) = H t&amp;quot;&lt;br /&gt;
| &amp;quot;espejo (N t i d) = N t (espejo d) (espejo i)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;espejo (N e (N c (H a) (H d)) (N g (H f) (H h))) &lt;br /&gt;
       = N e (N g (H h) (H f)) (N c (H d) (H a))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar que&lt;br /&gt;
     preOrden (espejo a) = rev (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort juacabsou serrodcal *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal*)&lt;br /&gt;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;raiz (N x i d) = x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función &lt;br /&gt;
     extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_izquierda a) es el nodo más a la izquierda del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal *)&lt;br /&gt;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda (N x i d) = extremo_izquierda i&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_izquierda (N e (N c (H a) (H d)) (N g (H f) (H h))) = a&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_izquierda_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_izquierda_1 (N t i d) = hd (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_13 al teorema del ejercicio 13 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_izquierda a = extremo_izquierda_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_13)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función &lt;br /&gt;
     extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (extremo_derecha a) es el nodo más a la derecha del árbol&lt;br /&gt;
  a. Por ejemplo,  &lt;br /&gt;
     extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos  juacabsou*)&lt;br /&gt;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha (H x) = x&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha (N x i d) = extremo_derecha d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;extremo_derecha (N e (N c (H a) (H d)) (N g (H f) (H h))) = h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
fun extremo_derecha_1 :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha_1 (H t) = t&amp;quot;&lt;br /&gt;
| &amp;quot;extremo_derecha_1 (N t i d) = last (inOrden (N t i d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Metaejercicio de demostración. Llamando teorema_12 al teorema del ejercicio 12 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;extremo_derecha a = extremo_derecha_1 a&amp;quot;&lt;br /&gt;
by (induct a, simp_all add: aux_ej12_1 teorema_12)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     last (inOrden a) = extremo_derecha a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux_ej12: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
apply (induct a) &lt;br /&gt;
apply simp&lt;br /&gt;
apply simp&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom  wilmorort juacabsou *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar padrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom juacabsou*)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos juacabsou *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos juacabsou *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=825</id>
		<title>Relación 5</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=825"/>
		<updated>2016-11-30T11:27:07Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R5: Eliminación de duplicados *}&lt;br /&gt;
&lt;br /&gt;
theory R5_Eliminacion_de_duplicados&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
        &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar bowma wilmorort pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1&lt;br /&gt;
    danrodcha manmorjim1 *)&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn _ [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim, ferrenseg josgarsan juacabsou dancorgar pabrodmac *)&lt;br /&gt;
(* Igual que la anterior pero con x en lugar de _ en el caso base *)&lt;br /&gt;
&lt;br /&gt;
fun estaEn1 :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn1 x [] = False&amp;quot; &lt;br /&gt;
| &amp;quot;estaEn1 x (a#xs) = ((x=a) ∨ estaEn1 x xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn1 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn1 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
(* reutilizando  la funcion &amp;quot;algunos&amp;quot; de R4.thy*)&lt;br /&gt;
fun estaEn2  :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn2 a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn2 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn2 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función primitiva recursiva &lt;br /&gt;
     sinDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (sinDuplicados xs) se verifica si la lista xs no contiene&lt;br /&gt;
  duplicados. Por ejemplo,  &lt;br /&gt;
     sinDuplicados [1::nat,4,2]   = True&lt;br /&gt;
     sinDuplicados [1::nat,4,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar ivamenjim  wilmorort bowma pablucoto &lt;br /&gt;
    serrodcal anaprarod migtermor paupeddeg fraortmoy marpoldia1 &lt;br /&gt;
    ferrenseg josgarsan danrodcha manmorjim1 juacabsou dancorgar pabrodmac*)&lt;br /&gt;
fun sinDuplicados :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados (x#xs) = (¬ estaEn x xs ∧ sinDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2]   = True&amp;quot;&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
(* Utilizando la función ∉ de Isabelle *)&lt;br /&gt;
fun sinDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados2 [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados2 (a#xs) = ((a ∉ set xs) ∧  sinDuplicados2 xs ) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función primitiva recursiva &lt;br /&gt;
     borraDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (borraDuplicados xs) es la lista obtenida eliminando los&lt;br /&gt;
  elementos duplicados de la lista xs. Por ejemplo, &lt;br /&gt;
     borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función borraDuplicados es equivalente a la predefinida&lt;br /&gt;
  remdups.  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar wilmorort bowma pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1 ferrenseg &lt;br /&gt;
    josgarsan danrodcha juacabsou dancorgar manmorjim1 pabrodmac*)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(* Otra forma Sin usar if &lt;br /&gt;
  Utilizando case aunque se le sacaría más partido con más de 2 casos *)&lt;br /&gt;
 &lt;br /&gt;
 fun borraDuplicados1 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados1 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados1 (x#xs) = ( case estaEn x xs of False  =&amp;gt; x#borraDuplicados1 xs | True =&amp;gt; borraDuplicados1 xs )&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(*Otra forma utilizando let*)&lt;br /&gt;
fun borraDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados2 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados2 (x#xs) =  (let condicion = estaEn x xs::bool  in &lt;br /&gt;
if  condicion then borraDuplicados2 xs else x # borraDuplicados2 xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(*crigomgom anaprarod ferrenseg*)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all)&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar wilmorort pablucoto serrodcal migtermor paupeddeg &lt;br /&gt;
    fraortmoy marpoldia1 danrodcha juacabsou dancorgar josgarsan pabrodmac *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
(* soy de ponerlo mejor por pasos *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma  anaprarod *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (simp, simp)  (* creo que es mejor poner aquí simp_all *)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all (* Creo que se puede poner simp_all fuera de parentesis *)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
(* crigomgom *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;(¬ estaEn x xs)&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;... = 1 +  length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... = length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;  by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  wilmorort ferrenseg rubgonmar juacabsou dancorgar josgarsan *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* serrodcal anaprarod danrodcha *)&lt;br /&gt;
lemma length_borraDuplicados_2: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;  &lt;br /&gt;
proof(induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length [] &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; length (borraDuplicados xs) ≤ length xs &amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp &lt;br /&gt;
  also have &amp;quot;... ≤ length (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally  show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
  have c1:&amp;quot;1+length xs = length (a#xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;length(borraDuplicados (a#xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  then show &amp;quot;length(borraDuplicados (a#xs)) ≤ length (a#xs)&amp;quot; using c1 by simp&lt;br /&gt;
(* ¿Aquí porqué no puedo usar &amp;quot;finally show &amp;quot;?p (a # xs)&amp;quot; using c1 by simp? &lt;br /&gt;
   Y porque no puedo añadir &amp;quot;finally show *) &amp;quot;?p (a # xs)&amp;quot; by simp al final? *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume &amp;quot;(estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume &amp;quot;¬ (estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = 1+ length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  qed&lt;br /&gt;
then show &amp;quot;?P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg marpoldia1 pabrodmac*)&lt;br /&gt;
lemma length_borraDuplicados_4:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ length [a] + length (borraDuplicados xs) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
(* muy parecida a alguna anterior, pero yo dí mas pasos *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  proof (induct xs)&lt;br /&gt;
    show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    fix a xs&lt;br /&gt;
    assume H1: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
    have &amp;quot;length (borraDuplicados (a # xs)) ≤ length(borraDuplicados [a])+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length xs&amp;quot; using H1 by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(* crigomgom rubgonmar  wilmorort pablucoto serrodcal bowma &lt;br /&gt;
    migtermor fraortmoy marpoldia1 ferrenseg danrodcha  juacabsou paupeddeg pabrodmac*)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim manmorjim1 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all, blast)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados&amp;#039;: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
apply (simp_all)&lt;br /&gt;
apply blast&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp, blast)&lt;br /&gt;
done&lt;br /&gt;
 &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  Nota: Para la demostración de la equivalencia se puede usar&lt;br /&gt;
     proof (rule iffI)&lt;br /&gt;
  La regla iffI es&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix b xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (b#xs)) = estaEn a (b#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  H1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#(borraDuplicados xs))&amp;quot; using H1 by simp&lt;br /&gt;
      then have &amp;quot;a=b ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; a=b ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn b (borraDuplicados xs) = estaEn b xs&amp;quot; using HI by simp&lt;br /&gt;
      then have &amp;quot;(estaEn b xs ⟶ estaEn b (borraDuplicados xs)) ∧&lt;br /&gt;
           (¬ estaEn b xs ⟶ estaEn b (b # borraDuplicados xs))&amp;quot; by simp      &lt;br /&gt;
       then have &amp;quot;estaEn b (borraDuplicados (b#xs))&amp;quot; by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a=b` by simp&lt;br /&gt;
     next&lt;br /&gt;
      assume &amp;quot;a≠b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#xs)&amp;quot; using H2 by simp&lt;br /&gt;
      then have &amp;quot;a = b ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;False ∨ estaEn a xs &amp;quot; using `a≠b` by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a≠b` by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod marpoldia1 ferrenseg juacabsou *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2:&lt;br /&gt;
 &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
 proof (cases)&lt;br /&gt;
  assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by auto&lt;br /&gt;
 next&lt;br /&gt;
  assume &amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= (x = a ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  finally show  &amp;quot;?P (x#xs)&amp;quot; using HI by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix aa xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have P1: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume C1: &amp;quot;(estaEn aa xs)&amp;quot;&lt;br /&gt;
    have &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (borraDuplicados xs)&amp;quot; &lt;br /&gt;
             using C1 by simp&lt;br /&gt;
    also have P3: &amp;quot;… = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = estaEn a (aa#xs)&amp;quot;  &lt;br /&gt;
    proof (cases)&lt;br /&gt;
     assume &amp;quot;(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; using C1 by simp&lt;br /&gt;
    next&lt;br /&gt;
     assume &amp;quot;¬(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P3 by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume C2: &amp;quot;¬(estaEn aa xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using HI by simp&lt;br /&gt;
  qed&lt;br /&gt;
 also have Conc: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P1 by simp&lt;br /&gt;
 finally show &amp;quot;?P (aa#xs)&amp;quot; using Conc by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg pabrodmac*)&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume a1: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  a1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#(borraDuplicados xs))&amp;quot; using a1 by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume a2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
      then  show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume b1: &amp;quot;a≠x&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#xs)&amp;quot; using a2 by simp&lt;br /&gt;
      then have &amp;quot;x = a ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs &amp;quot; using b1  by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using b1 by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a  ( borraDuplicados xs ) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
   fix x&lt;br /&gt;
   fix xs&lt;br /&gt;
   assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
   proof (rule iffI) (* usamos proof de la regla dada iffI*)&lt;br /&gt;
     assume cprim: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   next&lt;br /&gt;
     assume cseg: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by auto&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;a≠x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using `a≠x` cseg HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* &lt;br /&gt;
Aplico la regla iffI:&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
Así:&lt;br /&gt;
 [estaEn a (borraDuplicados (x # xs)) ⟹ estaEn a (x # xs); estaEn a (x # xs) ⟹ estaEn a (borraDuplicados (x # xs))] &lt;br /&gt;
⟹ estaEn a (borraDuplicados (x # xs)) = estaEn a (x # xs)&lt;br /&gt;
*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* bowma ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?p []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix x xs&lt;br /&gt;
assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
show &amp;quot;?p (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
  assume H1:&amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; &lt;br /&gt;
    proof(cases)&lt;br /&gt;
    assume &amp;quot;x=a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; using H1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    assume &amp;quot;x≠a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  assume H2:&amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha *)&lt;br /&gt;
(* es como la de ruben pero con diferencias de estilo *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
    next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;x=a&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using H2 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.1. Demostrar o refutar automáticamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal crigomgom anaprarod fraortmoy &lt;br /&gt;
    marpoldia1 ferrenseg danrodcha juacabsou paupeddeg josgarsan pabrodmac *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: estaEn_borraDuplicados)&lt;br /&gt;
&lt;br /&gt;
(* migtermor bowma *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs, simp_all add: estaEn_borraDuplicados_2)&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 no caí en usar la demostración anterior y he realizado&lt;br /&gt;
  la demostración de que si un elemento no estaba en una lista seguirá sin estar&lt;br /&gt;
  después de eliminar los duplicados en esa lista... *)&lt;br /&gt;
lemma noEsta_tras_borrarDuplicados:&lt;br /&gt;
  &amp;quot;(¬estaEn x xs) ⟶ (¬estaEn x (borraDuplicados xs))&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
apply (simp add: noEsta_tras_borrarDuplicados)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.2. Demostrar o refutar detalladamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot; sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot;&lt;br /&gt;
proof (cases)&lt;br /&gt;
assume &amp;quot;estaEn a xs&amp;quot;&lt;br /&gt;
then show &amp;quot;sinDuplicados (borraDuplicados (a#xs))&amp;quot; using HI by simp&lt;br /&gt;
next&lt;br /&gt;
assume&amp;quot;¬ estaEn a xs&amp;quot;&lt;br /&gt;
then have &amp;quot;¬ (estaEn a xs) ∧ sinDuplicados (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
then have &amp;quot;¬ estaEn a (borraDuplicados xs) ∧  sinDuplicados (borraDuplicados xs)&amp;quot; &lt;br /&gt;
      by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
then have &amp;quot; sinDuplicados (a#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
then show &amp;quot; sinDuplicados (borraDuplicados(a #xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor crigomgom rubgonmar fraortmoy marpoldia1 ferrenseg bowma juacabsou serrodcal josgarsan pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; &lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn a xs&amp;quot; &lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;¬(estaEn a xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod paupeddeg*)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show  &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
   proof (cases)&lt;br /&gt;
   assume c1: &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
   then show &amp;quot;sinDuplicados (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
   next&lt;br /&gt;
   assume c2: &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
   then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) =sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;…= (¬estaEn x (borraDuplicados xs) ∧ sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… = (¬estaEn x (borraDuplicados xs))&amp;quot; using HI by simp&lt;br /&gt;
   also have &amp;quot;… = (¬(estaEn x xs))&amp;quot; by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
   also have &amp;quot;… = True&amp;quot; using c2 by simp&lt;br /&gt;
   finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
    case True&lt;br /&gt;
    then have 1: &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
                 = sinDuplicados (borraDuplicados xs)&amp;quot; by (simp add: estaEn_borraDuplicados_2)&lt;br /&gt;
    show &amp;quot;?P (x#xs)&amp;quot; using HI 1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    case False&lt;br /&gt;
    then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
               = sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (estaEn x (borraDuplicados xs)) ∧ &lt;br /&gt;
                  sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = True&amp;quot;  using `¬ estaEn x xs` HI by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
    finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar o refutar:&lt;br /&gt;
    borraDuplicados (rev xs) = rev (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom rubgonmar ivamenjim wilmorort pablucoto migtermor &lt;br /&gt;
   anaprarod fraortmoy ferrenseg marpoldia1 bowma danrodcha juacabsou paupeddeg manmorjim1 serrodcal josgarsan pabrodmac *)&lt;br /&gt;
lemma &amp;quot;borraDuplicados (rev xs) = rev (borraDuplicados xs)&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: Quickcheck encuentra el siguiente contraejemplo: &lt;br /&gt;
   xs = [a1, a2, a1]&lt;br /&gt;
   Por lo que:&lt;br /&gt;
   · &amp;quot;borraDuplicados (rev xs) = [a2, a1]&amp;quot;&lt;br /&gt;
   · &amp;quot;rev (borraDuplicados xs) = [a1, a2]&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=824</id>
		<title>Relación 5</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=824"/>
		<updated>2016-11-30T11:25:10Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R5: Eliminación de duplicados *}&lt;br /&gt;
&lt;br /&gt;
theory R5_Eliminacion_de_duplicados&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
        &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar bowma wilmorort pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1&lt;br /&gt;
    danrodcha manmorjim1 *)&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn _ [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim, ferrenseg josgarsan juacabsou dancorgar pabrodmac *)&lt;br /&gt;
(* Igual que la anterior pero con x en lugar de _ en el caso base *)&lt;br /&gt;
&lt;br /&gt;
fun estaEn1 :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn1 x [] = False&amp;quot; &lt;br /&gt;
| &amp;quot;estaEn1 x (a#xs) = ((x=a) ∨ estaEn1 x xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn1 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn1 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
(* reutilizando  la funcion &amp;quot;algunos&amp;quot; de R4.thy*)&lt;br /&gt;
fun estaEn2  :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn2 a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn2 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn2 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función primitiva recursiva &lt;br /&gt;
     sinDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (sinDuplicados xs) se verifica si la lista xs no contiene&lt;br /&gt;
  duplicados. Por ejemplo,  &lt;br /&gt;
     sinDuplicados [1::nat,4,2]   = True&lt;br /&gt;
     sinDuplicados [1::nat,4,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar ivamenjim  wilmorort bowma pablucoto &lt;br /&gt;
    serrodcal anaprarod migtermor paupeddeg fraortmoy marpoldia1 &lt;br /&gt;
    ferrenseg josgarsan danrodcha manmorjim1 juacabsou dancorgar pabrodmac*)&lt;br /&gt;
fun sinDuplicados :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados (x#xs) = (¬ estaEn x xs ∧ sinDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2]   = True&amp;quot;&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
(* Utilizando la función ∉ de Isabelle *)&lt;br /&gt;
fun sinDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados2 [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados2 (a#xs) = ((a ∉ set xs) ∧  sinDuplicados2 xs ) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función primitiva recursiva &lt;br /&gt;
     borraDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (borraDuplicados xs) es la lista obtenida eliminando los&lt;br /&gt;
  elementos duplicados de la lista xs. Por ejemplo, &lt;br /&gt;
     borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función borraDuplicados es equivalente a la predefinida&lt;br /&gt;
  remdups.  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar wilmorort bowma pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1 ferrenseg &lt;br /&gt;
    josgarsan danrodcha juacabsou dancorgar manmorjim1 pabrodmac*)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(* Otra forma Sin usar if &lt;br /&gt;
  Utilizando case aunque se le sacaría más partido con más de 2 casos *)&lt;br /&gt;
 &lt;br /&gt;
 fun borraDuplicados1 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados1 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados1 (x#xs) = ( case estaEn x xs of False  =&amp;gt; x#borraDuplicados1 xs | True =&amp;gt; borraDuplicados1 xs )&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(*Otra forma utilizando let*)&lt;br /&gt;
fun borraDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados2 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados2 (x#xs) =  (let condicion = estaEn x xs::bool  in &lt;br /&gt;
if  condicion then borraDuplicados2 xs else x # borraDuplicados2 xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(*crigomgom anaprarod ferrenseg*)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all)&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar wilmorort pablucoto serrodcal migtermor paupeddeg &lt;br /&gt;
    fraortmoy marpoldia1 danrodcha juacabsou dancorgar josgarsan pabrodmac *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
(* soy de ponerlo mejor por pasos *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma  anaprarod *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (simp, simp)  (* creo que es mejor poner aquí simp_all *)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all (* Creo que se puede poner simp_all fuera de parentesis *)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
(* crigomgom *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;(¬ estaEn x xs)&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;... = 1 +  length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... = length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;  by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  wilmorort ferrenseg rubgonmar juacabsou dancorgar josgarsan *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* serrodcal anaprarod danrodcha *)&lt;br /&gt;
lemma length_borraDuplicados_2: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;  &lt;br /&gt;
proof(induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length [] &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; length (borraDuplicados xs) ≤ length xs &amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp &lt;br /&gt;
  also have &amp;quot;... ≤ length (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally  show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
  have c1:&amp;quot;1+length xs = length (a#xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;length(borraDuplicados (a#xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  then show &amp;quot;length(borraDuplicados (a#xs)) ≤ length (a#xs)&amp;quot; using c1 by simp&lt;br /&gt;
(* ¿Aquí porqué no puedo usar &amp;quot;finally show &amp;quot;?p (a # xs)&amp;quot; using c1 by simp? &lt;br /&gt;
   Y porque no puedo añadir &amp;quot;finally show *) &amp;quot;?p (a # xs)&amp;quot; by simp al final? *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume &amp;quot;(estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume &amp;quot;¬ (estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = 1+ length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  qed&lt;br /&gt;
then show &amp;quot;?P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg marpoldia1*)&lt;br /&gt;
lemma length_borraDuplicados_4:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ length [a] + length (borraDuplicados xs) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
(* muy parecida a alguna anterior, pero yo dí mas pasos *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  proof (induct xs)&lt;br /&gt;
    show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    fix a xs&lt;br /&gt;
    assume H1: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
    have &amp;quot;length (borraDuplicados (a # xs)) ≤ length(borraDuplicados [a])+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length xs&amp;quot; using H1 by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(* crigomgom rubgonmar  wilmorort pablucoto serrodcal bowma &lt;br /&gt;
    migtermor fraortmoy marpoldia1 ferrenseg danrodcha  juacabsou paupeddeg*)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim manmorjim1 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all, blast)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados&amp;#039;: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
apply (simp_all)&lt;br /&gt;
apply blast&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp, blast)&lt;br /&gt;
done&lt;br /&gt;
 &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  Nota: Para la demostración de la equivalencia se puede usar&lt;br /&gt;
     proof (rule iffI)&lt;br /&gt;
  La regla iffI es&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix b xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (b#xs)) = estaEn a (b#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  H1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#(borraDuplicados xs))&amp;quot; using H1 by simp&lt;br /&gt;
      then have &amp;quot;a=b ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; a=b ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn b (borraDuplicados xs) = estaEn b xs&amp;quot; using HI by simp&lt;br /&gt;
      then have &amp;quot;(estaEn b xs ⟶ estaEn b (borraDuplicados xs)) ∧&lt;br /&gt;
           (¬ estaEn b xs ⟶ estaEn b (b # borraDuplicados xs))&amp;quot; by simp      &lt;br /&gt;
       then have &amp;quot;estaEn b (borraDuplicados (b#xs))&amp;quot; by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a=b` by simp&lt;br /&gt;
     next&lt;br /&gt;
      assume &amp;quot;a≠b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#xs)&amp;quot; using H2 by simp&lt;br /&gt;
      then have &amp;quot;a = b ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;False ∨ estaEn a xs &amp;quot; using `a≠b` by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a≠b` by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod marpoldia1 ferrenseg juacabsou *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2:&lt;br /&gt;
 &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
 proof (cases)&lt;br /&gt;
  assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by auto&lt;br /&gt;
 next&lt;br /&gt;
  assume &amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= (x = a ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  finally show  &amp;quot;?P (x#xs)&amp;quot; using HI by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix aa xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have P1: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume C1: &amp;quot;(estaEn aa xs)&amp;quot;&lt;br /&gt;
    have &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (borraDuplicados xs)&amp;quot; &lt;br /&gt;
             using C1 by simp&lt;br /&gt;
    also have P3: &amp;quot;… = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = estaEn a (aa#xs)&amp;quot;  &lt;br /&gt;
    proof (cases)&lt;br /&gt;
     assume &amp;quot;(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; using C1 by simp&lt;br /&gt;
    next&lt;br /&gt;
     assume &amp;quot;¬(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P3 by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume C2: &amp;quot;¬(estaEn aa xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using HI by simp&lt;br /&gt;
  qed&lt;br /&gt;
 also have Conc: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P1 by simp&lt;br /&gt;
 finally show &amp;quot;?P (aa#xs)&amp;quot; using Conc by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg pabrodmac*)&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume a1: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  a1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#(borraDuplicados xs))&amp;quot; using a1 by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume a2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
      then  show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume b1: &amp;quot;a≠x&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#xs)&amp;quot; using a2 by simp&lt;br /&gt;
      then have &amp;quot;x = a ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs &amp;quot; using b1  by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using b1 by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a  ( borraDuplicados xs ) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
   fix x&lt;br /&gt;
   fix xs&lt;br /&gt;
   assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
   proof (rule iffI) (* usamos proof de la regla dada iffI*)&lt;br /&gt;
     assume cprim: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   next&lt;br /&gt;
     assume cseg: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by auto&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;a≠x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using `a≠x` cseg HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* &lt;br /&gt;
Aplico la regla iffI:&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
Así:&lt;br /&gt;
 [estaEn a (borraDuplicados (x # xs)) ⟹ estaEn a (x # xs); estaEn a (x # xs) ⟹ estaEn a (borraDuplicados (x # xs))] &lt;br /&gt;
⟹ estaEn a (borraDuplicados (x # xs)) = estaEn a (x # xs)&lt;br /&gt;
*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* bowma ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?p []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix x xs&lt;br /&gt;
assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
show &amp;quot;?p (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
  assume H1:&amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; &lt;br /&gt;
    proof(cases)&lt;br /&gt;
    assume &amp;quot;x=a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; using H1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    assume &amp;quot;x≠a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  assume H2:&amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha *)&lt;br /&gt;
(* es como la de ruben pero con diferencias de estilo *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
    next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;x=a&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using H2 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.1. Demostrar o refutar automáticamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal crigomgom anaprarod fraortmoy &lt;br /&gt;
    marpoldia1 ferrenseg danrodcha juacabsou paupeddeg josgarsan pabrodmac *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: estaEn_borraDuplicados)&lt;br /&gt;
&lt;br /&gt;
(* migtermor bowma *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs, simp_all add: estaEn_borraDuplicados_2)&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 no caí en usar la demostración anterior y he realizado&lt;br /&gt;
  la demostración de que si un elemento no estaba en una lista seguirá sin estar&lt;br /&gt;
  después de eliminar los duplicados en esa lista... *)&lt;br /&gt;
lemma noEsta_tras_borrarDuplicados:&lt;br /&gt;
  &amp;quot;(¬estaEn x xs) ⟶ (¬estaEn x (borraDuplicados xs))&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
apply (simp add: noEsta_tras_borrarDuplicados)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.2. Demostrar o refutar detalladamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot; sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot;&lt;br /&gt;
proof (cases)&lt;br /&gt;
assume &amp;quot;estaEn a xs&amp;quot;&lt;br /&gt;
then show &amp;quot;sinDuplicados (borraDuplicados (a#xs))&amp;quot; using HI by simp&lt;br /&gt;
next&lt;br /&gt;
assume&amp;quot;¬ estaEn a xs&amp;quot;&lt;br /&gt;
then have &amp;quot;¬ (estaEn a xs) ∧ sinDuplicados (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
then have &amp;quot;¬ estaEn a (borraDuplicados xs) ∧  sinDuplicados (borraDuplicados xs)&amp;quot; &lt;br /&gt;
      by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
then have &amp;quot; sinDuplicados (a#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
then show &amp;quot; sinDuplicados (borraDuplicados(a #xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor crigomgom rubgonmar fraortmoy marpoldia1 ferrenseg bowma juacabsou serrodcal josgarsan pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; &lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn a xs&amp;quot; &lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;¬(estaEn a xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod paupeddeg*)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show  &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
   proof (cases)&lt;br /&gt;
   assume c1: &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
   then show &amp;quot;sinDuplicados (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
   next&lt;br /&gt;
   assume c2: &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
   then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) =sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;…= (¬estaEn x (borraDuplicados xs) ∧ sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… = (¬estaEn x (borraDuplicados xs))&amp;quot; using HI by simp&lt;br /&gt;
   also have &amp;quot;… = (¬(estaEn x xs))&amp;quot; by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
   also have &amp;quot;… = True&amp;quot; using c2 by simp&lt;br /&gt;
   finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
    case True&lt;br /&gt;
    then have 1: &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
                 = sinDuplicados (borraDuplicados xs)&amp;quot; by (simp add: estaEn_borraDuplicados_2)&lt;br /&gt;
    show &amp;quot;?P (x#xs)&amp;quot; using HI 1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    case False&lt;br /&gt;
    then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
               = sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (estaEn x (borraDuplicados xs)) ∧ &lt;br /&gt;
                  sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = True&amp;quot;  using `¬ estaEn x xs` HI by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
    finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar o refutar:&lt;br /&gt;
    borraDuplicados (rev xs) = rev (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom rubgonmar ivamenjim wilmorort pablucoto migtermor &lt;br /&gt;
   anaprarod fraortmoy ferrenseg marpoldia1 bowma danrodcha juacabsou paupeddeg manmorjim1 serrodcal josgarsan pabrodmac *)&lt;br /&gt;
lemma &amp;quot;borraDuplicados (rev xs) = rev (borraDuplicados xs)&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: Quickcheck encuentra el siguiente contraejemplo: &lt;br /&gt;
   xs = [a1, a2, a1]&lt;br /&gt;
   Por lo que:&lt;br /&gt;
   · &amp;quot;borraDuplicados (rev xs) = [a2, a1]&amp;quot;&lt;br /&gt;
   · &amp;quot;rev (borraDuplicados xs) = [a1, a2]&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=823</id>
		<title>Relación 5</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=823"/>
		<updated>2016-11-30T11:21:56Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R5: Eliminación de duplicados *}&lt;br /&gt;
&lt;br /&gt;
theory R5_Eliminacion_de_duplicados&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
        &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar bowma wilmorort pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1&lt;br /&gt;
    danrodcha manmorjim1 *)&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn _ [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim, ferrenseg josgarsan juacabsou dancorgar pabrodmac *)&lt;br /&gt;
(* Igual que la anterior pero con x en lugar de _ en el caso base *)&lt;br /&gt;
&lt;br /&gt;
fun estaEn1 :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn1 x [] = False&amp;quot; &lt;br /&gt;
| &amp;quot;estaEn1 x (a#xs) = ((x=a) ∨ estaEn1 x xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn1 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn1 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
(* reutilizando  la funcion &amp;quot;algunos&amp;quot; de R4.thy*)&lt;br /&gt;
fun estaEn2  :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn2 a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn2 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn2 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función primitiva recursiva &lt;br /&gt;
     sinDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (sinDuplicados xs) se verifica si la lista xs no contiene&lt;br /&gt;
  duplicados. Por ejemplo,  &lt;br /&gt;
     sinDuplicados [1::nat,4,2]   = True&lt;br /&gt;
     sinDuplicados [1::nat,4,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar ivamenjim  wilmorort bowma pablucoto &lt;br /&gt;
    serrodcal anaprarod migtermor paupeddeg fraortmoy marpoldia1 &lt;br /&gt;
    ferrenseg josgarsan danrodcha manmorjim1 juacabsou dancorgar pabrodmac*)&lt;br /&gt;
fun sinDuplicados :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados (x#xs) = (¬ estaEn x xs ∧ sinDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2]   = True&amp;quot;&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
(* Utilizando la función ∉ de Isabelle *)&lt;br /&gt;
fun sinDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados2 [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados2 (a#xs) = ((a ∉ set xs) ∧  sinDuplicados2 xs ) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función primitiva recursiva &lt;br /&gt;
     borraDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (borraDuplicados xs) es la lista obtenida eliminando los&lt;br /&gt;
  elementos duplicados de la lista xs. Por ejemplo, &lt;br /&gt;
     borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función borraDuplicados es equivalente a la predefinida&lt;br /&gt;
  remdups.  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar wilmorort bowma pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1 ferrenseg &lt;br /&gt;
    josgarsan danrodcha juacabsou dancorgar manmorjim1 pabrodmac*)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(* Otra forma Sin usar if &lt;br /&gt;
  Utilizando case aunque se le sacaría más partido con más de 2 casos *)&lt;br /&gt;
 &lt;br /&gt;
 fun borraDuplicados1 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados1 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados1 (x#xs) = ( case estaEn x xs of False  =&amp;gt; x#borraDuplicados1 xs | True =&amp;gt; borraDuplicados1 xs )&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(*Otra forma utilizando let*)&lt;br /&gt;
fun borraDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados2 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados2 (x#xs) =  (let condicion = estaEn x xs::bool  in &lt;br /&gt;
if  condicion then borraDuplicados2 xs else x # borraDuplicados2 xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(*crigomgom anaprarod ferrenseg*)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all)&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar wilmorort pablucoto serrodcal migtermor paupeddeg &lt;br /&gt;
    fraortmoy marpoldia1 danrodcha juacabsou dancorgar josgarsan pabrodmac *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
(* soy de ponerlo mejor por pasos *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma  anaprarod *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (simp, simp)  (* creo que es mejor poner aquí simp_all *)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all (* Creo que se puede poner simp_all fuera de parentesis *)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
(* crigomgom *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;(¬ estaEn x xs)&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;... = 1 +  length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... = length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;  by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  wilmorort ferrenseg rubgonmar juacabsou dancorgar josgarsan *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* serrodcal anaprarod danrodcha *)&lt;br /&gt;
lemma length_borraDuplicados_2: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;  &lt;br /&gt;
proof(induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length [] &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; length (borraDuplicados xs) ≤ length xs &amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp &lt;br /&gt;
  also have &amp;quot;... ≤ length (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally  show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
  have c1:&amp;quot;1+length xs = length (a#xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;length(borraDuplicados (a#xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  then show &amp;quot;length(borraDuplicados (a#xs)) ≤ length (a#xs)&amp;quot; using c1 by simp&lt;br /&gt;
(* ¿Aquí porqué no puedo usar &amp;quot;finally show &amp;quot;?p (a # xs)&amp;quot; using c1 by simp? &lt;br /&gt;
   Y porque no puedo añadir &amp;quot;finally show *) &amp;quot;?p (a # xs)&amp;quot; by simp al final? *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume &amp;quot;(estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume &amp;quot;¬ (estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = 1+ length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  qed&lt;br /&gt;
then show &amp;quot;?P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg marpoldia1*)&lt;br /&gt;
lemma length_borraDuplicados_4:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ length [a] + length (borraDuplicados xs) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
(* muy parecida a alguna anterior, pero yo dí mas pasos *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  proof (induct xs)&lt;br /&gt;
    show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    fix a xs&lt;br /&gt;
    assume H1: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
    have &amp;quot;length (borraDuplicados (a # xs)) ≤ length(borraDuplicados [a])+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length xs&amp;quot; using H1 by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(* crigomgom rubgonmar  wilmorort pablucoto serrodcal bowma &lt;br /&gt;
    migtermor fraortmoy marpoldia1 ferrenseg danrodcha  juacabsou paupeddeg*)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim manmorjim1 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all, blast)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados&amp;#039;: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
apply (simp_all)&lt;br /&gt;
apply blast&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp, blast)&lt;br /&gt;
done&lt;br /&gt;
 &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  Nota: Para la demostración de la equivalencia se puede usar&lt;br /&gt;
     proof (rule iffI)&lt;br /&gt;
  La regla iffI es&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix b xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (b#xs)) = estaEn a (b#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  H1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#(borraDuplicados xs))&amp;quot; using H1 by simp&lt;br /&gt;
      then have &amp;quot;a=b ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; a=b ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn b (borraDuplicados xs) = estaEn b xs&amp;quot; using HI by simp&lt;br /&gt;
      then have &amp;quot;(estaEn b xs ⟶ estaEn b (borraDuplicados xs)) ∧&lt;br /&gt;
           (¬ estaEn b xs ⟶ estaEn b (b # borraDuplicados xs))&amp;quot; by simp      &lt;br /&gt;
       then have &amp;quot;estaEn b (borraDuplicados (b#xs))&amp;quot; by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a=b` by simp&lt;br /&gt;
     next&lt;br /&gt;
      assume &amp;quot;a≠b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#xs)&amp;quot; using H2 by simp&lt;br /&gt;
      then have &amp;quot;a = b ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;False ∨ estaEn a xs &amp;quot; using `a≠b` by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a≠b` by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod marpoldia1 ferrenseg juacabsou *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2:&lt;br /&gt;
 &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
 proof (cases)&lt;br /&gt;
  assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by auto&lt;br /&gt;
 next&lt;br /&gt;
  assume &amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= (x = a ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  finally show  &amp;quot;?P (x#xs)&amp;quot; using HI by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix aa xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have P1: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume C1: &amp;quot;(estaEn aa xs)&amp;quot;&lt;br /&gt;
    have &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (borraDuplicados xs)&amp;quot; &lt;br /&gt;
             using C1 by simp&lt;br /&gt;
    also have P3: &amp;quot;… = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = estaEn a (aa#xs)&amp;quot;  &lt;br /&gt;
    proof (cases)&lt;br /&gt;
     assume &amp;quot;(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; using C1 by simp&lt;br /&gt;
    next&lt;br /&gt;
     assume &amp;quot;¬(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P3 by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume C2: &amp;quot;¬(estaEn aa xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using HI by simp&lt;br /&gt;
  qed&lt;br /&gt;
 also have Conc: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P1 by simp&lt;br /&gt;
 finally show &amp;quot;?P (aa#xs)&amp;quot; using Conc by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg *)&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume a1: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  a1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#(borraDuplicados xs))&amp;quot; using a1 by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume a2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
      then  show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume b1: &amp;quot;a≠x&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#xs)&amp;quot; using a2 by simp&lt;br /&gt;
      then have &amp;quot;x = a ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs &amp;quot; using b1  by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using b1 by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a  ( borraDuplicados xs ) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
   fix x&lt;br /&gt;
   fix xs&lt;br /&gt;
   assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
   proof (rule iffI) (* usamos proof de la regla dada iffI*)&lt;br /&gt;
     assume cprim: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   next&lt;br /&gt;
     assume cseg: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by auto&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;a≠x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using `a≠x` cseg HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* &lt;br /&gt;
Aplico la regla iffI:&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
Así:&lt;br /&gt;
 [estaEn a (borraDuplicados (x # xs)) ⟹ estaEn a (x # xs); estaEn a (x # xs) ⟹ estaEn a (borraDuplicados (x # xs))] &lt;br /&gt;
⟹ estaEn a (borraDuplicados (x # xs)) = estaEn a (x # xs)&lt;br /&gt;
*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* bowma ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?p []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix x xs&lt;br /&gt;
assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
show &amp;quot;?p (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
  assume H1:&amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; &lt;br /&gt;
    proof(cases)&lt;br /&gt;
    assume &amp;quot;x=a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; using H1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    assume &amp;quot;x≠a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  assume H2:&amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha *)&lt;br /&gt;
(* es como la de ruben pero con diferencias de estilo *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
    next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;x=a&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using H2 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.1. Demostrar o refutar automáticamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal crigomgom anaprarod fraortmoy &lt;br /&gt;
    marpoldia1 ferrenseg danrodcha juacabsou paupeddeg josgarsan pabrodmac *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: estaEn_borraDuplicados)&lt;br /&gt;
&lt;br /&gt;
(* migtermor bowma *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs, simp_all add: estaEn_borraDuplicados_2)&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 no caí en usar la demostración anterior y he realizado&lt;br /&gt;
  la demostración de que si un elemento no estaba en una lista seguirá sin estar&lt;br /&gt;
  después de eliminar los duplicados en esa lista... *)&lt;br /&gt;
lemma noEsta_tras_borrarDuplicados:&lt;br /&gt;
  &amp;quot;(¬estaEn x xs) ⟶ (¬estaEn x (borraDuplicados xs))&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
apply (simp add: noEsta_tras_borrarDuplicados)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.2. Demostrar o refutar detalladamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot; sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot;&lt;br /&gt;
proof (cases)&lt;br /&gt;
assume &amp;quot;estaEn a xs&amp;quot;&lt;br /&gt;
then show &amp;quot;sinDuplicados (borraDuplicados (a#xs))&amp;quot; using HI by simp&lt;br /&gt;
next&lt;br /&gt;
assume&amp;quot;¬ estaEn a xs&amp;quot;&lt;br /&gt;
then have &amp;quot;¬ (estaEn a xs) ∧ sinDuplicados (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
then have &amp;quot;¬ estaEn a (borraDuplicados xs) ∧  sinDuplicados (borraDuplicados xs)&amp;quot; &lt;br /&gt;
      by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
then have &amp;quot; sinDuplicados (a#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
then show &amp;quot; sinDuplicados (borraDuplicados(a #xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor crigomgom rubgonmar fraortmoy marpoldia1 ferrenseg bowma juacabsou serrodcal josgarsan *)&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; &lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn a xs&amp;quot; &lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;¬(estaEn a xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod paupeddeg*)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show  &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
   proof (cases)&lt;br /&gt;
   assume c1: &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
   then show &amp;quot;sinDuplicados (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
   next&lt;br /&gt;
   assume c2: &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
   then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) =sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;…= (¬estaEn x (borraDuplicados xs) ∧ sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… = (¬estaEn x (borraDuplicados xs))&amp;quot; using HI by simp&lt;br /&gt;
   also have &amp;quot;… = (¬(estaEn x xs))&amp;quot; by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
   also have &amp;quot;… = True&amp;quot; using c2 by simp&lt;br /&gt;
   finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
    case True&lt;br /&gt;
    then have 1: &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
                 = sinDuplicados (borraDuplicados xs)&amp;quot; by (simp add: estaEn_borraDuplicados_2)&lt;br /&gt;
    show &amp;quot;?P (x#xs)&amp;quot; using HI 1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    case False&lt;br /&gt;
    then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
               = sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (estaEn x (borraDuplicados xs)) ∧ &lt;br /&gt;
                  sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = True&amp;quot;  using `¬ estaEn x xs` HI by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
    finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar o refutar:&lt;br /&gt;
    borraDuplicados (rev xs) = rev (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom rubgonmar ivamenjim wilmorort pablucoto migtermor &lt;br /&gt;
   anaprarod fraortmoy ferrenseg marpoldia1 bowma danrodcha juacabsou paupeddeg manmorjim1 serrodcal josgarsan pabrodmac *)&lt;br /&gt;
lemma &amp;quot;borraDuplicados (rev xs) = rev (borraDuplicados xs)&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: Quickcheck encuentra el siguiente contraejemplo: &lt;br /&gt;
   xs = [a1, a2, a1]&lt;br /&gt;
   Por lo que:&lt;br /&gt;
   · &amp;quot;borraDuplicados (rev xs) = [a2, a1]&amp;quot;&lt;br /&gt;
   · &amp;quot;rev (borraDuplicados xs) = [a1, a2]&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=822</id>
		<title>Relación 5</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=822"/>
		<updated>2016-11-30T11:18:01Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R5: Eliminación de duplicados *}&lt;br /&gt;
&lt;br /&gt;
theory R5_Eliminacion_de_duplicados&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
        &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar bowma wilmorort pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1&lt;br /&gt;
    danrodcha manmorjim1 *)&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn _ [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim, ferrenseg josgarsan juacabsou dancorgar pabrodmac *)&lt;br /&gt;
(* Igual que la anterior pero con x en lugar de _ en el caso base *)&lt;br /&gt;
&lt;br /&gt;
fun estaEn1 :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn1 x [] = False&amp;quot; &lt;br /&gt;
| &amp;quot;estaEn1 x (a#xs) = ((x=a) ∨ estaEn1 x xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn1 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn1 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
(* reutilizando  la funcion &amp;quot;algunos&amp;quot; de R4.thy*)&lt;br /&gt;
fun estaEn2  :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn2 a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn2 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn2 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función primitiva recursiva &lt;br /&gt;
     sinDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (sinDuplicados xs) se verifica si la lista xs no contiene&lt;br /&gt;
  duplicados. Por ejemplo,  &lt;br /&gt;
     sinDuplicados [1::nat,4,2]   = True&lt;br /&gt;
     sinDuplicados [1::nat,4,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar ivamenjim  wilmorort bowma pablucoto &lt;br /&gt;
    serrodcal anaprarod migtermor paupeddeg fraortmoy marpoldia1 &lt;br /&gt;
    ferrenseg josgarsan danrodcha manmorjim1 juacabsou dancorgar pabrodmac*)&lt;br /&gt;
fun sinDuplicados :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados (x#xs) = (¬ estaEn x xs ∧ sinDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2]   = True&amp;quot;&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
(* Utilizando la función ∉ de Isabelle *)&lt;br /&gt;
fun sinDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados2 [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados2 (a#xs) = ((a ∉ set xs) ∧  sinDuplicados2 xs ) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función primitiva recursiva &lt;br /&gt;
     borraDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (borraDuplicados xs) es la lista obtenida eliminando los&lt;br /&gt;
  elementos duplicados de la lista xs. Por ejemplo, &lt;br /&gt;
     borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función borraDuplicados es equivalente a la predefinida&lt;br /&gt;
  remdups.  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar wilmorort bowma pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1 ferrenseg &lt;br /&gt;
    josgarsan danrodcha juacabsou dancorgar manmorjim1 pabrodmac*)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(* Otra forma Sin usar if &lt;br /&gt;
  Utilizando case aunque se le sacaría más partido con más de 2 casos *)&lt;br /&gt;
 &lt;br /&gt;
 fun borraDuplicados1 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados1 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados1 (x#xs) = ( case estaEn x xs of False  =&amp;gt; x#borraDuplicados1 xs | True =&amp;gt; borraDuplicados1 xs )&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(*Otra forma utilizando let*)&lt;br /&gt;
fun borraDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados2 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados2 (x#xs) =  (let condicion = estaEn x xs::bool  in &lt;br /&gt;
if  condicion then borraDuplicados2 xs else x # borraDuplicados2 xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(*crigomgom anaprarod ferrenseg*)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all)&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar wilmorort pablucoto serrodcal migtermor paupeddeg &lt;br /&gt;
    fraortmoy marpoldia1 danrodcha juacabsou dancorgar josgarsan pabrodmac *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
(* soy de ponerlo mejor por pasos *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma  anaprarod *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (simp, simp)  (* creo que es mejor poner aquí simp_all *)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all (* Creo que se puede poner simp_all fuera de parentesis *)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
(* crigomgom *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;(¬ estaEn x xs)&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;... = 1 +  length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... = length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;  by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  wilmorort ferrenseg rubgonmar juacabsou dancorgar josgarsan *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* serrodcal anaprarod danrodcha *)&lt;br /&gt;
lemma length_borraDuplicados_2: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;  &lt;br /&gt;
proof(induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length [] &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; length (borraDuplicados xs) ≤ length xs &amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp &lt;br /&gt;
  also have &amp;quot;... ≤ length (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally  show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
  have c1:&amp;quot;1+length xs = length (a#xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;length(borraDuplicados (a#xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  then show &amp;quot;length(borraDuplicados (a#xs)) ≤ length (a#xs)&amp;quot; using c1 by simp&lt;br /&gt;
(* ¿Aquí porqué no puedo usar &amp;quot;finally show &amp;quot;?p (a # xs)&amp;quot; using c1 by simp? &lt;br /&gt;
   Y porque no puedo añadir &amp;quot;finally show *) &amp;quot;?p (a # xs)&amp;quot; by simp al final? *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume &amp;quot;(estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume &amp;quot;¬ (estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = 1+ length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  qed&lt;br /&gt;
then show &amp;quot;?P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg marpoldia1*)&lt;br /&gt;
lemma length_borraDuplicados_4:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ length [a] + length (borraDuplicados xs) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
(* muy parecida a alguna anterior, pero yo dí mas pasos *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  proof (induct xs)&lt;br /&gt;
    show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    fix a xs&lt;br /&gt;
    assume H1: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
    have &amp;quot;length (borraDuplicados (a # xs)) ≤ length(borraDuplicados [a])+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length xs&amp;quot; using H1 by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(* crigomgom rubgonmar  wilmorort pablucoto serrodcal bowma &lt;br /&gt;
    migtermor fraortmoy marpoldia1 ferrenseg danrodcha  juacabsou paupeddeg*)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim manmorjim1 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all, blast)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados&amp;#039;: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
apply (simp_all)&lt;br /&gt;
apply blast&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp, blast)&lt;br /&gt;
done&lt;br /&gt;
 &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  Nota: Para la demostración de la equivalencia se puede usar&lt;br /&gt;
     proof (rule iffI)&lt;br /&gt;
  La regla iffI es&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix b xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (b#xs)) = estaEn a (b#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  H1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#(borraDuplicados xs))&amp;quot; using H1 by simp&lt;br /&gt;
      then have &amp;quot;a=b ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; a=b ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn b (borraDuplicados xs) = estaEn b xs&amp;quot; using HI by simp&lt;br /&gt;
      then have &amp;quot;(estaEn b xs ⟶ estaEn b (borraDuplicados xs)) ∧&lt;br /&gt;
           (¬ estaEn b xs ⟶ estaEn b (b # borraDuplicados xs))&amp;quot; by simp      &lt;br /&gt;
       then have &amp;quot;estaEn b (borraDuplicados (b#xs))&amp;quot; by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a=b` by simp&lt;br /&gt;
     next&lt;br /&gt;
      assume &amp;quot;a≠b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#xs)&amp;quot; using H2 by simp&lt;br /&gt;
      then have &amp;quot;a = b ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;False ∨ estaEn a xs &amp;quot; using `a≠b` by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a≠b` by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod marpoldia1 ferrenseg juacabsou *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2:&lt;br /&gt;
 &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
 proof (cases)&lt;br /&gt;
  assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by auto&lt;br /&gt;
 next&lt;br /&gt;
  assume &amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= (x = a ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  finally show  &amp;quot;?P (x#xs)&amp;quot; using HI by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix aa xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have P1: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume C1: &amp;quot;(estaEn aa xs)&amp;quot;&lt;br /&gt;
    have &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (borraDuplicados xs)&amp;quot; &lt;br /&gt;
             using C1 by simp&lt;br /&gt;
    also have P3: &amp;quot;… = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = estaEn a (aa#xs)&amp;quot;  &lt;br /&gt;
    proof (cases)&lt;br /&gt;
     assume &amp;quot;(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; using C1 by simp&lt;br /&gt;
    next&lt;br /&gt;
     assume &amp;quot;¬(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P3 by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume C2: &amp;quot;¬(estaEn aa xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using HI by simp&lt;br /&gt;
  qed&lt;br /&gt;
 also have Conc: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P1 by simp&lt;br /&gt;
 finally show &amp;quot;?P (aa#xs)&amp;quot; using Conc by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg *)&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume a1: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  a1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#(borraDuplicados xs))&amp;quot; using a1 by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume a2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
      then  show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume b1: &amp;quot;a≠x&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#xs)&amp;quot; using a2 by simp&lt;br /&gt;
      then have &amp;quot;x = a ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs &amp;quot; using b1  by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using b1 by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a  ( borraDuplicados xs ) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
   fix x&lt;br /&gt;
   fix xs&lt;br /&gt;
   assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
   proof (rule iffI) (* usamos proof de la regla dada iffI*)&lt;br /&gt;
     assume cprim: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   next&lt;br /&gt;
     assume cseg: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by auto&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;a≠x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using `a≠x` cseg HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* &lt;br /&gt;
Aplico la regla iffI:&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
Así:&lt;br /&gt;
 [estaEn a (borraDuplicados (x # xs)) ⟹ estaEn a (x # xs); estaEn a (x # xs) ⟹ estaEn a (borraDuplicados (x # xs))] &lt;br /&gt;
⟹ estaEn a (borraDuplicados (x # xs)) = estaEn a (x # xs)&lt;br /&gt;
*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* bowma ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?p []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix x xs&lt;br /&gt;
assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
show &amp;quot;?p (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
  assume H1:&amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; &lt;br /&gt;
    proof(cases)&lt;br /&gt;
    assume &amp;quot;x=a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; using H1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    assume &amp;quot;x≠a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  assume H2:&amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha *)&lt;br /&gt;
(* es como la de ruben pero con diferencias de estilo *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
    next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;x=a&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using H2 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.1. Demostrar o refutar automáticamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal crigomgom anaprarod fraortmoy &lt;br /&gt;
    marpoldia1 ferrenseg danrodcha juacabsou paupeddeg josgarsan *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: estaEn_borraDuplicados)&lt;br /&gt;
&lt;br /&gt;
(* migtermor bowma *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs, simp_all add: estaEn_borraDuplicados_2)&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 no caí en usar la demostración anterior y he realizado&lt;br /&gt;
  la demostración de que si un elemento no estaba en una lista seguirá sin estar&lt;br /&gt;
  después de eliminar los duplicados en esa lista... *)&lt;br /&gt;
lemma noEsta_tras_borrarDuplicados:&lt;br /&gt;
  &amp;quot;(¬estaEn x xs) ⟶ (¬estaEn x (borraDuplicados xs))&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
apply (simp add: noEsta_tras_borrarDuplicados)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.2. Demostrar o refutar detalladamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot; sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot;&lt;br /&gt;
proof (cases)&lt;br /&gt;
assume &amp;quot;estaEn a xs&amp;quot;&lt;br /&gt;
then show &amp;quot;sinDuplicados (borraDuplicados (a#xs))&amp;quot; using HI by simp&lt;br /&gt;
next&lt;br /&gt;
assume&amp;quot;¬ estaEn a xs&amp;quot;&lt;br /&gt;
then have &amp;quot;¬ (estaEn a xs) ∧ sinDuplicados (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
then have &amp;quot;¬ estaEn a (borraDuplicados xs) ∧  sinDuplicados (borraDuplicados xs)&amp;quot; &lt;br /&gt;
      by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
then have &amp;quot; sinDuplicados (a#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
then show &amp;quot; sinDuplicados (borraDuplicados(a #xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor crigomgom rubgonmar fraortmoy marpoldia1 ferrenseg bowma juacabsou serrodcal josgarsan *)&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; &lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn a xs&amp;quot; &lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;¬(estaEn a xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod paupeddeg*)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show  &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
   proof (cases)&lt;br /&gt;
   assume c1: &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
   then show &amp;quot;sinDuplicados (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
   next&lt;br /&gt;
   assume c2: &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
   then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) =sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;…= (¬estaEn x (borraDuplicados xs) ∧ sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… = (¬estaEn x (borraDuplicados xs))&amp;quot; using HI by simp&lt;br /&gt;
   also have &amp;quot;… = (¬(estaEn x xs))&amp;quot; by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
   also have &amp;quot;… = True&amp;quot; using c2 by simp&lt;br /&gt;
   finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
    case True&lt;br /&gt;
    then have 1: &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
                 = sinDuplicados (borraDuplicados xs)&amp;quot; by (simp add: estaEn_borraDuplicados_2)&lt;br /&gt;
    show &amp;quot;?P (x#xs)&amp;quot; using HI 1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    case False&lt;br /&gt;
    then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
               = sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (estaEn x (borraDuplicados xs)) ∧ &lt;br /&gt;
                  sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = True&amp;quot;  using `¬ estaEn x xs` HI by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
    finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar o refutar:&lt;br /&gt;
    borraDuplicados (rev xs) = rev (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom rubgonmar ivamenjim wilmorort pablucoto migtermor &lt;br /&gt;
   anaprarod fraortmoy ferrenseg marpoldia1 bowma danrodcha juacabsou paupeddeg manmorjim1 serrodcal josgarsan *)&lt;br /&gt;
lemma &amp;quot;borraDuplicados (rev xs) = rev (borraDuplicados xs)&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: Quickcheck encuentra el siguiente contraejemplo: &lt;br /&gt;
   xs = [a1, a2, a1]&lt;br /&gt;
   Por lo que:&lt;br /&gt;
   · &amp;quot;borraDuplicados (rev xs) = [a2, a1]&amp;quot;&lt;br /&gt;
   · &amp;quot;rev (borraDuplicados xs) = [a1, a2]&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=821</id>
		<title>Relación 5</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=821"/>
		<updated>2016-11-30T11:14:57Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R5: Eliminación de duplicados *}&lt;br /&gt;
&lt;br /&gt;
theory R5_Eliminacion_de_duplicados&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
        &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar bowma wilmorort pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1&lt;br /&gt;
    danrodcha manmorjim1 *)&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn _ [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim, ferrenseg josgarsan juacabsou dancorgar pabrodmac *)&lt;br /&gt;
(* Igual que la anterior pero con x en lugar de _ en el caso base *)&lt;br /&gt;
&lt;br /&gt;
fun estaEn1 :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn1 x [] = False&amp;quot; &lt;br /&gt;
| &amp;quot;estaEn1 x (a#xs) = ((x=a) ∨ estaEn1 x xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn1 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn1 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
(* reutilizando  la funcion &amp;quot;algunos&amp;quot; de R4.thy*)&lt;br /&gt;
fun estaEn2  :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn2 a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn2 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn2 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función primitiva recursiva &lt;br /&gt;
     sinDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (sinDuplicados xs) se verifica si la lista xs no contiene&lt;br /&gt;
  duplicados. Por ejemplo,  &lt;br /&gt;
     sinDuplicados [1::nat,4,2]   = True&lt;br /&gt;
     sinDuplicados [1::nat,4,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar ivamenjim  wilmorort bowma pablucoto &lt;br /&gt;
    serrodcal anaprarod migtermor paupeddeg fraortmoy marpoldia1 &lt;br /&gt;
    ferrenseg josgarsan danrodcha manmorjim1 juacabsou dancorgar pabrodmac*)&lt;br /&gt;
fun sinDuplicados :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados (x#xs) = (¬ estaEn x xs ∧ sinDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2]   = True&amp;quot;&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
(* Utilizando la función ∉ de Isabelle *)&lt;br /&gt;
fun sinDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados2 [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados2 (a#xs) = ((a ∉ set xs) ∧  sinDuplicados2 xs ) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función primitiva recursiva &lt;br /&gt;
     borraDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (borraDuplicados xs) es la lista obtenida eliminando los&lt;br /&gt;
  elementos duplicados de la lista xs. Por ejemplo, &lt;br /&gt;
     borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función borraDuplicados es equivalente a la predefinida&lt;br /&gt;
  remdups.  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar wilmorort bowma pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1 ferrenseg &lt;br /&gt;
    josgarsan danrodcha juacabsou dancorgar manmorjim1 pabrodmac*)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(* Otra forma Sin usar if &lt;br /&gt;
  Utilizando case aunque se le sacaría más partido con más de 2 casos *)&lt;br /&gt;
 &lt;br /&gt;
 fun borraDuplicados1 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados1 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados1 (x#xs) = ( case estaEn x xs of False  =&amp;gt; x#borraDuplicados1 xs | True =&amp;gt; borraDuplicados1 xs )&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(*Otra forma utilizando let*)&lt;br /&gt;
fun borraDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados2 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados2 (x#xs) =  (let condicion = estaEn x xs::bool  in &lt;br /&gt;
if  condicion then borraDuplicados2 xs else x # borraDuplicados2 xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(*crigomgom anaprarod ferrenseg*)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all)&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar wilmorort pablucoto serrodcal migtermor paupeddeg &lt;br /&gt;
    fraortmoy marpoldia1 danrodcha juacabsou dancorgar josgarsan pabrodmac *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
(* soy de ponerlo mejor por pasos *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma  anaprarod *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (simp, simp)  (* creo que es mejor poner aquí simp_all *)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all (* Creo que se puede poner simp_all fuera de parentesis *)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
(* crigomgom *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;(¬ estaEn x xs)&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;... = 1 +  length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... = length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;  by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  wilmorort ferrenseg rubgonmar juacabsou dancorgar josgarsan *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* serrodcal anaprarod danrodcha *)&lt;br /&gt;
lemma length_borraDuplicados_2: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;  &lt;br /&gt;
proof(induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length [] &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; length (borraDuplicados xs) ≤ length xs &amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp &lt;br /&gt;
  also have &amp;quot;... ≤ length (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally  show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
  have c1:&amp;quot;1+length xs = length (a#xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;length(borraDuplicados (a#xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  then show &amp;quot;length(borraDuplicados (a#xs)) ≤ length (a#xs)&amp;quot; using c1 by simp&lt;br /&gt;
(* ¿Aquí porqué no puedo usar &amp;quot;finally show &amp;quot;?p (a # xs)&amp;quot; using c1 by simp? &lt;br /&gt;
   Y porque no puedo añadir &amp;quot;finally show *) &amp;quot;?p (a # xs)&amp;quot; by simp al final? *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume &amp;quot;(estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume &amp;quot;¬ (estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = 1+ length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  qed&lt;br /&gt;
then show &amp;quot;?P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg marpoldia1 pabrodmac*)&lt;br /&gt;
lemma length_borraDuplicados_4:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ length [a] + length (borraDuplicados xs) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
(* muy parecida a alguna anterior, pero yo dí mas pasos *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  proof (induct xs)&lt;br /&gt;
    show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    fix a xs&lt;br /&gt;
    assume H1: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
    have &amp;quot;length (borraDuplicados (a # xs)) ≤ length(borraDuplicados [a])+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length xs&amp;quot; using H1 by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(* crigomgom rubgonmar  wilmorort pablucoto serrodcal bowma &lt;br /&gt;
    migtermor fraortmoy marpoldia1 ferrenseg danrodcha  juacabsou paupeddeg*)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim manmorjim1 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all, blast)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados&amp;#039;: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
apply (simp_all)&lt;br /&gt;
apply blast&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp, blast)&lt;br /&gt;
done&lt;br /&gt;
 &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  Nota: Para la demostración de la equivalencia se puede usar&lt;br /&gt;
     proof (rule iffI)&lt;br /&gt;
  La regla iffI es&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix b xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (b#xs)) = estaEn a (b#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  H1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#(borraDuplicados xs))&amp;quot; using H1 by simp&lt;br /&gt;
      then have &amp;quot;a=b ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; a=b ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn b (borraDuplicados xs) = estaEn b xs&amp;quot; using HI by simp&lt;br /&gt;
      then have &amp;quot;(estaEn b xs ⟶ estaEn b (borraDuplicados xs)) ∧&lt;br /&gt;
           (¬ estaEn b xs ⟶ estaEn b (b # borraDuplicados xs))&amp;quot; by simp      &lt;br /&gt;
       then have &amp;quot;estaEn b (borraDuplicados (b#xs))&amp;quot; by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a=b` by simp&lt;br /&gt;
     next&lt;br /&gt;
      assume &amp;quot;a≠b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#xs)&amp;quot; using H2 by simp&lt;br /&gt;
      then have &amp;quot;a = b ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;False ∨ estaEn a xs &amp;quot; using `a≠b` by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a≠b` by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod marpoldia1 ferrenseg juacabsou *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2:&lt;br /&gt;
 &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
 proof (cases)&lt;br /&gt;
  assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by auto&lt;br /&gt;
 next&lt;br /&gt;
  assume &amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= (x = a ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  finally show  &amp;quot;?P (x#xs)&amp;quot; using HI by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix aa xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have P1: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume C1: &amp;quot;(estaEn aa xs)&amp;quot;&lt;br /&gt;
    have &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (borraDuplicados xs)&amp;quot; &lt;br /&gt;
             using C1 by simp&lt;br /&gt;
    also have P3: &amp;quot;… = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = estaEn a (aa#xs)&amp;quot;  &lt;br /&gt;
    proof (cases)&lt;br /&gt;
     assume &amp;quot;(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; using C1 by simp&lt;br /&gt;
    next&lt;br /&gt;
     assume &amp;quot;¬(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P3 by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume C2: &amp;quot;¬(estaEn aa xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using HI by simp&lt;br /&gt;
  qed&lt;br /&gt;
 also have Conc: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P1 by simp&lt;br /&gt;
 finally show &amp;quot;?P (aa#xs)&amp;quot; using Conc by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg *)&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume a1: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  a1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#(borraDuplicados xs))&amp;quot; using a1 by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume a2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
      then  show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume b1: &amp;quot;a≠x&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#xs)&amp;quot; using a2 by simp&lt;br /&gt;
      then have &amp;quot;x = a ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs &amp;quot; using b1  by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using b1 by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a  ( borraDuplicados xs ) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
   fix x&lt;br /&gt;
   fix xs&lt;br /&gt;
   assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
   proof (rule iffI) (* usamos proof de la regla dada iffI*)&lt;br /&gt;
     assume cprim: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   next&lt;br /&gt;
     assume cseg: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by auto&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;a≠x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using `a≠x` cseg HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* &lt;br /&gt;
Aplico la regla iffI:&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
Así:&lt;br /&gt;
 [estaEn a (borraDuplicados (x # xs)) ⟹ estaEn a (x # xs); estaEn a (x # xs) ⟹ estaEn a (borraDuplicados (x # xs))] &lt;br /&gt;
⟹ estaEn a (borraDuplicados (x # xs)) = estaEn a (x # xs)&lt;br /&gt;
*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* bowma ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?p []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix x xs&lt;br /&gt;
assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
show &amp;quot;?p (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
  assume H1:&amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; &lt;br /&gt;
    proof(cases)&lt;br /&gt;
    assume &amp;quot;x=a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; using H1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    assume &amp;quot;x≠a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  assume H2:&amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha *)&lt;br /&gt;
(* es como la de ruben pero con diferencias de estilo *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
    next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;x=a&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using H2 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.1. Demostrar o refutar automáticamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal crigomgom anaprarod fraortmoy &lt;br /&gt;
    marpoldia1 ferrenseg danrodcha juacabsou paupeddeg josgarsan *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: estaEn_borraDuplicados)&lt;br /&gt;
&lt;br /&gt;
(* migtermor bowma *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs, simp_all add: estaEn_borraDuplicados_2)&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 no caí en usar la demostración anterior y he realizado&lt;br /&gt;
  la demostración de que si un elemento no estaba en una lista seguirá sin estar&lt;br /&gt;
  después de eliminar los duplicados en esa lista... *)&lt;br /&gt;
lemma noEsta_tras_borrarDuplicados:&lt;br /&gt;
  &amp;quot;(¬estaEn x xs) ⟶ (¬estaEn x (borraDuplicados xs))&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
apply (simp add: noEsta_tras_borrarDuplicados)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.2. Demostrar o refutar detalladamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot; sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot;&lt;br /&gt;
proof (cases)&lt;br /&gt;
assume &amp;quot;estaEn a xs&amp;quot;&lt;br /&gt;
then show &amp;quot;sinDuplicados (borraDuplicados (a#xs))&amp;quot; using HI by simp&lt;br /&gt;
next&lt;br /&gt;
assume&amp;quot;¬ estaEn a xs&amp;quot;&lt;br /&gt;
then have &amp;quot;¬ (estaEn a xs) ∧ sinDuplicados (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
then have &amp;quot;¬ estaEn a (borraDuplicados xs) ∧  sinDuplicados (borraDuplicados xs)&amp;quot; &lt;br /&gt;
      by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
then have &amp;quot; sinDuplicados (a#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
then show &amp;quot; sinDuplicados (borraDuplicados(a #xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor crigomgom rubgonmar fraortmoy marpoldia1 ferrenseg bowma juacabsou serrodcal josgarsan *)&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; &lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn a xs&amp;quot; &lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;¬(estaEn a xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod paupeddeg*)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show  &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
   proof (cases)&lt;br /&gt;
   assume c1: &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
   then show &amp;quot;sinDuplicados (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
   next&lt;br /&gt;
   assume c2: &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
   then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) =sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;…= (¬estaEn x (borraDuplicados xs) ∧ sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… = (¬estaEn x (borraDuplicados xs))&amp;quot; using HI by simp&lt;br /&gt;
   also have &amp;quot;… = (¬(estaEn x xs))&amp;quot; by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
   also have &amp;quot;… = True&amp;quot; using c2 by simp&lt;br /&gt;
   finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
    case True&lt;br /&gt;
    then have 1: &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
                 = sinDuplicados (borraDuplicados xs)&amp;quot; by (simp add: estaEn_borraDuplicados_2)&lt;br /&gt;
    show &amp;quot;?P (x#xs)&amp;quot; using HI 1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    case False&lt;br /&gt;
    then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
               = sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (estaEn x (borraDuplicados xs)) ∧ &lt;br /&gt;
                  sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = True&amp;quot;  using `¬ estaEn x xs` HI by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
    finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar o refutar:&lt;br /&gt;
    borraDuplicados (rev xs) = rev (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom rubgonmar ivamenjim wilmorort pablucoto migtermor &lt;br /&gt;
   anaprarod fraortmoy ferrenseg marpoldia1 bowma danrodcha juacabsou paupeddeg manmorjim1 serrodcal josgarsan *)&lt;br /&gt;
lemma &amp;quot;borraDuplicados (rev xs) = rev (borraDuplicados xs)&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: Quickcheck encuentra el siguiente contraejemplo: &lt;br /&gt;
   xs = [a1, a2, a1]&lt;br /&gt;
   Por lo que:&lt;br /&gt;
   · &amp;quot;borraDuplicados (rev xs) = [a2, a1]&amp;quot;&lt;br /&gt;
   · &amp;quot;rev (borraDuplicados xs) = [a1, a2]&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=820</id>
		<title>Relación 5</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=820"/>
		<updated>2016-11-30T11:12:22Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R5: Eliminación de duplicados *}&lt;br /&gt;
&lt;br /&gt;
theory R5_Eliminacion_de_duplicados&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
        &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar bowma wilmorort pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1&lt;br /&gt;
    danrodcha manmorjim1 *)&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn _ [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim, ferrenseg josgarsan juacabsou dancorgar pabrodmac *)&lt;br /&gt;
(* Igual que la anterior pero con x en lugar de _ en el caso base *)&lt;br /&gt;
&lt;br /&gt;
fun estaEn1 :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn1 x [] = False&amp;quot; &lt;br /&gt;
| &amp;quot;estaEn1 x (a#xs) = ((x=a) ∨ estaEn1 x xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn1 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn1 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
(* reutilizando  la funcion &amp;quot;algunos&amp;quot; de R4.thy*)&lt;br /&gt;
fun estaEn2  :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn2 a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn2 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn2 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función primitiva recursiva &lt;br /&gt;
     sinDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (sinDuplicados xs) se verifica si la lista xs no contiene&lt;br /&gt;
  duplicados. Por ejemplo,  &lt;br /&gt;
     sinDuplicados [1::nat,4,2]   = True&lt;br /&gt;
     sinDuplicados [1::nat,4,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar ivamenjim  wilmorort bowma pablucoto &lt;br /&gt;
    serrodcal anaprarod migtermor paupeddeg fraortmoy marpoldia1 &lt;br /&gt;
    ferrenseg josgarsan danrodcha manmorjim1 juacabsou dancorgar pabrodmac*)&lt;br /&gt;
fun sinDuplicados :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados (x#xs) = (¬ estaEn x xs ∧ sinDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2]   = True&amp;quot;&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
(* Utilizando la función ∉ de Isabelle *)&lt;br /&gt;
fun sinDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados2 [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados2 (a#xs) = ((a ∉ set xs) ∧  sinDuplicados2 xs ) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función primitiva recursiva &lt;br /&gt;
     borraDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (borraDuplicados xs) es la lista obtenida eliminando los&lt;br /&gt;
  elementos duplicados de la lista xs. Por ejemplo, &lt;br /&gt;
     borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función borraDuplicados es equivalente a la predefinida&lt;br /&gt;
  remdups.  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar wilmorort bowma pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1 ferrenseg &lt;br /&gt;
    josgarsan danrodcha juacabsou dancorgar manmorjim1 pabrodmac*)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(* Otra forma Sin usar if &lt;br /&gt;
  Utilizando case aunque se le sacaría más partido con más de 2 casos *)&lt;br /&gt;
 &lt;br /&gt;
 fun borraDuplicados1 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados1 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados1 (x#xs) = ( case estaEn x xs of False  =&amp;gt; x#borraDuplicados1 xs | True =&amp;gt; borraDuplicados1 xs )&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(*Otra forma utilizando let*)&lt;br /&gt;
fun borraDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados2 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados2 (x#xs) =  (let condicion = estaEn x xs::bool  in &lt;br /&gt;
if  condicion then borraDuplicados2 xs else x # borraDuplicados2 xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(*crigomgom anaprarod ferrenseg*)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all)&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar wilmorort pablucoto serrodcal migtermor paupeddeg &lt;br /&gt;
    fraortmoy marpoldia1 danrodcha juacabsou dancorgar josgarsan pabrodmac *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
(* soy de ponerlo mejor por pasos *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma  anaprarod *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (simp, simp)  (* creo que es mejor poner aquí simp_all *)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all (* Creo que se puede poner simp_all fuera de parentesis *)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
(* crigomgom *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;(¬ estaEn x xs)&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;... = 1 +  length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... = length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;  by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  wilmorort ferrenseg rubgonmar juacabsou dancorgar josgarsan *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* serrodcal anaprarod danrodcha *)&lt;br /&gt;
lemma length_borraDuplicados_2: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;  &lt;br /&gt;
proof(induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length [] &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; length (borraDuplicados xs) ≤ length xs &amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp &lt;br /&gt;
  also have &amp;quot;... ≤ length (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally  show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
  have c1:&amp;quot;1+length xs = length (a#xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;length(borraDuplicados (a#xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  then show &amp;quot;length(borraDuplicados (a#xs)) ≤ length (a#xs)&amp;quot; using c1 by simp&lt;br /&gt;
(* ¿Aquí porqué no puedo usar &amp;quot;finally show &amp;quot;?p (a # xs)&amp;quot; using c1 by simp? &lt;br /&gt;
   Y porque no puedo añadir &amp;quot;finally show *) &amp;quot;?p (a # xs)&amp;quot; by simp al final? *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume &amp;quot;(estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume &amp;quot;¬ (estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = 1+ length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  qed&lt;br /&gt;
then show &amp;quot;?P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg marpoldia1*)&lt;br /&gt;
lemma length_borraDuplicados_4:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ length [a] + length (borraDuplicados xs) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
(* muy parecida a alguna anterior, pero yo dí mas pasos *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  proof (induct xs)&lt;br /&gt;
    show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    fix a xs&lt;br /&gt;
    assume H1: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
    have &amp;quot;length (borraDuplicados (a # xs)) ≤ length(borraDuplicados [a])+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length xs&amp;quot; using H1 by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(* crigomgom rubgonmar  wilmorort pablucoto serrodcal bowma &lt;br /&gt;
    migtermor fraortmoy marpoldia1 ferrenseg danrodcha  juacabsou paupeddeg*)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim manmorjim1 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all, blast)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados&amp;#039;: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
apply (simp_all)&lt;br /&gt;
apply blast&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp, blast)&lt;br /&gt;
done&lt;br /&gt;
 &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  Nota: Para la demostración de la equivalencia se puede usar&lt;br /&gt;
     proof (rule iffI)&lt;br /&gt;
  La regla iffI es&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix b xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (b#xs)) = estaEn a (b#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  H1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#(borraDuplicados xs))&amp;quot; using H1 by simp&lt;br /&gt;
      then have &amp;quot;a=b ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; a=b ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn b (borraDuplicados xs) = estaEn b xs&amp;quot; using HI by simp&lt;br /&gt;
      then have &amp;quot;(estaEn b xs ⟶ estaEn b (borraDuplicados xs)) ∧&lt;br /&gt;
           (¬ estaEn b xs ⟶ estaEn b (b # borraDuplicados xs))&amp;quot; by simp      &lt;br /&gt;
       then have &amp;quot;estaEn b (borraDuplicados (b#xs))&amp;quot; by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a=b` by simp&lt;br /&gt;
     next&lt;br /&gt;
      assume &amp;quot;a≠b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#xs)&amp;quot; using H2 by simp&lt;br /&gt;
      then have &amp;quot;a = b ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;False ∨ estaEn a xs &amp;quot; using `a≠b` by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a≠b` by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod marpoldia1 ferrenseg juacabsou *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2:&lt;br /&gt;
 &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
 proof (cases)&lt;br /&gt;
  assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by auto&lt;br /&gt;
 next&lt;br /&gt;
  assume &amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= (x = a ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  finally show  &amp;quot;?P (x#xs)&amp;quot; using HI by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix aa xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have P1: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume C1: &amp;quot;(estaEn aa xs)&amp;quot;&lt;br /&gt;
    have &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (borraDuplicados xs)&amp;quot; &lt;br /&gt;
             using C1 by simp&lt;br /&gt;
    also have P3: &amp;quot;… = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = estaEn a (aa#xs)&amp;quot;  &lt;br /&gt;
    proof (cases)&lt;br /&gt;
     assume &amp;quot;(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; using C1 by simp&lt;br /&gt;
    next&lt;br /&gt;
     assume &amp;quot;¬(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P3 by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume C2: &amp;quot;¬(estaEn aa xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using HI by simp&lt;br /&gt;
  qed&lt;br /&gt;
 also have Conc: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P1 by simp&lt;br /&gt;
 finally show &amp;quot;?P (aa#xs)&amp;quot; using Conc by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg *)&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume a1: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  a1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#(borraDuplicados xs))&amp;quot; using a1 by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume a2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
      then  show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume b1: &amp;quot;a≠x&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#xs)&amp;quot; using a2 by simp&lt;br /&gt;
      then have &amp;quot;x = a ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs &amp;quot; using b1  by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using b1 by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a  ( borraDuplicados xs ) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
   fix x&lt;br /&gt;
   fix xs&lt;br /&gt;
   assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
   proof (rule iffI) (* usamos proof de la regla dada iffI*)&lt;br /&gt;
     assume cprim: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   next&lt;br /&gt;
     assume cseg: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by auto&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;a≠x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using `a≠x` cseg HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* &lt;br /&gt;
Aplico la regla iffI:&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
Así:&lt;br /&gt;
 [estaEn a (borraDuplicados (x # xs)) ⟹ estaEn a (x # xs); estaEn a (x # xs) ⟹ estaEn a (borraDuplicados (x # xs))] &lt;br /&gt;
⟹ estaEn a (borraDuplicados (x # xs)) = estaEn a (x # xs)&lt;br /&gt;
*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* bowma ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?p []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix x xs&lt;br /&gt;
assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
show &amp;quot;?p (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
  assume H1:&amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; &lt;br /&gt;
    proof(cases)&lt;br /&gt;
    assume &amp;quot;x=a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; using H1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    assume &amp;quot;x≠a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  assume H2:&amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha *)&lt;br /&gt;
(* es como la de ruben pero con diferencias de estilo *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
    next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;x=a&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using H2 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.1. Demostrar o refutar automáticamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal crigomgom anaprarod fraortmoy &lt;br /&gt;
    marpoldia1 ferrenseg danrodcha juacabsou paupeddeg josgarsan *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: estaEn_borraDuplicados)&lt;br /&gt;
&lt;br /&gt;
(* migtermor bowma *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs, simp_all add: estaEn_borraDuplicados_2)&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 no caí en usar la demostración anterior y he realizado&lt;br /&gt;
  la demostración de que si un elemento no estaba en una lista seguirá sin estar&lt;br /&gt;
  después de eliminar los duplicados en esa lista... *)&lt;br /&gt;
lemma noEsta_tras_borrarDuplicados:&lt;br /&gt;
  &amp;quot;(¬estaEn x xs) ⟶ (¬estaEn x (borraDuplicados xs))&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
apply (simp add: noEsta_tras_borrarDuplicados)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.2. Demostrar o refutar detalladamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot; sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot;&lt;br /&gt;
proof (cases)&lt;br /&gt;
assume &amp;quot;estaEn a xs&amp;quot;&lt;br /&gt;
then show &amp;quot;sinDuplicados (borraDuplicados (a#xs))&amp;quot; using HI by simp&lt;br /&gt;
next&lt;br /&gt;
assume&amp;quot;¬ estaEn a xs&amp;quot;&lt;br /&gt;
then have &amp;quot;¬ (estaEn a xs) ∧ sinDuplicados (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
then have &amp;quot;¬ estaEn a (borraDuplicados xs) ∧  sinDuplicados (borraDuplicados xs)&amp;quot; &lt;br /&gt;
      by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
then have &amp;quot; sinDuplicados (a#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
then show &amp;quot; sinDuplicados (borraDuplicados(a #xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor crigomgom rubgonmar fraortmoy marpoldia1 ferrenseg bowma juacabsou serrodcal josgarsan *)&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; &lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn a xs&amp;quot; &lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;¬(estaEn a xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod paupeddeg*)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show  &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
   proof (cases)&lt;br /&gt;
   assume c1: &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
   then show &amp;quot;sinDuplicados (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
   next&lt;br /&gt;
   assume c2: &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
   then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) =sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;…= (¬estaEn x (borraDuplicados xs) ∧ sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… = (¬estaEn x (borraDuplicados xs))&amp;quot; using HI by simp&lt;br /&gt;
   also have &amp;quot;… = (¬(estaEn x xs))&amp;quot; by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
   also have &amp;quot;… = True&amp;quot; using c2 by simp&lt;br /&gt;
   finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
    case True&lt;br /&gt;
    then have 1: &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
                 = sinDuplicados (borraDuplicados xs)&amp;quot; by (simp add: estaEn_borraDuplicados_2)&lt;br /&gt;
    show &amp;quot;?P (x#xs)&amp;quot; using HI 1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    case False&lt;br /&gt;
    then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
               = sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (estaEn x (borraDuplicados xs)) ∧ &lt;br /&gt;
                  sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = True&amp;quot;  using `¬ estaEn x xs` HI by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
    finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar o refutar:&lt;br /&gt;
    borraDuplicados (rev xs) = rev (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom rubgonmar ivamenjim wilmorort pablucoto migtermor &lt;br /&gt;
   anaprarod fraortmoy ferrenseg marpoldia1 bowma danrodcha juacabsou paupeddeg manmorjim1 serrodcal josgarsan *)&lt;br /&gt;
lemma &amp;quot;borraDuplicados (rev xs) = rev (borraDuplicados xs)&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: Quickcheck encuentra el siguiente contraejemplo: &lt;br /&gt;
   xs = [a1, a2, a1]&lt;br /&gt;
   Por lo que:&lt;br /&gt;
   · &amp;quot;borraDuplicados (rev xs) = [a2, a1]&amp;quot;&lt;br /&gt;
   · &amp;quot;rev (borraDuplicados xs) = [a1, a2]&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=819</id>
		<title>Relación 5</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=819"/>
		<updated>2016-11-30T11:11:14Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R5: Eliminación de duplicados *}&lt;br /&gt;
&lt;br /&gt;
theory R5_Eliminacion_de_duplicados&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
        &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar bowma wilmorort pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1&lt;br /&gt;
    danrodcha manmorjim1 *)&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn _ [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim, ferrenseg josgarsan juacabsou dancorgar pabrodmac *)&lt;br /&gt;
(* Igual que la anterior pero con x en lugar de _ en el caso base *)&lt;br /&gt;
&lt;br /&gt;
fun estaEn1 :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn1 x [] = False&amp;quot; &lt;br /&gt;
| &amp;quot;estaEn1 x (a#xs) = ((x=a) ∨ estaEn1 x xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn1 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn1 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
(* reutilizando  la funcion &amp;quot;algunos&amp;quot; de R4.thy*)&lt;br /&gt;
fun estaEn2  :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn2 a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn2 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn2 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función primitiva recursiva &lt;br /&gt;
     sinDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (sinDuplicados xs) se verifica si la lista xs no contiene&lt;br /&gt;
  duplicados. Por ejemplo,  &lt;br /&gt;
     sinDuplicados [1::nat,4,2]   = True&lt;br /&gt;
     sinDuplicados [1::nat,4,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar ivamenjim  wilmorort bowma pablucoto &lt;br /&gt;
    serrodcal anaprarod migtermor paupeddeg fraortmoy marpoldia1 &lt;br /&gt;
    ferrenseg josgarsan danrodcha manmorjim1 juacabsou dancorgar pabrodmac*)&lt;br /&gt;
fun sinDuplicados :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados (x#xs) = (¬ estaEn x xs ∧ sinDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2]   = True&amp;quot;&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
(* Utilizando la función ∉ de Isabelle *)&lt;br /&gt;
fun sinDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados2 [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados2 (a#xs) = ((a ∉ set xs) ∧  sinDuplicados2 xs ) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función primitiva recursiva &lt;br /&gt;
     borraDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (borraDuplicados xs) es la lista obtenida eliminando los&lt;br /&gt;
  elementos duplicados de la lista xs. Por ejemplo, &lt;br /&gt;
     borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función borraDuplicados es equivalente a la predefinida&lt;br /&gt;
  remdups.  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar wilmorort bowma pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1 ferrenseg &lt;br /&gt;
    josgarsan danrodcha juacabsou dancorgar manmorjim1 pabrodmac*)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(* Otra forma Sin usar if &lt;br /&gt;
  Utilizando case aunque se le sacaría más partido con más de 2 casos *)&lt;br /&gt;
 &lt;br /&gt;
 fun borraDuplicados1 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados1 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados1 (x#xs) = ( case estaEn x xs of False  =&amp;gt; x#borraDuplicados1 xs | True =&amp;gt; borraDuplicados1 xs )&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(*Otra forma utilizando let*)&lt;br /&gt;
fun borraDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados2 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados2 (x#xs) =  (let condicion = estaEn x xs::bool  in &lt;br /&gt;
if  condicion then borraDuplicados2 xs else x # borraDuplicados2 xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(*crigomgom anaprarod ferrenseg*)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all)&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar wilmorort pablucoto serrodcal migtermor paupeddeg &lt;br /&gt;
    fraortmoy marpoldia1 danrodcha juacabsou dancorgar josgarsan *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
(* soy de ponerlo mejor por pasos *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma  anaprarod *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (simp, simp)  (* creo que es mejor poner aquí simp_all *)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all (* Creo que se puede poner simp_all fuera de parentesis *)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
(* crigomgom *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;(¬ estaEn x xs)&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;... = 1 +  length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... = length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;  by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  wilmorort ferrenseg rubgonmar juacabsou dancorgar josgarsan *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* serrodcal anaprarod danrodcha *)&lt;br /&gt;
lemma length_borraDuplicados_2: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;  &lt;br /&gt;
proof(induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length [] &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; length (borraDuplicados xs) ≤ length xs &amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp &lt;br /&gt;
  also have &amp;quot;... ≤ length (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally  show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
  have c1:&amp;quot;1+length xs = length (a#xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;length(borraDuplicados (a#xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  then show &amp;quot;length(borraDuplicados (a#xs)) ≤ length (a#xs)&amp;quot; using c1 by simp&lt;br /&gt;
(* ¿Aquí porqué no puedo usar &amp;quot;finally show &amp;quot;?p (a # xs)&amp;quot; using c1 by simp? &lt;br /&gt;
   Y porque no puedo añadir &amp;quot;finally show *) &amp;quot;?p (a # xs)&amp;quot; by simp al final? *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume &amp;quot;(estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume &amp;quot;¬ (estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = 1+ length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  qed&lt;br /&gt;
then show &amp;quot;?P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg marpoldia1*)&lt;br /&gt;
lemma length_borraDuplicados_4:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ length [a] + length (borraDuplicados xs) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
(* muy parecida a alguna anterior, pero yo dí mas pasos *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  proof (induct xs)&lt;br /&gt;
    show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    fix a xs&lt;br /&gt;
    assume H1: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
    have &amp;quot;length (borraDuplicados (a # xs)) ≤ length(borraDuplicados [a])+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length xs&amp;quot; using H1 by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(* crigomgom rubgonmar  wilmorort pablucoto serrodcal bowma &lt;br /&gt;
    migtermor fraortmoy marpoldia1 ferrenseg danrodcha  juacabsou paupeddeg*)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim manmorjim1 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all, blast)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados&amp;#039;: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
apply (simp_all)&lt;br /&gt;
apply blast&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp, blast)&lt;br /&gt;
done&lt;br /&gt;
 &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  Nota: Para la demostración de la equivalencia se puede usar&lt;br /&gt;
     proof (rule iffI)&lt;br /&gt;
  La regla iffI es&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix b xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (b#xs)) = estaEn a (b#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  H1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#(borraDuplicados xs))&amp;quot; using H1 by simp&lt;br /&gt;
      then have &amp;quot;a=b ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; a=b ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn b (borraDuplicados xs) = estaEn b xs&amp;quot; using HI by simp&lt;br /&gt;
      then have &amp;quot;(estaEn b xs ⟶ estaEn b (borraDuplicados xs)) ∧&lt;br /&gt;
           (¬ estaEn b xs ⟶ estaEn b (b # borraDuplicados xs))&amp;quot; by simp      &lt;br /&gt;
       then have &amp;quot;estaEn b (borraDuplicados (b#xs))&amp;quot; by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a=b` by simp&lt;br /&gt;
     next&lt;br /&gt;
      assume &amp;quot;a≠b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#xs)&amp;quot; using H2 by simp&lt;br /&gt;
      then have &amp;quot;a = b ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;False ∨ estaEn a xs &amp;quot; using `a≠b` by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a≠b` by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod marpoldia1 ferrenseg juacabsou *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2:&lt;br /&gt;
 &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
 proof (cases)&lt;br /&gt;
  assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by auto&lt;br /&gt;
 next&lt;br /&gt;
  assume &amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= (x = a ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  finally show  &amp;quot;?P (x#xs)&amp;quot; using HI by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix aa xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have P1: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume C1: &amp;quot;(estaEn aa xs)&amp;quot;&lt;br /&gt;
    have &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (borraDuplicados xs)&amp;quot; &lt;br /&gt;
             using C1 by simp&lt;br /&gt;
    also have P3: &amp;quot;… = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = estaEn a (aa#xs)&amp;quot;  &lt;br /&gt;
    proof (cases)&lt;br /&gt;
     assume &amp;quot;(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; using C1 by simp&lt;br /&gt;
    next&lt;br /&gt;
     assume &amp;quot;¬(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P3 by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume C2: &amp;quot;¬(estaEn aa xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using HI by simp&lt;br /&gt;
  qed&lt;br /&gt;
 also have Conc: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P1 by simp&lt;br /&gt;
 finally show &amp;quot;?P (aa#xs)&amp;quot; using Conc by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg *)&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume a1: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  a1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#(borraDuplicados xs))&amp;quot; using a1 by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume a2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
      then  show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume b1: &amp;quot;a≠x&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#xs)&amp;quot; using a2 by simp&lt;br /&gt;
      then have &amp;quot;x = a ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs &amp;quot; using b1  by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using b1 by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a  ( borraDuplicados xs ) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
   fix x&lt;br /&gt;
   fix xs&lt;br /&gt;
   assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
   proof (rule iffI) (* usamos proof de la regla dada iffI*)&lt;br /&gt;
     assume cprim: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   next&lt;br /&gt;
     assume cseg: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by auto&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;a≠x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using `a≠x` cseg HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* &lt;br /&gt;
Aplico la regla iffI:&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
Así:&lt;br /&gt;
 [estaEn a (borraDuplicados (x # xs)) ⟹ estaEn a (x # xs); estaEn a (x # xs) ⟹ estaEn a (borraDuplicados (x # xs))] &lt;br /&gt;
⟹ estaEn a (borraDuplicados (x # xs)) = estaEn a (x # xs)&lt;br /&gt;
*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* bowma ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?p []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix x xs&lt;br /&gt;
assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
show &amp;quot;?p (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
  assume H1:&amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; &lt;br /&gt;
    proof(cases)&lt;br /&gt;
    assume &amp;quot;x=a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; using H1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    assume &amp;quot;x≠a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  assume H2:&amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha *)&lt;br /&gt;
(* es como la de ruben pero con diferencias de estilo *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
    next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;x=a&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using H2 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.1. Demostrar o refutar automáticamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal crigomgom anaprarod fraortmoy &lt;br /&gt;
    marpoldia1 ferrenseg danrodcha juacabsou paupeddeg josgarsan *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: estaEn_borraDuplicados)&lt;br /&gt;
&lt;br /&gt;
(* migtermor bowma *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs, simp_all add: estaEn_borraDuplicados_2)&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 no caí en usar la demostración anterior y he realizado&lt;br /&gt;
  la demostración de que si un elemento no estaba en una lista seguirá sin estar&lt;br /&gt;
  después de eliminar los duplicados en esa lista... *)&lt;br /&gt;
lemma noEsta_tras_borrarDuplicados:&lt;br /&gt;
  &amp;quot;(¬estaEn x xs) ⟶ (¬estaEn x (borraDuplicados xs))&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
apply (simp add: noEsta_tras_borrarDuplicados)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.2. Demostrar o refutar detalladamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot; sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot;&lt;br /&gt;
proof (cases)&lt;br /&gt;
assume &amp;quot;estaEn a xs&amp;quot;&lt;br /&gt;
then show &amp;quot;sinDuplicados (borraDuplicados (a#xs))&amp;quot; using HI by simp&lt;br /&gt;
next&lt;br /&gt;
assume&amp;quot;¬ estaEn a xs&amp;quot;&lt;br /&gt;
then have &amp;quot;¬ (estaEn a xs) ∧ sinDuplicados (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
then have &amp;quot;¬ estaEn a (borraDuplicados xs) ∧  sinDuplicados (borraDuplicados xs)&amp;quot; &lt;br /&gt;
      by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
then have &amp;quot; sinDuplicados (a#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
then show &amp;quot; sinDuplicados (borraDuplicados(a #xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor crigomgom rubgonmar fraortmoy marpoldia1 ferrenseg bowma juacabsou serrodcal josgarsan *)&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; &lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn a xs&amp;quot; &lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;¬(estaEn a xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod paupeddeg*)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show  &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
   proof (cases)&lt;br /&gt;
   assume c1: &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
   then show &amp;quot;sinDuplicados (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
   next&lt;br /&gt;
   assume c2: &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
   then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) =sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;…= (¬estaEn x (borraDuplicados xs) ∧ sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… = (¬estaEn x (borraDuplicados xs))&amp;quot; using HI by simp&lt;br /&gt;
   also have &amp;quot;… = (¬(estaEn x xs))&amp;quot; by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
   also have &amp;quot;… = True&amp;quot; using c2 by simp&lt;br /&gt;
   finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
    case True&lt;br /&gt;
    then have 1: &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
                 = sinDuplicados (borraDuplicados xs)&amp;quot; by (simp add: estaEn_borraDuplicados_2)&lt;br /&gt;
    show &amp;quot;?P (x#xs)&amp;quot; using HI 1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    case False&lt;br /&gt;
    then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
               = sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (estaEn x (borraDuplicados xs)) ∧ &lt;br /&gt;
                  sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = True&amp;quot;  using `¬ estaEn x xs` HI by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
    finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar o refutar:&lt;br /&gt;
    borraDuplicados (rev xs) = rev (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom rubgonmar ivamenjim wilmorort pablucoto migtermor &lt;br /&gt;
   anaprarod fraortmoy ferrenseg marpoldia1 bowma danrodcha juacabsou paupeddeg manmorjim1 serrodcal josgarsan *)&lt;br /&gt;
lemma &amp;quot;borraDuplicados (rev xs) = rev (borraDuplicados xs)&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: Quickcheck encuentra el siguiente contraejemplo: &lt;br /&gt;
   xs = [a1, a2, a1]&lt;br /&gt;
   Por lo que:&lt;br /&gt;
   · &amp;quot;borraDuplicados (rev xs) = [a2, a1]&amp;quot;&lt;br /&gt;
   · &amp;quot;rev (borraDuplicados xs) = [a1, a2]&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=818</id>
		<title>Relación 5</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=818"/>
		<updated>2016-11-30T11:10:28Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R5: Eliminación de duplicados *}&lt;br /&gt;
&lt;br /&gt;
theory R5_Eliminacion_de_duplicados&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
        &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar bowma wilmorort pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1&lt;br /&gt;
    danrodcha manmorjim1 *)&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn _ [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim, ferrenseg josgarsan juacabsou dancorgar pabrodmac *)&lt;br /&gt;
(* Igual que la anterior pero con x en lugar de _ en el caso base *)&lt;br /&gt;
&lt;br /&gt;
fun estaEn1 :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn1 x [] = False&amp;quot; &lt;br /&gt;
| &amp;quot;estaEn1 x (a#xs) = ((x=a) ∨ estaEn1 x xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn1 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn1 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
(* reutilizando  la funcion &amp;quot;algunos&amp;quot; de R4.thy*)&lt;br /&gt;
fun estaEn2  :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn2 a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn2 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn2 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función primitiva recursiva &lt;br /&gt;
     sinDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (sinDuplicados xs) se verifica si la lista xs no contiene&lt;br /&gt;
  duplicados. Por ejemplo,  &lt;br /&gt;
     sinDuplicados [1::nat,4,2]   = True&lt;br /&gt;
     sinDuplicados [1::nat,4,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar ivamenjim  wilmorort bowma pablucoto &lt;br /&gt;
    serrodcal anaprarod migtermor paupeddeg fraortmoy marpoldia1 &lt;br /&gt;
    ferrenseg josgarsan danrodcha manmorjim1 juacabsou dancorgar pabrodmac*)&lt;br /&gt;
fun sinDuplicados :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados (x#xs) = (¬ estaEn x xs ∧ sinDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2]   = True&amp;quot;&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
(* Utilizando la función ∉ de Isabelle *)&lt;br /&gt;
fun sinDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados2 [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados2 (a#xs) = ((a ∉ set xs) ∧  sinDuplicados2 xs ) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función primitiva recursiva &lt;br /&gt;
     borraDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (borraDuplicados xs) es la lista obtenida eliminando los&lt;br /&gt;
  elementos duplicados de la lista xs. Por ejemplo, &lt;br /&gt;
     borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función borraDuplicados es equivalente a la predefinida&lt;br /&gt;
  remdups.  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar wilmorort bowma pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1 ferrenseg &lt;br /&gt;
    josgarsan danrodcha juacabsou dancorgar manmorjim1 *)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(* Otra forma Sin usar if &lt;br /&gt;
  Utilizando case aunque se le sacaría más partido con más de 2 casos *)&lt;br /&gt;
 &lt;br /&gt;
 fun borraDuplicados1 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados1 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados1 (x#xs) = ( case estaEn x xs of False  =&amp;gt; x#borraDuplicados1 xs | True =&amp;gt; borraDuplicados1 xs )&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(*Otra forma utilizando let*)&lt;br /&gt;
fun borraDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados2 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados2 (x#xs) =  (let condicion = estaEn x xs::bool  in &lt;br /&gt;
if  condicion then borraDuplicados2 xs else x # borraDuplicados2 xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(*crigomgom anaprarod ferrenseg*)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all)&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar wilmorort pablucoto serrodcal migtermor paupeddeg &lt;br /&gt;
    fraortmoy marpoldia1 danrodcha juacabsou dancorgar josgarsan *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
(* soy de ponerlo mejor por pasos *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma  anaprarod *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (simp, simp)  (* creo que es mejor poner aquí simp_all *)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all (* Creo que se puede poner simp_all fuera de parentesis *)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
(* crigomgom *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;(¬ estaEn x xs)&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;... = 1 +  length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... = length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;  by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  wilmorort ferrenseg rubgonmar juacabsou dancorgar josgarsan *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* serrodcal anaprarod danrodcha *)&lt;br /&gt;
lemma length_borraDuplicados_2: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;  &lt;br /&gt;
proof(induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length [] &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; length (borraDuplicados xs) ≤ length xs &amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp &lt;br /&gt;
  also have &amp;quot;... ≤ length (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally  show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
  have c1:&amp;quot;1+length xs = length (a#xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;length(borraDuplicados (a#xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  then show &amp;quot;length(borraDuplicados (a#xs)) ≤ length (a#xs)&amp;quot; using c1 by simp&lt;br /&gt;
(* ¿Aquí porqué no puedo usar &amp;quot;finally show &amp;quot;?p (a # xs)&amp;quot; using c1 by simp? &lt;br /&gt;
   Y porque no puedo añadir &amp;quot;finally show *) &amp;quot;?p (a # xs)&amp;quot; by simp al final? *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume &amp;quot;(estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume &amp;quot;¬ (estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = 1+ length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  qed&lt;br /&gt;
then show &amp;quot;?P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg marpoldia1*)&lt;br /&gt;
lemma length_borraDuplicados_4:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ length [a] + length (borraDuplicados xs) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
(* muy parecida a alguna anterior, pero yo dí mas pasos *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  proof (induct xs)&lt;br /&gt;
    show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    fix a xs&lt;br /&gt;
    assume H1: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
    have &amp;quot;length (borraDuplicados (a # xs)) ≤ length(borraDuplicados [a])+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length xs&amp;quot; using H1 by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(* crigomgom rubgonmar  wilmorort pablucoto serrodcal bowma &lt;br /&gt;
    migtermor fraortmoy marpoldia1 ferrenseg danrodcha  juacabsou paupeddeg*)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim manmorjim1 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all, blast)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados&amp;#039;: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
apply (simp_all)&lt;br /&gt;
apply blast&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp, blast)&lt;br /&gt;
done&lt;br /&gt;
 &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  Nota: Para la demostración de la equivalencia se puede usar&lt;br /&gt;
     proof (rule iffI)&lt;br /&gt;
  La regla iffI es&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix b xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (b#xs)) = estaEn a (b#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  H1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#(borraDuplicados xs))&amp;quot; using H1 by simp&lt;br /&gt;
      then have &amp;quot;a=b ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; a=b ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn b (borraDuplicados xs) = estaEn b xs&amp;quot; using HI by simp&lt;br /&gt;
      then have &amp;quot;(estaEn b xs ⟶ estaEn b (borraDuplicados xs)) ∧&lt;br /&gt;
           (¬ estaEn b xs ⟶ estaEn b (b # borraDuplicados xs))&amp;quot; by simp      &lt;br /&gt;
       then have &amp;quot;estaEn b (borraDuplicados (b#xs))&amp;quot; by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a=b` by simp&lt;br /&gt;
     next&lt;br /&gt;
      assume &amp;quot;a≠b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#xs)&amp;quot; using H2 by simp&lt;br /&gt;
      then have &amp;quot;a = b ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;False ∨ estaEn a xs &amp;quot; using `a≠b` by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a≠b` by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod marpoldia1 ferrenseg juacabsou *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2:&lt;br /&gt;
 &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
 proof (cases)&lt;br /&gt;
  assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by auto&lt;br /&gt;
 next&lt;br /&gt;
  assume &amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= (x = a ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  finally show  &amp;quot;?P (x#xs)&amp;quot; using HI by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix aa xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have P1: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume C1: &amp;quot;(estaEn aa xs)&amp;quot;&lt;br /&gt;
    have &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (borraDuplicados xs)&amp;quot; &lt;br /&gt;
             using C1 by simp&lt;br /&gt;
    also have P3: &amp;quot;… = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = estaEn a (aa#xs)&amp;quot;  &lt;br /&gt;
    proof (cases)&lt;br /&gt;
     assume &amp;quot;(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; using C1 by simp&lt;br /&gt;
    next&lt;br /&gt;
     assume &amp;quot;¬(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P3 by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume C2: &amp;quot;¬(estaEn aa xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using HI by simp&lt;br /&gt;
  qed&lt;br /&gt;
 also have Conc: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P1 by simp&lt;br /&gt;
 finally show &amp;quot;?P (aa#xs)&amp;quot; using Conc by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg *)&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume a1: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  a1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#(borraDuplicados xs))&amp;quot; using a1 by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume a2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
      then  show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume b1: &amp;quot;a≠x&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#xs)&amp;quot; using a2 by simp&lt;br /&gt;
      then have &amp;quot;x = a ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs &amp;quot; using b1  by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using b1 by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a  ( borraDuplicados xs ) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
   fix x&lt;br /&gt;
   fix xs&lt;br /&gt;
   assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
   proof (rule iffI) (* usamos proof de la regla dada iffI*)&lt;br /&gt;
     assume cprim: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   next&lt;br /&gt;
     assume cseg: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by auto&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;a≠x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using `a≠x` cseg HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* &lt;br /&gt;
Aplico la regla iffI:&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
Así:&lt;br /&gt;
 [estaEn a (borraDuplicados (x # xs)) ⟹ estaEn a (x # xs); estaEn a (x # xs) ⟹ estaEn a (borraDuplicados (x # xs))] &lt;br /&gt;
⟹ estaEn a (borraDuplicados (x # xs)) = estaEn a (x # xs)&lt;br /&gt;
*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* bowma ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?p []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix x xs&lt;br /&gt;
assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
show &amp;quot;?p (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
  assume H1:&amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; &lt;br /&gt;
    proof(cases)&lt;br /&gt;
    assume &amp;quot;x=a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; using H1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    assume &amp;quot;x≠a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  assume H2:&amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha *)&lt;br /&gt;
(* es como la de ruben pero con diferencias de estilo *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
    next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;x=a&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using H2 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.1. Demostrar o refutar automáticamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal crigomgom anaprarod fraortmoy &lt;br /&gt;
    marpoldia1 ferrenseg danrodcha juacabsou paupeddeg josgarsan *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: estaEn_borraDuplicados)&lt;br /&gt;
&lt;br /&gt;
(* migtermor bowma *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs, simp_all add: estaEn_borraDuplicados_2)&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 no caí en usar la demostración anterior y he realizado&lt;br /&gt;
  la demostración de que si un elemento no estaba en una lista seguirá sin estar&lt;br /&gt;
  después de eliminar los duplicados en esa lista... *)&lt;br /&gt;
lemma noEsta_tras_borrarDuplicados:&lt;br /&gt;
  &amp;quot;(¬estaEn x xs) ⟶ (¬estaEn x (borraDuplicados xs))&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
apply (simp add: noEsta_tras_borrarDuplicados)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.2. Demostrar o refutar detalladamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot; sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot;&lt;br /&gt;
proof (cases)&lt;br /&gt;
assume &amp;quot;estaEn a xs&amp;quot;&lt;br /&gt;
then show &amp;quot;sinDuplicados (borraDuplicados (a#xs))&amp;quot; using HI by simp&lt;br /&gt;
next&lt;br /&gt;
assume&amp;quot;¬ estaEn a xs&amp;quot;&lt;br /&gt;
then have &amp;quot;¬ (estaEn a xs) ∧ sinDuplicados (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
then have &amp;quot;¬ estaEn a (borraDuplicados xs) ∧  sinDuplicados (borraDuplicados xs)&amp;quot; &lt;br /&gt;
      by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
then have &amp;quot; sinDuplicados (a#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
then show &amp;quot; sinDuplicados (borraDuplicados(a #xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor crigomgom rubgonmar fraortmoy marpoldia1 ferrenseg bowma juacabsou serrodcal josgarsan *)&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; &lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn a xs&amp;quot; &lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;¬(estaEn a xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod paupeddeg*)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show  &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
   proof (cases)&lt;br /&gt;
   assume c1: &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
   then show &amp;quot;sinDuplicados (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
   next&lt;br /&gt;
   assume c2: &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
   then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) =sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;…= (¬estaEn x (borraDuplicados xs) ∧ sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… = (¬estaEn x (borraDuplicados xs))&amp;quot; using HI by simp&lt;br /&gt;
   also have &amp;quot;… = (¬(estaEn x xs))&amp;quot; by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
   also have &amp;quot;… = True&amp;quot; using c2 by simp&lt;br /&gt;
   finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
    case True&lt;br /&gt;
    then have 1: &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
                 = sinDuplicados (borraDuplicados xs)&amp;quot; by (simp add: estaEn_borraDuplicados_2)&lt;br /&gt;
    show &amp;quot;?P (x#xs)&amp;quot; using HI 1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    case False&lt;br /&gt;
    then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
               = sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (estaEn x (borraDuplicados xs)) ∧ &lt;br /&gt;
                  sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = True&amp;quot;  using `¬ estaEn x xs` HI by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
    finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar o refutar:&lt;br /&gt;
    borraDuplicados (rev xs) = rev (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom rubgonmar ivamenjim wilmorort pablucoto migtermor &lt;br /&gt;
   anaprarod fraortmoy ferrenseg marpoldia1 bowma danrodcha juacabsou paupeddeg manmorjim1 serrodcal josgarsan *)&lt;br /&gt;
lemma &amp;quot;borraDuplicados (rev xs) = rev (borraDuplicados xs)&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: Quickcheck encuentra el siguiente contraejemplo: &lt;br /&gt;
   xs = [a1, a2, a1]&lt;br /&gt;
   Por lo que:&lt;br /&gt;
   · &amp;quot;borraDuplicados (rev xs) = [a2, a1]&amp;quot;&lt;br /&gt;
   · &amp;quot;rev (borraDuplicados xs) = [a1, a2]&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=817</id>
		<title>Relación 5</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=817"/>
		<updated>2016-11-30T11:09:01Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R5: Eliminación de duplicados *}&lt;br /&gt;
&lt;br /&gt;
theory R5_Eliminacion_de_duplicados&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
        &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar bowma wilmorort pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1&lt;br /&gt;
    danrodcha manmorjim1 *)&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn _ [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim, ferrenseg josgarsan juacabsou dancorgar pabrodmac *)&lt;br /&gt;
(* Igual que la anterior pero con x en lugar de _ en el caso base *)&lt;br /&gt;
&lt;br /&gt;
fun estaEn1 :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn1 x [] = False&amp;quot; &lt;br /&gt;
| &amp;quot;estaEn1 x (a#xs) = ((x=a) ∨ estaEn1 x xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn1 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn1 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
(* reutilizando  la funcion &amp;quot;algunos&amp;quot; de R4.thy*)&lt;br /&gt;
fun estaEn2  :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn2 a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn2 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn2 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función primitiva recursiva &lt;br /&gt;
     sinDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (sinDuplicados xs) se verifica si la lista xs no contiene&lt;br /&gt;
  duplicados. Por ejemplo,  &lt;br /&gt;
     sinDuplicados [1::nat,4,2]   = True&lt;br /&gt;
     sinDuplicados [1::nat,4,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar ivamenjim  wilmorort bowma pablucoto &lt;br /&gt;
    serrodcal anaprarod migtermor paupeddeg fraortmoy marpoldia1 &lt;br /&gt;
    ferrenseg josgarsan danrodcha manmorjim1 juacabsou dancorgar *)&lt;br /&gt;
fun sinDuplicados :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados (x#xs) = (¬ estaEn x xs ∧ sinDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2]   = True&amp;quot;&lt;br /&gt;
value &amp;quot;sinDuplicados [1::nat,4,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
(* Utilizando la función ∉ de Isabelle *)&lt;br /&gt;
fun sinDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados2 [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados2 (a#xs) = ((a ∉ set xs) ∧  sinDuplicados2 xs ) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función primitiva recursiva &lt;br /&gt;
     borraDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (borraDuplicados xs) es la lista obtenida eliminando los&lt;br /&gt;
  elementos duplicados de la lista xs. Por ejemplo, &lt;br /&gt;
     borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función borraDuplicados es equivalente a la predefinida&lt;br /&gt;
  remdups.  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar wilmorort bowma pablucoto serrodcal &lt;br /&gt;
    anaprarod migtermor paupeddeg fraortmoy marpoldia1 ferrenseg &lt;br /&gt;
    josgarsan danrodcha juacabsou dancorgar manmorjim1 *)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(* Otra forma Sin usar if &lt;br /&gt;
  Utilizando case aunque se le sacaría más partido con más de 2 casos *)&lt;br /&gt;
 &lt;br /&gt;
 fun borraDuplicados1 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados1 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados1 (x#xs) = ( case estaEn x xs of False  =&amp;gt; x#borraDuplicados1 xs | True =&amp;gt; borraDuplicados1 xs )&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
(*Otra forma utilizando let*)&lt;br /&gt;
fun borraDuplicados2 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
&amp;quot;borraDuplicados2 [] = []&amp;quot; |&lt;br /&gt;
&amp;quot;borraDuplicados2 (x#xs) =  (let condicion = estaEn x xs::bool  in &lt;br /&gt;
if  condicion then borraDuplicados2 xs else x # borraDuplicados2 xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(*crigomgom anaprarod ferrenseg*)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all)&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar wilmorort pablucoto serrodcal migtermor paupeddeg &lt;br /&gt;
    fraortmoy marpoldia1 danrodcha juacabsou dancorgar josgarsan *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
(* soy de ponerlo mejor por pasos *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma  anaprarod *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (simp, simp)  (* creo que es mejor poner aquí simp_all *)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all (* Creo que se puede poner simp_all fuera de parentesis *)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
(* crigomgom *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;(¬ estaEn x xs)&amp;quot;&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (x#xs)) = length (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;... = 1 +  length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;...  ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... = length (x#xs)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (x#xs)) ≤ length (x#xs)&amp;quot;  by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  wilmorort ferrenseg rubgonmar juacabsou dancorgar josgarsan *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* serrodcal anaprarod danrodcha *)&lt;br /&gt;
lemma length_borraDuplicados_2: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;  &lt;br /&gt;
proof(induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length [] &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; length (borraDuplicados xs) ≤ length xs &amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp &lt;br /&gt;
  also have &amp;quot;... ≤ length (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally  show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
  have c1:&amp;quot;1+length xs = length (a#xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;length(borraDuplicados (a#xs)) ≤ 1 + length(borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1+length xs&amp;quot; using HI by simp&lt;br /&gt;
  then show &amp;quot;length(borraDuplicados (a#xs)) ≤ length (a#xs)&amp;quot; using c1 by simp&lt;br /&gt;
(* ¿Aquí porqué no puedo usar &amp;quot;finally show &amp;quot;?p (a # xs)&amp;quot; using c1 by simp? &lt;br /&gt;
   Y porque no puedo añadir &amp;quot;finally show *) &amp;quot;?p (a # xs)&amp;quot; by simp al final? *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume &amp;quot;(estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume &amp;quot;¬ (estaEn a xs)&amp;quot;&lt;br /&gt;
   then have Aux: &amp;quot;length (borraDuplicados (a#xs)) = 1+ length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… ≤ length (a#xs)&amp;quot; using HI by simp&lt;br /&gt;
   then show &amp;quot;length (borraDuplicados (a#xs)) ≤ (length (a#xs))&amp;quot; using Aux by simp&lt;br /&gt;
  qed&lt;br /&gt;
then show &amp;quot;?P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg marpoldia1*)&lt;br /&gt;
lemma length_borraDuplicados_4:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  have &amp;quot;length (borraDuplicados (a # xs)) ≤ length [a] + length (borraDuplicados xs) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
(* muy parecida a alguna anterior, pero yo dí mas pasos *)&lt;br /&gt;
lemma length_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  proof (induct xs)&lt;br /&gt;
    show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
    fix a xs&lt;br /&gt;
    assume H1: &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
    have &amp;quot;length (borraDuplicados (a # xs)) ≤ length(borraDuplicados [a])+length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… ≤ 1 + length xs&amp;quot; using H1 by simp&lt;br /&gt;
    finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática es&amp;quot;&lt;br /&gt;
(* crigomgom rubgonmar  wilmorort pablucoto serrodcal bowma &lt;br /&gt;
    migtermor fraortmoy marpoldia1 ferrenseg danrodcha  juacabsou paupeddeg*)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim manmorjim1 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs, simp_all, blast)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados&amp;#039;: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
apply (simp_all)&lt;br /&gt;
apply blast&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp, blast)&lt;br /&gt;
done&lt;br /&gt;
 &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  Nota: Para la demostración de la equivalencia se puede usar&lt;br /&gt;
     proof (rule iffI)&lt;br /&gt;
  La regla iffI es&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix b xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (b#xs)) = estaEn a (b#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  H1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn b xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#(borraDuplicados xs))&amp;quot; using H1 by simp&lt;br /&gt;
      then have &amp;quot;a=b ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; a=b ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (b#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (b#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn b (borraDuplicados xs) = estaEn b xs&amp;quot; using HI by simp&lt;br /&gt;
      then have &amp;quot;(estaEn b xs ⟶ estaEn b (borraDuplicados xs)) ∧&lt;br /&gt;
           (¬ estaEn b xs ⟶ estaEn b (b # borraDuplicados xs))&amp;quot; by simp      &lt;br /&gt;
       then have &amp;quot;estaEn b (borraDuplicados (b#xs))&amp;quot; by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a=b` by simp&lt;br /&gt;
     next&lt;br /&gt;
      assume &amp;quot;a≠b&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (b#xs)&amp;quot; using H2 by simp&lt;br /&gt;
      then have &amp;quot;a = b ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;False ∨ estaEn a xs &amp;quot; using `a≠b` by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (b#xs))&amp;quot; using `a≠b` by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod marpoldia1 ferrenseg juacabsou *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2:&lt;br /&gt;
 &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
 proof (cases)&lt;br /&gt;
  assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by auto&lt;br /&gt;
 next&lt;br /&gt;
  assume &amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;...= (x = a ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  finally show  &amp;quot;?P (x#xs)&amp;quot; using HI by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix aa xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have P1: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
   assume C1: &amp;quot;(estaEn aa xs)&amp;quot;&lt;br /&gt;
    have &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (borraDuplicados xs)&amp;quot; &lt;br /&gt;
             using C1 by simp&lt;br /&gt;
    also have P3: &amp;quot;… = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = estaEn a (aa#xs)&amp;quot;  &lt;br /&gt;
    proof (cases)&lt;br /&gt;
     assume &amp;quot;(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; using C1 by simp&lt;br /&gt;
    next&lt;br /&gt;
     assume &amp;quot;¬(a=aa)&amp;quot;&lt;br /&gt;
     then show &amp;quot;estaEn a xs = estaEn a (aa#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P3 by simp&lt;br /&gt;
  next&lt;br /&gt;
   assume C2: &amp;quot;¬(estaEn aa xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using HI by simp&lt;br /&gt;
  qed&lt;br /&gt;
 also have Conc: &amp;quot;estaEn a (borraDuplicados (aa#xs)) = estaEn a (aa#xs)&amp;quot; using P1 by simp&lt;br /&gt;
 finally show &amp;quot;?P (aa#xs)&amp;quot; using Conc by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg *)&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume a1: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using  a1 by  simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
      then show  &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#(borraDuplicados xs))&amp;quot; using a1 by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot; x=a ∨ (estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  next&lt;br /&gt;
    assume a2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
    proof (cases)&lt;br /&gt;
      assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
      then  show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      assume b1: &amp;quot;a≠x&amp;quot;&lt;br /&gt;
      then have &amp;quot;estaEn a (x#xs)&amp;quot; using a2 by simp&lt;br /&gt;
      then have &amp;quot;x = a ∨ estaEn a xs&amp;quot; by simp&lt;br /&gt;
      then have &amp;quot;estaEn a xs &amp;quot; using b1  by simp&lt;br /&gt;
      then have &amp;quot;estaEn a (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using b1 by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a  ( borraDuplicados xs ) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
   fix x&lt;br /&gt;
   fix xs&lt;br /&gt;
   assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
   proof (rule iffI) (* usamos proof de la regla dada iffI*)&lt;br /&gt;
     assume cprim: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   next&lt;br /&gt;
     assume cseg: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by auto&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;a≠x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using `a≠x` cseg HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* &lt;br /&gt;
Aplico la regla iffI:&lt;br /&gt;
     ⟦P ⟹ Q ; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
Así:&lt;br /&gt;
 [estaEn a (borraDuplicados (x # xs)) ⟹ estaEn a (x # xs); estaEn a (x # xs) ⟹ estaEn a (borraDuplicados (x # xs))] &lt;br /&gt;
⟹ estaEn a (borraDuplicados (x # xs)) = estaEn a (x # xs)&lt;br /&gt;
*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* bowma ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?p xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?p []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix x xs&lt;br /&gt;
assume HI: &amp;quot;?p xs&amp;quot;&lt;br /&gt;
show &amp;quot;?p (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases)&lt;br /&gt;
  assume H1:&amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a xs&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; &lt;br /&gt;
    proof(cases)&lt;br /&gt;
    assume &amp;quot;x=a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; using H1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    assume &amp;quot;x≠a&amp;quot;&lt;br /&gt;
    then show &amp;quot;estaEn a xs = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
    qed&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  assume H2:&amp;quot;¬estaEn x xs&amp;quot;&lt;br /&gt;
  then have &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x=a) ∨ estaEn a xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = estaEn a (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha *)&lt;br /&gt;
(* es como la de ruben pero con diferencias de estilo *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (rule iffI)&lt;br /&gt;
    assume H1: &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (x#xs)&amp;quot; using H1 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
    next&lt;br /&gt;
    assume H2: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
    show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot;&lt;br /&gt;
    proof (cases &amp;quot;x=a&amp;quot;)&lt;br /&gt;
      case True&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using HI by simp&lt;br /&gt;
    next&lt;br /&gt;
      case False&lt;br /&gt;
      then show &amp;quot;estaEn a (borraDuplicados (x # xs))&amp;quot; using H2 HI by simp&lt;br /&gt;
    qed&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.1. Demostrar o refutar automáticamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración automática&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal crigomgom anaprarod fraortmoy &lt;br /&gt;
    marpoldia1 ferrenseg danrodcha juacabsou paupeddeg josgarsan *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: estaEn_borraDuplicados)&lt;br /&gt;
&lt;br /&gt;
(* migtermor bowma *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs, simp_all add: estaEn_borraDuplicados_2)&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 no caí en usar la demostración anterior y he realizado&lt;br /&gt;
  la demostración de que si un elemento no estaba en una lista seguirá sin estar&lt;br /&gt;
  después de eliminar los duplicados en esa lista... *)&lt;br /&gt;
lemma noEsta_tras_borrarDuplicados:&lt;br /&gt;
  &amp;quot;(¬estaEn x xs) ⟶ (¬estaEn x (borraDuplicados xs))&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
apply (simp add: noEsta_tras_borrarDuplicados)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.2. Demostrar o refutar detalladamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot; sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot;&lt;br /&gt;
proof (cases)&lt;br /&gt;
assume &amp;quot;estaEn a xs&amp;quot;&lt;br /&gt;
then show &amp;quot;sinDuplicados (borraDuplicados (a#xs))&amp;quot; using HI by simp&lt;br /&gt;
next&lt;br /&gt;
assume&amp;quot;¬ estaEn a xs&amp;quot;&lt;br /&gt;
then have &amp;quot;¬ (estaEn a xs) ∧ sinDuplicados (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
then have &amp;quot;¬ estaEn a (borraDuplicados xs) ∧  sinDuplicados (borraDuplicados xs)&amp;quot; &lt;br /&gt;
      by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
then have &amp;quot; sinDuplicados (a#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
then show &amp;quot; sinDuplicados (borraDuplicados(a #xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor crigomgom rubgonmar fraortmoy marpoldia1 ferrenseg bowma juacabsou serrodcal josgarsan *)&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; &lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn a xs&amp;quot; &lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;¬(estaEn a xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod paupeddeg*)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show  &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
   proof (cases)&lt;br /&gt;
   assume c1: &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
   then show &amp;quot;sinDuplicados (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
   next&lt;br /&gt;
   assume c2: &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
   then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) =sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;…= (¬estaEn x (borraDuplicados xs) ∧ sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… = (¬estaEn x (borraDuplicados xs))&amp;quot; using HI by simp&lt;br /&gt;
   also have &amp;quot;… = (¬(estaEn x xs))&amp;quot; by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
   also have &amp;quot;… = True&amp;quot; using c2 by simp&lt;br /&gt;
   finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
    case True&lt;br /&gt;
    then have 1: &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
                 = sinDuplicados (borraDuplicados xs)&amp;quot; by (simp add: estaEn_borraDuplicados_2)&lt;br /&gt;
    show &amp;quot;?P (x#xs)&amp;quot; using HI 1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    case False&lt;br /&gt;
    then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
               = sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (estaEn x (borraDuplicados xs)) ∧ &lt;br /&gt;
                  sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = True&amp;quot;  using `¬ estaEn x xs` HI by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
    finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar o refutar:&lt;br /&gt;
    borraDuplicados (rev xs) = rev (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom rubgonmar ivamenjim wilmorort pablucoto migtermor &lt;br /&gt;
   anaprarod fraortmoy ferrenseg marpoldia1 bowma danrodcha juacabsou paupeddeg manmorjim1 serrodcal josgarsan *)&lt;br /&gt;
lemma &amp;quot;borraDuplicados (rev xs) = rev (borraDuplicados xs)&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: Quickcheck encuentra el siguiente contraejemplo: &lt;br /&gt;
   xs = [a1, a2, a1]&lt;br /&gt;
   Por lo que:&lt;br /&gt;
   · &amp;quot;borraDuplicados (rev xs) = [a2, a1]&amp;quot;&lt;br /&gt;
   · &amp;quot;rev (borraDuplicados xs) = [a1, a2]&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=641</id>
		<title>Relación 4</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=641"/>
		<updated>2016-11-23T11:50:50Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R4: Cuantificadores sobre listas *}&lt;br /&gt;
&lt;br /&gt;
theory R4_Cuantificadores_sobre_listas&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la función &lt;br /&gt;
     todos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (todos p xs) se verifica si todos los elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     todos (λx. 1&amp;lt;length x) [[2,1,4],[1,3]]&lt;br /&gt;
     ¬todos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función todos es equivalente a la predefinida list_all. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p xs =   &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor dancorgar wilmorort marpoldia1 ferrenseg paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     algunos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (algunos p xs) se verifica si algunos elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     algunos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
     ¬algunos (λx. 1&amp;lt;length x) [[],[3]]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  Nota: La función algunos es equivalente a la predefinida list_ex. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*}&lt;br /&gt;
fun algunos  :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
   &amp;quot;algunos p []     = False&amp;quot;&lt;br /&gt;
| &amp;quot;algunos p (x#xs) = (p x ∨ algunos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (P a ∧ Q a ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?R (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar paupeddeg *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix y xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = ((P y ∧ Q y) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ Q y) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ todos P xs) ∧ (Q y ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = ((todos P (y#xs)) ∧ (todos Q (y#xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = (todos P (y#xs) ∧ todos Q (y#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
 next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
 have &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = (( P x ∧ Q x) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot;&lt;br /&gt;
     by (simp only: todos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot; by arith&lt;br /&gt;
 also have &amp;quot;((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs)) = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot;&lt;br /&gt;
          by arith (* Este paso es exactamente el mismo que el anterior, pero sin cualquiera de los dos no funciona el &amp;quot;finally show&amp;quot; *)&lt;br /&gt;
 have &amp;quot;… = (((P x)∧(todos P xs))∧((Q x)∧(todos Q xs)))&amp;quot; by simp&lt;br /&gt;
 have &amp;quot;… = ((todos P (x#xs))∧(todos Q (x#xs)))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = ((todos P (x#xs)) ∧ (todos Q (x#xs)))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) =  ((P a ∧ Q a) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs) ∧ todos Q (a#xs)) &amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = (P n ∧ Q n ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = P n ∧ Q n ∧ todos P xs ∧ todos Q xs&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;⋯ = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) =  ((P n ∧ Q n) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P n ∧ todos P xs) ∧ (Q n ∧ todos Q xs))&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = ((todos P(n#xs)) ∧ (todos Q(n#xs)))&amp;quot; by simp&lt;br /&gt;
&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (n#xs) = (todos P (n#xs) ∧ todos Q (n#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* wilmorort pablucoto crigomgom anaprarod juacabsou rubgonmar fraortmoy *}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp   &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ todos P xs ∧ Q a ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
also have &amp;quot;... = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp (* Este paso se puede obviar*)&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (x#xs) = ( P x ∧ Q x  ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ Q x  ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ todos P xs ∧ Q x ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (x#xs) = (todos P (x#xs) ∧ todos Q (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
{*danrodcha ivamenjim marpoldia1 migtermor ferrenseg wilmorort paupeddeg crigomgom anaprarod serrodcal juacabsou rubgonmar pablucoto fraortmoy josgarsan lucnovdos pabrodmac*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
{* anaprarod dancorgar *}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
apply (induct x)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg wilmorort dancorgar fraortmoy josgarsan lucnovdos*)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append1:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?P x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix a x&lt;br /&gt;
 assume HI: &amp;quot;?P x&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;?P (a#x)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a#(x@y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
lemma todos_append3:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P (x @ y)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom juacabsou anaprarod*)&lt;br /&gt;
 &lt;br /&gt;
lemma todos_append4:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI:&amp;quot;todos P (xs @ y) = (todos P xs ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((x # xs) @ y) = (P x ∧ todos P (xs @ y ))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ (todos P xs ∧ todos P y)) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P x ∧ todos P xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((x # xs) @ y) = (todos P (x # xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma todos_append5:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x )&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a x&lt;br /&gt;
  assume HI:&amp;quot;todos P (x @ y) = (todos P x ∧ todos P y) &amp;quot; &lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = ( P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot; ... =( P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by auto&lt;br /&gt;
  qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma todos_append6:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?Q x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix x a assume HI: &amp;quot;?Q x&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # x @ y)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?Q (a # x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*pabrodmac*}&lt;br /&gt;
lemma todos_append7:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a#x) @ y) = (todos P (a#x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim marpoldia1 serrodcal anaprarod paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; &lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: todos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom rubgonmar fraortmoy josgarsan danrodcha lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: todos_append)&lt;br /&gt;
 &lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: todos_append,auto)&lt;br /&gt;
&lt;br /&gt;
(* juacabsou *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
apply (induct xs,simp,simp add: todos_append,auto) done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto * )&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) (auto, simp_all add: todos_append) &lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) ( simp_all add: todos_append, auto)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by (simp only: rev.simps(1))&lt;br /&gt;
next &lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P (rev (a#xs)) = (todos P (rev xs @ [a]))&amp;quot; by (simp add: auxiliar)&lt;br /&gt;
 have &amp;quot;… = ((todos P (rev xs)) ∧ (todos P [a]))&amp;quot; by (simp add: todos_append)&lt;br /&gt;
 have &amp;quot;… =  (todos P (rev xs) ∧ P a)&amp;quot; by simp&lt;br /&gt;
 also have Aux: &amp;quot;… = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
 have Aux1: &amp;quot;… = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
 have &amp;quot;(todos P (rev xs) ∧ P a) = (P a ∧ todos P xs)&amp;quot; using Aux Aux1 by simp&lt;br /&gt;
 finally show &amp;quot;todos P (rev (a#xs)) = todos P (a#xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 ferrenseg crigomgom serrodcal juacabsou rubgonmar josgarsan pablucoto pabrodmac lucnovdos*)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = (todos P (a#xs))&amp;quot; by simp    &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((todos P (rev xs)) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume H1: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot; todos P (rev (a # xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show  &amp;quot;todos P (rev (a # xs)) = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs &amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = todos P (rev(xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a]) &amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = todos P ([a] @ xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (todos P(rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;... = todos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;todos P (rev (a#xs))= todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)  &lt;br /&gt;
(* es igual que las anteriores pero con el final también con patrones *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by auto&lt;br /&gt;
  next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a#xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;… = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;… = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar o refutar:&lt;br /&gt;
    algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim ferrenseg paupeddeg crigomgom serrodcal wilmorort juacabsou rubgonmar anaprarod marpoldia1 fraortmoy josgarsan danrodcha pablucoto lucnovdos*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot; &lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo: P={a1}, Q={a2}, xs={a1,a2}. En este ejemplo:&lt;br /&gt;
   · &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot;&lt;br /&gt;
   · &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
assume H1: &amp;quot;xs = [a, b]&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;P a = True&amp;quot;&lt;br /&gt;
assume H3: &amp;quot;Q a = False&amp;quot;&lt;br /&gt;
assume H4: &amp;quot;P b = False&amp;quot;&lt;br /&gt;
assume H5: &amp;quot;Q b = True&amp;quot; &lt;br /&gt;
have F1: &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have F2: &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∧ Q x) xs ≠ (algunos P xs ∧ algunos Q xs)&amp;quot; using F1 F2 by simp&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom rubgonmar wilmorort anaprarod &lt;br /&gt;
    fraortmoy juacabsou paupeddeg josgarsan danrodcha pablucoto lucnovdos *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
(* anaprarod dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma AUX: &amp;quot;algunos (λa. P (f a)) xs = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (map f (x#xs)) = (algunos P ((f x)#(map f xs)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by (simp only: algunos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
   proof (cases)&lt;br /&gt;
    assume C1: &amp;quot;(P (f x))&amp;quot;&lt;br /&gt;
    have Aux: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = True&amp;quot; using C1 by simp&lt;br /&gt;
    have  Aux1: &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C1 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
              using Aux Aux1 by simp&lt;br /&gt;
   next&lt;br /&gt;
    assume C2: &amp;quot;¬(P (f x))&amp;quot;&lt;br /&gt;
    have Aux2: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = (algunos P (map f xs))&amp;quot; using C2 by simp&lt;br /&gt;
    have Aux3: &amp;quot;… = (algunos (P o f) xs)&amp;quot; using HI by (simp add: AUX)&lt;br /&gt;
    also have &amp;quot;… =  ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C2 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
            using Aux2 Aux3 by simp&lt;br /&gt;
   qed&lt;br /&gt;
 also have &amp;quot;… = (((P o f) x) ∨ (algunos (P o f) xs))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (map f (x#xs)) = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (map f (x # xs)) = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (((P ∘ f) x) ∨ (algunos (P ∘ f) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (a # xs)) = algunos P ((f a)#map f xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp &lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar anaprarod marpoldia1 juacabsou danrodcha paupeddeg josgarsan*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x # xs))  = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P ∘ f) x ∨ algunos (P ∘ f) xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* wilmorort pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?P xs&amp;quot; )&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (map f (a # xs))  = (P (f a) ∨ algunos P (map f xs))&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;... = (P (f a) ∨ algunos (P ∘ f) xs )&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = ((P ∘ f) a ∨ algunos (P ∘ f)xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot; algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have  &amp;quot;algunos P (map f (a # xs)) = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos (P ∘ f) [a] ∨  algunos (P ∘ f) xs )&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot; algunos P (map f (a # xs)) = algunos P ((f a)#(map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by blast&lt;br /&gt;
also have &amp;quot;… = ((P ∘ f) a ∨ algunos (P ∘ f) xs)&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;… = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P o f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x#xs)) = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x#xs)) = algunos (P o f) (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg crigomgom rubgonmar  wilmorort fraortmoy danrodcha pablucoto dancorgar josgarsan anaprarod*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
apply (induct  xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg marpoldia1 wilmorort dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (P a ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append2:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P ((x#xs) @ ys) = algunos P (x#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs) ∨ (algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (x#xs)) ∨ (algunos P ys))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P ((x#xs) @ ys) = (algunos P (x#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg*)&lt;br /&gt;
lemma algunos_append3:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ ( algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
lemma algunos_append4:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = ((algunos P [a] ∨ algunos P xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto anaprarod *}&lt;br /&gt;
lemma algunos_append5:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P ((a#xs) @ ys) = algunos P (a#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 rubgonmar paupeddeg dancorgar anaprarod *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: algunos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom danrodcha pablucoto josgarsan pabrodmac*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: algunos_append)&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: algunos_append,auto) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma auxiliar1:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto &lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (rev (x#xs)) = (algunos P (rev xs @ [x]))&amp;quot; using auxiliar1 by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (rev xs)) ∨ (algunos P [x]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (rev xs)))&amp;quot; by simp arith&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (rev (x#xs)) = (algunos P (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [x])&amp;quot; &lt;br /&gt;
      by (simp add: algunos_append)&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P x ∨ algunos P xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
 &lt;br /&gt;
(* ivamenjim marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = (algunos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI:&amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ (algunos P [a]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = ((algunos P xs) ∨ (algunos P [a]))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P [a]) ∨ (algunos P xs))&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto anaprarod *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot; algunos P (rev xs) = algunos P xs&amp;quot; &lt;br /&gt;
  have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (rev xs) ∨ algunos P [x])&amp;quot;  by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs  ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = algunos P (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;  (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P(rev xs) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;... = algunos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;algunos  P (rev (a#xs))= algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [a])&amp;quot; by (simp add:algunos_append)&lt;br /&gt;
also have &amp;quot;… = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;… = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Encontrar un término no trivial Z tal que sea cierta la &lt;br /&gt;
  siguiente ecuación:&lt;br /&gt;
     algunos (λx. P x ∨ Q x) xs = Z&lt;br /&gt;
  y demostrar la equivalencia de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos (λx. P x ∨ Q x) (x#xs) = (((λx. P x ∨ Q x) x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x ∨ Q x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot; by simp&lt;br /&gt;
 also have H1: &amp;quot;… = ((((λx. P x) x) ∨ (algunos (λx. P x) xs)) ∨ (((λx. Q x) x) ∨ (algunos (λx. Q x) xs)))&amp;quot;&lt;br /&gt;
          using HI by simp arith&lt;br /&gt;
 have H2: &amp;quot;… = ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               by simp&lt;br /&gt;
 have C: &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
         using H1 H2 by simp&lt;br /&gt;
 finally show &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos  (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. (P x ∨ Q x)) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = &lt;br /&gt;
      ((P x) ∨ (Q x) ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ (Q x) ∨ algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
      using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (((P x) ∨ algunos P xs) ∨ ((Q x) ∨ algunos Q xs))&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis &lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ algunos P xs ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* wilmorort danrodcha anaprarod*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
(is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ Q a ∨  (¬ todos (λx. ¬ P x) xs ∨ ¬ todos (λx. ¬ Q x) xs))&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ ¬ todos (λx. ¬ P x) xs ∨ Q a ∨  ¬ todos (λx. ¬ Q x) xs )&amp;quot; by arith&lt;br /&gt;
finally show  &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (~ todos (λx. ¬ P x) (a # xs) ∨ ~ todos (λx. ¬ Q x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
    have 1:&amp;quot; (Q a ∨ algunos P xs) = (algunos P xs ∨ Q a)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = &lt;br /&gt;
     (algunos P [a] ∨ algunos Q [a] ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (Q a ∨ algunos P xs) ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ algunos P xs ∨ Q a ∨ algunos Q xs)&amp;quot; using 1 by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?R (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) [] ⟹ (algunos P [] ∧ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
  have F1: &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ ((P xf ∧ Q xf) ∨ algunos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have F2: &amp;quot;… ⟹ (P xf ∧ Q xf ∨ (algunos P xs ∧ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  have F3: &amp;quot;((P xf ∧ Q xf) ∨ (algunos P xs ∧ algunos Q xs)) ⟹ &lt;br /&gt;
    ((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs))&amp;quot; by blast&lt;br /&gt;
  have F4: &amp;quot;((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs)) ⟹ &lt;br /&gt;
     (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot; by simp&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot;&lt;br /&gt;
    using F1 F2 F3 F4 by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto crigomgom*)&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs) &amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q []) &amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot; algunos (λx. P x ∨ Q x) (a # xs) = ( P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ (algunos P xs ∨ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (((P a) ∨ algunos P xs) ∨ ((Q a) ∨ algunos Q xs))&amp;quot; by arith &lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs)) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∨ Q x) (x#xs) =(P x ∨ Q x ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (P x ∨ Q x ∨ algunos P xs ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (P x ∨ algunos P xs ∨ Q x ∨ algunos Q xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort migtermor marpoldia1 crigomgom rubgonmar paupeddeg danrodcha pablucoto dancorgar josgarsan anaprarod*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot; &lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.2. Demostrar o refutar datalladamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom paupeddeg josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. ¬ P x) [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. ¬ P x) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (a # xs) = (P a ∨ (algunos P xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (¬ todos (λx. ¬ P x) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (a # xs) = (¬ todos (λx. ¬ P x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (x # xs) = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot;&lt;br /&gt;
  proof - &lt;br /&gt;
    have &amp;quot;algunos P (x # xs) = ((P x) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ ¬ todos (λx. (¬ P x)) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (¬ (P x) ∧ todos (λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto anaprarod *}&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
    have &amp;quot;algunos P (a # xs) = (P a ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (¬ todos (λx. (¬ P x)) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬(¬(P a) ∧ todos(λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos(λx. (¬ P x)) (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (xf#xs) = ((P xf) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ( (P xf) ∨ (¬ todos (λx. (¬ P x)) xs) )&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (¬((¬P xf) ∧ (todos (λx. (¬ P x)) xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (xf#xs) = (¬todos (λx. (¬ P x)) (xf#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg migtermor serrodcal crigomgom rubgonmar marpoldia1 paupeddeg danrodcha dancorgar pablucoto anaprarod*)&lt;br /&gt;
&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn x [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Expresar la relación existente entre estaEn y algunos. &lt;br /&gt;
  Demostrar dicha relación de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar13:&lt;br /&gt;
 &amp;quot;(x=a) = ((λa. a=x) a)&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;estaEn x (a#xs) = ((a=x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
 also have H: &amp;quot;… = ((a=x) ∨ (algunos (λa. a=x) xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((λa. a=x) a) ∨ (algunos (λa. a=x) xs))&amp;quot; using auxiliar13  by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (λa. a=x) (a#xs))&amp;quot; by simp&lt;br /&gt;
 have C: &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using H by simp&lt;br /&gt;
 finally show &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos_2:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x=y) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn y (x # xs) = algunos (λx. x=y) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;estaEn y (x # xs) = (y=x ∨ estaEn y xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (y=x ∨ algunos (λx. x=y) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (x=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos (λx. x=y) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg dancorgar *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; &lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; estaEn x [] = algunos (λa. a = x) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (λa. a = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = (a = x ∨ estaEn x xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (a = x ∨ algunos (λa. a = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (λa. a = x) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn x [] = algunos (op = x) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (op = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = ((a = x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  (a = x ∨ algunos (op = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (op = x) (a # xs)&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a [] = algunos (op = a) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs &lt;br /&gt;
  assume HI: &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
      have &amp;quot;estaEn a (x # xs) = ((x = a) ∨ (estaEn a xs))&amp;quot; by simp&lt;br /&gt;
      also have &amp;quot;… = (x = a ∨ algunos (op = a) xs)&amp;quot; using HI by simp&lt;br /&gt;
      also have &amp;quot;… = ((op = a) x ∨ algunos (op = a) xs)&amp;quot; by (simp add:HOL.eq_commute)&lt;br /&gt;
      also have &amp;quot;… = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
      finally show &amp;quot;estaEn a (x # xs) = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x = y) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; estaEn y xs = algunos (λx. x = y) xs &amp;quot;&lt;br /&gt;
  have &amp;quot; estaEn y (a # xs) = (y = a ∨ estaEn y xs)&amp;quot;  by simp &lt;br /&gt;
  also have &amp;quot;... = (y = a ∨ algunos (λx. x = y) xs) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (a=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
  also have &amp;quot;... = (algunos (λx. x = y) (a#xs))&amp;quot;  by simp&lt;br /&gt;
  finally show &amp;quot;estaEn y (a # xs) = algunos (λx. x = y) (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* Automática*)&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (λx. a=x) xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* Detallada (igual que las anteriores pero obviando el paso previo al finally) *)&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (λx. a=x) xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI : &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn a (x#xs) = (x=a ∨ estaEn a xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (x=a ∨ algunos (λx. a=x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (a=x ∨ algunos (λx. a=x) xs)&amp;quot; using HI by auto&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=638</id>
		<title>Relación 4</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=638"/>
		<updated>2016-11-23T11:39:38Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R4: Cuantificadores sobre listas *}&lt;br /&gt;
&lt;br /&gt;
theory R4_Cuantificadores_sobre_listas&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la función &lt;br /&gt;
     todos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (todos p xs) se verifica si todos los elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     todos (λx. 1&amp;lt;length x) [[2,1,4],[1,3]]&lt;br /&gt;
     ¬todos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función todos es equivalente a la predefinida list_all. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p xs =   &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor dancorgar wilmorort marpoldia1 ferrenseg paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     algunos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (algunos p xs) se verifica si algunos elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     algunos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
     ¬algunos (λx. 1&amp;lt;length x) [[],[3]]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  Nota: La función algunos es equivalente a la predefinida list_ex. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*}&lt;br /&gt;
fun algunos  :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
   &amp;quot;algunos p []     = False&amp;quot;&lt;br /&gt;
| &amp;quot;algunos p (x#xs) = (p x ∨ algunos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (P a ∧ Q a ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?R (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar paupeddeg *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix y xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = ((P y ∧ Q y) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ Q y) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ todos P xs) ∧ (Q y ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = ((todos P (y#xs)) ∧ (todos Q (y#xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = (todos P (y#xs) ∧ todos Q (y#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
 next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
 have &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = (( P x ∧ Q x) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot;&lt;br /&gt;
     by (simp only: todos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot; by arith&lt;br /&gt;
 also have &amp;quot;((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs)) = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot;&lt;br /&gt;
          by arith (* Este paso es exactamente el mismo que el anterior, pero sin cualquiera de los dos no funciona el &amp;quot;finally show&amp;quot; *)&lt;br /&gt;
 have &amp;quot;… = (((P x)∧(todos P xs))∧((Q x)∧(todos Q xs)))&amp;quot; by simp&lt;br /&gt;
 have &amp;quot;… = ((todos P (x#xs))∧(todos Q (x#xs)))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = ((todos P (x#xs)) ∧ (todos Q (x#xs)))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) =  ((P a ∧ Q a) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs) ∧ todos Q (a#xs)) &amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = (P n ∧ Q n ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = P n ∧ Q n ∧ todos P xs ∧ todos Q xs&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;⋯ = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) =  ((P n ∧ Q n) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P n ∧ todos P xs) ∧ (Q n ∧ todos Q xs))&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = ((todos P(n#xs)) ∧ (todos Q(n#xs)))&amp;quot; by simp&lt;br /&gt;
&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (n#xs) = (todos P (n#xs) ∧ todos Q (n#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* wilmorort pablucoto crigomgom anaprarod juacabsou rubgonmar fraortmoy *}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp   &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ todos P xs ∧ Q a ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
also have &amp;quot;... = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp (* Este paso se puede obviar*)&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (x#xs) = ( P x ∧ Q x  ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ Q x  ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ todos P xs ∧ Q x ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (x#xs) = (todos P (x#xs) ∧ todos Q (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
{*danrodcha ivamenjim marpoldia1 migtermor ferrenseg wilmorort paupeddeg crigomgom anaprarod serrodcal juacabsou rubgonmar pablucoto fraortmoy josgarsan lucnovdos pabrodmac*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
{* anaprarod dancorgar *}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
apply (induct x)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg wilmorort dancorgar fraortmoy josgarsan lucnovdos*)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append1:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?P x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix a x&lt;br /&gt;
 assume HI: &amp;quot;?P x&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;?P (a#x)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a#(x@y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
lemma todos_append3:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P (x @ y)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom juacabsou anaprarod*)&lt;br /&gt;
 &lt;br /&gt;
lemma todos_append4:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI:&amp;quot;todos P (xs @ y) = (todos P xs ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((x # xs) @ y) = (P x ∧ todos P (xs @ y ))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ (todos P xs ∧ todos P y)) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P x ∧ todos P xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((x # xs) @ y) = (todos P (x # xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma todos_append5:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x )&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a x&lt;br /&gt;
  assume HI:&amp;quot;todos P (x @ y) = (todos P x ∧ todos P y) &amp;quot; &lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = ( P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot; ... =( P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by auto&lt;br /&gt;
  qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma todos_append6:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?Q x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix x a assume HI: &amp;quot;?Q x&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # x @ y)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?Q (a # x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*pabrodmac*}&lt;br /&gt;
lemma todos_append7:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a#x) @ y) = (todos P (a#x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim marpoldia1 serrodcal anaprarod paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; &lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: todos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom rubgonmar fraortmoy josgarsan danrodcha lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: todos_append)&lt;br /&gt;
 &lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: todos_append,auto)&lt;br /&gt;
&lt;br /&gt;
(* juacabsou *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
apply (induct xs,simp,simp add: todos_append,auto) done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto * )&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) (auto, simp_all add: todos_append) &lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) ( simp_all add: todos_append, auto)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by (simp only: rev.simps(1))&lt;br /&gt;
next &lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P (rev (a#xs)) = (todos P (rev xs @ [a]))&amp;quot; by (simp add: auxiliar)&lt;br /&gt;
 have &amp;quot;… = ((todos P (rev xs)) ∧ (todos P [a]))&amp;quot; by (simp add: todos_append)&lt;br /&gt;
 have &amp;quot;… =  (todos P (rev xs) ∧ P a)&amp;quot; by simp&lt;br /&gt;
 also have Aux: &amp;quot;… = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
 have Aux1: &amp;quot;… = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
 have &amp;quot;(todos P (rev xs) ∧ P a) = (P a ∧ todos P xs)&amp;quot; using Aux Aux1 by simp&lt;br /&gt;
 finally show &amp;quot;todos P (rev (a#xs)) = todos P (a#xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 ferrenseg crigomgom serrodcal juacabsou rubgonmar josgarsan pablucoto pabrodmac*)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = (todos P (a#xs))&amp;quot; by simp    &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((todos P (rev xs)) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume H1: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot; todos P (rev (a # xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show  &amp;quot;todos P (rev (a # xs)) = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs &amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = todos P (rev(xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a]) &amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = todos P ([a] @ xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (todos P(rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;... = todos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;todos P (rev (a#xs))= todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)  &lt;br /&gt;
(* es igual que las anteriores pero con el final también con patrones *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by auto&lt;br /&gt;
  next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a#xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;… = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;… = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar o refutar:&lt;br /&gt;
    algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim ferrenseg paupeddeg crigomgom serrodcal wilmorort juacabsou rubgonmar anaprarod marpoldia1 fraortmoy josgarsan danrodcha pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot; &lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo: P={a1}, Q={a2}, xs={a1,a2}. En este ejemplo:&lt;br /&gt;
   · &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot;&lt;br /&gt;
   · &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
assume H1: &amp;quot;xs = [a, b]&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;P a = True&amp;quot;&lt;br /&gt;
assume H3: &amp;quot;Q a = False&amp;quot;&lt;br /&gt;
assume H4: &amp;quot;P b = False&amp;quot;&lt;br /&gt;
assume H5: &amp;quot;Q b = True&amp;quot; &lt;br /&gt;
have F1: &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have F2: &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∧ Q x) xs ≠ (algunos P xs ∧ algunos Q xs)&amp;quot; using F1 F2 by simp&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom rubgonmar wilmorort anaprarod &lt;br /&gt;
    fraortmoy juacabsou paupeddeg josgarsan danrodcha pablucoto *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
(* anaprarod dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma AUX: &amp;quot;algunos (λa. P (f a)) xs = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (map f (x#xs)) = (algunos P ((f x)#(map f xs)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by (simp only: algunos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
   proof (cases)&lt;br /&gt;
    assume C1: &amp;quot;(P (f x))&amp;quot;&lt;br /&gt;
    have Aux: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = True&amp;quot; using C1 by simp&lt;br /&gt;
    have  Aux1: &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C1 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
              using Aux Aux1 by simp&lt;br /&gt;
   next&lt;br /&gt;
    assume C2: &amp;quot;¬(P (f x))&amp;quot;&lt;br /&gt;
    have Aux2: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = (algunos P (map f xs))&amp;quot; using C2 by simp&lt;br /&gt;
    have Aux3: &amp;quot;… = (algunos (P o f) xs)&amp;quot; using HI by (simp add: AUX)&lt;br /&gt;
    also have &amp;quot;… =  ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C2 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
            using Aux2 Aux3 by simp&lt;br /&gt;
   qed&lt;br /&gt;
 also have &amp;quot;… = (((P o f) x) ∨ (algunos (P o f) xs))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (map f (x#xs)) = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (map f (x # xs)) = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (((P ∘ f) x) ∨ (algunos (P ∘ f) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (a # xs)) = algunos P ((f a)#map f xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp &lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar anaprarod marpoldia1 juacabsou danrodcha paupeddeg josgarsan*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x # xs))  = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P ∘ f) x ∨ algunos (P ∘ f) xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* wilmorort pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?P xs&amp;quot; )&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (map f (a # xs))  = (P (f a) ∨ algunos P (map f xs))&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;... = (P (f a) ∨ algunos (P ∘ f) xs )&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = ((P ∘ f) a ∨ algunos (P ∘ f)xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot; algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have  &amp;quot;algunos P (map f (a # xs)) = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos (P ∘ f) [a] ∨  algunos (P ∘ f) xs )&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot; algunos P (map f (a # xs)) = algunos P ((f a)#(map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by blast&lt;br /&gt;
also have &amp;quot;… = ((P ∘ f) a ∨ algunos (P ∘ f) xs)&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;… = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P o f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x#xs)) = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x#xs)) = algunos (P o f) (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg crigomgom rubgonmar  wilmorort fraortmoy danrodcha pablucoto dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg marpoldia1 wilmorort dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (P a ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append2:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P ((x#xs) @ ys) = algunos P (x#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs) ∨ (algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (x#xs)) ∨ (algunos P ys))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P ((x#xs) @ ys) = (algunos P (x#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg*)&lt;br /&gt;
lemma algunos_append3:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ ( algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
lemma algunos_append4:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = ((algunos P [a] ∨ algunos P xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto*}&lt;br /&gt;
lemma algunos_append5:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P ((a#xs) @ ys) = algunos P (a#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 rubgonmar paupeddeg dancorgar *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: algunos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom danrodcha pablucoto josgarsan*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: algunos_append)&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: algunos_append,auto) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma auxiliar1:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto &lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (rev (x#xs)) = (algunos P (rev xs @ [x]))&amp;quot; using auxiliar1 by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (rev xs)) ∨ (algunos P [x]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (rev xs)))&amp;quot; by simp arith&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (rev (x#xs)) = (algunos P (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [x])&amp;quot; &lt;br /&gt;
      by (simp add: algunos_append)&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P x ∨ algunos P xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
 &lt;br /&gt;
(* ivamenjim marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = (algunos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI:&amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ (algunos P [a]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = ((algunos P xs) ∨ (algunos P [a]))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P [a]) ∨ (algunos P xs))&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot; algunos P (rev xs) = algunos P xs&amp;quot; &lt;br /&gt;
  have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (rev xs) ∨ algunos P [x])&amp;quot;  by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs  ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = algunos P (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;  (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P(rev xs) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;... = algunos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;algunos  P (rev (a#xs))= algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [a])&amp;quot; by (simp add:algunos_append)&lt;br /&gt;
also have &amp;quot;… = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;… = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Encontrar un término no trivial Z tal que sea cierta la &lt;br /&gt;
  siguiente ecuación:&lt;br /&gt;
     algunos (λx. P x ∨ Q x) xs = Z&lt;br /&gt;
  y demostrar la equivalencia de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos (λx. P x ∨ Q x) (x#xs) = (((λx. P x ∨ Q x) x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x ∨ Q x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot; by simp&lt;br /&gt;
 also have H1: &amp;quot;… = ((((λx. P x) x) ∨ (algunos (λx. P x) xs)) ∨ (((λx. Q x) x) ∨ (algunos (λx. Q x) xs)))&amp;quot;&lt;br /&gt;
          using HI by simp arith&lt;br /&gt;
 have H2: &amp;quot;… = ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               by simp&lt;br /&gt;
 have C: &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
         using H1 H2 by simp&lt;br /&gt;
 finally show &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos  (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. (P x ∨ Q x)) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = &lt;br /&gt;
      ((P x) ∨ (Q x) ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ (Q x) ∨ algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
      using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (((P x) ∨ algunos P xs) ∨ ((Q x) ∨ algunos Q xs))&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis &lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ algunos P xs ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* wilmorort danrodcha*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
(is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ Q a ∨  (¬ todos (λx. ¬ P x) xs ∨ ¬ todos (λx. ¬ Q x) xs))&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ ¬ todos (λx. ¬ P x) xs ∨ Q a ∨  ¬ todos (λx. ¬ Q x) xs )&amp;quot; by arith&lt;br /&gt;
finally show  &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (~ todos (λx. ¬ P x) (a # xs) ∨ ~ todos (λx. ¬ Q x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
    have 1:&amp;quot; (Q a ∨ algunos P xs) = (algunos P xs ∨ Q a)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = &lt;br /&gt;
     (algunos P [a] ∨ algunos Q [a] ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (Q a ∨ algunos P xs) ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ algunos P xs ∨ Q a ∨ algunos Q xs)&amp;quot; using 1 by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?R (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) [] ⟹ (algunos P [] ∧ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
  have F1: &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ ((P xf ∧ Q xf) ∨ algunos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have F2: &amp;quot;… ⟹ (P xf ∧ Q xf ∨ (algunos P xs ∧ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  have F3: &amp;quot;((P xf ∧ Q xf) ∨ (algunos P xs ∧ algunos Q xs)) ⟹ &lt;br /&gt;
    ((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs))&amp;quot; by blast&lt;br /&gt;
  have F4: &amp;quot;((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs)) ⟹ &lt;br /&gt;
     (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot; by simp&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot;&lt;br /&gt;
    using F1 F2 F3 F4 by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto crigomgom*)&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs) &amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q []) &amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot; algunos (λx. P x ∨ Q x) (a # xs) = ( P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ (algunos P xs ∨ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (((P a) ∨ algunos P xs) ∨ ((Q a) ∨ algunos Q xs))&amp;quot; by arith &lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs)) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort migtermor marpoldia1 crigomgom rubgonmar paupeddeg danrodcha pablucoto dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.2. Demostrar o refutar datalladamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom paupeddeg josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. ¬ P x) [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. ¬ P x) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (a # xs) = (P a ∨ (algunos P xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (¬ todos (λx. ¬ P x) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (a # xs) = (¬ todos (λx. ¬ P x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (x # xs) = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot;&lt;br /&gt;
  proof - &lt;br /&gt;
    have &amp;quot;algunos P (x # xs) = ((P x) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ ¬ todos (λx. (¬ P x)) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (¬ (P x) ∧ todos (λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto*}&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
    have &amp;quot;algunos P (a # xs) = (P a ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (¬ todos (λx. (¬ P x)) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬(¬(P a) ∧ todos(λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos(λx. (¬ P x)) (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (xf#xs) = ((P xf) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ( (P xf) ∨ (¬ todos (λx. (¬ P x)) xs) )&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (¬((¬P xf) ∧ (todos (λx. (¬ P x)) xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (xf#xs) = (¬todos (λx. (¬ P x)) (xf#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg migtermor serrodcal crigomgom rubgonmar marpoldia1 paupeddeg danrodcha dancorgar pablucoto*)&lt;br /&gt;
&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn x [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Expresar la relación existente entre estaEn y algunos. &lt;br /&gt;
  Demostrar dicha relación de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar13:&lt;br /&gt;
 &amp;quot;(x=a) = ((λa. a=x) a)&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;estaEn x (a#xs) = ((a=x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
 also have H: &amp;quot;… = ((a=x) ∨ (algunos (λa. a=x) xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((λa. a=x) a) ∨ (algunos (λa. a=x) xs))&amp;quot; using auxiliar13  by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (λa. a=x) (a#xs))&amp;quot; by simp&lt;br /&gt;
 have C: &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using H by simp&lt;br /&gt;
 finally show &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos_2:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x=y) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn y (x # xs) = algunos (λx. x=y) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;estaEn y (x # xs) = (y=x ∨ estaEn y xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (y=x ∨ algunos (λx. x=y) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (x=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos (λx. x=y) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg dancorgar *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; &lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; estaEn x [] = algunos (λa. a = x) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (λa. a = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = (a = x ∨ estaEn x xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (a = x ∨ algunos (λa. a = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (λa. a = x) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn x [] = algunos (op = x) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (op = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = ((a = x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  (a = x ∨ algunos (op = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (op = x) (a # xs)&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a [] = algunos (op = a) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs &lt;br /&gt;
  assume HI: &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
      have &amp;quot;estaEn a (x # xs) = ((x = a) ∨ (estaEn a xs))&amp;quot; by simp&lt;br /&gt;
      also have &amp;quot;… = (x = a ∨ algunos (op = a) xs)&amp;quot; using HI by simp&lt;br /&gt;
      also have &amp;quot;… = ((op = a) x ∨ algunos (op = a) xs)&amp;quot; by (simp add:HOL.eq_commute)&lt;br /&gt;
      also have &amp;quot;… = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
      finally show &amp;quot;estaEn a (x # xs) = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x = y) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; estaEn y xs = algunos (λx. x = y) xs &amp;quot;&lt;br /&gt;
  have &amp;quot; estaEn y (a # xs) = (y = a ∨ estaEn y xs)&amp;quot;  by simp &lt;br /&gt;
  also have &amp;quot;... = (y = a ∨ algunos (λx. x = y) xs) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (a=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
  also have &amp;quot;... = (algunos (λx. x = y) (a#xs))&amp;quot;  by simp&lt;br /&gt;
  finally show &amp;quot;estaEn y (a # xs) = algunos (λx. x = y) (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=637</id>
		<title>Relación 4</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=637"/>
		<updated>2016-11-23T11:38:32Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R4: Cuantificadores sobre listas *}&lt;br /&gt;
&lt;br /&gt;
theory R4_Cuantificadores_sobre_listas&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la función &lt;br /&gt;
     todos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (todos p xs) se verifica si todos los elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     todos (λx. 1&amp;lt;length x) [[2,1,4],[1,3]]&lt;br /&gt;
     ¬todos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función todos es equivalente a la predefinida list_all. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p xs =   &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor dancorgar wilmorort marpoldia1 ferrenseg paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     algunos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (algunos p xs) se verifica si algunos elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     algunos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
     ¬algunos (λx. 1&amp;lt;length x) [[],[3]]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  Nota: La función algunos es equivalente a la predefinida list_ex. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*}&lt;br /&gt;
fun algunos  :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
   &amp;quot;algunos p []     = False&amp;quot;&lt;br /&gt;
| &amp;quot;algunos p (x#xs) = (p x ∨ algunos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (P a ∧ Q a ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?R (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar paupeddeg *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix y xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = ((P y ∧ Q y) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ Q y) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ todos P xs) ∧ (Q y ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = ((todos P (y#xs)) ∧ (todos Q (y#xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = (todos P (y#xs) ∧ todos Q (y#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
 next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
 have &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = (( P x ∧ Q x) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot;&lt;br /&gt;
     by (simp only: todos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot; by arith&lt;br /&gt;
 also have &amp;quot;((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs)) = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot;&lt;br /&gt;
          by arith (* Este paso es exactamente el mismo que el anterior, pero sin cualquiera de los dos no funciona el &amp;quot;finally show&amp;quot; *)&lt;br /&gt;
 have &amp;quot;… = (((P x)∧(todos P xs))∧((Q x)∧(todos Q xs)))&amp;quot; by simp&lt;br /&gt;
 have &amp;quot;… = ((todos P (x#xs))∧(todos Q (x#xs)))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = ((todos P (x#xs)) ∧ (todos Q (x#xs)))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) =  ((P a ∧ Q a) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs) ∧ todos Q (a#xs)) &amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = (P n ∧ Q n ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = P n ∧ Q n ∧ todos P xs ∧ todos Q xs&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;⋯ = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) =  ((P n ∧ Q n) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P n ∧ todos P xs) ∧ (Q n ∧ todos Q xs))&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = ((todos P(n#xs)) ∧ (todos Q(n#xs)))&amp;quot; by simp&lt;br /&gt;
&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (n#xs) = (todos P (n#xs) ∧ todos Q (n#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* wilmorort pablucoto crigomgom anaprarod juacabsou rubgonmar fraortmoy *}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp   &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ todos P xs ∧ Q a ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
also have &amp;quot;... = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp (* Este paso se puede obviar*)&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (x#xs) = ( P x ∧ Q x  ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ Q x  ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ todos P xs ∧ Q x ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (x#xs) = (todos P (x#xs) ∧ todos Q (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
{*danrodcha ivamenjim marpoldia1 migtermor ferrenseg wilmorort paupeddeg crigomgom anaprarod serrodcal juacabsou rubgonmar pablucoto fraortmoy josgarsan lucnovdos pabrodmac*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
{* anaprarod dancorgar *}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
apply (induct x)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg wilmorort dancorgar fraortmoy josgarsan lucnovdos*)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append1:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?P x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix a x&lt;br /&gt;
 assume HI: &amp;quot;?P x&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;?P (a#x)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a#(x@y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
lemma todos_append3:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P (x @ y)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom juacabsou anaprarod*)&lt;br /&gt;
 &lt;br /&gt;
lemma todos_append4:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI:&amp;quot;todos P (xs @ y) = (todos P xs ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((x # xs) @ y) = (P x ∧ todos P (xs @ y ))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ (todos P xs ∧ todos P y)) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P x ∧ todos P xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((x # xs) @ y) = (todos P (x # xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma todos_append5:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x )&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a x&lt;br /&gt;
  assume HI:&amp;quot;todos P (x @ y) = (todos P x ∧ todos P y) &amp;quot; &lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = ( P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot; ... =( P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by auto&lt;br /&gt;
  qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma todos_append6:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?Q x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix x a assume HI: &amp;quot;?Q x&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # x @ y)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?Q (a # x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*pabrodmac*}&lt;br /&gt;
lemma todos_append7:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a#x) @ y) = (todos P (a#x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim marpoldia1 serrodcal anaprarod paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; &lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: todos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom rubgonmar fraortmoy josgarsan danrodcha lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: todos_append)&lt;br /&gt;
 &lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: todos_append,auto)&lt;br /&gt;
&lt;br /&gt;
(* juacabsou *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
apply (induct xs,simp,simp add: todos_append,auto) done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto * )&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) (auto, simp_all add: todos_append) &lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) ( simp_all add: todos_append, auto)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by (simp only: rev.simps(1))&lt;br /&gt;
next &lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P (rev (a#xs)) = (todos P (rev xs @ [a]))&amp;quot; by (simp add: auxiliar)&lt;br /&gt;
 have &amp;quot;… = ((todos P (rev xs)) ∧ (todos P [a]))&amp;quot; by (simp add: todos_append)&lt;br /&gt;
 have &amp;quot;… =  (todos P (rev xs) ∧ P a)&amp;quot; by simp&lt;br /&gt;
 also have Aux: &amp;quot;… = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
 have Aux1: &amp;quot;… = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
 have &amp;quot;(todos P (rev xs) ∧ P a) = (P a ∧ todos P xs)&amp;quot; using Aux Aux1 by simp&lt;br /&gt;
 finally show &amp;quot;todos P (rev (a#xs)) = todos P (a#xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 ferrenseg crigomgom serrodcal juacabsou rubgonmar josgarsan pablucoto*)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = (todos P (a#xs))&amp;quot; by simp    &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((todos P (rev xs)) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume H1: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot; todos P (rev (a # xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show  &amp;quot;todos P (rev (a # xs)) = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs &amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = todos P (rev(xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a]) &amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = todos P ([a] @ xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (todos P(rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;... = todos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;todos P (rev (a#xs))= todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)  &lt;br /&gt;
(* es igual que las anteriores pero con el final también con patrones *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by auto&lt;br /&gt;
  next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a#xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;… = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;… = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar o refutar:&lt;br /&gt;
    algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim ferrenseg paupeddeg crigomgom serrodcal wilmorort juacabsou rubgonmar anaprarod marpoldia1 fraortmoy josgarsan danrodcha pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot; &lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo: P={a1}, Q={a2}, xs={a1,a2}. En este ejemplo:&lt;br /&gt;
   · &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot;&lt;br /&gt;
   · &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
assume H1: &amp;quot;xs = [a, b]&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;P a = True&amp;quot;&lt;br /&gt;
assume H3: &amp;quot;Q a = False&amp;quot;&lt;br /&gt;
assume H4: &amp;quot;P b = False&amp;quot;&lt;br /&gt;
assume H5: &amp;quot;Q b = True&amp;quot; &lt;br /&gt;
have F1: &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have F2: &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∧ Q x) xs ≠ (algunos P xs ∧ algunos Q xs)&amp;quot; using F1 F2 by simp&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom rubgonmar wilmorort anaprarod &lt;br /&gt;
    fraortmoy juacabsou paupeddeg josgarsan danrodcha pablucoto *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
(* anaprarod dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma AUX: &amp;quot;algunos (λa. P (f a)) xs = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (map f (x#xs)) = (algunos P ((f x)#(map f xs)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by (simp only: algunos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
   proof (cases)&lt;br /&gt;
    assume C1: &amp;quot;(P (f x))&amp;quot;&lt;br /&gt;
    have Aux: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = True&amp;quot; using C1 by simp&lt;br /&gt;
    have  Aux1: &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C1 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
              using Aux Aux1 by simp&lt;br /&gt;
   next&lt;br /&gt;
    assume C2: &amp;quot;¬(P (f x))&amp;quot;&lt;br /&gt;
    have Aux2: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = (algunos P (map f xs))&amp;quot; using C2 by simp&lt;br /&gt;
    have Aux3: &amp;quot;… = (algunos (P o f) xs)&amp;quot; using HI by (simp add: AUX)&lt;br /&gt;
    also have &amp;quot;… =  ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C2 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
            using Aux2 Aux3 by simp&lt;br /&gt;
   qed&lt;br /&gt;
 also have &amp;quot;… = (((P o f) x) ∨ (algunos (P o f) xs))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (map f (x#xs)) = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (map f (x # xs)) = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (((P ∘ f) x) ∨ (algunos (P ∘ f) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (a # xs)) = algunos P ((f a)#map f xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp &lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar anaprarod marpoldia1 juacabsou danrodcha paupeddeg josgarsan*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x # xs))  = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P ∘ f) x ∨ algunos (P ∘ f) xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* wilmorort pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?P xs&amp;quot; )&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (map f (a # xs))  = (P (f a) ∨ algunos P (map f xs))&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;... = (P (f a) ∨ algunos (P ∘ f) xs )&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = ((P ∘ f) a ∨ algunos (P ∘ f)xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot; algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have  &amp;quot;algunos P (map f (a # xs)) = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos (P ∘ f) [a] ∨  algunos (P ∘ f) xs )&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot; algunos P (map f (a # xs)) = algunos P ((f a)#(map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by blast&lt;br /&gt;
also have &amp;quot;… = ((P ∘ f) a ∨ algunos (P ∘ f) xs)&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;… = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P o f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x#xs)) = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x#xs)) = algunos (P o f) (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg crigomgom rubgonmar  wilmorort fraortmoy danrodcha pablucoto dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg marpoldia1 wilmorort dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (P a ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append2:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P ((x#xs) @ ys) = algunos P (x#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs) ∨ (algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (x#xs)) ∨ (algunos P ys))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P ((x#xs) @ ys) = (algunos P (x#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg*)&lt;br /&gt;
lemma algunos_append3:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ ( algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
lemma algunos_append4:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = ((algunos P [a] ∨ algunos P xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto*}&lt;br /&gt;
lemma algunos_append5:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P ((a#xs) @ ys) = algunos P (a#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 rubgonmar paupeddeg dancorgar *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: algunos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom danrodcha pablucoto josgarsan*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: algunos_append)&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: algunos_append,auto) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma auxiliar1:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto &lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (rev (x#xs)) = (algunos P (rev xs @ [x]))&amp;quot; using auxiliar1 by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (rev xs)) ∨ (algunos P [x]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (rev xs)))&amp;quot; by simp arith&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (rev (x#xs)) = (algunos P (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [x])&amp;quot; &lt;br /&gt;
      by (simp add: algunos_append)&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P x ∨ algunos P xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
 &lt;br /&gt;
(* ivamenjim marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = (algunos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI:&amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ (algunos P [a]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = ((algunos P xs) ∨ (algunos P [a]))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P [a]) ∨ (algunos P xs))&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot; algunos P (rev xs) = algunos P xs&amp;quot; &lt;br /&gt;
  have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (rev xs) ∨ algunos P [x])&amp;quot;  by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs  ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = algunos P (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;  (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P(rev xs) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;... = algunos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;algunos  P (rev (a#xs))= algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [a])&amp;quot; by (simp add:algunos_append)&lt;br /&gt;
also have &amp;quot;… = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;… = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Encontrar un término no trivial Z tal que sea cierta la &lt;br /&gt;
  siguiente ecuación:&lt;br /&gt;
     algunos (λx. P x ∨ Q x) xs = Z&lt;br /&gt;
  y demostrar la equivalencia de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos (λx. P x ∨ Q x) (x#xs) = (((λx. P x ∨ Q x) x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x ∨ Q x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot; by simp&lt;br /&gt;
 also have H1: &amp;quot;… = ((((λx. P x) x) ∨ (algunos (λx. P x) xs)) ∨ (((λx. Q x) x) ∨ (algunos (λx. Q x) xs)))&amp;quot;&lt;br /&gt;
          using HI by simp arith&lt;br /&gt;
 have H2: &amp;quot;… = ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               by simp&lt;br /&gt;
 have C: &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
         using H1 H2 by simp&lt;br /&gt;
 finally show &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos  (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. (P x ∨ Q x)) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = &lt;br /&gt;
      ((P x) ∨ (Q x) ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ (Q x) ∨ algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
      using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (((P x) ∨ algunos P xs) ∨ ((Q x) ∨ algunos Q xs))&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis &lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ algunos P xs ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* wilmorort danrodcha*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
(is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ Q a ∨  (¬ todos (λx. ¬ P x) xs ∨ ¬ todos (λx. ¬ Q x) xs))&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ ¬ todos (λx. ¬ P x) xs ∨ Q a ∨  ¬ todos (λx. ¬ Q x) xs )&amp;quot; by arith&lt;br /&gt;
finally show  &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (~ todos (λx. ¬ P x) (a # xs) ∨ ~ todos (λx. ¬ Q x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
    have 1:&amp;quot; (Q a ∨ algunos P xs) = (algunos P xs ∨ Q a)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = &lt;br /&gt;
     (algunos P [a] ∨ algunos Q [a] ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (Q a ∨ algunos P xs) ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ algunos P xs ∨ Q a ∨ algunos Q xs)&amp;quot; using 1 by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?R (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) [] ⟹ (algunos P [] ∧ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
  have F1: &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ ((P xf ∧ Q xf) ∨ algunos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have F2: &amp;quot;… ⟹ (P xf ∧ Q xf ∨ (algunos P xs ∧ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  have F3: &amp;quot;((P xf ∧ Q xf) ∨ (algunos P xs ∧ algunos Q xs)) ⟹ &lt;br /&gt;
    ((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs))&amp;quot; by blast&lt;br /&gt;
  have F4: &amp;quot;((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs)) ⟹ &lt;br /&gt;
     (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot; by simp&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot;&lt;br /&gt;
    using F1 F2 F3 F4 by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto crigomgom*)&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs) &amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q []) &amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot; algunos (λx. P x ∨ Q x) (a # xs) = ( P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ (algunos P xs ∨ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (((P a) ∨ algunos P xs) ∨ ((Q a) ∨ algunos Q xs))&amp;quot; by arith &lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs)) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort migtermor marpoldia1 crigomgom rubgonmar paupeddeg danrodcha pablucoto dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.2. Demostrar o refutar datalladamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom paupeddeg josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. ¬ P x) [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. ¬ P x) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (a # xs) = (P a ∨ (algunos P xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (¬ todos (λx. ¬ P x) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (a # xs) = (¬ todos (λx. ¬ P x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (x # xs) = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot;&lt;br /&gt;
  proof - &lt;br /&gt;
    have &amp;quot;algunos P (x # xs) = ((P x) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ ¬ todos (λx. (¬ P x)) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (¬ (P x) ∧ todos (λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto*}&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
    have &amp;quot;algunos P (a # xs) = (P a ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (¬ todos (λx. (¬ P x)) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬(¬(P a) ∧ todos(λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos(λx. (¬ P x)) (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (xf#xs) = ((P xf) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ( (P xf) ∨ (¬ todos (λx. (¬ P x)) xs) )&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (¬((¬P xf) ∧ (todos (λx. (¬ P x)) xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (xf#xs) = (¬todos (λx. (¬ P x)) (xf#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg migtermor serrodcal crigomgom rubgonmar marpoldia1 paupeddeg danrodcha dancorgar pablucoto*)&lt;br /&gt;
&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn x [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Expresar la relación existente entre estaEn y algunos. &lt;br /&gt;
  Demostrar dicha relación de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar13:&lt;br /&gt;
 &amp;quot;(x=a) = ((λa. a=x) a)&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;estaEn x (a#xs) = ((a=x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
 also have H: &amp;quot;… = ((a=x) ∨ (algunos (λa. a=x) xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((λa. a=x) a) ∨ (algunos (λa. a=x) xs))&amp;quot; using auxiliar13  by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (λa. a=x) (a#xs))&amp;quot; by simp&lt;br /&gt;
 have C: &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using H by simp&lt;br /&gt;
 finally show &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos_2:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x=y) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn y (x # xs) = algunos (λx. x=y) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;estaEn y (x # xs) = (y=x ∨ estaEn y xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (y=x ∨ algunos (λx. x=y) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (x=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos (λx. x=y) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg dancorgar *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; &lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; estaEn x [] = algunos (λa. a = x) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (λa. a = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = (a = x ∨ estaEn x xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (a = x ∨ algunos (λa. a = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (λa. a = x) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn x [] = algunos (op = x) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (op = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = ((a = x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  (a = x ∨ algunos (op = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (op = x) (a # xs)&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a [] = algunos (op = a) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs &lt;br /&gt;
  assume HI: &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
      have &amp;quot;estaEn a (x # xs) = ((x = a) ∨ (estaEn a xs))&amp;quot; by simp&lt;br /&gt;
      also have &amp;quot;… = (x = a ∨ algunos (op = a) xs)&amp;quot; using HI by simp&lt;br /&gt;
      also have &amp;quot;… = ((op = a) x ∨ algunos (op = a) xs)&amp;quot; by (simp add:HOL.eq_commute)&lt;br /&gt;
      also have &amp;quot;… = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
      finally show &amp;quot;estaEn a (x # xs) = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x = y) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; estaEn y xs = algunos (λx. x = y) xs &amp;quot;&lt;br /&gt;
  have &amp;quot; estaEn y (a # xs) = (y = a ∨ estaEn y xs)&amp;quot;  by simp &lt;br /&gt;
  also have &amp;quot;... = (y = a ∨ algunos (λx. x = y) xs) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (a=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
  also have &amp;quot;... = (algunos (λx. x = y) (a#xs))&amp;quot;  by simp&lt;br /&gt;
  finally show &amp;quot;estaEn y (a # xs) = algunos (λx. x = y) (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=636</id>
		<title>Relación 4</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=636"/>
		<updated>2016-11-23T11:30:01Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R4: Cuantificadores sobre listas *}&lt;br /&gt;
&lt;br /&gt;
theory R4_Cuantificadores_sobre_listas&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la función &lt;br /&gt;
     todos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (todos p xs) se verifica si todos los elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     todos (λx. 1&amp;lt;length x) [[2,1,4],[1,3]]&lt;br /&gt;
     ¬todos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función todos es equivalente a la predefinida list_all. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p xs =   &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor dancorgar wilmorort marpoldia1 ferrenseg paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     algunos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (algunos p xs) se verifica si algunos elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     algunos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
     ¬algunos (λx. 1&amp;lt;length x) [[],[3]]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  Nota: La función algunos es equivalente a la predefinida list_ex. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*}&lt;br /&gt;
fun algunos  :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
   &amp;quot;algunos p []     = False&amp;quot;&lt;br /&gt;
| &amp;quot;algunos p (x#xs) = (p x ∨ algunos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (P a ∧ Q a ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?R (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar paupeddeg *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix y xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = ((P y ∧ Q y) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ Q y) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ todos P xs) ∧ (Q y ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = ((todos P (y#xs)) ∧ (todos Q (y#xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = (todos P (y#xs) ∧ todos Q (y#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
 next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
 have &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = (( P x ∧ Q x) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot;&lt;br /&gt;
     by (simp only: todos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot; by arith&lt;br /&gt;
 also have &amp;quot;((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs)) = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot;&lt;br /&gt;
          by arith (* Este paso es exactamente el mismo que el anterior, pero sin cualquiera de los dos no funciona el &amp;quot;finally show&amp;quot; *)&lt;br /&gt;
 have &amp;quot;… = (((P x)∧(todos P xs))∧((Q x)∧(todos Q xs)))&amp;quot; by simp&lt;br /&gt;
 have &amp;quot;… = ((todos P (x#xs))∧(todos Q (x#xs)))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = ((todos P (x#xs)) ∧ (todos Q (x#xs)))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) =  ((P a ∧ Q a) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs) ∧ todos Q (a#xs)) &amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = (P n ∧ Q n ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = P n ∧ Q n ∧ todos P xs ∧ todos Q xs&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;⋯ = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) =  ((P n ∧ Q n) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P n ∧ todos P xs) ∧ (Q n ∧ todos Q xs))&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = ((todos P(n#xs)) ∧ (todos Q(n#xs)))&amp;quot; by simp&lt;br /&gt;
&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (n#xs) = (todos P (n#xs) ∧ todos Q (n#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* wilmorort pablucoto crigomgom anaprarod juacabsou rubgonmar fraortmoy *}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp   &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ todos P xs ∧ Q a ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
also have &amp;quot;... = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp (* Este paso se puede obviar*)&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (x#xs) = ( P x ∧ Q x  ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ Q x  ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ todos P xs ∧ Q x ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (x#xs) = (todos P (x#xs) ∧ todos Q (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
{*danrodcha ivamenjim marpoldia1 migtermor ferrenseg wilmorort paupeddeg crigomgom anaprarod serrodcal juacabsou rubgonmar pablucoto fraortmoy josgarsan lucnovdos*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
{* anaprarod dancorgar *}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
apply (induct x)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg wilmorort dancorgar fraortmoy josgarsan lucnovdos*)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append1:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?P x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix a x&lt;br /&gt;
 assume HI: &amp;quot;?P x&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;?P (a#x)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a#(x@y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
lemma todos_append3:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P (x @ y)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom juacabsou anaprarod*)&lt;br /&gt;
 &lt;br /&gt;
lemma todos_append4:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI:&amp;quot;todos P (xs @ y) = (todos P xs ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((x # xs) @ y) = (P x ∧ todos P (xs @ y ))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ (todos P xs ∧ todos P y)) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P x ∧ todos P xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((x # xs) @ y) = (todos P (x # xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma todos_append5:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x )&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a x&lt;br /&gt;
  assume HI:&amp;quot;todos P (x @ y) = (todos P x ∧ todos P y) &amp;quot; &lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = ( P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot; ... =( P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by auto&lt;br /&gt;
  qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma todos_append6:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?Q x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix x a assume HI: &amp;quot;?Q x&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # x @ y)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?Q (a # x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*pabrodmac*}&lt;br /&gt;
lemma todos_append7:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a#x) @ y) = (todos P (a#x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim marpoldia1 serrodcal anaprarod paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; &lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: todos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom rubgonmar fraortmoy josgarsan danrodcha lucnovdos pabrodmac*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: todos_append)&lt;br /&gt;
 &lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: todos_append,auto)&lt;br /&gt;
&lt;br /&gt;
(* juacabsou *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
apply (induct xs,simp,simp add: todos_append,auto) done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto * )&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) (auto, simp_all add: todos_append) &lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) ( simp_all add: todos_append, auto)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by (simp only: rev.simps(1))&lt;br /&gt;
next &lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P (rev (a#xs)) = (todos P (rev xs @ [a]))&amp;quot; by (simp add: auxiliar)&lt;br /&gt;
 have &amp;quot;… = ((todos P (rev xs)) ∧ (todos P [a]))&amp;quot; by (simp add: todos_append)&lt;br /&gt;
 have &amp;quot;… =  (todos P (rev xs) ∧ P a)&amp;quot; by simp&lt;br /&gt;
 also have Aux: &amp;quot;… = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
 have Aux1: &amp;quot;… = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
 have &amp;quot;(todos P (rev xs) ∧ P a) = (P a ∧ todos P xs)&amp;quot; using Aux Aux1 by simp&lt;br /&gt;
 finally show &amp;quot;todos P (rev (a#xs)) = todos P (a#xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 ferrenseg crigomgom serrodcal juacabsou rubgonmar josgarsan pablucoto*)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = (todos P (a#xs))&amp;quot; by simp    &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((todos P (rev xs)) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume H1: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot; todos P (rev (a # xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show  &amp;quot;todos P (rev (a # xs)) = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs &amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = todos P (rev(xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a]) &amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = todos P ([a] @ xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (todos P(rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;... = todos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;todos P (rev (a#xs))= todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)  &lt;br /&gt;
(* es igual que las anteriores pero con el final también con patrones *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by auto&lt;br /&gt;
  next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a#xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;… = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;… = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar o refutar:&lt;br /&gt;
    algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim ferrenseg paupeddeg crigomgom serrodcal wilmorort juacabsou rubgonmar anaprarod marpoldia1 fraortmoy josgarsan danrodcha pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot; &lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo: P={a1}, Q={a2}, xs={a1,a2}. En este ejemplo:&lt;br /&gt;
   · &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot;&lt;br /&gt;
   · &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
assume H1: &amp;quot;xs = [a, b]&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;P a = True&amp;quot;&lt;br /&gt;
assume H3: &amp;quot;Q a = False&amp;quot;&lt;br /&gt;
assume H4: &amp;quot;P b = False&amp;quot;&lt;br /&gt;
assume H5: &amp;quot;Q b = True&amp;quot; &lt;br /&gt;
have F1: &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have F2: &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∧ Q x) xs ≠ (algunos P xs ∧ algunos Q xs)&amp;quot; using F1 F2 by simp&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom rubgonmar wilmorort anaprarod &lt;br /&gt;
    fraortmoy juacabsou paupeddeg josgarsan danrodcha pablucoto *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
(* anaprarod dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma AUX: &amp;quot;algunos (λa. P (f a)) xs = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (map f (x#xs)) = (algunos P ((f x)#(map f xs)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by (simp only: algunos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
   proof (cases)&lt;br /&gt;
    assume C1: &amp;quot;(P (f x))&amp;quot;&lt;br /&gt;
    have Aux: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = True&amp;quot; using C1 by simp&lt;br /&gt;
    have  Aux1: &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C1 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
              using Aux Aux1 by simp&lt;br /&gt;
   next&lt;br /&gt;
    assume C2: &amp;quot;¬(P (f x))&amp;quot;&lt;br /&gt;
    have Aux2: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = (algunos P (map f xs))&amp;quot; using C2 by simp&lt;br /&gt;
    have Aux3: &amp;quot;… = (algunos (P o f) xs)&amp;quot; using HI by (simp add: AUX)&lt;br /&gt;
    also have &amp;quot;… =  ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C2 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
            using Aux2 Aux3 by simp&lt;br /&gt;
   qed&lt;br /&gt;
 also have &amp;quot;… = (((P o f) x) ∨ (algunos (P o f) xs))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (map f (x#xs)) = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (map f (x # xs)) = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (((P ∘ f) x) ∨ (algunos (P ∘ f) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (a # xs)) = algunos P ((f a)#map f xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp &lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar anaprarod marpoldia1 juacabsou danrodcha paupeddeg josgarsan*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x # xs))  = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P ∘ f) x ∨ algunos (P ∘ f) xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* wilmorort pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?P xs&amp;quot; )&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (map f (a # xs))  = (P (f a) ∨ algunos P (map f xs))&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;... = (P (f a) ∨ algunos (P ∘ f) xs )&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = ((P ∘ f) a ∨ algunos (P ∘ f)xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot; algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have  &amp;quot;algunos P (map f (a # xs)) = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos (P ∘ f) [a] ∨  algunos (P ∘ f) xs )&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot; algunos P (map f (a # xs)) = algunos P ((f a)#(map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by blast&lt;br /&gt;
also have &amp;quot;… = ((P ∘ f) a ∨ algunos (P ∘ f) xs)&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;… = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P o f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x#xs)) = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x#xs)) = algunos (P o f) (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg crigomgom rubgonmar  wilmorort fraortmoy danrodcha pablucoto dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg marpoldia1 wilmorort dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (P a ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append2:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P ((x#xs) @ ys) = algunos P (x#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs) ∨ (algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (x#xs)) ∨ (algunos P ys))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P ((x#xs) @ ys) = (algunos P (x#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg*)&lt;br /&gt;
lemma algunos_append3:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ ( algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
lemma algunos_append4:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = ((algunos P [a] ∨ algunos P xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto*}&lt;br /&gt;
lemma algunos_append5:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P ((a#xs) @ ys) = algunos P (a#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 rubgonmar paupeddeg dancorgar *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: algunos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom danrodcha pablucoto josgarsan*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: algunos_append)&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: algunos_append,auto) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma auxiliar1:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto &lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (rev (x#xs)) = (algunos P (rev xs @ [x]))&amp;quot; using auxiliar1 by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (rev xs)) ∨ (algunos P [x]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (rev xs)))&amp;quot; by simp arith&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (rev (x#xs)) = (algunos P (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [x])&amp;quot; &lt;br /&gt;
      by (simp add: algunos_append)&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P x ∨ algunos P xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
 &lt;br /&gt;
(* ivamenjim marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = (algunos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI:&amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ (algunos P [a]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = ((algunos P xs) ∨ (algunos P [a]))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P [a]) ∨ (algunos P xs))&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot; algunos P (rev xs) = algunos P xs&amp;quot; &lt;br /&gt;
  have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (rev xs) ∨ algunos P [x])&amp;quot;  by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs  ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = algunos P (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;  (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P(rev xs) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;... = algunos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;algunos  P (rev (a#xs))= algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [a])&amp;quot; by (simp add:algunos_append)&lt;br /&gt;
also have &amp;quot;… = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;… = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Encontrar un término no trivial Z tal que sea cierta la &lt;br /&gt;
  siguiente ecuación:&lt;br /&gt;
     algunos (λx. P x ∨ Q x) xs = Z&lt;br /&gt;
  y demostrar la equivalencia de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos (λx. P x ∨ Q x) (x#xs) = (((λx. P x ∨ Q x) x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x ∨ Q x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot; by simp&lt;br /&gt;
 also have H1: &amp;quot;… = ((((λx. P x) x) ∨ (algunos (λx. P x) xs)) ∨ (((λx. Q x) x) ∨ (algunos (λx. Q x) xs)))&amp;quot;&lt;br /&gt;
          using HI by simp arith&lt;br /&gt;
 have H2: &amp;quot;… = ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               by simp&lt;br /&gt;
 have C: &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
         using H1 H2 by simp&lt;br /&gt;
 finally show &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos  (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. (P x ∨ Q x)) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = &lt;br /&gt;
      ((P x) ∨ (Q x) ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ (Q x) ∨ algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
      using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (((P x) ∨ algunos P xs) ∨ ((Q x) ∨ algunos Q xs))&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis &lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ algunos P xs ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* wilmorort danrodcha*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
(is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ Q a ∨  (¬ todos (λx. ¬ P x) xs ∨ ¬ todos (λx. ¬ Q x) xs))&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ ¬ todos (λx. ¬ P x) xs ∨ Q a ∨  ¬ todos (λx. ¬ Q x) xs )&amp;quot; by arith&lt;br /&gt;
finally show  &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (~ todos (λx. ¬ P x) (a # xs) ∨ ~ todos (λx. ¬ Q x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
    have 1:&amp;quot; (Q a ∨ algunos P xs) = (algunos P xs ∨ Q a)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = &lt;br /&gt;
     (algunos P [a] ∨ algunos Q [a] ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (Q a ∨ algunos P xs) ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ algunos P xs ∨ Q a ∨ algunos Q xs)&amp;quot; using 1 by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?R (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) [] ⟹ (algunos P [] ∧ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
  have F1: &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ ((P xf ∧ Q xf) ∨ algunos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have F2: &amp;quot;… ⟹ (P xf ∧ Q xf ∨ (algunos P xs ∧ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  have F3: &amp;quot;((P xf ∧ Q xf) ∨ (algunos P xs ∧ algunos Q xs)) ⟹ &lt;br /&gt;
    ((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs))&amp;quot; by blast&lt;br /&gt;
  have F4: &amp;quot;((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs)) ⟹ &lt;br /&gt;
     (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot; by simp&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot;&lt;br /&gt;
    using F1 F2 F3 F4 by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto crigomgom*)&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs) &amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q []) &amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot; algunos (λx. P x ∨ Q x) (a # xs) = ( P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ (algunos P xs ∨ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (((P a) ∨ algunos P xs) ∨ ((Q a) ∨ algunos Q xs))&amp;quot; by arith &lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs)) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort migtermor marpoldia1 crigomgom rubgonmar paupeddeg danrodcha pablucoto dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.2. Demostrar o refutar datalladamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom paupeddeg josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. ¬ P x) [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. ¬ P x) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (a # xs) = (P a ∨ (algunos P xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (¬ todos (λx. ¬ P x) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (a # xs) = (¬ todos (λx. ¬ P x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (x # xs) = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot;&lt;br /&gt;
  proof - &lt;br /&gt;
    have &amp;quot;algunos P (x # xs) = ((P x) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ ¬ todos (λx. (¬ P x)) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (¬ (P x) ∧ todos (λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto*}&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
    have &amp;quot;algunos P (a # xs) = (P a ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (¬ todos (λx. (¬ P x)) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬(¬(P a) ∧ todos(λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos(λx. (¬ P x)) (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (xf#xs) = ((P xf) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ( (P xf) ∨ (¬ todos (λx. (¬ P x)) xs) )&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (¬((¬P xf) ∧ (todos (λx. (¬ P x)) xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (xf#xs) = (¬todos (λx. (¬ P x)) (xf#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg migtermor serrodcal crigomgom rubgonmar marpoldia1 paupeddeg danrodcha dancorgar pablucoto*)&lt;br /&gt;
&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn x [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Expresar la relación existente entre estaEn y algunos. &lt;br /&gt;
  Demostrar dicha relación de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar13:&lt;br /&gt;
 &amp;quot;(x=a) = ((λa. a=x) a)&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;estaEn x (a#xs) = ((a=x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
 also have H: &amp;quot;… = ((a=x) ∨ (algunos (λa. a=x) xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((λa. a=x) a) ∨ (algunos (λa. a=x) xs))&amp;quot; using auxiliar13  by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (λa. a=x) (a#xs))&amp;quot; by simp&lt;br /&gt;
 have C: &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using H by simp&lt;br /&gt;
 finally show &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos_2:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x=y) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn y (x # xs) = algunos (λx. x=y) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;estaEn y (x # xs) = (y=x ∨ estaEn y xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (y=x ∨ algunos (λx. x=y) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (x=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos (λx. x=y) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg dancorgar *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; &lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; estaEn x [] = algunos (λa. a = x) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (λa. a = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = (a = x ∨ estaEn x xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (a = x ∨ algunos (λa. a = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (λa. a = x) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn x [] = algunos (op = x) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (op = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = ((a = x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  (a = x ∨ algunos (op = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (op = x) (a # xs)&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a [] = algunos (op = a) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs &lt;br /&gt;
  assume HI: &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
      have &amp;quot;estaEn a (x # xs) = ((x = a) ∨ (estaEn a xs))&amp;quot; by simp&lt;br /&gt;
      also have &amp;quot;… = (x = a ∨ algunos (op = a) xs)&amp;quot; using HI by simp&lt;br /&gt;
      also have &amp;quot;… = ((op = a) x ∨ algunos (op = a) xs)&amp;quot; by (simp add:HOL.eq_commute)&lt;br /&gt;
      also have &amp;quot;… = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
      finally show &amp;quot;estaEn a (x # xs) = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x = y) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; estaEn y xs = algunos (λx. x = y) xs &amp;quot;&lt;br /&gt;
  have &amp;quot; estaEn y (a # xs) = (y = a ∨ estaEn y xs)&amp;quot;  by simp &lt;br /&gt;
  also have &amp;quot;... = (y = a ∨ algunos (λx. x = y) xs) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (a=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
  also have &amp;quot;... = (algunos (λx. x = y) (a#xs))&amp;quot;  by simp&lt;br /&gt;
  finally show &amp;quot;estaEn y (a # xs) = algunos (λx. x = y) (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=635</id>
		<title>Relación 4</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=635"/>
		<updated>2016-11-23T11:28:25Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R4: Cuantificadores sobre listas *}&lt;br /&gt;
&lt;br /&gt;
theory R4_Cuantificadores_sobre_listas&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la función &lt;br /&gt;
     todos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (todos p xs) se verifica si todos los elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     todos (λx. 1&amp;lt;length x) [[2,1,4],[1,3]]&lt;br /&gt;
     ¬todos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función todos es equivalente a la predefinida list_all. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p xs =   &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor dancorgar wilmorort marpoldia1 ferrenseg paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     algunos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (algunos p xs) se verifica si algunos elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     algunos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
     ¬algunos (λx. 1&amp;lt;length x) [[],[3]]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  Nota: La función algunos es equivalente a la predefinida list_ex. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*}&lt;br /&gt;
fun algunos  :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
   &amp;quot;algunos p []     = False&amp;quot;&lt;br /&gt;
| &amp;quot;algunos p (x#xs) = (p x ∨ algunos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (P a ∧ Q a ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?R (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar paupeddeg *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix y xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = ((P y ∧ Q y) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ Q y) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ todos P xs) ∧ (Q y ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = ((todos P (y#xs)) ∧ (todos Q (y#xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = (todos P (y#xs) ∧ todos Q (y#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
 next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
 have &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = (( P x ∧ Q x) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot;&lt;br /&gt;
     by (simp only: todos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot; by arith&lt;br /&gt;
 also have &amp;quot;((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs)) = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot;&lt;br /&gt;
          by arith (* Este paso es exactamente el mismo que el anterior, pero sin cualquiera de los dos no funciona el &amp;quot;finally show&amp;quot; *)&lt;br /&gt;
 have &amp;quot;… = (((P x)∧(todos P xs))∧((Q x)∧(todos Q xs)))&amp;quot; by simp&lt;br /&gt;
 have &amp;quot;… = ((todos P (x#xs))∧(todos Q (x#xs)))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = ((todos P (x#xs)) ∧ (todos Q (x#xs)))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) =  ((P a ∧ Q a) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs) ∧ todos Q (a#xs)) &amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = (P n ∧ Q n ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = P n ∧ Q n ∧ todos P xs ∧ todos Q xs&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;⋯ = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) =  ((P n ∧ Q n) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P n ∧ todos P xs) ∧ (Q n ∧ todos Q xs))&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = ((todos P(n#xs)) ∧ (todos Q(n#xs)))&amp;quot; by simp&lt;br /&gt;
&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (n#xs) = (todos P (n#xs) ∧ todos Q (n#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* wilmorort pablucoto crigomgom anaprarod juacabsou rubgonmar fraortmoy *}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp   &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ todos P xs ∧ Q a ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
also have &amp;quot;... = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp (* Este paso se puede obviar*)&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (x#xs) = ( P x ∧ Q x  ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ Q x  ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ todos P xs ∧ Q x ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (x#xs) = (todos P (x#xs) ∧ todos Q (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
{*danrodcha ivamenjim marpoldia1 migtermor ferrenseg wilmorort paupeddeg crigomgom anaprarod serrodcal juacabsou rubgonmar pablucoto fraortmoy josgarsan lucnovdos*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
{* anaprarod dancorgar *}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
apply (induct x)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg wilmorort dancorgar fraortmoy josgarsan lucnovdos*)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append1:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?P x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix a x&lt;br /&gt;
 assume HI: &amp;quot;?P x&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;?P (a#x)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a#(x@y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
lemma todos_append3:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P (x @ y)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom juacabsou anaprarod*)&lt;br /&gt;
 &lt;br /&gt;
lemma todos_append4:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI:&amp;quot;todos P (xs @ y) = (todos P xs ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((x # xs) @ y) = (P x ∧ todos P (xs @ y ))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ (todos P xs ∧ todos P y)) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P x ∧ todos P xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((x # xs) @ y) = (todos P (x # xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma todos_append5:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x )&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a x&lt;br /&gt;
  assume HI:&amp;quot;todos P (x @ y) = (todos P x ∧ todos P y) &amp;quot; &lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = ( P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot; ... =( P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by auto&lt;br /&gt;
  qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma todos_append6:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?Q x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix x a assume HI: &amp;quot;?Q x&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # x @ y)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?Q (a # x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*pabrodmac*}&lt;br /&gt;
lemma todos_append7:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a#x) @ y) = (todos P (a#x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim marpoldia1 serrodcal anaprarod paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; &lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: todos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom rubgonmar fraortmoy josgarsan danrodcha lucnovdos*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: todos_append)&lt;br /&gt;
 &lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: todos_append,auto)&lt;br /&gt;
&lt;br /&gt;
(* juacabsou *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
apply (induct xs,simp,simp add: todos_append,auto) done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto * )&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) (auto, simp_all add: todos_append) &lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) ( simp_all add: todos_append, auto)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by (simp only: rev.simps(1))&lt;br /&gt;
next &lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P (rev (a#xs)) = (todos P (rev xs @ [a]))&amp;quot; by (simp add: auxiliar)&lt;br /&gt;
 have &amp;quot;… = ((todos P (rev xs)) ∧ (todos P [a]))&amp;quot; by (simp add: todos_append)&lt;br /&gt;
 have &amp;quot;… =  (todos P (rev xs) ∧ P a)&amp;quot; by simp&lt;br /&gt;
 also have Aux: &amp;quot;… = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
 have Aux1: &amp;quot;… = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
 have &amp;quot;(todos P (rev xs) ∧ P a) = (P a ∧ todos P xs)&amp;quot; using Aux Aux1 by simp&lt;br /&gt;
 finally show &amp;quot;todos P (rev (a#xs)) = todos P (a#xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 ferrenseg crigomgom serrodcal juacabsou rubgonmar josgarsan pablucoto*)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = (todos P (a#xs))&amp;quot; by simp    &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((todos P (rev xs)) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume H1: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot; todos P (rev (a # xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show  &amp;quot;todos P (rev (a # xs)) = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs &amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = todos P (rev(xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a]) &amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = todos P ([a] @ xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (todos P(rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;... = todos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;todos P (rev (a#xs))= todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)  &lt;br /&gt;
(* es igual que las anteriores pero con el final también con patrones *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by auto&lt;br /&gt;
  next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a#xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;… = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;… = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar o refutar:&lt;br /&gt;
    algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim ferrenseg paupeddeg crigomgom serrodcal wilmorort juacabsou rubgonmar anaprarod marpoldia1 fraortmoy josgarsan danrodcha pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot; &lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo: P={a1}, Q={a2}, xs={a1,a2}. En este ejemplo:&lt;br /&gt;
   · &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot;&lt;br /&gt;
   · &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
assume H1: &amp;quot;xs = [a, b]&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;P a = True&amp;quot;&lt;br /&gt;
assume H3: &amp;quot;Q a = False&amp;quot;&lt;br /&gt;
assume H4: &amp;quot;P b = False&amp;quot;&lt;br /&gt;
assume H5: &amp;quot;Q b = True&amp;quot; &lt;br /&gt;
have F1: &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have F2: &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∧ Q x) xs ≠ (algunos P xs ∧ algunos Q xs)&amp;quot; using F1 F2 by simp&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom rubgonmar wilmorort anaprarod &lt;br /&gt;
    fraortmoy juacabsou paupeddeg josgarsan danrodcha pablucoto *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
(* anaprarod dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma AUX: &amp;quot;algunos (λa. P (f a)) xs = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (map f (x#xs)) = (algunos P ((f x)#(map f xs)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by (simp only: algunos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
   proof (cases)&lt;br /&gt;
    assume C1: &amp;quot;(P (f x))&amp;quot;&lt;br /&gt;
    have Aux: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = True&amp;quot; using C1 by simp&lt;br /&gt;
    have  Aux1: &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C1 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
              using Aux Aux1 by simp&lt;br /&gt;
   next&lt;br /&gt;
    assume C2: &amp;quot;¬(P (f x))&amp;quot;&lt;br /&gt;
    have Aux2: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = (algunos P (map f xs))&amp;quot; using C2 by simp&lt;br /&gt;
    have Aux3: &amp;quot;… = (algunos (P o f) xs)&amp;quot; using HI by (simp add: AUX)&lt;br /&gt;
    also have &amp;quot;… =  ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C2 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
            using Aux2 Aux3 by simp&lt;br /&gt;
   qed&lt;br /&gt;
 also have &amp;quot;… = (((P o f) x) ∨ (algunos (P o f) xs))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (map f (x#xs)) = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (map f (x # xs)) = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (((P ∘ f) x) ∨ (algunos (P ∘ f) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (a # xs)) = algunos P ((f a)#map f xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp &lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar anaprarod marpoldia1 juacabsou danrodcha paupeddeg josgarsan*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x # xs))  = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P ∘ f) x ∨ algunos (P ∘ f) xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* wilmorort pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?P xs&amp;quot; )&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (map f (a # xs))  = (P (f a) ∨ algunos P (map f xs))&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;... = (P (f a) ∨ algunos (P ∘ f) xs )&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = ((P ∘ f) a ∨ algunos (P ∘ f)xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot; algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have  &amp;quot;algunos P (map f (a # xs)) = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos (P ∘ f) [a] ∨  algunos (P ∘ f) xs )&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot; algunos P (map f (a # xs)) = algunos P ((f a)#(map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by blast&lt;br /&gt;
also have &amp;quot;… = ((P ∘ f) a ∨ algunos (P ∘ f) xs)&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;… = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P o f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x#xs)) = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x#xs)) = algunos (P o f) (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg crigomgom rubgonmar  wilmorort fraortmoy danrodcha pablucoto dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg marpoldia1 wilmorort dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (P a ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append2:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P ((x#xs) @ ys) = algunos P (x#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs) ∨ (algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (x#xs)) ∨ (algunos P ys))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P ((x#xs) @ ys) = (algunos P (x#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg*)&lt;br /&gt;
lemma algunos_append3:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ ( algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
lemma algunos_append4:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = ((algunos P [a] ∨ algunos P xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto*}&lt;br /&gt;
lemma algunos_append5:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P ((a#xs) @ ys) = algunos P (a#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 rubgonmar paupeddeg dancorgar *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: algunos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom danrodcha pablucoto josgarsan*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: algunos_append)&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: algunos_append,auto) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma auxiliar1:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto &lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (rev (x#xs)) = (algunos P (rev xs @ [x]))&amp;quot; using auxiliar1 by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (rev xs)) ∨ (algunos P [x]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (rev xs)))&amp;quot; by simp arith&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (rev (x#xs)) = (algunos P (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [x])&amp;quot; &lt;br /&gt;
      by (simp add: algunos_append)&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P x ∨ algunos P xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
 &lt;br /&gt;
(* ivamenjim marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = (algunos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI:&amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ (algunos P [a]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = ((algunos P xs) ∨ (algunos P [a]))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P [a]) ∨ (algunos P xs))&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot; algunos P (rev xs) = algunos P xs&amp;quot; &lt;br /&gt;
  have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (rev xs) ∨ algunos P [x])&amp;quot;  by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs  ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = algunos P (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;  (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P(rev xs) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;... = algunos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;algunos  P (rev (a#xs))= algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [a])&amp;quot; by (simp add:algunos_append)&lt;br /&gt;
also have &amp;quot;… = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;… = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Encontrar un término no trivial Z tal que sea cierta la &lt;br /&gt;
  siguiente ecuación:&lt;br /&gt;
     algunos (λx. P x ∨ Q x) xs = Z&lt;br /&gt;
  y demostrar la equivalencia de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos (λx. P x ∨ Q x) (x#xs) = (((λx. P x ∨ Q x) x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x ∨ Q x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot; by simp&lt;br /&gt;
 also have H1: &amp;quot;… = ((((λx. P x) x) ∨ (algunos (λx. P x) xs)) ∨ (((λx. Q x) x) ∨ (algunos (λx. Q x) xs)))&amp;quot;&lt;br /&gt;
          using HI by simp arith&lt;br /&gt;
 have H2: &amp;quot;… = ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               by simp&lt;br /&gt;
 have C: &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
         using H1 H2 by simp&lt;br /&gt;
 finally show &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos  (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. (P x ∨ Q x)) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = &lt;br /&gt;
      ((P x) ∨ (Q x) ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ (Q x) ∨ algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
      using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (((P x) ∨ algunos P xs) ∨ ((Q x) ∨ algunos Q xs))&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis &lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ algunos P xs ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* wilmorort danrodcha*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
(is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ Q a ∨  (¬ todos (λx. ¬ P x) xs ∨ ¬ todos (λx. ¬ Q x) xs))&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ ¬ todos (λx. ¬ P x) xs ∨ Q a ∨  ¬ todos (λx. ¬ Q x) xs )&amp;quot; by arith&lt;br /&gt;
finally show  &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (~ todos (λx. ¬ P x) (a # xs) ∨ ~ todos (λx. ¬ Q x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
    have 1:&amp;quot; (Q a ∨ algunos P xs) = (algunos P xs ∨ Q a)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = &lt;br /&gt;
     (algunos P [a] ∨ algunos Q [a] ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (Q a ∨ algunos P xs) ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ algunos P xs ∨ Q a ∨ algunos Q xs)&amp;quot; using 1 by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?R (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) [] ⟹ (algunos P [] ∧ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
  have F1: &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ ((P xf ∧ Q xf) ∨ algunos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have F2: &amp;quot;… ⟹ (P xf ∧ Q xf ∨ (algunos P xs ∧ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  have F3: &amp;quot;((P xf ∧ Q xf) ∨ (algunos P xs ∧ algunos Q xs)) ⟹ &lt;br /&gt;
    ((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs))&amp;quot; by blast&lt;br /&gt;
  have F4: &amp;quot;((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs)) ⟹ &lt;br /&gt;
     (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot; by simp&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot;&lt;br /&gt;
    using F1 F2 F3 F4 by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto crigomgom*)&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs) &amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q []) &amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot; algunos (λx. P x ∨ Q x) (a # xs) = ( P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ (algunos P xs ∨ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (((P a) ∨ algunos P xs) ∨ ((Q a) ∨ algunos Q xs))&amp;quot; by arith &lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs)) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort migtermor marpoldia1 crigomgom rubgonmar paupeddeg danrodcha pablucoto dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.2. Demostrar o refutar datalladamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom paupeddeg josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. ¬ P x) [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. ¬ P x) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (a # xs) = (P a ∨ (algunos P xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (¬ todos (λx. ¬ P x) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (a # xs) = (¬ todos (λx. ¬ P x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (x # xs) = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot;&lt;br /&gt;
  proof - &lt;br /&gt;
    have &amp;quot;algunos P (x # xs) = ((P x) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ ¬ todos (λx. (¬ P x)) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (¬ (P x) ∧ todos (λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto*}&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
    have &amp;quot;algunos P (a # xs) = (P a ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (¬ todos (λx. (¬ P x)) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬(¬(P a) ∧ todos(λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos(λx. (¬ P x)) (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (xf#xs) = ((P xf) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ( (P xf) ∨ (¬ todos (λx. (¬ P x)) xs) )&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (¬((¬P xf) ∧ (todos (λx. (¬ P x)) xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (xf#xs) = (¬todos (λx. (¬ P x)) (xf#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg migtermor serrodcal crigomgom rubgonmar marpoldia1 paupeddeg danrodcha dancorgar pablucoto*)&lt;br /&gt;
&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn x [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Expresar la relación existente entre estaEn y algunos. &lt;br /&gt;
  Demostrar dicha relación de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar13:&lt;br /&gt;
 &amp;quot;(x=a) = ((λa. a=x) a)&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;estaEn x (a#xs) = ((a=x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
 also have H: &amp;quot;… = ((a=x) ∨ (algunos (λa. a=x) xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((λa. a=x) a) ∨ (algunos (λa. a=x) xs))&amp;quot; using auxiliar13  by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (λa. a=x) (a#xs))&amp;quot; by simp&lt;br /&gt;
 have C: &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using H by simp&lt;br /&gt;
 finally show &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos_2:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x=y) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn y (x # xs) = algunos (λx. x=y) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;estaEn y (x # xs) = (y=x ∨ estaEn y xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (y=x ∨ algunos (λx. x=y) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (x=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos (λx. x=y) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg dancorgar *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; &lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; estaEn x [] = algunos (λa. a = x) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (λa. a = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = (a = x ∨ estaEn x xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (a = x ∨ algunos (λa. a = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (λa. a = x) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn x [] = algunos (op = x) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (op = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = ((a = x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  (a = x ∨ algunos (op = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (op = x) (a # xs)&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a [] = algunos (op = a) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs &lt;br /&gt;
  assume HI: &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
      have &amp;quot;estaEn a (x # xs) = ((x = a) ∨ (estaEn a xs))&amp;quot; by simp&lt;br /&gt;
      also have &amp;quot;… = (x = a ∨ algunos (op = a) xs)&amp;quot; using HI by simp&lt;br /&gt;
      also have &amp;quot;… = ((op = a) x ∨ algunos (op = a) xs)&amp;quot; by (simp add:HOL.eq_commute)&lt;br /&gt;
      also have &amp;quot;… = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
      finally show &amp;quot;estaEn a (x # xs) = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x = y) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; estaEn y xs = algunos (λx. x = y) xs &amp;quot;&lt;br /&gt;
  have &amp;quot; estaEn y (a # xs) = (y = a ∨ estaEn y xs)&amp;quot;  by simp &lt;br /&gt;
  also have &amp;quot;... = (y = a ∨ algunos (λx. x = y) xs) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (a=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
  also have &amp;quot;... = (algunos (λx. x = y) (a#xs))&amp;quot;  by simp&lt;br /&gt;
  finally show &amp;quot;estaEn y (a # xs) = algunos (λx. x = y) (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=634</id>
		<title>Relación 4</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=634"/>
		<updated>2016-11-23T11:06:29Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R4: Cuantificadores sobre listas *}&lt;br /&gt;
&lt;br /&gt;
theory R4_Cuantificadores_sobre_listas&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la función &lt;br /&gt;
     todos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (todos p xs) se verifica si todos los elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     todos (λx. 1&amp;lt;length x) [[2,1,4],[1,3]]&lt;br /&gt;
     ¬todos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función todos es equivalente a la predefinida list_all. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p xs =   &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor dancorgar wilmorort marpoldia1 ferrenseg paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     algunos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (algunos p xs) se verifica si algunos elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     algunos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
     ¬algunos (λx. 1&amp;lt;length x) [[],[3]]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  Nota: La función algunos es equivalente a la predefinida list_ex. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*}&lt;br /&gt;
fun algunos  :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
   &amp;quot;algunos p []     = False&amp;quot;&lt;br /&gt;
| &amp;quot;algunos p (x#xs) = (p x ∨ algunos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (P a ∧ Q a ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?R (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar paupeddeg *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix y xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = ((P y ∧ Q y) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ Q y) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ todos P xs) ∧ (Q y ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = ((todos P (y#xs)) ∧ (todos Q (y#xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = (todos P (y#xs) ∧ todos Q (y#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
 next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
 have &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = (( P x ∧ Q x) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot;&lt;br /&gt;
     by (simp only: todos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot; by arith&lt;br /&gt;
 also have &amp;quot;((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs)) = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot;&lt;br /&gt;
          by arith (* Este paso es exactamente el mismo que el anterior, pero sin cualquiera de los dos no funciona el &amp;quot;finally show&amp;quot; *)&lt;br /&gt;
 have &amp;quot;… = (((P x)∧(todos P xs))∧((Q x)∧(todos Q xs)))&amp;quot; by simp&lt;br /&gt;
 have &amp;quot;… = ((todos P (x#xs))∧(todos Q (x#xs)))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = ((todos P (x#xs)) ∧ (todos Q (x#xs)))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) =  ((P a ∧ Q a) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs) ∧ todos Q (a#xs)) &amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = (P n ∧ Q n ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = P n ∧ Q n ∧ todos P xs ∧ todos Q xs&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;⋯ = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) =  ((P n ∧ Q n) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P n ∧ todos P xs) ∧ (Q n ∧ todos Q xs))&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = ((todos P(n#xs)) ∧ (todos Q(n#xs)))&amp;quot; by simp&lt;br /&gt;
&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (n#xs) = (todos P (n#xs) ∧ todos Q (n#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* wilmorort pablucoto crigomgom anaprarod juacabsou rubgonmar fraortmoy *}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp   &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ todos P xs ∧ Q a ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
also have &amp;quot;... = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp (* Este paso se puede obviar*)&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (x#xs) = ( P x ∧ Q x  ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ Q x  ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ todos P xs ∧ Q x ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (x#xs) = (todos P (x#xs) ∧ todos Q (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
{*danrodcha ivamenjim marpoldia1 migtermor ferrenseg wilmorort paupeddeg crigomgom anaprarod serrodcal juacabsou rubgonmar pablucoto fraortmoy josgarsan lucnovdos*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
{* anaprarod dancorgar *}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
apply (induct x)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg wilmorort dancorgar fraortmoy josgarsan lucnovdos*)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append1:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?P x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix a x&lt;br /&gt;
 assume HI: &amp;quot;?P x&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;?P (a#x)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a#(x@y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
lemma todos_append3:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P (x @ y)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom juacabsou anaprarod*)&lt;br /&gt;
 &lt;br /&gt;
lemma todos_append4:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI:&amp;quot;todos P (xs @ y) = (todos P xs ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((x # xs) @ y) = (P x ∧ todos P (xs @ y ))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ (todos P xs ∧ todos P y)) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P x ∧ todos P xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((x # xs) @ y) = (todos P (x # xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma todos_append5:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x )&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a x&lt;br /&gt;
  assume HI:&amp;quot;todos P (x @ y) = (todos P x ∧ todos P y) &amp;quot; &lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = ( P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot; ... =( P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by auto&lt;br /&gt;
  qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma todos_append6:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?Q x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix x a assume HI: &amp;quot;?Q x&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # x @ y)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?Q (a # x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim marpoldia1 serrodcal anaprarod paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; &lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: todos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom rubgonmar fraortmoy josgarsan danrodcha lucnovdos*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: todos_append)&lt;br /&gt;
 &lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: todos_append,auto)&lt;br /&gt;
&lt;br /&gt;
(* juacabsou *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
apply (induct xs,simp,simp add: todos_append,auto) done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto * )&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) (auto, simp_all add: todos_append) &lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) ( simp_all add: todos_append, auto)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by (simp only: rev.simps(1))&lt;br /&gt;
next &lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P (rev (a#xs)) = (todos P (rev xs @ [a]))&amp;quot; by (simp add: auxiliar)&lt;br /&gt;
 have &amp;quot;… = ((todos P (rev xs)) ∧ (todos P [a]))&amp;quot; by (simp add: todos_append)&lt;br /&gt;
 have &amp;quot;… =  (todos P (rev xs) ∧ P a)&amp;quot; by simp&lt;br /&gt;
 also have Aux: &amp;quot;… = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
 have Aux1: &amp;quot;… = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
 have &amp;quot;(todos P (rev xs) ∧ P a) = (P a ∧ todos P xs)&amp;quot; using Aux Aux1 by simp&lt;br /&gt;
 finally show &amp;quot;todos P (rev (a#xs)) = todos P (a#xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 ferrenseg crigomgom serrodcal juacabsou rubgonmar josgarsan pablucoto*)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = (todos P (a#xs))&amp;quot; by simp    &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((todos P (rev xs)) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume H1: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot; todos P (rev (a # xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show  &amp;quot;todos P (rev (a # xs)) = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs &amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = todos P (rev(xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a]) &amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = todos P ([a] @ xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (todos P(rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;... = todos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;todos P (rev (a#xs))= todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)  &lt;br /&gt;
(* es igual que las anteriores pero con el final también con patrones *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by auto&lt;br /&gt;
  next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a#xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;… = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;… = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar o refutar:&lt;br /&gt;
    algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim ferrenseg paupeddeg crigomgom serrodcal wilmorort juacabsou rubgonmar anaprarod marpoldia1 fraortmoy josgarsan danrodcha pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot; &lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo: P={a1}, Q={a2}, xs={a1,a2}. En este ejemplo:&lt;br /&gt;
   · &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot;&lt;br /&gt;
   · &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
assume H1: &amp;quot;xs = [a, b]&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;P a = True&amp;quot;&lt;br /&gt;
assume H3: &amp;quot;Q a = False&amp;quot;&lt;br /&gt;
assume H4: &amp;quot;P b = False&amp;quot;&lt;br /&gt;
assume H5: &amp;quot;Q b = True&amp;quot; &lt;br /&gt;
have F1: &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have F2: &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∧ Q x) xs ≠ (algunos P xs ∧ algunos Q xs)&amp;quot; using F1 F2 by simp&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom rubgonmar wilmorort anaprarod &lt;br /&gt;
    fraortmoy juacabsou paupeddeg josgarsan danrodcha pablucoto *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
(* anaprarod dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma AUX: &amp;quot;algunos (λa. P (f a)) xs = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (map f (x#xs)) = (algunos P ((f x)#(map f xs)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by (simp only: algunos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
   proof (cases)&lt;br /&gt;
    assume C1: &amp;quot;(P (f x))&amp;quot;&lt;br /&gt;
    have Aux: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = True&amp;quot; using C1 by simp&lt;br /&gt;
    have  Aux1: &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C1 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
              using Aux Aux1 by simp&lt;br /&gt;
   next&lt;br /&gt;
    assume C2: &amp;quot;¬(P (f x))&amp;quot;&lt;br /&gt;
    have Aux2: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = (algunos P (map f xs))&amp;quot; using C2 by simp&lt;br /&gt;
    have Aux3: &amp;quot;… = (algunos (P o f) xs)&amp;quot; using HI by (simp add: AUX)&lt;br /&gt;
    also have &amp;quot;… =  ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C2 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
            using Aux2 Aux3 by simp&lt;br /&gt;
   qed&lt;br /&gt;
 also have &amp;quot;… = (((P o f) x) ∨ (algunos (P o f) xs))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (map f (x#xs)) = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (map f (x # xs)) = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (((P ∘ f) x) ∨ (algunos (P ∘ f) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (a # xs)) = algunos P ((f a)#map f xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp &lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar anaprarod marpoldia1 juacabsou danrodcha paupeddeg josgarsan*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x # xs))  = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P ∘ f) x ∨ algunos (P ∘ f) xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* wilmorort pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?P xs&amp;quot; )&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (map f (a # xs))  = (P (f a) ∨ algunos P (map f xs))&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;... = (P (f a) ∨ algunos (P ∘ f) xs )&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = ((P ∘ f) a ∨ algunos (P ∘ f)xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot; algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have  &amp;quot;algunos P (map f (a # xs)) = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos (P ∘ f) [a] ∨  algunos (P ∘ f) xs )&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot; algunos P (map f (a # xs)) = algunos P ((f a)#(map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by blast&lt;br /&gt;
also have &amp;quot;… = ((P ∘ f) a ∨ algunos (P ∘ f) xs)&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;… = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P o f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x#xs)) = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x#xs)) = algunos (P o f) (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg crigomgom rubgonmar  wilmorort fraortmoy danrodcha pablucoto dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg marpoldia1 wilmorort dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (P a ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append2:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P ((x#xs) @ ys) = algunos P (x#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs) ∨ (algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (x#xs)) ∨ (algunos P ys))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P ((x#xs) @ ys) = (algunos P (x#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg*)&lt;br /&gt;
lemma algunos_append3:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ ( algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
lemma algunos_append4:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = ((algunos P [a] ∨ algunos P xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto*}&lt;br /&gt;
lemma algunos_append5:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P ((a#xs) @ ys) = algunos P (a#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 rubgonmar paupeddeg dancorgar *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: algunos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom danrodcha pablucoto josgarsan*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: algunos_append)&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: algunos_append,auto) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma auxiliar1:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto &lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (rev (x#xs)) = (algunos P (rev xs @ [x]))&amp;quot; using auxiliar1 by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (rev xs)) ∨ (algunos P [x]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (rev xs)))&amp;quot; by simp arith&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (rev (x#xs)) = (algunos P (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [x])&amp;quot; &lt;br /&gt;
      by (simp add: algunos_append)&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P x ∨ algunos P xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
 &lt;br /&gt;
(* ivamenjim marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = (algunos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI:&amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ (algunos P [a]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = ((algunos P xs) ∨ (algunos P [a]))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P [a]) ∨ (algunos P xs))&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot; algunos P (rev xs) = algunos P xs&amp;quot; &lt;br /&gt;
  have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (rev xs) ∨ algunos P [x])&amp;quot;  by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs  ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = algunos P (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;  (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P(rev xs) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;... = algunos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;algunos  P (rev (a#xs))= algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [a])&amp;quot; by (simp add:algunos_append)&lt;br /&gt;
also have &amp;quot;… = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;… = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Encontrar un término no trivial Z tal que sea cierta la &lt;br /&gt;
  siguiente ecuación:&lt;br /&gt;
     algunos (λx. P x ∨ Q x) xs = Z&lt;br /&gt;
  y demostrar la equivalencia de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos (λx. P x ∨ Q x) (x#xs) = (((λx. P x ∨ Q x) x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x ∨ Q x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot; by simp&lt;br /&gt;
 also have H1: &amp;quot;… = ((((λx. P x) x) ∨ (algunos (λx. P x) xs)) ∨ (((λx. Q x) x) ∨ (algunos (λx. Q x) xs)))&amp;quot;&lt;br /&gt;
          using HI by simp arith&lt;br /&gt;
 have H2: &amp;quot;… = ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               by simp&lt;br /&gt;
 have C: &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
         using H1 H2 by simp&lt;br /&gt;
 finally show &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos  (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. (P x ∨ Q x)) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = &lt;br /&gt;
      ((P x) ∨ (Q x) ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ (Q x) ∨ algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
      using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (((P x) ∨ algunos P xs) ∨ ((Q x) ∨ algunos Q xs))&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis &lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ algunos P xs ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* wilmorort danrodcha*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
(is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ Q a ∨  (¬ todos (λx. ¬ P x) xs ∨ ¬ todos (λx. ¬ Q x) xs))&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ ¬ todos (λx. ¬ P x) xs ∨ Q a ∨  ¬ todos (λx. ¬ Q x) xs )&amp;quot; by arith&lt;br /&gt;
finally show  &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (~ todos (λx. ¬ P x) (a # xs) ∨ ~ todos (λx. ¬ Q x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
    have 1:&amp;quot; (Q a ∨ algunos P xs) = (algunos P xs ∨ Q a)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = &lt;br /&gt;
     (algunos P [a] ∨ algunos Q [a] ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (Q a ∨ algunos P xs) ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ algunos P xs ∨ Q a ∨ algunos Q xs)&amp;quot; using 1 by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?R (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) [] ⟹ (algunos P [] ∧ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
  have F1: &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ ((P xf ∧ Q xf) ∨ algunos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have F2: &amp;quot;… ⟹ (P xf ∧ Q xf ∨ (algunos P xs ∧ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  have F3: &amp;quot;((P xf ∧ Q xf) ∨ (algunos P xs ∧ algunos Q xs)) ⟹ &lt;br /&gt;
    ((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs))&amp;quot; by blast&lt;br /&gt;
  have F4: &amp;quot;((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs)) ⟹ &lt;br /&gt;
     (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot; by simp&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot;&lt;br /&gt;
    using F1 F2 F3 F4 by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto crigomgom*)&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs) &amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q []) &amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot; algunos (λx. P x ∨ Q x) (a # xs) = ( P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ (algunos P xs ∨ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (((P a) ∨ algunos P xs) ∨ ((Q a) ∨ algunos Q xs))&amp;quot; by arith &lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs)) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort migtermor marpoldia1 crigomgom rubgonmar paupeddeg danrodcha pablucoto dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.2. Demostrar o refutar datalladamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom paupeddeg josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. ¬ P x) [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. ¬ P x) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (a # xs) = (P a ∨ (algunos P xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (¬ todos (λx. ¬ P x) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (a # xs) = (¬ todos (λx. ¬ P x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (x # xs) = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot;&lt;br /&gt;
  proof - &lt;br /&gt;
    have &amp;quot;algunos P (x # xs) = ((P x) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ ¬ todos (λx. (¬ P x)) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (¬ (P x) ∧ todos (λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto*}&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
    have &amp;quot;algunos P (a # xs) = (P a ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (¬ todos (λx. (¬ P x)) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬(¬(P a) ∧ todos(λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos(λx. (¬ P x)) (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (xf#xs) = ((P xf) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ( (P xf) ∨ (¬ todos (λx. (¬ P x)) xs) )&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (¬((¬P xf) ∧ (todos (λx. (¬ P x)) xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (xf#xs) = (¬todos (λx. (¬ P x)) (xf#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg migtermor serrodcal crigomgom rubgonmar marpoldia1 paupeddeg danrodcha dancorgar pablucoto*)&lt;br /&gt;
&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn x [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Expresar la relación existente entre estaEn y algunos. &lt;br /&gt;
  Demostrar dicha relación de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar13:&lt;br /&gt;
 &amp;quot;(x=a) = ((λa. a=x) a)&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;estaEn x (a#xs) = ((a=x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
 also have H: &amp;quot;… = ((a=x) ∨ (algunos (λa. a=x) xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((λa. a=x) a) ∨ (algunos (λa. a=x) xs))&amp;quot; using auxiliar13  by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (λa. a=x) (a#xs))&amp;quot; by simp&lt;br /&gt;
 have C: &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using H by simp&lt;br /&gt;
 finally show &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos_2:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x=y) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn y (x # xs) = algunos (λx. x=y) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;estaEn y (x # xs) = (y=x ∨ estaEn y xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (y=x ∨ algunos (λx. x=y) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (x=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos (λx. x=y) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg dancorgar *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; &lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; estaEn x [] = algunos (λa. a = x) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (λa. a = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = (a = x ∨ estaEn x xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (a = x ∨ algunos (λa. a = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (λa. a = x) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn x [] = algunos (op = x) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (op = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = ((a = x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  (a = x ∨ algunos (op = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (op = x) (a # xs)&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a [] = algunos (op = a) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs &lt;br /&gt;
  assume HI: &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
      have &amp;quot;estaEn a (x # xs) = ((x = a) ∨ (estaEn a xs))&amp;quot; by simp&lt;br /&gt;
      also have &amp;quot;… = (x = a ∨ algunos (op = a) xs)&amp;quot; using HI by simp&lt;br /&gt;
      also have &amp;quot;… = ((op = a) x ∨ algunos (op = a) xs)&amp;quot; by (simp add:HOL.eq_commute)&lt;br /&gt;
      also have &amp;quot;… = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
      finally show &amp;quot;estaEn a (x # xs) = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x = y) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; estaEn y xs = algunos (λx. x = y) xs &amp;quot;&lt;br /&gt;
  have &amp;quot; estaEn y (a # xs) = (y = a ∨ estaEn y xs)&amp;quot;  by simp &lt;br /&gt;
  also have &amp;quot;... = (y = a ∨ algunos (λx. x = y) xs) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (a=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
  also have &amp;quot;... = (algunos (λx. x = y) (a#xs))&amp;quot;  by simp&lt;br /&gt;
  finally show &amp;quot;estaEn y (a # xs) = algunos (λx. x = y) (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=633</id>
		<title>Relación 4</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=633"/>
		<updated>2016-11-23T11:04:27Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R4: Cuantificadores sobre listas *}&lt;br /&gt;
&lt;br /&gt;
theory R4_Cuantificadores_sobre_listas&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la función &lt;br /&gt;
     todos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (todos p xs) se verifica si todos los elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     todos (λx. 1&amp;lt;length x) [[2,1,4],[1,3]]&lt;br /&gt;
     ¬todos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función todos es equivalente a la predefinida list_all. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p xs =   &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor dancorgar wilmorort marpoldia1 ferrenseg paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     algunos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (algunos p xs) se verifica si algunos elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     algunos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
     ¬algunos (λx. 1&amp;lt;length x) [[],[3]]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  Nota: La función algunos es equivalente a la predefinida list_ex. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*}&lt;br /&gt;
fun algunos  :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
   &amp;quot;algunos p []     = False&amp;quot;&lt;br /&gt;
| &amp;quot;algunos p (x#xs) = (p x ∨ algunos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (P a ∧ Q a ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?R (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar paupeddeg *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix y xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = ((P y ∧ Q y) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ Q y) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ todos P xs) ∧ (Q y ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = ((todos P (y#xs)) ∧ (todos Q (y#xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = (todos P (y#xs) ∧ todos Q (y#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
 next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
 have &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = (( P x ∧ Q x) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot;&lt;br /&gt;
     by (simp only: todos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot; by arith&lt;br /&gt;
 also have &amp;quot;((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs)) = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot;&lt;br /&gt;
          by arith (* Este paso es exactamente el mismo que el anterior, pero sin cualquiera de los dos no funciona el &amp;quot;finally show&amp;quot; *)&lt;br /&gt;
 have &amp;quot;… = (((P x)∧(todos P xs))∧((Q x)∧(todos Q xs)))&amp;quot; by simp&lt;br /&gt;
 have &amp;quot;… = ((todos P (x#xs))∧(todos Q (x#xs)))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = ((todos P (x#xs)) ∧ (todos Q (x#xs)))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) =  ((P a ∧ Q a) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs) ∧ todos Q (a#xs)) &amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = (P n ∧ Q n ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = P n ∧ Q n ∧ todos P xs ∧ todos Q xs&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;⋯ = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) =  ((P n ∧ Q n) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P n ∧ todos P xs) ∧ (Q n ∧ todos Q xs))&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = ((todos P(n#xs)) ∧ (todos Q(n#xs)))&amp;quot; by simp&lt;br /&gt;
&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (n#xs) = (todos P (n#xs) ∧ todos Q (n#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* wilmorort pablucoto crigomgom anaprarod juacabsou rubgonmar fraortmoy *}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp   &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ todos P xs ∧ Q a ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
also have &amp;quot;... = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp (* Este paso se puede obviar*)&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
{*danrodcha ivamenjim marpoldia1 migtermor ferrenseg wilmorort paupeddeg crigomgom anaprarod serrodcal juacabsou rubgonmar pablucoto fraortmoy josgarsan lucnovdos*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
{* anaprarod dancorgar *}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
apply (induct x)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg wilmorort dancorgar fraortmoy josgarsan lucnovdos*)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append1:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?P x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix a x&lt;br /&gt;
 assume HI: &amp;quot;?P x&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;?P (a#x)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a#(x@y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
lemma todos_append3:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P (x @ y)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom juacabsou anaprarod*)&lt;br /&gt;
 &lt;br /&gt;
lemma todos_append4:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI:&amp;quot;todos P (xs @ y) = (todos P xs ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((x # xs) @ y) = (P x ∧ todos P (xs @ y ))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ (todos P xs ∧ todos P y)) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P x ∧ todos P xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((x # xs) @ y) = (todos P (x # xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma todos_append5:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x )&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a x&lt;br /&gt;
  assume HI:&amp;quot;todos P (x @ y) = (todos P x ∧ todos P y) &amp;quot; &lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = ( P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot; ... =( P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by auto&lt;br /&gt;
  qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma todos_append6:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?Q x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix x a assume HI: &amp;quot;?Q x&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # x @ y)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?Q (a # x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim marpoldia1 serrodcal anaprarod paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; &lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: todos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom rubgonmar fraortmoy josgarsan danrodcha lucnovdos*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: todos_append)&lt;br /&gt;
 &lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: todos_append,auto)&lt;br /&gt;
&lt;br /&gt;
(* juacabsou *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
apply (induct xs,simp,simp add: todos_append,auto) done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto * )&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) (auto, simp_all add: todos_append) &lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) ( simp_all add: todos_append, auto)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by (simp only: rev.simps(1))&lt;br /&gt;
next &lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P (rev (a#xs)) = (todos P (rev xs @ [a]))&amp;quot; by (simp add: auxiliar)&lt;br /&gt;
 have &amp;quot;… = ((todos P (rev xs)) ∧ (todos P [a]))&amp;quot; by (simp add: todos_append)&lt;br /&gt;
 have &amp;quot;… =  (todos P (rev xs) ∧ P a)&amp;quot; by simp&lt;br /&gt;
 also have Aux: &amp;quot;… = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
 have Aux1: &amp;quot;… = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
 have &amp;quot;(todos P (rev xs) ∧ P a) = (P a ∧ todos P xs)&amp;quot; using Aux Aux1 by simp&lt;br /&gt;
 finally show &amp;quot;todos P (rev (a#xs)) = todos P (a#xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 ferrenseg crigomgom serrodcal juacabsou rubgonmar josgarsan pablucoto*)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = (todos P (a#xs))&amp;quot; by simp    &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((todos P (rev xs)) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume H1: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot; todos P (rev (a # xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show  &amp;quot;todos P (rev (a # xs)) = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs &amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = todos P (rev(xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a]) &amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = todos P ([a] @ xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (todos P(rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;... = todos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;todos P (rev (a#xs))= todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)  &lt;br /&gt;
(* es igual que las anteriores pero con el final también con patrones *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by auto&lt;br /&gt;
  next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a#xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;… = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;… = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar o refutar:&lt;br /&gt;
    algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim ferrenseg paupeddeg crigomgom serrodcal wilmorort juacabsou rubgonmar anaprarod marpoldia1 fraortmoy josgarsan danrodcha pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot; &lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo: P={a1}, Q={a2}, xs={a1,a2}. En este ejemplo:&lt;br /&gt;
   · &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot;&lt;br /&gt;
   · &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
assume H1: &amp;quot;xs = [a, b]&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;P a = True&amp;quot;&lt;br /&gt;
assume H3: &amp;quot;Q a = False&amp;quot;&lt;br /&gt;
assume H4: &amp;quot;P b = False&amp;quot;&lt;br /&gt;
assume H5: &amp;quot;Q b = True&amp;quot; &lt;br /&gt;
have F1: &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have F2: &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∧ Q x) xs ≠ (algunos P xs ∧ algunos Q xs)&amp;quot; using F1 F2 by simp&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom rubgonmar wilmorort anaprarod &lt;br /&gt;
    fraortmoy juacabsou paupeddeg josgarsan danrodcha pablucoto *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
(* anaprarod dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma AUX: &amp;quot;algunos (λa. P (f a)) xs = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (map f (x#xs)) = (algunos P ((f x)#(map f xs)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by (simp only: algunos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
   proof (cases)&lt;br /&gt;
    assume C1: &amp;quot;(P (f x))&amp;quot;&lt;br /&gt;
    have Aux: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = True&amp;quot; using C1 by simp&lt;br /&gt;
    have  Aux1: &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C1 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
              using Aux Aux1 by simp&lt;br /&gt;
   next&lt;br /&gt;
    assume C2: &amp;quot;¬(P (f x))&amp;quot;&lt;br /&gt;
    have Aux2: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = (algunos P (map f xs))&amp;quot; using C2 by simp&lt;br /&gt;
    have Aux3: &amp;quot;… = (algunos (P o f) xs)&amp;quot; using HI by (simp add: AUX)&lt;br /&gt;
    also have &amp;quot;… =  ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C2 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
            using Aux2 Aux3 by simp&lt;br /&gt;
   qed&lt;br /&gt;
 also have &amp;quot;… = (((P o f) x) ∨ (algunos (P o f) xs))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (map f (x#xs)) = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (map f (x # xs)) = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (((P ∘ f) x) ∨ (algunos (P ∘ f) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (a # xs)) = algunos P ((f a)#map f xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp &lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar anaprarod marpoldia1 juacabsou danrodcha paupeddeg josgarsan*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x # xs))  = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P ∘ f) x ∨ algunos (P ∘ f) xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* wilmorort pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?P xs&amp;quot; )&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (map f (a # xs))  = (P (f a) ∨ algunos P (map f xs))&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;... = (P (f a) ∨ algunos (P ∘ f) xs )&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = ((P ∘ f) a ∨ algunos (P ∘ f)xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot; algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have  &amp;quot;algunos P (map f (a # xs)) = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos (P ∘ f) [a] ∨  algunos (P ∘ f) xs )&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot; algunos P (map f (a # xs)) = algunos P ((f a)#(map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by blast&lt;br /&gt;
also have &amp;quot;… = ((P ∘ f) a ∨ algunos (P ∘ f) xs)&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;… = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P o f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x#xs)) = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x#xs)) = algunos (P o f) (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg crigomgom rubgonmar  wilmorort fraortmoy danrodcha pablucoto dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg marpoldia1 wilmorort dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (P a ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append2:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P ((x#xs) @ ys) = algunos P (x#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs) ∨ (algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (x#xs)) ∨ (algunos P ys))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P ((x#xs) @ ys) = (algunos P (x#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg*)&lt;br /&gt;
lemma algunos_append3:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ ( algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
lemma algunos_append4:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = ((algunos P [a] ∨ algunos P xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto*}&lt;br /&gt;
lemma algunos_append5:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P ((a#xs) @ ys) = algunos P (a#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 rubgonmar paupeddeg dancorgar *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: algunos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom danrodcha pablucoto josgarsan*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: algunos_append)&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: algunos_append,auto) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma auxiliar1:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto &lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (rev (x#xs)) = (algunos P (rev xs @ [x]))&amp;quot; using auxiliar1 by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (rev xs)) ∨ (algunos P [x]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (rev xs)))&amp;quot; by simp arith&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (rev (x#xs)) = (algunos P (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [x])&amp;quot; &lt;br /&gt;
      by (simp add: algunos_append)&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P x ∨ algunos P xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
 &lt;br /&gt;
(* ivamenjim marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = (algunos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI:&amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ (algunos P [a]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = ((algunos P xs) ∨ (algunos P [a]))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P [a]) ∨ (algunos P xs))&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot; algunos P (rev xs) = algunos P xs&amp;quot; &lt;br /&gt;
  have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (rev xs) ∨ algunos P [x])&amp;quot;  by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs  ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = algunos P (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;  (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P(rev xs) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;... = algunos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;algunos  P (rev (a#xs))= algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [a])&amp;quot; by (simp add:algunos_append)&lt;br /&gt;
also have &amp;quot;… = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;… = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Encontrar un término no trivial Z tal que sea cierta la &lt;br /&gt;
  siguiente ecuación:&lt;br /&gt;
     algunos (λx. P x ∨ Q x) xs = Z&lt;br /&gt;
  y demostrar la equivalencia de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos (λx. P x ∨ Q x) (x#xs) = (((λx. P x ∨ Q x) x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x ∨ Q x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot; by simp&lt;br /&gt;
 also have H1: &amp;quot;… = ((((λx. P x) x) ∨ (algunos (λx. P x) xs)) ∨ (((λx. Q x) x) ∨ (algunos (λx. Q x) xs)))&amp;quot;&lt;br /&gt;
          using HI by simp arith&lt;br /&gt;
 have H2: &amp;quot;… = ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               by simp&lt;br /&gt;
 have C: &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
         using H1 H2 by simp&lt;br /&gt;
 finally show &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos  (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. (P x ∨ Q x)) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = &lt;br /&gt;
      ((P x) ∨ (Q x) ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ (Q x) ∨ algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
      using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (((P x) ∨ algunos P xs) ∨ ((Q x) ∨ algunos Q xs))&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis &lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ algunos P xs ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* wilmorort danrodcha*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
(is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ Q a ∨  (¬ todos (λx. ¬ P x) xs ∨ ¬ todos (λx. ¬ Q x) xs))&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ ¬ todos (λx. ¬ P x) xs ∨ Q a ∨  ¬ todos (λx. ¬ Q x) xs )&amp;quot; by arith&lt;br /&gt;
finally show  &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (~ todos (λx. ¬ P x) (a # xs) ∨ ~ todos (λx. ¬ Q x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
    have 1:&amp;quot; (Q a ∨ algunos P xs) = (algunos P xs ∨ Q a)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = &lt;br /&gt;
     (algunos P [a] ∨ algunos Q [a] ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (Q a ∨ algunos P xs) ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ algunos P xs ∨ Q a ∨ algunos Q xs)&amp;quot; using 1 by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?R (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) [] ⟹ (algunos P [] ∧ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
  have F1: &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ ((P xf ∧ Q xf) ∨ algunos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have F2: &amp;quot;… ⟹ (P xf ∧ Q xf ∨ (algunos P xs ∧ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  have F3: &amp;quot;((P xf ∧ Q xf) ∨ (algunos P xs ∧ algunos Q xs)) ⟹ &lt;br /&gt;
    ((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs))&amp;quot; by blast&lt;br /&gt;
  have F4: &amp;quot;((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs)) ⟹ &lt;br /&gt;
     (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot; by simp&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot;&lt;br /&gt;
    using F1 F2 F3 F4 by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto crigomgom*)&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs) &amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q []) &amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot; algunos (λx. P x ∨ Q x) (a # xs) = ( P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ (algunos P xs ∨ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (((P a) ∨ algunos P xs) ∨ ((Q a) ∨ algunos Q xs))&amp;quot; by arith &lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs)) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort migtermor marpoldia1 crigomgom rubgonmar paupeddeg danrodcha pablucoto dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.2. Demostrar o refutar datalladamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom paupeddeg josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. ¬ P x) [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. ¬ P x) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (a # xs) = (P a ∨ (algunos P xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (¬ todos (λx. ¬ P x) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (a # xs) = (¬ todos (λx. ¬ P x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (x # xs) = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot;&lt;br /&gt;
  proof - &lt;br /&gt;
    have &amp;quot;algunos P (x # xs) = ((P x) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ ¬ todos (λx. (¬ P x)) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (¬ (P x) ∧ todos (λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto*}&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
    have &amp;quot;algunos P (a # xs) = (P a ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (¬ todos (λx. (¬ P x)) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬(¬(P a) ∧ todos(λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos(λx. (¬ P x)) (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (xf#xs) = ((P xf) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ( (P xf) ∨ (¬ todos (λx. (¬ P x)) xs) )&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (¬((¬P xf) ∧ (todos (λx. (¬ P x)) xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (xf#xs) = (¬todos (λx. (¬ P x)) (xf#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg migtermor serrodcal crigomgom rubgonmar marpoldia1 paupeddeg danrodcha dancorgar pablucoto*)&lt;br /&gt;
&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn x [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Expresar la relación existente entre estaEn y algunos. &lt;br /&gt;
  Demostrar dicha relación de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar13:&lt;br /&gt;
 &amp;quot;(x=a) = ((λa. a=x) a)&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;estaEn x (a#xs) = ((a=x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
 also have H: &amp;quot;… = ((a=x) ∨ (algunos (λa. a=x) xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((λa. a=x) a) ∨ (algunos (λa. a=x) xs))&amp;quot; using auxiliar13  by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (λa. a=x) (a#xs))&amp;quot; by simp&lt;br /&gt;
 have C: &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using H by simp&lt;br /&gt;
 finally show &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos_2:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x=y) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn y (x # xs) = algunos (λx. x=y) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;estaEn y (x # xs) = (y=x ∨ estaEn y xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (y=x ∨ algunos (λx. x=y) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (x=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos (λx. x=y) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg dancorgar *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; &lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; estaEn x [] = algunos (λa. a = x) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (λa. a = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = (a = x ∨ estaEn x xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (a = x ∨ algunos (λa. a = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (λa. a = x) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn x [] = algunos (op = x) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (op = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = ((a = x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  (a = x ∨ algunos (op = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (op = x) (a # xs)&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a [] = algunos (op = a) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs &lt;br /&gt;
  assume HI: &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
      have &amp;quot;estaEn a (x # xs) = ((x = a) ∨ (estaEn a xs))&amp;quot; by simp&lt;br /&gt;
      also have &amp;quot;… = (x = a ∨ algunos (op = a) xs)&amp;quot; using HI by simp&lt;br /&gt;
      also have &amp;quot;… = ((op = a) x ∨ algunos (op = a) xs)&amp;quot; by (simp add:HOL.eq_commute)&lt;br /&gt;
      also have &amp;quot;… = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
      finally show &amp;quot;estaEn a (x # xs) = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x = y) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; estaEn y xs = algunos (λx. x = y) xs &amp;quot;&lt;br /&gt;
  have &amp;quot; estaEn y (a # xs) = (y = a ∨ estaEn y xs)&amp;quot;  by simp &lt;br /&gt;
  also have &amp;quot;... = (y = a ∨ algunos (λx. x = y) xs) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (a=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
  also have &amp;quot;... = (algunos (λx. x = y) (a#xs))&amp;quot;  by simp&lt;br /&gt;
  finally show &amp;quot;estaEn y (a # xs) = algunos (λx. x = y) (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=632</id>
		<title>Relación 4</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=632"/>
		<updated>2016-11-23T10:54:27Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R4: Cuantificadores sobre listas *}&lt;br /&gt;
&lt;br /&gt;
theory R4_Cuantificadores_sobre_listas&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la función &lt;br /&gt;
     todos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (todos p xs) se verifica si todos los elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     todos (λx. 1&amp;lt;length x) [[2,1,4],[1,3]]&lt;br /&gt;
     ¬todos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función todos es equivalente a la predefinida list_all. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p xs =   &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor dancorgar wilmorort marpoldia1 ferrenseg paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     algunos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (algunos p xs) se verifica si algunos elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     algunos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
     ¬algunos (λx. 1&amp;lt;length x) [[],[3]]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  Nota: La función algunos es equivalente a la predefinida list_ex. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*}&lt;br /&gt;
fun algunos  :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
   &amp;quot;algunos p []     = False&amp;quot;&lt;br /&gt;
| &amp;quot;algunos p (x#xs) = (p x ∨ algunos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (P a ∧ Q a ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?R (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar paupeddeg *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix y xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = ((P y ∧ Q y) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ Q y) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ todos P xs) ∧ (Q y ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = ((todos P (y#xs)) ∧ (todos Q (y#xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = (todos P (y#xs) ∧ todos Q (y#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
 next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
 have &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = (( P x ∧ Q x) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot;&lt;br /&gt;
     by (simp only: todos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot; by arith&lt;br /&gt;
 also have &amp;quot;((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs)) = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot;&lt;br /&gt;
          by arith (* Este paso es exactamente el mismo que el anterior, pero sin cualquiera de los dos no funciona el &amp;quot;finally show&amp;quot; *)&lt;br /&gt;
 have &amp;quot;… = (((P x)∧(todos P xs))∧((Q x)∧(todos Q xs)))&amp;quot; by simp&lt;br /&gt;
 have &amp;quot;… = ((todos P (x#xs))∧(todos Q (x#xs)))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = ((todos P (x#xs)) ∧ (todos Q (x#xs)))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) =  ((P a ∧ Q a) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs) ∧ todos Q (a#xs)) &amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = (P n ∧ Q n ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = P n ∧ Q n ∧ todos P xs ∧ todos Q xs&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;⋯ = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) =  ((P n ∧ Q n) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P n ∧ todos P xs) ∧ (Q n ∧ todos Q xs))&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = ((todos P(n#xs)) ∧ (todos Q(n#xs)))&amp;quot; by simp&lt;br /&gt;
&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (n#xs) = (todos P (n#xs) ∧ todos Q (n#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* wilmorort pablucoto crigomgom anaprarod juacabsou rubgonmar fraortmoy *}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp   &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ todos P xs ∧ Q a ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
also have &amp;quot;... = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp (* Este paso se puede obviar*)&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
{*danrodcha ivamenjim marpoldia1 migtermor ferrenseg wilmorort paupeddeg crigomgom anaprarod serrodcal juacabsou rubgonmar pablucoto fraortmoy josgarsan lucnovdos*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
{* anaprarod dancorgar *}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
apply (induct x)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg wilmorort dancorgar fraortmoy josgarsan lucnovdos*)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append1:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?P x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix a x&lt;br /&gt;
 assume HI: &amp;quot;?P x&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;?P (a#x)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a#(x@y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
lemma todos_append3:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P (x @ y)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom juacabsou anaprarod*)&lt;br /&gt;
 &lt;br /&gt;
lemma todos_append4:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI:&amp;quot;todos P (xs @ y) = (todos P xs ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((x # xs) @ y) = (P x ∧ todos P (xs @ y ))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ (todos P xs ∧ todos P y)) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P x ∧ todos P xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((x # xs) @ y) = (todos P (x # xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma todos_append5:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x )&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a x&lt;br /&gt;
  assume HI:&amp;quot;todos P (x @ y) = (todos P x ∧ todos P y) &amp;quot; &lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = ( P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot; ... =( P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by auto&lt;br /&gt;
  qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma todos_append6:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?Q x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix x a assume HI: &amp;quot;?Q x&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # x @ y)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?Q (a # x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim marpoldia1 serrodcal anaprarod paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; &lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: todos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom rubgonmar fraortmoy josgarsan danrodcha lucnovdos*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: todos_append)&lt;br /&gt;
 &lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: todos_append,auto)&lt;br /&gt;
&lt;br /&gt;
(* juacabsou *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
apply (induct xs,simp,simp add: todos_append,auto) done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto * )&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) (auto, simp_all add: todos_append) &lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) ( simp_all add: todos_append, auto)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by (simp only: rev.simps(1))&lt;br /&gt;
next &lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P (rev (a#xs)) = (todos P (rev xs @ [a]))&amp;quot; by (simp add: auxiliar)&lt;br /&gt;
 have &amp;quot;… = ((todos P (rev xs)) ∧ (todos P [a]))&amp;quot; by (simp add: todos_append)&lt;br /&gt;
 have &amp;quot;… =  (todos P (rev xs) ∧ P a)&amp;quot; by simp&lt;br /&gt;
 also have Aux: &amp;quot;… = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
 have Aux1: &amp;quot;… = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
 have &amp;quot;(todos P (rev xs) ∧ P a) = (P a ∧ todos P xs)&amp;quot; using Aux Aux1 by simp&lt;br /&gt;
 finally show &amp;quot;todos P (rev (a#xs)) = todos P (a#xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 ferrenseg crigomgom serrodcal juacabsou rubgonmar josgarsan pablucoto*)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = (todos P (a#xs))&amp;quot; by simp    &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((todos P (rev xs)) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume H1: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot; todos P (rev (a # xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show  &amp;quot;todos P (rev (a # xs)) = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs &amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = todos P (rev(xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a]) &amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = todos P ([a] @ xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (todos P(rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;... = todos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;todos P (rev (a#xs))= todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)  &lt;br /&gt;
(* es igual que las anteriores pero con el final también con patrones *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by auto&lt;br /&gt;
  next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a#xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;… = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;… = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar o refutar:&lt;br /&gt;
    algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim ferrenseg paupeddeg crigomgom serrodcal wilmorort juacabsou rubgonmar anaprarod marpoldia1 fraortmoy josgarsan danrodcha pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot; &lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo: P={a1}, Q={a2}, xs={a1,a2}. En este ejemplo:&lt;br /&gt;
   · &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot;&lt;br /&gt;
   · &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
assume H1: &amp;quot;xs = [a, b]&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;P a = True&amp;quot;&lt;br /&gt;
assume H3: &amp;quot;Q a = False&amp;quot;&lt;br /&gt;
assume H4: &amp;quot;P b = False&amp;quot;&lt;br /&gt;
assume H5: &amp;quot;Q b = True&amp;quot; &lt;br /&gt;
have F1: &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have F2: &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∧ Q x) xs ≠ (algunos P xs ∧ algunos Q xs)&amp;quot; using F1 F2 by simp&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom rubgonmar wilmorort anaprarod &lt;br /&gt;
    fraortmoy juacabsou paupeddeg josgarsan danrodcha pablucoto *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
(* anaprarod dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma AUX: &amp;quot;algunos (λa. P (f a)) xs = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (map f (x#xs)) = (algunos P ((f x)#(map f xs)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by (simp only: algunos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
   proof (cases)&lt;br /&gt;
    assume C1: &amp;quot;(P (f x))&amp;quot;&lt;br /&gt;
    have Aux: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = True&amp;quot; using C1 by simp&lt;br /&gt;
    have  Aux1: &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C1 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
              using Aux Aux1 by simp&lt;br /&gt;
   next&lt;br /&gt;
    assume C2: &amp;quot;¬(P (f x))&amp;quot;&lt;br /&gt;
    have Aux2: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = (algunos P (map f xs))&amp;quot; using C2 by simp&lt;br /&gt;
    have Aux3: &amp;quot;… = (algunos (P o f) xs)&amp;quot; using HI by (simp add: AUX)&lt;br /&gt;
    also have &amp;quot;… =  ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C2 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
            using Aux2 Aux3 by simp&lt;br /&gt;
   qed&lt;br /&gt;
 also have &amp;quot;… = (((P o f) x) ∨ (algunos (P o f) xs))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (map f (x#xs)) = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (map f (x # xs)) = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (((P ∘ f) x) ∨ (algunos (P ∘ f) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (a # xs)) = algunos P ((f a)#map f xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp &lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar anaprarod marpoldia1 juacabsou danrodcha paupeddeg josgarsan*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x # xs))  = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P ∘ f) x ∨ algunos (P ∘ f) xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* wilmorort pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?P xs&amp;quot; )&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (map f (a # xs))  = (P (f a) ∨ algunos P (map f xs))&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;... = (P (f a) ∨ algunos (P ∘ f) xs )&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = ((P ∘ f) a ∨ algunos (P ∘ f)xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot; algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have  &amp;quot;algunos P (map f (a # xs)) = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos (P ∘ f) [a] ∨  algunos (P ∘ f) xs )&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot; algunos P (map f (a # xs)) = algunos P ((f a)#(map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by blast&lt;br /&gt;
also have &amp;quot;… = ((P ∘ f) a ∨ algunos (P ∘ f) xs)&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;… = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P o f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x#xs)) = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x#xs)) = algunos (P o f) (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg crigomgom rubgonmar  wilmorort fraortmoy danrodcha pablucoto dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg marpoldia1 wilmorort dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (P a ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append2:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P ((x#xs) @ ys) = algunos P (x#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs) ∨ (algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (x#xs)) ∨ (algunos P ys))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P ((x#xs) @ ys) = (algunos P (x#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg*)&lt;br /&gt;
lemma algunos_append3:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ ( algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
lemma algunos_append4:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = ((algunos P [a] ∨ algunos P xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto*}&lt;br /&gt;
lemma algunos_append5:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P ((a#xs) @ ys) = algunos P (a#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 rubgonmar paupeddeg dancorgar *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: algunos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom danrodcha pablucoto josgarsan*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: algunos_append)&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: algunos_append,auto) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma auxiliar1:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto &lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (rev (x#xs)) = (algunos P (rev xs @ [x]))&amp;quot; using auxiliar1 by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (rev xs)) ∨ (algunos P [x]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (rev xs)))&amp;quot; by simp arith&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (rev (x#xs)) = (algunos P (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [x])&amp;quot; &lt;br /&gt;
      by (simp add: algunos_append)&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P x ∨ algunos P xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
 &lt;br /&gt;
(* ivamenjim marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = (algunos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI:&amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ (algunos P [a]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = ((algunos P xs) ∨ (algunos P [a]))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P [a]) ∨ (algunos P xs))&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot; algunos P (rev xs) = algunos P xs&amp;quot; &lt;br /&gt;
  have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (rev xs) ∨ algunos P [x])&amp;quot;  by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs  ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = algunos P (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;  (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P(rev xs) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;... = algunos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;algunos  P (rev (a#xs))= algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [a])&amp;quot; by (simp add:algunos_append)&lt;br /&gt;
also have &amp;quot;… = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;… = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Encontrar un término no trivial Z tal que sea cierta la &lt;br /&gt;
  siguiente ecuación:&lt;br /&gt;
     algunos (λx. P x ∨ Q x) xs = Z&lt;br /&gt;
  y demostrar la equivalencia de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos (λx. P x ∨ Q x) (x#xs) = (((λx. P x ∨ Q x) x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x ∨ Q x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot; by simp&lt;br /&gt;
 also have H1: &amp;quot;… = ((((λx. P x) x) ∨ (algunos (λx. P x) xs)) ∨ (((λx. Q x) x) ∨ (algunos (λx. Q x) xs)))&amp;quot;&lt;br /&gt;
          using HI by simp arith&lt;br /&gt;
 have H2: &amp;quot;… = ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               by simp&lt;br /&gt;
 have C: &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
         using H1 H2 by simp&lt;br /&gt;
 finally show &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos  (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. (P x ∨ Q x)) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = &lt;br /&gt;
      ((P x) ∨ (Q x) ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ (Q x) ∨ algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
      using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (((P x) ∨ algunos P xs) ∨ ((Q x) ∨ algunos Q xs))&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis &lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ algunos P xs ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* wilmorort danrodcha*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
(is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ Q a ∨  (¬ todos (λx. ¬ P x) xs ∨ ¬ todos (λx. ¬ Q x) xs))&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ ¬ todos (λx. ¬ P x) xs ∨ Q a ∨  ¬ todos (λx. ¬ Q x) xs )&amp;quot; by arith&lt;br /&gt;
finally show  &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (~ todos (λx. ¬ P x) (a # xs) ∨ ~ todos (λx. ¬ Q x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
    have 1:&amp;quot; (Q a ∨ algunos P xs) = (algunos P xs ∨ Q a)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = &lt;br /&gt;
     (algunos P [a] ∨ algunos Q [a] ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (Q a ∨ algunos P xs) ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ algunos P xs ∨ Q a ∨ algunos Q xs)&amp;quot; using 1 by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?R (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) [] ⟹ (algunos P [] ∧ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
  have F1: &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ ((P xf ∧ Q xf) ∨ algunos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have F2: &amp;quot;… ⟹ (P xf ∧ Q xf ∨ (algunos P xs ∧ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  have F3: &amp;quot;((P xf ∧ Q xf) ∨ (algunos P xs ∧ algunos Q xs)) ⟹ &lt;br /&gt;
    ((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs))&amp;quot; by blast&lt;br /&gt;
  have F4: &amp;quot;((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs)) ⟹ &lt;br /&gt;
     (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot; by simp&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot;&lt;br /&gt;
    using F1 F2 F3 F4 by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto crigomgom*)&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs) &amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q []) &amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot; algunos (λx. P x ∨ Q x) (a # xs) = ( P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ (algunos P xs ∨ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (((P a) ∨ algunos P xs) ∨ ((Q a) ∨ algunos Q xs))&amp;quot; by arith &lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs)) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort migtermor marpoldia1 crigomgom rubgonmar paupeddeg danrodcha pablucoto dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.2. Demostrar o refutar datalladamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom paupeddeg josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. ¬ P x) [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. ¬ P x) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (a # xs) = (P a ∨ (algunos P xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (¬ todos (λx. ¬ P x) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (a # xs) = (¬ todos (λx. ¬ P x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (x # xs) = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot;&lt;br /&gt;
  proof - &lt;br /&gt;
    have &amp;quot;algunos P (x # xs) = ((P x) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ ¬ todos (λx. (¬ P x)) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (¬ (P x) ∧ todos (λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto*}&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
    have &amp;quot;algunos P (a # xs) = (P a ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (¬ todos (λx. (¬ P x)) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬(¬(P a) ∧ todos(λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos(λx. (¬ P x)) (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (xf#xs) = ((P xf) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ( (P xf) ∨ (¬ todos (λx. (¬ P x)) xs) )&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (¬((¬P xf) ∧ (todos (λx. (¬ P x)) xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (xf#xs) = (¬todos (λx. (¬ P x)) (xf#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg migtermor serrodcal crigomgom rubgonmar marpoldia1 paupeddeg danrodcha dancorgar pablucoto*)&lt;br /&gt;
&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn x [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Expresar la relación existente entre estaEn y algunos. &lt;br /&gt;
  Demostrar dicha relación de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar13:&lt;br /&gt;
 &amp;quot;(x=a) = ((λa. a=x) a)&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;estaEn x (a#xs) = ((a=x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
 also have H: &amp;quot;… = ((a=x) ∨ (algunos (λa. a=x) xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((λa. a=x) a) ∨ (algunos (λa. a=x) xs))&amp;quot; using auxiliar13  by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (λa. a=x) (a#xs))&amp;quot; by simp&lt;br /&gt;
 have C: &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using H by simp&lt;br /&gt;
 finally show &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos_2:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x=y) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn y (x # xs) = algunos (λx. x=y) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;estaEn y (x # xs) = (y=x ∨ estaEn y xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (y=x ∨ algunos (λx. x=y) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (x=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos (λx. x=y) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg dancorgar *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; &lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; estaEn x [] = algunos (λa. a = x) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (λa. a = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = (a = x ∨ estaEn x xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (a = x ∨ algunos (λa. a = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (λa. a = x) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn x [] = algunos (op = x) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (op = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = ((a = x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  (a = x ∨ algunos (op = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (op = x) (a # xs)&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a [] = algunos (op = a) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs &lt;br /&gt;
  assume HI: &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
      have &amp;quot;estaEn a (x # xs) = ((x = a) ∨ (estaEn a xs))&amp;quot; by simp&lt;br /&gt;
      also have &amp;quot;… = (x = a ∨ algunos (op = a) xs)&amp;quot; using HI by simp&lt;br /&gt;
      also have &amp;quot;… = ((op = a) x ∨ algunos (op = a) xs)&amp;quot; by (simp add:HOL.eq_commute)&lt;br /&gt;
      also have &amp;quot;… = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
      finally show &amp;quot;estaEn a (x # xs) = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x = y) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; estaEn y xs = algunos (λx. x = y) xs &amp;quot;&lt;br /&gt;
  have &amp;quot; estaEn y (a # xs) = (y = a ∨ estaEn y xs)&amp;quot;  by simp &lt;br /&gt;
  also have &amp;quot;... = (y = a ∨ algunos (λx. x = y) xs) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (a=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
  also have &amp;quot;... = (algunos (λx. x = y) (a#xs))&amp;quot;  by simp&lt;br /&gt;
  finally show &amp;quot;estaEn y (a # xs) = algunos (λx. x = y) (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=631</id>
		<title>Relación 4</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=631"/>
		<updated>2016-11-23T10:54:08Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R4: Cuantificadores sobre listas *}&lt;br /&gt;
&lt;br /&gt;
theory R4_Cuantificadores_sobre_listas&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la función &lt;br /&gt;
     todos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (todos p xs) se verifica si todos los elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     todos (λx. 1&amp;lt;length x) [[2,1,4],[1,3]]&lt;br /&gt;
     ¬todos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función todos es equivalente a la predefinida list_all. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p xs =   &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor dancorgar wilmorort marpoldia1 ferrenseg paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos pabrodmac*)&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     algunos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (algunos p xs) se verifica si algunos elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     algunos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
     ¬algunos (λx. 1&amp;lt;length x) [[],[3]]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  Nota: La función algunos es equivalente a la predefinida list_ex. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto crigomgom anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos*}&lt;br /&gt;
fun algunos  :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
   &amp;quot;algunos p []     = False&amp;quot;&lt;br /&gt;
| &amp;quot;algunos p (x#xs) = (p x ∨ algunos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg wilmorort paupeddeg pablucoto anaprarod serrodcal juacabsou rubgonmar josgarsan fraortmoy lucnovdos*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (P a ∧ Q a ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?R (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort serrodcal josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar paupeddeg *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix y xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = ((P y ∧ Q y) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ Q y) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = ((P y ∧ todos P xs) ∧ (Q y ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;… = ((todos P (y#xs)) ∧ (todos Q (y#xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (y#xs) = (todos P (y#xs) ∧ todos Q (y#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
 next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
 have &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = (( P x ∧ Q x) ∧ (todos (λx. P x ∧ Q x) xs))&amp;quot;&lt;br /&gt;
     by (simp only: todos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot; by arith&lt;br /&gt;
 also have &amp;quot;((P x ∧ Q x) ∧ (todos P xs ∧ todos Q xs)) = (((P x)∧(todos P xs)) ∧ ((Q x) ∧ (todos Q xs)))&amp;quot;&lt;br /&gt;
          by arith (* Este paso es exactamente el mismo que el anterior, pero sin cualquiera de los dos no funciona el &amp;quot;finally show&amp;quot; *)&lt;br /&gt;
 have &amp;quot;… = (((P x)∧(todos P xs))∧((Q x)∧(todos Q xs)))&amp;quot; by simp&lt;br /&gt;
 have &amp;quot;… = ((todos P (x#xs))∧(todos Q (x#xs)))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;(todos (λx. P x ∧ Q x) (x#xs)) = ((todos P (x#xs)) ∧ (todos Q (x#xs)))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) =  ((P a ∧ Q a) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P a ∧ todos P xs) ∧ (Q a ∧ todos Q xs))&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs) ∧ todos Q (a#xs)) &amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = (P n ∧ Q n ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = P n ∧ Q n ∧ todos P xs ∧ todos Q xs&amp;quot; by blast&lt;br /&gt;
  also have &amp;quot;⋯ = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (n # xs) = todos P (n # xs) ∧ todos Q (n # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) =  ((P n ∧ Q n) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P n ∧ todos P xs) ∧ (Q n ∧ todos Q xs))&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = ((todos P(n#xs)) ∧ (todos Q(n#xs)))&amp;quot; by simp&lt;br /&gt;
&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (n#xs) = (todos P (n#xs) ∧ todos Q (n#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* wilmorort pablucoto crigomgom anaprarod juacabsou rubgonmar fraortmoy *}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp   &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ todos P xs ∧ Q a ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
also have &amp;quot;... = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp (* Este paso se puede obviar*)&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
{*danrodcha ivamenjim marpoldia1 migtermor ferrenseg wilmorort paupeddeg crigomgom anaprarod serrodcal juacabsou rubgonmar pablucoto fraortmoy josgarsan lucnovdos*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
{* anaprarod dancorgar *}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
apply (induct x)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg wilmorort dancorgar fraortmoy josgarsan lucnovdos*)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append1:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?P x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix a x&lt;br /&gt;
 assume HI: &amp;quot;?P x&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;?P (a#x)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a#(x@y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
lemma todos_append3:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P (x @ y)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom juacabsou anaprarod*)&lt;br /&gt;
 &lt;br /&gt;
lemma todos_append4:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI:&amp;quot;todos P (xs @ y) = (todos P xs ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((x # xs) @ y) = (P x ∧ todos P (xs @ y ))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ (todos P xs ∧ todos P y)) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P x ∧ todos P xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((x # xs) @ y) = (todos P (x # xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma todos_append5:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x )&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a x&lt;br /&gt;
  assume HI:&amp;quot;todos P (x @ y) = (todos P x ∧ todos P y) &amp;quot; &lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = ( P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot; ... =( P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by auto&lt;br /&gt;
  qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma todos_append6:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?Q x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix x a assume HI: &amp;quot;?Q x&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # x @ y)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?Q (a # x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim marpoldia1 serrodcal anaprarod paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; &lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: todos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom rubgonmar fraortmoy josgarsan danrodcha lucnovdos*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: todos_append)&lt;br /&gt;
 &lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: todos_append,auto)&lt;br /&gt;
&lt;br /&gt;
(* juacabsou *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
apply (induct xs,simp,simp add: todos_append,auto) done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto * )&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) (auto, simp_all add: todos_append) &lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  by (induct xs) ( simp_all add: todos_append, auto)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by (simp only: rev.simps(1))&lt;br /&gt;
next &lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P (rev (a#xs)) = (todos P (rev xs @ [a]))&amp;quot; by (simp add: auxiliar)&lt;br /&gt;
 have &amp;quot;… = ((todos P (rev xs)) ∧ (todos P [a]))&amp;quot; by (simp add: todos_append)&lt;br /&gt;
 have &amp;quot;… =  (todos P (rev xs) ∧ P a)&amp;quot; by simp&lt;br /&gt;
 also have Aux: &amp;quot;… = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
 have Aux1: &amp;quot;… = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
 have &amp;quot;(todos P (rev xs) ∧ P a) = (P a ∧ todos P xs)&amp;quot; using Aux Aux1 by simp&lt;br /&gt;
 finally show &amp;quot;todos P (rev (a#xs)) = todos P (a#xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 ferrenseg crigomgom serrodcal juacabsou rubgonmar josgarsan pablucoto*)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ P a)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = (todos P (a#xs))&amp;quot; by simp    &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = (todos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((todos P (rev xs)) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume H1: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot; todos P (rev (a # xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show  &amp;quot;todos P (rev (a # xs)) = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; todos P (rev []) = todos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;todos P (rev xs) = todos P xs &amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a # xs)) = todos P (rev(xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [a]) &amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = todos P ([a] @ xs)&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  finally show &amp;quot;todos P (rev (a # xs)) = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (todos P(rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
also have &amp;quot;... = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;... = todos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;todos P (rev (a#xs))= todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)  &lt;br /&gt;
(* es igual que las anteriores pero con el final también con patrones *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by auto&lt;br /&gt;
  next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P (rev (a#xs)) = todos P (rev xs @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add: todos_append)&lt;br /&gt;
  also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;… = todos P (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;todos P (rev (a#xs)) = todos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (todos P (rev xs) ∧ todos P [a])&amp;quot; by (simp add:todos_append)&lt;br /&gt;
also have &amp;quot;… = (todos P xs ∧ todos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (todos P [a] ∧ todos P xs)&amp;quot; by (simp add: HOL.conj_commute)&lt;br /&gt;
also have &amp;quot;… = todos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar o refutar:&lt;br /&gt;
    algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim ferrenseg paupeddeg crigomgom serrodcal wilmorort juacabsou rubgonmar anaprarod marpoldia1 fraortmoy josgarsan danrodcha pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot; &lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo: P={a1}, Q={a2}, xs={a1,a2}. En este ejemplo:&lt;br /&gt;
   · &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot;&lt;br /&gt;
   · &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
assume H1: &amp;quot;xs = [a, b]&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;P a = True&amp;quot;&lt;br /&gt;
assume H3: &amp;quot;Q a = False&amp;quot;&lt;br /&gt;
assume H4: &amp;quot;P b = False&amp;quot;&lt;br /&gt;
assume H5: &amp;quot;Q b = True&amp;quot; &lt;br /&gt;
have F1: &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have F2: &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot; using H1 H2 H3 H4 H5 by simp&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∧ Q x) xs ≠ (algunos P xs ∧ algunos Q xs)&amp;quot; using F1 F2 by simp&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom rubgonmar wilmorort anaprarod &lt;br /&gt;
    fraortmoy juacabsou paupeddeg josgarsan danrodcha pablucoto *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
(* anaprarod dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma AUX: &amp;quot;algunos (λa. P (f a)) xs = algunos (P o f) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (map f (x#xs)) = (algunos P ((f x)#(map f xs)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by (simp only: algunos.simps(2))&lt;br /&gt;
 also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
   proof (cases)&lt;br /&gt;
    assume C1: &amp;quot;(P (f x))&amp;quot;&lt;br /&gt;
    have Aux: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = True&amp;quot; using C1 by simp&lt;br /&gt;
    have  Aux1: &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C1 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
              using Aux Aux1 by simp&lt;br /&gt;
   next&lt;br /&gt;
    assume C2: &amp;quot;¬(P (f x))&amp;quot;&lt;br /&gt;
    have Aux2: &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = (algunos P (map f xs))&amp;quot; using C2 by simp&lt;br /&gt;
    have Aux3: &amp;quot;… = (algunos (P o f) xs)&amp;quot; using HI by (simp add: AUX)&lt;br /&gt;
    also have &amp;quot;… =  ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using C2 by simp&lt;br /&gt;
    then show &amp;quot;((P (f x)) ∨ (algunos P (map f xs))) = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; &lt;br /&gt;
            using Aux2 Aux3 by simp&lt;br /&gt;
   qed&lt;br /&gt;
 also have &amp;quot;… = (((P o f) x) ∨ (algunos (P o f) xs))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (map f (x#xs)) = (algunos (P o f) (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (map f (x # xs)) = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (((P ∘ f) x) ∨ (algunos (P ∘ f) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (a # xs)) = algunos P ((f a)#map f xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = (algunos P (map f [a]) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp &lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar anaprarod marpoldia1 juacabsou danrodcha paupeddeg josgarsan*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x # xs))  = algunos P ((f x) # (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P ∘ f) x ∨ algunos (P ∘ f) xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x # xs)) = algunos (P ∘ f) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* wilmorort pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?P xs&amp;quot; )&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (map f (a # xs))  = (P (f a) ∨ algunos P (map f xs))&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;... = (P (f a) ∨ algunos (P ∘ f) xs )&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = ((P ∘ f) a ∨ algunos (P ∘ f)xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot; algunos P (map f (a # xs)) = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P ∘ f) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  have  &amp;quot;algunos P (map f (a # xs)) = (algunos P (map f [a]) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos (P ∘ f) [a] ∨  algunos (P ∘ f) xs )&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (a # xs)) = algunos (P ∘ f) (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot; algunos P (map f (a # xs)) = algunos P ((f a)#(map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos P (map f xs))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (P (f a) ∨ algunos (P ∘ f) xs)&amp;quot; using HI by blast&lt;br /&gt;
also have &amp;quot;… = ((P ∘ f) a ∨ algunos (P ∘ f) xs)&amp;quot;  by simp&lt;br /&gt;
also have &amp;quot;… = algunos (P ∘ f) (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (map f []) = algunos (P o f) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (map f (x#xs)) = ((P (f x)) ∨ (algunos P (map f xs)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P (f x)) ∨ (algunos (P o f) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x#xs)) = algunos (P o f) (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg crigomgom rubgonmar  wilmorort fraortmoy danrodcha pablucoto dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg marpoldia1 wilmorort dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (P a ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append2:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P ((x#xs) @ ys) = algunos P (x#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs) ∨ (algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (x#xs)) ∨ (algunos P ys))&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;algunos P ((x#xs) @ ys) = (algunos P (x#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg*)&lt;br /&gt;
lemma algunos_append3:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ ( algunos P (xs @ ys)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ (algunos P xs ∨ algunos P ys))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
lemma algunos_append4:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume H1: &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P ((a # xs) @ ys) = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;… = ((algunos P [a] ∨ algunos P xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P ((a # xs) @ ys) = (algunos P (a#xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto*}&lt;br /&gt;
lemma algunos_append5:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P ((a#xs) @ ys) = algunos P (a#(xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P (xs @ ys))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs ∨ algunos P ys)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (a # xs) ∨ algunos P ys)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 rubgonmar paupeddeg dancorgar *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: algunos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom danrodcha pablucoto josgarsan*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: algunos_append)&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: algunos_append,auto) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma auxiliar1:&lt;br /&gt;
 &amp;quot;rev (a#xs) = rev xs @ [a]&amp;quot;&lt;br /&gt;
by auto &lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos P (rev (x#xs)) = (algunos P (rev xs @ [x]))&amp;quot; using auxiliar1 by simp&lt;br /&gt;
 also have &amp;quot;… = ((algunos P (rev xs)) ∨ (algunos P [x]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P (rev xs)))&amp;quot; by simp arith&lt;br /&gt;
 also have &amp;quot;… = ((P x) ∨ (algunos P xs))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;algunos P (rev (x#xs)) = (algunos P (x#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [x])&amp;quot; &lt;br /&gt;
      by (simp add: algunos_append)&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P x ∨ algunos P xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
 &lt;br /&gt;
(* ivamenjim marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = (algunos P ((rev xs)@[a]))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI:&amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (rev (a # xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P (rev xs)) ∨ (algunos P [a]))&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = ((algunos P xs) ∨ (algunos P [a]))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((algunos P [a]) ∨ (algunos P xs))&amp;quot; by arith&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (a # xs)) = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P (rev []) = algunos P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot; algunos P (rev xs) = algunos P xs&amp;quot; &lt;br /&gt;
  have &amp;quot;algunos P (rev (x # xs)) = algunos P ((rev xs) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P (rev xs) ∨ algunos P [x])&amp;quot;  by (simp add: algunos_append)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs  ∨ algunos P [x])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ P x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∨ algunos P xs)&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = algunos P (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (x # xs)) = algunos P (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;  (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P(rev xs) ∨ algunos P [a])&amp;quot; by (simp add: algunos_append)&lt;br /&gt;
also have &amp;quot;... = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;... = algunos P([a]@(xs))&amp;quot; by (simp)&lt;br /&gt;
finally show  &amp;quot;algunos  P (rev (a#xs))= algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos P (rev (a#xs)) = algunos P ((rev xs) @ [a])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P (rev xs) ∨ algunos P [a])&amp;quot; by (simp add:algunos_append)&lt;br /&gt;
also have &amp;quot;… = (algunos P xs ∨ algunos P [a])&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;… = (algunos P [a] ∨ algunos P xs)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
also have &amp;quot;… = algunos P (a # xs)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Encontrar un término no trivial Z tal que sea cierta la &lt;br /&gt;
  siguiente ecuación:&lt;br /&gt;
     algunos (λx. P x ∨ Q x) xs = Z&lt;br /&gt;
  y demostrar la equivalencia de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = ((algunos (λx. P x) xs) ∨ (algunos (λx. Q x) xs))&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
 have &amp;quot;algunos (λx. P x ∨ Q x) (x#xs) = (((λx. P x ∨ Q x) x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = ((P x ∨ Q x) ∨ (algunos (λx. P x ∨ Q x) xs))&amp;quot; by simp&lt;br /&gt;
 also have H1: &amp;quot;… = ((((λx. P x) x) ∨ (algunos (λx. P x) xs)) ∨ (((λx. Q x) x) ∨ (algunos (λx. Q x) xs)))&amp;quot;&lt;br /&gt;
          using HI by simp arith&lt;br /&gt;
 have H2: &amp;quot;… = ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               by simp&lt;br /&gt;
 have C: &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
         using H1 H2 by simp&lt;br /&gt;
 finally show &amp;quot;(algunos (λx. P x ∨ Q x) (x#xs)) = &lt;br /&gt;
               ((algunos (λx. P x) (x#xs)) ∨ (algunos (λx. Q x) (x#xs)))&amp;quot; &lt;br /&gt;
               using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos  (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. (P x ∨ Q x)) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (x # xs) = &lt;br /&gt;
      ((P x) ∨ (Q x) ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ (Q x) ∨ algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
      using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (((P x) ∨ algunos P xs) ∨ ((Q x) ∨ algunos Q xs))&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = (algunos P (x # xs) ∨ algunos Q (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis &lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ algunos P xs ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* wilmorort danrodcha*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
(is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ Q a ∨  (¬ todos (λx. ¬ P x) xs ∨ ¬ todos (λx. ¬ Q x) xs))&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ ¬ todos (λx. ¬ P x) xs ∨ Q a ∨  ¬ todos (λx. ¬ Q x) xs )&amp;quot; by arith&lt;br /&gt;
finally show  &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (~ todos (λx. ¬ P x) (a # xs) ∨ ~ todos (λx. ¬ Q x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
    have 1:&amp;quot; (Q a ∨ algunos P xs) = (algunos P xs ∨ Q a)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = &lt;br /&gt;
     (algunos P [a] ∨ algunos Q [a] ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (Q a ∨ algunos P xs) ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ algunos P xs ∨ Q a ∨ algunos Q xs)&amp;quot; using 1 by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?R (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) [] ⟹ (algunos P [] ∧ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∧ Q x) xs ⟹ (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
  have F1: &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ ((P xf ∧ Q xf) ∨ algunos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have F2: &amp;quot;… ⟹ (P xf ∧ Q xf ∨ (algunos P xs ∧ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  have F3: &amp;quot;((P xf ∧ Q xf) ∨ (algunos P xs ∧ algunos Q xs)) ⟹ &lt;br /&gt;
    ((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs))&amp;quot; by blast&lt;br /&gt;
  have F4: &amp;quot;((P xf ∨ algunos P xs) ∧ (Q xf ∨ algunos Q xs)) ⟹ &lt;br /&gt;
     (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot; by simp&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∧ Q x) (xf#xs) ⟹ (algunos P (xf#xs) ∧ algunos Q (xf#xs))&amp;quot;&lt;br /&gt;
    using F1 F2 F3 F4 by blast&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto crigomgom*)&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs) &amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q []) &amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot; algunos (λx. P x ∨ Q x) (a # xs) = ( P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ (algunos P xs ∨ algunos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (((P a) ∨ algunos P xs) ∨ ((Q a) ∨ algunos Q xs))&amp;quot; by arith &lt;br /&gt;
  also have &amp;quot;… = (algunos P (a#xs) ∨ algunos Q (a#xs))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs)) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort migtermor marpoldia1 crigomgom rubgonmar paupeddeg danrodcha pablucoto dancorgar josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
by (induct xs) simp_all&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.2. Demostrar o refutar datalladamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor marpoldia1 crigomgom paupeddeg josgarsan*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. ¬ P x) [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. ¬ P x) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (a # xs) = (P a ∨ (algunos P xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ (¬ todos (λx. ¬ P x) xs))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (a # xs) = (¬ todos (λx. ¬ P x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;algunos P (x # xs) = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot;&lt;br /&gt;
  proof - &lt;br /&gt;
    have &amp;quot;algunos P (x # xs) = ((P x) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = ((P x) ∨ ¬ todos (λx. (¬ P x)) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (¬ (P x) ∧ todos (λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos (λx. (¬ P x)) (x # xs))&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha pablucoto*}&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot; (is &amp;quot;?Q xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?Q xs&amp;quot;&lt;br /&gt;
    have &amp;quot;algunos P (a # xs) = (P a ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (¬ todos (λx. (¬ P x)) xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (¬(¬(P a) ∧ todos(λx. (¬ P x)) xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ todos(λx. (¬ P x)) (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?Q (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos P [] = (¬ todos (λx. (¬ P x)) [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix xf xs&lt;br /&gt;
  assume HI: &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos P (xf#xs) = ((P xf) ∨ algunos P xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ( (P xf) ∨ (¬ todos (λx. (¬ P x)) xs) )&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (¬((¬P xf) ∧ (todos (λx. (¬ P x)) xs)))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;algunos P (xf#xs) = (¬todos (λx. (¬ P x)) (xf#xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg migtermor serrodcal crigomgom rubgonmar marpoldia1 paupeddeg danrodcha dancorgar pablucoto*)&lt;br /&gt;
&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn x [] = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Expresar la relación existente entre estaEn y algunos. &lt;br /&gt;
  Demostrar dicha relación de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor crigomgom *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma auxiliar13:&lt;br /&gt;
 &amp;quot;(x=a) = ((λa. a=x) a)&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix a xs&lt;br /&gt;
 assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
 have &amp;quot;estaEn x (a#xs) = ((a=x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
 also have H: &amp;quot;… = ((a=x) ∨ (algunos (λa. a=x) xs))&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;… = (((λa. a=x) a) ∨ (algunos (λa. a=x) xs))&amp;quot; using auxiliar13  by simp&lt;br /&gt;
 also have &amp;quot;… = (algunos (λa. a=x) (a#xs))&amp;quot; by simp&lt;br /&gt;
 have C: &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using H by simp&lt;br /&gt;
 finally show &amp;quot;estaEn x (a#xs) = (algunos (λa. a=x) (a#xs))&amp;quot; using C by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma estaEn_algunos_2:&lt;br /&gt;
  &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x=y) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  show &amp;quot;estaEn y (x # xs) = algunos (λx. x=y) (x # xs)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;estaEn y (x # xs) = (y=x ∨ estaEn y xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (y=x ∨ algunos (λx. x=y) xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (x=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
    also have &amp;quot;… = algunos (λx. x=y) (x # xs)&amp;quot; by simp&lt;br /&gt;
    finally show ?thesis&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg dancorgar *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = (algunos (λa. a=x) xs)&amp;quot; &lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot; estaEn x [] = algunos (λa. a = x) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (λa. a = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = (a = x ∨ estaEn x xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (a = x ∨ algunos (λa. a = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (λa. a = x) (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn x [] = algunos (op = x) []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (op = x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a # xs) = ((a = x) ∨ (estaEn x xs))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  (a = x ∨ algunos (op = x) xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; estaEn x (a # xs) = algunos (op = x) (a # xs)&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn a [] = algunos (op = a) []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs &lt;br /&gt;
  assume HI: &amp;quot;estaEn a xs = algunos (op = a) xs&amp;quot;&lt;br /&gt;
      have &amp;quot;estaEn a (x # xs) = ((x = a) ∨ (estaEn a xs))&amp;quot; by simp&lt;br /&gt;
      also have &amp;quot;… = (x = a ∨ algunos (op = a) xs)&amp;quot; using HI by simp&lt;br /&gt;
      also have &amp;quot;… = ((op = a) x ∨ algunos (op = a) xs)&amp;quot; by (simp add:HOL.eq_commute)&lt;br /&gt;
      also have &amp;quot;… = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
      finally show &amp;quot;estaEn a (x # xs) = algunos (op = a) (x # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Automatica&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
  by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;Detallada&amp;quot;&lt;br /&gt;
lemma &amp;quot; estaEn y xs = algunos (λx. x=y) xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;estaEn y [] = algunos (λx. x = y) []&amp;quot;  by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot; estaEn y xs = algunos (λx. x = y) xs &amp;quot;&lt;br /&gt;
  have &amp;quot; estaEn y (a # xs) = (y = a ∨ estaEn y xs)&amp;quot;  by simp &lt;br /&gt;
  also have &amp;quot;... = (y = a ∨ algunos (λx. x = y) xs) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (a=y ∨ algunos (λx. x=y) xs)&amp;quot; by auto&lt;br /&gt;
  also have &amp;quot;... = (algunos (λx. x = y) (a#xs))&amp;quot;  by simp&lt;br /&gt;
  finally show &amp;quot;estaEn y (a # xs) = algunos (λx. x = y) (a # xs) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_3&amp;diff=392</id>
		<title>Relación 3</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_3&amp;diff=392"/>
		<updated>2016-11-16T11:14:46Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R3: Razonamiento sobre programas *}&lt;br /&gt;
&lt;br /&gt;
theory R3_Razonamiento_sobre_programas&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1.1. Definir la función&lt;br /&gt;
     sumaImpares :: nat ⇒ nat&lt;br /&gt;
  tal que (sumaImpares n) es la suma de los n primeros números&lt;br /&gt;
  impares. Por ejemplo,&lt;br /&gt;
     sumaImpares 5  =  25&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun sumaImpares :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaImpares 0 = 0&amp;quot;&lt;br /&gt;
| &amp;quot;sumaImpares (Suc n) = sumaImpares n + (2*n+1)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1.2. Escribir la demostración detallada de &lt;br /&gt;
     sumaImpares n = n*n&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración detallada es&amp;quot;&lt;br /&gt;
(* crigomgom fraortmoy marpoldia1 ivamenjim serrodcal rubgonmar ferrenseg juacabsou wilmorort josgarsan lucnovdos paupeddeg bowma pabrodmac*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0 * 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;sumaImpares n = n * n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + 2*n + 1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = n*n + 2*n + 1&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha ; es la misma demostración que la anterior pero uso ?P para sustituir la propiedad.*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot; (is &amp;quot;?P n&amp;quot;)&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;?P 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;?P n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + 2*n + 1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = n*n + 2*n + 1&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = Suc n * Suc n&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;?P (Suc n)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0*0&amp;quot; by simp&lt;br /&gt;
 next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + 2*n+1&amp;quot; &lt;br /&gt;
   by (simp only: sumaImpares.simps(2))&lt;br /&gt;
  also have &amp;quot;sumaImpares (Suc n) = n*n + 2*n+1&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = (Suc n)*(Suc n)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 - Especifico la regla de simplificación y el paso del desarrollo al cuadrado para hacerlo más legible*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0 * 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI : &amp;quot;sumaImpares n = n * n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + (2 * n + 1)&amp;quot; by (simp only: sumaImpares.simps(2))&lt;br /&gt;
  also have &amp;quot;... = n * n + 2 * n + 1&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*palucoto anaprarod*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0 * 0&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n &lt;br /&gt;
  assume HI : &amp;quot;sumaImpares n = n * n&amp;quot;&lt;br /&gt;
  have &amp;quot; sumaImpares (Suc n) = sumaImpares n + 2*n+1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  n*n + 2*n+1&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2.1. Definir la función&lt;br /&gt;
     sumaPotenciasDeDosMasUno :: nat ⇒ nat&lt;br /&gt;
  tal que &lt;br /&gt;
     (sumaPotenciasDeDosMasUno n) = 1 + 2^0 + 2^1 + 2^2 + ... + 2^n. &lt;br /&gt;
  Por ejemplo, &lt;br /&gt;
     sumaPotenciasDeDosMasUno 3  =  16&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun sumaPotenciasDeDosMasUno :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaPotenciasDeDosMasUno 0 = 2&amp;quot;&lt;br /&gt;
| &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = &lt;br /&gt;
      sumaPotenciasDeDosMasUno n + 2^(n+1)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2.2. Escribir la demostración detallada de &lt;br /&gt;
     sumaPotenciasDeDosMasUno n = 2^(n+1)&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom ivamenjim danrodcha serrodcal rubgonmar ferrenseg juacabsou wilmorort anaprarod marpoldia1 josgarsan paupeddeg pabrodmac bowma*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI:  &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n+1)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ ((Suc n) + 1)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
(* es la misma demostración, pero quise probar a delimitar lo que se usa en el &amp;quot;by simp&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume H1:&amp;quot; sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n + 1)&amp;quot; by (simp only : sumaPotenciasDeDosMasUno.simps(2))&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) =  2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2^(0+1)&amp;quot; by simp&lt;br /&gt;
 next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n+1)&amp;quot;&lt;br /&gt;
   by (simp only: sumaPotenciasDeDosMasUno.simps(2))&lt;br /&gt;
  also have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2^(n+1)+2^(n+1)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2^((Suc n)+1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n &lt;br /&gt;
  assume HI : &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n+1) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2^(n + 1) +  2^( n + 1) &amp;quot; using HI by simp  &lt;br /&gt;
  finally show &amp;quot; sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 - Hago explícita toda la manipulación algebraica. Quizás excesivo.*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induction n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI : &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
    by (simp only:sumaPotenciasDeDosMasUno.simps(2))&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) * 2&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ ((n + 1) + 1)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*lucnovdos*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI:  &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2 ^ (n + 1)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.1. Definir la función&lt;br /&gt;
     copia :: nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (copia n x) es la lista formado por n copias del elemento&lt;br /&gt;
  x. Por ejemplo, &lt;br /&gt;
     copia 3 x = [x,x,x]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun copia :: &amp;quot;nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;copia 0 x       = []&amp;quot;&lt;br /&gt;
| &amp;quot;copia (Suc n) x = x # copia n x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Definir la función&lt;br /&gt;
     todos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (todos p xs) se verifica si todos los elementos de xs cumplen&lt;br /&gt;
  la propiedad p. Por ejemplo,&lt;br /&gt;
     todos (λx. x&amp;gt;(1::nat)) [2,6,4] = True&lt;br /&gt;
     todos (λx. x&amp;gt;(2::nat)) [2,6,4] = False&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Demostrar detalladamente que todos los elementos de&lt;br /&gt;
  (copia n x) son iguales a x. &lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom ivamenjim serrodcal ferrenseg wilmorort juacabsou josgarsan*)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y = x) (copia n x)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) =  todos (λy. y = x) (x # (copia n x))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x = x) ∧ (todos (λy. y = x) (copia n x)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos (λy. y = x) (copia (Suc n) x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia 0 x) = todos (λy. y = x) []&amp;quot; by (simp only: copia.simps(1))&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; by (simp only: todos.simps(1))&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n &lt;br /&gt;
 assume H1 : &amp;quot; todos (λy. y = x) (copia n x) &amp;quot;&lt;br /&gt;
 have &amp;quot;todos (λy. y = x) (copia (Suc n) x) = ((todos (λy. y = x) (x#[])) ∧  (todos (λy. y = x) (copia n x) )) &amp;quot; by simp&lt;br /&gt;
 also have &amp;quot; ... = (todos (λy. y = x) (x#[]))&amp;quot; using H1 by simp&lt;br /&gt;
 also have &amp;quot; ... = ((λy. y = x) x ∧ todos (λy. y = x) [])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot; ... = True&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot; todos (λy. y = x) (copia (Suc n) x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha rubgonmar*)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot; (is &amp;quot;?P n&amp;quot;)&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;?P 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;?P n&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y=x) (copia (Suc n) x) = todos (λy. y=x) (x # copia n x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((λy. y=x) x ∧ todos (λy. y=x) (copia n x))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = todos (λy. y=x) (copia n x)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (Suc n)&amp;quot; using HI by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  have &amp;quot;todos (λy. y=x) (copia 0 x) = todos (λy. y=x) []&amp;quot; by (simp only: copia.simps(1))&lt;br /&gt;
  also have &amp;quot;todos (λy. y=x) []&amp;quot; by (simp only: todos.simps(1))&lt;br /&gt;
  show &amp;quot;todos (λy. y=x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
 next &lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y=x) (copia (Suc n) x) = todos (λy. y=x) (x # (copia n x))&amp;quot;&lt;br /&gt;
    by (simp only: copia.simps(2))&lt;br /&gt;
  also have &amp;quot;todos (λy. y=x) (x#(copia n x)) = ((λy. y=x) x ∧ todos (λy. y=x) (copia n x))&amp;quot;&lt;br /&gt;
         by (simp only: todos.simps(2))&lt;br /&gt;
  also have &amp;quot;todos (λy. y=x) (copia (Suc n) x) = ((λy. y=x) x)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;((λy. y=x) x) = True&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;(todos (λy. y=x) (copia (Suc n) x))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto pabrodmac*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) = todos (λy. y=x) (x # copia n x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  ( (λy. y=x) x ∧ todos (λy. y=x) (copia (Suc n) x) ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; todos (λy. y = x) (copia (Suc n) x) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod marpoldia1 *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y = x) (copia n x)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) =todos (λy. y = x) (x # copia n x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((λy. y = x) x ∧ todos (λy. y = x) ( copia n x))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos (λy. y = x) (copia (Suc n) x)&amp;quot; using HI by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*paupeddeg*)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y = x) (copia n x)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) = (todos (λy. y = x) (x # copia n x))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((todos (λy. y = x) [x]) ∧ (todos (λy. y = x) (copia n x)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos(λy. y = x) (copia (Suc n) x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Definir la función&lt;br /&gt;
    factR :: nat ⇒ nat&lt;br /&gt;
  tal que (factR n) es el factorial de n. Por ejemplo,&lt;br /&gt;
    factR 4 = 24&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun factR :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;factR 0       = 1&amp;quot;&lt;br /&gt;
| &amp;quot;factR (Suc n) = Suc n * factR n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Se considera la siguiente definición iterativa de la&lt;br /&gt;
  función factorial &lt;br /&gt;
     factI :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
     factI n = factI&amp;#039; n 1&lt;br /&gt;
     &lt;br /&gt;
     factI&amp;#039; :: nat ⇒ nat ⇒ nat&amp;quot; where&lt;br /&gt;
     factI&amp;#039; 0       x = x&lt;br /&gt;
     factI&amp;#039; (Suc n) x = factI&amp;#039; n (Suc n)*x&lt;br /&gt;
  Demostrar que, para todo n y todo x, se tiene &lt;br /&gt;
     factI&amp;#039; n x = x * factR n&lt;br /&gt;
  Indicación: La propiedad mult_Suc es &lt;br /&gt;
     (Suc m) * n = n + m * n&lt;br /&gt;
  Puede que se necesite desactivarla en un paso con &lt;br /&gt;
     (simp del: mult_Suc)&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
fun factI&amp;#039; :: &amp;quot;nat ⇒ nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;factI&amp;#039; 0       x = x&amp;quot;&lt;br /&gt;
| &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
fun factI :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;factI n = factI&amp;#039; n 1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy , danrodcha serrodcal pablucoto wilmorort anaprarod marpoldia1 juacabsou josgarsan rubgonmar paupeddeg pabrodmac bowma*)&lt;br /&gt;
lemma fact: &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;factI&amp;#039; 0 x = x * factR 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume H1 :  &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
  have  &amp;quot;factI&amp;#039; (Suc n) x =  factI&amp;#039; n (x * Suc n)&amp;quot; by (simp only:factI&amp;#039;.simps(2))&lt;br /&gt;
  also have &amp;quot;... = (x * Suc n) * factR n&amp;quot; using H1 by simp (* no entiendo por qué no hace esto bien y luego todo funciona *) (*Creo que es porque no le estas dando la hipótesis de inducción sino otra que se le parece*)&lt;br /&gt;
  also have &amp;quot;... = x * factR (Suc n)&amp;quot; by (simp del: mult_Suc)&lt;br /&gt;
  finally show &amp;quot;factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom ivamenjim ferrenseg *)&lt;br /&gt;
lemma fact: &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
proof (induct n arbitrary: x)&lt;br /&gt;
  show &amp;quot;⋀x. factI&amp;#039; 0 x = x * factR 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;⋀x. factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
  show &amp;quot;⋀x. factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    fix x&lt;br /&gt;
    have &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot;   by simp&lt;br /&gt;
    also have &amp;quot;... = (x * Suc n) * factR n&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... = x * (Suc n * factR n)&amp;quot; by (simp del: mult_Suc)&lt;br /&gt;
    also have &amp;quot;... = x * factR (Suc n)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot; by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma fact: &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
 have &amp;quot;x * factR 0 = x&amp;quot; by (simp only: factR.simps(1))&lt;br /&gt;
 also have &amp;quot;factI&amp;#039; 0 x = x&amp;quot; by (simp only: factI&amp;#039;.simps(1))&lt;br /&gt;
 show &amp;quot;factI&amp;#039; 0 x = x * factR 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n&lt;br /&gt;
 assume HI: &amp;quot;∀x. factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
 fix x&lt;br /&gt;
 have &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot; by (simp only: factI&amp;#039;.simps(2))&lt;br /&gt;
 also have &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot; by simp&lt;br /&gt;
 have &amp;quot;factI&amp;#039; (Suc n) x = x * Suc n * factR n&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;... = x * factR (Suc n)&amp;quot; by (simp del: mult_Suc)&lt;br /&gt;
 finally  show &amp;quot;factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot; by simp  (* No entiendo por qué no acepta esto como demostrado *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.3. Escribir la demostración detallada de&lt;br /&gt;
     factI n = factR n&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy danrodcha crigomgom ivamenjim serrodcal ferrenseg pablucoto wilmorort rubgonmar marpoldia1 juacabsou josgarsan paupeddeg*)&lt;br /&gt;
corollary &amp;quot;factI n = factR n&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;factI n = factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 1 * factR n&amp;quot; by (simp add: fact)&lt;br /&gt;
  finally show &amp;quot;factI n = factR n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
corollary &amp;quot;factI n = factR n&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
 have &amp;quot;factI n = factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;... = 1 * factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;... = 1 * factR n&amp;quot;  using fact by simp&lt;br /&gt;
 finally show &amp;quot;factI n = factR n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
corollary &amp;quot;factI n = factR n&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
 have &amp;quot;factI n = factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;... = 1 * factR n&amp;quot;  using fact by simp&lt;br /&gt;
 finally show &amp;quot;factI n = factR n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Definir, recursivamente y sin usar (@), la función&lt;br /&gt;
     amplia :: &amp;#039;a list ⇒ &amp;#039;a ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (amplia xs y) es la lista obtenida añadiendo el elemento y al&lt;br /&gt;
  final de la lista xs. Por ejemplo,&lt;br /&gt;
     amplia [d,a] t = [d,a,t]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun amplia :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;amplia []     y = [y]&amp;quot;&lt;br /&gt;
| &amp;quot;amplia (x#xs) y = x # amplia xs y&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Escribir la demostración detallada de&lt;br /&gt;
     amplia xs y = xs @ [y]&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom fraortmoy rubgonmar ivamenjim serrodcal pablucoto wilmorort anaprarod marpoldia1 juacabsou paupeddeg pabrodmac *)&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;amplia [] y = [] @ [y]&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
  have &amp;quot;amplia (x # xs) y = x # (amplia xs y)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x # (xs @ [y])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;amplia (x # xs) y = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha ferrenseg *)&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;amplia (x # xs) y = x # amplia xs y&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (x # xs) @ [y]&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 have &amp;quot;amplia [] y = [y]&amp;quot; by (simp only: amplia.simps(1)) &lt;br /&gt;
 have &amp;quot;[] @ [y] = [y]&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;amplia [] y = [] @ [y]&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
 have &amp;quot;amplia (x # xs) y =  x # amplia xs y&amp;quot; by (simp only: amplia.simps(2))&lt;br /&gt;
 also have &amp;quot;... = x # (xs @ [y])&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;... = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;amplia (x # xs) y = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_3&amp;diff=390</id>
		<title>Relación 3</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_3&amp;diff=390"/>
		<updated>2016-11-16T10:43:57Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R3: Razonamiento sobre programas *}&lt;br /&gt;
&lt;br /&gt;
theory R3_Razonamiento_sobre_programas&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1.1. Definir la función&lt;br /&gt;
     sumaImpares :: nat ⇒ nat&lt;br /&gt;
  tal que (sumaImpares n) es la suma de los n primeros números&lt;br /&gt;
  impares. Por ejemplo,&lt;br /&gt;
     sumaImpares 5  =  25&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun sumaImpares :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaImpares 0 = 0&amp;quot;&lt;br /&gt;
| &amp;quot;sumaImpares (Suc n) = sumaImpares n + (2*n+1)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1.2. Escribir la demostración detallada de &lt;br /&gt;
     sumaImpares n = n*n&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración detallada es&amp;quot;&lt;br /&gt;
(* crigomgom fraortmoy marpoldia1 ivamenjim serrodcal rubgonmar ferrenseg juacabsou wilmorort josgarsan lucnovdos paupeddeg bowma pabrodmac*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0 * 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;sumaImpares n = n * n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + 2*n + 1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = n*n + 2*n + 1&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha ; es la misma demostración que la anterior pero uso ?P para sustituir la propiedad.*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot; (is &amp;quot;?P n&amp;quot;)&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;?P 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;?P n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + 2*n + 1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = n*n + 2*n + 1&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = Suc n * Suc n&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;?P (Suc n)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0*0&amp;quot; by simp&lt;br /&gt;
 next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + 2*n+1&amp;quot; &lt;br /&gt;
   by (simp only: sumaImpares.simps(2))&lt;br /&gt;
  also have &amp;quot;sumaImpares (Suc n) = n*n + 2*n+1&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = (Suc n)*(Suc n)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 - Especifico la regla de simplificación y el paso del desarrollo al cuadrado para hacerlo más legible*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0 * 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI : &amp;quot;sumaImpares n = n * n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + (2 * n + 1)&amp;quot; by (simp only: sumaImpares.simps(2))&lt;br /&gt;
  also have &amp;quot;... = n * n + 2 * n + 1&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*palucoto anaprarod*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0 * 0&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n &lt;br /&gt;
  assume HI : &amp;quot;sumaImpares n = n * n&amp;quot;&lt;br /&gt;
  have &amp;quot; sumaImpares (Suc n) = sumaImpares n + 2*n+1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  n*n + 2*n+1&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2.1. Definir la función&lt;br /&gt;
     sumaPotenciasDeDosMasUno :: nat ⇒ nat&lt;br /&gt;
  tal que &lt;br /&gt;
     (sumaPotenciasDeDosMasUno n) = 1 + 2^0 + 2^1 + 2^2 + ... + 2^n. &lt;br /&gt;
  Por ejemplo, &lt;br /&gt;
     sumaPotenciasDeDosMasUno 3  =  16&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun sumaPotenciasDeDosMasUno :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaPotenciasDeDosMasUno 0 = 2&amp;quot;&lt;br /&gt;
| &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = &lt;br /&gt;
      sumaPotenciasDeDosMasUno n + 2^(n+1)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2.2. Escribir la demostración detallada de &lt;br /&gt;
     sumaPotenciasDeDosMasUno n = 2^(n+1)&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom ivamenjim danrodcha serrodcal rubgonmar ferrenseg juacabsou wilmorort anaprarod marpoldia1 josgarsan paupeddeg pabrodmac bowma*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI:  &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n+1)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ ((Suc n) + 1)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
(* es la misma demostración, pero quise probar a delimitar lo que se usa en el &amp;quot;by simp&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume H1:&amp;quot; sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n + 1)&amp;quot; by (simp only : sumaPotenciasDeDosMasUno.simps(2))&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) =  2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2^(0+1)&amp;quot; by simp&lt;br /&gt;
 next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n+1)&amp;quot;&lt;br /&gt;
   by (simp only: sumaPotenciasDeDosMasUno.simps(2))&lt;br /&gt;
  also have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2^(n+1)+2^(n+1)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2^((Suc n)+1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n &lt;br /&gt;
  assume HI : &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n+1) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2^(n + 1) +  2^( n + 1) &amp;quot; using HI by simp  &lt;br /&gt;
  finally show &amp;quot; sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 - Hago explícita toda la manipulación algebraica. Quizás excesivo.*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induction n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI : &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
    by (simp only:sumaPotenciasDeDosMasUno.simps(2))&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) * 2&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ ((n + 1) + 1)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*lucnovdos*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI:  &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2 ^ (n + 1)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.1. Definir la función&lt;br /&gt;
     copia :: nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (copia n x) es la lista formado por n copias del elemento&lt;br /&gt;
  x. Por ejemplo, &lt;br /&gt;
     copia 3 x = [x,x,x]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun copia :: &amp;quot;nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;copia 0 x       = []&amp;quot;&lt;br /&gt;
| &amp;quot;copia (Suc n) x = x # copia n x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Definir la función&lt;br /&gt;
     todos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (todos p xs) se verifica si todos los elementos de xs cumplen&lt;br /&gt;
  la propiedad p. Por ejemplo,&lt;br /&gt;
     todos (λx. x&amp;gt;(1::nat)) [2,6,4] = True&lt;br /&gt;
     todos (λx. x&amp;gt;(2::nat)) [2,6,4] = False&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Demostrar detalladamente que todos los elementos de&lt;br /&gt;
  (copia n x) son iguales a x. &lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom ivamenjim serrodcal ferrenseg wilmorort juacabsou josgarsan*)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y = x) (copia n x)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) =  todos (λy. y = x) (x # (copia n x))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x = x) ∧ (todos (λy. y = x) (copia n x)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos (λy. y = x) (copia (Suc n) x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia 0 x) = todos (λy. y = x) []&amp;quot; by (simp only: copia.simps(1))&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; by (simp only: todos.simps(1))&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n &lt;br /&gt;
 assume H1 : &amp;quot; todos (λy. y = x) (copia n x) &amp;quot;&lt;br /&gt;
 have &amp;quot;todos (λy. y = x) (copia (Suc n) x) = ((todos (λy. y = x) (x#[])) ∧  (todos (λy. y = x) (copia n x) )) &amp;quot; by simp&lt;br /&gt;
 also have &amp;quot; ... = (todos (λy. y = x) (x#[]))&amp;quot; using H1 by simp&lt;br /&gt;
 also have &amp;quot; ... = ((λy. y = x) x ∧ todos (λy. y = x) [])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot; ... = True&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot; todos (λy. y = x) (copia (Suc n) x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha rubgonmar*)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot; (is &amp;quot;?P n&amp;quot;)&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;?P 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;?P n&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y=x) (copia (Suc n) x) = todos (λy. y=x) (x # copia n x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((λy. y=x) x ∧ todos (λy. y=x) (copia n x))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = todos (λy. y=x) (copia n x)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (Suc n)&amp;quot; using HI by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  have &amp;quot;todos (λy. y=x) (copia 0 x) = todos (λy. y=x) []&amp;quot; by (simp only: copia.simps(1))&lt;br /&gt;
  also have &amp;quot;todos (λy. y=x) []&amp;quot; by (simp only: todos.simps(1))&lt;br /&gt;
  show &amp;quot;todos (λy. y=x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
 next &lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y=x) (copia (Suc n) x) = todos (λy. y=x) (x # (copia n x))&amp;quot;&lt;br /&gt;
    by (simp only: copia.simps(2))&lt;br /&gt;
  also have &amp;quot;todos (λy. y=x) (x#(copia n x)) = ((λy. y=x) x ∧ todos (λy. y=x) (copia n x))&amp;quot;&lt;br /&gt;
         by (simp only: todos.simps(2))&lt;br /&gt;
  also have &amp;quot;todos (λy. y=x) (copia (Suc n) x) = ((λy. y=x) x)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;((λy. y=x) x) = True&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;(todos (λy. y=x) (copia (Suc n) x))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto pabrodmac*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) = todos (λy. y=x) (x # copia n x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  ( (λy. y=x) x ∧ todos (λy. y=x) (copia (Suc n) x) ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; todos (λy. y = x) (copia (Suc n) x) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod marpoldia1 *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y = x) (copia n x)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) =todos (λy. y = x) (x # copia n x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((λy. y = x) x ∧ todos (λy. y = x) ( copia n x))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos (λy. y = x) (copia (Suc n) x)&amp;quot; using HI by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*paupeddeg*)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y = x) (copia n x)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) = (todos (λy. y = x) (x # copia n x))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((todos (λy. y = x) [x]) ∧ (todos (λy. y = x) (copia n x)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos(λy. y = x) (copia (Suc n) x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Definir la función&lt;br /&gt;
    factR :: nat ⇒ nat&lt;br /&gt;
  tal que (factR n) es el factorial de n. Por ejemplo,&lt;br /&gt;
    factR 4 = 24&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun factR :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;factR 0       = 1&amp;quot;&lt;br /&gt;
| &amp;quot;factR (Suc n) = Suc n * factR n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Se considera la siguiente definición iterativa de la&lt;br /&gt;
  función factorial &lt;br /&gt;
     factI :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
     factI n = factI&amp;#039; n 1&lt;br /&gt;
     &lt;br /&gt;
     factI&amp;#039; :: nat ⇒ nat ⇒ nat&amp;quot; where&lt;br /&gt;
     factI&amp;#039; 0       x = x&lt;br /&gt;
     factI&amp;#039; (Suc n) x = factI&amp;#039; n (Suc n)*x&lt;br /&gt;
  Demostrar que, para todo n y todo x, se tiene &lt;br /&gt;
     factI&amp;#039; n x = x * factR n&lt;br /&gt;
  Indicación: La propiedad mult_Suc es &lt;br /&gt;
     (Suc m) * n = n + m * n&lt;br /&gt;
  Puede que se necesite desactivarla en un paso con &lt;br /&gt;
     (simp del: mult_Suc)&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
fun factI&amp;#039; :: &amp;quot;nat ⇒ nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;factI&amp;#039; 0       x = x&amp;quot;&lt;br /&gt;
| &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
fun factI :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;factI n = factI&amp;#039; n 1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy , danrodcha serrodcal pablucoto wilmorort anaprarod marpoldia1 juacabsou josgarsan rubgonmar paupeddeg pabrodmac*)&lt;br /&gt;
lemma fact: &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;factI&amp;#039; 0 x = x * factR 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume H1 :  &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
  have  &amp;quot;factI&amp;#039; (Suc n) x =  factI&amp;#039; n (x * Suc n)&amp;quot; by (simp only:factI&amp;#039;.simps(2))&lt;br /&gt;
  also have &amp;quot;... = (x * Suc n) * factR n&amp;quot; using H1 by simp (* no entiendo por qué no hace esto bien y luego todo funciona *) (*Creo que es porque no le estas dando la hipótesis de inducción sino otra que se le parece*)&lt;br /&gt;
  also have &amp;quot;... = x * factR (Suc n)&amp;quot; by (simp del: mult_Suc)&lt;br /&gt;
  finally show &amp;quot;factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom ivamenjim ferrenseg *)&lt;br /&gt;
lemma fact: &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
proof (induct n arbitrary: x)&lt;br /&gt;
  show &amp;quot;⋀x. factI&amp;#039; 0 x = x * factR 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;⋀x. factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
  show &amp;quot;⋀x. factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    fix x&lt;br /&gt;
    have &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot;   by simp&lt;br /&gt;
    also have &amp;quot;... = (x * Suc n) * factR n&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... = x * (Suc n * factR n)&amp;quot; by (simp del: mult_Suc)&lt;br /&gt;
    also have &amp;quot;... = x * factR (Suc n)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot; by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma fact: &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
 have &amp;quot;x * factR 0 = x&amp;quot; by (simp only: factR.simps(1))&lt;br /&gt;
 also have &amp;quot;factI&amp;#039; 0 x = x&amp;quot; by (simp only: factI&amp;#039;.simps(1))&lt;br /&gt;
 show &amp;quot;factI&amp;#039; 0 x = x * factR 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n&lt;br /&gt;
 assume HI: &amp;quot;∀x. factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
 fix x&lt;br /&gt;
 have &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot; by (simp only: factI&amp;#039;.simps(2))&lt;br /&gt;
 also have &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot; by simp&lt;br /&gt;
 have &amp;quot;factI&amp;#039; (Suc n) x = x * Suc n * factR n&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;... = x * factR (Suc n)&amp;quot; by (simp del: mult_Suc)&lt;br /&gt;
 finally  show &amp;quot;factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot; by simp  (* No entiendo por qué no acepta esto como demostrado *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.3. Escribir la demostración detallada de&lt;br /&gt;
     factI n = factR n&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy danrodcha crigomgom ivamenjim serrodcal ferrenseg pablucoto wilmorort rubgonmar marpoldia1 juacabsou josgarsan paupeddeg*)&lt;br /&gt;
corollary &amp;quot;factI n = factR n&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;factI n = factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 1 * factR n&amp;quot; by (simp add: fact)&lt;br /&gt;
  finally show &amp;quot;factI n = factR n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
corollary &amp;quot;factI n = factR n&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
 have &amp;quot;factI n = factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;... = 1 * factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;... = 1 * factR n&amp;quot;  using fact by simp&lt;br /&gt;
 finally show &amp;quot;factI n = factR n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac*)&lt;br /&gt;
corollary &amp;quot;factI n = factR n&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
 have &amp;quot;factI n = factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;... = 1 * factR n&amp;quot;  using fact by simp&lt;br /&gt;
 finally show &amp;quot;factI n = factR n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Definir, recursivamente y sin usar (@), la función&lt;br /&gt;
     amplia :: &amp;#039;a list ⇒ &amp;#039;a ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (amplia xs y) es la lista obtenida añadiendo el elemento y al&lt;br /&gt;
  final de la lista xs. Por ejemplo,&lt;br /&gt;
     amplia [d,a] t = [d,a,t]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun amplia :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;amplia []     y = [y]&amp;quot;&lt;br /&gt;
| &amp;quot;amplia (x#xs) y = x # amplia xs y&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Escribir la demostración detallada de&lt;br /&gt;
     amplia xs y = xs @ [y]&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom fraortmoy rubgonmar ivamenjim serrodcal pablucoto wilmorort anaprarod marpoldia1 juacabsou paupeddeg *)&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;amplia [] y = [] @ [y]&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
  have &amp;quot;amplia (x # xs) y = x # (amplia xs y)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x # (xs @ [y])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;amplia (x # xs) y = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha ferrenseg *)&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;amplia (x # xs) y = x # amplia xs y&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (x # xs) @ [y]&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 have &amp;quot;amplia [] y = [y]&amp;quot; by (simp only: amplia.simps(1)) &lt;br /&gt;
 have &amp;quot;[] @ [y] = [y]&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;amplia [] y = [] @ [y]&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
 have &amp;quot;amplia (x # xs) y =  x # amplia xs y&amp;quot; by (simp only: amplia.simps(2))&lt;br /&gt;
 also have &amp;quot;... = x # (xs @ [y])&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;... = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;amplia (x # xs) y = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_3&amp;diff=389</id>
		<title>Relación 3</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_3&amp;diff=389"/>
		<updated>2016-11-16T10:43:39Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R3: Razonamiento sobre programas *}&lt;br /&gt;
&lt;br /&gt;
theory R3_Razonamiento_sobre_programas&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1.1. Definir la función&lt;br /&gt;
     sumaImpares :: nat ⇒ nat&lt;br /&gt;
  tal que (sumaImpares n) es la suma de los n primeros números&lt;br /&gt;
  impares. Por ejemplo,&lt;br /&gt;
     sumaImpares 5  =  25&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun sumaImpares :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaImpares 0 = 0&amp;quot;&lt;br /&gt;
| &amp;quot;sumaImpares (Suc n) = sumaImpares n + (2*n+1)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1.2. Escribir la demostración detallada de &lt;br /&gt;
     sumaImpares n = n*n&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración detallada es&amp;quot;&lt;br /&gt;
(* crigomgom fraortmoy marpoldia1 ivamenjim serrodcal rubgonmar ferrenseg juacabsou wilmorort josgarsan lucnovdos paupeddeg bowma pabrodmac*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0 * 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;sumaImpares n = n * n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + 2*n + 1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = n*n + 2*n + 1&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha ; es la misma demostración que la anterior pero uso ?P para sustituir la propiedad.*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot; (is &amp;quot;?P n&amp;quot;)&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;?P 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;?P n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + 2*n + 1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = n*n + 2*n + 1&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = Suc n * Suc n&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;?P (Suc n)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0*0&amp;quot; by simp&lt;br /&gt;
 next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + 2*n+1&amp;quot; &lt;br /&gt;
   by (simp only: sumaImpares.simps(2))&lt;br /&gt;
  also have &amp;quot;sumaImpares (Suc n) = n*n + 2*n+1&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = (Suc n)*(Suc n)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 - Especifico la regla de simplificación y el paso del desarrollo al cuadrado para hacerlo más legible*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0 * 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI : &amp;quot;sumaImpares n = n * n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + (2 * n + 1)&amp;quot; by (simp only: sumaImpares.simps(2))&lt;br /&gt;
  also have &amp;quot;... = n * n + 2 * n + 1&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*palucoto anaprarod*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0 * 0&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n &lt;br /&gt;
  assume HI : &amp;quot;sumaImpares n = n * n&amp;quot;&lt;br /&gt;
  have &amp;quot; sumaImpares (Suc n) = sumaImpares n + 2*n+1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  n*n + 2*n+1&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2.1. Definir la función&lt;br /&gt;
     sumaPotenciasDeDosMasUno :: nat ⇒ nat&lt;br /&gt;
  tal que &lt;br /&gt;
     (sumaPotenciasDeDosMasUno n) = 1 + 2^0 + 2^1 + 2^2 + ... + 2^n. &lt;br /&gt;
  Por ejemplo, &lt;br /&gt;
     sumaPotenciasDeDosMasUno 3  =  16&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun sumaPotenciasDeDosMasUno :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaPotenciasDeDosMasUno 0 = 2&amp;quot;&lt;br /&gt;
| &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = &lt;br /&gt;
      sumaPotenciasDeDosMasUno n + 2^(n+1)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2.2. Escribir la demostración detallada de &lt;br /&gt;
     sumaPotenciasDeDosMasUno n = 2^(n+1)&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom ivamenjim danrodcha serrodcal rubgonmar ferrenseg juacabsou wilmorort anaprarod marpoldia1 josgarsan paupeddeg pabrodmac bowma*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI:  &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n+1)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ ((Suc n) + 1)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
(* es la misma demostración, pero quise probar a delimitar lo que se usa en el &amp;quot;by simp&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume H1:&amp;quot; sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n + 1)&amp;quot; by (simp only : sumaPotenciasDeDosMasUno.simps(2))&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) =  2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2^(0+1)&amp;quot; by simp&lt;br /&gt;
 next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n+1)&amp;quot;&lt;br /&gt;
   by (simp only: sumaPotenciasDeDosMasUno.simps(2))&lt;br /&gt;
  also have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2^(n+1)+2^(n+1)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2^((Suc n)+1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n &lt;br /&gt;
  assume HI : &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n+1) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2^(n + 1) +  2^( n + 1) &amp;quot; using HI by simp  &lt;br /&gt;
  finally show &amp;quot; sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 - Hago explícita toda la manipulación algebraica. Quizás excesivo.*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induction n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI : &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
    by (simp only:sumaPotenciasDeDosMasUno.simps(2))&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) * 2&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ ((n + 1) + 1)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*lucnovdos*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI:  &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2 ^ (n + 1)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.1. Definir la función&lt;br /&gt;
     copia :: nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (copia n x) es la lista formado por n copias del elemento&lt;br /&gt;
  x. Por ejemplo, &lt;br /&gt;
     copia 3 x = [x,x,x]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun copia :: &amp;quot;nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;copia 0 x       = []&amp;quot;&lt;br /&gt;
| &amp;quot;copia (Suc n) x = x # copia n x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Definir la función&lt;br /&gt;
     todos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (todos p xs) se verifica si todos los elementos de xs cumplen&lt;br /&gt;
  la propiedad p. Por ejemplo,&lt;br /&gt;
     todos (λx. x&amp;gt;(1::nat)) [2,6,4] = True&lt;br /&gt;
     todos (λx. x&amp;gt;(2::nat)) [2,6,4] = False&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Demostrar detalladamente que todos los elementos de&lt;br /&gt;
  (copia n x) son iguales a x. &lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom ivamenjim serrodcal ferrenseg wilmorort juacabsou josgarsan*)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y = x) (copia n x)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) =  todos (λy. y = x) (x # (copia n x))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x = x) ∧ (todos (λy. y = x) (copia n x)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos (λy. y = x) (copia (Suc n) x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia 0 x) = todos (λy. y = x) []&amp;quot; by (simp only: copia.simps(1))&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; by (simp only: todos.simps(1))&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n &lt;br /&gt;
 assume H1 : &amp;quot; todos (λy. y = x) (copia n x) &amp;quot;&lt;br /&gt;
 have &amp;quot;todos (λy. y = x) (copia (Suc n) x) = ((todos (λy. y = x) (x#[])) ∧  (todos (λy. y = x) (copia n x) )) &amp;quot; by simp&lt;br /&gt;
 also have &amp;quot; ... = (todos (λy. y = x) (x#[]))&amp;quot; using H1 by simp&lt;br /&gt;
 also have &amp;quot; ... = ((λy. y = x) x ∧ todos (λy. y = x) [])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot; ... = True&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot; todos (λy. y = x) (copia (Suc n) x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha rubgonmar*)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot; (is &amp;quot;?P n&amp;quot;)&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;?P 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;?P n&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y=x) (copia (Suc n) x) = todos (λy. y=x) (x # copia n x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((λy. y=x) x ∧ todos (λy. y=x) (copia n x))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = todos (λy. y=x) (copia n x)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (Suc n)&amp;quot; using HI by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  have &amp;quot;todos (λy. y=x) (copia 0 x) = todos (λy. y=x) []&amp;quot; by (simp only: copia.simps(1))&lt;br /&gt;
  also have &amp;quot;todos (λy. y=x) []&amp;quot; by (simp only: todos.simps(1))&lt;br /&gt;
  show &amp;quot;todos (λy. y=x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
 next &lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y=x) (copia (Suc n) x) = todos (λy. y=x) (x # (copia n x))&amp;quot;&lt;br /&gt;
    by (simp only: copia.simps(2))&lt;br /&gt;
  also have &amp;quot;todos (λy. y=x) (x#(copia n x)) = ((λy. y=x) x ∧ todos (λy. y=x) (copia n x))&amp;quot;&lt;br /&gt;
         by (simp only: todos.simps(2))&lt;br /&gt;
  also have &amp;quot;todos (λy. y=x) (copia (Suc n) x) = ((λy. y=x) x)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;((λy. y=x) x) = True&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;(todos (λy. y=x) (copia (Suc n) x))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto pabrodmac*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) = todos (λy. y=x) (x # copia n x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  ( (λy. y=x) x ∧ todos (λy. y=x) (copia (Suc n) x) ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; todos (λy. y = x) (copia (Suc n) x) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod marpoldia1 *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y = x) (copia n x)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) =todos (λy. y = x) (x # copia n x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((λy. y = x) x ∧ todos (λy. y = x) ( copia n x))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos (λy. y = x) (copia (Suc n) x)&amp;quot; using HI by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*paupeddeg*)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y = x) (copia n x)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) = (todos (λy. y = x) (x # copia n x))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((todos (λy. y = x) [x]) ∧ (todos (λy. y = x) (copia n x)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos(λy. y = x) (copia (Suc n) x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Definir la función&lt;br /&gt;
    factR :: nat ⇒ nat&lt;br /&gt;
  tal que (factR n) es el factorial de n. Por ejemplo,&lt;br /&gt;
    factR 4 = 24&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun factR :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;factR 0       = 1&amp;quot;&lt;br /&gt;
| &amp;quot;factR (Suc n) = Suc n * factR n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Se considera la siguiente definición iterativa de la&lt;br /&gt;
  función factorial &lt;br /&gt;
     factI :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
     factI n = factI&amp;#039; n 1&lt;br /&gt;
     &lt;br /&gt;
     factI&amp;#039; :: nat ⇒ nat ⇒ nat&amp;quot; where&lt;br /&gt;
     factI&amp;#039; 0       x = x&lt;br /&gt;
     factI&amp;#039; (Suc n) x = factI&amp;#039; n (Suc n)*x&lt;br /&gt;
  Demostrar que, para todo n y todo x, se tiene &lt;br /&gt;
     factI&amp;#039; n x = x * factR n&lt;br /&gt;
  Indicación: La propiedad mult_Suc es &lt;br /&gt;
     (Suc m) * n = n + m * n&lt;br /&gt;
  Puede que se necesite desactivarla en un paso con &lt;br /&gt;
     (simp del: mult_Suc)&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
fun factI&amp;#039; :: &amp;quot;nat ⇒ nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;factI&amp;#039; 0       x = x&amp;quot;&lt;br /&gt;
| &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
fun factI :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;factI n = factI&amp;#039; n 1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy , danrodcha serrodcal pablucoto wilmorort anaprarod marpoldia1 juacabsou josgarsan rubgonmar paupeddeg pabrodmac*)&lt;br /&gt;
lemma fact: &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;factI&amp;#039; 0 x = x * factR 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume H1 :  &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
  have  &amp;quot;factI&amp;#039; (Suc n) x =  factI&amp;#039; n (x * Suc n)&amp;quot; by (simp only:factI&amp;#039;.simps(2))&lt;br /&gt;
  also have &amp;quot;... = (x * Suc n) * factR n&amp;quot; using H1 by simp (* no entiendo por qué no hace esto bien y luego todo funciona *) (*Creo que es porque no le estas dando la hipótesis de inducción sino otra que se le parece*)&lt;br /&gt;
  also have &amp;quot;... = x * factR (Suc n)&amp;quot; by (simp del: mult_Suc)&lt;br /&gt;
  finally show &amp;quot;factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom ivamenjim ferrenseg *)&lt;br /&gt;
lemma fact: &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
proof (induct n arbitrary: x)&lt;br /&gt;
  show &amp;quot;⋀x. factI&amp;#039; 0 x = x * factR 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;⋀x. factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
  show &amp;quot;⋀x. factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    fix x&lt;br /&gt;
    have &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot;   by simp&lt;br /&gt;
    also have &amp;quot;... = (x * Suc n) * factR n&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... = x * (Suc n * factR n)&amp;quot; by (simp del: mult_Suc)&lt;br /&gt;
    also have &amp;quot;... = x * factR (Suc n)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot; by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma fact: &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
 have &amp;quot;x * factR 0 = x&amp;quot; by (simp only: factR.simps(1))&lt;br /&gt;
 also have &amp;quot;factI&amp;#039; 0 x = x&amp;quot; by (simp only: factI&amp;#039;.simps(1))&lt;br /&gt;
 show &amp;quot;factI&amp;#039; 0 x = x * factR 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n&lt;br /&gt;
 assume HI: &amp;quot;∀x. factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
 fix x&lt;br /&gt;
 have &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot; by (simp only: factI&amp;#039;.simps(2))&lt;br /&gt;
 also have &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot; by simp&lt;br /&gt;
 have &amp;quot;factI&amp;#039; (Suc n) x = x * Suc n * factR n&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;... = x * factR (Suc n)&amp;quot; by (simp del: mult_Suc)&lt;br /&gt;
 finally  show &amp;quot;factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot; by simp  (* No entiendo por qué no acepta esto como demostrado *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.3. Escribir la demostración detallada de&lt;br /&gt;
     factI n = factR n&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy danrodcha crigomgom ivamenjim serrodcal ferrenseg pablucoto wilmorort rubgonmar marpoldia1 juacabsou josgarsan paupeddeg*)&lt;br /&gt;
corollary &amp;quot;factI n = factR n&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;factI n = factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 1 * factR n&amp;quot; by (simp add: fact)&lt;br /&gt;
  finally show &amp;quot;factI n = factR n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
corollary &amp;quot;factI n = factR n&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
 have &amp;quot;factI n = factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;... = 1 * factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;... = 1 * factR n&amp;quot;  using fact by simp&lt;br /&gt;
 finally show &amp;quot;factI n = factR n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pabrodmac)&lt;br /&gt;
corollary &amp;quot;factI n = factR n&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
 have &amp;quot;factI n = factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;... = 1 * factR n&amp;quot;  using fact by simp&lt;br /&gt;
 finally show &amp;quot;factI n = factR n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Definir, recursivamente y sin usar (@), la función&lt;br /&gt;
     amplia :: &amp;#039;a list ⇒ &amp;#039;a ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (amplia xs y) es la lista obtenida añadiendo el elemento y al&lt;br /&gt;
  final de la lista xs. Por ejemplo,&lt;br /&gt;
     amplia [d,a] t = [d,a,t]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun amplia :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;amplia []     y = [y]&amp;quot;&lt;br /&gt;
| &amp;quot;amplia (x#xs) y = x # amplia xs y&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Escribir la demostración detallada de&lt;br /&gt;
     amplia xs y = xs @ [y]&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom fraortmoy rubgonmar ivamenjim serrodcal pablucoto wilmorort anaprarod marpoldia1 juacabsou paupeddeg *)&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;amplia [] y = [] @ [y]&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
  have &amp;quot;amplia (x # xs) y = x # (amplia xs y)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x # (xs @ [y])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;amplia (x # xs) y = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha ferrenseg *)&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;amplia (x # xs) y = x # amplia xs y&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (x # xs) @ [y]&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 have &amp;quot;amplia [] y = [y]&amp;quot; by (simp only: amplia.simps(1)) &lt;br /&gt;
 have &amp;quot;[] @ [y] = [y]&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;amplia [] y = [] @ [y]&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
 have &amp;quot;amplia (x # xs) y =  x # amplia xs y&amp;quot; by (simp only: amplia.simps(2))&lt;br /&gt;
 also have &amp;quot;... = x # (xs @ [y])&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;... = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;amplia (x # xs) y = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_3&amp;diff=388</id>
		<title>Relación 3</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_3&amp;diff=388"/>
		<updated>2016-11-16T10:32:04Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R3: Razonamiento sobre programas *}&lt;br /&gt;
&lt;br /&gt;
theory R3_Razonamiento_sobre_programas&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1.1. Definir la función&lt;br /&gt;
     sumaImpares :: nat ⇒ nat&lt;br /&gt;
  tal que (sumaImpares n) es la suma de los n primeros números&lt;br /&gt;
  impares. Por ejemplo,&lt;br /&gt;
     sumaImpares 5  =  25&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun sumaImpares :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaImpares 0 = 0&amp;quot;&lt;br /&gt;
| &amp;quot;sumaImpares (Suc n) = sumaImpares n + (2*n+1)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1.2. Escribir la demostración detallada de &lt;br /&gt;
     sumaImpares n = n*n&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración detallada es&amp;quot;&lt;br /&gt;
(* crigomgom fraortmoy marpoldia1 ivamenjim serrodcal rubgonmar ferrenseg juacabsou wilmorort josgarsan lucnovdos paupeddeg bowma pabrodmac*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0 * 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;sumaImpares n = n * n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + 2*n + 1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = n*n + 2*n + 1&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha ; es la misma demostración que la anterior pero uso ?P para sustituir la propiedad.*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot; (is &amp;quot;?P n&amp;quot;)&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;?P 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;?P n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + 2*n + 1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = n*n + 2*n + 1&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = Suc n * Suc n&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;?P (Suc n)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0*0&amp;quot; by simp&lt;br /&gt;
 next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + 2*n+1&amp;quot; &lt;br /&gt;
   by (simp only: sumaImpares.simps(2))&lt;br /&gt;
  also have &amp;quot;sumaImpares (Suc n) = n*n + 2*n+1&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = (Suc n)*(Suc n)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 - Especifico la regla de simplificación y el paso del desarrollo al cuadrado para hacerlo más legible*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0 * 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI : &amp;quot;sumaImpares n = n * n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + (2 * n + 1)&amp;quot; by (simp only: sumaImpares.simps(2))&lt;br /&gt;
  also have &amp;quot;... = n * n + 2 * n + 1&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*palucoto anaprarod*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0 * 0&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n &lt;br /&gt;
  assume HI : &amp;quot;sumaImpares n = n * n&amp;quot;&lt;br /&gt;
  have &amp;quot; sumaImpares (Suc n) = sumaImpares n + 2*n+1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  n*n + 2*n+1&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2.1. Definir la función&lt;br /&gt;
     sumaPotenciasDeDosMasUno :: nat ⇒ nat&lt;br /&gt;
  tal que &lt;br /&gt;
     (sumaPotenciasDeDosMasUno n) = 1 + 2^0 + 2^1 + 2^2 + ... + 2^n. &lt;br /&gt;
  Por ejemplo, &lt;br /&gt;
     sumaPotenciasDeDosMasUno 3  =  16&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun sumaPotenciasDeDosMasUno :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaPotenciasDeDosMasUno 0 = 2&amp;quot;&lt;br /&gt;
| &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = &lt;br /&gt;
      sumaPotenciasDeDosMasUno n + 2^(n+1)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2.2. Escribir la demostración detallada de &lt;br /&gt;
     sumaPotenciasDeDosMasUno n = 2^(n+1)&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom ivamenjim danrodcha serrodcal rubgonmar ferrenseg juacabsou wilmorort anaprarod marpoldia1 josgarsan paupeddeg pabrodmac bowma*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI:  &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n+1)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ ((Suc n) + 1)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
(* es la misma demostración, pero quise probar a delimitar lo que se usa en el &amp;quot;by simp&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume H1:&amp;quot; sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n + 1)&amp;quot; by (simp only : sumaPotenciasDeDosMasUno.simps(2))&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) =  2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2^(0+1)&amp;quot; by simp&lt;br /&gt;
 next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n+1)&amp;quot;&lt;br /&gt;
   by (simp only: sumaPotenciasDeDosMasUno.simps(2))&lt;br /&gt;
  also have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2^(n+1)+2^(n+1)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2^((Suc n)+1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n &lt;br /&gt;
  assume HI : &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n+1) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2^(n + 1) +  2^( n + 1) &amp;quot; using HI by simp  &lt;br /&gt;
  finally show &amp;quot; sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 - Hago explícita toda la manipulación algebraica. Quizás excesivo.*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induction n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI : &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
    by (simp only:sumaPotenciasDeDosMasUno.simps(2))&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) * 2&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ ((n + 1) + 1)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*lucnovdos*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI:  &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2 ^ (n + 1)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.1. Definir la función&lt;br /&gt;
     copia :: nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (copia n x) es la lista formado por n copias del elemento&lt;br /&gt;
  x. Por ejemplo, &lt;br /&gt;
     copia 3 x = [x,x,x]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun copia :: &amp;quot;nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;copia 0 x       = []&amp;quot;&lt;br /&gt;
| &amp;quot;copia (Suc n) x = x # copia n x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Definir la función&lt;br /&gt;
     todos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (todos p xs) se verifica si todos los elementos de xs cumplen&lt;br /&gt;
  la propiedad p. Por ejemplo,&lt;br /&gt;
     todos (λx. x&amp;gt;(1::nat)) [2,6,4] = True&lt;br /&gt;
     todos (λx. x&amp;gt;(2::nat)) [2,6,4] = False&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Demostrar detalladamente que todos los elementos de&lt;br /&gt;
  (copia n x) son iguales a x. &lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom ivamenjim serrodcal ferrenseg wilmorort juacabsou josgarsan*)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y = x) (copia n x)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) =  todos (λy. y = x) (x # (copia n x))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x = x) ∧ (todos (λy. y = x) (copia n x)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos (λy. y = x) (copia (Suc n) x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia 0 x) = todos (λy. y = x) []&amp;quot; by (simp only: copia.simps(1))&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; by (simp only: todos.simps(1))&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n &lt;br /&gt;
 assume H1 : &amp;quot; todos (λy. y = x) (copia n x) &amp;quot;&lt;br /&gt;
 have &amp;quot;todos (λy. y = x) (copia (Suc n) x) = ((todos (λy. y = x) (x#[])) ∧  (todos (λy. y = x) (copia n x) )) &amp;quot; by simp&lt;br /&gt;
 also have &amp;quot; ... = (todos (λy. y = x) (x#[]))&amp;quot; using H1 by simp&lt;br /&gt;
 also have &amp;quot; ... = ((λy. y = x) x ∧ todos (λy. y = x) [])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot; ... = True&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot; todos (λy. y = x) (copia (Suc n) x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha rubgonmar*)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot; (is &amp;quot;?P n&amp;quot;)&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;?P 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;?P n&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y=x) (copia (Suc n) x) = todos (λy. y=x) (x # copia n x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((λy. y=x) x ∧ todos (λy. y=x) (copia n x))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = todos (λy. y=x) (copia n x)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (Suc n)&amp;quot; using HI by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  have &amp;quot;todos (λy. y=x) (copia 0 x) = todos (λy. y=x) []&amp;quot; by (simp only: copia.simps(1))&lt;br /&gt;
  also have &amp;quot;todos (λy. y=x) []&amp;quot; by (simp only: todos.simps(1))&lt;br /&gt;
  show &amp;quot;todos (λy. y=x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
 next &lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y=x) (copia (Suc n) x) = todos (λy. y=x) (x # (copia n x))&amp;quot;&lt;br /&gt;
    by (simp only: copia.simps(2))&lt;br /&gt;
  also have &amp;quot;todos (λy. y=x) (x#(copia n x)) = ((λy. y=x) x ∧ todos (λy. y=x) (copia n x))&amp;quot;&lt;br /&gt;
         by (simp only: todos.simps(2))&lt;br /&gt;
  also have &amp;quot;todos (λy. y=x) (copia (Suc n) x) = ((λy. y=x) x)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;((λy. y=x) x) = True&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;(todos (λy. y=x) (copia (Suc n) x))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto pabrodmac*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) = todos (λy. y=x) (x # copia n x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  ( (λy. y=x) x ∧ todos (λy. y=x) (copia (Suc n) x) ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; todos (λy. y = x) (copia (Suc n) x) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod marpoldia1 *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y = x) (copia n x)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) =todos (λy. y = x) (x # copia n x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((λy. y = x) x ∧ todos (λy. y = x) ( copia n x))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos (λy. y = x) (copia (Suc n) x)&amp;quot; using HI by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*paupeddeg*)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y = x) (copia n x)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) = (todos (λy. y = x) (x # copia n x))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((todos (λy. y = x) [x]) ∧ (todos (λy. y = x) (copia n x)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos(λy. y = x) (copia (Suc n) x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Definir la función&lt;br /&gt;
    factR :: nat ⇒ nat&lt;br /&gt;
  tal que (factR n) es el factorial de n. Por ejemplo,&lt;br /&gt;
    factR 4 = 24&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun factR :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;factR 0       = 1&amp;quot;&lt;br /&gt;
| &amp;quot;factR (Suc n) = Suc n * factR n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Se considera la siguiente definición iterativa de la&lt;br /&gt;
  función factorial &lt;br /&gt;
     factI :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
     factI n = factI&amp;#039; n 1&lt;br /&gt;
     &lt;br /&gt;
     factI&amp;#039; :: nat ⇒ nat ⇒ nat&amp;quot; where&lt;br /&gt;
     factI&amp;#039; 0       x = x&lt;br /&gt;
     factI&amp;#039; (Suc n) x = factI&amp;#039; n (Suc n)*x&lt;br /&gt;
  Demostrar que, para todo n y todo x, se tiene &lt;br /&gt;
     factI&amp;#039; n x = x * factR n&lt;br /&gt;
  Indicación: La propiedad mult_Suc es &lt;br /&gt;
     (Suc m) * n = n + m * n&lt;br /&gt;
  Puede que se necesite desactivarla en un paso con &lt;br /&gt;
     (simp del: mult_Suc)&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
fun factI&amp;#039; :: &amp;quot;nat ⇒ nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;factI&amp;#039; 0       x = x&amp;quot;&lt;br /&gt;
| &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
fun factI :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;factI n = factI&amp;#039; n 1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy , danrodcha serrodcal pablucoto wilmorort anaprarod marpoldia1 juacabsou josgarsan rubgonmar paupeddeg pabrodmac*)&lt;br /&gt;
lemma fact: &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;factI&amp;#039; 0 x = x * factR 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume H1 :  &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
  have  &amp;quot;factI&amp;#039; (Suc n) x =  factI&amp;#039; n (x * Suc n)&amp;quot; by (simp only:factI&amp;#039;.simps(2))&lt;br /&gt;
  also have &amp;quot;... = (x * Suc n) * factR n&amp;quot; using H1 by simp (* no entiendo por qué no hace esto bien y luego todo funciona *) (*Creo que es porque no le estas dando la hipótesis de inducción sino otra que se le parece*)&lt;br /&gt;
  also have &amp;quot;... = x * factR (Suc n)&amp;quot; by (simp del: mult_Suc)&lt;br /&gt;
  finally show &amp;quot;factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom ivamenjim ferrenseg *)&lt;br /&gt;
lemma fact: &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
proof (induct n arbitrary: x)&lt;br /&gt;
  show &amp;quot;⋀x. factI&amp;#039; 0 x = x * factR 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;⋀x. factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
  show &amp;quot;⋀x. factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    fix x&lt;br /&gt;
    have &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot;   by simp&lt;br /&gt;
    also have &amp;quot;... = (x * Suc n) * factR n&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... = x * (Suc n * factR n)&amp;quot; by (simp del: mult_Suc)&lt;br /&gt;
    also have &amp;quot;... = x * factR (Suc n)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot; by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma fact: &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
 have &amp;quot;x * factR 0 = x&amp;quot; by (simp only: factR.simps(1))&lt;br /&gt;
 also have &amp;quot;factI&amp;#039; 0 x = x&amp;quot; by (simp only: factI&amp;#039;.simps(1))&lt;br /&gt;
 show &amp;quot;factI&amp;#039; 0 x = x * factR 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n&lt;br /&gt;
 assume HI: &amp;quot;∀x. factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
 fix x&lt;br /&gt;
 have &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot; by (simp only: factI&amp;#039;.simps(2))&lt;br /&gt;
 also have &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot; by simp&lt;br /&gt;
 have &amp;quot;factI&amp;#039; (Suc n) x = x * Suc n * factR n&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;... = x * factR (Suc n)&amp;quot; by (simp del: mult_Suc)&lt;br /&gt;
 finally  show &amp;quot;factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot; by simp  (* No entiendo por qué no acepta esto como demostrado *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.3. Escribir la demostración detallada de&lt;br /&gt;
     factI n = factR n&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy danrodcha crigomgom ivamenjim serrodcal ferrenseg pablucoto wilmorort rubgonmar marpoldia1 juacabsou josgarsan paupeddeg*)&lt;br /&gt;
corollary &amp;quot;factI n = factR n&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;factI n = factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 1 * factR n&amp;quot; by (simp add: fact)&lt;br /&gt;
  finally show &amp;quot;factI n = factR n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
corollary &amp;quot;factI n = factR n&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
 have &amp;quot;factI n = factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;... = 1 * factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;... = 1 * factR n&amp;quot;  using fact by simp&lt;br /&gt;
 finally show &amp;quot;factI n = factR n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Definir, recursivamente y sin usar (@), la función&lt;br /&gt;
     amplia :: &amp;#039;a list ⇒ &amp;#039;a ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (amplia xs y) es la lista obtenida añadiendo el elemento y al&lt;br /&gt;
  final de la lista xs. Por ejemplo,&lt;br /&gt;
     amplia [d,a] t = [d,a,t]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun amplia :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;amplia []     y = [y]&amp;quot;&lt;br /&gt;
| &amp;quot;amplia (x#xs) y = x # amplia xs y&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Escribir la demostración detallada de&lt;br /&gt;
     amplia xs y = xs @ [y]&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom fraortmoy rubgonmar ivamenjim serrodcal pablucoto wilmorort anaprarod marpoldia1 juacabsou paupeddeg *)&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;amplia [] y = [] @ [y]&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
  have &amp;quot;amplia (x # xs) y = x # (amplia xs y)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x # (xs @ [y])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;amplia (x # xs) y = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha ferrenseg *)&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;amplia (x # xs) y = x # amplia xs y&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (x # xs) @ [y]&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 have &amp;quot;amplia [] y = [y]&amp;quot; by (simp only: amplia.simps(1)) &lt;br /&gt;
 have &amp;quot;[] @ [y] = [y]&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;amplia [] y = [] @ [y]&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
 have &amp;quot;amplia (x # xs) y =  x # amplia xs y&amp;quot; by (simp only: amplia.simps(2))&lt;br /&gt;
 also have &amp;quot;... = x # (xs @ [y])&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;... = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;amplia (x # xs) y = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_3&amp;diff=386</id>
		<title>Relación 3</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_3&amp;diff=386"/>
		<updated>2016-11-16T10:11:27Z</updated>

		<summary type="html">&lt;p&gt;Pabrodmac: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R3: Razonamiento sobre programas *}&lt;br /&gt;
&lt;br /&gt;
theory R3_Razonamiento_sobre_programas&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1.1. Definir la función&lt;br /&gt;
     sumaImpares :: nat ⇒ nat&lt;br /&gt;
  tal que (sumaImpares n) es la suma de los n primeros números&lt;br /&gt;
  impares. Por ejemplo,&lt;br /&gt;
     sumaImpares 5  =  25&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun sumaImpares :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaImpares 0 = 0&amp;quot;&lt;br /&gt;
| &amp;quot;sumaImpares (Suc n) = sumaImpares n + (2*n+1)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1.2. Escribir la demostración detallada de &lt;br /&gt;
     sumaImpares n = n*n&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración detallada es&amp;quot;&lt;br /&gt;
(* crigomgom fraortmoy marpoldia1 ivamenjim serrodcal rubgonmar ferrenseg juacabsou wilmorort josgarsan lucnovdos paupeddeg bowma pabrodmac*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0 * 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;sumaImpares n = n * n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + 2*n + 1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = n*n + 2*n + 1&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha ; es la misma demostración que la anterior pero uso ?P para sustituir la propiedad.*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot; (is &amp;quot;?P n&amp;quot;)&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;?P 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;?P n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + 2*n + 1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = n*n + 2*n + 1&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = Suc n * Suc n&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;?P (Suc n)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0*0&amp;quot; by simp&lt;br /&gt;
 next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + 2*n+1&amp;quot; &lt;br /&gt;
   by (simp only: sumaImpares.simps(2))&lt;br /&gt;
  also have &amp;quot;sumaImpares (Suc n) = n*n + 2*n+1&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = (Suc n)*(Suc n)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 - Especifico la regla de simplificación y el paso del desarrollo al cuadrado para hacerlo más legible*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0 * 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI : &amp;quot;sumaImpares n = n * n&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaImpares (Suc n) = sumaImpares n + (2 * n + 1)&amp;quot; by (simp only: sumaImpares.simps(2))&lt;br /&gt;
  also have &amp;quot;... = n * n + 2 * n + 1&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*palucoto anaprarod*)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaImpares 0 = 0 * 0&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n &lt;br /&gt;
  assume HI : &amp;quot;sumaImpares n = n * n&amp;quot;&lt;br /&gt;
  have &amp;quot; sumaImpares (Suc n) = sumaImpares n + 2*n+1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  n*n + 2*n+1&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2.1. Definir la función&lt;br /&gt;
     sumaPotenciasDeDosMasUno :: nat ⇒ nat&lt;br /&gt;
  tal que &lt;br /&gt;
     (sumaPotenciasDeDosMasUno n) = 1 + 2^0 + 2^1 + 2^2 + ... + 2^n. &lt;br /&gt;
  Por ejemplo, &lt;br /&gt;
     sumaPotenciasDeDosMasUno 3  =  16&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun sumaPotenciasDeDosMasUno :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaPotenciasDeDosMasUno 0 = 2&amp;quot;&lt;br /&gt;
| &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = &lt;br /&gt;
      sumaPotenciasDeDosMasUno n + 2^(n+1)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2.2. Escribir la demostración detallada de &lt;br /&gt;
     sumaPotenciasDeDosMasUno n = 2^(n+1)&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom ivamenjim danrodcha serrodcal rubgonmar ferrenseg juacabsou wilmorort anaprarod marpoldia1 josgarsan paupeddeg pabrodmac*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI:  &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n+1)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ ((Suc n) + 1)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
(* es la misma demostración, pero quise probar a delimitar lo que se usa en el &amp;quot;by simp&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume H1:&amp;quot; sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n + 1)&amp;quot; by (simp only : sumaPotenciasDeDosMasUno.simps(2))&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using H1 by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) =  2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2^(0+1)&amp;quot; by simp&lt;br /&gt;
 next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n+1)&amp;quot;&lt;br /&gt;
   by (simp only: sumaPotenciasDeDosMasUno.simps(2))&lt;br /&gt;
  also have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2^(n+1)+2^(n+1)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2^((Suc n)+1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n &lt;br /&gt;
  assume HI : &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2^(n+1) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2^(n + 1) +  2^( n + 1) &amp;quot; using HI by simp  &lt;br /&gt;
  finally show &amp;quot; sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 - Hago explícita toda la manipulación algebraica. Quizás excesivo.*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induction n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI : &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
    by (simp only:sumaPotenciasDeDosMasUno.simps(2))&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) * 2&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ ((n + 1) + 1)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*lucnovdos*)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2 ^ (0 + 1)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI:  &amp;quot;sumaPotenciasDeDosMasUno n = 2 ^ (n + 1)&amp;quot;&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = sumaPotenciasDeDosMasUno n + 2 ^ (n + 1)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 2 ^ (n + 1) + 2 ^ (n + 1)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2 ^ (Suc n + 1)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.1. Definir la función&lt;br /&gt;
     copia :: nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (copia n x) es la lista formado por n copias del elemento&lt;br /&gt;
  x. Por ejemplo, &lt;br /&gt;
     copia 3 x = [x,x,x]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun copia :: &amp;quot;nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;copia 0 x       = []&amp;quot;&lt;br /&gt;
| &amp;quot;copia (Suc n) x = x # copia n x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Definir la función&lt;br /&gt;
     todos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (todos p xs) se verifica si todos los elementos de xs cumplen&lt;br /&gt;
  la propiedad p. Por ejemplo,&lt;br /&gt;
     todos (λx. x&amp;gt;(1::nat)) [2,6,4] = True&lt;br /&gt;
     todos (λx. x&amp;gt;(2::nat)) [2,6,4] = False&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Demostrar detalladamente que todos los elementos de&lt;br /&gt;
  (copia n x) son iguales a x. &lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom ivamenjim serrodcal ferrenseg wilmorort juacabsou josgarsan*)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y = x) (copia n x)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) =  todos (λy. y = x) (x # (copia n x))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((x = x) ∧ (todos (λy. y = x) (copia n x)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos (λy. y = x) (copia (Suc n) x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia 0 x) = todos (λy. y = x) []&amp;quot; by (simp only: copia.simps(1))&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; by (simp only: todos.simps(1))&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n &lt;br /&gt;
 assume H1 : &amp;quot; todos (λy. y = x) (copia n x) &amp;quot;&lt;br /&gt;
 have &amp;quot;todos (λy. y = x) (copia (Suc n) x) = ((todos (λy. y = x) (x#[])) ∧  (todos (λy. y = x) (copia n x) )) &amp;quot; by simp&lt;br /&gt;
 also have &amp;quot; ... = (todos (λy. y = x) (x#[]))&amp;quot; using H1 by simp&lt;br /&gt;
 also have &amp;quot; ... = ((λy. y = x) x ∧ todos (λy. y = x) [])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot; ... = True&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot; todos (λy. y = x) (copia (Suc n) x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha rubgonmar*)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot; (is &amp;quot;?P n&amp;quot;)&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;?P 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;?P n&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y=x) (copia (Suc n) x) = todos (λy. y=x) (x # copia n x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((λy. y=x) x ∧ todos (λy. y=x) (copia n x))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = todos (λy. y=x) (copia n x)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (Suc n)&amp;quot; using HI by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  have &amp;quot;todos (λy. y=x) (copia 0 x) = todos (λy. y=x) []&amp;quot; by (simp only: copia.simps(1))&lt;br /&gt;
  also have &amp;quot;todos (λy. y=x) []&amp;quot; by (simp only: todos.simps(1))&lt;br /&gt;
  show &amp;quot;todos (λy. y=x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
 next &lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y=x) (copia (Suc n) x) = todos (λy. y=x) (x # (copia n x))&amp;quot;&lt;br /&gt;
    by (simp only: copia.simps(2))&lt;br /&gt;
  also have &amp;quot;todos (λy. y=x) (x#(copia n x)) = ((λy. y=x) x ∧ todos (λy. y=x) (copia n x))&amp;quot;&lt;br /&gt;
         by (simp only: todos.simps(2))&lt;br /&gt;
  also have &amp;quot;todos (λy. y=x) (copia (Suc n) x) = ((λy. y=x) x)&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;((λy. y=x) x) = True&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;(todos (λy. y=x) (copia (Suc n) x))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*pablucoto pabrodmac*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) = todos (λy. y=x) (x # copia n x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... =  ( (λy. y=x) x ∧ todos (λy. y=x) (copia (Suc n) x) ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot; todos (λy. y = x) (copia (Suc n) x) &amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod marpoldia1 *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y = x) (copia n x)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) =todos (λy. y = x) (x # copia n x)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((λy. y = x) x ∧ todos (λy. y = x) ( copia n x))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos (λy. y = x) (copia (Suc n) x)&amp;quot; using HI by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*paupeddeg*)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;todos (λy. y = x) (copia 0 x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;todos (λy. y = x) (copia n x)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λy. y = x) (copia (Suc n) x) = (todos (λy. y = x) (x # copia n x))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = ((todos (λy. y = x) [x]) ∧ (todos (λy. y = x) (copia n x)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = True&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos(λy. y = x) (copia (Suc n) x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Definir la función&lt;br /&gt;
    factR :: nat ⇒ nat&lt;br /&gt;
  tal que (factR n) es el factorial de n. Por ejemplo,&lt;br /&gt;
    factR 4 = 24&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun factR :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;factR 0       = 1&amp;quot;&lt;br /&gt;
| &amp;quot;factR (Suc n) = Suc n * factR n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Se considera la siguiente definición iterativa de la&lt;br /&gt;
  función factorial &lt;br /&gt;
     factI :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
     factI n = factI&amp;#039; n 1&lt;br /&gt;
     &lt;br /&gt;
     factI&amp;#039; :: nat ⇒ nat ⇒ nat&amp;quot; where&lt;br /&gt;
     factI&amp;#039; 0       x = x&lt;br /&gt;
     factI&amp;#039; (Suc n) x = factI&amp;#039; n (Suc n)*x&lt;br /&gt;
  Demostrar que, para todo n y todo x, se tiene &lt;br /&gt;
     factI&amp;#039; n x = x * factR n&lt;br /&gt;
  Indicación: La propiedad mult_Suc es &lt;br /&gt;
     (Suc m) * n = n + m * n&lt;br /&gt;
  Puede que se necesite desactivarla en un paso con &lt;br /&gt;
     (simp del: mult_Suc)&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
fun factI&amp;#039; :: &amp;quot;nat ⇒ nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;factI&amp;#039; 0       x = x&amp;quot;&lt;br /&gt;
| &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
fun factI :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;factI n = factI&amp;#039; n 1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy , danrodcha serrodcal pablucoto wilmorort anaprarod marpoldia1 juacabsou josgarsan rubgonmar paupeddeg*)&lt;br /&gt;
lemma fact: &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;factI&amp;#039; 0 x = x * factR 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume H1 :  &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
  have  &amp;quot;factI&amp;#039; (Suc n) x =  factI&amp;#039; n (x * Suc n)&amp;quot; by (simp only:factI&amp;#039;.simps(2))&lt;br /&gt;
  also have &amp;quot;... = (x * Suc n) * factR n&amp;quot; using H1 by simp (* no entiendo por qué no hace esto bien y luego todo funciona *)&lt;br /&gt;
  also have &amp;quot;... = x * factR (Suc n)&amp;quot; by (simp del: mult_Suc)&lt;br /&gt;
  finally show &amp;quot;factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom ivamenjim ferrenseg *)&lt;br /&gt;
lemma fact: &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
proof (induct n arbitrary: x)&lt;br /&gt;
  show &amp;quot;⋀x. factI&amp;#039; 0 x = x * factR 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume HI: &amp;quot;⋀x. factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
  show &amp;quot;⋀x. factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    fix x&lt;br /&gt;
    have &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot;   by simp&lt;br /&gt;
    also have &amp;quot;... = (x * Suc n) * factR n&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;... = x * (Suc n * factR n)&amp;quot; by (simp del: mult_Suc)&lt;br /&gt;
    also have &amp;quot;... = x * factR (Suc n)&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot; by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
&lt;br /&gt;
lemma fact: &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
 have &amp;quot;x * factR 0 = x&amp;quot; by (simp only: factR.simps(1))&lt;br /&gt;
 also have &amp;quot;factI&amp;#039; 0 x = x&amp;quot; by (simp only: factI&amp;#039;.simps(1))&lt;br /&gt;
 show &amp;quot;factI&amp;#039; 0 x = x * factR 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n&lt;br /&gt;
 assume HI: &amp;quot;∀x. factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
 fix x&lt;br /&gt;
 have &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot; by (simp only: factI&amp;#039;.simps(2))&lt;br /&gt;
 also have &amp;quot;factI&amp;#039; (Suc n) x = factI&amp;#039; n (x * Suc n)&amp;quot; by simp&lt;br /&gt;
 have &amp;quot;factI&amp;#039; (Suc n) x = x * Suc n * factR n&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;... = x * factR (Suc n)&amp;quot; by (simp del: mult_Suc)&lt;br /&gt;
 finally  show &amp;quot;factI&amp;#039; (Suc n) x = x * factR (Suc n)&amp;quot; by simp  (* No entiendo por qué no acepta esto como demostrado *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.3. Escribir la demostración detallada de&lt;br /&gt;
     factI n = factR n&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy danrodcha crigomgom ivamenjim serrodcal ferrenseg pablucoto wilmorort rubgonmar marpoldia1 juacabsou josgarsan paupeddeg*)&lt;br /&gt;
corollary &amp;quot;factI n = factR n&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;factI n = factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = 1 * factR n&amp;quot; by (simp add: fact)&lt;br /&gt;
  finally show &amp;quot;factI n = factR n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
corollary &amp;quot;factI n = factR n&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
 have &amp;quot;factI n = factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;... = 1 * factI&amp;#039; n 1&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;... = 1 * factR n&amp;quot;  using fact by simp&lt;br /&gt;
 finally show &amp;quot;factI n = factR n&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Definir, recursivamente y sin usar (@), la función&lt;br /&gt;
     amplia :: &amp;#039;a list ⇒ &amp;#039;a ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (amplia xs y) es la lista obtenida añadiendo el elemento y al&lt;br /&gt;
  final de la lista xs. Por ejemplo,&lt;br /&gt;
     amplia [d,a] t = [d,a,t]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
fun amplia :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;amplia []     y = [y]&amp;quot;&lt;br /&gt;
| &amp;quot;amplia (x#xs) y = x # amplia xs y&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Escribir la demostración detallada de&lt;br /&gt;
     amplia xs y = xs @ [y]&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom fraortmoy rubgonmar ivamenjim serrodcal pablucoto wilmorort anaprarod marpoldia1 juacabsou paupeddeg *)&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;amplia [] y = [] @ [y]&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
  have &amp;quot;amplia (x # xs) y = x # (amplia xs y)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x # (xs @ [y])&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;amplia (x # xs) y = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(*danrodcha ferrenseg *)&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  have &amp;quot;amplia (x # xs) y = x # amplia xs y&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (x # xs) @ [y]&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
 have &amp;quot;amplia [] y = [y]&amp;quot; by (simp only: amplia.simps(1)) &lt;br /&gt;
 have &amp;quot;[] @ [y] = [y]&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;amplia [] y = [] @ [y]&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix x xs&lt;br /&gt;
 assume HI: &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
 have &amp;quot;amplia (x # xs) y =  x # amplia xs y&amp;quot; by (simp only: amplia.simps(2))&lt;br /&gt;
 also have &amp;quot;... = x # (xs @ [y])&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;... = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;amplia (x # xs) y = (x # xs) @ [y]&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pabrodmac</name></author>
		
	</entry>
</feed>