<?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=Danrodcha</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=Danrodcha"/>
	<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php/Especial:Contribuciones/Danrodcha"/>
	<updated>2026-07-17T07:58:22Z</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=1405</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=1405"/>
		<updated>2017-01-29T18:28:56Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 *)&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;
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 *)&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 *)&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;
&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 *)&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;
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*)&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_10&amp;diff=1391</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=1391"/>
		<updated>2017-01-28T17:17:43Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 *)&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*)&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;
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 *)&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 *)&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 *)&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;
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 *)&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. 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;
&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 *)&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_10&amp;diff=1390</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=1390"/>
		<updated>2017-01-28T17:05:49Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 *)&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*)&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;
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 *)&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 *)&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 *)&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;
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 *)&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. 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;
&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_10&amp;diff=1389</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=1389"/>
		<updated>2017-01-28T17:04:59Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 : Se aceptan órdenes del operador.&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&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*)&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;
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 *)&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 *)&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 *)&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;
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 *)&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. 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;
&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_10&amp;diff=1385</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=1385"/>
		<updated>2017-01-27T15:05:00Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 : Se aceptan órdenes del operador.&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&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*)&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;
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 *)&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;
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;
&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_10&amp;diff=1384</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=1384"/>
		<updated>2017-01-27T14:35:34Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 : Se aceptan órdenes del operador.&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&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*)&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;
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 *)&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;
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;
&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_8&amp;diff=1267</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=1267"/>
		<updated>2017-01-16T11:39:20Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 jeamacpov *)&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*)&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 *)&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 *)&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 jeamacpov *)&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 *)&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 *)&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 *)&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;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Demostrar&lt;br /&gt;
     ¬(¬p ∨ ¬q) ⊢ p ∧ q&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
(* marcarmor13 jeamacpov *)&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 *)&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 *)&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;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Demostrar&lt;br /&gt;
     ¬(p ∧ q) ⊢ ¬p ∨ ¬q&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
(* marcarmor13 jeamacpov *)&lt;br /&gt;
--&amp;quot;usando un supuesto p ∧ q&amp;quot;&lt;br /&gt;
 lemma ejercicio_4:&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 *)&lt;br /&gt;
lemma ejercicio_4:&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 *)&lt;br /&gt;
lemma ejercicio_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;
{ 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 *)&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;
&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 *)&lt;br /&gt;
--&amp;quot;usando un supuesto q&amp;quot;&lt;br /&gt;
lemma ejercicio_5:&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 *)&lt;br /&gt;
lemma ejercicio_5:&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 *)&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_8&amp;diff=1266</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=1266"/>
		<updated>2017-01-16T11:35:18Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 jeamacpov *)&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*)&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 *)&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 *)&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 jeamacpov *)&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 *)&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 *)&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 *)&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;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Demostrar&lt;br /&gt;
     ¬(¬p ∨ ¬q) ⊢ p ∧ q&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
(* marcarmor13 jeamacpov *)&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 *)&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 *)&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;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Demostrar&lt;br /&gt;
     ¬(p ∧ q) ⊢ ¬p ∨ ¬q&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
(* marcarmor13 jeamacpov *)&lt;br /&gt;
--&amp;quot;usando un supuesto p ∧ q&amp;quot;&lt;br /&gt;
 lemma ejercicio_4:&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 *)&lt;br /&gt;
lemma ejercicio_4:&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 *)&lt;br /&gt;
lemma ejercicio_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;
{ 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;
&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 *)&lt;br /&gt;
--&amp;quot;usando un supuesto q&amp;quot;&lt;br /&gt;
lemma ejercicio_5:&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 *)&lt;br /&gt;
lemma ejercicio_5:&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_7&amp;diff=1156</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=1156"/>
		<updated>2016-12-19T23:02:56Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 *)&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*)&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;
&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*)&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 *)&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;
&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 &lt;br /&gt;
                    then a else b)&amp;quot;&lt;br /&gt;
&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 i d) = 1 + maximo(profundidad i, profundidad d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: llamando a la función anterior profundidad3 *)&lt;br /&gt;
&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;
&lt;br /&gt;
(* ivamenjim *)&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;
(* fraortmoy marpoldia1 anaprarod paupeddeg migtermor  wilmorort &lt;br /&gt;
    serrodcal crigomgom rubgonmar danrodcha *)&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*)&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 *)&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;
&lt;br /&gt;
(* marpoldia1 paupeddeg ivamenjim pablucoto*)&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;
&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 *)&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 crigomgom &lt;br /&gt;
    rubgonmar ivamenjim danrodcha *)&lt;br /&gt;
(* También funciona con AUX7 *)&lt;br /&gt;
&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;
&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;
&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;
&lt;br /&gt;
(* Otra forma de escribir lo mismo *)&lt;br /&gt;
(* anaprarod crigomgom*)&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;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod wilmorort pablucoto serrodcal *)&lt;br /&gt;
&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;
(* anaprarod crigomgom*)&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;
&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 lej8: &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;
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*)&lt;br /&gt;
&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;
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 crigomgom*)&lt;br /&gt;
&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;
&lt;br /&gt;
(* anaprarod rubgonmar danrodcha *)&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;
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;
&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;
&lt;br /&gt;
(* Otra forma de escribir lo mismo *)&lt;br /&gt;
(* anaprarod crigomgom rubgonmar *)&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;
&lt;br /&gt;
(* anaprarod  wilmorort pablucoto serrodcal  danrodcha*)&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 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;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_7&amp;diff=1155</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=1155"/>
		<updated>2016-12-19T22:58:17Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 *)&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*)&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;
&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*)&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 *)&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;
&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 &lt;br /&gt;
                    then a else b)&amp;quot;&lt;br /&gt;
&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 i d) = 1 + maximo(profundidad i, profundidad d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: llamando a la función anterior profundidad3 *)&lt;br /&gt;
&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;
&lt;br /&gt;
(* ivamenjim *)&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;
(* fraortmoy marpoldia1 anaprarod paupeddeg migtermor  wilmorort &lt;br /&gt;
    serrodcal crigomgom rubgonmar danrodcha *)&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*)&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 *)&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;
&lt;br /&gt;
(* marpoldia1 paupeddeg ivamenjim pablucoto*)&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;
&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 *)&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 crigomgom &lt;br /&gt;
    rubgonmar ivamenjim danrodcha *)&lt;br /&gt;
