<?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=Wilmorort</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=Wilmorort"/>
	<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php/Especial:Contribuciones/Wilmorort"/>
	<updated>2026-07-18T02:30:08Z</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=1141</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=1141"/>
		<updated>2016-12-18T22:39:07Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R7: Árboles binarios completos *}&lt;br /&gt;
&lt;br /&gt;
theory R7_Arboles_binarios_completos&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  En esta relación se piden demostraciones automáticas (lo más cortas&lt;br /&gt;
  posibles). Para ello, en algunos casos es necesario incluir lemas&lt;br /&gt;
  auxiliares (que se demuestran automáticamente) y usar ejercicios&lt;br /&gt;
  anteriores. &lt;br /&gt;
&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que no tienen información ni en los nodos y ni en las&lt;br /&gt;
  hojas. Por ejemplo, el árbol&lt;br /&gt;
          ·&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       ·     ·&lt;br /&gt;
      / \   / \&lt;br /&gt;
     ·   · ·   · &lt;br /&gt;
  se representa por &amp;quot;N (N H H) (N H H)&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
datatype arbol = H | N arbol arbol&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N (N H H) (N H H) = (N (N H H) (N H H) :: arbol)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función&lt;br /&gt;
     hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (hojas a) es el número de hojas del árbol a. Por ejemplo,&lt;br /&gt;
     hojas (N (N H H) (N H H)) = 4&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
fun hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas H = Suc 0&amp;quot;&lt;br /&gt;
| &amp;quot;hojas (N a b) = hojas a + hojas b&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;hojas (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 anaprarod paupeddeg migtermor wilmorort pablucoto ivamenjim *)&lt;br /&gt;
(* Es muy parecida a la definición anterior *)&lt;br /&gt;
fun hojas2 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas2 H = 1&amp;quot; |&lt;br /&gt;
  &amp;quot;hojas2 (N i d) = hojas2 i + hojas2 d&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
value &amp;quot;hojas2 (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* Equivalencia de las definiciones *)&lt;br /&gt;
lemma &amp;quot;hojas a = hojas2 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función&lt;br /&gt;
     profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (profundidad a) es la profundidad del árbol a. Por ejemplo,&lt;br /&gt;
     profundidad (N (N H H) (N H H)) = 2&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 anaprarod migtermor wilmorort*)&lt;br /&gt;
fun profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad (N a b) = (if profundidad a &amp;gt; profundidad b&lt;br /&gt;
                          then 1 + profundidad a &lt;br /&gt;
                          else 1 + profundidad b)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;profundidad (N (N H H) (N H H)) = 2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod wilmorort pablucoto ivamenjim *)&lt;br /&gt;
fun profundidad2 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad2 H = 0&amp;quot;&lt;br /&gt;
 |&amp;quot;profundidad2 (N i d) = 1 + (max (profundidad2 i)(profundidad2 d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;profundidad2 (N (N H H) (N H H)) = 2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* Equivalencia de las definiciones *)&lt;br /&gt;
lemma &amp;quot;profundidad a= profundidad2 a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* paupeddeg *)&lt;br /&gt;
fun maximo :: &amp;quot;nat ×  nat =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;maximo (a,b) = (if a &amp;gt; b &lt;br /&gt;
                    then a else b)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
fun profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad (N i d) = 1 + maximo(profundidad i, profundidad d)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim: llamando a la función anterior profundidad3 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;profundidad a = profundidad3 a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
fun profundidad4 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad4 H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad4 (N i d) = Suc (max (profundidad4 i)(profundidad4 d))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;profundidad a = profundidad4 a&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función&lt;br /&gt;
     abc :: &amp;quot;nat ⇒ arbol&amp;quot; &lt;br /&gt;
  tal que (abc n) es el árbol binario completo de profundidad n. Por&lt;br /&gt;
  ejemplo,  &lt;br /&gt;
     abc 3 = N (N (N H H) (N H H)) (N (N H H) (N H H))&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
(* fraortmoy marpoldia1 anaprarod paupeddeg migtermor  wilmorort*)&lt;br /&gt;
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;
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 *)&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 *)&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 *)&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 *)&lt;br /&gt;
lemma AUX7: &amp;quot;es_abc profundidad a ⟶ (hojas a = 2^(profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod wilmorort *)&lt;br /&gt;
(* También funciona con AUX7 *)&lt;br /&gt;
&lt;br /&gt;
lemma lej7: &amp;quot;es_abc profundidad a = es_abc hojas a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: abc_prof_num_hojas)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que un árbol binario a es completo respecto del&lt;br /&gt;
  número de hojas syss es completo respecto del número de nodos.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor wilmorort*)&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 *)&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*)&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 *)&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;
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*)&lt;br /&gt;
&lt;br /&gt;
lemma lej9:  &amp;quot;es_abc profundidad a = es_abc size a&amp;quot;&lt;br /&gt;
by (simp add: lej7 lej8)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Demostrar que (abc n) es un árbol binario completo.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor wilmorort *)&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 *)&lt;br /&gt;
(* con un demostrador más débil *)&lt;br /&gt;
lemma L10:  &amp;quot;es_abc f (abc a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Demostrar que si a es un árbolo binario completo&lt;br /&gt;
  respecto de la profundidad, entonces a es igual a&lt;br /&gt;
  (abc (profundidad a)).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor wilmorort *)&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 *)&lt;br /&gt;
lemma &amp;quot;es_abc profundidad a ⟶ (a = (abc (profundidad a)))&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Encontrar una medida f tal que (es_abc f) es distinto de &lt;br /&gt;
  (es_abc size).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
fun medida_nula :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
 &amp;quot;medida_nula H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;medida_nula (N i d) = 0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;es_abc medida_nula a = es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo:&lt;br /&gt;
  a= N H (N H H) &lt;br /&gt;
  Tras evaluar:&lt;br /&gt;
  es_abc medida_nula a = True&lt;br /&gt;
  es_abc size a = False*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod  wilmorort*)&lt;br /&gt;
lemma &amp;quot;es_abc f a =  es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
(* Quickcheck found a counterexample:&lt;br /&gt;
  f = λx. a⇩1   &lt;br /&gt;
  a = N H (N H H)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  es_abc f a = True&lt;br /&gt;
  es_abc size a = False *)&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_7&amp;diff=1136</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=1136"/>
		<updated>2016-12-18T22:00:33Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R7: Árboles binarios completos *}&lt;br /&gt;
&lt;br /&gt;
theory R7_Arboles_binarios_completos&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  En esta relación se piden demostraciones automáticas (lo más cortas&lt;br /&gt;
  posibles). Para ello, en algunos casos es necesario incluir lemas&lt;br /&gt;
  auxiliares (que se demuestran automáticamente) y usar ejercicios&lt;br /&gt;
  anteriores. &lt;br /&gt;
