{"id":8045,"date":"2023-11-05T08:33:01","date_gmt":"2023-11-05T07:33:01","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/?p=8045"},"modified":"2023-11-05T08:33:01","modified_gmt":"2023-11-05T07:33:01","slug":"05-nov-23","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/05-nov-23\/","title":{"rendered":"La semana en Calculemus (5 de noviembre de 2023)"},"content":{"rendered":"\n<p>Esta semana he publicado en <a href=\"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/\">Calculemus<\/a> las demostraciones con Lean4 de las siguientes propiedades:<\/p>\n<ul>\n<li><a href=\"#ej1\">1. La suma de dos funciones acotadas superiormente tambi\u00e9n lo est\u00e1<\/a><\/li>\n<li><a href=\"#ej2\">2. La suma de dos funciones acotadas inferiormente tambi\u00e9n lo est\u00e1<\/a><\/li>\n<li><a href=\"#ej3\">3. Si a es una cota superior de f y c \u2265 0, entonces ca es una cota superior de cf<\/a><\/li>\n<li><a href=\"#ej4\">4. Si c \u2265 0 y f est\u00e1 acotada superiormente, entonces c\u00b7f tambi\u00e9n lo est\u00e1<\/a><\/li>\n<li><a href=\"#ej5\">5. Si x e y son sumas de dos cuadrados, entonces xy tambi\u00e9n lo es<\/a><\/li>\n<\/ul>\n<p>A continuaci\u00f3n se muestran las soluciones.<br \/>\n<!--more--><br \/>\n<a name=\"ej1\"><\/a><\/p>\n<h3>1. La suma de dos funciones acotadas superiormente tambi\u00e9n lo est\u00e1<\/h3>\n<p>Demostrar con Lean4 que la suma de dos funciones acotadas superiormente tambi\u00e9n lo est\u00e1.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\nimport src.Suma_de_cotas_superiores\nvariable {f g : \u211d \u2192 \u211d}\n\n-- (acotadaSup f) afirma que f tiene cota superior.\ndef acotadaSup (f : \u211d \u2192 \u211d) :=\n  \u2203 a, CotaSuperior f a\n\nexample\n  (hf : acotadaSup f)\n  (hg : acotadaSup g)\n  : acotadaSup (f + g) :=\nby sorry\n<\/pre>\n<p><b>Demostraci\u00f3n en lenguaje natural<\/b><\/p>\n<p>Del ejercicio <a href=\"https:\/\/bit.ly\/3QauluK\">La suma de una cota superior de f y una cota superior de g es una cota superior de f+g<\/a> usaremos la definici\u00f3n de cota superior (<code>CotaSuperior<\/code>) y el lema <code>sumaCotaSup<\/code>.<\/p>\n<p>Puesto que &#92;(f&#92;) est\u00e1 acotada superiormente, tiene una cota superior. Sea &#92;(a&#92;) una de dichas cotas. An\u00e1logamentte, puesto que &#92;(g&#92;) est\u00e1 acotada superiormente, tiene una cota superior. Sea &#92;(b&#92;) una de dichas cotas. Por el lema sumaCotaSup, &#92;(a+b&#92;) es una cota superior de &#92;(f+g&#92;). Por consiguiente, &#92;(f+g&#92;) est\u00e1 acotada superiormente.<\/p>\n<p><b>Demostraciones con Lean4<\/b><\/p>\n<pre lang=\"lean\">\nimport src.Suma_de_cotas_superiores\n\nvariable {f g : \u211d \u2192 \u211d}\n\n-- (acotadaSup f) afirma que f tiene cota superior.\ndef acotadaSup (f : \u211d \u2192 \u211d) :=\n  \u2203 a, CotaSuperior f a\n\n-- 1\u00aa demostraci\u00f3n\nexample\n  (hf : acotadaSup f)\n  (hg : acotadaSup g)\n  : acotadaSup (f + g) :=\nby\n  cases' hf with a ha\n  -- a : \u211d\n  -- ha : CotaSuperior f a\n  cases' hg with b hb\n  -- b : \u211d\n  -- hb : CotaSuperior g b\n  have h1 : CotaSuperior (f + g) (a + b) :=\n    sumaCotaSup ha hb\n  have h2 : \u2203 z, CotaSuperior (f+g) z :=\n    Exists.intro (a + b) h1\n  show acotadaSup (f + g)\n  exact h2\n\n-- 2\u00aa demostraci\u00f3n\nexample\n  (hf : acotadaSup f)\n  (hg : acotadaSup g)\n  : acotadaSup (f + g) :=\nby\n  cases' hf with a ha\n  -- a : \u211d\n  -- ha : FnUb f a\n  cases' hg with b hb\n  -- b : \u211d\n  -- hb : FnUb g b\n  use a + b\n  apply sumaCotaSup ha hb\n\n-- 4\u00aa demostraci\u00f3n\nexample\n  (hf : acotadaSup f)\n  (hg : acotadaSup g)\n  : acotadaSup (f + g) :=\nby\n  rcases hf with \u27e8a, ha\u27e9\n  rcases hg with \u27e8b, hb\u27e9\n  exact \u27e8a + b, sumaCotaSup ha hb\u27e9\n\n-- 5\u00aa demostraci\u00f3n\nexample :\n  acotadaSup f \u2192 acotadaSup g \u2192 acotadaSup (f + g) :=\nby\n  rintro \u27e8a, ha\u27e9 \u27e8b, hb\u27e9\n  exact \u27e8a + b, sumaCotaSup ha hb\u27e9\n\n-- 6\u00aa demostraci\u00f3n\nexample :\n  acotadaSup f \u2192 acotadaSup g \u2192 acotadaSup (f + g) :=\nfun \u27e8a, ha\u27e9 \u27e8b, hb\u27e9 \u21a6 \u27e8a + b, sumaCotaSup ha hb\u27e9\n\n-- Lemas usados\n-- ============\n\n-- #check (sumaCotaSup : CotaSuperior f a \u2192 CotaSuperior g b \u2192 CotaSuperior (f + g) (a + b))\n<\/pre>\n<p><b>Referencias<\/b><\/p>\n<ul>\n<li> J. Avigad y P. Massot. <a href=\"https:\/\/bit.ly\/3U4UjBk\">Mathematics in Lean<\/a>, p. 29.<\/li>\n<\/ul>\n<p><a name=\"ej2\"><\/a><\/p>\n<h3>2. La suma de dos funciones acotadas inferiormente tambi\u00e9n lo est\u00e1<\/h3>\n<p>Demostrar con Lean4 que la suma de dos funciones acotadas inferiormente tambi\u00e9n lo est\u00e1.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\nimport src.Suma_de_cotas_inferiores\nvariable {f g : \u211d \u2192 \u211d}\n\n-- (acotadaInf f) afirma que f tiene cota inferior.\ndef acotadaInf (f : \u211d \u2192 \u211d) :=\n  \u2203 a, CotaInferior f a\n\nexample\n  (hf : acotadaInf f)\n  (hg : acotadaInf g)\n  : acotadaInf (f + g) :=\nby sorry\n<\/pre>\n<p><b>Demostraci\u00f3n en lenguaje natural<\/b><\/p>\n<p>Del ejercicio &#8220;La suma de una cota inferior de &#92;(f&#92;) y una cota inferior de &#92;(g&#92;) es una cota inferior de &#92;(f+g&#92;)&#8221; usaremos la definici\u00f3n de cota inferior (<code>CotaInferior<\/code>) y el lema <code>sumaCotaInf<\/code>.<\/p>\n<p>Puesto que &#92;(f&#92;) est\u00e1 acotada inferiormente, tiene una cota inferior.  &#92;(a&#92;) una de dichas cotas. An\u00e1logamentte, puesto que &#92;(g&#92;) est\u00e1 acotada inferiormente, tiene una cota inferior. Sea &#92;(b&#92;) una de dichas cotas. Por el lema <code>sumaCotaInf<\/code>, a+b es una cota inferior de &#92;(f+g&#92;). Por consiguiente, &#92;(f+g&#92;) est\u00e1 acotada inferiormente.<\/p>\n<p><b>Demostraciones con Lean4<\/b><\/p>\n<pre lang=\"lean\">\nimport src.Suma_de_cotas_inferiores\nvariable {f g : \u211d \u2192 \u211d}\n\n-- (acotadaInf f) afirma que f tiene cota inferior.\ndef acotadaInf (f : \u211d \u2192 \u211d) :=\n  \u2203 a, CotaInferior f a\n\n-- 1\u00aa demostraci\u00f3n\nexample\n  (hf : acotadaInf f)\n  (hg : acotadaInf g)\n  : acotadaInf (f + g) :=\nby\n  cases' hf with a ha\n  -- a : \u211d\n  -- ha : CotaInferior f a\n  cases' hg with b hb\n  -- b : \u211d\n  -- hb : CotaInferior g b\n  have h1 : CotaInferior (f + g) (a + b) := sumaCotaInf ha hb\n  have h2 : \u2203 z, CotaInferior (f + g) z :=\n    Exists.intro (a + b) h1\n  show acotadaInf (f + g)\n  exact h2\n\n-- 2\u00aa demostraci\u00f3n\nexample\n  (hf : acotadaInf f)\n  (hg : acotadaInf g)\n  : acotadaInf (f + g) :=\nby\n  cases' hf with a ha\n  -- a : \u211d\n  -- ha : FnLb f a\n  cases' hg with b hgb\n  -- b : \u211d\n  -- hgb : FnLb g b\n  use a + b\n  -- \u22a2 FnLb (f + g) (a + b)\n  apply sumaCotaInf ha hgb\n\n-- 3\u00aa demostraci\u00f3n\nexample\n  (hf : acotadaInf f)\n  (hg : acotadaInf g)\n  : acotadaInf (f + g) :=\nby\n  rcases hf with \u27e8a, ha\u27e9\n  -- a : \u211d\n  -- ha : FnLb f a\n  rcases hg with \u27e8b, hb\u27e9\n  -- b : \u211d\n  -- hb : FnLb g b\n  exact \u27e8a + b, sumaCotaInf ha hb\u27e9\n\n-- 4\u00aa demostraci\u00f3n\nexample :\n  acotadaInf f \u2192 acotadaInf g \u2192 acotadaInf (f + g) :=\nby\n  rintro \u27e8a, ha\u27e9 \u27e8b, hb\u27e9\n  -- a : \u211d\n  -- ha : FnLb f a\n  -- b : \u211d\n  -- hb : FnLb g b\n  exact \u27e8a + b, sumaCotaInf ha hb\u27e9\n\n-- 5\u00aa demostraci\u00f3n\nexample :\n  acotadaInf f \u2192 acotadaInf g \u2192 acotadaInf (f + g) :=\nfun \u27e8a, ha\u27e9 \u27e8b, hb\u27e9 \u21a6 \u27e8a + b, sumaCotaInf ha hb\u27e9\n\n-- Lemas usados\n-- ============\n\n-- #check (sumaCotaInf : FnLb f a \u2192 FnLb g b \u2192 FnLb (f + g) (a + b))\n<\/pre>\n<p><b>Referencias<\/b><\/p>\n<ul>\n<li> J. Avigad y P. Massot. <a href=\"https:\/\/bit.ly\/3U4UjBk\">Mathematics in Lean<\/a>, p. 29.<\/li>\n<\/ul>\n<p><a name=\"ej3\"><\/a><\/p>\n<h3>3. Si a es una cota superior de f y c \u2265 0, entonces ca es una cota superior de cf<\/h3>\n<p>Demostrar con Lean4 que si &#92;(a&#92;) es una cota superior de &#92;(f&#92;) y &#92;(c \u2265 0&#92;), entonces &#92;(ca&#92;) es una cota superior de &#92;(cf&#92;).<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\nimport Mathlib.Data.Real.Basic\n\n-- (CotaSuperior f a) se verifica si a es una cota superior de f.\ndef CotaSuperior (f : \u211d \u2192 \u211d) (a : \u211d) : Prop :=\n  \u2200 x, f x \u2264 a\n\nvariable {f : \u211d \u2192 \u211d}\nvariable {c : \u211d}\n\nexample\n  (hfa : CotaSuperior f a)\n  (h : c \u2265 0)\n  : CotaSuperior (fun x \u21a6 c * f x) (c * a) :=\nby sorry\n<\/pre>\n<p><b>Demostraci\u00f3n en lenguaje natural<\/b><\/p>\n<p>Se usar\u00e1 el lema<br \/>\n&#92;[ &#92;{b \u2264 c, 0 \u2264 a&#92;} \u22a2 ab \u2264 ac &#92;tag{L1} &#92;]<\/p>\n<p>Tenemos que demostrar que<br \/>\n&#92;[ (\u2200 y \u2208 \u211d) cf(y) \u2264 ca &#92;]<br \/>\nSea &#92;(y \u2208 R&#92;). Puesto que &#92;(a&#92;) es una cota de &#92;(f&#92;), se tiene que<br \/>\n&#92;[ f(y) \u2264 a &#92;]<br \/>\nque, junto con &#92;(c \u2265 0&#92;), por el lema L1 nos da<br \/>\n&#92;[ cf(y) \u2264 ca &#92;]<\/p>\n<p><b>Demostraciones con Lean4<\/b><\/p>\n<pre lang=\"lean\">\nimport Mathlib.Data.Real.Basic\n\n-- (CotaSuperior f a) se verifica si a es una cota superior de f.\ndef CotaSuperior (f : \u211d \u2192 \u211d) (a : \u211d) : Prop :=\n  \u2200 x, f x \u2264 a\n\nvariable {f : \u211d \u2192 \u211d}\nvariable {c : \u211d}\n\n-- 1\u00aa demostraci\u00f3n\nexample\n  (hfa : CotaSuperior f a)\n  (h : c \u2265 0)\n  : CotaSuperior (fun x \u21a6 c * f x) (c * a) :=\nby\n  intro y\n  -- y : \u211d\n  -- \u22a2 (fun x => c * f x) y \u2264 c * a\n  have ha : f y \u2264 a := hfa y\n  calc (fun x => c * f x) y\n       = c * f y := by rfl\n     _ \u2264 c * a   := mul_le_mul_of_nonneg_left ha h\n\n-- 2\u00aa demostraci\u00f3n\nexample\n  (hfa : CotaSuperior f a)\n  (h : c \u2265 0)\n  : CotaSuperior (fun x \u21a6 c * f x) (c * a) :=\nby\n  intro y\n  calc (fun x => c * f x) y\n       = c * f y := by rfl\n     _ \u2264 c * a   := mul_le_mul_of_nonneg_left (hfa y) h\n\n-- 3\u00aa demostraci\u00f3n\nexample\n  (hfa : CotaSuperior f a)\n  (h : c \u2265 0)\n  : CotaSuperior (fun x \u21a6 c * f x) (c * a) :=\nby\n  intro y\n  show (fun x => c * f x) y \u2264 c * a\n  exact mul_le_mul_of_nonneg_left (hfa y) h\n\n-- 4\u00aa demostraci\u00f3n\nlemma CotaSuperior_mul\n  (hfa : CotaSuperior f a)\n  (h : c \u2265 0)\n  : CotaSuperior (fun x \u21a6 c * f x) (c * a) :=\nfun y \u21a6 mul_le_mul_of_nonneg_left (hfa y) h\n\n-- Lemas usados\n-- ============\n\n-- variable (c : \u211d)\n-- #check (mul_le_mul_of_nonneg_left : b \u2264 c \u2192 0 \u2264 a \u2192 a * b \u2264 a * c)\n<\/pre>\n<p><b>Demostraciones interactivas<\/b><\/p>\n<p>Se puede interactuar con las demostraciones anteriores en <a href=\"https:\/\/live.lean-lang.org\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus2\/main\/src\/Cota_superior_de_producto_por_escalar.lean\" rel=\"noopener noreferrer\" target=\"_blank\">Lean 4 Web<\/a>.<\/p>\n<p><b>Referencias<\/b><\/p>\n<ul>\n<li> J. Avigad y P. Massot. <a href=\"https:\/\/bit.ly\/3U4UjBk\">Mathematics in Lean<\/a>, p. 29.<\/li>\n<\/ul>\n<p><a name=\"ej4\"><\/a><\/p>\n<h3>4. Si c \u2265 0 y f est\u00e1 acotada superiormente, entonces c\u00b7f tambi\u00e9n lo est\u00e1<\/h3>\n<p>Demostrar con Lean4 que si &#92;(c \u2265 0&#92;) y &#92;(f&#92;) est\u00e1 acotada superiormente, entonces &#92;(c\u00b7f&#92;) tambi\u00e9n lo est\u00e1.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\nimport src.Cota_superior_de_producto_por_escalar\n\nvariable {f : \u211d \u2192 \u211d}\nvariable {c : \u211d}\n\n-- (acotadaSup f) afirma que f tiene cota superior.\ndef acotadaSup (f : \u211d \u2192 \u211d) :=\n  \u2203 a, CotaSuperior f a\n\nexample\n  (hf : acotadaSup f)\n  (hc : c \u2265 0)\n  : acotadaSup (fun x \u21a6 c * f x) :=\nby sorry\n<\/pre>\n<p><b>Demostraci\u00f3n en lenguaje natural<\/b><\/p>\n<p>Usaremos el siguiente lema:<br \/>\n&#92;begin{align}<br \/>\n&#8220;&#92;text{Si } a &#92;text{ es cota superior de } f &#92;text{ y } c \u2265 0&#92;text{, entonces } c\u00b7a &#92;text{ es cota superior de } c\u00b7f&#8221;<br \/>\n&#92;end{align}<\/p>\n<p>Puesto que &#92;(f&#92;) est\u00e1 acotada superiormente, tiene una cota superior. Sea &#92;(a&#92;) una de dichas cotas. Entonces, por el lema, &#92;(c\u00b7a&#92;) es una cota superior de &#92;(c\u00b7f&#92;). Por consiguiente, &#92;(c\u00b7f&#92;) est\u00e1 acotada superiormente.<\/p>\n<p><b>Demostraciones con Lean4<\/b><\/p>\n<pre lang=\"lean\">\nimport src.Cota_superior_de_producto_por_escalar\n\nvariable {f : \u211d \u2192 \u211d}\nvariable {c : \u211d}\n\n-- (acotadaSup f) afirma que f tiene cota superior.\ndef acotadaSup (f : \u211d \u2192 \u211d) :=\n  \u2203 a, CotaSuperior f a\n\n-- 1\u00aa demostraci\u00f3n\nexample\n  (hf : acotadaSup f)\n  (hc : c \u2265 0)\n  : acotadaSup (fun x \u21a6 c * f x) :=\nby\n  cases' hf with a ha\n  -- a : \u211d\n  -- ha : CotaSuperior f a\n  have h1 : CotaSuperior (fun x \u21a6 c * f x) (c * a) :=\n    CotaSuperior_mul ha hc\n  have h2 : \u2203 z, \u2200 x, (fun x \u21a6 c * f x) x \u2264 z :=\n    Exists.intro (c * a) h1\n  show acotadaSup (fun x \u21a6 c * f x)\n  exact h2\n\n-- 2\u00aa demostraci\u00f3n\nexample\n  (hf : acotadaSup f)\n  (hc : c \u2265 0)\n  : acotadaSup (fun x \u21a6 c * f x) :=\nby\n  cases' hf with a ha\n  -- a : \u211d\n  -- ha : CotaSuperior f a\n  use c * a\n  -- \u22a2 CotaSuperior (fun x => c * f x) (c * a)\n  apply CotaSuperior_mul ha hc\n\n-- 3\u00aa demostraci\u00f3n\nexample\n  (hf : acotadaSup f)\n  (hc : c \u2265 0)\n  : acotadaSup (fun x \u21a6 c * f x) :=\nby\n  rcases hf with \u27e8a, ha\u27e9\n  -- a : \u211d\n  -- ha : CotaSuperior f a\n  exact \u27e8c * a, CotaSuperior_mul ha hc\u27e9\n\n-- 4\u00aa demostraci\u00f3n\nexample\n  (hc : c \u2265 0)\n  : acotadaSup f \u2192 acotadaSup (fun x \u21a6 c * f x) :=\nby\n  rintro \u27e8a, ha\u27e9\n  -- a : \u211d\n  -- ha : CotaSuperior f a\n  exact \u27e8c * a, CotaSuperior_mul ha hc\u27e9\n\n-- 5\u00aa demostraci\u00f3n\nexample\n  (hc : c \u2265 0)\n  : acotadaSup f \u2192 acotadaSup (fun x \u21a6 c * f x) :=\nfun \u27e8a, ha\u27e9 \u21a6 \u27e8c * a, CotaSuperior_mul ha hc\u27e9\n\n-- Lemas usados\n-- ============\n\n-- #check (CotaSuperior_mul : CotaSuperior f a \u2192 c \u2265 0 \u2192 CotaSuperior (fun x \u21a6 c * f x) (c * a))\n<\/pre>\n<p><b>Referencias<\/b><\/p>\n<ul>\n<li> J. Avigad y P. Massot. <a href=\"https:\/\/bit.ly\/3U4UjBk\">Mathematics in Lean<\/a>, p. 29.<\/li>\n<\/ul>\n<p><a name=\"ej5\"><\/a><\/p>\n<h3>5. Si x e y son sumas de dos cuadrados, entonces xy tambi\u00e9n lo es<\/h3>\n<p>Demostrar con Lean4 que si &#92;(x&#92;) e &#92;(y&#92;) son sumas de dos cuadrados, entonces &#92;(xy&#92;) tambi\u00e9n lo es<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\nimport Mathlib.Tactic\nvariable {\u03b1 : Type _} [CommRing \u03b1]\nvariable {x y : \u03b1}\n\n-- (suma_de_cuadrados x) afirma que x se puede escribir como la suma\n-- de dos cuadrados.\ndef suma_de_cuadrados (x : \u03b1) :=\n  \u2203 a b, x = a^2 + b^2\n\nexample\n  (hx : suma_de_cuadrados x)\n  (hy : suma_de_cuadrados y)\n  : suma_de_cuadrados (x * y) :=\nby sorry\n<\/pre>\n<p><b>Demostraci\u00f3n en lenguaje natural<\/b><\/p>\n<p>Puesto que &#92;(x&#92;) e &#92;(y&#92;) se pueden escribir como la suma de dos cuadrados, existen &#92;(a&#92;), &#92;(b&#92;) , &#92;(c&#92;) y &#92;(d&#92;) tales que<br \/>\n&#92;begin{align}<br \/>\n   x &amp;= a\u00b2 + b\u00b2 &#92;&#92;<br \/>\n   y &amp;= c\u00b2 + d\u00b2<br \/>\n&#92;end{align}<br \/>\nEntonces,<br \/>\n&#92;begin{align}<br \/>\n   xy &amp;= (a\u00b2 + b\u00b2)(c\u00b2 + d\u00b2) &#92;&#92;<br \/>\n      &amp;= a\u00b2c\u00b2 + b\u00b2d\u00b2 + a\u00b2d\u00b2 + b\u00b2c\u00b2 &#92;&#92;<br \/>\n      &amp;= a\u00b2c\u00b2 &#8211; 2acbd + b\u00b2d\u00b2 + a\u00b2d\u00b2 + 2adbc + b\u00b2c\u00b2 &#92;&#92;<br \/>\n      &amp;= (ac &#8211; bd)\u00b2 + (ad + bc)\u00b2<br \/>\n&#92;end{align}<br \/>\nPor tanto, &#92;(xy&#92;) es la suma de dos cuadrados.<\/p>\n<p><b>Demostraciones con Lean4<\/b><\/p>\n<pre lang=\"lean\">\nimport Mathlib.Tactic\nvariable {\u03b1 : Type _} [CommRing \u03b1]\nvariable {x y : \u03b1}\n\n-- (suma_de_cuadrados x) afirma que x se puede escribir como la suma\n-- de dos cuadrados.\ndef suma_de_cuadrados (x : \u03b1) :=\n  \u2203 a b, x = a^2 + b^2\n\n-- 1\u00aa demostraci\u00f3n\nexample\n  (hx : suma_de_cuadrados x)\n  (hy : suma_de_cuadrados y)\n  : suma_de_cuadrados (x * y) :=\nby\n  rcases hx with \u27e8a, b, xeq : x = a^2 + b^2\u27e9\n  -- a b : \u03b1\n  -- xeq : x = a ^ 2 + b ^ 2\n  rcases hy with \u27e8c, d, yeq : y = c^2 + d^2\u27e9\n  -- c d : \u03b1\n  -- yeq : y = c ^ 2 + d ^ 2\n  have h1: x * y = (a*c - b*d)^2 + (a*d + b*c)^2 :=\n    calc x * y\n         = (a^2 + b^2) * (c^2 + d^2) :=\n                by rw [xeq, yeq]\n       _ = a^2*c^2 + b^2*d^2 + a^2*d^2 + b^2*c^2 :=\n                by ring\n       _ = a^2*c^2 - 2*a*c*b*d + b^2*d^2 + a^2*d^2 + 2*a*d*b*c + b^2*c^2 :=\n                by ring\n       _ = (a*c - b*d)^2 + (a*d + b*c)^2 :=\n                by ring\n  have h2 : \u2203 f, x * y = (a*c - b*d)^2 + f^2 :=\n    Exists.intro (a*d + b*c) h1\n  have h3 : \u2203 e f, x * y = e^2 + f^2 :=\n    Exists.intro (a*c - b*d) h2\n  show suma_de_cuadrados (x * y)\n  exact h3\n\n-- 2\u00aa demostraci\u00f3n\nexample\n  (hx : suma_de_cuadrados x)\n  (hy : suma_de_cuadrados y)\n  : suma_de_cuadrados (x * y) :=\nby\n  rcases hx with \u27e8a, b, xeq : x = a^2 + b^2\u27e9\n  -- a b : \u03b1\n  -- xeq : x = a ^ 2 + b ^ 2\n  rcases hy with \u27e8c, d, yeq : y = c^2 + d^2\u27e9\n  -- c d : \u03b1\n  -- yeq : y = c ^ 2 + d ^ 2\n  have h1: x * y = (a*c - b*d)^2 + (a*d + b*c)^2 :=\n    calc x * y\n         = (a^2 + b^2) * (c^2 + d^2)     := by rw [xeq, yeq]\n       _ = (a*c - b*d)^2 + (a*d + b*c)^2 := by ring\n  have h2 : \u2203 e f, x * y = e^2 + f^2 :=\n    by tauto\n  show suma_de_cuadrados (x * y)\n  exact h2\n\n-- 3\u00aa demostraci\u00f3n\nexample\n  (hx : suma_de_cuadrados x)\n  (hy : suma_de_cuadrados y)\n  : suma_de_cuadrados (x * y) :=\nby\n  rcases hx with \u27e8a, b, xeq\u27e9\n  -- a b : \u03b1\n  -- xeq : x = a ^ 2 + b ^ 2\n  rcases hy with \u27e8c, d, yeq\u27e9\n  -- c d : \u03b1\n  -- yeq : y = c ^ 2 + d ^ 2\n  rw [xeq, yeq]\n  -- \u22a2 suma_de_cuadrados ((a ^ 2 + b ^ 2) * (c ^ 2 + d ^ 2))\n  use a*c - b*d, a*d + b*c\n  -- \u22a2 (a ^ 2 + b ^ 2) * (c ^ 2 + d ^ 2)\n  --   = (a * c - b * d) ^ 2 + (a * d + b * c) ^ 2\n  ring\n\n-- 4\u00aa demostraci\u00f3n\nexample\n  (hx : suma_de_cuadrados x)\n  (hy : suma_de_cuadrados y)\n  : suma_de_cuadrados (x * y) :=\nby\n  rcases hx with \u27e8a, b, rfl\u27e9\n  -- \u22a2 suma_de_cuadrados ((a ^ 2 + b ^ 2) * y)\n  rcases hy with \u27e8c, d, rfl\u27e9\n  -- \u22a2 suma_de_cuadrados ((a ^ 2 + b ^ 2) * (c ^ 2 + d ^ 2))\n  use a*c - b*d, a*d + b*c\n  -- \u22a2 (a ^ 2 + b ^ 2) * (c ^ 2 + d ^ 2)\n  --   = (a * c - b * d) ^ 2 + (a * d + b * c) ^ 2\n  ring\n<\/pre>\n<p><b>Demostraciones interactivas<\/b><\/p>\n<p>Se puede interactuar con las demostraciones anteriores en <a href=\"https:\/\/live.lean-lang.org\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus2\/main\/src\/Producto_de_suma_de_cuadrados.lean\" rel=\"noopener noreferrer\" target=\"_blank\">Lean 4 Web<\/a>.<\/p>\n<p><b>Referencias<\/b><\/p>\n<ul>\n<li> J. Avigad y P. Massot. <a href=\"https:\/\/bit.ly\/3U4UjBk\">Mathematics in Lean<\/a>, p. 30.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Esta semana he publicado en Calculemus las demostraciones con Lean4 de las siguientes propiedades: 1. La suma de dos funciones acotadas superiormente tambi\u00e9n lo est\u00e1 2. La suma de dos funciones acotadas inferiormente tambi\u00e9n lo est\u00e1 3. Si a es una cota superior de f y c \u2265 0, entonces ca es una cota superior&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"footnotes":"","_jetpack_memberships_contains_paid_content":false},"categories":[335],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":false,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/posts\/8045"}],"collection":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/comments?post=8045"}],"version-history":[{"count":1,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/posts\/8045\/revisions"}],"predecessor-version":[{"id":8046,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/posts\/8045\/revisions\/8046"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/media?parent=8045"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/categories?post=8045"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/vestigium\/wp-json\/wp\/v2\/tags?post=8045"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}