(* También funciona con AUX7 *)&lt;br /&gt;
&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;
&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;
&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;
&lt;br /&gt;
(* Otra forma de escribir lo mismo *)&lt;br /&gt;
(* anaprarod crigomgom*)&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;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod wilmorort pablucoto serrodcal *)&lt;br /&gt;
&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;
(* anaprarod crigomgom*)&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;
&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 lej8: &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;
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*)&lt;br /&gt;
&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;
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 crigomgom*)&lt;br /&gt;
&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;
&lt;br /&gt;
(* anaprarod rubgonmar *)&lt;br /&gt;
(* con un demostrador más débil *)&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;
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;
&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;
&lt;br /&gt;
(* Otra forma de escribir lo mismo *)&lt;br /&gt;
(* anaprarod crigomgom rubgonmar *)&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;
&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;
&lt;br /&gt;
(* anaprarod  wilmorort pablucoto serrodcal *)&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;
&lt;br /&gt;
(*crigomgom *)&lt;br /&gt;
(* Como en la primera de las soluciones he usado la función constante 0 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;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_7&amp;diff=1154</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=1154"/>
		<updated>2016-12-19T22:51:27Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 *)&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*)&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;
&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*)&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 *)&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;
&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 &lt;br /&gt;
                    then a else b)&amp;quot;&lt;br /&gt;
&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 i d) = 1 + maximo(profundidad i, profundidad d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: llamando a la función anterior profundidad3 *)&lt;br /&gt;
&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;
&lt;br /&gt;
(* ivamenjim *)&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;
(* fraortmoy marpoldia1 anaprarod paupeddeg migtermor  wilmorort &lt;br /&gt;
    serrodcal crigomgom rubgonmar danrodcha *)&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*)&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;
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;
&lt;br /&gt;
(* marpoldia1 paupeddeg ivamenjim pablucoto*)&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;
&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 *)&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;
(* fraortmoy marpoldia1 migtermor anaprarod wilmorort serrodcal crigomgom rubgonmar ivamenjim *)&lt;br /&gt;
(* También funciona con AUX7 *)&lt;br /&gt;
&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;
&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;
&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;
&lt;br /&gt;
(* Otra forma de escribir lo mismo *)&lt;br /&gt;
(* anaprarod crigomgom*)&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;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod wilmorort pablucoto serrodcal *)&lt;br /&gt;
&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;
(* anaprarod crigomgom*)&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;
&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 lej8: &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;
&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 serrodcal crigomgom rubgonmar *)&lt;br /&gt;
&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;
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 crigomgom*)&lt;br /&gt;
&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;
&lt;br /&gt;
(* anaprarod rubgonmar *)&lt;br /&gt;
(* con un demostrador más débil *)&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;
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;
&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;
&lt;br /&gt;
(* Otra forma de escribir lo mismo *)&lt;br /&gt;
(* anaprarod crigomgom rubgonmar *)&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;
&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;
&lt;br /&gt;
(* anaprarod  wilmorort pablucoto serrodcal *)&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;
&lt;br /&gt;
(*crigomgom *)&lt;br /&gt;
(* Como en la primera de las soluciones he usado la función constante 0 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;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=1044</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=1044"/>
		<updated>2016-12-13T14:49:57Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 &lt;br /&gt;
   juacabsou serrodcal pabrodmac ferrenseg rubgonmar paupeddeg &lt;br /&gt;
   crigomgom danrodcha*)&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 &lt;br /&gt;
   wilmorort lucnovdos serrodcal pabrodmac jeamacpov paupeddeg*)&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 ferrenseg &lt;br /&gt;
   rubgonmar paupeddeg *)&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&lt;br /&gt;
    pablucoto bowma fraortmoy migtermor wilmorort lucnovdos&lt;br /&gt;
    juacabsou serrodcal pabrodmac  ferrenseg jeamacpov &lt;br /&gt;
    rubgonmar paupeddeg *)&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 &lt;br /&gt;
   migtermor wilmorort lucnovdos juacabsou serrodcal pabrodmac &lt;br /&gt;
   ferrenseg jeamacpov rubgonmar paupeddeg*)&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 &lt;br /&gt;
   pablucoto bowma fraortmoy migtermor wilmorort lucnovdos &lt;br /&gt;
   juacabsou serrodcal pabrodmac ferrenseg jeamacpov rubgonmar &lt;br /&gt;
   paupeddeg *)&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 paupeddeg *)&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 jeamacpov paupeddeg*)&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;
&lt;br /&gt;
(* ferrenseg rubgonmar *)&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 l r&lt;br /&gt;
  assume H1: &amp;quot;?P l&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x l r)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;preOrden (espejo (N x l r)) = &lt;br /&gt;
          preOrden (N x (espejo r) (espejo l))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = x # (preOrden (espejo r) @ preOrden (espejo l))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = x # (rev (postOrden r) @ rev (postOrden l))&amp;quot; &lt;br /&gt;
       using H1 H2 by simp &lt;br /&gt;
    also have &amp;quot;… = x # rev (postOrden l @ postOrden r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev ((postOrden l) @ (postOrden r) @ [x])&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev (postOrden (N x l r))&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 jeamacpov paupeddeg rubgonmar *)&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 paupeddeg *)&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;
(* ferrenseg *)&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 l r&lt;br /&gt;
  assume H1: &amp;quot;?P l&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x l r)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;postOrden (espejo (N x l r)) = &lt;br /&gt;
          postOrden (N x (espejo r) (espejo l))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = postOrden (espejo r) @ postOrden (espejo l) @ [x]&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev (preOrden r) @ rev (preOrden l) @ [x]&amp;quot; &lt;br /&gt;
       using H1 H2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev (preOrden l @ preOrden r) @ [x]&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev ([x] @ preOrden l @ preOrden r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev (preOrden (N x l r))&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 jeamacpov paupeddeg *)&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 paupeddeg *)&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;
(* ferrenseg rubgonmar *)&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 i d&lt;br /&gt;
  assume H1: &amp;quot;?P l&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x l r)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;inOrden (espejo (N x l r)) = &lt;br /&gt;
          inOrden (N x (espejo r) (espejo l))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = inOrden (espejo r) @ [x] @ inOrden (espejo l)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev (inOrden r) @ [x] @ rev (inOrden l)&amp;quot; &lt;br /&gt;
       using H1 H2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev (inOrden l @ [x] @ inOrden r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev (inOrden (N x l r))&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 &lt;br /&gt;
   migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal &lt;br /&gt;
   ferrenseg paupeddeg rubgonmar *)&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 &lt;br /&gt;
   migtermor marpoldia1 wilmorort lucnovdos  juacabsou serrodcal &lt;br /&gt;
   pabrodmac ferrenseg jeamacpov paupeddeg rubgonmar *)&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. &lt;br /&gt;
   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 &lt;br /&gt;
   migtermor marpoldia1 wilmorort lucnovdos  juacabsou pabrodmac &lt;br /&gt;
   serrodcal ferrenseg jeamacpov paupeddeg rubgonmar *)&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. &lt;br /&gt;
   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 serrodcal &lt;br /&gt;
   rubgonmar *)&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 paupeddeg *)&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;
