<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="es">
	<id>https://www.glc.us.es/~jalonso/LMF2019/index.php?action=history&amp;feed=atom&amp;title=Examen_3</id>
	<title>Examen 3 - Historial de revisiones</title>
	<link rel="self" type="application/atom+xml" href="https://www.glc.us.es/~jalonso/LMF2019/index.php?action=history&amp;feed=atom&amp;title=Examen_3"/>
	<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/LMF2019/index.php?title=Examen_3&amp;action=history"/>
	<updated>2026-07-19T04:05:03Z</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/LMF2019/index.php?title=Examen_3&amp;diff=810&amp;oldid=prev</id>
		<title>Jalonso en 15:39 8 jul 2019</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/LMF2019/index.php?title=Examen_3&amp;diff=810&amp;oldid=prev"/>
		<updated>2019-07-08T15:39:59Z</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;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:39 8 jul 2019&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>Jalonso</name></author>
		
	</entry>
	<entry>
		<id>https://www.glc.us.es/~jalonso/LMF2019/index.php?title=Examen_3&amp;diff=809&amp;oldid=prev</id>
		<title>Jalonso en 10:33 8 jul 2019</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/LMF2019/index.php?title=Examen_3&amp;diff=809&amp;oldid=prev"/>
		<updated>2019-07-08T10:33:31Z</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:33 8 jul 2019&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-l112&quot; &gt;Línea 112:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Línea 112:&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; &amp;#160;  ∀x y. M x ∧ P y ⟶ Mayor x y&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; &amp;#160;  ∀x y. M x ∧ P y ⟶ Mayor x y&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; &amp;#160;  ∀x y z . Mayor x y ∧ Mayor y z ⟶ Mayor x z&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; &amp;#160;  ∀x y z . Mayor x y ∧ Mayor y z ⟶ Mayor x z&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;&amp;#160;&amp;#160; &amp;#160;  ∀x. ¬(Mayor x x)&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot;&lt;/del&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;#160;&amp;#160; &amp;#160;  ∀x. ¬(Mayor x x)&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;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; Demostrar detalladamente que la fórmula&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; Demostrar detalladamente que la fórmula&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/LMF2019/index.php?title=Examen_3&amp;diff=808&amp;oldid=prev</id>
		<title>Jalonso en 10:31 8 jul 2019</title>
		<link rel="alternate" type="text/html" href="https://www.glc.us.es/~jalonso/LMF2019/index.php?title=Examen_3&amp;diff=808&amp;oldid=prev"/>
		<updated>2019-07-08T10:31:08Z</updated>

		<summary type="html">&lt;p&gt;&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;text ‹Examen de Lógica Matemática y Fundamentos (5 julio 2019)›&lt;br /&gt;
&lt;br /&gt;
theory examen_3_05_jul_sol&lt;br /&gt;
imports Main &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
text ‹Nota: En las demostraciones se pueden las reglas básicas de &lt;br /&gt;
  deducción natural de la lógica proposicional, de los cuantificadores &lt;br /&gt;
  y de la igualdad:  &lt;br /&gt;
  · conjI:      ⟦P; Q⟧ ⟹ P ∧ Q&lt;br /&gt;
  · conjunct1:  P ∧ Q ⟹ P&lt;br /&gt;
  · conjunct2:  P ∧ Q ⟹ Q  &lt;br /&gt;
  · notnotD:    ¬¬ P ⟹ P&lt;br /&gt;
  · mp:         ⟦P ⟶ Q; P⟧ ⟹ Q &lt;br /&gt;
  · impI:       (P ⟹ Q) ⟹ P ⟶ Q&lt;br /&gt;
  · disjI1:     P ⟹ P ∨ Q&lt;br /&gt;
  · disjI2:     Q ⟹ P ∨ Q&lt;br /&gt;
  · disjE:      ⟦P ∨ Q; P ⟹ R; Q ⟹ R⟧ ⟹ R &lt;br /&gt;
  · FalseE:     False ⟹ P&lt;br /&gt;
  · notE:       ⟦¬P; P⟧ ⟹ R&lt;br /&gt;
  · notI:       (P ⟹ False) ⟹ ¬P&lt;br /&gt;
  · iffI:       ⟦P ⟹ Q; Q ⟹ P⟧ ⟹ P = Q&lt;br /&gt;
  · iffD1:      ⟦Q = P; Q⟧ ⟹ P &lt;br /&gt;
  · iffD2:      ⟦P = Q; Q⟧ ⟹ P&lt;br /&gt;
  · ccontr:     (¬P ⟹ False) ⟹ P&lt;br /&gt;
  · excluded_middle: (¬P ∨ P) &lt;br /&gt;