&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que no tienen información ni en los nodos y ni en las&lt;br /&gt;
  hojas. Por ejemplo, el árbol&lt;br /&gt;
          ·&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       ·     ·&lt;br /&gt;
      / \   / \&lt;br /&gt;
     ·   · ·   · &lt;br /&gt;
  se representa por &amp;quot;N (N H H) (N H H)&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
datatype arbol = H | N arbol arbol&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N (N H H) (N H H) = (N (N H H) (N H H) :: arbol)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función&lt;br /&gt;
     hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (hojas a) es el número de hojas del árbol a. Por ejemplo,&lt;br /&gt;
     hojas (N (N H H) (N H H)) = 4&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
fun hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas H = Suc 0&amp;quot;&lt;br /&gt;
| &amp;quot;hojas (N a b) = hojas a + hojas b&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;hojas (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 anaprarod paupeddeg migtermor wilmorort pablucoto*)&lt;br /&gt;
(* Es muy parecida a la definición anterior *)&lt;br /&gt;
fun hojas2 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas2 H = 1&amp;quot; |&lt;br /&gt;
  &amp;quot;hojas2 (N i d) = hojas2 i + hojas2 d&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
value &amp;quot;hojas2 (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* Equivalencia de las definiciones *)&lt;br /&gt;
lemma &amp;quot;hojas a = hojas2 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función&lt;br /&gt;
     profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (profundidad a) es la profundidad del árbol a. Por ejemplo,&lt;br /&gt;
     profundidad (N (N H H) (N H H)) = 2&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 anaprarod migtermor wilmorort*)&lt;br /&gt;
fun profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad (N a b) = (if profundidad a &amp;gt; profundidad b&lt;br /&gt;
                          then 1 + profundidad a &lt;br /&gt;
                          else 1 + profundidad b)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;profundidad (N (N H H) (N H H)) = 2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod wilmorort*)&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;
&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;
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;
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 *)&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 *)&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 *)&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 *)&lt;br /&gt;
lemma AUX7: &amp;quot;es_abc profundidad a ⟶ (hojas a = 2^(profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod wilmorort *)&lt;br /&gt;
(* También funciona con AUX7 *)&lt;br /&gt;
&lt;br /&gt;
lemma lej7: &amp;quot;es_abc profundidad a = es_abc hojas a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: abc_prof_num_hojas)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que un árbol binario a es completo respecto del&lt;br /&gt;
  número de hojas syss es completo respecto del número de nodos.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor wilmorort*)&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 *)&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*)&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 *)&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;
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*)&lt;br /&gt;
&lt;br /&gt;
lemma lej9:  &amp;quot;es_abc profundidad a = es_abc size a&amp;quot;&lt;br /&gt;
by (simp add: lej7 lej8)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Demostrar que (abc n) es un árbol binario completo.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&lt;br /&gt;
(* con un demostrador más débil *)&lt;br /&gt;
lemma L10:  &amp;quot;es_abc f (abc a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Demostrar que si a es un árbolo binario completo&lt;br /&gt;
  respecto de la profundidad, entonces a es igual a&lt;br /&gt;
  (abc (profundidad a)).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&lt;br /&gt;
lemma &amp;quot;es_abc profundidad a ⟶ (a = (abc (profundidad a)))&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Encontrar una medida f tal que (es_abc f) es distinto de &lt;br /&gt;
  (es_abc size).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
fun medida_nula :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
 &amp;quot;medida_nula H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;medida_nula (N i d) = 0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;es_abc medida_nula a = es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo:&lt;br /&gt;
  a= N H (N H H) &lt;br /&gt;
  Tras evaluar:&lt;br /&gt;
  es_abc medida_nula a = True&lt;br /&gt;
  es_abc size a = False*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod  wilmorort*)&lt;br /&gt;
lemma &amp;quot;es_abc f a =  es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
(* Quickcheck found a counterexample:&lt;br /&gt;
  f = λx. a⇩1   &lt;br /&gt;
  a = N H (N H H)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  es_abc f a = True&lt;br /&gt;
  es_abc size a = False *)&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_7&amp;diff=1134</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=1134"/>
		<updated>2016-12-18T21:26:01Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R7: Árboles binarios completos *}&lt;br /&gt;
&lt;br /&gt;
theory R7_Arboles_binarios_completos&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  En esta relación se piden demostraciones automáticas (lo más cortas&lt;br /&gt;
  posibles). Para ello, en algunos casos es necesario incluir lemas&lt;br /&gt;
  auxiliares (que se demuestran automáticamente) y usar ejercicios&lt;br /&gt;
  anteriores. &lt;br /&gt;
&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que no tienen información ni en los nodos y ni en las&lt;br /&gt;
  hojas. Por ejemplo, el árbol&lt;br /&gt;
          ·&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       ·     ·&lt;br /&gt;
      / \   / \&lt;br /&gt;
     ·   · ·   · &lt;br /&gt;
  se representa por &amp;quot;N (N H H) (N H H)&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
datatype arbol = H | N arbol arbol&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N (N H H) (N H H) = (N (N H H) (N H H) :: arbol)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función&lt;br /&gt;
     hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (hojas a) es el número de hojas del árbol a. Por ejemplo,&lt;br /&gt;
     hojas (N (N H H) (N H H)) = 4&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
fun hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas H = Suc 0&amp;quot;&lt;br /&gt;
| &amp;quot;hojas (N a b) = hojas a + hojas b&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;hojas (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 anaprarod paupeddeg migtermor wilmorort*)&lt;br /&gt;
(* Es muy parecida a la definición anterior *)&lt;br /&gt;
fun hojas2 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas2 H = 1&amp;quot; |&lt;br /&gt;
  &amp;quot;hojas2 (N i d) = hojas2 i + hojas2 d&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
value &amp;quot;hojas2 (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* Equivalencia de las definiciones *)&lt;br /&gt;
lemma &amp;quot;hojas a = hojas2 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función&lt;br /&gt;
     profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (profundidad a) es la profundidad del árbol a. Por ejemplo,&lt;br /&gt;
     profundidad (N (N H H) (N H H)) = 2&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 anaprarod migtermor wilmorort*)&lt;br /&gt;
fun profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad (N a b) = (if profundidad a &amp;gt; profundidad b&lt;br /&gt;
                          then 1 + profundidad a &lt;br /&gt;
                          else 1 + profundidad b)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;profundidad (N (N H H) (N H H)) = 2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod wilmorort*)&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;
