        {"id":2294,"date":"2024-03-01T06:00:49","date_gmt":"2024-03-01T04:00:49","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=2294"},"modified":"2024-02-27T12:40:03","modified_gmt":"2024-02-27T10:40:03","slug":"01-mar-24","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/01-mar-24\/","title":{"rendered":"(s \\ t) \u222a t = s \u222a t"},"content":{"rendered":"\n<p>Demostrar con Lean4 que<br \/>\n&#92;[ (s &#92;setminus t) \u222a t = s \u222a t &#92;]<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\nimport Mathlib.Data.Set.Basic\nopen Set\n\nvariable {\u03b1 : Type}\nvariable (s t : Set \u03b1)\n\nexample : (s \\ t) \u222a t = s \u222a t :=\nby sorry\n<\/pre>\n<p><!--more--><\/p>\n<h2>1. Demostraci\u00f3n en lenguaje natural<\/h2>\n<p>Tenemos que demostrar que<br \/>\n&#92;[ (\u2200 x)[x \u2208 (s &#92;setminus t) \u222a t \u2194 x \u2208 s \u222a t] &#92;]<br \/>\ny lo demostraremos por la siguiente cadena de equivalencias:<br \/>\n&#92;begin{align}<br \/>\n   x \u2208 (s &#92;setminus t) \u222a t<br \/>\n                   &amp;\u2194 x \u2208 (s &#92;setminus t) \u2228 (x \u2208 t)             &#92;&#92;<br \/>\n                   &amp;\u2194 (x \u2208 s \u2227 x \u2209 t) \u2228 x \u2208 t           &#92;&#92;<br \/>\n                   &amp;\u2194 (x \u2208 s \u2228 x \u2208 t) \u2227 (x \u2209 t \u2228 x \u2208 t) &#92;&#92;<br \/>\n                   &amp;\u2194 x \u2208 s \u2228 x \u2208 t                     &#92;&#92;<br \/>\n                   &amp;\u2194 x \u2208 s \u222a t<br \/>\n&#92;end{align}<\/p>\n<h2>2. Demostraciones con Lean4<\/h2>\n<pre lang=\"lean\">\nimport Mathlib.Data.Set.Basic\nopen Set\n\nvariable {\u03b1 : Type}\nvariable (s t : Set \u03b1)\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample : (s \\ t) \u222a t = s \u222a t :=\nby\n  ext x\n  -- x : \u03b1\n  -- \u22a2 x \u2208 (s \\ t) \u222a t \u2194 x \u2208 s \u222a t\n  calc x \u2208 (s \\ t) \u222a t\n       \u2194 x \u2208 s \\ t \u2228 x \u2208 t                 := mem_union x (s \\ t) t\n     _ \u2194 (x \u2208 s \u2227 x \u2209 t) \u2228 x \u2208 t           := by simp only [mem_diff x]\n     _ \u2194 (x \u2208 s \u2228 x \u2208 t) \u2227 (x \u2209 t \u2228 x \u2208 t) := and_or_right\n     _ \u2194 (x \u2208 s \u2228 x \u2208 t) \u2227 True            := by simp only [em' (x \u2208 t)]\n     _ \u2194 x \u2208 s \u2228 x \u2208 t                     := and_true_iff (x \u2208 s \u2228 x \u2208 t)\n     _ \u2194 x \u2208 s \u222a t                         := (mem_union x s t).symm\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample : (s \\ t) \u222a t = s \u222a t :=\nby\n  ext x\n  -- x : \u03b1\n  -- \u22a2 x \u2208 (s \\ t) \u222a t \u2194 x \u2208 s \u222a t\n  constructor\n  . -- \u22a2 x \u2208 (s \\ t) \u222a t \u2192 x \u2208 s \u222a t\n    intro hx\n    -- hx : x \u2208 (s \\ t) \u222a t\n    -- \u22a2 x \u2208 s \u222a t\n    rcases hx with (xst | xt)\n    . -- xst : x \u2208 s \\ t\n      -- \u22a2 x \u2208 s \u222a t\n      left\n      -- \u22a2 x \u2208 s\n      exact xst.1\n    . -- xt : x \u2208 t\n      -- \u22a2 x \u2208 s \u222a t\n      right\n      -- \u22a2 x \u2208 t\n      exact xt\n  . -- \u22a2 x \u2208 s \u222a t \u2192 x \u2208 (s \\ t) \u222a t\n    by_cases h : x \u2208 t\n    . -- h : x \u2208 t\n      intro _xst\n      -- _xst : x \u2208 s \u222a t\n      right\n      -- \u22a2 x \u2208 t\n      exact h\n    . -- \u22a2 x \u2208 s \u222a t \u2192 x \u2208 (s \\ t) \u222a t\n      intro hx\n      -- hx : x \u2208 s \u222a t\n      -- \u22a2 x \u2208 (s \\ t) \u222a t\n      rcases hx with (xs | xt)\n      . -- xs : x \u2208 s\n        left\n        -- \u22a2 x \u2208 s \\ t\n        constructor\n        . -- \u22a2 x \u2208 s\n          exact xs\n        . -- \u22a2 \u00acx \u2208 t\n          exact h\n      . -- xt : x \u2208 t\n        right\n        -- \u22a2 x \u2208 t\n        exact xt\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample : (s \\ t) \u222a t = s \u222a t :=\nby\n  ext x\n  -- x : \u03b1\n  -- \u22a2 x \u2208 (s \\ t) \u222a t \u2194 x \u2208 s \u222a t\n  constructor\n  . -- \u22a2 x \u2208 (s \\ t) \u222a t \u2192 x \u2208 s \u222a t\n    rintro (\u27e8xs, -\u27e9 | xt)\n    . -- xs : x \u2208 s\n      -- \u22a2 x \u2208 s \u222a t\n      left\n      -- \u22a2 x \u2208 s\n      exact xs\n    . -- xt : x \u2208 t\n      -- \u22a2 x \u2208 s \u222a t\n      right\n      -- \u22a2 x \u2208 t\n      exact xt\n  . -- \u22a2 x \u2208 s \u222a t \u2192 x \u2208 (s \\ t) \u222a t\n    by_cases h : x \u2208 t\n    . -- h : x \u2208 t\n      intro _xst\n      -- _xst : x \u2208 s \u222a t\n      -- \u22a2 x \u2208 (s \\ t) \u222a t\n      right\n      -- \u22a2 x \u2208 t\n      exact h\n    . -- \u22a2 x \u2208 s \u222a t \u2192 x \u2208 (s \\ t) \u222a t\n      rintro (xs | xt)\n      . -- xs : x \u2208 s\n        -- \u22a2 x \u2208 (s \\ t) \u222a t\n        left\n        -- \u22a2 x \u2208 s \\ t\n        exact \u27e8xs, h\u27e9\n      . -- xt : x \u2208 t\n        -- \u22a2 x \u2208 (s \\ t) \u222a t\n        right\n        -- \u22a2 x \u2208 t\n        exact xt\n\n-- 4\u00aa demostraci\u00f3n\n-- ===============\n\nexample : (s \\ t) \u222a t = s \u222a t :=\ndiff_union_self\n\n-- 5\u00aa demostraci\u00f3n\n-- ===============\n\nexample : (s \\ t) \u222a t = s \u222a t :=\nby\n  ext\n  -- x : \u03b1\n  -- \u22a2 x \u2208 s \\ t \u222a t \u2194 x \u2208 s \u222a t\n  simp\n\n-- 6\u00aa demostraci\u00f3n\n-- ===============\n\nexample : (s \\ t) \u222a t = s \u222a t :=\nby simp\n\n-- Lemas usados\n-- ============\n\n-- variable (a b c : Prop)\n-- variable (x : \u03b1)\n-- #check (and_or_right : (a \u2227 b) \u2228 c \u2194 (a \u2228 c) \u2227 (b \u2228 c))\n-- #check (and_true_iff a : a \u2227 True \u2194 a)\n-- #check (diff_union_self : (s \\ t) \u222a t = s \u222a t)\n-- #check (em' a : \u00aca \u2228 a)\n-- #check (mem_diff x : x \u2208 s \\ t \u2194 x \u2208 s \u2227 x \u2209 t)\n-- #check (mem_union x s t : x \u2208 s \u222a t \u2194 x \u2208 s \u2228 x \u2208 t)\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\/(s \\ t) \u222a t = s \u222a t.\" 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_su_diferencia\nimports Main\nbegin\n\n(* 1\u00aa demostraci\u00f3n *)\nlemma \"(s - t) \u222a t = s \u222a t\"\nproof (rule equalityI)\n  show \"(s - t) \u222a t \u2286 s \u222a t\"\n  proof (rule subsetI)\n    fix x\n    assume \"x \u2208 (s - t) \u222a t\"\n    then show \"x \u2208 s \u222a t\"\n    proof (rule UnE)\n      assume \"x \u2208 s - t\"\n      then have \"x \u2208 s\"\n        by (simp only: DiffD1)\n      then show \"x \u2208 s \u222a t\"\n        by (simp only: UnI1)\n    next\n      assume \"x \u2208 t\"\n      then show \"x \u2208 s \u222a t\"\n        by (simp only: UnI2)\n    qed\n  qed\nnext\n  show \"s \u222a t \u2286 (s - t) \u222a t\"\n  proof (rule subsetI)\n    fix x\n    assume \"x \u2208 s \u222a t\"\n    then show \"x \u2208 (s - t) \u222a t\"\n    proof (rule UnE)\n      assume \"x \u2208 s\"\n      show \"x \u2208 (s - t) \u222a t\"\n      proof (cases \u2039x \u2208 t\u203a)\n        assume \"x \u2208 t\"\n        then show \"x \u2208 (s - t) \u222a t\"\n          by (simp only: UnI2)\n      next\n        assume \"x \u2209 t\"\n        with \u2039x \u2208 s\u203a have \"x \u2208 s - t\"\n          by (rule DiffI)\n        then show \"x \u2208 (s - t) \u222a t\"\n          by (simp only: UnI1)\n      qed\n    next\n      assume \"x \u2208 t\"\n      then show \"x \u2208 (s - t) \u222a t\"\n        by (simp only: UnI2)\n    qed\n  qed\nqed\n\n(* 2\u00aa demostraci\u00f3n *)\nlemma \"(s - t) \u222a t = s \u222a t\"\nproof\n  show \"(s - t) \u222a t \u2286 s \u222a t\"\n  proof\n    fix x\n    assume \"x \u2208 (s - t) \u222a t\"\n    then show \"x \u2208 s \u222a t\"\n    proof\n      assume \"x \u2208 s - t\"\n      then have \"x \u2208 s\"\n        by simp\n      then show \"x \u2208 s \u222a t\"\n        by simp\n    next\n      assume \"x \u2208 t\"\n      then show \"x \u2208 s \u222a t\"\n        by simp\n    qed\n  qed\nnext\n  show \"s \u222a t \u2286 (s - t) \u222a t\"\n  proof\n    fix x\n    assume \"x \u2208 s \u222a t\"\n    then show \"x \u2208 (s - t) \u222a t\"\n    proof\n      assume \"x \u2208 s\"\n      show \"x \u2208 (s - t) \u222a t\"\n      proof\n        assume \"x \u2209 t\"\n        with \u2039x \u2208 s\u203a show \"x \u2208 s - t\"\n          by simp\n      qed\n    next\n      assume \"x \u2208 t\"\n      then show \"x \u2208 (s - t) \u222a t\"\n        by simp\n    qed\n  qed\nqed\n\n(* 3\u00aa demostraci\u00f3n *)\nlemma \"(s - t) \u222a t = s \u222a t\"\nby (fact Un_Diff_cancel2)\n\n(* 4\u00aa demostraci\u00f3n *)\nlemma \"(s - t) \u222a t = s \u222a t\"\n  by auto\n\nend\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Demostrar con Lean4 que &#92;[ (s &#92;setminus t) \u222a t = s \u222a t &#92;] Para ello, completar la siguiente teor\u00eda de Lean4: import Mathlib.Data.Set.Basic open Set variable {\u03b1 : Type} variable (s t : Set \u03b1) example : (s \\ t) \u222a t = s \u222a t := 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\/2294"}],"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=2294"}],"version-history":[{"count":2,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2294\/revisions"}],"predecessor-version":[{"id":2296,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2294\/revisions\/2296"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=2294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=2294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=2294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}