        {"id":683,"date":"2021-08-25T06:00:33","date_gmt":"2021-08-25T04:00:33","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=683"},"modified":"2021-08-19T16:25:46","modified_gmt":"2021-08-19T14:25:46","slug":"las-particiones-definen-relaciones-reflexivas","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/las-particiones-definen-relaciones-reflexivas\/","title":{"rendered":"Las particiones definen relaciones reflexivas"},"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 elemento 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 reflexiva.<\/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  : reflexive (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  : reflexive (relacion P) :=\r\nbegin\r\n  unfold reflexive,\r\n  intro x,\r\n  unfold relacion,\r\n  unfold particion at h,\r\n  replace h : \u2203 A \u2208 P, x \u2208 A \u2227 \u2200 B \u2208 P, x \u2208 B \u2192 A = B := h.1 x,\r\n  rcases h with \u27e8A, hAP, hxA, -\u27e9,\r\n  use A,\r\n  repeat { split },\r\n  { exact hAP, },\r\n  { exact hxA, },\r\n  { exact hxA, },\r\nend\r\n\r\n-- 2\u00aa demostraci\u00f3n\r\nexample\r\n  (h : particion P)\r\n  : reflexive (relacion P) :=\r\nbegin\r\n  intro x,\r\n  replace h : \u2203 A \u2208 P, x \u2208 A \u2227 \u2200 B \u2208 P, x \u2208 B \u2192 A = B := h.1 x,\r\n  rcases h with \u27e8A, hAP, hxA, -\u27e9,\r\n  use A,\r\n  repeat { split } ; assumption,\r\nend\r\n\r\n-- 3\u00aa demostraci\u00f3n\r\nexample\r\n  (h : particion P)\r\n  : reflexive (relacion P) :=\r\nbegin\r\n  intro x,\r\n  rcases (h.1 x) with \u27e8A, hAP, hxA, -\u27e9,\r\n  use A,\r\n  repeat { split } ; assumption,\r\nend\r\n\r\n-- 4\u00aa demostraci\u00f3n\r\nexample\r\n  (h : particion P)\r\n  : reflexive (relacion P) :=\r\nbegin\r\n  intro x,\r\n  rcases (h.1 x) with \u27e8A, hAP, hxA, -\u27e9,\r\n  use [A, \u27e8hAP, hxA, hxA\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_reflexivas.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_reflexivas\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\nru(* 1\u00aa demostraci\u00f3n *)\r\nlemma\r\n  assumes \"particion P\"\r\n  shows   \"reflp (relacion P)\"\r\nproof (rule reflpI)\r\n  fix x\r\n  have \"(\u2200x. (\u2203B\u2208P. x \u2208 B \u2227 (\u2200C\u2208P. x \u2208 C \u27f6 B = C))) \u2227 {} \u2209 P\"\r\n    using assms by (unfold particion_def)\r\n  then have \"\u2200x. (\u2203B\u2208P. x \u2208 B \u2227 (\u2200C\u2208P. x \u2208 C \u27f6 B = C))\"\r\n    by (rule conjunct1)\r\n  then have \"\u2203B\u2208P. x \u2208 B \u2227 (\u2200C\u2208P. x \u2208 C \u27f6 B = C)\"\r\n    by (rule allE)\r\n  then obtain B where \"B \u2208 P \u2227 (x \u2208 B \u2227 (\u2200C\u2208P. x \u2208 C \u27f6 B = C))\"\r\n    by (rule someI2_bex)\r\n  then obtain B where \"(B \u2208 P \u2227 x \u2208 B) \u2227 (\u2200C\u2208P. x \u2208 C \u27f6 B = C)\"\r\n    by (simp only: conj_assoc)\r\n  then have \"B \u2208 P \u2227 x \u2208 B\"\r\n    by (rule conjunct1)\r\n  then have \"x \u2208 B\"\r\n    by (rule conjunct2)\r\n  then have \"x \u2208 B \u2227 x \u2208 B\"\r\n    using \u2039x \u2208 B\u203a by (rule conjI)\r\n  moreover have \"B \u2208 P\"\r\n    using \u2039B \u2208 P \u2227 x \u2208 B\u203a by (rule conjunct1)\r\n  ultimately have \"\u2203B\u2208P. x \u2208 B \u2227 x \u2208 B\"\r\n    by (rule bexI)\r\n  then show \"relacion P x x\"\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   \"reflp (relacion P)\"\r\nproof (rule reflpI)\r\n  fix x\r\n  obtain A where \"A \u2208 P \u2227 x \u2208 A\"\r\n    using assms particion_def\r\n    by metis\r\n  then show \"relacion P x x\"\r\n    using 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   \"reflp (relacion P)\"\r\n  using assms particion_def relacion_def\r\n  by (metis reflp_def)\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 elemento 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&#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":[54,59,56,58,53,57,60,61,52,51,55,50,49,43,45,40,47,44,48,46],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/683"}],"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=683"}],"version-history":[{"count":1,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/683\/revisions"}],"predecessor-version":[{"id":684,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/683\/revisions\/684"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}