(* ferrenseg *)&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 l r&lt;br /&gt;
  assume HI: &amp;quot;?P r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x l r)&amp;quot;&lt;br /&gt;
  proof -  &lt;br /&gt;
    have &amp;quot;last (inOrden (N x l r)) = &lt;br /&gt;
          last (inOrden r @ [x] @ inOrden r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = last (inOrden r)&amp;quot;  by (simp add: inOrden)&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha r&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… =  extremo_derecha (N x l r)&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 serrodcal jeamacpov*)&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 paupeddeg rubgonmar *)&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 paupeddeg*)&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;
(* ferrenseg *)&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 l r&lt;br /&gt;
  assume HI: &amp;quot;?P l&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x l r)&amp;quot;&lt;br /&gt;
  proof - &lt;br /&gt;
    have &amp;quot;hd (inOrden (N x l r)) = &lt;br /&gt;
          hd (inOrden l @ [x] @ inOrden r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = hd (inOrden l)&amp;quot;  by (simp add: inOrden)&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda l&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda (N x l r)&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 jeamacpov paupeddeg rubgonmar *) (*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 serrodcal *)&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 paupeddeg *)&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;
(* ferrenseg *)&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 (cases a)&lt;br /&gt;
  fix x&lt;br /&gt;
  assume &amp;quot;a = H x&amp;quot;&lt;br /&gt;
  then show &amp;quot;?P a&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x l r&lt;br /&gt;
  assume H: &amp;quot;a = N x l r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P a&amp;quot;&lt;br /&gt;
  proof - &lt;br /&gt;
    have &amp;quot;hd (preOrden a) = hd (preOrden (N x l r))&amp;quot; using H by simp&lt;br /&gt;
    also have &amp;quot;… = hd (x # (preOrden l @ preOrden r))&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 l @ postOrden r @ [x])&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = last (postOrden (N x l r))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = last (postOrden a)&amp;quot; using H 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 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 serrodcal jeamacpov paupeddeg rubgonmar *)&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 paupeddeg *)&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;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (cases a)&lt;br /&gt;
  fix x&lt;br /&gt;
  assume &amp;quot;a = H x&amp;quot;&lt;br /&gt;
  then show &amp;quot;?P a&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x l r&lt;br /&gt;
  assume H: &amp;quot;a = N x l r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P a&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;hd (preOrden a) = hd (preOrden (N x l r))&amp;quot; using H by simp&lt;br /&gt;
    also have &amp;quot;… = hd (x#(preOrden l @ preOrden r))&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 l r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = raiz a&amp;quot; using H 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 serrodcal ferrenseg jeamacpov paupeddeg rubgonmar *)&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 serrodcal jeamacpov paupeddeg rubgonmar *) (*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 paupeddeg*)&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;
(* ferrenseg *)&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 (cases a)&lt;br /&gt;
  fix x&lt;br /&gt;
  assume &amp;quot;a = H x&amp;quot;&lt;br /&gt;
  then show &amp;quot;?P a&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x l r&lt;br /&gt;
  assume H: &amp;quot;a = N x l r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P a&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;last (postOrden a) = last (postOrden (N x l r))&amp;quot; using H by simp&lt;br /&gt;
    also have &amp;quot;… = last (postOrden l @ preOrden r @ [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 a&amp;quot; using H by simp&lt;br /&gt;
    finally show ?thesis .&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>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=1043</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=1043"/>
		<updated>2016-12-13T14:39:56Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 &lt;br /&gt;
   juacabsou serrodcal pabrodmac ferrenseg rubgonmar paupeddeg &lt;br /&gt;
   crigomgom danrodcha*)&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 &lt;br /&gt;
   wilmorort lucnovdos serrodcal pabrodmac jeamacpov paupeddeg*)&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 ferrenseg &lt;br /&gt;
   rubgonmar paupeddeg *)&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  ferrenseg jeamacpov rubgonmar paupeddeg *)&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 ferrenseg jeamacpov rubgonmar paupeddeg*)&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 ferrenseg jeamacpov rubgonmar paupeddeg *)&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 paupeddeg *)&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 jeamacpov paupeddeg*)&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;
&lt;br /&gt;
(* ferrenseg rubgonmar *)&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 l r&lt;br /&gt;
  assume H1: &amp;quot;?P l&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x l r)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;preOrden (espejo (N x l r)) = &lt;br /&gt;
          preOrden (N x (espejo r) (espejo l))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = x # (preOrden (espejo r) @ preOrden (espejo l))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = x # (rev (postOrden r) @ rev (postOrden l))&amp;quot; &lt;br /&gt;
       using H1 H2 by simp &lt;br /&gt;
    also have &amp;quot;… = x # rev (postOrden l @ postOrden r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev ((postOrden l) @ (postOrden r) @ [x])&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev (postOrden (N x l r))&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 jeamacpov paupeddeg rubgonmar *)&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 paupeddeg *)&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;
(* ferrenseg *)&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 l r&lt;br /&gt;
  assume H1: &amp;quot;?P l&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x l r)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;postOrden (espejo (N x l r)) = &lt;br /&gt;
          postOrden (N x (espejo r) (espejo l))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = postOrden (espejo r) @ postOrden (espejo l) @ [x]&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev (preOrden r) @ rev (preOrden l) @ [x]&amp;quot; &lt;br /&gt;
       using H1 H2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev (preOrden l @ preOrden r) @ [x]&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev ([x] @ preOrden l @ preOrden r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev (preOrden (N x l r))&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 jeamacpov paupeddeg *)&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 paupeddeg *)&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;
