        {"id":2273,"date":"2024-02-22T06:00:54","date_gmt":"2024-02-22T04:00:54","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=2273"},"modified":"2024-02-21T10:02:04","modified_gmt":"2024-02-21T08:02:04","slug":"22-feb-23","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/22-feb-23\/","title":{"rendered":"(s \\ t) \\ u \u2286 s \\ (t \u222a u)"},"content":{"rendered":"\n<p>Demostrar con Lean4 que<br \/>\n&#92;[ (s \\setminus t) \\setminus u \u2286 s \\setminus (t \u222a u) &#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\nvariable {\u03b1 : Type}\nvariable (s t u : Set \u03b1)\n\nexample : (s \\ t) \\ u \u2286 s \\ (t \u222a u) :=\nby sorry\n<\/pre>\n<p><!--more--><\/p>\n<h2>1. Demostraci\u00f3n en lenguaje natural<\/h2>\n<p>Sea &#92;(x \u2208 (s \\setminus t) \\setminus u&#92;). Entonces, se tiene que<br \/>\n&#92;begin{align}<br \/>\n   &amp;x \u2208 s &#92;tag{1} &#92;&#92;<br \/>\n   &amp;x \u2209 t &#92;tag{2} &#92;&#92;<br \/>\n   &amp;x \u2209 u &#92;tag{3}<br \/>\n&#92;end{align}<br \/>\nTenemos que demostrar que<br \/>\n&#92;[ x \u2208 s \\setminus (t \u222a u) &#92;]<br \/>\npero, por (1), se reduce a<br \/>\n&#92;[ x \u2209 t \u222a u &#92;]<br \/>\nque se verifica por (2) y (3).<\/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 u : Set \u03b1)\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample : (s \\ t) \\ u \u2286 s \\ (t \u222a u) :=\nby\n  intros x hx\n  -- x : \u03b1\n  -- hx : x \u2208 (s \\ t) \\ u\n  -- \u22a2 x \u2208 s \\ (t \u222a u)\n  rcases hx with \u27e8hxst, hxnu\u27e9\n  -- hxst : x \u2208 s \\ t\n  -- hxnu : \u00acx \u2208 u\n  rcases hxst with \u27e8hxs, hxnt\u27e9\n  -- hxs : x \u2208 s\n  -- hxnt : \u00acx \u2208 t\n  constructor\n  . -- \u22a2 x \u2208 s\n    exact hxs\n  . -- \u22a2 \u00acx \u2208 t \u222a u\n    by_contra hxtu\n    -- hxtu : x \u2208 t \u222a u\n    -- \u22a2 False\n    rcases hxtu with (hxt | hxu)\n    . -- hxt : x \u2208 t\n      apply hxnt\n      -- \u22a2 x \u2208 t\n      exact hxt\n    . -- hxu : x \u2208 u\n      apply hxnu\n      -- \u22a2 x \u2208 u\n      exact hxu\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample : (s \\ t) \\ u \u2286 s \\ (t \u222a u) :=\nby\n  rintro x \u27e8\u27e8hxs, hxnt\u27e9, hxnu\u27e9\n  -- x : \u03b1\n  -- hxnu : \u00acx \u2208 u\n  -- hxs : x \u2208 s\n  -- hxnt : \u00acx \u2208 t\n  -- \u22a2 x \u2208 s \\ (t \u222a u)\n  constructor\n  . -- \u22a2 x \u2208 s\n    exact hxs\n  . -- \u22a2 \u00acx \u2208 t \u222a u\n    by_contra hxtu\n    -- hxtu : x \u2208 t \u222a u\n    -- \u22a2 False\n    rcases hxtu with (hxt | hxu)\n    . -- hxt : x \u2208 t\n      exact hxnt hxt\n    . -- hxu : x \u2208 u\n      exact hxnu hxu\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample : (s \\ t) \\ u \u2286 s \\ (t \u222a u) :=\nby\n  rintro x \u27e8\u27e8xs, xnt\u27e9, xnu\u27e9\n  -- x : \u03b1\n  -- xnu : \u00acx \u2208 u\n  -- xs : x \u2208 s\n  -- xnt : \u00acx \u2208 t\n  -- \u22a2 x \u2208 s \\ (t \u222a u)\n  use xs\n  -- \u22a2 \u00acx \u2208 t \u222a u\n  rintro (xt | xu)\n  . -- xt : x \u2208 t\n    -- \u22a2 False\n    contradiction\n  . -- xu : x \u2208 u\n    -- \u22a2 False\n    contradiction\n\n-- 4\u00aa demostraci\u00f3n\n-- ===============\n\nexample : (s \\ t) \\ u \u2286 s \\ (t \u222a u) :=\nby\n  rintro x \u27e8\u27e8xs, xnt\u27e9, xnu\u27e9\n  -- x : \u03b1\n  -- xnu : \u00acx \u2208 u\n  -- xs : x \u2208 s\n  -- xnt : \u00acx \u2208 t\n  -- \u22a2 x \u2208 s \\ (t \u222a u)\n  use xs\n  -- \u22a2 \u00acx \u2208 t \u222a u\n  rintro (xt | xu) <;> contradiction\n\n-- 5\u00aa demostraci\u00f3n\n-- ===============\n\nexample : (s \\ t) \\ u \u2286 s \\ (t \u222a u) :=\nby\n  intro x xstu\n  -- x : \u03b1\n  -- xstu : x \u2208 (s \\ t) \\ u\n  -- \u22a2 x \u2208 s \\ (t \u222a u)\n  simp at *\n  -- \u22a2 x \u2208 s \u2227 \u00ac(x \u2208 t \u2228 x \u2208 u)\n  aesop\n\n-- 6\u00aa demostraci\u00f3n\n-- ===============\n\nexample : (s \\ t) \\ u \u2286 s \\ (t \u222a u) :=\nby\n  intro x xstu\n  -- x : \u03b1\n  -- xstu : x \u2208 (s \\ t) \\ u\n  -- \u22a2 x \u2208 s \\ (t \u222a u)\n  aesop\n\n-- 7\u00aa demostraci\u00f3n\n-- ===============\n\nexample : (s \\ t) \\ u \u2286 s \\ (t \u222a u) :=\nby rw [diff_diff]\n\n-- Lema usado\n-- ==========\n\n-- #check (diff_diff : (s \\ t) \\ u = s \\ (t \u222a u))\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\/Diferencia_de_diferencia_de_conjuntos.lean\" rel=\"noopener noreferrer\" target=\"_blank\">Lean 4 Web<\/a>.<\/p>\n<h2>3. Demostraciones con Isabelle\/HOL<\/h2>\n<pre lang=\"isar\">\ntheory Diferencia_de_diferencia_de_conjuntos\nimports Main\nbegin\n\n(* 1\u00aa demostraci\u00f3n *)\nlemma \"(s - t) - u \u2286 s - (t \u222a u)\"\nproof (rule subsetI)\n  fix x\n  assume hx : \"x \u2208 (s - t) - u\"\n  then show \"x \u2208 s - (t \u222a u)\"\n  proof (rule DiffE)\n    assume xst : \"x \u2208 s - t\"\n    assume xnu : \"x \u2209 u\"\n    note xst\n    then show \"x \u2208 s - (t \u222a u)\"\n    proof (rule DiffE)\n      assume xs : \"x \u2208 s\"\n      assume xnt : \"x \u2209 t\"\n      have xntu : \"x \u2209 t \u222a u\"\n      proof (rule notI)\n        assume xtu : \"x \u2208 t \u222a u\"\n        then show False\n        proof (rule UnE)\n          assume xt : \"x \u2208 t\"\n          with xnt show False\n            by (rule notE)\n        next\n          assume xu : \"x \u2208 u\"\n          with xnu show False\n            by (rule notE)\n        qed\n      qed\n      show \"x \u2208 s - (t \u222a u)\"\n        using xs xntu by (rule DiffI)\n    qed\n  qed\nqed\n\n(* 2\u00aa demostraci\u00f3n *)\nlemma \"(s - t) - u \u2286 s - (t \u222a u)\"\nproof\n  fix x\n  assume hx : \"x \u2208 (s - t) - u\"\n  then have xst : \"x \u2208 (s - t)\"\n    by simp\n  then have xs : \"x \u2208 s\"\n    by simp\n  have xnt : \"x \u2209 t\"\n    using xst by simp\n  have xnu : \"x \u2209 u\"\n    using hx by simp\n  have xntu : \"x \u2209 t \u222a u\"\n    using xnt xnu by simp\n  then show \"x \u2208 s - (t \u222a u)\"\n    using xs by simp\nqed\n\n(* 3\u00aa demostraci\u00f3n *)\nlemma \"(s - t) - u \u2286 s - (t \u222a u)\"\nproof\n  fix x\n  assume \"x \u2208 (s - t) - u\"\n  then show \"x \u2208 s - (t \u222a u)\"\n     by simp\nqed\n\n(* 4\u00aa demostraci\u00f3n *)\nlemma \"(s - t) - u \u2286 s - (t \u222a u)\"\nby auto\n\nend\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Demostrar con Lean4 que &#92;[ (s \\setminus t) \\setminus u \u2286 s \\setminus (t \u222a u) &#92;] Para ello, completar la siguiente teor\u00eda de Lean4: import Mathlib.Data.Set.Basic open Set variable {\u03b1 : Type} variable (s t u : Set \u03b1) example : (s \\ t) \\ u \u2286 s \\ (t \u222a u) := 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\/2273"}],"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=2273"}],"version-history":[{"count":3,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2273\/revisions"}],"predecessor-version":[{"id":2277,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2273\/revisions\/2277"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=2273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=2273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=2273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}