&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;
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;
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 *)&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 *)&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 *)&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 *)&lt;br /&gt;
lemma AUX7: &amp;quot;es_abc profundidad a ⟶ (hojas a = 2^(profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod wilmorort *)&lt;br /&gt;
(* También funciona con AUX7 *)&lt;br /&gt;
&lt;br /&gt;
lemma lej7: &amp;quot;es_abc profundidad a = es_abc hojas a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: abc_prof_num_hojas)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que un árbol binario a es completo respecto del&lt;br /&gt;
  número de hojas syss es completo respecto del número de nodos.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor wilmorort*)&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 *)&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*)&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 *)&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;
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 *)&lt;br /&gt;
&lt;br /&gt;
lemma lej9:  &amp;quot;es_abc profundidad a = es_abc size a&amp;quot;&lt;br /&gt;
by (simp add: lej7 lej8)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Demostrar que (abc n) es un árbol binario completo.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&lt;br /&gt;
(* con un demostrador más débil *)&lt;br /&gt;
lemma L10:  &amp;quot;es_abc f (abc a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Demostrar que si a es un árbolo binario completo&lt;br /&gt;
  respecto de la profundidad, entonces a es igual a&lt;br /&gt;
  (abc (profundidad a)).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&lt;br /&gt;
lemma &amp;quot;es_abc profundidad a ⟶ (a = (abc (profundidad a)))&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Encontrar una medida f tal que (es_abc f) es distinto de &lt;br /&gt;
  (es_abc size).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
fun medida_nula :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
 &amp;quot;medida_nula H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;medida_nula (N i d) = 0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;es_abc medida_nula a = es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo:&lt;br /&gt;
  a= N H (N H H) &lt;br /&gt;
  Tras evaluar:&lt;br /&gt;
  es_abc medida_nula a = True&lt;br /&gt;
  es_abc size a = False*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod  wilmorort*)&lt;br /&gt;
lemma &amp;quot;es_abc f a =  es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
(* Quickcheck found a counterexample:&lt;br /&gt;
  f = λx. a⇩1   &lt;br /&gt;
  a = N H (N H H)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  es_abc f a = True&lt;br /&gt;
  es_abc size a = False *)&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_7&amp;diff=1133</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=1133"/>
		<updated>2016-12-18T21:14:11Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R7: Árboles binarios completos *}&lt;br /&gt;
&lt;br /&gt;
theory R7_Arboles_binarios_completos&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  En esta relación se piden demostraciones automáticas (lo más cortas&lt;br /&gt;
  posibles). Para ello, en algunos casos es necesario incluir lemas&lt;br /&gt;
  auxiliares (que se demuestran automáticamente) y usar ejercicios&lt;br /&gt;
  anteriores. &lt;br /&gt;
&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que no tienen información ni en los nodos y ni en las&lt;br /&gt;
  hojas. Por ejemplo, el árbol&lt;br /&gt;
          ·&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       ·     ·&lt;br /&gt;
      / \   / \&lt;br /&gt;
     ·   · ·   · &lt;br /&gt;
  se representa por &amp;quot;N (N H H) (N H H)&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
datatype arbol = H | N arbol arbol&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N (N H H) (N H H) = (N (N H H) (N H H) :: arbol)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función&lt;br /&gt;
     hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (hojas a) es el número de hojas del árbol a. Por ejemplo,&lt;br /&gt;
     hojas (N (N H H) (N H H)) = 4&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
fun hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas H = Suc 0&amp;quot;&lt;br /&gt;
| &amp;quot;hojas (N a b) = hojas a + hojas b&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;hojas (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 anaprarod paupeddeg migtermor wilmorort*)&lt;br /&gt;
(* Es muy parecida a la definición anterior *)&lt;br /&gt;
fun hojas2 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas2 H = 1&amp;quot; |&lt;br /&gt;
  &amp;quot;hojas2 (N i d) = hojas2 i + hojas2 d&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
value &amp;quot;hojas2 (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* Equivalencia de las definiciones *)&lt;br /&gt;
lemma &amp;quot;hojas a = hojas2 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función&lt;br /&gt;
     profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (profundidad a) es la profundidad del árbol a. Por ejemplo,&lt;br /&gt;
     profundidad (N (N H H) (N H H)) = 2&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 anaprarod migtermor wilmorort*)&lt;br /&gt;
fun profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad (N a b) = (if profundidad a &amp;gt; profundidad b&lt;br /&gt;
                          then 1 + profundidad a &lt;br /&gt;
                          else 1 + profundidad b)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;profundidad (N (N H H) (N H H)) = 2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod wilmorort*)&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;
&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;
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;
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 *)&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 *)&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 *)&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 *)&lt;br /&gt;
lemma AUX7: &amp;quot;es_abc profundidad a ⟶ (hojas a = 2^(profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod wilmorort *)&lt;br /&gt;
(* También funciona con AUX7 *)&lt;br /&gt;
&lt;br /&gt;
lemma lej7: &amp;quot;es_abc profundidad a = es_abc hojas a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: abc_prof_num_hojas)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que un árbol binario a es completo respecto del&lt;br /&gt;
  número de hojas syss es completo respecto del número de nodos.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&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*)&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 *)&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;
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 *)&lt;br /&gt;
&lt;br /&gt;
lemma lej9:  &amp;quot;es_abc profundidad a = es_abc size a&amp;quot;&lt;br /&gt;
by (simp add: lej7 lej8)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Demostrar que (abc n) es un árbol binario completo.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&lt;br /&gt;
(* con un demostrador más débil *)&lt;br /&gt;
lemma L10:  &amp;quot;es_abc f (abc a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Demostrar que si a es un árbolo binario completo&lt;br /&gt;
  respecto de la profundidad, entonces a es igual a&lt;br /&gt;
  (abc (profundidad a)).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&lt;br /&gt;
lemma &amp;quot;es_abc profundidad a ⟶ (a = (abc (profundidad a)))&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Encontrar una medida f tal que (es_abc f) es distinto de &lt;br /&gt;
  (es_abc size).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
fun medida_nula :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
 &amp;quot;medida_nula H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;medida_nula (N i d) = 0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;es_abc medida_nula a = es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo:&lt;br /&gt;
  a= N H (N H H) &lt;br /&gt;
  Tras evaluar:&lt;br /&gt;
  es_abc medida_nula a = True&lt;br /&gt;
  es_abc size a = False*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod  wilmorort*)&lt;br /&gt;
lemma &amp;quot;es_abc f a =  es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
(* Quickcheck found a counterexample:&lt;br /&gt;
  f = λx. a⇩1   &lt;br /&gt;
  a = N H (N H H)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  es_abc f a = True&lt;br /&gt;
  es_abc size a = False *)&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_7&amp;diff=1132</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=1132"/>
		<updated>2016-12-18T21:02:21Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R7: Árboles binarios completos *}&lt;br /&gt;
&lt;br /&gt;
theory R7_Arboles_binarios_completos&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  En esta relación se piden demostraciones automáticas (lo más cortas&lt;br /&gt;
  posibles). Para ello, en algunos casos es necesario incluir lemas&lt;br /&gt;
  auxiliares (que se demuestran automáticamente) y usar ejercicios&lt;br /&gt;
  anteriores. &lt;br /&gt;
&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que no tienen información ni en los nodos y ni en las&lt;br /&gt;
  hojas. Por ejemplo, el árbol&lt;br /&gt;
          ·&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       ·     ·&lt;br /&gt;
      / \   / \&lt;br /&gt;
     ·   · ·   · &lt;br /&gt;
  se representa por &amp;quot;N (N H H) (N H H)&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