&lt;br /&gt;
  · allE:       ⟦∀x. P x; P x ⟹ R⟧ ⟹ R&lt;br /&gt;
  · allI:       (⋀x. P x) ⟹ ∀x. P x&lt;br /&gt;
  · exI:        P x ⟹ ∃x. P x&lt;br /&gt;
  · exE:        ⟦∃x. P x; ⋀x. P x ⟹ Q⟧ ⟹ Q&lt;br /&gt;
&lt;br /&gt;
  · refl:       t = t&lt;br /&gt;
  · subst:      ⟦s = t; P s⟧ ⟹ P t&lt;br /&gt;
  · trans:      ⟦r = s; s = t⟧ ⟹ r = t&lt;br /&gt;
  · sym:        s = t ⟹ t = s&lt;br /&gt;
  · not_sym:    t ≠ s ⟹ s ≠ t&lt;br /&gt;
  · ssubst:     ⟦t = s; P s⟧ ⟹ P t&lt;br /&gt;
  · box_equals: ⟦a = b; a = c; b = d⟧ ⟹ c = d&lt;br /&gt;
  · arg_cong:   x = y ⟹ f x = f y&lt;br /&gt;
  · fun_cong:   f = g ⟹ f x = g x&lt;br /&gt;
  · cong:       ⟦f = g; x = y⟧ ⟹ f x = g y&lt;br /&gt;
&lt;br /&gt;
  También se pueden usar las reglas notnotI y mt que demostramos a&lt;br /&gt;
  continuación. ›&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. (2.5 puntos) Demostrar detalladamente que la siguiente&lt;br /&gt;
  fórmula es una tautología: &lt;br /&gt;
     p ∨ (q ⟶ ¬(p ⟷ q))&lt;br /&gt;
&lt;br /&gt;
  Nota: No usar ninguno de los métodos automáticos: simp, simp_all, &lt;br /&gt;
  auto, blast, force, fast, arith o metis&lt;br /&gt;
  --------------------------------------------------------------------›&lt;br /&gt;
&lt;br /&gt;
(* Demostración declarativa. *)&lt;br /&gt;
lemma &amp;quot;p ∨ (q ⟶ ¬(p ⟷ q))&amp;quot;&lt;br /&gt;
proof - &lt;br /&gt;
  have &amp;quot;¬p ∨ p&amp;quot; by (rule excluded_middle)&lt;br /&gt;
  then show &amp;quot;p ∨ (q ⟶ ¬(p ⟷ q))&amp;quot;&lt;br /&gt;
  proof&lt;br /&gt;
    assume &amp;quot;¬p&amp;quot;&lt;br /&gt;
    have &amp;quot;q ⟶ ¬(p ⟷ q)&amp;quot;&lt;br /&gt;
    proof&lt;br /&gt;
      assume &amp;quot;q&amp;quot;&lt;br /&gt;
      show &amp;quot;¬(p ⟷ q)&amp;quot;&lt;br /&gt;
      proof&lt;br /&gt;
        assume &amp;quot;p ⟷ q&amp;quot;&lt;br /&gt;
        then have &amp;quot;p&amp;quot; using `q` by (rule iffD2)&lt;br /&gt;
        with `¬p` show False by (rule notE)&lt;br /&gt;
      qed&lt;br /&gt;
    qed&lt;br /&gt;
    then show &amp;quot;p ∨ (q ⟶ ¬(p ⟷ q))&amp;quot; by (rule disjI2)&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;p&amp;quot;&lt;br /&gt;
    then show &amp;quot;p ∨ (q ⟶ ¬(p ⟷ q))&amp;quot; by (rule disjI1)&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Demostración aplicativa. *)&lt;br /&gt;
