<?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=Juacabsou</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=Juacabsou"/>
	<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php/Especial:Contribuciones/Juacabsou"/>
	<updated>2026-07-17T20:25:26Z</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_2&amp;diff=1452</id>
		<title>Relación 2</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_2&amp;diff=1452"/>
		<updated>2017-02-12T12:36:48Z</updated>

		<summary type="html">&lt;p&gt;Juacabsou: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R2: Razonamiento sobre programas en Isabelle/HOL *}&lt;br /&gt;
&lt;br /&gt;
theory R2_Razonamiento_automatico_sobre_programas&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
declare [[names_short]]&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1.1. Definir la función&lt;br /&gt;
     sumaImpares :: nat ⇒ nat&lt;br /&gt;
  tal que (sumaImpares n) es la suma de los n primeros números&lt;br /&gt;
  impares. Por ejemplo,&lt;br /&gt;
     sumaImpares 5  =  25&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 *)&lt;br /&gt;
fun sumaImpares0 :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaImpares0 0 = 0&amp;quot;&lt;br /&gt;
| &amp;quot;sumaImpares0 n = (n mod 2)*n + sumaImpares(n-1)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sumaImpares0 5 = 25&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* Comentario: Debe de definirse usando como patrones los dos &lt;br /&gt;
   constructores de nat: 0 y Suc *)&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort*)&lt;br /&gt;
fun sumaImpares :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaImpares 0 = 0&amp;quot;&lt;br /&gt;
| &amp;quot;sumaImpares n = 2*(n-1) + 1 + sumaImpares (n-1)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sumaImpares 5 = 25&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
&lt;br /&gt;
(*Notar: Por la propiedad de Gauss se puede deducir que:&lt;br /&gt;
         la suma de los n números impares es igual a la suma de los &lt;br /&gt;
         n y n-1 números consecutivos*)   &lt;br /&gt;
fun suma :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;suma 0 = 0&amp;quot;&lt;br /&gt;
| &amp;quot;suma n = n + suma(n-1)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
fun sumaImpares1 :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaImpares1 0 = 0&amp;quot; &lt;br /&gt;
| &amp;quot;sumaImpares1 n = suma(n) + suma(n-1)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sumaImpares1 5 = 25&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* Comentario: La definición sumaImpares1 no es recursiva y, por tanto,&lt;br /&gt;
   no es apropiada para demostraciones por inducción. &lt;br /&gt;
   &lt;br /&gt;
   Comentario: La definición sumaImpares1 no es recursiva pero la&lt;br /&gt;
   demostración, está realizada por inducción, por lo tanto no se puede&lt;br /&gt;
   concluir que: &amp;quot;Si una def. no es recuriva no se puede demostrar por&lt;br /&gt;
   inducción&amp;quot; &lt;br /&gt;
   &lt;br /&gt;
   Comentario: Las definiciones no recursivas no generan esquemas de&lt;br /&gt;
   inducción.&lt;br /&gt;
 *) &lt;br /&gt;
&lt;br /&gt;
(* fraortmoy antsancab1 *)&lt;br /&gt;
fun sumaImpares2 :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaImpares2 0 = 0&amp;quot;&lt;br /&gt;
| &amp;quot;sumaImpares2 (Suc(n)) = ((Suc(n)*2)-1) + sumaImpares2 n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sumaImpares2 5 = 25&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* anaprarod danrodcha crigomgom migtermor pabrodmac juacabsou *)&lt;br /&gt;
fun sumaImpares3 :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaImpares3 0 = 0&amp;quot;&lt;br /&gt;
 |&amp;quot;sumaImpares3 (Suc n) = (2*n +1) + (sumaImpares3 n)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sumaImpares3 5 = 25&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
fun sumaImpares4 :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaImpares4 0 = 0&amp;quot;&lt;br /&gt;
| &amp;quot;sumaImpares4 (Suc n) = (Suc (2 * n)) + (sumaImpares4 n)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sumaImpares4 5 = 25&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* pablucoto serrodcal marcarmor13 rubgonmar marpoldia1 jeamacpov*)&lt;br /&gt;
fun sumaImpares5 :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaImpares5 0 = 0&amp;quot;&lt;br /&gt;
| &amp;quot;sumaImpares5 n = (2*n-1) + sumaImpares5 (n-1) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sumaImpares5 5 = 25&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg paupeddeg josgarsan dancorgar *)&lt;br /&gt;
&lt;br /&gt;
fun sumaImpares6 :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaImpares6 0 = 0&amp;quot;&lt;br /&gt;
| &amp;quot;sumaImpares6 (Suc n) = (2 * (Suc n) - 1) + sumaImpares6 n&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
value &amp;quot;sumaImpares6 5 = 25&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1.2. Demostrar que &lt;br /&gt;
     sumaImpares n = n*n&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort anaprarod crigomgom manmorjim1 pablucoto&lt;br /&gt;
   serrodcal marcarmor13 rubgonmar pabrodmac marpoldia1 josgarsan&lt;br /&gt;
   jeamacpov dancorgar antsancab1 fracorjim1 juacabsou *)  &lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
apply (induct n)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
(* Demostración estructurada *)&lt;br /&gt;
&lt;br /&gt;
lemma aux1 : &amp;quot;suma(Suc n) + suma(n) = (n+1) + suma(n) + n + suma(n-1)&amp;quot;&lt;br /&gt;
apply (induct n)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
lemma aux2: &amp;quot;(n+1) + suma(n) + n + suma(n-1) = (n+1) + n + sumaImpares1 n &amp;quot;&lt;br /&gt;
apply (induct n)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;sumaImpares1 n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
show &amp;quot;sumaImpares1 0 = 0*0&amp;quot; by simp&lt;br /&gt;
next &lt;br /&gt;
 fix n&lt;br /&gt;
 assume HI:&amp;quot;sumaImpares1 n = n*n&amp;quot;&lt;br /&gt;
 have &amp;quot;sumaImpares1 (Suc n) = suma(Suc n) + suma(n)&amp;quot; by simp&lt;br /&gt;
 have &amp;quot;suma(Suc n) + suma(n) = (n+1) + suma(n) + n + suma(n-1)&amp;quot;  using&lt;br /&gt;
 &amp;quot;aux1&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;... = (n+1) + n + sumaImpares1 n &amp;quot; using &amp;quot;aux2&amp;quot; by simp&lt;br /&gt;
 also have &amp;quot;... = 2*n +1 + n*n&amp;quot; using HI by simp&lt;br /&gt;
 also have &amp;quot;... = (n+1)*(n+1)&amp;quot; by simp&lt;br /&gt;
 finally show &amp;quot;sumaImpares1 (Suc n) = Suc n * Suc n&amp;quot; by simp&lt;br /&gt;
 qed&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