(* ferrenseg rubgonmar *)&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 i d&lt;br /&gt;
  assume H1: &amp;quot;?P l&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x l r)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;inOrden (espejo (N x l r)) = &lt;br /&gt;
          inOrden (N x (espejo r) (espejo l))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = inOrden (espejo r) @ [x] @ inOrden (espejo l)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev (inOrden r) @ [x] @ rev (inOrden l)&amp;quot; &lt;br /&gt;
       using H1 H2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev (inOrden l @ [x] @ inOrden r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev (inOrden (N x l r))&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 ferrenseg paupeddeg rubgonmar *)&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 ferrenseg jeamacpov paupeddeg rubgonmar *)&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 serrodcal ferrenseg jeamacpov paupeddeg rubgonmar *)&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 serrodcal rubgonmar *)&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 paupeddeg *)&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;
(* ferrenseg *)&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 l r&lt;br /&gt;
  assume HI: &amp;quot;?P r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x l r)&amp;quot;&lt;br /&gt;
  proof -  &lt;br /&gt;
    have &amp;quot;last (inOrden (N x l r)) = &lt;br /&gt;
          last (inOrden r @ [x] @ inOrden r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = last (inOrden r)&amp;quot;  by (simp add: inOrden)&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha r&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… =  extremo_derecha (N x l r)&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 serrodcal jeamacpov*)&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 paupeddeg rubgonmar *)&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 paupeddeg*)&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;
(* ferrenseg *)&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 l r&lt;br /&gt;
  assume HI: &amp;quot;?P l&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x l r)&amp;quot;&lt;br /&gt;
  proof - &lt;br /&gt;
    have &amp;quot;hd (inOrden (N x l r)) = &lt;br /&gt;
          hd (inOrden l @ [x] @ inOrden r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = hd (inOrden l)&amp;quot;  by (simp add: inOrden)&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda l&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda (N x l r)&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 jeamacpov paupeddeg rubgonmar *) (*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 serrodcal *)&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 paupeddeg *)&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;
(* ferrenseg *)&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 (cases a)&lt;br /&gt;
  fix x&lt;br /&gt;
  assume &amp;quot;a = H x&amp;quot;&lt;br /&gt;
  then show &amp;quot;?P a&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x l r&lt;br /&gt;
  assume H: &amp;quot;a = N x l r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P a&amp;quot;&lt;br /&gt;
  proof - &lt;br /&gt;
    have &amp;quot;hd (preOrden a) = hd (preOrden (N x l r))&amp;quot; using H by simp&lt;br /&gt;
    also have &amp;quot;… = hd (x # (preOrden l @ preOrden r))&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 l @ postOrden r @ [x])&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = last (postOrden (N x l r))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = last (postOrden a)&amp;quot; using H 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 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 serrodcal jeamacpov paupeddeg rubgonmar *)&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 paupeddeg *)&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;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (cases a)&lt;br /&gt;
  fix x&lt;br /&gt;
  assume &amp;quot;a = H x&amp;quot;&lt;br /&gt;
  then show &amp;quot;?P a&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x l r&lt;br /&gt;
  assume H: &amp;quot;a = N x l r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P a&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;hd (preOrden a) = hd (preOrden (N x l r))&amp;quot; using H by simp&lt;br /&gt;
    also have &amp;quot;… = hd (x#(preOrden l @ preOrden r))&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 l r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = raiz a&amp;quot; using H 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 serrodcal ferrenseg jeamacpov paupeddeg rubgonmar *)&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 serrodcal jeamacpov paupeddeg rubgonmar *) (*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 paupeddeg*)&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;
(* ferrenseg *)&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 (cases a)&lt;br /&gt;
  fix x&lt;br /&gt;
  assume &amp;quot;a = H x&amp;quot;&lt;br /&gt;
  then show &amp;quot;?P a&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x l r&lt;br /&gt;
  assume H: &amp;quot;a = N x l r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P a&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;last (postOrden a) = last (postOrden (N x l r))&amp;quot; using H by simp&lt;br /&gt;
    also have &amp;quot;… = last (postOrden l @ preOrden r @ [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 a&amp;quot; using H by simp&lt;br /&gt;
    finally show ?thesis .&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>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=1042</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=1042"/>
		<updated>2016-12-13T14:38:37Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 &lt;br /&gt;
    juacabsou serrodcal pabrodmac ferrenseg rubgonmar paupeddeg &lt;br /&gt;
    crigomgom*)&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 jeamacpov paupeddeg*)&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 ferrenseg rubgonmar paupeddeg *)&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  ferrenseg jeamacpov rubgonmar paupeddeg *)&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 ferrenseg jeamacpov rubgonmar paupeddeg*)&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 ferrenseg jeamacpov rubgonmar paupeddeg *)&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 paupeddeg *)&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 jeamacpov paupeddeg*)&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;
&lt;br /&gt;
(* ferrenseg rubgonmar *)&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 l r&lt;br /&gt;
  assume H1: &amp;quot;?P l&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x l r)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;preOrden (espejo (N x l r)) = &lt;br /&gt;
          preOrden (N x (espejo r) (espejo l))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = x # (preOrden (espejo r) @ preOrden (espejo l))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = x # (rev (postOrden r) @ rev (postOrden l))&amp;quot; &lt;br /&gt;
       using H1 H2 by simp &lt;br /&gt;
    also have &amp;quot;… = x # rev (postOrden l @ postOrden r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev ((postOrden l) @ (postOrden r) @ [x])&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev (postOrden (N x l r))&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 jeamacpov paupeddeg rubgonmar *)&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 paupeddeg *)&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;
(* ferrenseg *)&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 l r&lt;br /&gt;
  assume H1: &amp;quot;?P l&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x l r)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;postOrden (espejo (N x l r)) = &lt;br /&gt;
          postOrden (N x (espejo r) (espejo l))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = postOrden (espejo r) @ postOrden (espejo l) @ [x]&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev (preOrden r) @ rev (preOrden l) @ [x]&amp;quot; &lt;br /&gt;
       using H1 H2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev (preOrden l @ preOrden r) @ [x]&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev ([x] @ preOrden l @ preOrden r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev (preOrden (N x l r))&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 jeamacpov paupeddeg *)&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 paupeddeg *)&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;
(* ferrenseg rubgonmar *)&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 i d&lt;br /&gt;
  assume H1: &amp;quot;?P l&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x l r)&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;inOrden (espejo (N x l r)) = &lt;br /&gt;
          inOrden (N x (espejo r) (espejo l))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = inOrden (espejo r) @ [x] @ inOrden (espejo l)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev (inOrden r) @ [x] @ rev (inOrden l)&amp;quot; &lt;br /&gt;
       using H1 H2 by simp&lt;br /&gt;
    also have &amp;quot;… = rev (inOrden l @ [x] @ inOrden r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = rev (inOrden (N x l r))&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 ferrenseg paupeddeg rubgonmar *)&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 ferrenseg jeamacpov paupeddeg rubgonmar *)&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 serrodcal ferrenseg jeamacpov paupeddeg rubgonmar *)&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 serrodcal rubgonmar *)&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 paupeddeg *)&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;