datatype arbol = H | N arbol arbol&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N (N H H) (N H H) = (N (N H H) (N H H) :: arbol)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función&lt;br /&gt;
     hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (hojas a) es el número de hojas del árbol a. Por ejemplo,&lt;br /&gt;
     hojas (N (N H H) (N H H)) = 4&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
fun hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas H = Suc 0&amp;quot;&lt;br /&gt;
| &amp;quot;hojas (N a b) = hojas a + hojas b&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;hojas (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 anaprarod paupeddeg migtermor wilmorort*)&lt;br /&gt;
(* Es muy parecida a la definición anterior *)&lt;br /&gt;
fun hojas2 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas2 H = 1&amp;quot; |&lt;br /&gt;
  &amp;quot;hojas2 (N i d) = hojas2 i + hojas2 d&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
value &amp;quot;hojas2 (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* Equivalencia de las definiciones *)&lt;br /&gt;
lemma &amp;quot;hojas a = hojas2 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función&lt;br /&gt;
     profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (profundidad a) es la profundidad del árbol a. Por ejemplo,&lt;br /&gt;
     profundidad (N (N H H) (N H H)) = 2&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 anaprarod migtermor wilmorort*)&lt;br /&gt;
fun profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad (N a b) = (if profundidad a &amp;gt; profundidad b&lt;br /&gt;
                          then 1 + profundidad a &lt;br /&gt;
                          else 1 + profundidad b)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;profundidad (N (N H H) (N H H)) = 2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod wilmorort*)&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;
&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;
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;
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 *)&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 *)&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 *)&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 *)&lt;br /&gt;
lemma AUX7: &amp;quot;es_abc profundidad a ⟶ (hojas a = 2^(profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod wilmorort *)&lt;br /&gt;
(* También funciona con AUX7 *)&lt;br /&gt;
&lt;br /&gt;
lemma lej7: &amp;quot;es_abc profundidad a = es_abc hojas a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: abc_prof_num_hojas)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que un árbol binario a es completo respecto del&lt;br /&gt;
  número de hojas syss es completo respecto del número de nodos.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&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*)&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 *)&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;
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 *)&lt;br /&gt;
&lt;br /&gt;
lemma lej9:  &amp;quot;es_abc profundidad a = es_abc size a&amp;quot;&lt;br /&gt;
by (simp add: lej7 lej8)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Demostrar que (abc n) es un árbol binario completo.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&lt;br /&gt;
(* con un demostrador más débil *)&lt;br /&gt;
lemma L10:  &amp;quot;es_abc f (abc a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Demostrar que si a es un árbolo binario completo&lt;br /&gt;
  respecto de la profundidad, entonces a es igual a&lt;br /&gt;
  (abc (profundidad a)).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&lt;br /&gt;
lemma &amp;quot;es_abc profundidad a ⟶ (a = (abc (profundidad a)))&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Encontrar una medida f tal que (es_abc f) es distinto de &lt;br /&gt;
  (es_abc size).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
fun medida_nula :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
 &amp;quot;medida_nula H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;medida_nula (N i d) = 0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;es_abc medida_nula a = es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo:&lt;br /&gt;
  a= N H (N H H) &lt;br /&gt;
  Tras evaluar:&lt;br /&gt;
  es_abc medida_nula a = True&lt;br /&gt;
  es_abc size a = False*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma &amp;quot;es_abc f a =  es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
(* Quickcheck found a counterexample:&lt;br /&gt;
  f = λx. a⇩1   &lt;br /&gt;
  a = N H (N H H)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  es_abc f a = True&lt;br /&gt;
  es_abc size a = False *)&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_7&amp;diff=1131</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=1131"/>
		<updated>2016-12-18T20:43:53Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R7: Árboles binarios completos *}&lt;br /&gt;
&lt;br /&gt;
theory R7_Arboles_binarios_completos&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  En esta relación se piden demostraciones automáticas (lo más cortas&lt;br /&gt;
  posibles). Para ello, en algunos casos es necesario incluir lemas&lt;br /&gt;
  auxiliares (que se demuestran automáticamente) y usar ejercicios&lt;br /&gt;
  anteriores. &lt;br /&gt;
&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que no tienen información ni en los nodos y ni en las&lt;br /&gt;
  hojas. Por ejemplo, el árbol&lt;br /&gt;
          ·&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       ·     ·&lt;br /&gt;
      / \   / \&lt;br /&gt;
     ·   · ·   · &lt;br /&gt;
  se representa por &amp;quot;N (N H H) (N H H)&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
datatype arbol = H | N arbol arbol&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N (N H H) (N H H) = (N (N H H) (N H H) :: arbol)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función&lt;br /&gt;
     hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (hojas a) es el número de hojas del árbol a. Por ejemplo,&lt;br /&gt;
     hojas (N (N H H) (N H H)) = 4&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
fun hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas H = Suc 0&amp;quot;&lt;br /&gt;
| &amp;quot;hojas (N a b) = hojas a + hojas b&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;hojas (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 anaprarod paupeddeg migtermor wilmorort*)&lt;br /&gt;
(* Es muy parecida a la definición anterior *)&lt;br /&gt;
fun hojas2 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas2 H = 1&amp;quot; |&lt;br /&gt;
  &amp;quot;hojas2 (N i d) = hojas2 i + hojas2 d&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
value &amp;quot;hojas2 (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* Equivalencia de las definiciones *)&lt;br /&gt;
lemma &amp;quot;hojas a = hojas2 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función&lt;br /&gt;
     profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (profundidad a) es la profundidad del árbol a. Por ejemplo,&lt;br /&gt;
     profundidad (N (N H H) (N H H)) = 2&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 anaprarod migtermor wilmorort*)&lt;br /&gt;
fun profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad (N a b) = (if profundidad a &amp;gt; profundidad b&lt;br /&gt;
                          then 1 + profundidad a &lt;br /&gt;
                          else 1 + profundidad b)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;profundidad (N (N H H) (N H H)) = 2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod wilmorort*)&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;