(* La demostración para la función sumaImpares2 es la misma que la de&lt;br /&gt;
   sumaImpares*) &lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;sumaImpares2 n = n*n&amp;quot;&lt;br /&gt;
apply (induct n)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha migtermor paupeddeg *)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
by (induct n) auto&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot; (is &amp;quot;?P n&amp;quot;)&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;?P 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n assume &amp;quot;?P n&amp;quot;&lt;br /&gt;
  thus &amp;quot;?P (Suc n)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
lemma &amp;quot;sumaImpares3 n = n*n&amp;quot;&lt;br /&gt;
by (induct n) simp_all&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2.1. Definir la función&lt;br /&gt;
     sumaPotenciasDeDosMasUno :: nat ⇒ nat&lt;br /&gt;
  tal que &lt;br /&gt;
     (sumaPotenciasDeDosMasUno n) = 1 + 2^0 + 2^1 + 2^2 + ... + 2^n. &lt;br /&gt;
  Por ejemplo, &lt;br /&gt;
     sumaPotenciasDeDosMasUno 3  =  16&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* wilmorort ivamenjim pablucoto serrodcal ferrenseg rubgonmar &lt;br /&gt;
   pabrodmac *)&lt;br /&gt;
fun sumaPotenciasDeDosMasUno :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaPotenciasDeDosMasUno 0 = 2&amp;quot;&lt;br /&gt;
| &amp;quot;sumaPotenciasDeDosMasUno n = 2^n + sumaPotenciasDeDosMasUno (n-1)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sumaPotenciasDeDosMasUno 3 = 16&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy anaprarod danrodcha crigomgom migtermor manmorjim1&lt;br /&gt;
   fracorjim1 paupeddeg josgarsan dancorgar antsancab1 juacabsou *) &lt;br /&gt;
fun sumaPotenciasDeDosMasUno2 :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaPotenciasDeDosMasUno2 0 = 2&amp;quot;&lt;br /&gt;
| &amp;quot;sumaPotenciasDeDosMasUno2 (Suc(n)) = &lt;br /&gt;
    (2^(Suc n)) + sumaPotenciasDeDosMasUno2 n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sumaPotenciasDeDosMasUno2 3 = 16&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* marcarmor13 jeamacpov *)&lt;br /&gt;
fun sumaPotenciasDeDosMasUno3 :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sumaPotenciasDeDosMasUno3 0 = 2&amp;quot;&lt;br /&gt;
| &amp;quot;sumaPotenciasDeDosMasUno3 n = 2*sumaPotenciasDeDosMasUno3 (n-1)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sumaPotenciasDeDosMasUno3 3 = 16&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2.2. Demostrar que &lt;br /&gt;
     sumaPotenciasDeDosMasUno n = 2^(n+1)&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* wilmorort ivamenjim fraortmoy anaprarod crigomgom pablucoto serrodcal&lt;br /&gt;
   manmorjim1 marcarmor13 rubgonmar pabrodmac josgarsan jeamacpov&lt;br /&gt;
   dancorgar antsancab1 juacabsou *)  &lt;br /&gt;
(* esta demostración funciona con sumaPotenciasDeDosMasUno2 *)&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
apply (induct n)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha migtermor ferrenseg fracorjim1 paupeddeg *)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
by (induct n) auto&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot; (is &amp;quot;?P n&amp;quot;)&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;?P 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n assume &amp;quot;?P n&amp;quot;&lt;br /&gt;
  thus &amp;quot;?P (Suc n)&amp;quot;by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.1. Definir la función&lt;br /&gt;
     copia :: nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (copia n x) es la lista formado por n copias del elemento&lt;br /&gt;
  x. Por ejemplo, &lt;br /&gt;
     copia 3 x = [x,x,x]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim wilmorort pablucoto rubgonmar marcarmor13 jeamacpov *)&lt;br /&gt;
fun copia :: &amp;quot;nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;copia 0 x = [] &amp;quot; &lt;br /&gt;
| &amp;quot;copia n x = x # (copia (n-1) x)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort anaprarod *)&lt;br /&gt;
fun copia1 :: &amp;quot;nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;copia1 0 x = []&amp;quot; &lt;br /&gt;
| &amp;quot;copia1 (Suc n) x = [x] @ (copia1 n x) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* Comentario: La dedinición copia1 se puede simplificar eliminando @ *)&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom migtermor manmorjim1 fracorjim1 pabrodmac&lt;br /&gt;
   paupeddeg josgarsan dancorgar antsancab1 juacabsou *) &lt;br /&gt;
fun copia2 :: &amp;quot;nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;copia2 0 x = []&amp;quot;&lt;br /&gt;
| &amp;quot;copia2 (Suc n) x = x # copia2 n x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* serrodcal ferrenseg *)&lt;br /&gt;
fun copia3 :: &amp;quot;nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;copia3 0 x = []&amp;quot; &lt;br /&gt;
| &amp;quot;copia3 n x = [x] @ copia3 (n-1) x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;copia 3 x = [x,x,x]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* Comentario: La definición copia3 se puede simplificar eliminando @ *)&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.2. Definir la función&lt;br /&gt;
     todos :: (&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (todos p xs) se verifica si todos los elementos de xs cumplen&lt;br /&gt;
  la propiedad p. Por ejemplo,&lt;br /&gt;
     todos (λx. x&amp;gt;(1::nat)) [2,6,4] = True&lt;br /&gt;
     todos (λx. x&amp;gt;(2::nat)) [2,6,4] = False&lt;br /&gt;
  Nota: La conjunción se representa por ∧&lt;br /&gt;
  ----------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* 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 = True ∧ todos p xs) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* Comentario: La definición todos se puede simplificar eliminando True&lt;br /&gt;