lemma &amp;quot;p ∨ (q ⟶ ¬(p ⟷ q))&amp;quot;&lt;br /&gt;
  apply (case_tac &amp;quot;p&amp;quot;)&lt;br /&gt;
   apply (erule disjI1)&lt;br /&gt;
  apply (rule disjI2) &lt;br /&gt;
  apply (rule impI)&lt;br /&gt;
  apply (rule notI)&lt;br /&gt;
  apply (drule iffD2)&lt;br /&gt;
   apply assumption&lt;br /&gt;
  apply (erule notE)&lt;br /&gt;
  apply assumption&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
text ‹-----------------------------------------------------------------&lt;br /&gt;
  Ejercicio 2. (2.5 puntos) Se puede formalizar la teoría de las tallas&lt;br /&gt;
  usando los siguientes símbolos&lt;br /&gt;
     P x       representa que x es de la talla pequeña&lt;br /&gt;
     M x       representa que x es de la talla mediana&lt;br /&gt;
     G x       representa que x es de la talla grande&lt;br /&gt;
     Mayor x y representa que la talla de x es mayor que la de y.&lt;br /&gt;
&lt;br /&gt;
  Los axiomas de las tallas son&lt;br /&gt;
     ∃x. P x&lt;br /&gt;
     ∃x. M x&lt;br /&gt;
     ∃x. G x&lt;br /&gt;
     ∀x y. G x ∧ M y ⟶ Mayor x y&lt;br /&gt;
     ∀x y. M x ∧ P y ⟶ Mayor x y&lt;br /&gt;
     ∀x y z . Mayor x y ∧ Mayor y z ⟶ Mayor x z&lt;br /&gt;
     ∀x. ¬(Mayor x x)&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
  Demostrar detalladamente que la fórmula&lt;br /&gt;
      ∀x. ¬(P x) ∨ ¬(M x)&lt;br /&gt;
  es consecuencia de los axiomas de las tallas.&lt;br /&gt;
&lt;br /&gt;
  Nota: No usar ninguno de los métodos automáticos: simp, simp_all, &lt;br /&gt;
  auto, blast, force, fast, arith o metis&lt;br /&gt;
  --------------------------------------------------------------------›&lt;br /&gt;
&lt;br /&gt;
(* Demostración declarativa *)&lt;br /&gt;
lemma&lt;br /&gt;
  assumes &amp;quot;∃x. P x&amp;quot;&lt;br /&gt;
          &amp;quot;∃x. M x&amp;quot;&lt;br /&gt;
          &amp;quot;∃x. G x&amp;quot;&lt;br /&gt;
          &amp;quot;∀x y. G x ∧ M y ⟶ Mayor x y&amp;quot;&lt;br /&gt;
          &amp;quot;∀x y. M x ∧ P y ⟶ Mayor x y&amp;quot;&lt;br /&gt;
          &amp;quot;∀x y z . Mayor x y ∧ Mayor y z ⟶ Mayor x z&amp;quot;&lt;br /&gt;
          &amp;quot;∀x. ¬(Mayor x x)&amp;quot;&lt;br /&gt;
  shows &amp;quot;∀x. ¬(P x) ∨ ¬(M x)&amp;quot;&lt;br /&gt;
proof&lt;br /&gt;
  fix a&lt;br /&gt;
  have &amp;quot;¬(P a) ∨ P a&amp;quot; by (rule excluded_middle)&lt;br /&gt;
  then show &amp;quot;¬(P a) ∨ ¬(M a)&amp;quot;&lt;br /&gt;
  proof&lt;br /&gt;
    assume &amp;quot;¬(P a)&amp;quot;&lt;br /&gt;
    then show &amp;quot;¬(P a) ∨ ¬(M a)&amp;quot; by (rule disjI1)&lt;br /&gt;
  next&lt;br /&gt;
    assume &amp;quot;P a&amp;quot;&lt;br /&gt;
    have &amp;quot;~(M a)&amp;quot;&lt;br /&gt;
    proof&lt;br /&gt;
      assume &amp;quot;M a&amp;quot;&lt;br /&gt;
      have &amp;quot;~(Mayor a a)&amp;quot; using assms(7) by (rule allE)&lt;br /&gt;
      moreover&lt;br /&gt;
      have &amp;quot;Mayor a a&amp;quot;&lt;br /&gt;
      proof -&lt;br /&gt;
        have &amp;quot;∀y. M a ∧ P y ⟶ Mayor a y&amp;quot; using assms(5) by (rule allE)&lt;br /&gt;
        then have &amp;quot;M a ∧ P a ⟶ Mayor a a&amp;quot;  by (rule allE)&lt;br /&gt;
        moreover&lt;br /&gt;
        have &amp;quot;M a ∧ P a&amp;quot; using `M a` `P a` by (rule conjI)&lt;br /&gt;
        ultimately show &amp;quot;Mayor a a&amp;quot;  by (rule mp)&lt;br /&gt;
      qed  &lt;br /&gt;
      ultimately show False by (rule notE) &lt;br /&gt;
    qed&lt;br /&gt;
    then show &amp;quot;¬ P a ∨ ¬ M a&amp;quot; by (rule disjI2)&lt;br /&gt;
  qed&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