&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;
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;
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 *)&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 *)&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 *)&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 *)&lt;br /&gt;
lemma AUX7: &amp;quot;es_abc profundidad a ⟶ (hojas a = 2^(profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod *)&lt;br /&gt;
(* También funciona con AUX7 *)&lt;br /&gt;
&lt;br /&gt;
lemma lej7: &amp;quot;es_abc profundidad a = es_abc hojas a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: abc_prof_num_hojas)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que un árbol binario a es completo respecto del&lt;br /&gt;
  número de hojas syss es completo respecto del número de nodos.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&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*)&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 *)&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;
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 *)&lt;br /&gt;
&lt;br /&gt;
lemma lej9:  &amp;quot;es_abc profundidad a = es_abc size a&amp;quot;&lt;br /&gt;
by (simp add: lej7 lej8)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Demostrar que (abc n) es un árbol binario completo.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&lt;br /&gt;
(* con un demostrador más débil *)&lt;br /&gt;
lemma L10:  &amp;quot;es_abc f (abc a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Demostrar que si a es un árbolo binario completo&lt;br /&gt;
  respecto de la profundidad, entonces a es igual a&lt;br /&gt;
  (abc (profundidad a)).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&lt;br /&gt;
lemma &amp;quot;es_abc profundidad a ⟶ (a = (abc (profundidad a)))&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Encontrar una medida f tal que (es_abc f) es distinto de &lt;br /&gt;
  (es_abc size).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
fun medida_nula :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
 &amp;quot;medida_nula H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;medida_nula (N i d) = 0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;es_abc medida_nula a = es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo:&lt;br /&gt;
  a= N H (N H H) &lt;br /&gt;
  Tras evaluar:&lt;br /&gt;
  es_abc medida_nula a = True&lt;br /&gt;
  es_abc size a = False*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma &amp;quot;es_abc f a =  es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
(* Quickcheck found a counterexample:&lt;br /&gt;
  f = λx. a⇩1   &lt;br /&gt;
  a = N H (N H H)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  es_abc f a = True&lt;br /&gt;
  es_abc size a = False *)&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_7&amp;diff=1130</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=1130"/>
		<updated>2016-12-18T20:40:26Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R7: Árboles binarios completos *}&lt;br /&gt;
&lt;br /&gt;
theory R7_Arboles_binarios_completos&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  En esta relación se piden demostraciones automáticas (lo más cortas&lt;br /&gt;
  posibles). Para ello, en algunos casos es necesario incluir lemas&lt;br /&gt;
  auxiliares (que se demuestran automáticamente) y usar ejercicios&lt;br /&gt;
  anteriores. &lt;br /&gt;
&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que no tienen información ni en los nodos y ni en las&lt;br /&gt;
  hojas. Por ejemplo, el árbol&lt;br /&gt;
          ·&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       ·     ·&lt;br /&gt;
      / \   / \&lt;br /&gt;
     ·   · ·   · &lt;br /&gt;
  se representa por &amp;quot;N (N H H) (N H H)&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
datatype arbol = H | N arbol arbol&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N (N H H) (N H H) = (N (N H H) (N H H) :: arbol)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función&lt;br /&gt;
     hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (hojas a) es el número de hojas del árbol a. Por ejemplo,&lt;br /&gt;
     hojas (N (N H H) (N H H)) = 4&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
fun hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas H = Suc 0&amp;quot;&lt;br /&gt;
| &amp;quot;hojas (N a b) = hojas a + hojas b&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;hojas (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 anaprarod paupeddeg migtermor wilmorort*)&lt;br /&gt;
(* Es muy parecida a la definición anterior *)&lt;br /&gt;
fun hojas2 :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas2 H = 1&amp;quot; |&lt;br /&gt;
  &amp;quot;hojas2 (N i d) = hojas2 i + hojas2 d&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
value &amp;quot;hojas2 (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
(* Equivalencia de las definiciones *)&lt;br /&gt;
lemma &amp;quot;hojas a = hojas2 a&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función&lt;br /&gt;
     profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (profundidad a) es la profundidad del árbol a. Por ejemplo,&lt;br /&gt;
     profundidad (N (N H H) (N H H)) = 2&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 anaprarod migtermor wilmorort*)&lt;br /&gt;
fun profundidad :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;profundidad H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;profundidad (N a b) = (if profundidad a &amp;gt; profundidad b&lt;br /&gt;
                          then 1 + profundidad a &lt;br /&gt;
                          else 1 + profundidad b)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;profundidad (N (N H H) (N H H)) = 2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod wilmorort*)&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;
&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 *)&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;
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 *)&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 *)&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 *)&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 *)&lt;br /&gt;
lemma AUX7: &amp;quot;es_abc profundidad a ⟶ (hojas a = 2^(profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod *)&lt;br /&gt;
(* También funciona con AUX7 *)&lt;br /&gt;
&lt;br /&gt;
lemma lej7: &amp;quot;es_abc profundidad a = es_abc hojas a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: abc_prof_num_hojas)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que un árbol binario a es completo respecto del&lt;br /&gt;
  número de hojas syss es completo respecto del número de nodos.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&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*)&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 *)&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;
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 *)&lt;br /&gt;
&lt;br /&gt;
lemma lej9:  &amp;quot;es_abc profundidad a = es_abc size a&amp;quot;&lt;br /&gt;
by (simp add: lej7 lej8)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Demostrar que (abc n) es un árbol binario completo.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&lt;br /&gt;
(* con un demostrador más débil *)&lt;br /&gt;
lemma L10:  &amp;quot;es_abc f (abc a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Demostrar que si a es un árbolo binario completo&lt;br /&gt;
  respecto de la profundidad, entonces a es igual a&lt;br /&gt;
  (abc (profundidad a)).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&lt;br /&gt;
lemma &amp;quot;es_abc profundidad a ⟶ (a = (abc (profundidad a)))&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Encontrar una medida f tal que (es_abc f) es distinto de &lt;br /&gt;
  (es_abc size).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
fun medida_nula :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
 &amp;quot;medida_nula H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;medida_nula (N i d) = 0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;es_abc medida_nula a = es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo:&lt;br /&gt;
  a= N H (N H H) &lt;br /&gt;
  Tras evaluar:&lt;br /&gt;
  es_abc medida_nula a = True&lt;br /&gt;
  es_abc size a = False*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma &amp;quot;es_abc f a =  es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
(* Quickcheck found a counterexample:&lt;br /&gt;
  f = λx. a⇩1   &lt;br /&gt;
  a = N H (N H H)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  es_abc f a = True&lt;br /&gt;
  es_abc size a = False *)&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_7&amp;diff=1129</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=1129"/>
		<updated>2016-12-18T20:25:16Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R7: Árboles binarios completos *}&lt;br /&gt;
&lt;br /&gt;
theory R7_Arboles_binarios_completos&lt;br /&gt;
imports Main &lt;br /&gt;
begin &lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  En esta relación se piden demostraciones automáticas (lo más cortas&lt;br /&gt;
  posibles). Para ello, en algunos casos es necesario incluir lemas&lt;br /&gt;
  auxiliares (que se demuestran automáticamente) y usar ejercicios&lt;br /&gt;
  anteriores. &lt;br /&gt;
&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1. Definir el tipo de datos arbol para representar los&lt;br /&gt;
  árboles binarios que no tienen información ni en los nodos y ni en las&lt;br /&gt;
  hojas. Por ejemplo, el árbol&lt;br /&gt;
          ·&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       ·     ·&lt;br /&gt;
      / \   / \&lt;br /&gt;
     ·   · ·   · &lt;br /&gt;
  se representa por &amp;quot;N (N H H) (N H H)&amp;quot;.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