*) &lt;br /&gt;
&lt;br /&gt;
value &amp;quot;todos (λx. x&amp;gt;(1::nat)) [2,6,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;todos (λx. x&amp;gt;(2::nat)) [2,6,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy anaprarod danrodcha crigomgom migtermor ivamenjim serrodcal&lt;br /&gt;
   pablucoto ferrenseg rubgonmar pabrodmac paupeddeg marcarmor13&lt;br /&gt;
   jeamacpov dancorgar josgarsan antsancab1 fracorjim1 juacabsou *) &lt;br /&gt;
fun todos1 :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos1 p []     = True&amp;quot;&lt;br /&gt;
| &amp;quot;todos1 p (x#xs) = (p x ∧ todos1 p xs )&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;todos1 (λx. x&amp;gt;(1::nat)) [2,6,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;todos1 (λx. x&amp;gt;(2::nat)) [2,6,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
fun todos2 :: &amp;quot;(&amp;#039;a ⇒ bool) ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;todos2 p xs = ((filter p xs) = xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;todos2 (λx. x&amp;gt;(1::nat)) [2,6,4] = True&amp;quot;&lt;br /&gt;
value &amp;quot;todos2 (λx. x&amp;gt;(2::nat)) [2,6,4] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3.3. Demostrar que todos los elementos de (copia n x) son&lt;br /&gt;
  iguales a x. &lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* wilmorort fraortmoy anaprarod crigomgom ivamenjim serrodcal&lt;br /&gt;
   manmorjim1 pablucoto rubgonmar pabrodmac marcarmor13 dancorgar&lt;br /&gt;
   josgarsan antsancab1 juacabsou *)  &lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
apply (induct n)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha ferrenseg paupeddeg jeamacpov *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
by (induct n) auto&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot; (is &amp;quot;?P n&amp;quot;)&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  show &amp;quot;?P 0&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n assume &amp;quot;?P n&amp;quot;&lt;br /&gt;
  thus &amp;quot;?P (Suc n)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 *)&lt;br /&gt;
lemma &amp;quot;todos (λy. y = x)(copia n x) = True&amp;quot;&lt;br /&gt;
apply (induct n)&lt;br /&gt;
apply auto&lt;br /&gt;
done &lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.1. Definir, recursivamente y sin usar (@), la función&lt;br /&gt;
     amplia :: &amp;#039;a list ⇒ &amp;#039;a ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (amplia xs y) es la lista obtenida añadiendo el elemento y al&lt;br /&gt;
  final de la lista xs. Por ejemplo,&lt;br /&gt;
     amplia [d,a] t = [d,a,t]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* wilmorort fraortmoy anaprarod crigomgom migtermor ivamenjim serrodcal&lt;br /&gt;
   manmorjim1 pablucoto ferrenseg rubgonmar pabrodmac paupeddeg&lt;br /&gt;
   marcarmor13 jeamacpov dancorgar josgarsan antsancab1 fracorjim1 juacabsou *)  &lt;br /&gt;
fun amplia :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
   &amp;quot;amplia [] y     = [y] &amp;quot;&lt;br /&gt;
|  &amp;quot;amplia (x#xs) y = x # amplia xs y&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;amplia [d,a] t = [d,a,t]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4.2. Demostrar que &lt;br /&gt;
     amplia xs y = xs @ [y]&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* wilmorort fraortmoy anaprarod crigomgom ivamenjim serrodcal&lt;br /&gt;
   manmorjim1 pablucoto rubgonmar pabrodmac marcarmor13 jeamacpov&lt;br /&gt;
   dancorgar josgarsan antsancab1 fracorjim1 juacabsou *) &lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
apply (induct xs)&lt;br /&gt;
apply auto&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
(* danrodcha migtermor ferrenseg paupeddeg *)&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot; (is &amp;quot;?P xs&amp;quot;)&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;?P []&amp;quot; by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs assume &amp;quot;?P xs&amp;quot;&lt;br /&gt;
  thus &amp;quot;?P (a#xs)&amp;quot; by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Juacabsou</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_1&amp;diff=1451</id>
		<title>Relación 1</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_1&amp;diff=1451"/>
		<updated>2017-02-12T12:33:57Z</updated>

		<summary type="html">&lt;p&gt;Juacabsou: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;isar&amp;quot;&amp;gt;&lt;br /&gt;
chapter {* R1: Programación funcional en Isabelle *}&lt;br /&gt;
&lt;br /&gt;
theory R1&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text {* ----------------------------------------------------------------&lt;br /&gt;
  Ejercicio 0. Definir, por recursión, la función&lt;br /&gt;
     factorial :: nat ⇒ nat&lt;br /&gt;
  tal que (factorial n) es el factorial de n. Por ejemplo,&lt;br /&gt;
     factorial 4 = 24&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* danrodcha anaprarod ivamenjim serrodcal manmorjim1 fraortmoy&lt;br /&gt;
   dancorgar ferrenseg paupeddeg pabrodmac antsancab1 fracorjim1 juacabsou *)  &lt;br /&gt;
fun factorial :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;factorial 0 = 1&amp;quot;&lt;br /&gt;
| &amp;quot;factorial (Suc n) = (Suc n) * factorial n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;factorial 4 = 24&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort pablucoto marcarmor13 crigomgom rubgonmar jeamacpov&lt;br /&gt;
   marpoldia1*) &lt;br /&gt;
fun factorial1 :: &amp;quot;nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;factorial1 0  = 1 &amp;quot;&lt;br /&gt;
| &amp;quot;factorial1 n  = n * factorial1 (n-1)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;factorial1 4 = 24&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* ----------------------------------------------------------------&lt;br /&gt;
  Ejercicio 1. Definir, por recursión, la función&lt;br /&gt;
     longitud :: &amp;#039;a list ⇒ nat&lt;br /&gt;
  tal que (longitud xs) es la longitud de la listas xs. Por ejemplo,&lt;br /&gt;
     longitud [4,2,5] = 3&lt;br /&gt;
  ------------------------------------------------------------------- *}&lt;br /&gt;
