<?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_11_%28sol%29</id>
	<title>Rel 11 (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_11_%28sol%29"/>
	<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/LMF2020/index.php?title=Rel_11_(sol)&amp;action=history"/>
	<updated>2026-07-20T11:45:27Z</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_11_(sol)&amp;diff=1094&amp;oldid=prev</id>
		<title>Jalonso en 10:05 12 may 2020</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/LMF2020/index.php?title=Rel_11_(sol)&amp;diff=1094&amp;oldid=prev"/>
		<updated>2020-05-12T10:05:02Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;es&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Revisión anterior&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revisión del 10:05 12 may 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l607&quot; &gt;Línea 607:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Línea 607:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; rev (borraDuplicados xs) = [a⇩1, a⇩2]&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; rev (borraDuplicados xs) = [a⇩1, a⇩2]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;end&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;end&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jalonso</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/LMF2020/index.php?title=Rel_11_(sol)&amp;diff=1093&amp;oldid=prev</id>
		<title>Jalonso en 10:04 12 may 2020</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/LMF2020/index.php?title=Rel_11_(sol)&amp;diff=1093&amp;oldid=prev"/>
		<updated>2020-05-12T10:04:21Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;es&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Revisión anterior&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revisión del 10:04 12 may 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Línea 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Línea 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang = &amp;quot;isabelle&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;isabelle&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;chapter ‹ R11: Razonamiento sobre programas en Isabelle/HOL (II)›&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;chapter ‹ R11: Razonamiento sobre programas en Isabelle/HOL (II)›&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jalonso</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/LMF2020/index.php?title=Rel_11_(sol)&amp;diff=1019&amp;oldid=prev</id>
		<title>Mjoseh: Protegió «Rel 11 (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_11_(sol)&amp;diff=1019&amp;oldid=prev"/>
		<updated>2020-05-05T06:47:48Z</updated>

		<summary type="html">&lt;p&gt;Protegió «&lt;a href=&quot;/~jalonso/LMF2020/index.php/Rel_11_(sol)&quot; title=&quot;Rel 11 (sol)&quot;&gt;Rel 11 (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:47 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_11_(sol)&amp;diff=1018&amp;oldid=prev</id>
		<title>Mjoseh: Página creada con «&lt;source lang = &quot;isabelle&quot;&gt; chapter ‹ R11: Razonamiento sobre programas en Isabelle/HOL (II)›   theory R11_sol imports Main  begin   text ‹ ---------------------------…»</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/LMF2020/index.php?title=Rel_11_(sol)&amp;diff=1018&amp;oldid=prev"/>
		<updated>2020-05-05T06:47:37Z</updated>

		<summary type="html">&lt;p&gt;Página creada con «&amp;lt;source lang = &amp;quot;isabelle&amp;quot;&amp;gt; chapter ‹ R11: Razonamiento sobre programas en Isabelle/HOL (II)›   theory R11_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 ‹ R11: Razonamiento sobre programas en Isabelle/HOL (II)›&lt;br /&gt;
 &lt;br /&gt;
theory R11_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;
    + en el ejercicio 1.2, la prueba detallada usando &amp;quot;simp only:...&amp;quot;&lt;br /&gt;
      (bien de forma declarativa o aplicativa) &lt;br /&gt;
    + en los ejercicios 5, 6 y 7 sólo es necesario hacer la demostración &lt;br /&gt;
      detallada usando &amp;quot;simp&amp;quot;, sin llegar al detalle de usar &amp;quot;simp only:...&amp;quot;&lt;br /&gt;
  ------------------------------------------------------------------ ›&lt;br /&gt;
    &lt;br /&gt;
text ‹ --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1.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;
value &amp;quot;factR 4&amp;quot; ― ‹= 24›&lt;br /&gt;
 &lt;br /&gt;
text ‹ --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1.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;
  ------------------------------------------------------------------- ›&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;
 ― ‹Demostración automática:›&lt;br /&gt;
lemma &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;  &lt;br /&gt;
  by (induct n arbitrary: x) &lt;br /&gt;
    (auto simp del: mult_Suc)&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración en lenguaje natural:&lt;br /&gt;
Por inducción en n con x arbitrario, hay que probar &lt;br /&gt;
     ∀n. (∀x. factI&amp;#039; n x = x * factR n)&lt;br /&gt;
&lt;br /&gt;
+ Caso base:  hay que probar ∀x. factI&amp;#039; 0 x = x * factR 0&lt;br /&gt;
  En efecto, para cualquier x, se tiene factI&amp;#039; 0 x = x * factR 0,&lt;br /&gt;
  aplicando directamenta las definiciones de ambas funciones.&lt;br /&gt;
&lt;br /&gt;
+ Paso inductivo:&lt;br /&gt;
  + HI: ∀x. factI&amp;#039; n x = x * factR n&lt;br /&gt;
  + Hay que probar  ∀x. factI&amp;#039; (n+1) x = x * factR (n+1)&lt;br /&gt;
  En efecto, sea a cualquiera&lt;br /&gt;
     factI&amp;#039; (n+1) a       = (por def. de factI&amp;#039;)&lt;br /&gt;
     factI&amp;#039; n (a*(n+1))   = (por HI, para x = a*(n+1))&lt;br /&gt;
     (a*(n+1))*(factR n)  = (asociativa de *)&lt;br /&gt;
     a*((n+1)*(factR n))  = (def. de factR)&lt;br /&gt;
     a*(factR (n+1))&lt;br /&gt;
›&lt;br /&gt;
&lt;br /&gt;
― ‹Demostración estructurada:›&lt;br /&gt;
lemma &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;
― ‹Demostración detallada declarativa:›     &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;
fix x&lt;br /&gt;
  have &amp;quot;factI&amp;#039; 0 x = x&amp;quot;&lt;br /&gt;
    by (simp only: factI&amp;#039;.simps(1))&lt;br /&gt;
  also have &amp;quot;... = x * 1&amp;quot;&lt;br /&gt;
    by (simp only: mult_1_right)&lt;br /&gt;
  also have &amp;quot;... = x * factR 0&amp;quot;&lt;br /&gt;
    by (simp only: factR.simps(1))&lt;br /&gt;
  finally show &amp;quot;factI&amp;#039; 0 x= x* factR 0&amp;quot;&lt;br /&gt;
    by this&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;&lt;br /&gt;
      by (simp only: factI&amp;#039;.simps(2))&lt;br /&gt;
    also have &amp;quot;... = (x*Suc n)*factR n&amp;quot;&lt;br /&gt;
      by (simp only: HI)&lt;br /&gt;
    also have &amp;quot;... = x*(Suc n*factR n)&amp;quot;&lt;br /&gt;
      by (simp only: mult.assoc)&lt;br /&gt;
    also have &amp;quot;... = x*factR (Suc n)&amp;quot;&lt;br /&gt;
      by (simp only: factR.simps(2))&lt;br /&gt;
    finally show &amp;quot;factI&amp;#039; (Suc n) x= x*factR (Suc n)&amp;quot;&lt;br /&gt;
      by this&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
― ‹Demostración detallada aplicativa:›     &lt;br /&gt;
lemma  &amp;quot;factI&amp;#039; n x = x * factR n&amp;quot;&lt;br /&gt;
  apply (induct n arbitrary: x)&lt;br /&gt;
   apply (simp only: factI&amp;#039;.simps(1))&lt;br /&gt;
   apply (simp only: factR.simps(1)) &lt;br /&gt;
  apply  (simp only: factI&amp;#039;.simps(2))&lt;br /&gt;
  apply  (simp only: factR.simps(2))&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
text ‹ --------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 1.3. Demostrar que&lt;br /&gt;
     factI n = factR n&lt;br /&gt;
  ------------------------------------------------------------------- ›&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
― ‹Demostración automática:›&lt;br /&gt;
corollary &amp;quot;factI n = factR n&amp;quot;&lt;br /&gt;
  by (simp add: fact)&lt;br /&gt;
&lt;br /&gt;
― ‹Demostración en lenguaje natural:&lt;br /&gt;
&lt;br /&gt;
   factI n        = (def. de factI)&lt;br /&gt;
   factI&amp;#039; n 1     = (lema fact)&lt;br /&gt;
   1 * (factR n)  = (1 es elemento neutro de *)&lt;br /&gt;
   factR n&lt;br /&gt;
›&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
― ‹Demostración estructurada:›&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;&lt;br /&gt;
    by simp&lt;br /&gt;
  also have &amp;quot;… = 1 * factR n&amp;quot;&lt;br /&gt;
    by (simp add: fact)&lt;br /&gt;
  also have &amp;quot;… = factR n&amp;quot;&lt;br /&gt;
    by simp &lt;br /&gt;
  finally show &amp;quot;factI n = factR n&amp;quot;&lt;br /&gt;
    by this&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
― ‹Demostración detallada declarativa:›&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;&lt;br /&gt;
    by (simp only: factI.simps)&lt;br /&gt;
  also have &amp;quot;… = 1 * factR n&amp;quot;&lt;br /&gt;
    by (simp only: fact)&lt;br /&gt;
  also have &amp;quot;… = factR n&amp;quot;&lt;br /&gt;
    by (simp only: nat_mult_1)&lt;br /&gt;
  finally show &amp;quot;factI n = factR n&amp;quot;&lt;br /&gt;
    by this&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 text ‹&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 2. 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) = (x=a ∨ estaEn x xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text ‹ &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 3. Definir la función&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;
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 (a#xs) = ((¬ estaEn a xs) ∧ sinDuplicados xs)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
text ‹ &lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. Definir la función&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;
&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 (a#xs) = (if estaEn a xs&lt;br /&gt;
                             then borraDuplicados xs&lt;br /&gt;
                             else (a#borraDuplicados xs))&amp;quot;&lt;br /&gt;
&lt;br /&gt;
text ‹&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 5. Demostrar o refutar&lt;br /&gt;
     length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
›&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración automática:›&lt;br /&gt;
lemma &amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  by (induct xs) simp_all&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración en lenguaje natural:&lt;br /&gt;
Por inducción en xs.&lt;br /&gt;
&lt;br /&gt;
+ Caso base: &lt;br /&gt;
    length (borraDuplicados [])  ≤ length [], directamente por las definciones.&lt;br /&gt;
&lt;br /&gt;
+ Paso inductivo: &lt;br /&gt;
  + HI: length (borraDuplicados xs) ≤ length xs&lt;br /&gt;
  + Hay que probar: length (borraDuplicados (a#xs)) ≤ length (a#xs)&lt;br /&gt;
    La demostración se realiza por casos:&lt;br /&gt;
&lt;br /&gt;
    + Caso 1: estaEn a xs&lt;br /&gt;
      En este caso, por la definición de borraDuplicados, &lt;br /&gt;
      borraDuplicados (a#xs) = borraDuplicados xs. Por tanto,&lt;br /&gt;
      length (borraDuplicados (a#xs)) = (def. de borraDuplicados)&lt;br /&gt;
      length (borraDuplicados xs)     ≤ (por HI)&lt;br /&gt;
      length xs                       ≤ (aritmética)&lt;br /&gt;
      1 + length xs                   = (por def. de length)&lt;br /&gt;
      length (a#xs)    &lt;br /&gt;
              &lt;br /&gt;
    + Caso 2: ¬ (estaEn a xs)&lt;br /&gt;
      En este caso, por la definición de borraDuplicados, &lt;br /&gt;
      borraDuplicados (a#xs) = a#(borraDuplicados xs). Por tanto,&lt;br /&gt;
      length (borraDuplicados (a#xs)) = (def. de borraDuplicados)&lt;br /&gt;
      length (a#(borraDuplicados xs)) = (def. de length)&lt;br /&gt;
      1 + length (borraDuplicados xs) ≤ (por HI)&lt;br /&gt;
      1 + length xs                   = (por def. de length)&lt;br /&gt;
      length (a#xs)                  &lt;br /&gt;
&lt;br /&gt;
›&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración estructurada:›&lt;br /&gt;
&lt;br /&gt;
lemma &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 :: &amp;#039;a list)) ≤ length xs&amp;quot;&lt;br /&gt;
  thus &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;
    thus &amp;quot;length (borraDuplicados (a#xs)) ≤ length (a#xs)&amp;quot;&lt;br /&gt;
      using HI by simp&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;(¬ estaEn a xs)&amp;quot;&lt;br /&gt;
    thus &amp;quot;length (borraDuplicados (a#xs)) ≤ length (a#xs)&amp;quot;&lt;br /&gt;
      using HI by simp&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ― ‹Auxiliares para la demostración detallada:›&lt;br /&gt;
lemma estaEnBD1:&lt;br /&gt;
  assumes &amp;quot;estaEn b xs&amp;quot;&lt;br /&gt;
  shows &amp;quot;borraDuplicados (b#xs) = borraDuplicados xs&amp;quot; &lt;br /&gt;
  using assms by (simp only:borraDuplicados.simps(2) if_P)&lt;br /&gt;
&lt;br /&gt;
lemma estaEnBD2:&lt;br /&gt;
  assumes &amp;quot;¬ (estaEn b xs)&amp;quot;&lt;br /&gt;
  shows &amp;quot;borraDuplicados (b#xs) = b#(borraDuplicados xs)&amp;quot; &lt;br /&gt;
proof-&lt;br /&gt;
 have  &amp;quot;borraDuplicados (b#xs) =  (if estaEn b xs &lt;br /&gt;
                             then borraDuplicados xs&lt;br /&gt;
                             else (b#borraDuplicados xs))&amp;quot; &lt;br /&gt;
   by (simp only: borraDuplicados.simps(2))&lt;br /&gt;
  also have &amp;quot;…= (b#borraDuplicados xs)&amp;quot; using assms by (rule if_not_P)&lt;br /&gt;
  finally show &amp;quot;borraDuplicados (b # xs) = b # borraDuplicados xs&amp;quot; by this&lt;br /&gt;
qed &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada declarativa:›&lt;br /&gt;
lemma length_borraDuplicados_d:&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; &lt;br /&gt;
    by (simp only: borraDuplicados.simps(1) list.size)&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;length (borraDuplicados (xs :: &amp;#039;a list)) ≤ length xs&amp;quot;&lt;br /&gt;
  show &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 &amp;quot;borraDuplicados (a#xs) = borraDuplicados xs&amp;quot; by (rule estaEnBD1)&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (a#xs)) = length (borraDuplicados xs)&amp;quot;&lt;br /&gt;
      by (rule arg_cong)&lt;br /&gt;
    also have &amp;quot;... ≤ length xs&amp;quot; using HI by this&lt;br /&gt;
    also have &amp;quot;... ≤ length (a#xs)&amp;quot; by (simp only: list.size)&lt;br /&gt;
    finally show ?thesis by this&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;(¬ estaEn a xs)&amp;quot;&lt;br /&gt;
    then have &amp;quot;borraDuplicados (a#xs) = a#(borraDuplicados xs)&amp;quot;&lt;br /&gt;
      by (rule estaEnBD2)&lt;br /&gt;
    then have &amp;quot;length (borraDuplicados (a#xs)) = length (a#(borraDuplicados xs))&amp;quot;&lt;br /&gt;
      by (rule arg_cong)&lt;br /&gt;
    also have &amp;quot;... = 1 + length (borraDuplicados xs)&amp;quot; by (simp only: list.size)&lt;br /&gt;
    also have &amp;quot;... ≤ 1 + length xs&amp;quot; using HI by (simp only: add_left_mono)&lt;br /&gt;
    also have &amp;quot;... = length (a#xs)&amp;quot; by (simp only: list.size)&lt;br /&gt;
    finally show ?thesis  by this&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración aplicativa detallada:›&lt;br /&gt;
lemma length_borraDuplicados_a:&lt;br /&gt;
&amp;quot;length (borraDuplicados xs) ≤ length xs&amp;quot;&lt;br /&gt;
  apply (induct xs)&lt;br /&gt;
   apply (simp only: borraDuplicados.simps(1) list.size)&lt;br /&gt;
  apply (simp only: borraDuplicados.simps(2))&lt;br /&gt;
  apply(split if_split)&lt;br /&gt;
  apply (rule conjI)&lt;br /&gt;
  apply (rule impI)&lt;br /&gt;
   apply (drule estaEnBD1)&lt;br /&gt;
   apply (simp only:list.size)&lt;br /&gt;
   apply (rule impI)&lt;br /&gt;
   apply (drule estaEnBD2)&lt;br /&gt;
   apply (simp only:list.size)&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
text ‹&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 6. Demostrar o refutar&lt;br /&gt;
     estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
›&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración automática:›&lt;br /&gt;
lemma &amp;quot;estaEn a (borraDuplicados xs) = estaEn a xs&amp;quot;&lt;br /&gt;
  by (induct xs) auto&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración en lenguaje natural:&lt;br /&gt;
Por inducción en xs.&lt;br /&gt;
&lt;br /&gt;
+ Caso base: &lt;br /&gt;
     estaEn a (borraDuplicados []) = estaEn a [], directamente por las definiciones.&lt;br /&gt;
&lt;br /&gt;
+ Paso inductivo:&lt;br /&gt;
  + HI: estaEn a (borraDuplicados xs) = estaEn a xs&lt;br /&gt;
  + Hay que probar: estaEn a (borraDuplicados (b#xs)) = estaEn a (b#xs).&lt;br /&gt;
    La demostración se realiza por casos.&lt;br /&gt;
    &lt;br /&gt;
    + Caso 1: estaEn b xs&lt;br /&gt;
      En este caso, por la definición de borraDuplicados, &lt;br /&gt;
      borraDuplicados (b#xs) = borraDuplicados xs. Por tanto,&lt;br /&gt;
      estaEn a (borraDuplicados (b#xs))    = (def. de borraDuplicados)&lt;br /&gt;
      estaEn a (borraDuplicados xs)        = (por HI)&lt;br /&gt;
      estaEn a xs                          = (por (estaEn b xs))&lt;br /&gt;
      estaEn a (b#xs)&lt;br /&gt;
           &lt;br /&gt;
    + Caso 2: ¬ (estaEn b xs)&lt;br /&gt;
      En este caso, por la definición de borraDuplicados, &lt;br /&gt;
      borraDuplicados (b#xs) = b # (borraDuplicados xs). Por tanto,&lt;br /&gt;
      estaEn a (borraDuplicados (b#xs))        = (def. de borraDuplicados)&lt;br /&gt;
      estaEn a ( b # (borraDuplicados xs))     = (def. de estaEn)&lt;br /&gt;
      (a = b) ∨ (estaEn a (borraDuplicados xs) = (por HI)&lt;br /&gt;
      (a = b) ∨ (estaEn a xs                  = (def. de estaEn)&lt;br /&gt;
      estaEn a (b#xs)&lt;br /&gt;
›    &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración estructurada:›&lt;br /&gt;
lemma &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  (cases)&lt;br /&gt;
    assume &amp;quot;estaEn b xs&amp;quot;&lt;br /&gt;
    then have &amp;quot;borraDuplicados (b#xs) = borraDuplicados xs&amp;quot; by (rule estaEnBD1)&lt;br /&gt;
    then have &amp;quot;estaEn a (borraDuplicados (b#xs)) = &lt;br /&gt;
               estaEn a (borraDuplicados xs)&amp;quot; by (rule arg_cong)&lt;br /&gt;
    also have &amp;quot;… = estaEn a xs&amp;quot; using HI by this&lt;br /&gt;
    also have &amp;quot;… = estaEn a (b#xs)&amp;quot; using ‹estaEn b xs› by auto&lt;br /&gt;
    finally show ?thesis by this&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot; ¬ estaEn b xs&amp;quot;&lt;br /&gt;
    then have &amp;quot;borraDuplicados (b#xs) = b#(borraDuplicados xs)&amp;quot; by (rule estaEnBD2)&lt;br /&gt;
    then have &amp;quot;estaEn a (borraDuplicados (b#xs)) = &lt;br /&gt;
               estaEn a (b#(borraDuplicados xs))&amp;quot; by (rule arg_cong)&lt;br /&gt;
    also have &amp;quot;… = ((a = b) ∨ (estaEn a (borraDuplicados xs)))&amp;quot;&lt;br /&gt;
      by (simp only: estaEn.simps(2))&lt;br /&gt;
    also have &amp;quot;… =  ((a = b) ∨ (estaEn a  xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = estaEn a (b#xs)&amp;quot; by (simp only: estaEn.simps(2))&lt;br /&gt;
    finally show ?thesis by this&lt;br /&gt;
  qed&lt;br /&gt;
  qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Auxiliar:›&lt;br /&gt;
&lt;br /&gt;
lemma estaEnCons:&lt;br /&gt;
  assumes &amp;quot;estaEn b xs&amp;quot;&lt;br /&gt;
  shows &amp;quot;estaEn a xs = estaEn a (b#xs)&amp;quot; &lt;br /&gt;
proof (rule iffI)&lt;br /&gt;
  assume &amp;quot; estaEn a xs &amp;quot; &lt;br /&gt;
  then have &amp;quot;((a = b) ∨ (estaEn a xs))&amp;quot; by (rule disjI2)&lt;br /&gt;
  then show &amp;quot;estaEn a (b # xs)&amp;quot; by (simp only:estaEn.simps(2))&lt;br /&gt;
next&lt;br /&gt;
  assume &amp;quot;estaEn a (b # xs)&amp;quot; &lt;br /&gt;
   then have &amp;quot;((a = b) ∨ (estaEn a xs))&amp;quot; by (simp only:estaEn.simps(2))&lt;br /&gt;
   then show  &amp;quot;estaEn a xs&amp;quot; &lt;br /&gt;
   proof&lt;br /&gt;
     assume &amp;quot;a = b&amp;quot; then show &amp;quot;estaEn a xs&amp;quot; using assms by (rule ssubst)&lt;br /&gt;
   next &lt;br /&gt;
     assume &amp;quot;estaEn a xs&amp;quot; then show  &amp;quot;estaEn a xs&amp;quot; by this&lt;br /&gt;
   qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada declarativa:›&lt;br /&gt;
lemma estaEn_borraDuplicados_d:&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; &lt;br /&gt;
    by (simp only:borraDuplicados.simps(1))&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  (cases)&lt;br /&gt;
    assume &amp;quot;estaEn b xs&amp;quot;&lt;br /&gt;
    then have &amp;quot;borraDuplicados (b#xs) = borraDuplicados xs&amp;quot; by (rule estaEnBD1)&lt;br /&gt;
    then have &amp;quot;estaEn a (borraDuplicados (b#xs)) = &lt;br /&gt;
               estaEn a (borraDuplicados xs)&amp;quot; by (rule arg_cong)&lt;br /&gt;
    also have &amp;quot;… = estaEn a xs&amp;quot; using HI by this&lt;br /&gt;
    also have &amp;quot;… = estaEn a (b#xs)&amp;quot; using ‹estaEn b xs› by (rule  estaEnCons)&lt;br /&gt;
    finally show ?thesis by this&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot; ¬ estaEn b xs&amp;quot;&lt;br /&gt;
    then have &amp;quot;borraDuplicados (b#xs) = b#(borraDuplicados xs)&amp;quot; by (rule estaEnBD2)&lt;br /&gt;
    then have &amp;quot;estaEn a (borraDuplicados (b#xs)) = &lt;br /&gt;
               estaEn a (b#(borraDuplicados xs))&amp;quot; by (rule arg_cong)&lt;br /&gt;
    also have &amp;quot;… = ((a = b) ∨ (estaEn a (borraDuplicados xs)))&amp;quot;&lt;br /&gt;
      by (simp only: estaEn.simps(2))&lt;br /&gt;
    also have &amp;quot;… =  ((a = b) ∨ (estaEn a  xs))&amp;quot; using HI by simp&lt;br /&gt;
    also have &amp;quot;… = estaEn a (b#xs)&amp;quot; by (simp only: estaEn.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 &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 only: borraDuplicados.simps(1))&lt;br /&gt;
    apply (simp only: borraDuplicados.simps(2))&lt;br /&gt;
  apply(split if_split)&lt;br /&gt;
  apply (rule conjI)&lt;br /&gt;
   apply (rule impI) &lt;br /&gt;
   apply (simp only: estaEnCons)&lt;br /&gt;
  apply (rule impI) &lt;br /&gt;
  apply (simp only: estaEn.simps(2))&lt;br /&gt;
  done&lt;br /&gt;
                    &lt;br /&gt;
&lt;br /&gt;
text ‹&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 7. Demostrar o refutar&lt;br /&gt;
     sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
›&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración automática:›&lt;br /&gt;
lemma &amp;quot;sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
  by (induct xs) &lt;br /&gt;
    (auto simp add: estaEn_borraDuplicados_d)&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración en lenguaje natural:&lt;br /&gt;
Por inducción en xs.&lt;br /&gt;
&lt;br /&gt;
+ Caso base: &lt;br /&gt;
   sinDuplicados (borraDuplicados []), directamente por las definiciones.&lt;br /&gt;
&lt;br /&gt;
+ Paso inductivo:&lt;br /&gt;
  + HI: sinDuplicados (borraDuplicados xs)&lt;br /&gt;
  + Hay que probar: sinDuplicados (borraDuplicados (a#xs))&lt;br /&gt;
       La demostración se realiza por casos.&lt;br /&gt;
    &lt;br /&gt;
    + Caso 1: estaEn a xs&lt;br /&gt;
      En este caso, por la definición de borraDuplicados, &lt;br /&gt;
      borraDuplicados (a#xs) = borraDuplicados xs. Por tanto,&lt;br /&gt;
      sinDuplicados (borraDuplicados (a#xs)) = (def.de borraDuplicados)&lt;br /&gt;
      sinDuplicados  (borraDuplicados xs)     (cierto, por HI)&lt;br /&gt;
    &lt;br /&gt;
    + Caso 2: ¬ (estaEn a xs)&lt;br /&gt;
      En este caso, por la definición de borraDuplicados, &lt;br /&gt;
      borraDuplicados (a#xs) = a # (borraDuplicados xs). Por tanto,&lt;br /&gt;
      sinDuplicados (borraDuplicados (a#xs))     = (def. de borraDuplicados)  &lt;br /&gt;
      sinDuplicados (a#(borraDuplicados xs))     = (def. de sinDuplicados)&lt;br /&gt;
      ((¬ estaEn a (borraDuplicados xs)) ∧ &lt;br /&gt;
       sinDuplicados (borraDuplicados xs))       = (por hI)&lt;br /&gt;
      ¬ estaEn a (borraDuplicados xs)            (cierto por la hipótesis del &lt;br /&gt;
                                                  caso 2 y el ejercicio 6)   &lt;br /&gt;
›&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración estructurada:›&lt;br /&gt;
lemma &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;#039;a list))&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;
    thus &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;
    thus &amp;quot;sinDuplicados (borraDuplicados (a#xs))&amp;quot;&lt;br /&gt;
      using `¬ estaEn a xs` HI by (auto simp add: estaEn_borraDuplicados_d)&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 ― ‹Demostración detallada declarativa:›&lt;br /&gt;
lemma sinDuplicados_borraDuplicados_d:&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; &lt;br /&gt;
    by (simp only: borraDuplicados.simps(1) &lt;br /&gt;
                   sinDuplicados.simps(1))&lt;br /&gt;
next&lt;br /&gt;
  fix a xs&lt;br /&gt;
  assume HI: &amp;quot;sinDuplicados (borraDuplicados (xs:: &amp;#039;a list))&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 have &amp;quot;borraDuplicados (a#xs) = borraDuplicados xs&amp;quot; &lt;br /&gt;
      by (rule estaEnBD1)&lt;br /&gt;
    then show &amp;quot;sinDuplicados (borraDuplicados (a#xs))&amp;quot; using HI &lt;br /&gt;
      by (rule ssubst)&lt;br /&gt;
  next&lt;br /&gt;
    assume 1: &amp;quot;¬ estaEn a xs&amp;quot;&lt;br /&gt;
     then have 2: &amp;quot;borraDuplicados (a#xs) = a#(borraDuplicados xs)&amp;quot; &lt;br /&gt;
       by (rule estaEnBD2)&lt;br /&gt;
     have &amp;quot;¬ estaEn a (borraDuplicados xs)&amp;quot; using 1&lt;br /&gt;
       by  (simp add: estaEn_borraDuplicados_d)&lt;br /&gt;
     then have &amp;quot;¬ (estaEn a (borraDuplicados xs)) &lt;br /&gt;
                   ∧ sinDuplicados (borraDuplicados xs)&amp;quot;&lt;br /&gt;
       using HI by (rule conjI)&lt;br /&gt;
     then have &amp;quot;sinDuplicados (a#(borraDuplicados xs))&amp;quot; &lt;br /&gt;
       by (simp only: sinDuplicados.simps(2)[THEN sym])  &lt;br /&gt;
     with 2 show  &amp;quot;sinDuplicados (borraDuplicados (a#xs))&amp;quot; &lt;br /&gt;
       by (rule ssubst)&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text ‹&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 8. Demostrar o refutar:&lt;br /&gt;
    borraDuplicados (rev xs) = rev (borraDuplicados xs)&lt;br /&gt;
  --------------------------------------------------------------------- &lt;br /&gt;
›&lt;br /&gt;
&lt;br /&gt;
lemma &amp;quot;borraDuplicados (rev xs) = rev (borraDuplicados xs)&amp;quot;&lt;br /&gt;
  oops&lt;br /&gt;
(*&lt;br /&gt;
Auto Quickcheck found a counterexample:&lt;br /&gt;
  xs = [a⇩1, a⇩2, a⇩1]&lt;br /&gt;
Evaluated terms:&lt;br /&gt;
  borraDuplicados (rev xs) = [a⇩2, a⇩1]&lt;br /&gt;
  rev (borraDuplicados xs) = [a⇩1, a⇩2]&lt;br /&gt;
*)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
end&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>