<?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=T5-1_sol</id>
	<title>T5-1 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=T5-1_sol"/>
	<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/LMF2020/index.php?title=T5-1_sol&amp;action=history"/>
	<updated>2026-07-20T08:31:25Z</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=T5-1_sol&amp;diff=1258&amp;oldid=prev</id>
		<title>Mjoseh: Protegió «T5-1 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=T5-1_sol&amp;diff=1258&amp;oldid=prev"/>
		<updated>2020-06-17T15:36:57Z</updated>

		<summary type="html">&lt;p&gt;Protegió «&lt;a href=&quot;/~jalonso/LMF2020/index.php/T5-1_sol&quot; title=&quot;T5-1 sol&quot;&gt;T5-1 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 15:36 17 jun 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=T5-1_sol&amp;diff=1257&amp;oldid=prev</id>
		<title>Mjoseh: Página creada con «&lt;source lang = &quot;isabelle&quot;&gt;  theory ej_2_jun_sol imports Main  begin  lemma notnotI: &quot;P ⟹ ¬¬ P&quot;   by auto  lemma mt: &quot;⟦F ⟶ G; ¬G⟧ ⟹ ¬F&quot; by auto  text ‹------…»</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/LMF2020/index.php?title=T5-1_sol&amp;diff=1257&amp;oldid=prev"/>
		<updated>2020-06-17T15:36:45Z</updated>

		<summary type="html">&lt;p&gt;Página creada con «&amp;lt;source lang = &amp;quot;isabelle&amp;quot;&amp;gt;  theory ej_2_jun_sol imports Main  begin  lemma notnotI: &amp;quot;P ⟹ ¬¬ P&amp;quot;   by auto  lemma mt: &amp;quot;⟦F ⟶ G; ¬G⟧ ⟹ ¬F&amp;quot; by auto  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;
&lt;br /&gt;
theory ej_2_jun_sol&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
lemma notnotI: &amp;quot;P ⟹ ¬¬ P&amp;quot;&lt;br /&gt;
  by auto&lt;br /&gt;
&lt;br /&gt;
lemma mt: &amp;quot;⟦F ⟶ G; ¬G⟧ ⟹ ¬F&amp;quot;&lt;br /&gt;
by auto&lt;br /&gt;
&lt;br /&gt;
text ‹-----------------------------------------------------------------&lt;br /&gt;
  Ejercicio 1. Consideremos el árbol binario definido por&lt;br /&gt;
     datatype &amp;#039;a arbol = H  &lt;br /&gt;
                       | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  Por ejemplo, el árbol&lt;br /&gt;
          e&lt;br /&gt;
         / \&lt;br /&gt;
        /   \&lt;br /&gt;
       c     g&lt;br /&gt;
      / \   / \&lt;br /&gt;
             &lt;br /&gt;
  se representa por &amp;quot;N e (N c H H) (N g H H)&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
  Se define las funciones&lt;br /&gt;
    fun nHojas :: &amp;quot;&amp;#039;a arbol ⇒ nat&amp;quot; where&lt;br /&gt;
      &amp;quot;nHojas H         = 1&amp;quot;&lt;br /&gt;
    | &amp;quot;nHojas (N x i d) = nHojas i + nHojas d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    fun nHojasAaux :: &amp;quot;&amp;#039;a arbol ⇒ nat ⇒ nat&amp;quot; where&lt;br /&gt;
      &amp;quot;nHojasAaux H         n = n + 1&amp;quot;&lt;br /&gt;
    | &amp;quot;nHojasAaux (N x i d) n = nHojasAaux i (nHojasAaux d n)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    definition nHojasA :: &amp;quot;&amp;#039;a arbol ⇒ nat&amp;quot; where&lt;br /&gt;
      &amp;quot;nHojasA a ≡ nHojasAaux a 0&amp;quot;&lt;br /&gt;
  tales que&lt;br /&gt;
  + (nHojas a) es el número de hojas del árbol a. Por ejemplo, &lt;br /&gt;
       nHojas (N e (N c H H) (N g H H)) = 4&lt;br /&gt;
  + (nHojasAA a) es el número de hojas del árbol a, calculado &lt;br /&gt;
    con la función auxiliar nHojasAaux que el el segundo argumento va&lt;br /&gt;
    acumulando el resultado. Por ejemplo, &lt;br /&gt;
       nHojasA (N e (N c H H) (N g H H)) = 4&lt;br /&gt;
 &lt;br /&gt;
  Demostrar detalladamente que las funciones nHojas y nHojasA son&lt;br /&gt;
  equivalentes; es decir,&lt;br /&gt;
     nHojasA a = nHojas a&lt;br /&gt;
