        {"id":687,"date":"2021-08-27T06:00:24","date_gmt":"2021-08-27T04:00:24","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=687"},"modified":"2021-08-21T12:45:36","modified_gmt":"2021-08-21T10:45:36","slug":"las-particiones-definen-relaciones-transitivas","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/las-particiones-definen-relaciones-transitivas\/","title":{"rendered":"Las particiones definen relaciones transitivas"},"content":{"rendered":"<p>Cada familia de conjuntos P define una relaci\u00f3n de forma que dos elementos est\u00e1n relacionados si alg\u00fan conjunto de P contiene a ambos elementos. Se puede definir en Lean por<\/p>\n<pre lang=\"text\">\n   def relacion (P : set (set X)) (x y : X) :=\n     \u2203 A \u2208 P, x \u2208 A \u2227 y \u2208 A\n<\/pre>\n<p>Una familia de subconjuntos de X es una partici\u00f3n de X si cada  de X pertenece a un \u00fanico conjunto de P y todos los elementos de P son no vac\u00edos. Se puede definir en Lean por<\/p>\n<pre lang=\"text\">\n   def particion (P : set (set X)) : Prop :=\n     (\u2200 x, (\u2203 B \u2208 P, x \u2208 B \u2227 \u2200 C \u2208 P, x \u2208 C \u2192 B = C)) \u2227 \u2205 \u2209 P\n<\/pre>\n<p>Demostrar que si P es una partici\u00f3n de X, entonces la relaci\u00f3n definida por P es transitiva.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/p>\n<pre lang=\"lean\">\nimport tactic\n\nvariable {X : Type}\nvariable (P : set (set X))\n\ndef relacion (P : set (set X)) (x y : X) :=\n  \u2203 A \u2208 P, x \u2208 A \u2227 y \u2208 A\n\ndef particion (P : set (set X)) : Prop :=\n  (\u2200 x, (\u2203 B \u2208 P, x \u2208 B \u2227 \u2200 C \u2208 P, x \u2208 C \u2192 B = C)) \u2227 \u2205 \u2209 P\n\nexample\n  (h : particion P)\n  : transitive (relacion P) :=\nsorry\n<\/pre>\n<p>[expand title=\u00bbSoluciones con Lean\u00bb]<\/p>\n<pre lang=\"lean\">\r\nimport tactic\r\n\r\nvariable {X : Type}\r\nvariable (P : set (set X))\r\n\r\ndef relacion (P : set (set X)) (x y : X) :=\r\n  \u2203 A \u2208 P, x \u2208 A \u2227 y \u2208 A\r\n\r\ndef particion (P : set (set X)) : Prop :=\r\n  (\u2200 x, (\u2203 B \u2208 P, x \u2208 B \u2227 \u2200 C \u2208 P, x \u2208 C \u2192 B = C)) \u2227 \u2205 \u2209 P\r\n\r\n-- 1\u00aa demostraci\u00f3n\r\nexample\r\n  (h : particion P)\r\n  : transitive (relacion P) :=\r\nbegin\r\n  unfold transitive,\r\n  intros x y z h1 h2,\r\n  unfold relacion at *,\r\n  rcases h1 with \u27e8B1, hB1P, hxB1, hyB1\u27e9,\r\n  rcases h2 with \u27e8B2, hB2P, hyB2, hzB2\u27e9,\r\n  use B1,\r\n  repeat { split },\r\n  { exact hB1P, },\r\n  { exact hxB1, },\r\n  { convert hzB2,\r\n    rcases (h.1 y) with \u27e8B, -, -, hB\u27e9,\r\n    have hBB1 : B = B1 := hB B1 hB1P hyB1,\r\n    have hBB2 : B = B2 := hB B2 hB2P hyB2,\r\n    exact eq.trans hBB1.symm hBB2, },\r\nend\r\n\r\n-- 2\u00aa demostraci\u00f3n\r\nexample\r\n  (h : particion P)\r\n  : transitive (relacion P) :=\r\nbegin\r\n  rintros x y z \u27e8B1,hB1P,hxB1,hyB1\u27e9 \u27e8B2,hB2P,hyB2,hzB2\u27e9,\r\n  use B1,\r\n  repeat { split },\r\n  { exact hB1P, },\r\n  { exact hxB1, },\r\n  { convert hzB2,\r\n    rcases (h.1 y) with \u27e8B, -, -, hB\u27e9,\r\n    exact eq.trans (hB B1 hB1P hyB1).symm (hB B2 hB2P hyB2), },\r\nend\r\n\r\n-- 3\u00aa demostraci\u00f3n\r\nexample\r\n  (h : particion P)\r\n  : transitive (relacion P) :=\r\nbegin\r\n  rintros x y z \u27e8B1,hB1P,hxB1,hyB1\u27e9 \u27e8B2,hB2P,hyB2,hzB2\u27e9,\r\n  use [B1, \u27e8hB1P,\r\n            hxB1,\r\n            by { convert hzB2,\r\n                 rcases (h.1 y) with \u27e8B, -, -, hB\u27e9,\r\n                 exact eq.trans (hB B1 hB1P hyB1).symm\r\n                                (hB B2 hB2P hyB2), }\u27e9],\r\nend\r\n<\/pre>\n<p>Se puede interactuar con la prueba anterior en <a href=\"https:\/\/leanprover-community.github.io\/lean-web-editor\/#url=https:\/\/raw.githubusercontent.com\/jaalonso\/Calculemus\/main\/src\/Las_particiones_definen_relaciones_transitivas.lean\" rel=\"noopener noreferrer\" target=\"_blank\">esta sesi\u00f3n con Lean<\/a>.<\/p>\n<p>En los comentarios se pueden escribir otras soluciones, escribiendo el c\u00f3digo entre una l\u00ednea con &#60;pre lang=&quot;lean&quot;&#62; y otra con &#60;\/pre&#62;<br \/>\n[\/expand]<\/p>\n<p>[expand title=\u00bbSoluciones con Isabelle\/HOL\u00bb]<\/p>\n<pre lang=\"isar\">\r\ntheory Las_particiones_definen_relaciones_transitivas\r\nimports Main\r\nbegin\r\n\r\ndefinition relacion :: \"('a set) set \u21d2 'a \u21d2 'a \u21d2 bool\" where\r\n  \"relacion P x y \u27f7 (\u2203A\u2208P. x \u2208 A \u2227 y \u2208 A)\"\r\n\r\ndefinition particion :: \"('a set) set \u21d2 bool\" where\r\n  \"particion P \u27f7 (\u2200x. (\u2203B\u2208P. x \u2208 B \u2227 (\u2200C\u2208P. x \u2208 C \u27f6 B = C))) \u2227 {} \u2209 P\"\r\n\r\n(* 1\u00aa demostraci\u00f3n *)\r\nlemma\r\n  assumes \"particion P\"\r\n  shows   \"transp (relacion P)\"\r\nproof (rule transpI)\r\n  fix x y z\r\n  assume \"relacion P x y\" and \"relacion P y z\"\r\n  have \"\u2203A\u2208P. x \u2208 A \u2227 y \u2208 A\"\r\n    using \u2039relacion P x y\u203a\r\n    by (simp only: relacion_def)\r\n  then obtain A where \"A \u2208 P\" and hA : \"x \u2208 A \u2227 y \u2208 A\"\r\n    by (rule bexE)\r\n  have \"\u2203B\u2208P. y \u2208 B \u2227 z \u2208 B\"\r\n    using \u2039relacion P y z\u203a\r\n    by (simp only: relacion_def)\r\n  then obtain B where \"B \u2208 P\" and hB : \"y \u2208 B \u2227 z \u2208 B\"\r\n    by (rule bexE)\r\n  have \"A = B\"\r\n  proof -\r\n    have \"\u2203C \u2208 P. y \u2208 C \u2227 (\u2200D\u2208P. y \u2208 D \u27f6 C = D)\"\r\n      using assms\r\n      by (simp only: particion_def)\r\n    then obtain C where \"C \u2208 P\"\r\n                    and hC : \"y \u2208 C \u2227 (\u2200D\u2208P. y \u2208 D \u27f6 C = D)\"\r\n      by (rule bexE)\r\n    have hC' : \"\u2200D\u2208P. y \u2208 D \u27f6 C = D\"\r\n      using hC by (rule conjunct2)\r\n    have \"C = A\"\r\n      using \u2039A \u2208 P\u203a hA hC' by simp\r\n    moreover have \"C = B\"\r\n      using \u2039B \u2208 P\u203a hB hC by simp\r\n    ultimately show \"A = B\"\r\n      by (rule subst)\r\n  qed\r\n  then have \"x \u2208 A \u2227 z \u2208 A\"\r\n    using hA hB by simp\r\n  then have \"\u2203A\u2208P. x \u2208 A \u2227 z \u2208 A\"\r\n    using \u2039A \u2208 P\u203a by (rule bexI)\r\n  then show \"relacion P x z\"\r\n    using \u2039A = B\u203a \u2039A \u2208 P\u203a\r\n    by (unfold relacion_def)\r\nqed\r\n\r\n(* 2\u00aa demostraci\u00f3n *)\r\nlemma\r\n  assumes \"particion P\"\r\n  shows   \"transp (relacion P)\"\r\nproof (rule transpI)\r\n  fix x y z\r\n  assume \"relacion P x y\" and \"relacion P y z\"\r\n  obtain A where \"A \u2208 P\" and hA : \"x \u2208 A \u2227 y \u2208 A\"\r\n    using \u2039relacion P x y\u203a\r\n    by (meson relacion_def)\r\n  obtain B where \"B \u2208 P\" and hB : \"y \u2208 B \u2227 z \u2208 B\"\r\n    using \u2039relacion P y z\u203a\r\n    by (meson relacion_def)\r\n  have \"A = B\"\r\n  proof -\r\n    obtain C where \"C \u2208 P\" and hC : \"y \u2208 C \u2227 (\u2200D\u2208P. y \u2208 D \u27f6 C = D)\"\r\n      using assms particion_def\r\n      by metis\r\n    have \"C = A\"\r\n      using \u2039A \u2208 P\u203a hA hC by auto\r\n    moreover have \"C = B\"\r\n      using \u2039B \u2208 P\u203a hB hC by auto\r\n    ultimately show \"A = B\"\r\n      by simp\r\n  qed\r\n  then have \"x \u2208 A \u2227 z \u2208 A\"\r\n    using hA hB by auto\r\n  then show \"relacion P x z\"\r\n    using \u2039A = B\u203a \u2039A \u2208 P\u203a relacion_def\r\n    by metis\r\nqed\r\n\r\n(* 3\u00aa demostraci\u00f3n *)\r\nlemma\r\n  assumes \"particion P\"\r\n  shows   \"transp (relacion P)\"\r\n  using assms particion_def relacion_def\r\n  by (smt (verit) transpI)\r\n\r\nend\r\n<\/pre>\n<p>En los comentarios se pueden escribir otras soluciones, escribiendo el c\u00f3digo entre una l\u00ednea con &#60;pre lang=&quot;isar&quot;&#62; y otra con &#60;\/pre&#62;<br \/>\n[\/expand]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cada familia de conjuntos P define una relaci\u00f3n de forma que dos elementos est\u00e1n relacionados si alg\u00fan conjunto de P contiene a ambos elementos. Se puede definir en Lean por def relacion (P : set (set X)) (x y : X) := \u2203 A \u2208 P, x \u2208 A \u2227 y \u2208 A Una familia de subconjuntos de X es una partici\u00f3n de X si cada de X pertenece a un \u00fanico conjunto de P y todos los elementos de P son no vac\u00edos. Se puede definir en Lean por def particion (P : set (set X)) : Prop := (\u2200 x, (\u2203 B \u2208 P, x \u2208 B \u2227 \u2200 C \u2208 P, x \u2208 C \u2192 B = C)) \u2227 \u2205 \u2209 P&#8230;<\/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":"","_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,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[29],"tags":[77,66,59,57,76,60,51,100,75,68,73,69,71,49,63,45,47,70,48,72,46],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/687"}],"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=687"}],"version-history":[{"count":1,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/687\/revisions"}],"predecessor-version":[{"id":688,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/687\/revisions\/688"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}