        {"id":2444,"date":"2024-05-02T18:41:16","date_gmt":"2024-05-02T16:41:16","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=2444"},"modified":"2024-05-02T18:41:16","modified_gmt":"2024-05-02T16:41:16","slug":"02-may-24","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/02-may-24\/","title":{"rendered":"Teorema de Cantor"},"content":{"rendered":"\n<p>Demostrar con Lean4 el teorema de Cantor; es decir, que no existe ninguna aplicaci\u00f3n suprayectiva de un conjunto en el conjunto de sus subconjuntos.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\nimport Mathlib.Data.Set.Basic\nopen Function\n\nvariable {\u03b1 : Type}\n\nexample : \u2200 f : \u03b1 \u2192 Set \u03b1, \u00acSurjective f :=\nby sorry\n<\/pre>\n<p><!--more--><\/p>\n<h2>1. Demostraci\u00f3n en lenguaje natural<\/h2>\n<p>Sea &#92;(f&#92;) una funci\u00f3n de &#92;(A&#92;) en el conjunto de los subconjuntos  &#92;(A&#92;). Tenemos que demostrar que &#92;(f&#92;) no es suprayectiva. Lo haremos por reducci\u00f3n al absurdo. Para ello, supongamos que &#92;(f&#92;) es suprayectiva y consideremos el conjunto<br \/>\n&#92;[ S := &#92;{i \u2208 A | i \u2209 f(i)&#92;} &#92;tag{1} &#92;]<br \/>\nEntonces, tiene que existir un &#92;(j \u2208 A&#92;) tal que<br \/>\n&#92;[ f(j) = S &#92;tag{2} &#92;]<br \/>\nSe pueden dar dos casos: &#92;(j \u2208 S&#92;) \u00f3 &#92;(j \u2209 S&#92;). Veamos que ambos son imposibles.<\/p>\n<p>Caso 1: Supongamos que &#92;(j \u2208 S&#92;). Entonces, por (1)<br \/>\n&#92;[ j \u2209 f(j) &#92;]<br \/>\ny, por (2),<br \/>\n&#92;[ j \u2209 S &#92;]<br \/>\nque es una contradicci\u00f3n.<\/p>\n<p>Caso 2: Supongamos que &#92;(j \u2209 S&#92;). Entonces, por (1)<br \/>\n&#92;[ j \u2208 f(j) &#92;]<br \/>\ny, por (2),<br \/>\n&#92;[ j \u2208 S &#92;]<br \/>\nque es una contradicci\u00f3n.<\/p>\n<h2>2. Demostraciones con Lean4<\/h2>\n<pre lang=\"lean\">\nimport Mathlib.Data.Set.Basic\nopen Function\n\nvariable {\u03b1 : Type}\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample : \u2200 f : \u03b1 \u2192 Set \u03b1, \u00acSurjective f :=\nby\n  intros f hf\n  -- f : \u03b1 \u2192 Set \u03b1\n  -- hf : Surjective f\n  -- \u22a2 False\n  let S := {i | i \u2209 f i}\n  unfold Surjective at hf\n  -- hf : \u2200 (b : Set \u03b1), \u2203 a, f a = b\n  cases' hf S with j hj\n  -- j : \u03b1\n  -- hj : f j = S\n  by_cases j \u2208 S\n  . -- h : j \u2208 S\n    dsimp at h\n    -- h : \u00acj \u2208 f j\n    apply h\n    -- \u22a2 j \u2208 f j\n    rw [hj]\n    -- \u22a2 j \u2208 S\n    exact h\n  . -- h : \u00acj \u2208 S\n    apply h\n    -- \u22a2 j \u2208 S\n    rw [\u2190hj] at h\n    -- h : \u00acj \u2208 f j\n    exact h\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample : \u2200 f : \u03b1 \u2192 Set \u03b1, \u00ac Surjective f :=\nby\n  intros f hf\n  -- f : \u03b1 \u2192 Set \u03b1\n  -- hf : Surjective f\n  -- \u22a2 False\n  let S := {i | i \u2209 f i}\n  cases' hf S with j hj\n  -- j : \u03b1\n  -- hj : f j = S\n  by_cases j \u2208 S\n  . -- h : j \u2208 S\n    apply h\n    -- \u22a2 j \u2208 f j\n    rwa [hj]\n  . -- h : \u00acj \u2208 S\n    apply h\n    rwa [\u2190hj] at h\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample : \u2200 f : \u03b1 \u2192 Set \u03b1, \u00ac Surjective f :=\nby\n  intros f hf\n  -- f : \u03b1 \u2192 Set \u03b1\n  -- hf : Surjective f\n  -- \u22a2 False\n  let S := {i | i \u2209 f i}\n  cases' hf S with j hj\n  -- j : \u03b1\n  -- hj : f j = S\n  have h : (j \u2208 S) = (j \u2209 S) :=\n    calc  (j \u2208 S)\n       = (j \u2209 f j) := Set.mem_setOf_eq\n     _ = (j \u2209 S)   := congrArg (j \u2209 .) hj\n  exact iff_not_self (iff_of_eq h)\n\n-- 4\u00aa demostraci\u00f3n\n-- ===============\n\nexample : \u2200 f : \u03b1 \u2192 Set \u03b1, \u00ac Surjective f :=\ncantor_surjective\n\n-- Lemas usados\n-- ============\n\n-- variable (x : \u03b1)\n-- variable (p : \u03b1 \u2192 Prop)\n-- variable (a b : Prop)\n-- #check (Set.mem_setOf_eq : (x \u2208 {y : \u03b1 | p y}) = p x)\n-- #check (iff_of_eq : a = b \u2192 (a \u2194 b))\n-- #check (iff_not_self : \u00ac(a \u2194 \u00aca))\n-- #check (cantor_surjective : \u2200 f : \u03b1 \u2192 Set \u03b1, \u00ac Surjective f)\n<\/pre>\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\/Teorema_de_Cantor.lean\">Lean 4 Web<\/a>.<\/p>\n<h2>3. Demostraciones con Isabelle\/HOL<\/h2>\n<pre lang=\"isar\">\ntheory Teorema_de_Cantor\nimports Main\nbegin\n\n(* 1\u00aa demostraci\u00f3n *)\n\ntheorem\n  fixes f :: \"'\u03b1 \u21d2 '\u03b1 set\"\n  shows \"\u00ac surj f\"\nproof (rule notI)\n  assume \"surj f\"\n  let ?S = \"{i. i \u2209 f i}\"\n  have \"\u2203 j. ?S = f j\"\n    using \u2039surj f\u203a by (simp only: surjD)\n  then obtain j where \"?S = f j\"\n    by (rule exE)\n  show False\n  proof (cases \"j \u2208 ?S\")\n    assume \"j \u2208 ?S\"\n    then have \"j \u2209 f j\"\n      by (rule CollectD)\n    moreover\n    have \"j \u2208 f j\"\n      using \u2039?S = f j\u203a \u2039j \u2208 ?S\u203a by (rule subst)\n    ultimately show False\n      by (rule notE)\n  next\n    assume \"j \u2209 ?S\"\n    with \u2039?S = f j\u203a have \"j \u2209 f j\"\n      by (rule subst)\n    then have \"j \u2208 ?S\"\n      by (rule CollectI)\n    with \u2039j \u2209 ?S\u203a show False\n      by (rule notE)\n  qed\nqed\n\n(* 2\u00aa demostraci\u00f3n *)\n\ntheorem\n  fixes f :: \"'\u03b1 \u21d2 '\u03b1 set\"\n  shows \"\u00ac surj f\"\nproof (rule notI)\n  assume \"surj f\"\n  let ?S = \"{i. i \u2209 f i}\"\n  have \"\u2203 j. ?S = f j\"\n    using \u2039surj f\u203a by (simp only: surjD)\n  then obtain j where \"?S = f j\"\n    by (rule exE)\n  have \"j \u2209 ?S\"\n  proof (rule notI)\n    assume \"j \u2208 ?S\"\n    then have \"j \u2209 f j\"\n      by (rule CollectD)\n    with \u2039?S = f j\u203a have \"j \u2209 ?S\"\n      by (rule ssubst)\n    then show False\n      using \u2039j \u2208 ?S\u203a by (rule notE)\n  qed\n  moreover\n  have \"j \u2208 ?S\"\n  proof (rule CollectI)\n    show \"j \u2209 f j\"\n    proof (rule notI)\n      assume \"j \u2208 f j\"\n      with \u2039?S = f j\u203a have \"j \u2208 ?S\"\n        by (rule ssubst)\n      then have \"j \u2209 f j\"\n        by (rule CollectD)\n      then show False\n        using \u2039j \u2208 f j\u203a by (rule notE)\n    qed\n  qed\n  ultimately show False\n    by (rule notE)\nqed\n\n(* 3\u00aa demostraci\u00f3n *)\n\ntheorem\n  fixes f :: \"'\u03b1 \u21d2 '\u03b1 set\"\n  shows \"\u00ac surj f\"\nproof\n  assume \"surj f\"\n  let ?S = \"{i. i \u2209 f i}\"\n  have \"\u2203 j. ?S = f j\" using \u2039surj f\u203a by (simp only: surjD)\n  then obtain j where \"?S = f j\" by (rule exE)\n  have \"j \u2209 ?S\"\n  proof\n    assume \"j \u2208 ?S\"\n    then have \"j \u2209 f j\" by simp\n    with \u2039?S = f j\u203a have \"j \u2209 ?S\" by simp\n    then show False using \u2039j \u2208 ?S\u203a by simp\n  qed\n  moreover\n  have \"j \u2208 ?S\"\n  proof\n    show \"j \u2209 f j\"\n    proof\n      assume \"j \u2208 f j\"\n      with \u2039?S = f j\u203a have \"j \u2208 ?S\" by simp\n      then have \"j \u2209 f j\" by simp\n      then show False using \u2039j \u2208 f j\u203a by simp\n    qed\n  qed\n  ultimately show False by simp\nqed\n\n(* 4\u00aa demostraci\u00f3n *)\n\ntheorem\n  fixes f :: \"'\u03b1 \u21d2 '\u03b1 set\"\n  shows \"\u00ac surj f\"\nproof (rule notI)\n  assume \"surj f\"\n  let ?S = \"{i. i \u2209 f i}\"\n  have \"\u2203 j. ?S = f j\"\n    using \u2039surj f\u203a by (simp only: surjD)\n  then obtain j where \"?S = f j\"\n    by (rule exE)\n  have \"j \u2208 ?S = (j \u2209 f j)\"\n    by (rule mem_Collect_eq)\n  also have \"\u2026 = (j \u2209 ?S)\"\n    by (simp only: \u2039?S = f j\u203a)\n  finally show False\n    by (simp only: simp_thms(10))\nqed\n\n(* 5\u00aa demostraci\u00f3n *)\n\ntheorem\n  fixes f :: \"'\u03b1 \u21d2 '\u03b1 set\"\n  shows \"\u00ac surj f\"\nproof\n  assume \"surj f\"\n  let ?S = \"{i. i \u2209 f i}\"\n  have \"\u2203 j. ?S = f j\" using \u2039surj f\u203a by (simp only: surjD)\n  then obtain j where \"?S = f j\" by (rule exE)\n  have \"j \u2208 ?S = (j \u2209 f j)\" by simp\n  also have \"\u2026 = (j \u2209 ?S)\" using \u2039?S = f j\u203a by simp\n  finally show False by simp\nqed\n\n(* 6\u00aa demostraci\u00f3n *)\n\ntheorem\n  fixes f :: \"'\u03b1 \u21d2 '\u03b1 set\"\n  shows \"\u00ac surj f\"\n  unfolding surj_def\n  by best\n\nend\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Demostrar con Lean4 el teorema de Cantor; es decir, que no existe ninguna aplicaci\u00f3n suprayectiva de un conjunto en el conjunto de sus subconjuntos. Para ello, completar la siguiente teor\u00eda de Lean4: import Mathlib.Data.Set.Basic open Function variable {\u03b1 : Type} example : \u2200 f : \u03b1 \u2192 Set \u03b1, \u00acSurjective f := by sorry<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_kad_post_transparent":"default","_kad_post_title":"default","_kad_post_layout":"default","_kad_post_sidebar_id":"","_kad_post_content_style":"default","_kad_post_vertical_padding":"default","_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,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2444"}],"collection":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/comments?post=2444"}],"version-history":[{"count":1,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2444\/revisions"}],"predecessor-version":[{"id":2445,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2444\/revisions\/2445"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=2444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=2444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=2444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}