&lt;br /&gt;
(* wilmorort *)&lt;br /&gt;
(* Para usar las lista en forma de [a,b,c] *)&lt;br /&gt;
translations&lt;br /&gt;
  &amp;quot;[x, xs]&amp;quot; == &amp;quot;x#[xs]&amp;quot;&lt;br /&gt;
  &amp;quot;[x]&amp;quot; == &amp;quot;x#[]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort serrodcal crigomgom rubgonmar anaprarod dancorgar ferrenseg&lt;br /&gt;
   paupeddeg pabrodmac antsancab1 juacabsou *) &lt;br /&gt;
fun longitud :: &amp;quot;&amp;#039;a  list  ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;longitud []       = 0&amp;quot; |&lt;br /&gt;
  &amp;quot;longitud (x # xs) = 1 + longitud xs &amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;longitud [4,2,5] = 3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
fun longitud2 :: &amp;quot;&amp;#039;a list ⇒ nat &amp;quot; where&lt;br /&gt;
  &amp;quot;longitud2 []  = 0&amp;quot;&lt;br /&gt;
| &amp;quot;longitud2 xs  = 1 + longitud2 (butlast xs) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;longitud2 [4,2,5] = 3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
fun longitud3 :: &amp;quot;&amp;#039;a list ⇒ nat &amp;quot; where&lt;br /&gt;
  &amp;quot;longitud3 xs = (if xs = [] &lt;br /&gt;
                   then 0 &lt;br /&gt;
                   else 1 + longitud3 (butlast xs))&amp;quot;  &lt;br /&gt;
&lt;br /&gt;
value &amp;quot;longitud3 [4,2,5] = 3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* marcarmor13 manmorjim1 jeamacpov marpoldia1 fraortmoy *)&lt;br /&gt;
fun longitud4 :: &amp;quot;&amp;#039;a list ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;longitud4 []  = 0 &amp;quot;&lt;br /&gt;
| &amp;quot;longitud4  xs = (1 + longitud4 (tl xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;longitud4 [4,2,5] = 3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fracorjim1 *)&lt;br /&gt;
fun longitud5 :: &amp;quot;&amp;#039;a list ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;longitud5 []     = 0&amp;quot;&lt;br /&gt;
| &amp;quot;longitud5 (x#xs) = Suc (longitud5 xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;longitud5 [4,2,5] = 3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* serrodcal *)&lt;br /&gt;
fun longitud6 :: &amp;quot;&amp;#039;a list ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;longitud xs = length xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;longitud6 [4,2,5] &amp;quot; -- &amp;quot;= 3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* Comentario: El objetivo es explicitar cómo está definida la función&lt;br /&gt;
   length *) &lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
fun longitud7 :: &amp;quot;&amp;#039;a list ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;longitud7 [] = 0&amp;quot;  &lt;br /&gt;
| &amp;quot;longitud7 xs = longitud7 (drop 1 xs) + 1&amp;quot;&lt;br /&gt;
   &lt;br /&gt;
value &amp;quot;longitud7 [4,2,5] = 3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. Definir la función&lt;br /&gt;
     fun intercambia :: &amp;#039;a × &amp;#039;b ⇒ &amp;#039;b × &amp;#039;a&lt;br /&gt;
  tal que (intercambia p) es el par obtenido intercambiando las&lt;br /&gt;
  componentes del par p. Por ejemplo,&lt;br /&gt;
     intercambia (u,v) = (v,u)&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* wilmorort marcarmor13 danrodcha crigomgom pablucoto rubgonmar&lt;br /&gt;
   manmorjim1 serrodcal fraortmoy anaprarod dancorgar ferrenseg&lt;br /&gt;
   paupeddeg pabrodmac antsancab1 fracorjim1 juacabsou*) &lt;br /&gt;
fun intercambia :: &amp;quot;&amp;#039;a × &amp;#039;b ⇒ &amp;#039;b × &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;intercambia (x,y) = (y,x)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;intercambia (u,v) = (v,u)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* jeamacpov ivamenjim marpoldia1*)&lt;br /&gt;
fun intercambia2 :: &amp;quot;&amp;#039;a × &amp;#039;b ⇒ &amp;#039;b × &amp;#039;a&amp;quot; where&lt;br /&gt;
  &amp;quot;intercambia2 (x,y) = (snd (x,y), fst (x,y))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;intercambia2 (u,v) = (v,u)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir, por recursión, la función&lt;br /&gt;
     inversa :: &amp;#039;a list ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (inversa xs) es la lista obtenida invirtiendo el orden de los&lt;br /&gt;
  elementos de xs. Por ejemplo,&lt;br /&gt;
     inversa [a,d,c] = [c,d,a]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* wilmorort fraortmoy *)&lt;br /&gt;
(* @ :: &amp;quot;&amp;#039;a list =&amp;gt; &amp;#039;a list =&amp;gt; &amp;#039;a list&amp;quot;, función agregación definida&lt;br /&gt;
   en Theory Main, concatena dos listas: [a,b] @ [c,d] = [a,b,c,d] *)&lt;br /&gt;