(* ferrenseg *)&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 l r&lt;br /&gt;
  assume HI: &amp;quot;?P r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x l r)&amp;quot;&lt;br /&gt;
  proof -  &lt;br /&gt;
    have &amp;quot;last (inOrden (N x l r)) = &lt;br /&gt;
          last (inOrden r @ [x] @ inOrden r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = last (inOrden r)&amp;quot;  by (simp add: inOrden)&lt;br /&gt;
    also have &amp;quot;… = extremo_derecha r&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… =  extremo_derecha (N x l r)&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 serrodcal jeamacpov*)&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 paupeddeg rubgonmar *)&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 paupeddeg*)&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;
(* ferrenseg *)&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 l r&lt;br /&gt;
  assume HI: &amp;quot;?P l&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x l r)&amp;quot;&lt;br /&gt;
  proof - &lt;br /&gt;
    have &amp;quot;hd (inOrden (N x l r)) = &lt;br /&gt;
          hd (inOrden l @ [x] @ inOrden r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = hd (inOrden l)&amp;quot;  by (simp add: inOrden)&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda l&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = extremo_izquierda (N x l r)&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 jeamacpov paupeddeg rubgonmar *) (*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 serrodcal *)&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 paupeddeg *)&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;
(* ferrenseg *)&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 (cases a)&lt;br /&gt;
  fix x&lt;br /&gt;
  assume &amp;quot;a = H x&amp;quot;&lt;br /&gt;
  then show &amp;quot;?P a&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x l r&lt;br /&gt;
  assume H: &amp;quot;a = N x l r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P a&amp;quot;&lt;br /&gt;
  proof - &lt;br /&gt;
    have &amp;quot;hd (preOrden a) = hd (preOrden (N x l r))&amp;quot; using H by simp&lt;br /&gt;
    also have &amp;quot;… = hd (x # (preOrden l @ preOrden r))&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 l @ postOrden r @ [x])&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = last (postOrden (N x l r))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = last (postOrden a)&amp;quot; using H 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 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 serrodcal jeamacpov paupeddeg rubgonmar *)&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 paupeddeg *)&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;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (cases a)&lt;br /&gt;
  fix x&lt;br /&gt;
  assume &amp;quot;a = H x&amp;quot;&lt;br /&gt;
  then show &amp;quot;?P a&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x l r&lt;br /&gt;
  assume H: &amp;quot;a = N x l r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P a&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;hd (preOrden a) = hd (preOrden (N x l r))&amp;quot; using H by simp&lt;br /&gt;
    also have &amp;quot;… = hd (x#(preOrden l @ preOrden r))&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 l r)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = raiz a&amp;quot; using H 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 serrodcal ferrenseg jeamacpov paupeddeg rubgonmar *)&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 serrodcal jeamacpov paupeddeg rubgonmar *) (*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 paupeddeg*)&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;
(* ferrenseg *)&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 (cases a)&lt;br /&gt;
  fix x&lt;br /&gt;
  assume &amp;quot;a = H x&amp;quot;&lt;br /&gt;
  then show &amp;quot;?P a&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x l r&lt;br /&gt;
  assume H: &amp;quot;a = N x l r&amp;quot;&lt;br /&gt;
  show &amp;quot;?P a&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;last (postOrden a) = last (postOrden (N x l r))&amp;quot; using H by simp&lt;br /&gt;
    also have &amp;quot;… = last (postOrden l @ preOrden r @ [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 a&amp;quot; using H by simp&lt;br /&gt;
    finally show ?thesis .&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>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=870</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=870"/>
		<updated>2016-12-03T10:46:26Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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   h &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 *)&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 *)&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 *)&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*)&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 *)&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;
(* danrodcha *)&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;
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*)&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 *)&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 *)&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 *)&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;
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 *)&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;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&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;
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 *)&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;
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 *)&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 *)&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;
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 *)&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;
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 *)&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;
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 *)&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;
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;
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;
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;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&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;
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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=869</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=869"/>
		<updated>2016-12-03T10:44:56Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: Deshecha la edición 868 de Danrodcha (disc.)&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   h &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 *)&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 *)&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 *)&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*)&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 *)&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;
(* danrodcha *)&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;
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*)&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 *)&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 *)&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 *)&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;
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 *)&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;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&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;
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 *)&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;
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 *)&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 *)&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;
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 *)&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;
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 *)&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;
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 *)&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;
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;
  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; 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;
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;
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;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&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;
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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=868</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=868"/>
		<updated>2016-12-03T10:41:42Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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   h &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 *)&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 *)&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 *)&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*)&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 *)&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;
(* danrodcha *)&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;
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*)&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 *)&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 *)&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 *)&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;
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 *)&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;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&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;
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 *)&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;
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 *)&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 *)&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;
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 *)&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;
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 *)&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;
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 *)&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;
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;
  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;
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;
  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;
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;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&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;
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;
  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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=867</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=867"/>
		<updated>2016-12-03T10:34:13Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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   h &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 *)&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 *)&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 *)&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*)&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 *)&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;
(* danrodcha *)&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;
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*)&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 *)&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 *)&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 *)&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;
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 *)&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;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&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;
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 *)&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;
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 *)&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 *)&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;
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 *)&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;
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 *)&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;
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 *)&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;
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;
  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; 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;
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;
  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; 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;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&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;
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;
  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; 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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=866</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=866"/>
		<updated>2016-12-03T10:21:28Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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   h &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 *)&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 *)&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 *)&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*)&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 *)&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;
(* danrodcha *)&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;
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*)&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 *)&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 *)&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 *)&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;
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 *)&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;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&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;
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 *)&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;
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 *)&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 *)&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;
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 *)&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;
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 *)&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;
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 *)&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;
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;
  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; 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;
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;
  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; 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;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&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;
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;
theorem &amp;quot;last (postOrden a) = raiz 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>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=865</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=865"/>
		<updated>2016-12-03T10:13:50Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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   h &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 *)&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 *)&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 *)&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*)&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 *)&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;
(* danrodcha *)&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;
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*)&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 *)&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 *)&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 *)&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;
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 *)&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;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&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;
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 *)&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;
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 *)&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 *)&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;
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 *)&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;
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 *)&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;
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 *)&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;
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;
  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; 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;
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;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;last (postOrden a) = raiz 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>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=864</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=864"/>
		<updated>2016-12-03T09:57:50Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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   h &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 *)&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 *)&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 *)&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*)&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 *)&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;
