<?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=Lucnovdos</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=Lucnovdos"/>
	<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php/Especial:Contribuciones/Lucnovdos"/>
	<updated>2026-07-18T05:48:34Z</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_7&amp;diff=1205</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=1205"/>
		<updated>2016-12-21T20:41:10Z</updated>

		<summary type="html">&lt;p&gt;Lucnovdos: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R7: Árboles binarios completos *}&lt;br /&gt;
&lt;br /&gt;
theory R7_Arboles_binarios_completos&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  En esta relación se piden demostraciones automáticas (lo más cortas&lt;br /&gt;
  posibles). Para ello, en algunos casos es necesario incluir lemas&lt;br /&gt;
  auxiliares (que se demuestran automáticamente) y usar ejercicios&lt;br /&gt;
  anteriores. &lt;br /&gt;
&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que no tienen información ni en los nodos y ni en las&lt;br /&gt;
  hojas. Por ejemplo, el árbol&lt;br /&gt;
          ·&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       ·     ·&lt;br /&gt;
      / \   / \&lt;br /&gt;
     ·   · ·   · &lt;br /&gt;
  se representa por &amp;quot;N (N H H) (N H H)&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
datatype arbol = H | N arbol arbol&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N (N H H) (N H H) = (N (N H H) (N H H) :: arbol)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función&lt;br /&gt;
     hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (hojas a) es el número de hojas del árbol a. Por ejemplo,&lt;br /&gt;
     hojas (N (N H H) (N H H)) = 4&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marcarmor13 josgarsan fracorjim1 *)&lt;br /&gt;
fun hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas H = Suc 0&amp;quot;&lt;br /&gt;
| &amp;quot;hojas (N a b) = hojas a + hojas b&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;hojas (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 anaprarod paupeddeg migtermor wilmorort pablucoto &lt;br /&gt;
    ivamenjim serrodcal crigomgom rubgonmar  danrodcha ferrenseg manmorjim1 juacabsou lucnovdos &lt;br /&gt;
    dancorgar bowma *)&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 marcarmor13 dancorgar *)&lt;br /&gt;
fun profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad (N a b) = (if profundidad a &amp;gt; profundidad b&lt;br /&gt;
                          then 1 + profundidad a &lt;br /&gt;
                          else 1 + profundidad b)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;profundidad (N (N H H) (N H H)) = 2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod wilmorort pablucoto ivamenjim serrodcal crigomgom rubgonmar &lt;br /&gt;
    danrodcha ferrenseg josgarsan juacabsou lucnovdos bowma *)&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 manmorjim1 fracorjim1 *)&lt;br /&gt;
fun profundidad4 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad4 H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad4 (N i d) = Suc (max (profundidad4 i)(profundidad4 d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;profundidad a = profundidad4 a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función&lt;br /&gt;
     abc :: &amp;quot;nat ⇒ arbol&amp;quot; &lt;br /&gt;
  tal que (abc n) es el árbol binario completo de profundidad n. Por&lt;br /&gt;
  ejemplo,  &lt;br /&gt;
     abc 3 = N (N (N H H) (N H H)) (N (N H H) (N H H))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
(* fraortmoy marpoldia1 anaprarod paupeddeg migtermor  wilmorort &lt;br /&gt;
    serrodcal crigomgom rubgonmar danrodcha ferrenseg josgarsan manmorjim1 juacabsou fracorjim1 lucnovdos &lt;br /&gt;
    dancorgar bowma *)&lt;br /&gt;
fun abc :: &amp;quot;nat ⇒ arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;abc 0 = H&amp;quot;&lt;br /&gt;
| &amp;quot;abc (Suc n) = (N (abc n) (abc n))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;abc 3 = N (N (N H H) (N H H)) (N (N H H) (N H H))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim pablucoto marcarmor13*)&lt;br /&gt;
fun abc2 :: &amp;quot;nat ⇒ arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;abc2 0 = H&amp;quot;&lt;br /&gt;
| &amp;quot;abc2 t = N (abc2 (t-1)) (abc2 (t-1))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;abc2 3 = N (N (N H H) (N H H)) (N (N H H) (N H H))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: Metaejercicio de demostración *)&lt;br /&gt;
lemma &amp;quot;abc t = abc2 t&amp;quot;&lt;br /&gt;
by (induct t) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Un árbol binario a es completo respecto de la medida f si&lt;br /&gt;
  a es una hoja o bien a es de la forma (N i d) y se cumple que tanto i&lt;br /&gt;
  como d son árboles binarios completos respecto de f y, además, &lt;br /&gt;
  f(i) = f(r).&lt;br /&gt;
&lt;br /&gt;
  Definir la función&lt;br /&gt;
     es_abc :: &amp;quot;(arbol =&amp;gt; &amp;#039;a) =&amp;gt; arbol =&amp;gt; bool&lt;br /&gt;
  tal que (es_abc f a) se verifica si a es un árbol binario completo&lt;br /&gt;
  respecto de f.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy anaprarod migtermor serrodcal crigomgom rubgonmar &lt;br /&gt;
    danrodcha ferrenseg juacabsou josgarsan fracorjim1 lucnovdos bowma *)&lt;br /&gt;
fun es_abc :: &amp;quot;(arbol =&amp;gt; &amp;#039;a) =&amp;gt; arbol =&amp;gt; bool&amp;quot; where&lt;br /&gt;
  &amp;quot;es_abc _ H = True&amp;quot;&lt;br /&gt;
| &amp;quot;es_abc f (N a b) = (es_abc f a ∧ es_abc f b ∧ (f a = f b))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 paupeddeg ivamenjim pablucoto marcarmor13 manmorjim1 dancorgar *)&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 fracorjim1 josgarsan lucnovdos bowma *)&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 paupeddeg juacabsou *)&lt;br /&gt;
lemma AUX7: &amp;quot;es_abc profundidad a ⟶ (hojas a = 2^(profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* Otra forma de escribir lo mismo *)&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux1: &amp;quot;es_abc profundidad (a::arbol) ⟹ (hojas a = 2^ (profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod wilmorort serrodcal crigomgom &lt;br /&gt;
    rubgonmar ivamenjim danrodcha marcarmor13 paupeddeg juacabsou bowma *)&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;
(* ferrenseg *)&lt;br /&gt;
lemma [simp]: &amp;quot;es_abc profundidad a ⟶ hojas a = 2 ^ (profundidad a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
 &lt;br /&gt;
theorem es_abc_profundidad_hojas: &amp;quot;es_abc profundidad a = es_abc hojas a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma rel_hojas_prof: &amp;quot;es_abc hojas a ∧ es_abc profundidad a&lt;br /&gt;
      ⟹ hojas a = 2 ^ profundidad a&amp;quot;&lt;br /&gt;
by (induct a) (auto)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;es_abc hojas a = es_abc profundidad a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: rel_hojas_prof)&lt;br /&gt;
&lt;br /&gt;
&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 marcarmor13 josgarsan lucnovdos bowma*)&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 paupeddeg juacabsou rubgonmar *)&lt;br /&gt;
lemma AUX8: &amp;quot;es_abc hojas a ⟶ (hojas a = (Suc (size a)))&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
&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 paupeddeg juacabsou rubgonmar *)&lt;br /&gt;
(* Usando AUX8 *)&lt;br /&gt;
lemma L8: &amp;quot;es_abc hojas a= es_abc size a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: AUX8)&lt;br /&gt;
&lt;br /&gt;
&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;
(* ferrenseg *)&lt;br /&gt;
lemma [simp]: &amp;quot;hojas a = size a + 1&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
 &lt;br /&gt;