fun inversa :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversa [] = []&amp;quot; |&lt;br /&gt;
  &amp;quot;inversa (x # xs) = (inversa xs) @ (x#[]) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inversa [a,d,c] = [c,d,a]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(*marcarmor13 manmorjim1*)&lt;br /&gt;
fun inversa1 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversa1 [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;inversa1 xs =  inversa1 (tl xs)@ ((hd xs)#[])&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inversa1 [a,d,c] = [c,d,a]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha pablucoto rubgonmar anaprarod dancorgar ferrenseg paupeddeg&lt;br /&gt;
   pabrodmac fracorjim1 *) &lt;br /&gt;
(* es igual que inversa sustituyendo x#[] por [x] *)&lt;br /&gt;
fun inversa2 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
   &amp;quot;inversa2 []     = []&amp;quot;&lt;br /&gt;
|  &amp;quot;inversa2 (x#xs) = (inversa2 xs) @ [x]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inversa2 [a,d,c] = [c,d,a]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha ivamenjim antsancab1 *)&lt;br /&gt;
fun inversa3 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
   &amp;quot;inversa3 []     = []&amp;quot;&lt;br /&gt;
|  &amp;quot;inversa3 (x#xs) = concat [(inversa3 xs),[x]] &amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inversa3 [a,d,c] = [c,d,a]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* crigomgom serrodcal marpoldia1 juacabsou *)&lt;br /&gt;
fun inversa4 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversa4 [] = []&amp;quot; |&lt;br /&gt;
  &amp;quot;inversa4 xs = (last xs) # (inversa4 (butlast xs)) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inversa4 [a,d,c] = [c,d,a]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* jeamacpov *)&lt;br /&gt;
fun inversa5 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversa5 [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;inversa5 xs = &lt;br /&gt;
    (drop (length(xs)-1) xs) @ inversa5 (take (length(xs)-1) xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inversa5 [a,d,c] = [c,d,a]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función&lt;br /&gt;
     repite :: nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (repite n x) es la lista formada por n copias del elemento&lt;br /&gt;
  x. Por ejemplo, &lt;br /&gt;
     repite 3 a = [a,a,a]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* wilmorort marcarmor13 crigomgom pablucoto rubgonmar manmorjim1&lt;br /&gt;
   jeamacpov ivamenjim marpoldia1 juacabsou *) &lt;br /&gt;
fun repite :: &amp;quot;nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;repite 0 x = [] &amp;quot; |&lt;br /&gt;
  &amp;quot;repite n x = x # (repite (n-1) x)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;repite 3 a = [a,a,a]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy dancorgar ferrenseg paupeddeg pabrodmac antsancab1 fracorjim1 *)&lt;br /&gt;
fun repite1 :: &amp;quot;nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;repite1 0 x       = []&amp;quot;&lt;br /&gt;
| &amp;quot;repite1 (Suc n) x = x # (repite1 n x)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;repite1 3 a = [a,a,a]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(*serrodcal anaprarod *)&lt;br /&gt;
fun repite2 :: &amp;quot;nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;repite2 0 x       = []&amp;quot;&lt;br /&gt;
| &amp;quot;repite2 (Suc n) x = [x] @ (repite2 n x)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;repite2 3 a = [a,a,a]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
fun repite3 :: &amp;quot;nat ⇒ &amp;#039;a ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;repite3 n x = replicate n x&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;repite3 3 a = [a,a,a]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* Comentario: uso de replicate *) &lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Definir la función&lt;br /&gt;
     conc :: &amp;#039;a list ⇒ &amp;#039;a list ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (conc xs ys) es la concatención de las listas xs e ys. Por&lt;br /&gt;
  ejemplo, &lt;br /&gt;
     conc [a,d] [b,d,a,c] = [a,d,b,d,a,c]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* marcarmor13 serrodcal *)&lt;br /&gt;
fun conc :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;conc xs ys = xs@ys&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;conc [a,d] [b,d,a,c] = [a,d,b,d,a,c]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* Comentario: El objetivo del ejercicio es explicitar la definición de&lt;br /&gt;
   @ *) &lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom rubgonmar paupeddeg *)&lt;br /&gt;
fun conc1 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;conc1 [] ys = ys&amp;quot;&lt;br /&gt;
| &amp;quot;conc1 xs [] = xs&amp;quot;       (* esta no hace falta *)&lt;br /&gt;
| &amp;quot;conc1 (x#xs) ys = x# (conc1 xs ys)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;conc1 [a,d] [b,d,a,c] = [a,d,b,d,a,c]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* pablucoto jeamacpov fraortmoy anaprarod ferrenseg pabrodmac antsancab1 fracorjim1 juacabsou *)&lt;br /&gt;
fun conc2 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;conc2 [] ys     = ys&amp;quot; |&lt;br /&gt;
  &amp;quot;conc2 (x#xs) ys = x # (conc2 xs ys)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;conc2 [a,d] [b,d,a,c] = [a,d,b,d,a,c]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* manmorjim1 *)&lt;br /&gt;
fun conc3 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;conc3 [] ys = ys&amp;quot;&lt;br /&gt;
| &amp;quot;conc3 xs ys = (hd xs)#[] @ (conc3 (tl xs) ys)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;conc3 [a,d] [b,d,a,c] = [a,d,b,d,a,c]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
fun conc4 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;conc4 xs ys = concat [xs,ys]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;conc4 [a,d] [b,d,a,c] = [a,d,b,d,a,c]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* Comentario: uso de concat *) &lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
fun conc5 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;conc5 [] [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;conc5 [] (y#ys) = y#(conc5 [] ys)&amp;quot;&lt;br /&gt;
| &amp;quot;conc5 (x#xs) ys = x#(conc5 xs ys)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;conc5 [a,d] [b,d,a,c] = [a,d,b,d,a,c]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* Comentario: La definición conc5 se puede simplificar. *)&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
fun conc6 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;conc6 [] [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;conc6 [] ys = ys&amp;quot;&lt;br /&gt;
| &amp;quot;conc6 xs ys = (hd xs)#(conc6 (tl xs) ys)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;conc6 [a,d] [b,d,a,c] = [a,d,b,d,a,c]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* Comentario: La 2ª ecuación de conc6 contiene a la primera. Además, se&lt;br /&gt;
  puede eliminar el uso de hd y tl. *)  &lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Definir la función&lt;br /&gt;
     coge :: nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (coge n xs) es la lista de los n primeros elementos de xs. Por &lt;br /&gt;
  ejemplo, &lt;br /&gt;
     coge 2 [a,c,d,b,e] = [a,c]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* marcarmor13 manmorjim1*)&lt;br /&gt;
fun coge :: &amp;quot;nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;coge 0 xs = []&amp;quot;&lt;br /&gt;
| &amp;quot;coge n xs = (hd xs)#(coge (n-1) (tl xs)) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;coge 2 [a,c,d,b,e] = [a,c]&amp;quot;&lt;br /&gt;
value &amp;quot;coge 2 [a,c,d,b,e] = [a,c]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha fraortmoy anaprarod ferrenseg paupeddeg pabrodmac juacabsou *)&lt;br /&gt;
fun coge1 :: &amp;quot;nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;coge1 0 _            = []&amp;quot;&lt;br /&gt;
| &amp;quot;coge1 _ []           = []&amp;quot;&lt;br /&gt;
| &amp;quot;coge1 (Suc n) (x#xs) = x#(coge1 n xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;coge1 2 [a,c,d,b,e] = [a,c]&amp;quot;&lt;br /&gt;
value &amp;quot;coge1 2 [a,c,d,b,e] = [a,c]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* crimgomgom jeamacpov rubgonmar ivamenjim *)&lt;br /&gt;
fun coge2 :: &amp;quot;nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;coge2 0 _      = []&amp;quot;|&lt;br /&gt;
  &amp;quot;coge2 _ []     = []&amp;quot; |&lt;br /&gt;
  &amp;quot;coge2 n (x#xs) = x#(coge2 (n-1) xs) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;coge2 2 [a,c,d,b,e] = [a,c]&amp;quot;&lt;br /&gt;
value &amp;quot;coge2 2 [a,c,d,b,e] = [a,c]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
fun coge3 :: &amp;quot;nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;coge3 0 xs = []&amp;quot; |&lt;br /&gt;
  &amp;quot;coge3 n (x#xs) = (if n &amp;gt; length (x#xs) &lt;br /&gt;
                     then (x#xs) &lt;br /&gt;
                     else x # (coge3 (n-1) xs))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
value &amp;quot;coge3 2 [a,c,d,b,e] = [a,c]&amp;quot;&lt;br /&gt;
value &amp;quot;coge3 3 [a,c] = [a,c]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* serrodcal *)&lt;br /&gt;
fun coge4 :: &amp;quot;nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;coge4 0 xs = []&amp;quot;&lt;br /&gt;
| &amp;quot;coge4 n xs = [(hd xs)]@(coge4 (n-1) (tl xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;coge4 2 [a,c,d,b,e] = [a,c]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
fun coge5 :: &amp;quot;nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;coge5 n xs = take n xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;coge5 2 [a,c,d,b,e] = [a,c]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* Comentario: uso de take *)&lt;br /&gt;
&lt;br /&gt;
(* dancorgar antsancab1 *)&lt;br /&gt;
fun coge6 :: &amp;quot;nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;coge6 0 xs = []&amp;quot;&lt;br /&gt;
| &amp;quot;coge6 (Suc m) [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;coge6 (Suc m) (x#xs) = (x#(coge6 m xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;coge6 2 [a,c,d,b,e] = [a,c]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* marpoldia1 *)&lt;br /&gt;
fun coge7 :: &amp;quot;nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;coge7 0 xs = []&amp;quot;|&lt;br /&gt;
  &amp;quot;coge7 n [] = []&amp;quot;| &lt;br /&gt;
  &amp;quot;coge7 n xs = (hd xs) # (coge7 (n-1) (tl xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;coge7 0 [a,b,c] = []&amp;quot;&lt;br /&gt;
value &amp;quot;coge7 2 [] = []&amp;quot;&lt;br /&gt;
value &amp;quot;coge7 2 [a,c,d,b,e] = [a,c]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 - Versión compacta, pero genera un esquema de inducción poco claro al no utilizar patrones *)&lt;br /&gt;
fun coge8 :: &amp;quot;nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;coge8 0 xs       = []&amp;quot;&lt;br /&gt;
| &amp;quot;coge8 (Suc n) xs = (hd xs)#(coge8 n (tl xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Definir la función&lt;br /&gt;
     elimina :: nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (elimina n xs) es la lista obtenida eliminando los n primeros&lt;br /&gt;
  elementos de xs. Por ejemplo, &lt;br /&gt;
     elimina 2 [a,c,d,b,e] = [d,b,e]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* marcarmor13 manmorjim1 serrodcal marpoldia1*)&lt;br /&gt;
fun elimina :: &amp;quot;nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;elimina 0 xs = xs&amp;quot;&lt;br /&gt;
| &amp;quot;elimina n xs = (elimina (n-1) (tl xs ))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom fraortmoy anaprarod paupeddeg pabrodmac juacabsou *)&lt;br /&gt;
fun elimina1 :: &amp;quot;nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;elimina1 0 xs           = xs&amp;quot;&lt;br /&gt;
| &amp;quot;elimina1 _ []           = []&amp;quot;&lt;br /&gt;
| &amp;quot;elimina1 (Suc n) (x#xs) = elimina1 n xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
fun elimina2 :: &amp;quot;nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;elimina2 0 xs     = xs&amp;quot; |&lt;br /&gt;
  &amp;quot;elimina2 n (x#xs) = (if n &amp;gt; length (x#xs) &lt;br /&gt;
                        then [] &lt;br /&gt;
                        else (elimina2 (n-1) xs))&amp;quot; &lt;br /&gt;
&lt;br /&gt;
(* jeamacpov ivamenjim *)&lt;br /&gt;
fun elimina3 :: &amp;quot;nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;elimina3 0 xs = xs&amp;quot;&lt;br /&gt;
| &amp;quot;elimina3 n xs =  (elimina3 (n-1) (drop 1 xs)) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar *)&lt;br /&gt;
fun elimina4 :: &amp;quot;nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
   &amp;quot;elimina4 0 xs = xs&amp;quot; |&lt;br /&gt;
   &amp;quot;elimina4 n xs = (if n &amp;gt; length(xs) &lt;br /&gt;
                     then [] &lt;br /&gt;
                     else (elimina4 (n-1) (tl xs)))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;elimina4 2 [a,c,d,b,e] = [d,b,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* dancorgar antsancab1 *)&lt;br /&gt;
fun elimina5 :: &amp;quot;nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;elimina5 0 xs = xs&amp;quot;&lt;br /&gt;
| &amp;quot;elimina5 (Suc m) [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;elimina5 (Suc m) (x#xs) = elimina5 m xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;elimina5 2 [a,c,d,b,e]= [d,b,e]&amp;quot; -- &amp;quot;= [d,b,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
&lt;br /&gt;
fun elimina6 :: &amp;quot;nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;elimina6 0 xs = xs&amp;quot;&lt;br /&gt;
  |&amp;quot;elimina6 n [] = []&amp;quot;&lt;br /&gt;
  |&amp;quot;elimina6 (Suc n) (x#xs) = elimina6 n xs&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
value &amp;quot;elimina6 2 [a,c,d,b,e]&amp;quot; -- &amp;quot;= [d,b,e]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* fracorjim1 - Versión compacta, pero genera un esquema de inducción poco claro al no utilizar patrones *)&lt;br /&gt;
fun elimina7 :: &amp;quot;nat ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
	&amp;quot;elimina7 0 xs = xs&amp;quot;&lt;br /&gt;
| &amp;quot;elimina7 (Suc n) xs = elimina7 n (tl xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Definir la función&lt;br /&gt;
     esVacia :: &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (esVacia xs) se verifica si xs es la lista vacía. Por ejemplo,&lt;br /&gt;
     esVacia []  = True&lt;br /&gt;
     esVacia [1] = False&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* marcarmor13 rubgonmar danrodcha crigomgom fraortmoy dancorgar&lt;br /&gt;
   paupeddeg *) &lt;br /&gt;
fun esVacia :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;esVacia [] = True &amp;quot;&lt;br /&gt;
| &amp;quot;esVacia xs = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha anaprarod*)&lt;br /&gt;
fun esVacia1 :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;esVacia1 xs = (xs = [])&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* pablucoto jeamacpov antsancab1 *)&lt;br /&gt;
fun esVacia2 :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;esVacia2 xs = (if xs = [] &lt;br /&gt;
                  then True &lt;br /&gt;
                  else False)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(*manmorjim1, serrodcal*)&lt;br /&gt;
fun esVacia3 :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;esVacia3 xs = (length xs = 0)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;esVacia3 []  = True&amp;quot;&lt;br /&gt;
value &amp;quot;esVacia3 [1] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim marpoldia1*)&lt;br /&gt;
fun esVacia4 :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;esVacia4 xs = (if length (xs) &amp;gt; 0 &lt;br /&gt;
                  then False &lt;br /&gt;
                  else True)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;esVacia4 [] = True&amp;quot;&lt;br /&gt;
value &amp;quot;esVacia4 [1] = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg fracorjim1 juacabsou *)&lt;br /&gt;
fun esVacia5 :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;esVacia5 [] = True&amp;quot;&lt;br /&gt;
 |&amp;quot;esVacia5 (x#xs) = False&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
value &amp;quot;esVacia5 []&amp;quot;  -- &amp;quot;= True&amp;quot;&lt;br /&gt;
value &amp;quot;esVacia5 [1]&amp;quot; -- &amp;quot;= False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac *)&lt;br /&gt;
fun esVacia6 :: &amp;quot;&amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;esVacia6 [] = True&amp;quot;&lt;br /&gt;
| &amp;quot;esVacia6 _ = False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;esVacia6 []= True&amp;quot;&lt;br /&gt;
value &amp;quot;esVacia6 [1]= False&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Definir la función&lt;br /&gt;
     inversaAc :: &amp;#039;a list ⇒ &amp;#039;a list&lt;br /&gt;
  tal que (inversaAc xs) es a inversa de xs calculada usando&lt;br /&gt;
  acumuladores. Por ejemplo, &lt;br /&gt;
     inversaAc [a,c,b,e] = [e,b,c,a]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar marcarmor13 mamnorjim1 serrodcal ivamenjim marpoldia1*)&lt;br /&gt;
fun inversaAcAux :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversaAcAux [] ys = ys&amp;quot;&lt;br /&gt;
| &amp;quot;inversaAcAux xs ys = inversaAcAux (tl xs) (hd xs#ys) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar danrodcha crigomgom manmorjim1 serrodcal ivamenjim&lt;br /&gt;
   anaprarod marpoldia1*) &lt;br /&gt;
fun inversaAc :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversaAc xs = inversaAcAux xs []&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inversaAc [a,c,b,e]= [e,b,c,a]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom anaprarod paupeddeg juacabsou *)&lt;br /&gt;
fun inversaAcAux1 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversaAcAux1 [] ys     = ys&amp;quot;&lt;br /&gt;
| &amp;quot;inversaAcAux1 (x#xs) ys = inversaAcAux1 xs (x#ys)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* pablucoto *)&lt;br /&gt;
fun inversaAcAux2 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversaAcAux2 [] []     = []&amp;quot;| &lt;br /&gt;
  &amp;quot;inversaAcAux2 xs (y#ys) = (inversaAcAux2 [] ys) @ [y]&amp;quot; &lt;br /&gt;
&lt;br /&gt;
fun inversaAc2 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversaAc2 xs = inversaAcAux2 [] xs &amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inversaAc2 [a,c,b,e]= [e,b,c,a]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* jeamacpov *)&lt;br /&gt;
fun inversaAcAux3 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversaAcAux3 ys [] = ys&amp;quot;&lt;br /&gt;
| &amp;quot;inversaAcAux3 ys (x#xs) = inversaAcAux3 (x#ys) xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
fun inversaAc3 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversaAc3 xs = inversaAcAux3 [] xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inversaAc3 [a,c,b,e]= [e,b,c,a]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* fraortmoy *)&lt;br /&gt;
fun inversaAcAux4 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversaAcAux4 xs [] = xs&amp;quot;&lt;br /&gt;
| &amp;quot;inversaAcAux4 xs (x#ys) = inversaAcAux4 (x#xs) ys&amp;quot;&lt;br /&gt;
&lt;br /&gt;
fun inversaAc4 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversaAc4 [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;inversaAc4 (x#xs)= (inversaAcAux4 [x] xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inversaAc4 [a,c,b,e]&amp;quot; -- &amp;quot;= [e,b,c,a]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
fun inversaAcAux5 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversaAcAux5 [] [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;inversaAcAux5 [] (y#ys) = y#(inversaAcAux5 [] ys)&amp;quot;&lt;br /&gt;
| &amp;quot;inversaAcAux5 (x#xs) ys = x#(inversaAcAux5 xs ys)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
fun inversaAc5 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversaAc5 [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;inversaAc5 (x#xs) = inversaAcAux5 (inversaAc5 xs) [x]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inversaAc5 [a,c,b,e] = [e,b,c,a]&amp;quot; -- &amp;quot;= [e,b,c,a]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ferrenseg *)&lt;br /&gt;
fun inversaAcAux6 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversaAcAux6 [] ys = ys&amp;quot;&lt;br /&gt;
 |&amp;quot;inversaAcAux6 (x#xs) ys = inversaAcAux6 xs (x#ys)&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
fun inversaAc6 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversaAc6 xs = inversaAcAux6 xs []&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
value &amp;quot;inversaAc6 [a,c,b,e]&amp;quot; -- &amp;quot;= [e,b,c,a]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* pabrodmac antsancab1 *)&lt;br /&gt;
fun inversaAcAux7 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
  &amp;quot;inversaAcAux7 [] ys = ys &amp;quot;&lt;br /&gt;
| &amp;quot;inversaAcAux7 (x#xs) ys =inversaAcAux7 xs (x#ys) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
fun inversaAc7 :: &amp;quot;&amp;#039;a list ⇒ &amp;#039;a list&amp;quot; where&lt;br /&gt;
    &amp;quot;inversaAc7 [] =[]&amp;quot;&lt;br /&gt;
|   &amp;quot;inversaAc7 (x#xs) = inversaAcAux7 xs [x]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;inversaAc7 [a,c,b,e]= [e,b,c,a]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Definir la función&lt;br /&gt;
     sum :: nat list ⇒ nat&lt;br /&gt;
  tal que (sum xs) es la suma de los elementos de xs. Por ejemplo,&lt;br /&gt;
     sum [3,2,5] = 10&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar marcarmor13 manmorjim1 serrodcal ivamenjim marpoldia1*)&lt;br /&gt;
fun sum :: &amp;quot;nat list ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sum [] = 0&amp;quot;&lt;br /&gt;
| &amp;quot;sum xs = hd xs + sum (tl xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sum [3,2,5] = 10&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha crigomgom pablucoto fraortmoy anaprarod ferrenseg paupeddeg&lt;br /&gt;
   pabrodmac antsancab1 fracorjim1 juacabsou *) &lt;br /&gt;
fun sum1 :: &amp;quot;nat list ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sum1 []     = 0&amp;quot;&lt;br /&gt;
| &amp;quot;sum1 (x#xs) = x + sum1 xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sum1 [3,2,5] = 10&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* danrodcha *)&lt;br /&gt;
fun sum2 :: &amp;quot;nat list ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sum2 xs = fold (op +) xs 0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sum2 [3,2,5] = 10&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* jeamacpov *)&lt;br /&gt;
fun sum3 :: &amp;quot;nat list ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sum3 [] = 0&amp;quot;&lt;br /&gt;
| &amp;quot;sum3 xs = (hd xs) + (sum3(drop 1 xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sum3 [3,2,5] = 10&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* ivamenjim *)&lt;br /&gt;
fun sum4 :: &amp;quot;nat list ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sum4 xs = listsum xs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;sum4 [3,2,5] = 10&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* Comentario: uso de listsum *)&lt;br /&gt;
&lt;br /&gt;
(* dancorgar *)&lt;br /&gt;
fun sum5 :: &amp;quot;nat list ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;sum5 [] = 0&amp;quot;&lt;br /&gt;
| &amp;quot;sum5 (x#[]) = x&amp;quot;&lt;br /&gt;
| &amp;quot;sum5 (x#(y#xs)) = sum5 ((x + y)#xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text {* --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. Definir la función&lt;br /&gt;
     map :: (&amp;#039;a ⇒ &amp;#039;b) ⇒ &amp;#039;a list ⇒ &amp;#039;b list&lt;br /&gt;
  tal que (map f xs) es la lista obtenida aplicando la función f a los&lt;br /&gt;
  elementos de xs. Por ejemplo,&lt;br /&gt;
     map (λx. 2*x) [3,2,5] = [6,4,10]&lt;br /&gt;
  ------------------------------------------------------------------ *}&lt;br /&gt;
&lt;br /&gt;
(* rubgonmar marcarmor13 manmorjim1 serrodcal ivamenjim marpoldia1*)&lt;br /&gt;
fun map :: &amp;quot;(&amp;#039;a ⇒ &amp;#039;b) ⇒ &amp;#039;a list ⇒ &amp;#039;b list&amp;quot; where&lt;br /&gt;
  &amp;quot;map f [] = []&amp;quot; &lt;br /&gt;
| &amp;quot;map f xs = f (hd xs) # map f (tl xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;map (λx. 2*x) [3::nat,2,5] = [6,4,10]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* wilmorort danrodcha crigomgom pablucoto fraortmoy anaprarod dancorgar&lt;br /&gt;
   ferrenseg paupeddeg pabrodmac antsancab1 fracorjim1 juacabsou *) &lt;br /&gt;
fun map2 :: &amp;quot;(&amp;#039;a ⇒ &amp;#039;b) ⇒ &amp;#039;a list ⇒ &amp;#039;b list&amp;quot; where&lt;br /&gt;
  &amp;quot;map2 f [] = []&amp;quot; &lt;br /&gt;
| &amp;quot;map2 f (x # xs) = f x # map2 f xs&amp;quot; (* yo pondría paréntesis, pero sin&lt;br /&gt;
                                         ellos lo entiende*)&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;map2 (λx. 2*x) [3::nat,2,5] = [6,4,10]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* jeamacpov *)&lt;br /&gt;
fun map3 :: &amp;quot;(&amp;#039;a ⇒ &amp;#039;b) ⇒ &amp;#039;a list ⇒ &amp;#039;b list&amp;quot; where&lt;br /&gt;
  &amp;quot;map3 f [] = []&amp;quot;&lt;br /&gt;
| &amp;quot;map3 f xs = f (hd xs) # (map3 f (drop 1 xs)) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;map3 (λx. 2*x) [3::nat,2,5] = [6,4,10]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Juacabsou</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_10&amp;diff=1433</id>
		<title>Relación 10</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_10&amp;diff=1433"/>
		<updated>2017-02-01T16:04:23Z</updated>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		<summary type="html">&lt;p&gt;Juacabsou: &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 *)&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 crigomgom*)&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 crigomgom*)&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>Juacabsou</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_3&amp;diff=373</id>
		<title>Relación 3</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/RA2016/index.php?title=Relaci%C3%B3n_3&amp;diff=373"/>
		<updated>2016-11-15T19:46:00Z</updated>

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

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