(* Demostración aplicativa *)&lt;br /&gt;
lemma &amp;quot;⟦∃x. P x;&lt;br /&gt;
        ∃x. M x;&lt;br /&gt;
        ∃x. G x;&lt;br /&gt;
        ∀x y. M x ∧ P y ⟶ Mayor x y;&lt;br /&gt;
        ∀x y. G x ∧ M y ⟶ Mayor x y;&lt;br /&gt;
        ∀x y z . Mayor x y ∧ Mayor y z ⟶ Mayor x z;&lt;br /&gt;
        ∀x. ¬(Mayor x x)⟧⟹&lt;br /&gt;
                             ∀x. ¬(P x) ∨ ¬(M x)&amp;quot;&lt;br /&gt;
  apply (rule allI)&lt;br /&gt;
  apply (case_tac &amp;quot;P x&amp;quot;)&lt;br /&gt;
   prefer 2&lt;br /&gt;
   apply (rule disjI1, assumption)&lt;br /&gt;
  apply (rule disjI2)&lt;br /&gt;
  apply (rule notI)&lt;br /&gt;
  apply (erule_tac x = x in allE)&lt;br /&gt;
  apply (erule_tac x = x in allE)&lt;br /&gt;
  apply (erule_tac x = x in allE)&lt;br /&gt;
  apply (erule_tac x = x in allE)&lt;br /&gt;
  apply (erule_tac x = x in allE)&lt;br /&gt;
  apply (erule notE)&lt;br /&gt;
  apply (drule mp)&lt;br /&gt;
   apply (rule conjI, assumption+)&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
text ‹-----------------------------------------------------------------&lt;br /&gt;
  Ejercicio 3 (2.5 puntos) 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 usa un acumulador. Por &lt;br /&gt;
    ejemplo, &lt;br /&gt;
       nHojasA (N e (N c H H) (N g H H)) = 4&lt;br /&gt;
 &lt;br /&gt;
  Demostrar estructuradamente (es decir, mediante una demostración &lt;br /&gt;
  declarativa) que las funciones nHojas y nHojasA son equivalentes; &lt;br /&gt;
  es decir,&lt;br /&gt;
     nHojasA a = nHojas a&lt;br /&gt;
&lt;br /&gt;
  Notas: &lt;br /&gt;
  1. Los únicos métodos que se pueden usar son induct, (simp only: ...)&lt;br /&gt;
     y this.&lt;br /&gt;
  2. En las demostraciones por introducción del cuantificador universal&lt;br /&gt;
     hay que explicitar el tipo de las variables introducidas con fix.&lt;br /&gt;
     Por ejemplo, en lugar de   &lt;br /&gt;
          fix x t n&lt;br /&gt;
     hay que escribir&lt;br /&gt;
          fix x :: &amp;#039;a and t :: &amp;quot;&amp;#039;a arbol&amp;quot; and and n :: nat&lt;br /&gt;
  -------------------------------------------------------------------›&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;
lemma nHojasA:&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; by (simp only: nHojasAaux.simps(1))&lt;br /&gt;
  also have &amp;quot;… = nHojas H + n&amp;quot; by (simp only: nHojas.simps(1))&lt;br /&gt;
  finally show &amp;quot;nHojasAaux H n = nHojas H + n&amp;quot; by this&lt;br /&gt;