(* danrodcha *)&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;
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*)&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 *)&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 *)&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 *)&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;
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 *)&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;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&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;
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 *)&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;
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 *)&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 *)&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;
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 *)&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;
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 *)&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;
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 *)&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;
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;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;last (postOrden a) = raiz 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>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=863</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=863"/>
		<updated>2016-12-03T09:54:31Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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   h &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 *)&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 *)&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 *)&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*)&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 *)&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;
(* danrodcha *)&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;
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*)&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 *)&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 *)&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 *)&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;
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 *)&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;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&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;
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 *)&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;
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 *)&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 *)&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;
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 *)&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;
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 *)&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;
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;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;last (postOrden a) = raiz 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>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=862</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=862"/>
		<updated>2016-12-03T09:51:36Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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   h &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 *)&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 *)&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 *)&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*)&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 *)&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;
(* danrodcha *)&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;
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*)&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 *)&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 *)&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 *)&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;
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 *)&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;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&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;
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 *)&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;
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 *)&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 *)&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;
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 *)&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;
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 *)&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 ([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 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;
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;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;last (postOrden a) = raiz 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>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=861</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=861"/>
		<updated>2016-12-03T09:20:32Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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   h &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 *)&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 *)&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 *)&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*)&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 *)&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;
(* danrodcha *)&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;
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*)&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 *)&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 *)&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 *)&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;
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 *)&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;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&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;
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 *)&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;
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 *)&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 *)&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;
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 *)&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;
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;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;last (postOrden a) = raiz 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>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=860</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=860"/>
		<updated>2016-12-03T09:18:51Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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   h &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 *)&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 *)&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 *)&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*)&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 *)&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;
(* danrodcha *)&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;
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*)&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 *)&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 *)&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 *)&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;
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 *)&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;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&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;
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 *)&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;
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;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz t = undefined&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;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda t = undefined&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;
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;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha t = undefined&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;
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;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;last (postOrden a) = raiz 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>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=859</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=859"/>
		<updated>2016-12-03T09:03:16Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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   h &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 *)&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 *)&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 *)&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) auto&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 *)&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 *)&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;
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;
&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 *)&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 *)&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;
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 *)&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;
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 *)&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;
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;
fun raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;raiz t = undefined&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;
fun extremo_izquierda :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_izquierda t = undefined&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;
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;
fun extremo_derecha :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;extremo_derecha t = undefined&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;
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;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
oops&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;
theorem &amp;quot;last (postOrden a) = raiz 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>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_5&amp;diff=848</id>
		<title>Discusión:Relación 5</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_5&amp;diff=848"/>
		<updated>2016-12-01T14:07:13Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;(* bowma *)&lt;br /&gt;
lemma length_borraDuplicados_2f: &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)) ≤ &lt;br /&gt;
             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; &lt;br /&gt;
    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;
(* respuesta : danrodcha *)&lt;br /&gt;
(* mirar en editar xq aqui no se entiende *)&lt;br /&gt;
lemma length_borraDuplicados_2f: &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 (* &amp;lt;----yo aprovecharia los patrones &amp;quot;?p []&amp;quot; *)&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 *) (* &amp;lt;------ esto no hace falta *)&lt;br /&gt;
(* also *) have &amp;quot;length(borraDuplicados (a#xs)) ≤ &lt;br /&gt;
             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; &lt;br /&gt;
     using c1 by simp *)&lt;br /&gt;
  finally show &amp;quot;?p (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_5&amp;diff=847</id>
		<title>Discusión:Relación 5</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_5&amp;diff=847"/>
		<updated>2016-12-01T14:06:26Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;(* bowma *)&lt;br /&gt;
lemma length_borraDuplicados_2f: &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)) ≤ &lt;br /&gt;
             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; &lt;br /&gt;
    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;
(* respuesta : danrodcha *)&lt;br /&gt;
(* mirar en editar xq aqui no se entiende *)&lt;br /&gt;
lemma length_borraDuplicados_2f: &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 (* &amp;lt;----yo aprovecharia los patrones &amp;quot;?p []&amp;quot; *)&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 *) (* &amp;lt;------ esto no hace falta *)&lt;br /&gt;
(* also *) have &amp;quot;length(borraDuplicados (a#xs)) ≤ &lt;br /&gt;
             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; &lt;br /&gt;
     using c1 by simp *)&lt;br /&gt;
  finally show &amp;quot;?p (a#xs)&amp;quot; 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;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_5&amp;diff=846</id>
		<title>Discusión:Relación 5</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_5&amp;diff=846"/>
		<updated>2016-12-01T14:06:11Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;(* bowma *)&lt;br /&gt;
lemma length_borraDuplicados_2f: &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)) ≤ &lt;br /&gt;
             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; &lt;br /&gt;
    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;
(* respuesta : danrodcha *)&lt;br /&gt;
(* mirar en editar xq aqui nose entiende *)&lt;br /&gt;
lemma length_borraDuplicados_2f: &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 (* &amp;lt;----yo aprovecharia los patrones &amp;quot;?p []&amp;quot; *)&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 *) (* &amp;lt;------ esto no hace falta *)&lt;br /&gt;
(* also *) have &amp;quot;length(borraDuplicados (a#xs)) ≤ &lt;br /&gt;
             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; &lt;br /&gt;
     using c1 by simp *)&lt;br /&gt;
  finally show &amp;quot;?p (a#xs)&amp;quot; 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;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_5&amp;diff=845</id>
		<title>Discusión:Relación 5</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_5&amp;diff=845"/>
		<updated>2016-12-01T14:04:47Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: Página creada con &amp;#039;(* bowma *) lemma length_borraDuplicados_2f:    &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot; (is &amp;quot;?p xs&amp;quot;) proof (induct xs)   show &amp;quot;length (borraDuplicados []) ≤ length []&amp;quot; by ...&amp;#039;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;(* bowma *)&lt;br /&gt;
lemma length_borraDuplicados_2f: &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)) ≤ &lt;br /&gt;
             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; &lt;br /&gt;
    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;