theorem es_abc_hojas_size: &amp;quot;es_abc hojas a = es_abc size a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 *)&lt;br /&gt;
&lt;br /&gt;
lemma aux10 : &amp;quot;hojas (a::arbol) = Suc(size a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
    &lt;br /&gt;
lemma es_abc_hojas_size_10 : &amp;quot;es_abc hojas (a::arbol) = es_abc size a&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply (auto simp add: aux10)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
lemma rel_hojas_size: &amp;quot;es_abc hojas a ∧ es_abc size a&lt;br /&gt;
      ⟹ hojas a = (size a) + 1&amp;quot;&lt;br /&gt;
by (induct a) (auto)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;es_abc hojas a = es_abc size a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: rel_hojas_size)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Demostrar que un árbol binario a es completo respecto de&lt;br /&gt;
  la profundidad syss es completo respecto del número de nodos.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod  wilmorort pablucoto &lt;br /&gt;
   serrodcal crigomgom rubgonmar danrodcha ivamenjim marcarmor13 paupeddeg juacabsou&lt;br /&gt;
   josgarsan bowma lucnovdos *)&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;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
corollary es_abc_size_profundidad: &amp;quot;es_abc size a = es_abc profundidad a&amp;quot;&lt;br /&gt;
by (simp add: es_abc_profundidad_hojas es_abc_hojas_size)&lt;br /&gt;
&lt;br /&gt;
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 marcarmor13 paupeddeg juacabsou&lt;br /&gt;
   dancorgar lucnovdos *)&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 ferrenseg ivamenjim paupeddeg juacabsou bowma*)&lt;br /&gt;
(* con un demostrador más débil *)&lt;br /&gt;
(* y en general para cualquier medida *)&lt;br /&gt;
lemma L10:  &amp;quot;es_abc f (abc a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Igual que el anterior pero usando auto *)&lt;br /&gt;
lemma lej10: &amp;quot;es_abc f (abc n)&amp;quot;&lt;br /&gt;
by (induct n) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Demostrar que si a es un árbolo binario completo&lt;br /&gt;
  respecto de la profundidad, entonces a es igual a&lt;br /&gt;
  (abc (profundidad a)).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor wilmorort pablucoto serrodcal marcarmor13  *)&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 ferrenseg ivamenjim paupeddeg juacabsou dancorgar bowma lucnovdos *)&lt;br /&gt;
lemma &amp;quot;es_abc profundidad a ⟶ (a = (abc (profundidad a)))&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* danrodcha*)&lt;br /&gt;
lemma 11:&amp;quot;es_abc profundidad a ⟹ (a = (abc (profundidad a)))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
&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 marcarmor13 ferrenseg ivamenjim paupeddeg juacabsou rubgonmar bowma lucnovdos *)&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;
(* dancorgar *)&lt;br /&gt;
fun medida :: &amp;quot;arbol =&amp;gt; bool&amp;quot; where&lt;br /&gt;
  &amp;quot;medida H = True&amp;quot;&lt;br /&gt;
| &amp;quot;medida (N i d) = ((profundidad i) = (size d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;es_abc size a = es_abc medida a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lucnovdos</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_7&amp;diff=1191</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=1191"/>
		<updated>2016-12-21T13:10:58Z</updated>

		<summary type="html">&lt;p&gt;Lucnovdos: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R7: Árboles binarios completos *}&lt;br /&gt;
&lt;br /&gt;
theory R7_Arboles_binarios_completos&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  En esta relación se piden demostraciones automáticas (lo más cortas&lt;br /&gt;
  posibles). Para ello, en algunos casos es necesario incluir lemas&lt;br /&gt;
  auxiliares (que se demuestran automáticamente) y usar ejercicios&lt;br /&gt;
  anteriores. &lt;br /&gt;
&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que no tienen información ni en los nodos y ni en las&lt;br /&gt;
  hojas. Por ejemplo, el árbol&lt;br /&gt;
          ·&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       ·     ·&lt;br /&gt;
      / \   / \&lt;br /&gt;
     ·   · ·   · &lt;br /&gt;
  se representa por &amp;quot;N (N H H) (N H H)&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
datatype arbol = H | N arbol arbol&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N (N H H) (N H H) = (N (N H H) (N H H) :: arbol)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función&lt;br /&gt;
     hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (hojas a) es el número de hojas del árbol a. Por ejemplo,&lt;br /&gt;
     hojas (N (N H H) (N H H)) = 4&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marcarmor13 josgarsan fracorjim1 *)&lt;br /&gt;
fun hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas H = Suc 0&amp;quot;&lt;br /&gt;
| &amp;quot;hojas (N a b) = hojas a + hojas b&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;hojas (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 anaprarod paupeddeg migtermor wilmorort pablucoto &lt;br /&gt;
    ivamenjim serrodcal crigomgom rubgonmar  danrodcha ferrenseg manmorjim1 juacabsou lucnovdos *)&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 marcarmor13*)&lt;br /&gt;
fun profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad (N a b) = (if profundidad a &amp;gt; profundidad b&lt;br /&gt;
                          then 1 + profundidad a &lt;br /&gt;
                          else 1 + profundidad b)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;profundidad (N (N H H) (N H H)) = 2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod wilmorort pablucoto ivamenjim serrodcal crigomgom rubgonmar &lt;br /&gt;
    danrodcha ferrenseg josgarsan juacabsou lucnovdos*)&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 manmorjim1 fracorjim1 *)&lt;br /&gt;
fun profundidad4 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad4 H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad4 (N i d) = Suc (max (profundidad4 i)(profundidad4 d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;profundidad a = profundidad4 a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función&lt;br /&gt;
     abc :: &amp;quot;nat ⇒ arbol&amp;quot; &lt;br /&gt;
  tal que (abc n) es el árbol binario completo de profundidad n. Por&lt;br /&gt;
  ejemplo,  &lt;br /&gt;
     abc 3 = N (N (N H H) (N H H)) (N (N H H) (N H H))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
(* fraortmoy marpoldia1 anaprarod paupeddeg migtermor  wilmorort &lt;br /&gt;
    serrodcal crigomgom rubgonmar danrodcha ferrenseg josgarsan manmorjim1 juacabsou fracorjim1 lucnovdos *)&lt;br /&gt;
fun abc :: &amp;quot;nat ⇒ arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;abc 0 = H&amp;quot;&lt;br /&gt;
| &amp;quot;abc (Suc n) = (N (abc n) (abc n))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;abc 3 = N (N (N H H) (N H H)) (N (N H H) (N H H))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim pablucoto marcarmor13*)&lt;br /&gt;
fun abc2 :: &amp;quot;nat ⇒ arbol&amp;quot; where&lt;br /&gt;
  &amp;quot;abc2 0 = H&amp;quot;&lt;br /&gt;
| &amp;quot;abc2 t = N (abc2 (t-1)) (abc2 (t-1))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;abc2 3 = N (N (N H H) (N H H)) (N (N H H) (N H H))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: Metaejercicio de demostración *)&lt;br /&gt;
lemma &amp;quot;abc t = abc2 t&amp;quot;&lt;br /&gt;
by (induct t) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Un árbol binario a es completo respecto de la medida f si&lt;br /&gt;
  a es una hoja o bien a es de la forma (N i d) y se cumple que tanto i&lt;br /&gt;
  como d son árboles binarios completos respecto de f y, además, &lt;br /&gt;
  f(i) = f(r).&lt;br /&gt;