datatype arbol = H | N arbol arbol&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;N (N H H) (N H H) = (N (N H H) (N H H) :: arbol)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función&lt;br /&gt;
     hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; &lt;br /&gt;
  tal que (hojas a) es el número de hojas del árbol a. Por ejemplo,&lt;br /&gt;
     hojas (N (N H H) (N H H)) = 4&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
fun hojas :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
  &amp;quot;hojas H = Suc 0&amp;quot;&lt;br /&gt;
| &amp;quot;hojas (N a b) = hojas a + hojas b&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;hojas (N (N H H) (N H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 anaprarod paupeddeg migtermor wilmorort*)&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 *)&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 *)&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;
&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 *)&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;
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 *)&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 *)&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 *)&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 *)&lt;br /&gt;
lemma AUX7: &amp;quot;es_abc profundidad a ⟶ (hojas a = 2^(profundidad a))&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor anaprarod *)&lt;br /&gt;
(* También funciona con AUX7 *)&lt;br /&gt;
&lt;br /&gt;
lemma lej7: &amp;quot;es_abc profundidad a = es_abc hojas a&amp;quot;&lt;br /&gt;
by (induct a) (auto simp add: abc_prof_num_hojas)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar que un árbol binario a es completo respecto del&lt;br /&gt;
  número de hojas syss es completo respecto del número de nodos.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&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*)&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 *)&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;
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 *)&lt;br /&gt;
&lt;br /&gt;
lemma lej9:  &amp;quot;es_abc profundidad a = es_abc size a&amp;quot;&lt;br /&gt;
by (simp add: lej7 lej8)&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Demostrar que (abc n) es un árbol binario completo.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&lt;br /&gt;
(* con un demostrador más débil *)&lt;br /&gt;
lemma L10:  &amp;quot;es_abc f (abc a)&amp;quot;&lt;br /&gt;
by (induct a) simp_all&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Demostrar que si a es un árbolo binario completo&lt;br /&gt;
  respecto de la profundidad, entonces a es igual a&lt;br /&gt;
  (abc (profundidad a)).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy marpoldia1 migtermor *)&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 *)&lt;br /&gt;
lemma &amp;quot;es_abc profundidad a ⟶ (a = (abc (profundidad a)))&amp;quot;&lt;br /&gt;
by (induct a) auto&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text {*  &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Encontrar una medida f tal que (es_abc f) es distinto de &lt;br /&gt;
  (es_abc size).&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* migtermor *)&lt;br /&gt;
fun medida_nula :: &amp;quot;arbol =&amp;gt; nat&amp;quot; where&lt;br /&gt;
 &amp;quot;medida_nula H = 0&amp;quot;&lt;br /&gt;
| &amp;quot;medida_nula (N i d) = 0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;es_abc medida_nula a = es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
oops&lt;br /&gt;
(* Quickcheck encuentra el siguiente contraejemplo:&lt;br /&gt;
  a= N H (N H H) &lt;br /&gt;
  Tras evaluar:&lt;br /&gt;
  es_abc medida_nula a = True&lt;br /&gt;
  es_abc size a = False*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* anaprarod *)&lt;br /&gt;
lemma &amp;quot;es_abc f a =  es_abc size a&amp;quot;&lt;br /&gt;
quickcheck&lt;br /&gt;
(* Quickcheck found a counterexample:&lt;br /&gt;
  f = λx. a⇩1   &lt;br /&gt;
  a = N H (N H H)&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  es_abc f a = True&lt;br /&gt;
  es_abc size a = False *)&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=962</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=962"/>
		<updated>2016-12-04T23:00:04Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=961</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=961"/>
		<updated>2016-12-04T22:54:58Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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 *)&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 *) (*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 *)&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 *)&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 *) (*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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=960</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=960"/>
		<updated>2016-12-04T21:51:20Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *) (*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 *)&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 *)&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 *) (*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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=959</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=959"/>
		<updated>2016-12-04T21:14:05Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *) (*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 *)&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 *)&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 *) (*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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_6&amp;diff=958</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=958"/>
		<updated>2016-12-04T20:55:46Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *)&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 *) (*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 *)&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 *)&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 *) (*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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=707</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=707"/>
		<updated>2016-11-27T05:33:06Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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*)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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*)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
 &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;
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 *)&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;
&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;
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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=706</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=706"/>
		<updated>2016-11-27T05:32:02Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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*)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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*)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
 &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;
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 *)&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;
&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;
-- &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;
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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=705</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=705"/>
		<updated>2016-11-27T04:16:32Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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*)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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*)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
 &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;
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 *)&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;
&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;
-- &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;
oops&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=704</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=704"/>
		<updated>2016-11-27T04:15:47Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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*)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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*)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
 &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;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&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;
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 *)&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;
&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;
-- &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;
oops&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=703</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=703"/>
		<updated>2016-11-27T01:27:35Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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*)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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*)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
 &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;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&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 *)&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;
&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;
-- &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;
oops&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=702</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=702"/>
		<updated>2016-11-27T01:22:22Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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*)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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*)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
 &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;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&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 *)&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;
&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;
-- &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;
oops&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=701</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=701"/>
		<updated>2016-11-26T22:20:32Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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*)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
 &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;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&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 *)&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;
&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;
-- &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;
oops&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=700</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=700"/>
		<updated>2016-11-26T22:10:45Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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*)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
(*&lt;br /&gt;
Si a  = a1 &lt;br /&gt;
   xs = [a1,a1]&lt;br /&gt;
Luego&lt;br /&gt;
   estaEn a1 (borraDuplicados [a1,a1]) = esta a1 [a1] = True&lt;br /&gt;
   estaEn a1 [a1,a1] = True&lt;br /&gt;
Pero &lt;br /&gt;
   [a1,a1] ≠ [a1]&lt;br /&gt;
---- Por otro lado ---- &lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  xs = [a⇩1, a⇩1]&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  borraDuplicados xs = [a⇩1]&lt;br /&gt;
 *)&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;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
(*&lt;br /&gt;
Si a  = a1 &lt;br /&gt;
   xs = [a1,a1]&lt;br /&gt;
Luego&lt;br /&gt;
   estaEn a1 (borraDuplicados [a1,a1]) = esta a1 [a1] = True&lt;br /&gt;
   estaEn a1 [a1,a1] = True&lt;br /&gt;
Pero &lt;br /&gt;
   [a1,a1] ≠ [a1]&lt;br /&gt;
---- Por otro lado ---- &lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  xs = [a⇩1, a⇩1]&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  borraDuplicados xs = [a⇩1]&lt;br /&gt;
 *)&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 *)&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;
&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;
-- &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;
oops&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=699</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=699"/>
		<updated>2016-11-26T22:08:48Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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*)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
