        {"id":665,"date":"2021-08-19T06:00:49","date_gmt":"2021-08-19T04:00:49","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=665"},"modified":"2021-08-10T11:36:40","modified_gmt":"2021-08-10T09:36:40","slug":"la-igualdad-de-valores-es-una-relacion-de-equivalencia","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/la-igualdad-de-valores-es-una-relacion-de-equivalencia\/","title":{"rendered":"La igualdad de valores es una relaci\u00f3n de equivalencia"},"content":{"rendered":"<p>Sean X e Y dos conjuntos y f una funci\u00f3n de X en Y. Se define la relaci\u00f3n R en X de forma que x est\u00e1 relacionado con y si f(x) = f(y).<\/p>\n<p>Demostrar que R es una relaci\u00f3n de equivalencia.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean:<\/p>\n<pre lang=\"lean\">\nimport tactic\n\nuniverse u\nvariables {X Y : Type u}\nvariable  (f : X \u2192 Y)\n\ndef R (x y : X) := f x = f y\n\nexample : equivalence (R f) :=\nsorry\n<\/pre>\n<p>[expand title=\u00bbSoluciones con Lean\u00bb]<\/p>\n<pre lang=\"lean\">\r\nimport tactic\r\n\r\nuniverse u\r\nvariables {X Y : Type u}\r\nvariable  (f : X \u2192 Y)\r\n\r\ndef R (x y : X) := f x = f y\r\n\r\n-- 1\u00aa demostraci\u00f3n\r\nexample : equivalence (R f) :=\r\nbegin\r\n  unfold equivalence,\r\n  repeat { split },\r\n  { unfold reflexive,\r\n    intro x,\r\n    unfold R, },\r\n  { unfold symmetric,\r\n    intros x y hxy,\r\n    unfold R,\r\n    exact symm hxy, },\r\n  { unfold transitive,\r\n    unfold R,\r\n    intros x y z hxy hyz,\r\n    exact eq.trans hxy hyz, },\r\nend\r\n\r\n-- 2\u00aa demostraci\u00f3n\r\nexample : equivalence (R f) :=\r\nbegin\r\n  repeat { split },\r\n  { intro x,\r\n    exact rfl, },\r\n  { intros x y hxy,\r\n    exact eq.symm hxy, },\r\n  { intros x y z hxy hyz,\r\n    exact eq.trans hxy hyz, },\r\nend\r\n\r\n-- 3\u00aa demostraci\u00f3n\r\nexample : equivalence (R f) :=\r\nbegin\r\n  repeat { split },\r\n  { exact \u03bb x, rfl, },\r\n  { exact \u03bb x y hxy, eq.symm hxy, },\r\n  { exact \u03bb x y z hxy hyz, eq.trans hxy hyz, },\r\nend\r\n\r\n-- 4\u00aa demostraci\u00f3n\r\nexample : equivalence (R f) :=\r\n\u27e8\u03bb x, rfl,\r\n \u03bb x y hxy, eq.symm hxy,\r\n \u03bb x y z hxy hyz, eq.trans hxy hyz\u27e9\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\/La_igualdad_de_valores_es_una_relacion_de_equivalencia.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 La_igualdad_de_valores_es_una_relacion_de_equivalencia\r\nimports Main\r\nbegin\r\n\r\ndefinition R :: \"('a \u21d2 'b) \u21d2 'a \u21d2 'a \u21d2 bool\" where\r\n  \"R f x y \u27f7 (f x = f y)\"\r\n\r\n(* 1\u00aa demostraci\u00f3n *)\r\nlemma \"equivp (R f)\"\r\nproof (rule equivpI)\r\n  show \"reflp (R f)\"\r\n  proof (rule reflpI)\r\n    fix x\r\n    have \"f x = f x\"\r\n      by (rule refl)\r\n    then show \"R f x x\"\r\n      by (unfold R_def)\r\n  qed\r\nnext\r\n  show \"symp (R f)\"\r\n  proof (rule sympI)\r\n    fix x y\r\n    assume \"R f x y\"\r\n    then have \"f x = f y\"\r\n      by (unfold R_def)\r\n    then have \"f y = f x\"\r\n      by (rule sym)\r\n    then show \"R f y x\"\r\n      by (unfold R_def)\r\n  qed\r\nnext\r\n  show \"transp (R f)\"\r\n  proof (rule transpI)\r\n    fix x y z\r\n    assume \"R f x y\" and \"R f y z\"\r\n    then have \"f x = f y\" and \"f y = f z\"\r\n      by (unfold R_def)\r\n    then have \"f x = f z\"\r\n      by (rule ssubst)\r\n    then show \"R f x z\"\r\n      by (unfold R_def)\r\n  qed\r\nqed\r\n\r\n(* 2\u00aa demostraci\u00f3n *)\r\nlemma \"equivp (R f)\"\r\nproof (rule equivpI)\r\n  show \"reflp (R f)\"\r\n  proof (rule reflpI)\r\n    fix x\r\n    show \"R f x x\"\r\n      by (metis R_def)\r\n  qed\r\nnext\r\n  show \"symp (R f)\"\r\n  proof (rule sympI)\r\n    fix x y\r\n    assume \"R f x y\"\r\n    then show \"R f y x\"\r\n      by (metis R_def)\r\n  qed\r\nnext\r\n  show \"transp (R f)\"\r\n  proof (rule transpI)\r\n    fix x y z\r\n    assume \"R f x y\" and \"R f y z\"\r\n    then show \"R f x z\"\r\n      by (metis R_def)\r\n  qed\r\nqed\r\n\r\n(* 3\u00aa demostraci\u00f3n *)\r\nlemma \"equivp (R f)\"\r\nproof (rule equivpI)\r\n  show \"reflp (R f)\"\r\n    by (simp add: R_def reflpI)\r\nnext\r\n  show \"symp (R f)\"\r\n    by (metis R_def sympI)\r\nnext\r\n  show \"transp (R f)\"\r\n    by (metis R_def transpI)\r\nqed\r\n\r\n(* 4\u00aa demostraci\u00f3n *)\r\nlemma \"equivp (R f)\"\r\n  by (metis R_def\r\n            equivpI\r\n            reflpI\r\n            sympI\r\n            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>Sean X e Y dos conjuntos y f una funci\u00f3n de X en Y. Se define la relaci\u00f3n R en X de forma que x est\u00e1 relacionado con y si f(x) = f(y). Demostrar que R es una relaci\u00f3n de equivalencia. Para ello, completar la siguiente teor\u00eda de Lean: import tactic universe u variables {X Y : Type u} variable (f : X \u2192 Y) def R (x y : X) := f x = f y example : equivalence (R f) := sorry [expand title=\u00bbSoluciones con Lean\u00bb] import tactic universe u variables {X Y : Type u} variable (f : X \u2192 Y) def R (x y : X) := f x = f y &#8212; 1\u00aa demostraci\u00f3n example : equivalence (R f) :=&#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":[30],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/665"}],"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=665"}],"version-history":[{"count":1,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/665\/revisions"}],"predecessor-version":[{"id":666,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/665\/revisions\/666"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}