<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="es">
	<id>https://www.glc.us.es/~jalonso/LMF2020/index.php?action=history&amp;feed=atom&amp;title=Rel_10_%28sol%29</id>
	<title>Rel 10 (sol) - Historial de revisiones</title>
	<link rel="self" type="application/atom+xml" href="https://www.glc.us.es/~jalonso/LMF2020/index.php?action=history&amp;feed=atom&amp;title=Rel_10_%28sol%29"/>
	<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/LMF2020/index.php?title=Rel_10_(sol)&amp;action=history"/>
	<updated>2026-09-19T04:44:23Z</updated>
	<subtitle>Historial de revisiones para esta página en el wiki</subtitle>
	<generator>MediaWiki 1.31.14</generator>
	<entry>
		<id>https://www.glc.us.es/~jalonso/LMF2020/index.php?title=Rel_10_(sol)&amp;diff=1017&amp;oldid=prev</id>
		<title>Mjoseh: Protegió «Rel 10 (sol)» ([Editar=Solo administradores] (indefinido) [Trasladar=Solo administradores] (indefinido))</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/LMF2020/index.php?title=Rel_10_(sol)&amp;diff=1017&amp;oldid=prev"/>
		<updated>2020-05-05T06:46:46Z</updated>

		<summary type="html">&lt;p&gt;Protegió «&lt;a href=&quot;/~jalonso/LMF2020/index.php/Rel_10_(sol)&quot; title=&quot;Rel 10 (sol)&quot;&gt;Rel 10 (sol)&lt;/a&gt;» ([Editar=Solo administradores] (indefinido) [Trasladar=Solo administradores] (indefinido))&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;es&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Revisión anterior&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revisión del 06:46 5 may 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;es&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(Sin diferencias)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Mjoseh</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/LMF2020/index.php?title=Rel_10_(sol)&amp;diff=1016&amp;oldid=prev</id>
		<title>Mjoseh: Página creada con «&lt;source lang = &quot;isabelle&quot;&gt; chapter ‹ R10: Razonamiento sobre programas en Isabelle/HOL ›   theory R10_sol imports Main  begin   text ‹ -------------------------------…»</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/LMF2020/index.php?title=Rel_10_(sol)&amp;diff=1016&amp;oldid=prev"/>
		<updated>2020-05-05T06:46:33Z</updated>

		<summary type="html">&lt;p&gt;Página creada con «&amp;lt;source lang = &amp;quot;isabelle&amp;quot;&amp;gt; chapter ‹ R10: Razonamiento sobre programas en Isabelle/HOL ›   theory R10_sol imports Main  begin   text ‹ -------------------------------…»&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Página nueva&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;source lang = &amp;quot;isabelle&amp;quot;&amp;gt;&lt;br /&gt;
chapter ‹ R10: Razonamiento sobre programas en Isabelle/HOL ›&lt;br /&gt;
 &lt;br /&gt;
theory R10_sol&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text ‹ --------------------------------------------------------------- &lt;br /&gt;
   En toda la relación de ejercicios las demostraciones han de realizarse&lt;br /&gt;
   de las formas siguientes:&lt;br /&gt;
    (*) automática&lt;br /&gt;
    (*) detallada (bien declarativa o aplicativa)&lt;br /&gt;
  ------------------------------------------------------------------ ›&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;
value &amp;quot;sumaImpares 5&amp;quot;  ― ‹= 25›&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;
 ― ‹Demostración automática:›&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
  by (induct n) simp_all&lt;br /&gt;
&lt;br /&gt;
― ‹Demostración estructurada:›&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;
― ‹Demostración detallada declarativa:›&lt;br /&gt;
lemma &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  have &amp;quot;sumaImpares 0 = 0&amp;quot;&lt;br /&gt;
    by (simp only: sumaImpares.simps(1))&lt;br /&gt;
  also have &amp;quot;... = 0*0&amp;quot;&lt;br /&gt;
    by (simp only: mult_0)&lt;br /&gt;
  finally show &amp;quot;sumaImpares 0 = 0*0&amp;quot;&lt;br /&gt;
    by this&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;... = n*n+(2*n+1)&amp;quot;&lt;br /&gt;
    by (simp only: HI)&lt;br /&gt;
  also have &amp;quot;... = n*(n+1)+1*(n+1)&amp;quot;&lt;br /&gt;
    by (simp only: add_mult_distrib2)&lt;br /&gt;
  also have &amp;quot;... = (n+1)*(n+1)&amp;quot;&lt;br /&gt;
    by (simp only: add_mult_distrib)&lt;br /&gt;
  also have &amp;quot;... = (Suc n)*(Suc n)&amp;quot;&lt;br /&gt;
    by (simp only: Suc_eq_plus1)&lt;br /&gt;
  finally show &amp;quot;sumaImpares (Suc n) = (Suc n)*(Suc n)&amp;quot;&lt;br /&gt;
    by this&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada aplicativa:›&lt;br /&gt;