(* respuesta : danrodcha *)&lt;br /&gt;
lemma length_borraDuplicados_2f: &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 (* &amp;lt;----yo aprovecharia los patrones &amp;quot;?p []&amp;quot; *)&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 *) (* &amp;lt;------ esto no hace falta *)&lt;br /&gt;
(* also *) have &amp;quot;length(borraDuplicados (a#xs)) ≤ &lt;br /&gt;
             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; &lt;br /&gt;
     using c1 by simp *)&lt;br /&gt;
  finally show &amp;quot;?p (a#xs)&amp;quot; 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;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=792</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=792"/>
		<updated>2016-11-29T17:50:57Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 *)&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 *)&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 *)&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 *)&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;
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 *)&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;
(* 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 *)&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_3: &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 &amp;quot;length (a#xs) = 1 + length xs&amp;quot; by simp &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;?p (a # xs)&amp;quot; by simp&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 *)&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 *)&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 *)&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 *)&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;
       thus &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 *)&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 *)&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;
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 *)&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 *)&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 *)&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>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=791</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=791"/>
		<updated>2016-11-29T17:49:04Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 *)&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 *)&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 *)&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 *)&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;
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 *)&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;
(* 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 *)&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_3: &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 &amp;quot;length (a#xs) = 1 + length xs&amp;quot; by simp &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;?p (a # xs)&amp;quot; by simp&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 *)&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 *)&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 *)&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 *)&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;
       thus &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 *)&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 marpoldia1 ferrenseg*)&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;
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 *)&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 *)&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;
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 anaprarod fraortmoy ferrenseg marpoldia1 bowma *)&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>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=790</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=790"/>
		<updated>2016-11-29T17:46:40Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 *)&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 *)&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 *)&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 *)&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;
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 *)&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;
(* 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 *)&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 *)&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_3: &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 &amp;quot;length (a#xs) = 1 + length xs&amp;quot; by simp &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;?p (a # xs)&amp;quot; by simp&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 migtermor fraortmoy marpoldia1 ferrenseg *)&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 *)&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 *)&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 *)&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;
       thus &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 *)&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;
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 marpoldia1 ferrenseg*)&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;
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 *)&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 *)&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;
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 anaprarod fraortmoy ferrenseg marpoldia1 bowma *)&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>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=789</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=789"/>
		<updated>2016-11-29T17:45:15Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 *)&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 *)&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 *)&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 anaprarod migtermor paupeddeg fraortmoy marpoldia1 ferrenseg josgarsan *)&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;
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 fraortmoy marpoldia1*)&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;
(* 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 *)&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 *)&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_3: &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 &amp;quot;length (a#xs) = 1 + length xs&amp;quot; by simp &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;?p (a # xs)&amp;quot; by simp&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 migtermor fraortmoy marpoldia1 ferrenseg *)&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 *)&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 *)&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 *)&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;
       thus &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 *)&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;
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 marpoldia1 ferrenseg*)&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;
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 *)&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 *)&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;
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 anaprarod fraortmoy ferrenseg marpoldia1 bowma *)&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>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=788</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=788"/>
		<updated>2016-11-29T17:44:40Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 *)&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 *)&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 serrodcal anaprarod migtermor paupeddeg fraortmoy marpoldia1 ferrenseg josgarsan *)&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 anaprarod migtermor paupeddeg fraortmoy marpoldia1 ferrenseg josgarsan *)&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;
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 fraortmoy marpoldia1*)&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;
(* 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 *)&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 *)&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_3: &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 &amp;quot;length (a#xs) = 1 + length xs&amp;quot; by simp &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;?p (a # xs)&amp;quot; by simp&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 migtermor fraortmoy marpoldia1 ferrenseg *)&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 *)&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 *)&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 *)&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;
       thus &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 *)&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;
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 marpoldia1 ferrenseg*)&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;
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 *)&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 *)&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;
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 anaprarod fraortmoy ferrenseg marpoldia1 bowma *)&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>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_4&amp;diff=604</id>
		<title>Discusión:Relación 4</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_4&amp;diff=604"/>
		<updated>2016-11-22T21:55:40Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&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;
(* Preguntaanaprarod: *)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar datalladamente&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; (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;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;
   also have &amp;quot;… = algunos (P ∘ f) (x#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;
(* no pilla bien los patrones en la inducción en xs y en el resultado de x#xs, es decir: *)&lt;br /&gt;
&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 x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot; (* da error en la línea que usa la HI (no admite el by simp) *)&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;
  also have &amp;quot;… = algunos (P ∘ f) (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by simp  (* no admite el by simp *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Me hace pensar que hay que usar otra regla cuando se usan patrones, pero en un ejercicio anterior (ver 5.2) me lo aceptaba... ¿Alguna idea de lo que pasa? *)&lt;br /&gt;
&lt;br /&gt;
{* danrodcha: si quitas los patrones ya funciona xDD *}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha: si aumentas un poco los demostradores si sale: *}&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 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;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_4&amp;diff=603</id>
		<title>Discusión:Relación 4</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_4&amp;diff=603"/>
		<updated>2016-11-22T21:55:00Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&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;
(* Preguntaanaprarod: *)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar datalladamente&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; (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;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;
  also have &amp;quot;… = algunos (P ∘ f) (x#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;
(* no pilla bien los patrones en la inducción en xs y en el resultado de x#xs, es decir: *)&lt;br /&gt;
&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 x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot; (* da error en la línea que usa la HI (no admite el by simp) *)&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;
  also have &amp;quot;… = algunos (P ∘ f) (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by simp  (* no admite el by simp *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Me hace pensar que hay que usar otra regla cuando se usan patrones, pero en un ejercicio anterior (ver 5.2) me lo aceptaba... ¿Alguna idea de lo que pasa? *)&lt;br /&gt;
&lt;br /&gt;
{* danrodcha: si quitas los patrones ya funciona xDD *}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha: si aumentas un poco los demostradores si sale: *}&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 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;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_4&amp;diff=602</id>
		<title>Discusión:Relación 4</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_4&amp;diff=602"/>
		<updated>2016-11-22T21:54:02Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&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;
(* Preguntaanaprarod: *)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar datalladamente&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; (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;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;
  also have &amp;quot;… = algunos (P ∘ f) (x#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;
(* no pilla bien los patrones en la inducción en xs y en el resultado de x#xs, es decir: *)&lt;br /&gt;
&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 x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot; (* da error en la línea que usa la HI (no admite el by simp) *)&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;
  also have &amp;quot;… = algunos (P ∘ f) (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by simp  (* no admite el by simp *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Me hace pensar que hay que usar otra regla cuando se usan patrones, pero en un ejercicio anterior (ver 5.2) me lo aceptaba... ¿Alguna idea de lo que pasa? *)&lt;br /&gt;
&lt;br /&gt;
{* danrodcha: si quitas los patrones ya funciona xDD *}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha: si aumentas un poco los demostradores si sale: *}&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 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;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_4&amp;diff=601</id>
		<title>Discusión:Relación 4</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_4&amp;diff=601"/>
		<updated>2016-11-22T21:52:50Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&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;
(* Preguntaanaprarod: *)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar datalladamente&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; (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;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;
  also have &amp;quot;… = algunos (P ∘ f) (x#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;
(* no pilla bien los patrones en la inducción en xs y en el resultado de x#xs, es decir: *)&lt;br /&gt;
&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 x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot; (* da error en la línea que usa la HI (no admite el by simp) *)&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;
  also have &amp;quot;… = algunos (P ∘ f) (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by simp  (* no admite el by simp *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Me hace pensar que hay que usar otra regla cuando se usan patrones, pero en un ejercicio anterior (ver 5.2) me lo aceptaba... ¿Alguna idea de lo que pasa? *)&lt;br /&gt;
&lt;br /&gt;
{* danrodcha: si quitas los patrones ya funciona xDD *}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha: si aumentas un poco los demostradores si sale: *}&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 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;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=600</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=600"/>
		<updated>2016-11-22T21:52:18Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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*)&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;
{* 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*}&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*)&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 *)&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*)&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;
(* 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 add: todos_append)&lt;br /&gt;
apply (simp add: todos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
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*)&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;
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*)&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 *)&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 datalladamente&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*)&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 *)&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;
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 *)&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*)&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 *}&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 *)&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*)&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*)&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 *)&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 *)&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;
&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*)&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*)&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 *}&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;
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*)&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*)&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_4&amp;diff=599</id>
		<title>Discusión:Relación 4</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_4&amp;diff=599"/>
		<updated>2016-11-22T21:44:21Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&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;
