        {"id":2517,"date":"2024-05-29T06:00:37","date_gmt":"2024-05-29T04:00:37","guid":{"rendered":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/?p=2517"},"modified":"2024-05-28T20:41:43","modified_gmt":"2024-05-28T18:41:43","slug":"29-may-24","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/29-may-24\/","title":{"rendered":"La paradoja del barbero"},"content":{"rendered":"\n<p>Demostrar con Lean4 la <a href=\"https:\/\/bit.ly\/3eWyvVw\">paradoja del barbero<\/a>; es decir, que no existe un hombre que afeite a todos los que no se afeitan a s\u00ed mismo y s\u00f3lo a los que no se afeitan a s\u00ed mismo.<\/p>\n<p>Para ello, completar la siguiente teor\u00eda de Lean4:<\/p>\n<pre lang=\"lean\">\nimport Mathlib.Tactic\n\nvariable (Hombre : Type)\nvariable (afeita : Hombre \u2192 Hombre \u2192 Prop)\n\nexample :\n  \u00ac(\u2203 x : Hombre, \u2200 y : Hombre, afeita x y \u2194 \u00ac afeita y y) :=\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;[ \u00ac((\u2203 x)(\u2200 y)[&#92;text{afeita}(x,y) \u2194 \u00ac&#92;text{afeita}(y,y)]) &#92;]<br \/>\nPara ello, supongamos que<br \/>\n&#92;[ (\u2203 x)(\u2200 y)[&#92;text{afeita}(x,y) \u2194 \u00ac&#92;text{afeita}(y,y)] &#92;tag{1} &#92;]<br \/>\ny tenemos que llegar a una contradicci\u00f3n.<\/p>\n<p>Sea &#92;(b&#92;) un elemento que verifica (1); es decir,<br \/>\n&#92;[ (\u2200 y)[&#92;text{afeita}(b,y) \u2194 \u00ac&#92;text{afeita}(y,y)] &#92;]<br \/>\nEntonces,<br \/>\n&#92;[ &#92;text{afeita}(b,b) \u2194 \u00ac&#92;text{afeita}(b,b) &#92;]<br \/>\nque es una contradicci\u00f3n.<\/p>\n<h2>2. Demostraciones con Lean4<\/h2>\n<pre lang=\"lean\">\nimport Mathlib.Tactic\n\nvariable (Hombre : Type)\nvariable (afeita : Hombre \u2192 Hombre \u2192 Prop)\n\n-- 1\u00aa demostraci\u00f3n\n-- ===============\n\nexample :\n  \u00ac(\u2203 x : Hombre, \u2200 y : Hombre, afeita x y \u2194 \u00ac afeita y y) :=\nby\n  intro h\n  -- h : \u2203 x, \u2200 (y : Hombre), afeita x y \u2194 \u00acafeita y y\n  -- \u22a2 False\n  cases' h with b hb\n  -- b : Hombre\n  -- hb : \u2200 (y : Hombre), afeita b y \u2194 \u00acafeita y y\n  specialize hb b\n  -- hb : afeita b b \u2194 \u00acafeita b b\n  by_cases (afeita b b)\n  . -- h : afeita b b\n    apply absurd h\n    -- \u22a2 \u00acafeita b b\n    exact hb.mp h\n  . -- h : \u00acafeita b b\n    apply h\n    -- \u22a2 afeita b b\n    exact hb.mpr h\n\n-- 2\u00aa demostraci\u00f3n\n-- ===============\n\nexample :\n  \u00ac(\u2203 x : Hombre, \u2200 y : Hombre, afeita x y \u2194 \u00ac afeita y y) :=\nby\n  intro h\n  -- h : \u2203 x, \u2200 (y : Hombre), afeita x y \u2194 \u00acafeita y y\n  -- \u22a2 False\n  cases' h with b hb\n  -- b : Hombre\n  -- hb : \u2200 (y : Hombre), afeita b y \u2194 \u00acafeita y y\n  specialize hb b\n  -- hb : afeita b b \u2194 \u00acafeita b b\n  by_cases (afeita b b)\n  . -- h : afeita b b\n    exact (hb.mp h) h\n  . -- h : \u00acafeita b b\n    exact h (hb.mpr h)\n\n-- 3\u00aa demostraci\u00f3n\n-- ===============\n\nexample :\n  \u00ac(\u2203 x : Hombre, \u2200 y : Hombre, afeita x y \u2194 \u00ac afeita y y) :=\nby\n  intro h\n  -- h : \u2203 x, \u2200 (y : Hombre), afeita x y \u2194 \u00acafeita y y\n  -- \u22a2 False\n  cases' h with b hb\n  -- b : Hombre\n  -- hb : \u2200 (y : Hombre), afeita b y \u2194 \u00acafeita y y\n  exact iff_not_self (hb b)\n\n-- 4\u00aa demostraci\u00f3n\n-- ===============\n\nexample :\n  \u00ac (\u2203 x : Hombre,  \u2200 y : Hombre, afeita x y \u2194 \u00ac afeita y y ) :=\nby\n  rintro \u27e8b, hb\u27e9\n  -- b : Hombre\n  -- hb : \u2200 (y : Hombre), afeita b y \u2194 \u00acafeita y y\n  -- \u22a2 False\n  exact iff_not_self (hb b)\n\n-- 5\u00aa demostraci\u00f3n\n-- ===============\n\nexample :\n  \u00ac (\u2203 x : Hombre,  \u2200 y : Hombre, afeita x y \u2194 \u00ac afeita y y ) :=\nfun \u27e8b, hb\u27e9 \u21a6 iff_not_self (hb b)\n\n-- Lemas usados\n-- ============\n\n-- variable (p q : Prop)\n-- #check (absurd : p \u2192 (\u00acp \u2192 q))\n-- #check (iff_not_self : \u00ac(p \u2194 \u00acp))\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\/La_paradoja_del_barbero.lean\">Lean 4 Web<\/a>.<\/p>\n<h2>3. Demostraciones con Isabelle\/HOL<\/h2>\n<pre lang=\"isar\">\ntheory La_paradoja_del_barbero\nimports Main\nbegin\n\n(* 1\u00aa demostraci\u00f3n *)\n\nlemma\n  \"\u00ac(\u2203 x::'H. \u2200 y::'H. afeita x y \u27f7 \u00ac afeita y y)\"\nproof (rule notI)\n  assume \"\u2203 x. \u2200 y. afeita x y \u27f7 \u00ac afeita y y\"\n  then obtain b where \"\u2200 y. afeita b y \u27f7 \u00ac afeita y y\"\n    by (rule exE)\n  then have h : \"afeita b b \u27f7 \u00ac afeita b b\"\n    by (rule allE)\n  show False\n  proof (cases \"afeita b b\")\n    assume \"afeita b b\"\n    then have \"\u00ac afeita b b\"\n      using h by (rule rev_iffD1)\n    then show False\n      using \u2039afeita b b\u203a by (rule notE)\n  next\n    assume \"\u00ac afeita b b\"\n    then have \"afeita b b\"\n      using h by (rule rev_iffD2)\n    with \u2039\u00ac afeita b b\u203a show False\n      by (rule notE)\n  qed\nqed\n\n(* 2\u00aa demostraci\u00f3n *)\n\nlemma\n  \"\u00ac(\u2203 x::'H. \u2200 y::'H. afeita x y \u27f7 \u00ac afeita y y)\"\nproof\n  assume \"\u2203 x. \u2200 y. afeita x y \u27f7 \u00ac afeita y y\"\n  then obtain b where \"\u2200 y. afeita b y \u27f7 \u00ac afeita y y\"\n    by (rule exE)\n  then have h : \"afeita b b \u27f7 \u00ac afeita b b\"\n    by (rule allE)\n  then show False\n    by simp\nqed\n\n(* 3\u00aa demostraci\u00f3n *)\n\nlemma\n  \"\u00ac(\u2203 x::'H. \u2200 y::'H. afeita x y \u27f7 \u00ac afeita y y)\"\n  by auto\n\nend\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Demostrar con Lean4 la paradoja del barbero; es decir, que no existe un hombre que afeite a todos los que no se afeitan a s\u00ed mismo y s\u00f3lo a los que no se afeitan a s\u00ed mismo. Para ello, completar la siguiente teor\u00eda de Lean4: import Mathlib.Tactic variable (Hombre : Type) variable (afeita : Hombre \u2192 Hombre \u2192 Prop) example : \u00ac(\u2203 x : Hombre, \u2200 y : Hombre, afeita x y \u2194 \u00ac afeita y y) := 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":[103],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2517"}],"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=2517"}],"version-history":[{"count":2,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2517\/revisions"}],"predecessor-version":[{"id":2519,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/posts\/2517\/revisions\/2519"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/media?parent=2517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/categories?post=2517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/calculemus\/wp-json\/wp\/v2\/tags?post=2517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}