&lt;br /&gt;
  Nota: Los únicos métodos que se pueden usar son induct y simp. &lt;br /&gt;
  -------------------------------------------------------------------›&lt;br /&gt;
&lt;br /&gt;
section ‹Definiciones›&lt;br /&gt;
&lt;br /&gt;
datatype &amp;#039;a arbol = H  &lt;br /&gt;
                  | N &amp;quot;&amp;#039;a&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot; &amp;quot;&amp;#039;a arbol&amp;quot;&lt;br /&gt;
&lt;br /&gt;
fun nHojas :: &amp;quot;&amp;#039;a arbol ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;nHojas H         = 1&amp;quot;&lt;br /&gt;
| &amp;quot;nHojas (N x i d) = nHojas i + nHojas d&amp;quot;&lt;br /&gt;
&lt;br /&gt;
fun nHojasAaux :: &amp;quot;&amp;#039;a arbol ⇒ nat ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;nHojasAaux H         n = n + 1&amp;quot;&lt;br /&gt;
| &amp;quot;nHojasAaux (N x i d) n = nHojasAaux i (nHojasAaux d n)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
definition nHojasA :: &amp;quot;&amp;#039;a arbol ⇒ nat&amp;quot; where&lt;br /&gt;
  &amp;quot;nHojasA a ≡ nHojasAaux a 0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
value &amp;quot;nHojas (N e (N c H H) (N g H H)) = 4&amp;quot;&lt;br /&gt;
value &amp;quot;nHojasA (N e (N c H H) (N g H H)) = 4&amp;quot;&lt;br /&gt;
&lt;br /&gt;
section ‹Demostraciones del lema auxiliar nHojasAux›&lt;br /&gt;
&lt;br /&gt;
subsection ‹Demostración estructurada de nHojasAux›&lt;br /&gt;
&lt;br /&gt;
lemma nHojasAuxE:&lt;br /&gt;
  &amp;quot;nHojasAaux a n = nHojas a + n&amp;quot;&lt;br /&gt;
proof (induct a arbitrary: n)&lt;br /&gt;
  case H&lt;br /&gt;
  then show ?case by simp&lt;br /&gt;
next&lt;br /&gt;
  case (N x1 a1 a2)&lt;br /&gt;
  then show ?case by simp&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
subsection ‹Demostración automática de nHojasAux›&lt;br /&gt;
&lt;br /&gt;
lemma nHojasAuxA:&lt;br /&gt;
  &amp;quot;nHojasAaux a n = nHojas a + n&amp;quot;&lt;br /&gt;
  by (induct a arbitrary: n) simp_all&lt;br /&gt;
&lt;br /&gt;
subsection ‹Demostración declarativa detallada de nHojasAux›&lt;br /&gt;
&lt;br /&gt;
lemma nHojasAux:&lt;br /&gt;
  &amp;quot;nHojasAaux a n = (nHojas a) + n&amp;quot;&lt;br /&gt;
proof (induct a arbitrary: n)&lt;br /&gt;
  fix n&lt;br /&gt;
  have &amp;quot;nHojasAaux H n = n + 1&amp;quot; &lt;br /&gt;
    by (simp only: nHojasAaux.simps(1))&lt;br /&gt;
  also have &amp;quot;… = nHojas H + n&amp;quot; &lt;br /&gt;
    by (simp only:nHojas.simps(1))&lt;br /&gt;
  finally show &amp;quot;nHojasAaux H n = nHojas H + n&amp;quot; &lt;br /&gt;
    by this&lt;br /&gt;
