        {"id":2325,"date":"2024-03-11T06:00:42","date_gmt":"2024-03-11T04:00:42","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=2325"},"modified":"2024-03-08T20:14:32","modified_gmt":"2024-03-08T18:14:32","slug":"11-mar-24","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/11-mar-24\/","title":{"rendered":"s \u222a \u22c2 i, A i = \u22c2 i, (A i \u222a s)"},"content":{"rendered":"\n<p>Demostrar con Lean4 que<br \/>\n&#92;[ s \u222a \u22c2_i A_i = \u22c2_i (A_i \u222a s) &#92;]<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\nimport Mathlib.Data.Set.Basic\nimport Mathlib.Tactic\nopen Set\nvariable {\u03b1 : Type}\nvariable (s : Set \u03b1)\nvariable (A : \u2115 \u2192 Set \u03b1)\n\nexample : s \u222a (\u22c2 i, A i) = \u22c2 i, (A i \u222a s) :=\nby sorry\n<\/pre>\n<p><!--more--><\/p>\n<h2>1. Demostraci\u00f3n en lenguaje natural<\/h2>\n<p>Tenemos que demostrar que para todo &#92;(x&#92;),<br \/>\n&#92;[ x \u2208 s \u222a \u22c2_i A_i \u2194 x \u2208 \u22c2_i (A i \u222a s) &#92;]<br \/>\nLo haremos mediante la siguiente cadena de equivalencias<br \/>\n&#92;begin{align}<br \/>\n   x \u2208 s \u222a \u22c2_i A_i &amp;\u2194 x \u2208 s \u2228 x \u2208 \u22c2_i A_i &#92;&#92;<br \/>\n                   &amp;\u2194 x \u2208 s \u2228 (\u2200 i)[x \u2208 A_i] &#92;&#92;<br \/>\n                   &amp;\u2194 (\u2200 i)[x \u2208 s \u2228 x \u2208 A_i] &#92;&#92;<br \/>\n                   &amp;\u2194 (\u2200 i)[x \u2208 A_i \u2228 x \u2208 s] &#92;&#92;<br \/>\n                   &amp;\u2194 (\u2200 i)[x \u2208 A_i \u222a s]     &#92;&#92;<br \/>\n                   &amp;\u2194 x \u2208 \u22c2_i (A_i \u222a s)<br \/>\n&#92;end{align}<\/p>\n<h2>2. Demostraciones con Lean4<\/h2>\n<pre lang=\"lean\">\nimport Mathlib.Data.Set.Basic\nimport Mathlib.Tactic\n\nopen Set\n\nvariable {\u03b1 : Type}\nvariable (s : Set \u03b1)\nvariable (A : \u2115 \u2192 Set \u03b1)\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample : s \u222a (\u22c2 i, A i) = \u22c2 i, (A i \u222a s) :=\nby\n  ext x\n  -- x : \u03b1\n  -- \u22a2 x \u2208 s \u222a \u22c2 (i : \u2115), A i \u2194 x \u2208 \u22c2 (i : \u2115), A i \u222a s\n  calc x \u2208 s \u222a \u22c2 i, A i\n     \u2194 x \u2208 s \u2228 x \u2208 \u22c2 i, A i :=\n         by simp only [mem_union]\n   _ \u2194 x \u2208 s \u2228 \u2200 i, x \u2208 A i :=\n         by simp only [mem_iInter]\n   _ \u2194 \u2200 i, x \u2208 s \u2228 x \u2208 A i :=\n         by simp only [forall_or_left]\n   _ \u2194 \u2200 i, x \u2208 A i \u2228 x \u2208 s  :=\n         by simp only [or_comm]\n   _ \u2194 \u2200 i, x \u2208 A i \u222a s  :=\n         by simp only [mem_union]\n   _ \u2194 x \u2208 \u22c2 i, A i \u222a s :=\n         by simp only [mem_iInter]\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample : s \u222a (\u22c2 i, A i) = \u22c2 i, (A i \u222a s) :=\nby\n  ext x\n  -- x : \u03b1\n  -- \u22a2 x \u2208 s \u222a \u22c2 (i : \u2115), A i \u2194 x \u2208 \u22c2 (i : \u2115), A i \u222a s\n  simp only [mem_union, mem_iInter]\n  -- \u22a2 (x \u2208 s \u2228 \u2200 (i : \u2115), x \u2208 A i) \u2194 \u2200 (i : \u2115), x \u2208 A i \u2228 x \u2208 s\n  constructor\n  . -- \u22a2 (x \u2208 s \u2228 \u2200 (i : \u2115), x \u2208 A i) \u2192 \u2200 (i : \u2115), x \u2208 A i \u2228 x \u2208 s\n    intros h i\n    -- h : x \u2208 s \u2228 \u2200 (i : \u2115), x \u2208 A i\n    -- i : \u2115\n    -- \u22a2 x \u2208 A i \u2228 x \u2208 s\n    rcases h with (xs | xAi)\n    . -- xs : x \u2208 s\n      right\n      -- \u22a2 x \u2208 s\n      exact xs\n    . -- xAi : \u2200 (i : \u2115), x \u2208 A i\n      left\n      -- \u22a2 x \u2208 A i\n      exact xAi i\n  . -- \u22a2 (\u2200 (i : \u2115), x \u2208 A i \u2228 x \u2208 s) \u2192 x \u2208 s \u2228 \u2200 (i : \u2115), x \u2208 A i\n    intro h\n    -- h : \u2200 (i : \u2115), x \u2208 A i \u2228 x \u2208 s\n    -- \u22a2 x \u2208 s \u2228 \u2200 (i : \u2115), x \u2208 A i\n    by_cases cxs : x \u2208 s\n    . -- cxs : x \u2208 s\n      left\n      -- \u22a2 x \u2208 s\n      exact cxs\n    . -- cns : \u00acx \u2208 s\n      right\n      -- \u22a2 \u2200 (i : \u2115), x \u2208 A i\n      intro i\n      -- i : \u2115\n      -- \u22a2 x \u2208 A i\n      rcases h i with (xAi | xs)\n      . -- \u22a2 x \u2208 A i\n        exact xAi\n      . -- xs : x \u2208 s\n        exact absurd xs cxs\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample : s \u222a (\u22c2 i, A i) = \u22c2 i, (A i \u222a s) :=\nby\n  ext x\n  -- x : \u03b1\n  -- \u22a2 x \u2208 s \u222a \u22c2 (i : \u2115), A i \u2194 x \u2208 \u22c2 (i : \u2115), A i \u222a s\n  simp only [mem_union, mem_iInter]\n  -- \u22a2 (x \u2208 s \u2228 \u2200 (i : \u2115), x \u2208 A i) \u2194 \u2200 (i : \u2115), x \u2208 A i \u2228 x \u2208 s\n  constructor\n  . -- \u22a2 (x \u2208 s \u2228 \u2200 (i : \u2115), x \u2208 A i) \u2192 \u2200 (i : \u2115), x \u2208 A i \u2228 x \u2208 s\n    rintro (xs | xI) i\n    . -- xs : x \u2208 s\n      -- i : \u2115\n      -- \u22a2 x \u2208 A i \u2228 x \u2208 s\n      right\n      -- \u22a2 x \u2208 s\n      exact xs\n    . -- xI : \u2200 (i : \u2115), x \u2208 A i\n      -- i : \u2115\n      -- \u22a2 x \u2208 A i \u2228 x \u2208 s\n      left\n      -- \u22a2 x \u2208 A i\n      exact xI i\n  . -- \u22a2 (\u2200 (i : \u2115), x \u2208 A i \u2228 x \u2208 s) \u2192 x \u2208 s \u2228 \u2200 (i : \u2115), x \u2208 A i\n    intro h\n    -- h : \u2200 (i : \u2115), x \u2208 A i \u2228 x \u2208 s\n    -- \u22a2 x \u2208 s \u2228 \u2200 (i : \u2115), x \u2208 A i\n    by_cases cxs : x \u2208 s\n    . -- cxs : x \u2208 s\n      left\n      -- \u22a2 x \u2208 s\n      exact cxs\n    . -- cxs : \u00acx \u2208 s\n      right\n      -- \u22a2 \u2200 (i : \u2115), x \u2208 A i\n      intro i\n      -- i : \u2115\n      -- \u22a2 x \u2208 A i\n      cases h i\n      . -- h : x \u2208 A i\n        assumption\n      . -- h : x \u2208 s\n        contradiction\n\n-- Lemas usados\n-- ============\n\n-- variable (x : \u03b1)\n-- variable (s t : Set \u03b1)\n-- variable (a b q : Prop)\n-- variable (p : \u2115 \u2192 Prop)\n-- #check (absurd : a \u2192 \u00aca \u2192 b)\n-- #check (forall_or_left : (\u2200 x, q \u2228 p x) \u2194 q \u2228 \u2200 x, p x)\n-- #check (mem_iInter : x \u2208 \u22c2 i, A i \u2194 \u2200 i, x \u2208 A i)\n-- #check (mem_union x a b : x \u2208 s \u222a t \u2194 x \u2208 s \u2228 x \u2208 t)\n-- #check (or_comm : a \u2228 b \u2194 b \u2228 a)\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\/Union_con_interseccion_general.lean\" rel=\"noopener noreferrer\" target=\"_blank\">Lean 4 Web<\/a>.<\/p>\n<h2>3. Demostraciones con Isabelle\/HOL<\/h2>\n<pre lang=\"isar\">\ntheory Union_con_interseccion_general\nimports Main\nbegin\n\n(* 1\u00aa demostraci\u00f3n *)\nlemma \"s \u222a (\u22c2 i \u2208 I. A i) = (\u22c2 i \u2208 I. A i \u222a s)\"\nproof (rule equalityI)\n  show \"s \u222a (\u22c2 i \u2208 I. A i) \u2286 (\u22c2 i \u2208 I. A i \u222a s)\"\n  proof (rule subsetI)\n    fix x\n    assume \"x \u2208 s \u222a (\u22c2 i \u2208 I. A i)\"\n    then show \"x \u2208 (\u22c2 i \u2208 I. A i \u222a s)\"\n    proof (rule UnE)\n      assume \"x \u2208 s\"\n      show \"x \u2208 (\u22c2 i \u2208 I. A i \u222a s)\"\n      proof (rule INT_I)\n        fix i\n        assume \"i \u2208 I\"\n        show \"x \u2208 A i \u222a s\"\n          using \u2039x \u2208 s\u203a by (rule UnI2)\n      qed\n    next\n      assume h1 : \"x \u2208 (\u22c2 i \u2208 I. A i)\"\n      show \"x \u2208 (\u22c2 i \u2208 I. A i \u222a s)\"\n      proof (rule INT_I)\n        fix i\n        assume \"i \u2208 I\"\n        with h1 have \"x \u2208 A i\"\n          by (rule INT_D)\n        then show \"x \u2208 A i \u222a s\"\n          by (rule UnI1)\n      qed\n    qed\n  qed\nnext\n  show \"(\u22c2 i \u2208 I. A i \u222a s) \u2286 s \u222a (\u22c2 i \u2208 I. A i)\"\n  proof (rule subsetI)\n    fix x\n    assume h2 : \"x \u2208 (\u22c2 i \u2208 I. A i \u222a s)\"\n    show \"x \u2208 s \u222a (\u22c2 i \u2208 I. A i)\"\n    proof (cases \"x \u2208 s\")\n      assume \"x \u2208 s\"\n      then show \"x \u2208 s \u222a (\u22c2 i \u2208 I. A i)\"\n        by (rule UnI1)\n    next\n      assume \"x \u2209 s\"\n      have \"x \u2208 (\u22c2 i \u2208 I. A i)\"\n      proof (rule INT_I)\n        fix i\n        assume \"i \u2208 I\"\n        with h2 have \"x \u2208 A i \u222a s\"\n          by (rule INT_D)\n        then show \"x \u2208 A i\"\n        proof (rule UnE)\n          assume \"x \u2208 A i\"\n          then show \"x \u2208 A i\"\n            by this\n        next\n          assume \"x \u2208 s\"\n          with \u2039x \u2209 s\u203a show \"x \u2208 A i\"\n            by (rule notE)\n        qed\n      qed\n      then show \"x \u2208 s \u222a (\u22c2 i \u2208 I. A i)\"\n        by (rule UnI2)\n    qed\n  qed\nqed\n\n(* 2\u00aa demostraci\u00f3n *)\nlemma \"s \u222a (\u22c2 i \u2208 I. A i) = (\u22c2 i \u2208 I. A i \u222a s)\"\nproof\n  show \"s \u222a (\u22c2 i \u2208 I. A i) \u2286 (\u22c2 i \u2208 I. A i \u222a s)\"\n  proof\n    fix x\n    assume \"x \u2208 s \u222a (\u22c2 i \u2208 I. A i)\"\n    then show \"x \u2208 (\u22c2 i \u2208 I. A i \u222a s)\"\n    proof\n      assume \"x \u2208 s\"\n      show \"x \u2208 (\u22c2 i \u2208 I. A i \u222a s)\"\n      proof\n        fix i\n        assume \"i \u2208 I\"\n        show \"x \u2208 A i \u222a s\"\n          using \u2039x \u2208 s\u203a by simp\n      qed\n    next\n      assume h1 : \"x \u2208 (\u22c2 i \u2208 I. A i)\"\n      show \"x \u2208 (\u22c2 i \u2208 I. A i \u222a s)\"\n      proof\n        fix i\n        assume \"i \u2208 I\"\n        with h1 have \"x \u2208 A i\"\n          by simp\n        then show \"x \u2208 A i \u222a s\"\n          by simp\n      qed\n    qed\n  qed\nnext\n  show \"(\u22c2 i \u2208 I. A i \u222a s) \u2286 s \u222a (\u22c2 i \u2208 I. A i)\"\n  proof\n    fix x\n    assume h2 : \"x \u2208 (\u22c2 i \u2208 I. A i \u222a s)\"\n    show \"x \u2208 s \u222a (\u22c2 i \u2208 I. A i)\"\n    proof (cases \"x \u2208 s\")\n      assume \"x \u2208 s\"\n      then show \"x \u2208 s \u222a (\u22c2 i \u2208 I. A i)\"\n        by simp\n    next\n      assume \"x \u2209 s\"\n      have \"x \u2208 (\u22c2 i \u2208 I. A i)\"\n      proof\n        fix i\n        assume \"i \u2208 I\"\n        with h2 have \"x \u2208 A i \u222a s\"\n          by (rule INT_D)\n        then show \"x \u2208 A i\"\n        proof\n          assume \"x \u2208 A i\"\n          then show \"x \u2208 A i\"\n            by this\n        next\n          assume \"x \u2208 s\"\n          with \u2039x \u2209 s\u203a show \"x \u2208 A i\"\n            by simp\n        qed\n      qed\n      then show \"x \u2208 s \u222a (\u22c2 i \u2208 I. A i)\"\n        by simp\n    qed\n  qed\nqed\n\n(* 3\u00aa demostraci\u00f3n *)\nlemma \"s \u222a (\u22c2 i \u2208 I. A i) = (\u22c2 i \u2208 I. A i \u222a s)\"\nproof\n  show \"s \u222a (\u22c2 i \u2208 I. A i) \u2286 (\u22c2 i \u2208 I. A i \u222a s)\"\n  proof\n    fix x\n    assume \"x \u2208 s \u222a (\u22c2 i \u2208 I. A i)\"\n    then show \"x \u2208 (\u22c2 i \u2208 I. A i \u222a s)\"\n    proof\n      assume \"x \u2208 s\"\n      then show \"x \u2208 (\u22c2 i \u2208 I. A i \u222a s)\"\n        by simp\n    next\n      assume \"x \u2208 (\u22c2 i \u2208 I. A i)\"\n      then show \"x \u2208 (\u22c2 i \u2208 I. A i \u222a s)\"\n        by simp\n    qed\n  qed\nnext\n  show \"(\u22c2 i \u2208 I. A i \u222a s) \u2286 s \u222a (\u22c2 i \u2208 I. A i)\"\n  proof\n    fix x\n    assume h2 : \"x \u2208 (\u22c2 i \u2208 I. A i \u222a s)\"\n    show \"x \u2208 s \u222a (\u22c2 i \u2208 I. A i)\"\n    proof (cases \"x \u2208 s\")\n      assume \"x \u2208 s\"\n      then show \"x \u2208 s \u222a (\u22c2 i \u2208 I. A i)\"\n        by simp\n    next\n      assume \"x \u2209 s\"\n      then show \"x \u2208 s \u222a (\u22c2 i \u2208 I. A i)\"\n        using h2 by simp\n    qed\n  qed\nqed\n\n(* 4\u00aa demostraci\u00f3n *)\nlemma \"s \u222a (\u22c2 i \u2208 I. A i) = (\u22c2 i \u2208 I. A i \u222a s)\"\nproof\n  show \"s \u222a (\u22c2 i \u2208 I. A i) \u2286 (\u22c2 i \u2208 I. A i \u222a s)\"\n  proof\n    fix x\n    assume \"x \u2208 s \u222a (\u22c2 i \u2208 I. A i)\"\n    then show \"x \u2208 (\u22c2 i \u2208 I. A i \u222a s)\"\n    proof\n      assume \"x \u2208 s\"\n      then show ?thesis by simp\n    next\n      assume \"x \u2208 (\u22c2 i \u2208 I. A i)\"\n      then show ?thesis by simp\n    qed\n  qed\nnext\n  show \"(\u22c2 i \u2208 I. A i \u222a s) \u2286 s \u222a (\u22c2 i \u2208 I. A i)\"\n  proof\n    fix x\n    assume h2 : \"x \u2208 (\u22c2 i \u2208 I. A i \u222a s)\"\n    show \"x \u2208 s \u222a (\u22c2 i \u2208 I. A i)\"\n    proof (cases \"x \u2208 s\")\n      case True\n      then show ?thesis by simp\n    next\n      case False\n      then show ?thesis using h2 by simp\n    qed\n  qed\nqed\n\n(* 5\u00aa demostraci\u00f3n *)\nlemma \"s \u222a (\u22c2 i \u2208 I. A i) = (\u22c2 i \u2208 I. A i \u222a s)\"\n  by auto\n\nend\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Demostrar con Lean4 que &#92;[ s \u222a \u22c2_i A_i = \u22c2_i (A_i \u222a s) &#92;] Para ello, completar la siguiente teor\u00eda de Lean4: import Mathlib.Data.Set.Basic import Mathlib.Tactic open Set variable {\u03b1 : Type} variable (s : Set \u03b1) variable (A : \u2115 \u2192 Set \u03b1) example : s \u222a (\u22c2 i, A i) = \u22c2 i, (A i \u222a s) := 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":[7],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2325"}],"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=2325"}],"version-history":[{"count":2,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2325\/revisions"}],"predecessor-version":[{"id":2327,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2325\/revisions\/2327"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=2325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=2325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=2325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}