&lt;br /&gt;
  Definir la función&lt;br /&gt;
     es_abc :: &amp;quot;(arbol =&amp;gt; &amp;#039;a) =&amp;gt; arbol =&amp;gt; bool&lt;br /&gt;
  tal que (es_abc f a) se verifica si a es un árbol binario completo&lt;br /&gt;
  respecto de f.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy anaprarod migtermor serrodcal crigomgom rubgonmar &lt;br /&gt;
    danrodcha ferrenseg juacabsou josgarsan fracorjim1 lucnovdos *)&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 marcarmor13 manmorjim1 *)&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 fracorjim1 josgarsan lucnovdos *)&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 paupeddeg juacabsou *)&lt;br /&gt;
lemma AUX7: &amp;quot;es_abc profundidad a ⟶ (hojas a = 2^(profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* Otra forma de escribir lo mismo *)&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma aux1: &amp;quot;es_abc profundidad (a::arbol) ⟹ (hojas a = 2^ (profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod wilmorort serrodcal crigomgom &lt;br /&gt;
    rubgonmar ivamenjim danrodcha marcarmor13 paupeddeg juacabsou*)&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;
(* ferrenseg *)&lt;br /&gt;
lemma [simp]: &amp;quot;es_abc profundidad a ⟶ hojas a = 2 ^ (profundidad a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
 &lt;br /&gt;
theorem es_abc_profundidad_hojas: &amp;quot;es_abc profundidad a = es_abc hojas a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
&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 marcarmor13 josgarsan lucnovdos *)&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 paupeddeg juacabsou rubgonmar *)&lt;br /&gt;
lemma AUX8: &amp;quot;es_abc hojas a ⟶ (hojas a = (Suc (size a)))&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
&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 paupeddeg juacabsou rubgonmar *)&lt;br /&gt;
(* Usando AUX8 *)&lt;br /&gt;
lemma L8: &amp;quot;es_abc hojas a= es_abc size a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: AUX8)&lt;br /&gt;
&lt;br /&gt;
&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;
(* ferrenseg *)&lt;br /&gt;
lemma [simp]: &amp;quot;hojas a = size a + 1&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
 &lt;br /&gt;
theorem es_abc_hojas_size: &amp;quot;es_abc hojas a = es_abc size a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 *)&lt;br /&gt;
&lt;br /&gt;
lemma aux10 : &amp;quot;hojas (a::arbol) = Suc(size a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
    &lt;br /&gt;
lemma es_abc_hojas_size_10 : &amp;quot;es_abc hojas (a::arbol) = es_abc size a&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply (auto simp add: aux10)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Demostrar que un árbol binario a es completo respecto de&lt;br /&gt;
  la profundidad syss es completo respecto del número de nodos.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod  wilmorort pablucoto &lt;br /&gt;
   serrodcal crigomgom rubgonmar danrodcha ivamenjim marcarmor13 paupeddeg juacabsou&lt;br /&gt;
   josgarsan&lt;br /&gt;
*)&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;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
corollary es_abc_size_profundidad: &amp;quot;es_abc size a = es_abc profundidad a&amp;quot;&lt;br /&gt;
by (simp add: es_abc_profundidad_hojas es_abc_hojas_size)&lt;br /&gt;
&lt;br /&gt;
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 marcarmor13 paupeddeg juacabsou*)&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 ferrenseg ivamenjim paupeddeg juacabsou*)&lt;br /&gt;
(* con un demostrador más débil *)&lt;br /&gt;
(* y en general para cualquier medida *)&lt;br /&gt;
lemma L10:  &amp;quot;es_abc f (abc a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Igual que el anterior pero usando auto *)&lt;br /&gt;
lemma lej10: &amp;quot;es_abc f (abc n)&amp;quot;&lt;br /&gt;
by (induct n) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Demostrar que si a es un árbolo binario completo&lt;br /&gt;
  respecto de la profundidad, entonces a es igual a&lt;br /&gt;
  (abc (profundidad a)).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor wilmorort pablucoto serrodcal marcarmor13  *)&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 ferrenseg ivamenjim paupeddeg juacabsou *)&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;
&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 marcarmor13 ferrenseg ivamenjim paupeddeg juacabsou rubgonmar *)&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>Lucnovdos</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=970</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=970"/>
		<updated>2016-12-06T04:18:17Z</updated>

		<summary type="html">&lt;p&gt;Lucnovdos: &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 marpoldia1 manmorjim1 bowma migtermor wilmorort *)&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 *)&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 *)&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 *)&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*)&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 *)&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 *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos *)&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 *)&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 *)&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*)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar padrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort lucnovdos *) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort lucnovdos *) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lucnovdos</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=969</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=969"/>
		<updated>2016-12-06T03:24:05Z</updated>

		<summary type="html">&lt;p&gt;Lucnovdos: &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 marpoldia1 manmorjim1 bowma migtermor wilmorort *)&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 *)&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 *)&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 *)&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*)&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 *)&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 *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos *)&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 *)&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 *)&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*)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar padrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda i&amp;quot; using HIi by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma lucnovdos *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort*) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort*) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lucnovdos</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=968</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=968"/>
		<updated>2016-12-06T03:06:28Z</updated>

		<summary type="html">&lt;p&gt;Lucnovdos: &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 marpoldia1 manmorjim1 bowma migtermor wilmorort *)&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 *)&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 *)&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 *)&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*)&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 *)&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 *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos *)&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 *)&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 *)&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*)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos*)&lt;br /&gt;