next&lt;br /&gt;
  fix x :: &amp;#039;a and i d :: &amp;quot;&amp;#039;a arbol&amp;quot; and n :: nat&lt;br /&gt;
  assume HI1: &amp;quot;⋀n. nHojasAaux i n = nHojas i + n&amp;quot;&lt;br /&gt;
    and HI2: &amp;quot;⋀n. nHojasAaux d n = nHojas d + n&amp;quot;&lt;br /&gt;
  have &amp;quot;nHojasAaux (N x i d) n = nHojasAaux i (nHojasAaux d n)&amp;quot; &lt;br /&gt;
    by (simp only: nHojasAaux.simps(2))&lt;br /&gt;
  also have &amp;quot;… = nHojasAaux i (nHojas d + n)&amp;quot; &lt;br /&gt;
    by (simp only: HI2)&lt;br /&gt;
  also have &amp;quot;… = nHojas i + (nHojas d + n)&amp;quot; &lt;br /&gt;
    by (simp only: HI1)&lt;br /&gt;
  also have &amp;quot;… = (nHojas i + nHojas d) + n&amp;quot;&lt;br /&gt;
    by (simp only: add.commute)&lt;br /&gt;
  also have &amp;quot;… = nHojas (N x i d) + n&amp;quot; &lt;br /&gt;
    by (simp only: nHojas.simps(2))&lt;br /&gt;
  finally show &amp;quot;nHojasAaux (N x i d) n = nHojas (N x i d) + n&amp;quot;  &lt;br /&gt;
    by this&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
section ‹Demostraciones del teorema nHojasA›&lt;br /&gt;
&lt;br /&gt;
subsection ‹Demostración automática de nHojasA›&lt;br /&gt;
&lt;br /&gt;
theorem nHojasA_A:&lt;br /&gt;
  &amp;quot;nHojasA a = nHojas a&amp;quot;&lt;br /&gt;
  by (simp add: nHojasA_def nHojasAux)&lt;br /&gt;
&lt;br /&gt;
subsection &amp;quot;Demostración declarativa detallada de nHojasA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
theorem nHojasA:&lt;br /&gt;
  &amp;quot;nHojasA a = nHojas a&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;nHojasA a = nHojasAaux a 0&amp;quot; &lt;br /&gt;
    by (simp only: nHojasA_def)&lt;br /&gt;
  also have &amp;quot;… = nHojas a + 0&amp;quot;&lt;br /&gt;
    by (simp only: nHojasAux)&lt;br /&gt;
  also have &amp;quot;... = nHojas a&amp;quot;&lt;br /&gt;
    by (simp only: add_0_right)&lt;br /&gt;
  finally show &amp;quot;nHojasA a = nHojas a&amp;quot;&lt;br /&gt;
    by this&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text ‹------------------------------------------------------------------&lt;br /&gt;
  Ejercicio 2. Sea G un grupo. Demostrar detalladamente lo siguiente:&lt;br /&gt;
     x = y^ ⋅ z si y sólo si z = y ⋅ x&lt;br /&gt;
&lt;br /&gt;
  Nota: No usar ninguno de los métodos automáticos: auto, blast, force,&lt;br /&gt;
  fast, arith o metis &lt;br /&gt;
  ------------------------------------------------------------------ ›&lt;br /&gt;