lemma sumaImpares_d:&lt;br /&gt;
  &amp;quot;sumaImpares n = n*n&amp;quot;&lt;br /&gt;
    apply (induct n) &lt;br /&gt;
    apply (simp only: sumaImpares.simps(1))&lt;br /&gt;
    apply (simp only: sumaImpares.simps(2)) &lt;br /&gt;
    apply (simp only:mult_Suc_right)&lt;br /&gt;
    apply (simp only:mult_Suc)&lt;br /&gt;
    done&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) = sumaPotenciasDeDosMasUno n + 2^(n+1)&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
value &amp;quot;sumaPotenciasDeDosMasUno 3&amp;quot; ― ‹= 16›&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;
 ― ‹Demostración automática:›&lt;br /&gt;
lemma  &lt;br /&gt;
  &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
  by (induct n) simp_all&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
― ‹Demostración estructurada:›&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) = &lt;br /&gt;
        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;&lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
― ‹Demostración detallada declarativa:›&lt;br /&gt;
lemma &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
proof (induct n)&lt;br /&gt;
  have &amp;quot;sumaPotenciasDeDosMasUno 0 = 2&amp;quot;&lt;br /&gt;
    by (simp only: sumaPotenciasDeDosMasUno.simps(1))&lt;br /&gt;
  also have &amp;quot;... = 2^1&amp;quot;&lt;br /&gt;
    by (simp only: monoid_mult_class.power_one_right)&lt;br /&gt;
  also have &amp;quot;... = 2^(0+1)&amp;quot;&lt;br /&gt;
    by (simp only: add_0)&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno 0 = 2^(0+1)&amp;quot;&lt;br /&gt;
    by this&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) =  &lt;br /&gt;
        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;&lt;br /&gt;
    by (simp only: HI)&lt;br /&gt;
  also have &amp;quot;... = 2^(n+1)*2&amp;quot;&lt;br /&gt;
    by (simp only: mult_2_right)&lt;br /&gt;
  also have &amp;quot;... = 2^(Suc(n+1))&amp;quot;&lt;br /&gt;
    by (simp only: power_Suc2)&lt;br /&gt;
  also have &amp;quot;... = 2^((Suc n)+1)&amp;quot;&lt;br /&gt;
    by (simp only: Suc_eq_plus1)&lt;br /&gt;
  finally show &amp;quot;sumaPotenciasDeDosMasUno (Suc n) = 2^((Suc n)+1)&amp;quot;&lt;br /&gt;
    by this&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada aplicativa:›&lt;br /&gt;
lemma sumaPotenciasDeDosMasUno_d: &lt;br /&gt;
  &amp;quot;sumaPotenciasDeDosMasUno n = 2^(n+1)&amp;quot;&lt;br /&gt;
  apply (induct n) &lt;br /&gt;
   apply (simp only: sumaPotenciasDeDosMasUno.simps(1))&lt;br /&gt;
   apply (simp only:plus_nat.add_0)&lt;br /&gt;
  apply (simp only: power_one_right) &lt;br /&gt;
  apply (simp only: sumaPotenciasDeDosMasUno.simps(2))&lt;br /&gt;
  apply (simp only:Suc_eq_plus1 )&lt;br /&gt;
  apply (simp only: power_add)&lt;br /&gt;
  apply (simp only: power_one_right) &lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
text ‹ --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. 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;
value &amp;quot;copia 3 x&amp;quot; ― ‹= [x,x,x]›&lt;br /&gt;
 &lt;br /&gt;
text ‹ --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. 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;
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;
value &amp;quot;todos (λx. x&amp;gt;(1::nat)) [2,6,4]&amp;quot; ― ‹= True›&lt;br /&gt;
value &amp;quot;todos (λx. x&amp;gt;(2::nat)) [2,6,4]&amp;quot; ― ‹= False›&lt;br /&gt;
 &lt;br /&gt;
text ‹ --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. 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;
 ― ‹Demostración automática:›&lt;br /&gt;
lemma &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
    by (induct n) simp_all  &lt;br /&gt;
&lt;br /&gt;
―‹Demostración estructurada:›&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;&lt;br /&gt;
    by simp&lt;br /&gt;
next&lt;br /&gt;
  fix n&lt;br /&gt;
  assume &amp;quot;todos (λy. y = x) (copia n x)&amp;quot;&lt;br /&gt;
  then show &amp;quot;todos (λy. y = x) (copia (Suc n) x)&amp;quot;&lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