(* Preguntaanaprarod: *)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar datalladamente&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; (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;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;
  also have &amp;quot;… = algunos (P ∘ f) (x#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;
(* no pilla bien los patrones en la inducción en xs y en el resultado de x#xs, es decir: *)&lt;br /&gt;
&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 x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot; (* da error en la línea que usa la HI (no admite el by simp) *)&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;
  also have &amp;quot;… = algunos (P ∘ f) (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by simp  (* no admite el by simp *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Me hace pensar que hay que usar otra regla cuando se usan patrones, pero en un ejercicio anterior (ver 5.2) me lo aceptaba... ¿Alguna idea de lo que pasa? *)&lt;br /&gt;
&lt;br /&gt;
{* danrodcha: si quitas los patrones ya funciona xDD *}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha: si aumentas un poco los demostradores si sale: *}&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;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=598</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=598"/>
		<updated>2016-11-22T21:43:01Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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*)&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;
{* 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*}&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*)&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 *)&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*)&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;
(* 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 add: todos_append)&lt;br /&gt;
apply (simp add: todos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
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*)&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;
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*)&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 *)&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 datalladamente&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*)&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 *)&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;
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 *)&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*)&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_append:&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_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) = (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_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 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;
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 *)&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*)&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;
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*)&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 *)&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;
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 *)&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 *)&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;
&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;
&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*)&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*)&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;
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*)&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*)&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_4&amp;diff=597</id>
		<title>Discusión:Relación 4</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Discusi%C3%B3n:Relaci%C3%B3n_4&amp;diff=597"/>
		<updated>2016-11-22T21:40:26Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&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;
(* Preguntaanaprarod: *)&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar datalladamente&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; (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;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;
  also have &amp;quot;… = algunos (P ∘ f) (x#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;
(* no pilla bien los patrones en la inducción en xs y en el resultado de x#xs, es decir: *)&lt;br /&gt;
&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 x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot; (* da error en la línea que usa la HI (no admite el by simp) *)&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;
  also have &amp;quot;… = algunos (P ∘ f) (x#xs)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (x#xs)&amp;quot; by simp  (* no admite el by simp *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Me hace pensar que hay que usar otra regla cuando se usan patrones, pero en un ejercicio anterior (ver 5.2) me lo aceptaba... ¿Alguna idea de lo que pasa? *)&lt;br /&gt;
&lt;br /&gt;
{* danrodcha: si quitas los patrones ya funciona xDD *}&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=596</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=596"/>
		<updated>2016-11-22T21:38:40Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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*)&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;
{* 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*}&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*)&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 *)&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*)&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;
(* 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 add: todos_append)&lt;br /&gt;
apply (simp add: todos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
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*)&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;
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*)&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 *)&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 datalladamente&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 *)&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 *)&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;
&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 *)&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*)&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_append:&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_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) = (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_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 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;
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 *)&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*)&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;
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*)&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 *)&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;
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 *)&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 *)&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;
&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;
&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*)&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*)&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;
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*)&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*)&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=420</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=420"/>
		<updated>2016-11-17T17:19:08Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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;
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*}&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*}&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;
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*}&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;
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;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
oops&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;
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;
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;
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;
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;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar datalladamente&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;
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;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
oops&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;
lemma algunos_append:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
oops&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;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
oops&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;
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;
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;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
oops&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;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
oops&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;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn x xs = undefined&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=419</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=419"/>
		<updated>2016-11-17T17:18:43Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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;
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*}&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*}&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;
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;
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;
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;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
oops&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;
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;
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;
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;
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;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar datalladamente&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;
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;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
oops&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;
lemma algunos_append:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
oops&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;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
oops&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;
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;
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;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
oops&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;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
oops&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;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn x xs = undefined&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_3&amp;diff=327</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=327"/>
		<updated>2016-11-12T00:02:45Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 *)&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;
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*)&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;
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 *)&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*)&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;
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*)&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;
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 *)&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;
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 *)&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*)&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_3&amp;diff=326</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=326"/>
		<updated>2016-11-12T00:02:14Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 *)&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;
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*)&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;
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 *)&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*)&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;
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*)&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;
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 *)&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;
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 *)&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;
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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_3&amp;diff=325</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=325"/>
		<updated>2016-11-11T23:57:10Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 *)&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;
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*)&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;
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 *)&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*)&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;
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 *)&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;
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 *)&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;
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 *)&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_3&amp;diff=324</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=324"/>
		<updated>2016-11-11T23:53:58Z</updated>

		<summary type="html">&lt;p&gt;Danrodcha: &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 *)&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;
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*)&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;
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 *)&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;
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 *)&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;
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 *)&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;
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 *)&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danrodcha</name></author>
		
	</entry>
</feed>