&lt;br /&gt;
locale grupo =&lt;br /&gt;
  fixes prod :: &amp;quot;[&amp;#039;a, &amp;#039;a] ⇒ &amp;#039;a&amp;quot; (infixl &amp;quot;⋅&amp;quot; 70)&lt;br /&gt;
    and neutro (&amp;quot;𝟭&amp;quot;) &lt;br /&gt;
    and inverso (&amp;quot;_^&amp;quot; [100] 100)&lt;br /&gt;
  assumes asociativa: &amp;quot;(x ⋅ y) ⋅ z = x ⋅ (y ⋅ z)&amp;quot;&lt;br /&gt;
      and neutro_i:   &amp;quot;𝟭 ⋅ x = x&amp;quot;&lt;br /&gt;
      and neutro_d:   &amp;quot;x ⋅ 𝟭 = x&amp;quot;&lt;br /&gt;
      and inverso_i:  &amp;quot;x^ ⋅ x = 𝟭&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(* Notas sobre notación:&lt;br /&gt;
   * El producto es ⋅ y se escribe con \ cdot (sin espacio entre ellos). &lt;br /&gt;
   * El neutro es 𝟭 y se escribe con \ y one (sin espacio entre ellos).&lt;br /&gt;
   * El inverso de x es x^ y se escribe pulsando 2 veces en ^. *)&lt;br /&gt;
&lt;br /&gt;
context grupo&lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
section ‹Demostraciones de inverso_d›&lt;br /&gt;
&lt;br /&gt;
subsection ‹Demostración automática de inverso_d›&lt;br /&gt;
&lt;br /&gt;
lemma inverso_d_A:&lt;br /&gt;
  &amp;quot;x ⋅ x^ = 𝟭&amp;quot;&lt;br /&gt;
  by (metis asociativa neutro_i inverso_i)&lt;br /&gt;
&lt;br /&gt;
subsection ‹Demostración declarativa detallada de inverso_d›&lt;br /&gt;
&lt;br /&gt;
lemma inverso_d:&lt;br /&gt;
  &amp;quot;x ⋅ x^ = 𝟭&amp;quot;&lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;x ⋅ x^ = 𝟭 ⋅ (x ⋅ x^)&amp;quot; &lt;br /&gt;
    by (simp only: neutro_i)&lt;br /&gt;
  also have &amp;quot;… = (𝟭 ⋅ x) ⋅ x^&amp;quot; &lt;br /&gt;
    by (simp only: asociativa)&lt;br /&gt;
  also have &amp;quot;… = (((x^)^ ⋅ x^) ⋅ x) ⋅ x^&amp;quot; &lt;br /&gt;
    by (simp only: inverso_i)&lt;br /&gt;
  also have &amp;quot;… = ((x^)^ ⋅ (x^ ⋅ x)) ⋅ x^&amp;quot; &lt;br /&gt;
    by (simp only: asociativa)&lt;br /&gt;
  also have &amp;quot;… = ((x^)^ ⋅ 𝟭) ⋅ x^&amp;quot; &lt;br /&gt;
    by (simp only: inverso_i)&lt;br /&gt;
  also have &amp;quot;… = (x^)^ ⋅ (𝟭 ⋅ x^)&amp;quot; &lt;br /&gt;
    by (simp only: asociativa)&lt;br /&gt;
  also have &amp;quot;… = (x^)^ ⋅ x^&amp;quot; &lt;br /&gt;
    by (simp only: neutro_i)&lt;br /&gt;
  also have &amp;quot;… = 𝟭&amp;quot; &lt;br /&gt;
    by (simp only: inverso_i)&lt;br /&gt;
  finally show ?thesis &lt;br /&gt;
    by this&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
section ‹Demostraciones de condicion_necesaria›&lt;br /&gt;
&lt;br /&gt;
subsection ‹Demostración automática de condicion_necesaria›&lt;br /&gt;
&lt;br /&gt;
lemma condicion_necesaria_A:&lt;br /&gt;
  assumes &amp;quot;x = y^ ⋅ z&amp;quot; &lt;br /&gt;
  shows   &amp;quot;z = y  ⋅ x&amp;quot; &lt;br /&gt;
  using assms&lt;br /&gt;
  by (metis asociativa neutro_i inverso_d)&lt;br /&gt;
&lt;br /&gt;
subsection ‹Demostración declarativa detallada de condicion_necesaria›&lt;br /&gt;
&lt;br /&gt;
lemma condicion_necesaria:&lt;br /&gt;
  assumes &amp;quot;x = y^ ⋅ z&amp;quot; &lt;br /&gt;
  shows   &amp;quot;z = y  ⋅ x&amp;quot; &lt;br /&gt;
proof -&lt;br /&gt;
  have &amp;quot;y ⋅ x = y ⋅ (y^ ⋅ z)&amp;quot; &lt;br /&gt;
    using assms(1)&lt;br /&gt;
    by (rule arg_cong)&lt;br /&gt;
  also have &amp;quot;… = (y ⋅ y^) ⋅ z&amp;quot; &lt;br /&gt;
    by (simp only: asociativa)&lt;br /&gt;
  also have &amp;quot;… = 𝟭 ⋅ z&amp;quot; &lt;br /&gt;
    by (simp only: inverso_d)&lt;br /&gt;
  also have &amp;quot;… = z&amp;quot; &lt;br /&gt;
    by (simp only: neutro_i)&lt;br /&gt;
  finally have &amp;quot;y ⋅ x = z&amp;quot; &lt;br /&gt;
    by this&lt;br /&gt;
  then show &amp;quot;z = y ⋅ x&amp;quot; &lt;br /&gt;
    by (rule sym)&lt;br /&gt;
  qed&lt;br /&gt;
&lt;br /&gt;
section ‹Demostraciones de condicion_suficiente›&lt;br /&gt;
&lt;br /&gt;
subsection ‹Demostración automática de condicion_suficiente›&lt;br /&gt;
&lt;br /&gt;
lemma condicion_suficiente_A:&lt;br /&gt;
  assumes &amp;quot;z = y  ⋅ x&amp;quot; &lt;br /&gt;
  shows   &amp;quot;x = y^ ⋅ z&amp;quot; &lt;br /&gt;
  using assms(1)&lt;br /&gt;
  by (metis asociativa neutro_i inverso_i)&lt;br /&gt;
&lt;br /&gt;
subsection ‹Demostración declarativa detallada de condicion_suficiente›&lt;br /&gt;
&lt;br /&gt;
lemma condicion_suficiente:&lt;br /&gt;
  assumes &amp;quot;z = y  ⋅ x&amp;quot; &lt;br /&gt;
  shows   &amp;quot;x = y^ ⋅ z&amp;quot; &lt;br /&gt;
proof -&lt;br /&gt;
  have  &amp;quot;y^ ⋅ z = y^ ⋅ (y ⋅ x)&amp;quot;&lt;br /&gt;
    using assms(1)&lt;br /&gt;
    by (rule arg_cong)&lt;br /&gt;
  also have &amp;quot;… =  (y^ ⋅ y) ⋅ x&amp;quot; &lt;br /&gt;
    by (simp only: asociativa)&lt;br /&gt;
  also have &amp;quot;… = 𝟭 ⋅ x&amp;quot; &lt;br /&gt;
    by (simp only: inverso_i)&lt;br /&gt;
  also have &amp;quot;… = x&amp;quot; &lt;br /&gt;
    by (simp only: neutro_i)&lt;br /&gt;
  finally have &amp;quot;y^ ⋅ z = x&amp;quot; &lt;br /&gt;
    by this&lt;br /&gt;
  then show  &amp;quot;x = y^ ⋅ z&amp;quot; &lt;br /&gt;
    by (rule sym)&lt;br /&gt;
qed   &lt;br /&gt;
&lt;br /&gt;
section ‹Demostraciones del teorema›&lt;br /&gt;
&lt;br /&gt;
section ‹Demostraciones automática del teorema›&lt;br /&gt;
&lt;br /&gt;
theorem condicion_necesaria_y_suficiente_A:&lt;br /&gt;
  &amp;quot;x = y^ ⋅ z ⟷ z = y  ⋅ x&amp;quot; &lt;br /&gt;
  using condicion_necesaria  &lt;br /&gt;
        condicion_suficiente &lt;br /&gt;
  by auto&lt;br /&gt;
&lt;br /&gt;
section ‹Demostraciones declarativa detallada del teorema›&lt;br /&gt;
&lt;br /&gt;
theorem condicion_necesaria_y_suficiente:&lt;br /&gt;
  &amp;quot;x = y^ ⋅ z ⟷ z = y  ⋅ x&amp;quot; &lt;br /&gt;
proof (rule iffI)&lt;br /&gt;
  assume &amp;quot;x = y^ ⋅ z&amp;quot;&lt;br /&gt;
  then show &amp;quot;z = y ⋅ x&amp;quot;&lt;br /&gt;
    by (rule condicion_necesaria)&lt;br /&gt;
next&lt;br /&gt;
  assume &amp;quot;z = y ⋅ x&amp;quot;&lt;br /&gt;
  then show &amp;quot;x = y^ ⋅ z&amp;quot;&lt;br /&gt;
    by (rule condicion_suficiente)&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mjoseh</name></author>
		
	</entry>
</feed>