― ‹Demostración detallada declarativa:›&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) []&amp;quot;&lt;br /&gt;
    by (simp only: todos.simps(1))&lt;br /&gt;
  then show &amp;quot;todos (λy. y=x) (copia 0 x)&amp;quot;&lt;br /&gt;
    by (simp only: copia.simps(1))&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;
  then have &amp;quot;todos (λy. y = x) (x # copia n x)&amp;quot;&lt;br /&gt;
    by (simp only: todos.simps(2))&lt;br /&gt;
  then show &amp;quot;todos (λy. y = x) (copia (Suc n) x)&amp;quot;&lt;br /&gt;
    by (simp only: copia.simps(2))&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada aplicativa:›&lt;br /&gt;
lemma todos_copia_d: &lt;br /&gt;
  &amp;quot;todos (λy. y=x) (copia n x)&amp;quot;&lt;br /&gt;
    apply (induct n)&lt;br /&gt;
   apply (simp only: copia.simps(1))&lt;br /&gt;
   apply (simp only:todos.simps(1))&lt;br /&gt;
  apply (simp only: copia.simps(2))&lt;br /&gt;
  apply (simp only:todos.simps(2))&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
text ‹ --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.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;
value &amp;quot;amplia [d,a] t&amp;quot; ― ‹= [d,a,t]›&lt;br /&gt;
 &lt;br /&gt;
text ‹ --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6.2, Demostrar que &lt;br /&gt;
     amplia xs y = xs @ [y]&lt;br /&gt;
  ------------------------------------------------------------------- ›&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración automática:›&lt;br /&gt;
lemma &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
    by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
― ‹Demostración estructurada:›&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;
― ‹Demostración detallada declarativa:›&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;&lt;br /&gt;
    by (simp only: amplia.simps(1))&lt;br /&gt;
  also have &amp;quot;... = [] @ [y]&amp;quot;&lt;br /&gt;
    by (simp only: append_Nil)&lt;br /&gt;
  finally show &amp;quot;amplia [] y = [] @ [y]&amp;quot;&lt;br /&gt;
    by this&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;&lt;br /&gt;
    by (simp only: amplia.simps(2))&lt;br /&gt;
  also have &amp;quot;... = x # (xs @ [y])&amp;quot;&lt;br /&gt;
    by (simp only: HI)&lt;br /&gt;
  also have &amp;quot;... = (x # xs) @ [y]&amp;quot;&lt;br /&gt;
    by (simp only: append_Cons)&lt;br /&gt;
  finally show &amp;quot;amplia (x#xs) y = (x # xs) @ [y]&amp;quot;&lt;br /&gt;
    by this&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada aplicativa:›&lt;br /&gt;
lemma amplia_append_d: &amp;quot;amplia xs y = xs @ [y]&amp;quot;&lt;br /&gt;
  apply (induct xs) &lt;br /&gt;
   apply (simp only: amplia.simps(1))&lt;br /&gt;
   apply (simp only: append.simps(1))&lt;br /&gt;
  apply (simp only: amplia.simps(2))&lt;br /&gt;
  apply (simp only: append.simps(2))&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
text ‹ &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. 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;
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;
&lt;br /&gt;
text ‹&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar o refutar&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;
 ― ‹Demostración automática:›&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;
&lt;br /&gt;
― ‹Demostración estructurada:›&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs &lt;br /&gt;
  assume &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  then show &amp;quot;todos (λx. P x ∧ Q x) (a#xs) = (todos P (a#xs) ∧ todos Q (a#xs))&amp;quot;&lt;br /&gt;
    by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
― ‹Demostración detallada declarativa:›&lt;br /&gt;
lemma &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  have &amp;quot;todos (λx. P x ∧ Q x) [] = True&amp;quot;&lt;br /&gt;
    by (simp only: todos.simps(1))&lt;br /&gt;
  also have &amp;quot;... = (True ∧ True)&amp;quot;&lt;br /&gt;
    by (simp only: conj_absorb)&lt;br /&gt;
  also have &amp;quot;... = (todos P [] ∧ todos Q [])&amp;quot;&lt;br /&gt;
    by (simp only: todos.simps(1))&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) [] = (todos P [] ∧ todos Q [])&amp;quot;&lt;br /&gt;
    by this&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) = ((λx. P x ∧ Q x) 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;... = ((λx. P x ∧ Q x) x ∧ (todos P xs ∧ todos Q xs))&amp;quot;&lt;br /&gt;
    by (simp only: HI)&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ Q x ∧ todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
    by (simp only: conj_assoc)&lt;br /&gt;
  also have &amp;quot;... = (P x ∧ todos P xs ∧ Q x ∧ todos Q xs)&amp;quot;&lt;br /&gt;
    by (simp only: conj_left_commute)&lt;br /&gt;
  also have &amp;quot;... = ((P x ∧ todos P xs) ∧ Q x ∧ todos Q xs)&amp;quot;&lt;br /&gt;
    by (simp only: conj_assoc)&lt;br /&gt;
  also have &amp;quot;... = (todos P (x#xs) ∧ Q x ∧ todos Q xs)&amp;quot;&lt;br /&gt;
    by (simp only: todos.simps(2))&lt;br /&gt;
  also have &amp;quot;... = (todos P (x#xs) ∧ todos Q (x#xs))&amp;quot;&lt;br /&gt;
    by (simp only: todos.simps(2))&lt;br /&gt;
  finally show &amp;quot;todos (λx. P x ∧ Q x) (x#xs) = &lt;br /&gt;
                (todos P (x#xs) ∧ todos Q (x#xs))&amp;quot;&lt;br /&gt;
    by this&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada aplicativa:›&lt;br /&gt;
lemma todos_conj_a: &lt;br /&gt;
  &amp;quot;todos (λx. P x ∧ Q x) xs = (todos P xs ∧ todos Q xs)&amp;quot;&lt;br /&gt;
  apply (induct xs) &lt;br /&gt;
  apply (simp only: todos.simps(1))&lt;br /&gt;
   apply  (simp only: conj_absorb)&lt;br /&gt;
  apply (simp only: todos.simps(2))&lt;br /&gt;
   apply  (simp only: conj_assoc)&lt;br /&gt;
  apply (simp only: conj_left_commute)&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text ‹&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 9. Demostrar o refutar&lt;br /&gt;
     todos P (xs @ ys) = (todos P xs ∧ todos P ys)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
›&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración automática:›&lt;br /&gt;
lemma &amp;quot;todos P (xs @ ys) = (todos P xs ∧ todos P ys)&amp;quot;&lt;br /&gt;
   by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración estructurada:›&lt;br /&gt;
lemma todos_append_e: &lt;br /&gt;
  &amp;quot;todos P (xs @ ys) = (todos P xs ∧ todos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;todos P ([] @ ys) = (todos P [] ∧ todos P ys)&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume &amp;quot;todos P (xs @ ys) = (todos P xs ∧ todos P ys)&amp;quot;&lt;br /&gt;
  then show &amp;quot;todos P ((a#xs) @ ys) = (todos P (a#xs) ∧ todos P ys)&amp;quot;&lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada declarativa:›&lt;br /&gt;
lemma todos_append_d: &lt;br /&gt;
  &amp;quot;todos P (xs @ ys) = (todos P xs ∧ todos P ys)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  have &amp;quot;todos P ([] @ ys) = todos P ys&amp;quot;&lt;br /&gt;
    by (simp only: append.simps(1))&lt;br /&gt;
  also have &amp;quot;... = (True ∧ todos P ys)&amp;quot;&lt;br /&gt;
    by (simp only: simp_thms(22))&lt;br /&gt;
  also have &amp;quot;... = (todos P [] ∧ todos P ys)&amp;quot;&lt;br /&gt;
    by (simp only: todos.simps(1))&lt;br /&gt;
  finally show &amp;quot;todos P ([] @ ys) = (todos P [] ∧ todos P ys)&amp;quot;&lt;br /&gt;
    by this&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI:&amp;quot;todos P (xs @ ys) = (todos P xs ∧ todos P ys)&amp;quot;&lt;br /&gt;
  have &amp;quot;todos P ((a#xs) @ ys) = (todos P (a#(xs @ ys)))&amp;quot;&lt;br /&gt;
    by (simp only: append.simps(2))&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P (xs @ ys))&amp;quot;&lt;br /&gt;
    by (simp only: todos.simps(2))&lt;br /&gt;
  also have &amp;quot;... = (P a ∧ todos P xs ∧ todos P ys)&amp;quot;&lt;br /&gt;
    by (simp only: HI)&lt;br /&gt;
  also have &amp;quot;... = ((P a ∧ todos P xs) ∧ todos P ys)&amp;quot;&lt;br /&gt;
    by (simp only: conj_assoc)&lt;br /&gt;
  also have &amp;quot;... = (todos P (a#xs) ∧ todos P ys)&amp;quot;&lt;br /&gt;
    by (simp only: todos.simps(2))&lt;br /&gt;
  finally show &amp;quot;todos P ((a#xs) @ ys) = (todos P (a#xs) ∧ todos P ys)&amp;quot;&lt;br /&gt;
    by this&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada aplicativa:›&lt;br /&gt;
lemma todos_append_a: &amp;quot;todos P (xs @ ys) = (todos P xs ∧ todos P ys)&amp;quot;&lt;br /&gt;
  apply (induct xs)&lt;br /&gt;
   apply (simp only: append.simps(1))&lt;br /&gt;
   apply (simp only: todos.simps(1))&lt;br /&gt;
   apply (simp only:  simp_thms(22))&lt;br /&gt;
    apply (simp only: append.simps(2))&lt;br /&gt;
  apply (simp only: todos.simps(2))&lt;br /&gt;
  apply (simp only: conj_assoc)&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
text ‹&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 10. Demostrar o refutar&lt;br /&gt;
     todos P (rev xs) = todos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
›&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración automática:›&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_d)&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración estructurada:›&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; &lt;br /&gt;
    by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  then show &amp;quot;todos P (rev (a#xs)) = todos P (a#xs)&amp;quot; &lt;br /&gt;
    by (auto simp add: todos_append_d)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada declarativa:›&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;&lt;br /&gt;
    by (simp only: rev.simps(1))&lt;br /&gt;
next&lt;br /&gt;
  fix x 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 (x#xs)) = todos P (rev xs@[x])&amp;quot;&lt;br /&gt;
    by (simp only: rev.simps(2))&lt;br /&gt;
  also have &amp;quot;... = (todos P (rev xs) ∧ todos P [x])&amp;quot;&lt;br /&gt;
    by (simp only: todos_append_d)&lt;br /&gt;
  also have &amp;quot;... = (todos P xs ∧ todos P [x])&amp;quot;&lt;br /&gt;
    by (simp only: HI)&lt;br /&gt;
  also have &amp;quot;... = (todos P [x] ∧ todos P xs)&amp;quot;&lt;br /&gt;
    by (simp only: conj_commute)&lt;br /&gt;
  also have &amp;quot;... = (todos P ([x]@xs))&amp;quot;&lt;br /&gt;
    by (simp only: todos_append_d)&lt;br /&gt;
  also have &amp;quot;... = (todos P (x#xs))&amp;quot;&lt;br /&gt;
    by (simp only: append.simps)&lt;br /&gt;
  finally show &amp;quot;todos P (rev (x#xs)) = todos P (x#xs)&amp;quot;&lt;br /&gt;
    by this&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada aplicativa:›&lt;br /&gt;
lemma todos_rev_d: &amp;quot;todos P (rev xs) = todos P xs&amp;quot;&lt;br /&gt;
  apply (induct xs)&lt;br /&gt;
   apply  (simp only: rev.simps(1))&lt;br /&gt;
  apply  (simp only: rev.simps(2))&lt;br /&gt;
  apply  (simp only: todos_append_d)&lt;br /&gt;
  apply (simp only: todos.simps(2))&lt;br /&gt;
  apply (simp only: todos.simps(1))&lt;br /&gt;
   apply (simp only: simp_thms(21))&lt;br /&gt;
  apply  (simp only: conj_commute)&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
text ‹&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 11. 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;
  quickcheck&lt;br /&gt;
  oops  &lt;br /&gt;
&lt;br /&gt;
text ‹&lt;br /&gt;
&lt;br /&gt;
Quickcheck found a counterexample:&lt;br /&gt;
  P = {a⇩1}&lt;br /&gt;
  Q = {a⇩2}&lt;br /&gt;
  xs = [a⇩1, a⇩2]&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  algunos (λx. P x ∧ Q x) xs = False&lt;br /&gt;
  algunos P xs ∧ algunos Q xs = True&lt;br /&gt;
›&lt;br /&gt;
&lt;br /&gt;
text ‹&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 12. Demostrar o refutar&lt;br /&gt;
     algunos P (map f xs) = algunos (P ∘ f) xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
›&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración automática:›&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;
 &lt;br /&gt;
 ― ‹Demostración estructurada:›&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; &lt;br /&gt;
    by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume &amp;quot;algunos P (map f xs) = algunos (P ∘ f) xs&amp;quot;&lt;br /&gt;
  then show &amp;quot;algunos P (map f (a#xs)) = algunos (P ∘ f) (a#xs)&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada declarativa:›&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;
  have &amp;quot;algunos P (map f []) = algunos P []&amp;quot;&lt;br /&gt;
    by (simp only: list.map(1))&lt;br /&gt;
  also have &amp;quot;... = algunos (P o f) []&amp;quot;&lt;br /&gt;
    by (simp only: algunos.simps(1))&lt;br /&gt;
  finally show &amp;quot;algunos P (map f []) = algunos (P o f) []&amp;quot;&lt;br /&gt;
    by this&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)) = algunos P ((f x) # (map f xs))&amp;quot;&lt;br /&gt;
    by (simp only: list.map(2))&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos P (map f xs))&amp;quot;&lt;br /&gt;
    by (simp only: algunos.simps(2))&lt;br /&gt;
  also have &amp;quot;... = (P (f x) ∨ algunos (P o f) xs)&amp;quot;&lt;br /&gt;
    by (simp only: HI)&lt;br /&gt;
  also have &amp;quot;... = ((P o f) x ∨ algunos (P o f) xs)&amp;quot;&lt;br /&gt;
    by (simp only: o_apply)&lt;br /&gt;
  also have &amp;quot;... = algunos (P o f) (x#xs)&amp;quot;&lt;br /&gt;
    by (simp only: algunos.simps(2))&lt;br /&gt;
  finally show &amp;quot;algunos P (map f (x#xs)) = algunos (P o f) (x#xs)&amp;quot;&lt;br /&gt;
    by this&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada aplicativa:›&lt;br /&gt;
lemma algunos_map_e: &amp;quot;algunos P (map f xs) = algunos (P o f) xs&amp;quot;&lt;br /&gt;
  apply (induct xs)&lt;br /&gt;
   apply (simp only: list.map(1))&lt;br /&gt;
   apply (simp only: algunos.simps(1))&lt;br /&gt;
    apply (simp only: list.map(2))&lt;br /&gt;
  apply (simp only: algunos.simps(2)) &lt;br /&gt;
  apply (rule iffI)&lt;br /&gt;
   apply (erule disjE)&lt;br /&gt;
  apply (rule disjI1)&lt;br /&gt;
    apply  (simp only: o_apply)&lt;br /&gt;
   apply (rule disjI2, assumption)&lt;br /&gt;
  apply (erule disjE)&lt;br /&gt;
  apply (rule disjI1)&lt;br /&gt;
   apply  (simp only: o_apply)&lt;br /&gt;
  apply (rule disjI2, assumption)&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
text ‹&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 13. Demostrar o refutar&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;
 ― ‹Demostración automática:›&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;
 &lt;br /&gt;
― ‹Demostración estructurada:›&lt;br /&gt;
lemma algunos_append_e: &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; &lt;br /&gt;
    by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  then show &amp;quot;algunos P ((a#xs) @ ys) = (algunos P (a#xs) ∨ algunos P ys)&amp;quot;&lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada declarativa:›&lt;br /&gt;
lemma algunos_append_d: &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;
  have &amp;quot;algunos P ([] @ ys) = (algunos P ys)&amp;quot;&lt;br /&gt;
    by (simp only: append_Nil)&lt;br /&gt;
  also have &amp;quot;... = (False ∨ algunos P ys)&amp;quot;&lt;br /&gt;
    by (simp only: simp_thms(32))&lt;br /&gt;
  also have &amp;quot;... = (algunos P [] ∨ algunos P ys)&amp;quot;&lt;br /&gt;
    by (simp only: algunos.simps(1))&lt;br /&gt;
  finally show &amp;quot;algunos P ([] @ ys) = (algunos P [] ∨ algunos P ys)&amp;quot;&lt;br /&gt;
    by this&lt;br /&gt;
next&lt;br /&gt;
  fix x 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 ((x#xs) @ ys) = algunos P (x#(xs @ ys))&amp;quot;&lt;br /&gt;
    by (simp only: append_Cons)&lt;br /&gt;
  also have &amp;quot;... = (P x ∨ algunos P (xs @ ys))&amp;quot;&lt;br /&gt;
    by (simp only: algunos.simps(2))&lt;br /&gt;
  also have &amp;quot;... = (P x ∨ algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
    by (simp only: HI)&lt;br /&gt;
  also have &amp;quot;... = ((P x ∨ algunos P xs) ∨ algunos P ys)&amp;quot;&lt;br /&gt;
    by (simp only: disj_assoc)&lt;br /&gt;
  also have &amp;quot;... = (algunos P (x#xs) ∨ algunos P ys)&amp;quot;&lt;br /&gt;
    by (simp only: algunos.simps(2))&lt;br /&gt;
  finally show &amp;quot;algunos P ((x#xs) @ ys) = &lt;br /&gt;
                (algunos P (x#xs) ∨ algunos P ys)&amp;quot;&lt;br /&gt;
    by this&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
― ‹Demostración detallada aplicativa:›&lt;br /&gt;
lemma algunos_append_a: &lt;br /&gt;
  &amp;quot;algunos P (xs @ ys) = (algunos P xs ∨ algunos P ys)&amp;quot;&lt;br /&gt;
  apply (induct xs)&lt;br /&gt;
   apply  (simp only: algunos.simps(1))&lt;br /&gt;
    apply  (simp only: append.simps(1))&lt;br /&gt;
   apply  (simp only: simp_thms(32))&lt;br /&gt;
  apply (simp only: append_Cons)&lt;br /&gt;
  apply  (simp only: algunos.simps(2))&lt;br /&gt;
  apply  (simp only: disj_assoc)&lt;br /&gt;
  done&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
text ‹&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 14. Demostrar o refutar&lt;br /&gt;
     algunos P (rev xs) = algunos P xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
›&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración automática:›&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_d)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración estructurada:›&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; &lt;br /&gt;
    by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  then show &amp;quot;algunos P (rev (a#xs)) = algunos P (a#xs)&amp;quot; &lt;br /&gt;
    by (auto simp add: algunos_append_d)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada declarativa:›&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;&lt;br /&gt;
    by (simp only: rev.simps(1))&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;&lt;br /&gt;
    by (simp only: rev.simps(2))&lt;br /&gt;
  also have &amp;quot;... = (algunos P (rev xs) ∨ algunos P [x])&amp;quot;&lt;br /&gt;
    by (simp only: algunos_append_d)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ algunos P [x])&amp;quot;&lt;br /&gt;
    by (simp only: HI)&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ P x ∨ algunos P [])&amp;quot;&lt;br /&gt;
    by (simp only: algunos.simps(2))&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ P x ∨ False)&amp;quot;&lt;br /&gt;
    by (simp only: algunos.simps(1))&lt;br /&gt;
  also have &amp;quot;... = (algunos P xs ∨ P x)&amp;quot;&lt;br /&gt;
    by (simp only: simp_thms(31))&lt;br /&gt;
  also have &amp;quot;... = (P x ∨ algunos P xs)&amp;quot;&lt;br /&gt;
    by (simp only: disj_commute)&lt;br /&gt;
  also have &amp;quot;... = algunos P (x#xs)&amp;quot;&lt;br /&gt;
    by (simp only: algunos.simps(2))&lt;br /&gt;
  finally show &amp;quot;algunos P (rev (x#xs)) = algunos P (x#xs)&amp;quot;&lt;br /&gt;
    by this&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada aplicativa:›&lt;br /&gt;
lemma algunos_rev_e: &lt;br /&gt;
  &amp;quot;algunos P (rev xs) = algunos P xs&amp;quot;&lt;br /&gt;
  apply (induct xs)&lt;br /&gt;
   apply (simp only: rev.simps(1))&lt;br /&gt;
  apply (simp only: rev.simps(2))   &lt;br /&gt;
  apply (simp only: algunos.simps(2))&lt;br /&gt;
  apply (simp only: algunos_append_d)&lt;br /&gt;
  apply (simp only: algunos.simps(2))&lt;br /&gt;
  apply (simp only: algunos.simps(1))&lt;br /&gt;
  apply (simp only: simp_thms(31))&lt;br /&gt;
  apply (simp only: disj_commute)&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text ‹&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 15. Encontrar un término no trivial Z tal que sea cierta la &lt;br /&gt;
  siguiente ecuación:&lt;br /&gt;
     algunos (λx. P x ∨ Q x) xs = Z&lt;br /&gt;
  y demostrar la equivalencia de forma automática y detallada.&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
›&lt;br /&gt;
&lt;br /&gt;
text ‹Solución: La ecuación se verifica eligiendo como Z el término  &lt;br /&gt;
     algunos P xs ∨ algunos Q xs&lt;br /&gt;
  En efecto,›&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración automatica:›&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;
&lt;br /&gt;
 ― ‹Demostración estructurada:›&lt;br /&gt;
lemma &amp;quot;algunos (λx. P x ∨ Q x) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
proof (induct xs)&lt;br /&gt;
  show &amp;quot;algunos  (λx. P x ∨ Q x) [] = (algunos P [] ∨ algunos Q [])&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume &amp;quot;algunos (λx. (P x ∨ Q x)) xs = (algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
  then show &amp;quot;algunos (λx. P x ∨ Q x) (a#xs) = &lt;br /&gt;
             (algunos P (a#xs) ∨ algunos Q (a#xs))&amp;quot;&lt;br /&gt;
    by auto&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada declarativa:›&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;
  have &amp;quot;algunos (λx. P x ∨ Q x) [] = False&amp;quot;&lt;br /&gt;
    by (simp only: algunos.simps(1))&lt;br /&gt;
  also have &amp;quot;... = (False ∨ False)&amp;quot;&lt;br /&gt;
    by (simp only: simp_thms(31))&lt;br /&gt;
  also have &amp;quot;... = (algunos P [] ∨ False)&amp;quot;&lt;br /&gt;
    by (simp only: algunos.simps(1))&lt;br /&gt;
  also have &amp;quot;... = (algunos P [] ∨ algunos Q [])&amp;quot;&lt;br /&gt;
    by (simp only: algunos.simps(1))&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) [] = &lt;br /&gt;
                (algunos P [] ∨ algunos Q [])&amp;quot;&lt;br /&gt;
    by this&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;
  have &amp;quot;algunos (λx. P x ∨ Q x) (x#xs) =((P x ∨ Q x) ∨ algunos (λx. P x ∨ Q x) xs)&amp;quot;&lt;br /&gt;
    by (simp only: algunos.simps(2))&lt;br /&gt;
  also have &amp;quot;... = ((P x ∨ Q x) ∨ algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
    by (simp only: HI)&lt;br /&gt;
  also have &amp;quot;... = (P x ∨ Q x ∨ algunos P xs ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
    by (simp only: disj_assoc)&lt;br /&gt;
  also have &amp;quot;... = (P x ∨ algunos P xs ∨ Q x ∨ algunos Q xs)&amp;quot;&lt;br /&gt;
    by (simp only: disj_left_commute)&lt;br /&gt;
  also have &amp;quot;... = ((P x ∨ algunos P xs) ∨ (Q x ∨ algunos Q xs))&amp;quot;&lt;br /&gt;
    by (simp only: disj_assoc)&lt;br /&gt;
  also have &amp;quot;... = (algunos P (x#xs) ∨ algunos Q (x#xs))&amp;quot;&lt;br /&gt;
    by (simp only: algunos.simps(2))&lt;br /&gt;
  finally show &amp;quot;algunos (λx. P x ∨ Q x) (x#xs) = &lt;br /&gt;
                (algunos P (x#xs) ∨ algunos Q (x#xs))&amp;quot;&lt;br /&gt;
    by this&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada aplicativa:›&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 (simp only: algunos.simps(1))&lt;br /&gt;
   apply  (simp only: simp_thms(31))&lt;br /&gt;
  apply (simp only: algunos.simps(2))&lt;br /&gt;
  apply (simp only: disj_assoc)&lt;br /&gt;
  apply (simp only: disj_comms)&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text ‹&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 16. Demostrar o refutar&lt;br /&gt;
     algunos P xs = (¬ todos (λx. (¬ P x)) xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
›&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración automática:›&lt;br /&gt;
lemma algunos_no_todos_d: &lt;br /&gt;
  &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;
&lt;br /&gt;
 ― ‹Demostración estructurada:›&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; &lt;br /&gt;
    by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  then show &amp;quot;algunos P (a#xs) = (¬ todos (λx. (¬ P x)) (a#xs))&amp;quot;&lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada declarativa:›&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; &lt;br /&gt;
    by (simp only: algunos.simps(1)&lt;br /&gt;
                   todos.simps(1)&lt;br /&gt;
                   not_True_eq_False)&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;
  show &amp;quot;algunos P (a#xs) = (¬ todos (λx. (¬ P x)) (a#xs))&amp;quot;&lt;br /&gt;
  proof - &lt;br /&gt;
    have &amp;quot;algunos P (a#xs) = ((P a) ∨ algunos P xs)&amp;quot; &lt;br /&gt;
      by  (simp only: algunos.simps(2))&lt;br /&gt;
    also have &amp;quot;… = ((P a) ∨ ¬ todos (λx. (¬ P x)) xs)&amp;quot; using HI &lt;br /&gt;
      by  (simp only: todos.simps(2))&lt;br /&gt;
    also have &amp;quot;… = (¬ (¬ (P a) ∧ todos (λx. (¬ P x)) xs))&amp;quot; &lt;br /&gt;
      by (simp only: de_Morgan_conj not_not)&lt;br /&gt;
    also have &amp;quot;… = (¬ todos (λx. (¬ P x)) (a#xs))&amp;quot; &lt;br /&gt;
      by (simp only: de_Morgan_conj todos.simps(2))&lt;br /&gt;
    finally show ?thesis by this&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada aplicativa:›&lt;br /&gt;
lemma algunos_no_todos_e: &lt;br /&gt;
  &amp;quot;algunos P xs = (¬ todos (λx. (¬ P x)) xs)&amp;quot;&lt;br /&gt;
  apply (induct xs)&lt;br /&gt;
   apply (simp only: algunos.simps(1))&lt;br /&gt;
   apply (simp only: todos.simps(1)) &lt;br /&gt;
   apply (simp only:not_True_eq_False)&lt;br /&gt;
   apply (simp only: algunos.simps(2))&lt;br /&gt;
  apply (simp only: todos.simps(2)) &lt;br /&gt;
  apply (simp only: de_Morgan_conj)&lt;br /&gt;
  apply (simp only: not_not)&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 text ‹&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17.1. Definir la función&lt;br /&gt;
     estaEn :: &amp;#039;a ⇒ &amp;#039;a list ⇒ bool&lt;br /&gt;
  tal que (estaEn x xs) se verifica si el elemento x está en la lista&lt;br /&gt;
  xs. Por ejemplo, &lt;br /&gt;
     estaEn (2::nat) [3,2,4] = True&lt;br /&gt;
     estaEn (1::nat) [3,2,4] = False&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
›&lt;br /&gt;
&lt;br /&gt;
fun estaEn :: &amp;quot;&amp;#039;a ⇒ &amp;#039;a list ⇒ bool&amp;quot; where&lt;br /&gt;
  &amp;quot;estaEn x []     = 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;
&lt;br /&gt;
text ‹&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 17.2. 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;
text ‹Solución: La relación es &lt;br /&gt;
     estaEn y xs = algunos (λx. x=y) xs&lt;br /&gt;
  En efecto,›&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración automática:›&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. y=x) xs&amp;quot;&lt;br /&gt;
  by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración estructurada:›&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. y=x) xs&amp;quot;&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
  show &amp;quot;estaEn x [] = algunos (λy. y=x) []&amp;quot;&lt;br /&gt;
    by simp&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (λy. y=x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a#xs) = algunos  (λy. y=x) (a#xs)&amp;quot;  &lt;br /&gt;
    using HI by simp&lt;br /&gt;
  then show &amp;quot;estaEn x (a#xs) = algunos (λy. y=x) (a#xs)&amp;quot; &lt;br /&gt;
    by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada declarativa:›&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. y=x) xs&amp;quot;&lt;br /&gt;
proof (induct xs) &lt;br /&gt;
  have &amp;quot;estaEn x [] = False&amp;quot;&lt;br /&gt;
    by (simp only: estaEn.simps(1))&lt;br /&gt;
  also have &amp;quot;... = algunos (λy. y=x) []&amp;quot;&lt;br /&gt;
    by (simp only: algunos.simps(1))&lt;br /&gt;
  finally show &amp;quot;estaEn x [] = algunos (λy. y=x) []&amp;quot;&lt;br /&gt;
    by this&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;estaEn x xs = algunos (λy. y=x) xs&amp;quot;&lt;br /&gt;
  have &amp;quot;estaEn x (a#xs) = ((a=x) ∨ estaEn x xs)&amp;quot;  &lt;br /&gt;
    by (simp only: estaEn.simps(2))&lt;br /&gt;
  also have &amp;quot;... = ((a=x) ∨ algunos  (λy. y=x) xs) &amp;quot; &lt;br /&gt;
    using HI by (simp only :)&lt;br /&gt;
  also have &amp;quot;... = algunos  (λy. y=x) (a#xs)&amp;quot;  &lt;br /&gt;
    by (simp only: algunos.simps(2))&lt;br /&gt;
  finally show &amp;quot;estaEn x (a#xs) = algunos (λy. y=x) (a#xs)&amp;quot; &lt;br /&gt;
    by this&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada aplicativa:›&lt;br /&gt;
lemma &amp;quot;estaEn x xs = algunos (λy. y=x) xs&amp;quot;&lt;br /&gt;
  apply (induct xs) &lt;br /&gt;
   apply (simp only:estaEn.simps(1))&lt;br /&gt;
   apply (simp only:algunos.simps(1))&lt;br /&gt;
   apply (simp only:estaEn.simps(2))&lt;br /&gt;
  apply (simp only:algunos.simps(2))&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mjoseh</name></author>
		
	</entry>
</feed>