next&lt;br /&gt;
  fix x :: &amp;#039;a and &lt;br /&gt;
      i :: &amp;quot;&amp;#039;a arbol&amp;quot; and&lt;br /&gt;
      d :: &amp;quot;&amp;#039;a arbol&amp;quot; and&lt;br /&gt;
      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 (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;
(* Demostración aplicativa del lema anterior *)&lt;br /&gt;
lemma &amp;quot;nHojasAaux a n = (nHojas a) + n&amp;quot;&lt;br /&gt;
  apply (induct a arbitrary: n)&lt;br /&gt;
   apply (simp only: nHojasAaux.simps(1))&lt;br /&gt;
   apply (simp only: nHojas.simps(1))&lt;br /&gt;
  apply (simp only: nHojasAaux.simps(2))&lt;br /&gt;
  apply (simp only: nHojas.simps(2))&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
lemma &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; by (simp only: nHojasA_def)&lt;br /&gt;
  also have &amp;quot;… = (nHojas a)&amp;quot; by (simp only: nHojasA)&lt;br /&gt;
  finally show &amp;quot;nHojasA a = nHojas a&amp;quot; by this&lt;br /&gt;
qed&lt;br /&gt;
&lt;br /&gt;
text ‹--------------------------------------------------------------- &lt;br /&gt;
  Ejercicio 4. (2.5 puntos) Demostrar detalladamente que los grupos &lt;br /&gt;
  booleanos son conmutativos; es decir, si G un grupo tal que  &lt;br /&gt;
     x ⋅ x = 1 &lt;br /&gt;
  para todo x de G, entonces&lt;br /&gt;
     x ⋅ y = y ⋅ x &lt;br /&gt;
  para todo x, y de G.&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;
  Nota: Los únicos métodos que se pueden usar son (simp only: ...) o &lt;br /&gt;
  rule.&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;
(* Una demostración declarativa es *)&lt;br /&gt;
lemma&lt;br /&gt;
  assumes &amp;quot;∀x. x ⋅ x = 𝟭&amp;quot;&lt;br /&gt;
  shows   &amp;quot;∀x. ∀y. x ⋅ y = y ⋅ x&amp;quot;&lt;br /&gt;
proof (rule allI)+&lt;br /&gt;
  fix a b&lt;br /&gt;
  show &amp;quot;a ⋅ b = b ⋅ a&amp;quot;&lt;br /&gt;
  proof -&lt;br /&gt;
    have &amp;quot;(b ⋅ a) ⋅ (b ⋅ a) = 𝟭&amp;quot; by (simp only: assms)&lt;br /&gt;
    then have &amp;quot;b ⋅ ((b ⋅ a) ⋅ (b ⋅ a)) = b ⋅ 𝟭&amp;quot; by (rule arg_cong)&lt;br /&gt;
    then have &amp;quot;b ⋅ ((b ⋅ a) ⋅ (b ⋅ a)) = b&amp;quot; by (simp only: neutro_d)&lt;br /&gt;
    then have &amp;quot;(b ⋅ b) ⋅ (a ⋅ (b ⋅ a)) = b&amp;quot; by (simp only: asociativa)&lt;br /&gt;
    then have &amp;quot;𝟭 ⋅ (a ⋅ (b ⋅ a)) = b&amp;quot; by (simp only: assms)&lt;br /&gt;
    then have &amp;quot;a ⋅ (b ⋅ a) = b&amp;quot; by (simp only: neutro_i)&lt;br /&gt;
    then have &amp;quot;(a ⋅ (b ⋅ a)) ⋅ a = b ⋅ a&amp;quot; by (rule arg_cong)&lt;br /&gt;
    then have &amp;quot;(a ⋅ b) ⋅ (a ⋅ a) = b ⋅ a&amp;quot; by (simp only: asociativa)&lt;br /&gt;
    then have &amp;quot;(a ⋅ b) ⋅ 𝟭 = b ⋅ a&amp;quot; by (simp only: assms)&lt;br /&gt;
    then show &amp;quot;a ⋅ b = b ⋅ a&amp;quot; by (simp only: neutro_d)&lt;br /&gt;
  qed &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>Jalonso</name></author>
		
	</entry>
</feed>