(*&lt;br /&gt;
Si a  = a1 &lt;br /&gt;
   xs = [a1,a1]&lt;br /&gt;
Luego&lt;br /&gt;
   estaEn a1 (borraDuplicados [a1,a1]) = esta a1 [a1] = True&lt;br /&gt;
   estaEn a1 [a1,a1] = True&lt;br /&gt;
Pero &lt;br /&gt;
   [a1,a1] ≠ [a1]&lt;br /&gt;
---- Por otro lado ---- &lt;br /&gt;
lemma  borrarDuplicados xs = xs &lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  borrarDuplicados = (λx. undefined)(a⇩1 := a⇩2, a⇩2 := a⇩1)&lt;br /&gt;
  xs = a⇩1&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  borrarDuplicados xs = a⇩2&lt;br /&gt;
 *)&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;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
(*&lt;br /&gt;
Si a  = a1 &lt;br /&gt;
   xs = [a1,a1]&lt;br /&gt;
Luego&lt;br /&gt;
   estaEn a1 (borraDuplicados [a1,a1]) = esta a1 [a1] = True&lt;br /&gt;
   estaEn a1 [a1,a1] = True&lt;br /&gt;
Pero &lt;br /&gt;
   [a1,a1] ≠ [a1]&lt;br /&gt;
---- Por otro lado ---- &lt;br /&gt;
lemma  borrarDuplicados xs = xs &lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  borrarDuplicados = (λx. undefined)(a⇩1 := a⇩2, a⇩2 := a⇩1)&lt;br /&gt;
  xs = a⇩1&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  borrarDuplicados xs = a⇩2&lt;br /&gt;
 *)&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 *)&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;
&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;
-- &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;
oops&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=698</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=698"/>
		<updated>2016-11-26T22:07:20Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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*)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
(*&lt;br /&gt;
Si a  = a1 &lt;br /&gt;
   xs = [a1,a1]&lt;br /&gt;
Luego&lt;br /&gt;
   estaEn a1 (borraDuplicados [a1,a1]) = esta a1 [a1] = True&lt;br /&gt;
   estaEn a1 [a1,a1] = True&lt;br /&gt;
Pero &lt;br /&gt;
   [a1,a1] ≠ [a1]&lt;br /&gt;
---- Por otro lado ---- &lt;br /&gt;
lemma  borrarDuplicados xs = xs &lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  borrarDuplicados = (λx. undefined)(a⇩1 := a⇩2, a⇩2 := a⇩1)&lt;br /&gt;
  xs = a⇩1&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  borrarDuplicados xs = a⇩2&lt;br /&gt;
 *)&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 *)&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;
&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;
-- &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;
oops&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=696</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=696"/>
		<updated>2016-11-26T21:56:07Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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 *)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
oops&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 *)&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;
&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;
-- &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;
oops&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=695</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=695"/>
		<updated>2016-11-26T21:54:07Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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 *)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(*wilmorort*)&lt;br /&gt;
(*Contra_Ejemplo*)&lt;br /&gt;
(*&lt;br /&gt;
Si a  = a1 &lt;br /&gt;
   xs = [a1,a1]&lt;br /&gt;
Luego&lt;br /&gt;
   estaEn a1 (borraDuplicados [a1,a1]) = esta a1 [a1] = True&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 *)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&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;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
oops&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 *)&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;
&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;
-- &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;
oops&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=693</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=693"/>
		<updated>2016-11-26T20:32:41Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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 *)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
oops&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 *)&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;
&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;
-- &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;
oops&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=692</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=692"/>
		<updated>2016-11-26T20:09:46Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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 *)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
oops&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 *)&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;
&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;
-- &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;
oops&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=691</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=691"/>
		<updated>2016-11-26T18:41:35Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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 *)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
oops&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 *)&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;
&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;
-- &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;
oops&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=690</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=690"/>
		<updated>2016-11-26T18:40:10Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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 *)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
oops&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 *)&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;
&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;
-- &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;
oops&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=689</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=689"/>
		<updated>2016-11-26T18:21:57Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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 *)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
oops&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 *)&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;
&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;
-- &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;
oops&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=688</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=688"/>
		<updated>2016-11-26T17:57:19Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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 *)&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;
&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 *)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
oops&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 *)&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;
&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;
-- &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;
oops&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_5&amp;diff=687</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=687"/>
		<updated>2016-11-26T17:37:28Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *)&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;
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 *)&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;
&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 *)&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) =( if estaEn x xs then borraDuplicados xs else x#borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;borraDuplicados [1::nat,2,4,2,3] = [1,4,2,3]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Utilizando la negación primero *)&lt;br /&gt;
&lt;br /&gt;
fun borraDuplicados :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;borraDuplicados [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;borraDuplicados (x#xs) = (if ¬(estaEn x xs) then (x#(borraDuplicados xs)) else borraDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
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*)&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 *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length ( borraDuplicados xs ) ≤ length xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
(* Demostrando objetivo a objetivo *)&lt;br /&gt;
lemma length_borraDuplicados:&lt;br /&gt;
  &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply simp &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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 *)&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;
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 *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
lemma estaEn_borraDuplicados: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
apply (induct xs) &lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
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;
lemma estaEn_borraDuplicados_2: &lt;br /&gt;
  &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
oops&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 *)&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;
&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;
-- &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;
oops&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=667</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=667"/>
		<updated>2016-11-24T22:10:12Z</updated>

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

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

		<summary type="html">&lt;p&gt;Wilmorort: &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*)&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*}&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*}&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 *}&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*}&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 *)&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 *)&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;
(* 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 *)&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;
&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;
&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=568</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=568"/>
		<updated>2016-11-22T14:22:21Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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*)&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*}&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*}&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 *}&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*}&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 *)&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 *)&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;
(* 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 *)&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;
&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;
&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 *)&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;
&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=557</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=557"/>
		<updated>2016-11-22T13:21:00Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *}&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 *}&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 *)&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 *}&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*}&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 *}&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 *)&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 *)&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 *)&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;
(* paupeddeg*)&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 *)&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;
&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;
&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 *)&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;
(* 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 *)&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;
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 *)&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=555</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=555"/>
		<updated>2016-11-22T13:10:16Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *}&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 *}&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 *)&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 *}&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*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg wilmorort *)&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 *)&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 *)&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 *)&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 *)&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;
(* paupeddeg*)&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;
&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 *)&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;
&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 *)&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;
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 *)&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;
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;
&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;
(* 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 *)&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;
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 *)&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=554</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=554"/>
		<updated>2016-11-22T13:01:17Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *}&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 *}&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 *)&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 *}&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*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg wilmorort *)&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 *)&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 *)&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 *)&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 *)&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;
(* paupeddeg*)&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;
&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 *)&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;
&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 *)&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;
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 *)&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*)&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;
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;
&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;
(* 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 *)&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;
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 *)&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=553</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=553"/>
		<updated>2016-11-22T12:55:53Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *}&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 *}&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 *)&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 *}&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*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg wilmorort *)&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 *)&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 *)&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 *)&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 *)&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;