(* El mismo que el anterior,pero sin usar padrones *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot;&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;last (inOrden (H x)) = extremo_derecha (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x   ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i d ::&amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  assume HI: &amp;quot;last (inOrden d) = extremo_derecha d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom *)&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 *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort*) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort*) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lucnovdos</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=967</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=967"/>
		<updated>2016-12-06T01:30:04Z</updated>

		<summary type="html">&lt;p&gt;Lucnovdos: &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 marpoldia1 manmorjim1 bowma migtermor wilmorort *)&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 *)&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 *)&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 *)&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*)&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 *)&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 *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos *)&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 *)&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 *)&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*)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom *)&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 *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort*) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort*) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lucnovdos</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=966</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=966"/>
		<updated>2016-12-06T01:26:43Z</updated>

		<summary type="html">&lt;p&gt;Lucnovdos: &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 marpoldia1 manmorjim1 bowma migtermor wilmorort *)&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 *)&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 *)&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 *)&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*)&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 *)&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 *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* lucnovdos *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función &lt;br /&gt;
     raiz :: &amp;quot;&amp;#039;a arbol ⇒ &amp;#039;a&amp;quot;&lt;br /&gt;
  tal que (raiz a) es la raiz del árbol a. Por ejemplo, &lt;br /&gt;
     raiz (N e (N c (H a) (H d)) (N g (H f) (H h))) = e&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom manmorjim1 ivamenjim bowma pablucoto migtermor marpoldia1 wilmorort lucnovdos *)&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 *)&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 *)&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*)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom *)&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 *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort*) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort*) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lucnovdos</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=965</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=965"/>
		<updated>2016-12-06T01:23:03Z</updated>

		<summary type="html">&lt;p&gt;Lucnovdos: &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 marpoldia1 manmorjim1 bowma migtermor wilmorort *)&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 *)&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 *)&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 *)&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*)&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 *)&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 *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy lucnovdos *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
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 *)&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 *)&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 *)&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*)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom *)&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 *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort*) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort*) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lucnovdos</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=964</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=964"/>
		<updated>2016-12-06T01:16:49Z</updated>

		<summary type="html">&lt;p&gt;Lucnovdos: &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 marpoldia1 manmorjim1 bowma migtermor wilmorort *)&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 *)&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 *)&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 *)&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*)&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*)&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 *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
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 *)&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 *)&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 *)&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*)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom *)&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 *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort*) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort*) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lucnovdos</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=963</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=963"/>
		<updated>2016-12-06T01:06:00Z</updated>

		<summary type="html">&lt;p&gt;Lucnovdos: &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 marpoldia1 manmorjim1 bowma migtermor wilmorort lucnovdos *)&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 *)&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 *)&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 *)&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*)&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*)&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 *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;preOrden (espejo (N x i d)) = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom*)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot;&lt;br /&gt;
    by (simp only: espejo.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x#preOrden (espejo d) @ preOrden (espejo i)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have&amp;quot;… = x#rev (postOrden d) @ rev (postOrden i)&amp;quot; &lt;br /&gt;
    using HIi HId by simp&lt;br /&gt;
  also have &amp;quot;… = rev (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
apply (induct a)&lt;br /&gt;
apply simp_all&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;preOrden (espejo (N x i d)) = preOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using h1 h2 by simp&lt;br /&gt;
  also have &amp;quot;... = [x] @ rev (postOrden i @ postOrden d)&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = rev ( postOrden i @ postOrden d @ [x] ) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (postOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
(* Aquí si le diga &amp;quot;preOrden (espejo (H t)) = rev (postOrden (H t))&amp;quot;,isabelle dice: &lt;br /&gt;
proof (prove)&lt;br /&gt;
goal (1 subgoal):&lt;br /&gt;
 1. preOrden (espejo (H t)) = rev (postOrden (H t)) &lt;br /&gt;
Introduced fixed type variable(s): &amp;#039;b in &amp;quot;t__&amp;quot; &lt;br /&gt;
No entiendo porqué *)&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume H1: &amp;quot;?p i&amp;quot;&lt;br /&gt;
assume H2: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;preOrden (espejo (N t i d)) = preOrden (N t (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ (preOrden (espejo d)) @ (preOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = [t] @ rev (postOrden d) @ rev (postOrden i)&amp;quot; using H1 H2 by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
&lt;br /&gt;
lemma  &amp;quot;preOrden (espejo a) = rev (postOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar que&lt;br /&gt;
     postOrden (espejo a) = rev (preOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;postOrden (espejo (N x i d)) = postOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (postOrden (espejo d)) @ (postOrden (espejo i)) @ [x]&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x]&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;postOrden (espejo (N x i d)) = rev (preOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  (* &amp;quot;?p (N x i d)&amp;quot; más corto *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1*)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;  (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume H1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume H2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; postOrden (espejo (N x i d)) = postOrden ( N x (espejo d) (espejo i)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = postOrden (espejo d) @ postOrden (espejo i) @ [x]  &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (preOrden i) @ [x] &amp;quot; using H1 H2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden d) @ rev (x # preOrden i)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (preOrden (N x i d)) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
lemma &amp;quot;postOrden (espejo a) = rev (preOrden a)&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que&lt;br /&gt;
     inOrden (espejo a) = rev (inOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim crigomgom bowma migtermor wilmorort*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;inOrden (espejo (N x i d)) = inOrden (N x (espejo d) (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (inOrden (espejo d)) @ [x] @ (inOrden (espejo i))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using h1 h2 by simp &lt;br /&gt;
  finally show &amp;quot;inOrden (espejo (N x i d)) = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; using HIi HId by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto marpoldia1 *)&lt;br /&gt;
theorem &amp;quot;inOrden (espejo a) = rev (inOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x) &amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; inOrden (espejo (N x i d)) = inOrden ( N x (espejo d) (espejo i) )&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = inOrden (espejo d) @ [x] @ inOrden (espejo i) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden d) @ [x] @ rev (inOrden i)&amp;quot; using HI1 HI2 by simp&lt;br /&gt;
  also have &amp;quot;... = rev (x # inOrden d ) @ rev (inOrden i)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev ( inOrden i @ x # inOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = rev (inOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
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 *)&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 *)&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 *)&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*)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d &lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last (inOrden i @ [x] @ inOrden d)&amp;quot; &lt;br /&gt;
    by (simp only: inOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = last (inOrden d)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
  also have &amp;quot;… = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
lemma aux_ej12_1: &amp;quot;inOrden a ≠ []&amp;quot;&lt;br /&gt;
by (induct a) simp_all &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
(* Igual que la anterior, pero poniendo solo by simp en el primer have *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (inOrden (N x i d)) = last ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp &lt;br /&gt;
  also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_derecha d&amp;quot; using h2 by simp &lt;br /&gt;
  finally show &amp;quot;last (inOrden (N x i d)) = extremo_derecha (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* Casi lo mismo que el anterior,pero no hace falta suponer &amp;quot;?p i&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
fix t i d&lt;br /&gt;
assume HI: &amp;quot;?p d&amp;quot;&lt;br /&gt;
have &amp;quot;last (inOrden (N t i d)) = last (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = last (inOrden d)&amp;quot; by (simp add:aux_ej12)&lt;br /&gt;
also have &amp;quot;... = extremo_derecha d&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (inOrden a) = extremo_derecha a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i&lt;br /&gt;
 fix d assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden d = [])&amp;quot; (is &amp;quot;?Q d&amp;quot;)&lt;br /&gt;
     proof (induct d)&lt;br /&gt;
      fix hd&lt;br /&gt;
      show &amp;quot;?Q (H hd)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix nd&lt;br /&gt;
     fix id assume HIid: &amp;quot;?Q id&amp;quot;&lt;br /&gt;
     fix dd assume HIdd: &amp;quot;?Q dd&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N nd id dd)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;last (inOrden (N n i d)) = last (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = last (inOrden d)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_derecha d&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = extremo_izquierda a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto crigomgom *)&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 *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d &lt;br /&gt;
assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
have &amp;quot;hd (inOrden (N t i d)) = hd (inOrden i @ [t] @ inOrden d)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;… = hd (inOrden i)&amp;quot; by (simp add: aux_ej12)&lt;br /&gt;
also have &amp;quot;… = extremo_izquierda i&amp;quot; using HI by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n d&lt;br /&gt;
 fix i assume HId: &amp;quot;?P i&amp;quot;&lt;br /&gt;
 have AUX: &amp;quot;¬ (inOrden i = [])&amp;quot; (is &amp;quot;?Q i&amp;quot;)&lt;br /&gt;
     proof (induct i)&lt;br /&gt;
      fix hi&lt;br /&gt;
      show &amp;quot;?Q (H hi)&amp;quot; by simp&lt;br /&gt;
     next&lt;br /&gt;
     fix ni&lt;br /&gt;
     fix ii assume HIid: &amp;quot;?Q ii&amp;quot;&lt;br /&gt;
     fix di assume HIdd: &amp;quot;?Q di&amp;quot;&lt;br /&gt;
     show &amp;quot;?Q (N ni ii di)&amp;quot; using HIid HIdd by simp&lt;br /&gt;
     qed&lt;br /&gt;
 have &amp;quot;hd (inOrden (N n i d)) = hd (inOrden i @[n]@inOrden d)&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = hd (inOrden i)&amp;quot; using AUX by simp&lt;br /&gt;
 also have &amp;quot;… = extremo_izquierda i&amp;quot; using HId by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot;  by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = extremo_izquierda a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1)&lt;br /&gt;
  also have &amp;quot;... = extremo_izquierda i&amp;quot; using h1 by simp &lt;br /&gt;
  finally show &amp;quot;hd (inOrden (N x i d)) = extremo_izquierda (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = last (postOrden a)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N x i d))&amp;quot; &lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom bowma marpoldia1 wilmorort*) (*Similar al anterior*)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next   &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d)&amp;quot;  by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden i @ postOrden d @ [x]) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ( postOrden (N x i d) )&amp;quot; by simp  &lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot; &lt;br /&gt;
      by simp&lt;br /&gt;
 (* Si no especifico que i y d son árboles, salta un error de tipo. Supongo que será por&lt;br /&gt;
    no haber asumido hipótesis sobre ellos *)&lt;br /&gt;
 also have &amp;quot;… = last (postOrden (N n i d))&amp;quot; by simp&lt;br /&gt;
 show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = last (postOrden (N x i d))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Demostrar o refutar&lt;br /&gt;
     hd (preOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd (x#preOrden i @ preOrden d)&amp;quot;&lt;br /&gt;
    by (simp only: preOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a) &lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot; ?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot; ?P d&amp;quot;&lt;br /&gt;
  have &amp;quot; hd (preOrden (N x i d)) = hd ([x] @ preOrden i @ preOrden d) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* similar al anterior pero sin suponer &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = last (postOrden a)&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix t&lt;br /&gt;
  show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix t i d&lt;br /&gt;
  assume HI: &amp;quot;?p i&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N t i d)) = hd ([t] @ preOrden i @ preOrden d)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = t&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = last (postOrden (N t i d))&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;hd (preOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = hd ([n]@preOrden i@preOrden d)&amp;quot;&lt;br /&gt;
      by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (preOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  show &amp;quot;hd (preOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x ::&amp;quot;&amp;#039;a&amp;quot;&lt;br /&gt;
  fix i ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;hd (preOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d ::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;hd (preOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (preOrden (N x i d)) = hd ([x] @ (preOrden i) @ (preOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd ([x])&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;hd (preOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     hd (inOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom pablucoto bowma migtermor ivamenjim wilmorort *)&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* danrodcha:&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  a = N a⇩1 (H a⇩2) (H a⇩1)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  hd (inOrden a) = a⇩2&lt;br /&gt;
  raiz a = a⇩1 *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;hd (inOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x &lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x &lt;br /&gt;
  fix i assume h1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  fix d assume h2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;hd (inOrden (N x i d)) = hd ((inOrden i) @ [x] @ (inOrden d))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = hd (inOrden i)&amp;quot; by (simp add: aux_ej12_1) &lt;br /&gt;
  (* Perdemos la x, luego se refuta el enunciado del teorema *)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17. Demostrar o refutar&lt;br /&gt;
     last (postOrden a) = raiz a&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HIi: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HId: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last (postOrden i @ postOrden d @ [x])&amp;quot;&lt;br /&gt;
    by (simp only: postOrden.simps(2))&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = raiz (N x i d)&amp;quot; by (simp only: raiz.simps(2))&lt;br /&gt;
  finally show &amp;quot;?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto crigomgom ivamenjim marpoldia1 wilmorort*) (*Similar al anterior*)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a )&lt;br /&gt;
  fix x&lt;br /&gt;
  show &amp;quot;?P (H x)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix x i d&lt;br /&gt;
  assume HI1: &amp;quot;?P i&amp;quot;&lt;br /&gt;
  assume HI2: &amp;quot;?P d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ( postOrden i @ postOrden d @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = x&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = raiz (N x i d) &amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot; ?P (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* bowma *)&lt;br /&gt;
(* También sin usar el supuesto &amp;quot;?p d&amp;quot; *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?p a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
fix t&lt;br /&gt;
show &amp;quot;?p (H t)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix t i d&lt;br /&gt;
assume &amp;quot;?p i&amp;quot;&lt;br /&gt;
(* si quito este supuesto, hay error pero no sé dónde se lo está usando *)&lt;br /&gt;
have &amp;quot;last (postOrden (N t i d)) = last (postOrden i @ postOrden d @ [t])&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = t&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = raiz (N t i d)&amp;quot; by simp&lt;br /&gt;
finally show &amp;quot;?p (N t i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; (is &amp;quot;?P a&amp;quot;)&lt;br /&gt;
proof (induct a)&lt;br /&gt;
 fix h&lt;br /&gt;
 show &amp;quot;?P (H h)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
 fix n i d&lt;br /&gt;
 have &amp;quot;last (postOrden (N n (i :: &amp;#039;a arbol) (d :: &amp;#039;a arbol))) = &lt;br /&gt;
       last (postOrden i@postOrden d@[n])&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = raiz (N n i d)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;?P (N n i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: sin usar patrones *)&lt;br /&gt;
&lt;br /&gt;
theorem &amp;quot;last (postOrden a) = raiz a&amp;quot; &lt;br /&gt;
proof (induct a)&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot; &lt;br /&gt;
  show &amp;quot;last (postOrden (H x)) = raiz (H x)&amp;quot; by simp &lt;br /&gt;
next&lt;br /&gt;
  fix x::&amp;quot;&amp;#039;a&amp;quot;  &lt;br /&gt;
  fix i::&amp;quot;&amp;#039;a arbol&amp;quot; assume h1: &amp;quot;last (postOrden i) = raiz i&amp;quot;&lt;br /&gt;
  fix d::&amp;quot;&amp;#039;a arbol&amp;quot; assume h2: &amp;quot;last (postOrden d) = raiz d&amp;quot;&lt;br /&gt;
  have &amp;quot;last (postOrden (N x i d)) = last ((postOrden i) @ (postOrden d) @ [x])&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = last ([x])&amp;quot; by simp &lt;br /&gt;
  finally show &amp;quot;last (postOrden (N x i d)) = raiz (N x i d)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lucnovdos</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=837</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=837"/>
		<updated>2016-11-30T20:27:47Z</updated>

		<summary type="html">&lt;p&gt;Lucnovdos: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R5: Eliminación de duplicados *}&lt;br /&gt;
&lt;br /&gt;
theory R5_Eliminacion_de_duplicados&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
        &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar bowma wilmorort pablucoto serrodcal &lt;br /&gt;
   anaprarod migtermor paupeddeg fraortmoy marpoldia1&lt;br /&gt;
   danrodcha manmorjim1 jeamacpov *)&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn _ []     = False&amp;quot;&lt;br /&gt;
| &amp;quot;estaEn x (a#xs) = ((a = x) ∨ (estaEn x xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg josgarsan juacabsou dancorgar pabrodmac lucnovdos&lt;br /&gt;
   fracorjim1 *)    &lt;br /&gt;
(* Igual que la anterior pero con x en lugar de _ en el caso base *)&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 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;
fun estaEn2  :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn2 a xs = algunos (λx. x = a) xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;estaEn2 (2::nat) [3,2,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;estaEn2 (1::nat) [3,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función primitiva recursiva &lt;br /&gt;
     sinDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (sinDuplicados xs) se verifica si la lista xs no contiene&lt;br /&gt;
  duplicados. Por ejemplo,  &lt;br /&gt;
     sinDuplicados [1::nat,4,2]   = True&lt;br /&gt;
     sinDuplicados [1::nat,4,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar ivamenjim  wilmorort bowma pablucoto &lt;br /&gt;
   serrodcal anaprarod migtermor paupeddeg fraortmoy marpoldia1 &lt;br /&gt;
   ferrenseg josgarsan danrodcha manmorjim1 juacabsou dancorgar&lt;br /&gt;
   pabrodmac lucnovdos jeamacpov *) &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;
(* fracorjim1 - La versión anterior no prueba el segundo enunciado. La&lt;br /&gt;
   que propongo demuestra ambos. *) &lt;br /&gt;
fun sinDuplicados1 :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;sinDuplicados1 [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;sinDuplicados1 (x#xs) = (¬(estaEn x xs ∧ sinDuplicados xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sinDuplicados1 [1::nat,4,2]   = True&amp;quot;&lt;br /&gt;
value &amp;quot;sinDuplicados1 [1::nat,4,2,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* Comentario: La definición sinDuplicados1 no cumple el segundo&lt;br /&gt;
   ejemplo. *) &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;
(* Comentario: Uso de ∉ y set *)&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función primitiva recursiva &lt;br /&gt;
     borraDuplicados :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (borraDuplicados xs) es la lista obtenida eliminando los&lt;br /&gt;
  elementos duplicados de la lista xs. Por ejemplo, &lt;br /&gt;
     borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&lt;br /&gt;
&lt;br /&gt;
  Nota: La función borraDuplicados es equivalente a la predefinida&lt;br /&gt;
  remdups.  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar wilmorort bowma pablucoto serrodcal &lt;br /&gt;
   anaprarod migtermor paupeddeg fraortmoy marpoldia1 ferrenseg &lt;br /&gt;
   josgarsan danrodcha juacabsou dancorgar manmorjim1 pabrodmac&lt;br /&gt;
   lucnovdos jeamacpov *) &lt;br /&gt;
fun borraDuplicados0 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados0 []     = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados0 (x#xs) = (if estaEn x xs &lt;br /&gt;
                              then borraDuplicados0 xs &lt;br /&gt;
                              else x#borraDuplicados0 xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados0 [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&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;
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 &lt;br /&gt;
                                False =&amp;gt; x#borraDuplicados1 xs &lt;br /&gt;
                              | True  =&amp;gt; borraDuplicados1 xs )&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados1 [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&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) =  &lt;br /&gt;
    (let condicion = estaEn x xs::bool in &lt;br /&gt;
     if condicion &lt;br /&gt;
        then borraDuplicados2 xs &lt;br /&gt;
        else x # borraDuplicados2 xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados2 [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;
fun borraDuplicados3 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados3 []     = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados3 (x#xs) = (if ¬(estaEn x xs) &lt;br /&gt;
                              then (x#(borraDuplicados3 xs)) &lt;br /&gt;
                              else borraDuplicados3 xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados3 [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&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 xs = borraDuplicados0 xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1. Utilizo un acumulador para optimizar la eficiencia *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicadosAc :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicadosAc [] ys = ys&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicadosAc (x#xs) ys = (if (estaEn x ys) then (borraDuplicadosAc xs ys)&lt;br /&gt;
                                  else (borraDuplicadosAc xs (x#ys)))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1. Uso un caso base *)&lt;br /&gt;
fun borraDuplicados4 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados4 xs = (if (sinDuplicados xs) then xs else borraDuplicadosAc xs [])&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&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;
(* 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;
(* Comentario: Falla para borraDuplicados1. *)&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar wilmorort pablucoto serrodcal migtermor paupeddeg &lt;br /&gt;
   fraortmoy marpoldia1 danrodcha juacabsou dancorgar josgarsan&lt;br /&gt;
   pabrodmac lucnovdos *) &lt;br /&gt;
lemma length_borraDuplicados2:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
(* soy de ponerlo mejor por pasos *)&lt;br /&gt;
lemma length_borraDuplicados3:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados4:&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_borraDuplicados5:&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;
lemma length_borraDuplicados6:&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&lt;br /&gt;
                           paréntesis *) &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;
(* 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)) = &lt;br /&gt;
               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; &lt;br /&gt;
      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)) = &lt;br /&gt;
               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;  &lt;br /&gt;
      by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim  wilmorort ferrenseg rubgonmar juacabsou dancorgar&lt;br /&gt;
   josgarsan lucnovdos *) &lt;br /&gt;
lemma length_borraDuplicados_2b: &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)) ≤ &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;
  finally show &amp;quot;length (borraDuplicados (a # xs)) ≤ length (a # xs)&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* serrodcal anaprarod danrodcha *)&lt;br /&gt;
lemma length_borraDuplicados_2c: &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)) ≤ &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;
  finally show &amp;quot;?P (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto jeamacpov *)&lt;br /&gt;
lemma length_borraDuplicados_2d: &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)) ≤ &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;
  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; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&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;
(* Comentario: Responder la pregunta. *)&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
lemma length_borraDuplicados_2g: &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)) = &lt;br /&gt;
                   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; &lt;br /&gt;
     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)) = &lt;br /&gt;
                   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; &lt;br /&gt;
     using Aux by simp&lt;br /&gt;
  qed&lt;br /&gt;
 then show &amp;quot;?P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg marpoldia1 pabrodmac*)&lt;br /&gt;
lemma length_borraDuplicados_2h:&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)) ≤ &lt;br /&gt;
        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)) ≤ &lt;br /&gt;
                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í más pasos *)&lt;br /&gt;
lemma length_borraDuplicados_2i: &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)) ≤ &lt;br /&gt;
          length(borraDuplicados [a])+length (borraDuplicados xs)&amp;quot; &lt;br /&gt;
      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; &lt;br /&gt;
      by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* crigomgom rubgonmar  wilmorort pablucoto serrodcal bowma &lt;br /&gt;
    migtermor fraortmoy marpoldia1 ferrenseg danrodcha  juacabsou paupeddeg pabrodmac lucnovdos dancorgar jeamacpov *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim manmorjim1 *)&lt;br /&gt;
lemma estaEn_borraDuplicados2: &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_borraDuplicados3: &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;
(* anaprarod *)&lt;br /&gt;
lemma estaEn_borraDuplicados4: &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_borraDuplicados5: &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;
(* wilmorort *)&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; &lt;br /&gt;
        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; &lt;br /&gt;
        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;
(* anaprarod marpoldia1 ferrenseg juacabsou *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2b:&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)) = &lt;br /&gt;
             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)) = &lt;br /&gt;
             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;
(* migtermor *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2c: &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)) = &lt;br /&gt;
          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; &lt;br /&gt;
      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)) = &lt;br /&gt;
               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; &lt;br /&gt;
   using P1 by simp&lt;br /&gt;
 finally show &amp;quot;?P (aa#xs)&amp;quot; using Conc by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom paupeddeg pabrodmac*)&lt;br /&gt;
lemma estaEn_borraDuplicados_2d: &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;
(* rubgonmar jeamacpov *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2e: &lt;br /&gt;
  &amp;quot;estaEn a  ( borraDuplicados xs ) = estaEn a xs&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados []) = estaEn a []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
   fix x&lt;br /&gt;
   fix xs&lt;br /&gt;
   assume HI: &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
   show &amp;quot;estaEn a (borraDuplicados (x#xs)) = estaEn a (x#xs)&amp;quot;&lt;br /&gt;
   proof (rule iffI) (* usamos proof de la regla dada iffI*)&lt;br /&gt;
     assume cprim: &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (x#xs)&amp;quot; using cprim HI by simp&lt;br /&gt;
     qed&lt;br /&gt;
   next&lt;br /&gt;
     assume cseg: &amp;quot;estaEn a (x#xs)&amp;quot;&lt;br /&gt;
     show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot;&lt;br /&gt;
     proof (cases)&lt;br /&gt;
       assume &amp;quot;a=x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using HI by auto&lt;br /&gt;
     next&lt;br /&gt;
       assume &amp;quot;a≠x&amp;quot;&lt;br /&gt;
       then show &amp;quot;estaEn a (borraDuplicados (x#xs))&amp;quot; using `a≠x` &lt;br /&gt;
         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)) &lt;br /&gt;
  ⟹ estaEn a (x # xs); estaEn a (x # xs) &lt;br /&gt;
  ⟹ 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;
(* bowma ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados_2f: &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)) = &lt;br /&gt;
             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)) = &lt;br /&gt;
             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_2g: &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 &lt;br /&gt;
        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;
(* ivamenjim wilmorort serrodcal crigomgom anaprarod fraortmoy &lt;br /&gt;
    marpoldia1 ferrenseg danrodcha juacabsou paupeddeg josgarsan pabrodmac dancorgar jeamacpov *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: estaEn_borraDuplicados)&lt;br /&gt;
&lt;br /&gt;
(* migtermor bowma *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
by (induct xs, simp_all add: estaEn_borraDuplicados_2)&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 no caí en usar la demostración anterior y he realizado&lt;br /&gt;
  la demostración de que si un elemento no estaba en una lista seguirá sin estar&lt;br /&gt;
  después de eliminar los duplicados en esa lista... *)&lt;br /&gt;
lemma noEsta_tras_borrarDuplicados:&lt;br /&gt;
  &amp;quot;(¬estaEn x xs) ⟶ (¬estaEn x (borraDuplicados xs))&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
apply (simp add: noEsta_tras_borrarDuplicados)&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.2. Demostrar o refutar detalladamente&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
&lt;br /&gt;
-- &amp;quot;La demostración estructurada es&amp;quot;&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot; sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot;&lt;br /&gt;
proof (cases)&lt;br /&gt;
assume &amp;quot;estaEn a xs&amp;quot;&lt;br /&gt;
then show &amp;quot;sinDuplicados (borraDuplicados (a#xs))&amp;quot; using HI by simp&lt;br /&gt;
next&lt;br /&gt;
assume&amp;quot;¬ estaEn a xs&amp;quot;&lt;br /&gt;
then have &amp;quot;¬ (estaEn a xs) ∧ sinDuplicados (borraDuplicados xs)&amp;quot; using HI by simp&lt;br /&gt;
then have &amp;quot;¬ estaEn a (borraDuplicados xs) ∧  sinDuplicados (borraDuplicados xs)&amp;quot; &lt;br /&gt;
      by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
then have &amp;quot; sinDuplicados (a#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
then show &amp;quot; sinDuplicados (borraDuplicados(a #xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim migtermor crigomgom rubgonmar fraortmoy marpoldia1 ferrenseg bowma juacabsou serrodcal josgarsan pabrodmac dancorgar jeamacpov lucnovdos *)&lt;br /&gt;
&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
  show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; &lt;br /&gt;
  proof (cases)&lt;br /&gt;
    assume &amp;quot;estaEn a xs&amp;quot; &lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;¬(estaEn a xs)&amp;quot;&lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a # xs))&amp;quot; using HI by (simp add: estaEn_borraDuplicados)&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* anaprarod paupeddeg*)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show  &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
  next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
   proof (cases)&lt;br /&gt;
   assume c1: &amp;quot;estaEn x xs&amp;quot;&lt;br /&gt;
   then show &amp;quot;sinDuplicados (borraDuplicados (x#xs))&amp;quot; using HI by simp&lt;br /&gt;
   next&lt;br /&gt;
   assume c2: &amp;quot;¬ estaEn x xs&amp;quot;&lt;br /&gt;
   then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) =sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;…= (¬estaEn x (borraDuplicados xs) ∧ sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
   also have &amp;quot;… = (¬estaEn x (borraDuplicados xs))&amp;quot; using HI by simp&lt;br /&gt;
   also have &amp;quot;… = (¬(estaEn x xs))&amp;quot; by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
   also have &amp;quot;… = True&amp;quot; using c2 by simp&lt;br /&gt;
   finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_2:&lt;br /&gt;
  &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  show &amp;quot;?P (x#xs)&amp;quot;&lt;br /&gt;
  proof (cases &amp;quot;estaEn x xs&amp;quot;)&lt;br /&gt;
    case True&lt;br /&gt;
    then have 1: &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
                 = sinDuplicados (borraDuplicados xs)&amp;quot; by (simp add: estaEn_borraDuplicados_2)&lt;br /&gt;
    show &amp;quot;?P (x#xs)&amp;quot; using HI 1 by simp&lt;br /&gt;
    next&lt;br /&gt;
    case False&lt;br /&gt;
    then have &amp;quot;sinDuplicados (borraDuplicados (x#xs)) &lt;br /&gt;
               = sinDuplicados (x#borraDuplicados xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (¬ (estaEn x (borraDuplicados xs)) ∧ &lt;br /&gt;
                  sinDuplicados (borraDuplicados xs))&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = True&amp;quot;  using `¬ estaEn x xs` HI by (simp add:estaEn_borraDuplicados)&lt;br /&gt;
    finally show &amp;quot;?P (x#xs)&amp;quot; by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar o refutar:&lt;br /&gt;
    borraDuplicados (rev xs) = rev (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(*crigomgom rubgonmar ivamenjim wilmorort pablucoto migtermor &lt;br /&gt;
   anaprarod fraortmoy ferrenseg marpoldia1 bowma danrodcha juacabsou paupeddeg manmorjim1 serrodcal josgarsan pabrodmac lucnovdos dancorgar jeamacpov *)&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>Lucnovdos</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=826</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=826"/>
		<updated>2016-11-30T12:26:53Z</updated>

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

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

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

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

		<summary type="html">&lt;p&gt;Lucnovdos: &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;
(* lucnovdos *)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) =  ((P n ∧ Q n) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P n ∧ todos P xs) ∧ (Q n ∧ todos Q xs))&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = ((todos P(n#xs)) ∧ (todos Q(n#xs)))&amp;quot; by simp&lt;br /&gt;
&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (n#xs) = (todos P (n#xs) ∧ todos Q (n#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* wilmorort pablucoto crigomgom anaprarod juacabsou rubgonmar fraortmoy *}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp   &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ todos P xs ∧ Q a ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
also have &amp;quot;... = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp (* Este paso se puede obviar*)&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
{*danrodcha ivamenjim marpoldia1 migtermor ferrenseg wilmorort paupeddeg crigomgom anaprarod serrodcal juacabsou rubgonmar pablucoto fraortmoy josgarsan lucnovdos*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
{* anaprarod dancorgar *}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
apply (induct x)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg wilmorort dancorgar fraortmoy josgarsan lucnovdos*)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* migtermor serrodcal *)&lt;br /&gt;
&lt;br /&gt;
lemma todos_append1:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?P x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
 show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix a x&lt;br /&gt;
 assume HI: &amp;quot;?P x&amp;quot;&lt;br /&gt;
 have &amp;quot;todos P ((a#x) @ y) = (P a ∧ (todos P (x @ y)))&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;… = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
 finally show &amp;quot;?P (a#x)&amp;quot; by simp&lt;br /&gt;
qed  &lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
lemma todos_append:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a#(x@y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp  &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
lemma todos_append3:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a x&lt;br /&gt;
  assume HI: &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ todos P (x @ y)) &amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P [a] ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* crigomgom juacabsou anaprarod*)&lt;br /&gt;
 &lt;br /&gt;
lemma todos_append4:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix x xs&lt;br /&gt;
  assume HI:&amp;quot;todos P (xs @ y) = (todos P xs ∧ todos P y)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((x # xs) @ y) = (P x ∧ todos P (xs @ y ))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ (todos P xs ∧ todos P y)) &amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P x ∧ todos P xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((x # xs) @ y) = (todos P (x # xs) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
lemma todos_append5:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
proof (induct x )&lt;br /&gt;
  show &amp;quot;todos P ([] @ y) = (todos P [] ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a x&lt;br /&gt;
  assume HI:&amp;quot;todos P (x @ y) = (todos P x ∧ todos P y) &amp;quot; &lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = ( P a ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot; ... =( P a ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;todos P ((a # x) @ y) = (todos P (a # x) ∧ todos P y)&amp;quot; by auto&lt;br /&gt;
  qed&lt;br /&gt;
&lt;br /&gt;
{*danrodcha*}&lt;br /&gt;
lemma todos_append6:&lt;br /&gt;
  &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot; (is &amp;quot;?Q x&amp;quot;)&lt;br /&gt;
proof (induct x)&lt;br /&gt;
  show &amp;quot;?Q []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix x a assume HI: &amp;quot;?Q x&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a # x) @ y) = todos P (a # x @ y)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ todos P (x @ y))&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;… = ((P a) ∧ (todos P x ∧ todos P y))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;… = (todos P (a # x) ∧ todos P y)&amp;quot; by simp&lt;br /&gt;
  finally show &amp;quot;?Q (a # x)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim marpoldia1 serrodcal anaprarod paupeddeg *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot; &lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp&lt;br /&gt;
apply (simp add: todos_append)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg crigomgom rubgonmar fraortmoy josgarsan danrodcha lucnovdos*)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs) (auto simp add: todos_append)&lt;br /&gt;
 &lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
by (induct xs,simp,simp add: todos_append,auto)&lt;br /&gt;
&lt;br /&gt;
(* juacabsou *)&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
apply (induct xs,simp,simp add: todos_append,auto) done&lt;br /&gt;
&lt;br /&gt;
(* 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 pablucoto*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot; &lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo: P={a1}, Q={a2}, xs={a1,a2}. En este ejemplo:&lt;br /&gt;
   · &amp;quot;algunos (λx. P x ∧ Q x) xs = False&amp;quot;&lt;br /&gt;
   · &amp;quot;(algunos P xs ∧ algunos Q xs) = True&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
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 paupeddeg*)&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 paupeddeg *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; &lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
  also have &amp;quot;... = (P a ∨ Q a ∨ algunos P xs ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* wilmorort danrodcha*)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (¬todos(λx. ¬P x)xs ∨ ¬todos(λx. ¬Q x)xs)&amp;quot;&lt;br /&gt;
(is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;?P xs&amp;quot;&lt;br /&gt;
have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (P a ∨ Q a ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ Q a ∨  (¬ todos (λx. ¬ P x) xs ∨ ¬ todos (λx. ¬ Q x) xs))&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∨ ¬ todos (λx. ¬ P x) xs ∨ Q a ∨  ¬ todos (λx. ¬ Q x) xs )&amp;quot; by arith&lt;br /&gt;
finally show  &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = (~ todos (λx. ¬ P x) (a # xs) ∨ ~ todos (λx. ¬ Q x) (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* danrodcha *}&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot; (is &amp;quot;?R xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?R []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume HI: &amp;quot;?R xs&amp;quot;&lt;br /&gt;
    have 1:&amp;quot; (Q a ∨ algunos P xs) = (algunos P xs ∨ Q a)&amp;quot; by (simp add: HOL.disj_commute)&lt;br /&gt;
    have &amp;quot;algunos (λx. P x ∨ Q x) (a # xs) = &lt;br /&gt;
     (algunos P [a] ∨ algunos Q [a] ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot; by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ (Q a ∨ algunos P xs) ∨ algunos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = (P a ∨ algunos P xs ∨ Q a ∨ algunos Q xs)&amp;quot; using 1 by simp&lt;br /&gt;
    also have &amp;quot;… = (algunos P (a # xs) ∨ algunos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
    finally show &amp;quot;?R (a # xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&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>Lucnovdos</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=607</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=607"/>
		<updated>2016-11-22T22:58:01Z</updated>

		<summary type="html">&lt;p&gt;Lucnovdos: &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;
(* lucnovdos *)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) =  ((P n ∧ Q n) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P n ∧ todos P xs) ∧ (Q n ∧ todos Q xs))&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = ((todos P(n#xs)) ∧ (todos Q(n#xs)))&amp;quot; by simp&lt;br /&gt;
&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (n#xs) = (todos P (n#xs) ∧ todos Q (n#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* wilmorort pablucoto crigomgom anaprarod juacabsou rubgonmar fraortmoy *}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp   &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ todos P xs ∧ Q a ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
also have &amp;quot;... = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp (* Este paso se puede obviar*)&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
{*danrodcha ivamenjim marpoldia1 migtermor ferrenseg wilmorort paupeddeg crigomgom anaprarod serrodcal juacabsou rubgonmar pablucoto fraortmoy josgarsan lucnovdos*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
{* anaprarod dancorgar *}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
apply (induct x)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg wilmorort dancorgar fraortmoy josgarsan*)&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 paupeddeg*)&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>Lucnovdos</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=606</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=606"/>
		<updated>2016-11-22T22:56:27Z</updated>

		<summary type="html">&lt;p&gt;Lucnovdos: &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;
(* lucnovdos *)&lt;br /&gt;
 &lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n xs&lt;br /&gt;
  assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot; &lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) (n # xs) =  ((P n ∧ Q n) ∧ (todos P xs ∧ todos Q xs))&amp;quot; using HI by simp&lt;br /&gt;
  also have &amp;quot;... = ((P n ∧ todos P xs) ∧ (Q n ∧ todos Q xs))&amp;quot; by arith&lt;br /&gt;
  also have &amp;quot;... = ((todos P(n#xs)) ∧ (todos Q(n#xs)))&amp;quot; by simp&lt;br /&gt;
&lt;br /&gt;
 finally show &amp;quot;todos (λx. P x ∧ Q x) (n#xs) = (todos P (n#xs) ∧ todos Q (n#xs))&amp;quot; by simp &lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
{* wilmorort pablucoto crigomgom anaprarod juacabsou rubgonmar fraortmoy *}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; by simp   &lt;br /&gt;
next&lt;br /&gt;
fix a xs&lt;br /&gt;
assume HI: &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
have &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (P a ∧ Q a ∧ todos (λx. P x ∧ Q x) xs)&amp;quot; by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ Q a ∧ todos P xs ∧ todos Q xs)&amp;quot; using HI by simp&lt;br /&gt;
also have &amp;quot;... = (P a ∧ todos P xs ∧ Q a ∧ todos Q xs)&amp;quot;  by arith&lt;br /&gt;
also have &amp;quot;... = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp (* Este paso se puede obviar*)&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (a # xs) = (todos P (a # xs) ∧ todos Q (a # xs))&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Demostrar o refutar automáticamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
{*danrodcha ivamenjim marpoldia1 migtermor ferrenseg wilmorort paupeddeg crigomgom anaprarod serrodcal juacabsou rubgonmar pablucoto fraortmoy josgarsan*}&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 paupeddeg*)&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>Lucnovdos</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=581</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=581"/>
		<updated>2016-11-22T17:44:40Z</updated>

		<summary type="html">&lt;p&gt;Lucnovdos: &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 *}&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 *)&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;
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 *)&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 *)&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 *)&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;
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 *)&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 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;
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 *)&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;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg crigomgom rubgonmar  wilmorort*)&lt;br /&gt;
&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;
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 *)&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 *)&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*)&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*)&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*)&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>Lucnovdos</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=580</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=580"/>
		<updated>2016-11-22T17:43:15Z</updated>

		<summary type="html">&lt;p&gt;Lucnovdos: &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*}&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 *}&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 *)&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;
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 *)&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 *)&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 *)&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;
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 *)&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 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;
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 *)&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;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg crigomgom rubgonmar  wilmorort*)&lt;br /&gt;
&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;
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 *)&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 *)&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*)&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*)&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*)&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>Lucnovdos</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=579</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=579"/>
		<updated>2016-11-22T17:42:09Z</updated>

		<summary type="html">&lt;p&gt;Lucnovdos: &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 *)&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*}&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 *}&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 *)&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;
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 *)&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 *)&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 *)&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;
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 *)&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 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;
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 *)&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;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1 paupeddeg crigomgom rubgonmar  wilmorort*)&lt;br /&gt;
&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;
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 *)&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 *)&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*)&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*)&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*)&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>Lucnovdos</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_3&amp;diff=394</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=394"/>
		<updated>2016-11-16T18:39:29Z</updated>

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

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

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