(* paupeddeg*)&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;
&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 *)&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;
&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 *)&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;
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 *)&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 *)&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*)&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;
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;
&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;
(* 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 *)&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;
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 *)&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=552</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=552"/>
		<updated>2016-11-22T12:42:51Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *}&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 *}&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 *)&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 *}&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*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg wilmorort *)&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 *)&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 *)&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 *)&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 *)&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;
(* paupeddeg*)&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;
&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 *)&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;
&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 *)&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;
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 *)&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;
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 *)&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*)&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;
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;
&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;
(* 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 *)&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;
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 *)&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=551</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=551"/>
		<updated>2016-11-22T12:41:09Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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 *}&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 *}&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 *)&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 *}&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*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg wilmorort *)&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 *)&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 *)&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 *)&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 *)&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;
(* paupeddeg*)&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;
&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 *)&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;
&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 *)&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;
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 *)&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;
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 *)&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*)&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;
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;
&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;
(* 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 *)&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;
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 *)&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 *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=532</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=532"/>
		<updated>2016-11-21T19:45:11Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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*}&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 *}&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 *)&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 *}&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*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg *)&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 *)&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;
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 *)&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 *)&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;
&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*)&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;
(* paupeddeg*)&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;
&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar o refutar:&lt;br /&gt;
    algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
(* migtermor ivamenjim ferrenseg paupeddeg crigomgom serrodcal wilmorort*)&lt;br /&gt;
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;
&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 *)&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;
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 *)&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;
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*)&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*)&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*)&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;
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;
&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;
(* 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 *)&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;
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*)&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 *)&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 *)&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;
(* ivamenjim *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=518</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=518"/>
		<updated>2016-11-21T02:34:34Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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*}&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*}&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 *)&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*}&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 *}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg *)&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 *)&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;
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 *)&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 *)&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;
&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 *)&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;
(* paupeddeg*)&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;
&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 *)&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;
&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 *)&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;
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;
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*)&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*)&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 *)&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*)&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 *)&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;
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;
&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;
(* 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 *)&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;
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 *)&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 *)&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 *)&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 *)&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;
(* ivamenjim *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=516</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=516"/>
		<updated>2016-11-21T01:54:34Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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*}&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*}&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 *)&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 *}&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 *}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg *)&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 *)&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;
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 *)&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 *)&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;
&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 *)&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;
(* paupeddeg*)&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;
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 *)&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;
&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 *)&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;
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;
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*)&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*)&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 *)&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*)&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 *)&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;
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;
&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;
(* 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 *)&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;
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 *)&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 *)&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 *)&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 *)&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;
(* ivamenjim *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=503</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=503"/>
		<updated>2016-11-20T22:01:33Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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*}&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*}&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 *)&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 *)&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 *}&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 *}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg *)&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 *)&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;
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 *)&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 *)&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;
&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 *)&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;
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 *)&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;
&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 *)&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;
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;
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*)&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*)&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 *)&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;
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*)&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 *)&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;
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;
&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;
(* 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;
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 *)&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 *)&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 *)&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 *)&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;
(* ivamenjim *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=502</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=502"/>
		<updated>2016-11-20T21:59:14Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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*}&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*}&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 *)&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 *)&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 *}&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*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim ferrenseg *)&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 *)&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;
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 *)&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 *)&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;
&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 *)&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;
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 *)&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;
&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 *)&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;
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;
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*)&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*)&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 *)&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;
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*)&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 *)&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;
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;
&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;
(* 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;
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 *)&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 *)&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 *)&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 *)&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;
(* ivamenjim *)&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>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=464</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=464"/>
		<updated>2016-11-20T15:41:15Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&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*}&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*}&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 *)&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 *)&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;
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*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&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 *)&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;
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 *)&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;
&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 *)&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;
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 *)&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;
&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 *)&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;
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;
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 *)&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;
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 *)&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 *)&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;
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 *)&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;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Encontrar un término no trivial Z tal que sea cierta la &lt;br /&gt;
  siguiente ecuación:&lt;br /&gt;
     algunos (λx. P x ∨ Q x) xs = Z&lt;br /&gt;
  y demostrar la equivalencia de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort*)&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;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.2. Demostrar o refutar datalladamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=463</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=463"/>
		<updated>2016-11-20T15:37:26Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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 *)&lt;br /&gt;
fun todos :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos p (x#xs) = (p x ∧ todos p xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función &lt;br /&gt;
     algunos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (algunos p xs) se verifica si algunos elementos de la lista &lt;br /&gt;
  xs cumplen la propiedad p. Por ejemplo, se verifica &lt;br /&gt;
     algunos (λx. 1&amp;lt;length x) [[2,1,4],[3]]&lt;br /&gt;
     ¬algunos (λx. 1&amp;lt;length x) [[],[3]]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  Nota: La función algunos es equivalente a la predefinida list_ex. &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
{*danrodcha ivamenjim migtermor dancorgar marpoldia1 ferrenseg*}&lt;br /&gt;
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*}&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 *)&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 *)&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;
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*}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&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 *)&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;
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 *)&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;
&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 *)&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;
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 *)&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;
&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 *)&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;
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;
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 *)&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;
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 *)&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 *)&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;
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 *)&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;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Encontrar un término no trivial Z tal que sea cierta la &lt;br /&gt;
  siguiente ecuación:&lt;br /&gt;
     algunos (λx. P x ∨ Q x) xs = Z&lt;br /&gt;
  y demostrar la equivalencia de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort*)&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;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.2. Demostrar o refutar datalladamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&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;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wilmorort</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_4&amp;diff=430</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=430"/>
		<updated>2016-11-19T02:35:08Z</updated>

		<summary type="html">&lt;p&gt;Wilmorort: &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*)&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*}&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*}&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 *)&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 *)&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;
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 *}&lt;br /&gt;
lemma &amp;quot;todos P (x @ y) = (todos P x ∧ todos P y)&amp;quot;&lt;br /&gt;
by (induct x) auto&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (x @ y) = (todos P x ∧ todos P y)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&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;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.1. Demostrar o refutar automáticamente &lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5.2. Demostrar o refutar detalladamente&lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar o refutar:&lt;br /&gt;
    algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∧ Q x) xs = (algunos P xs ∧ algunos Q xs)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7.2. Demostrar o refutar datalladamente&lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.1. Demostrar o refutar automáticamente &lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma algunos_append:&lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9.2. Demostrar o refutar detalladamente&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Encontrar un término no trivial Z tal que sea cierta la &lt;br /&gt;
  siguiente ecuación:&lt;br /&gt;
     algunos (λx. P x ∨ Q x) xs = Z&lt;br /&gt;
  y demostrar la equivalencia de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.1. Demostrar o refutar automáticamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11.2. Demostrar o refutar datalladamente&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
oops&lt;br /&gt;
     &lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Definir la funcion primitiva recursiva &lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn x xs = undefined&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {*&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Expresar la relación existente entre estaEn y algunos. &lt;br /&gt;
  Demostrar dicha relación de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
*}&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wilmorort</name></author>
		
	</entry>
</feed>