src/HOL/Examples/Peirce.thy
author paulson <lp15@cam.ac.uk>
Mon, 03 Jul 2023 11:45:59 +0100
changeset 78248 740b23f1138a
parent 71925 bf085daea304
permissions -rw-r--r--
EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
71925
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
     1
(*  Title:      HOL/Examples/Peirce.thy
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
     3
*)
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
     4
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
     5
section \<open>Peirce's Law\<close>
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
     6
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
     7
theory Peirce
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
     8
  imports Main
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
     9
begin
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    10
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    11
text \<open>
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    12
  We consider Peirce's Law: \<open>((A \<longrightarrow> B) \<longrightarrow> A) \<longrightarrow> A\<close>. This is an inherently
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    13
  non-intuitionistic statement, so its proof will certainly involve some form
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    14
  of classical contradiction.
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    15
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    16
  The first proof is again a well-balanced combination of plain backward and
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    17
  forward reasoning. The actual classical step is where the negated goal may
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    18
  be introduced as additional assumption. This eventually leads to a
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    19
  contradiction.\<^footnote>\<open>The rule involved there is negation elimination; it holds in
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    20
  intuitionistic logic as well.\<close>\<close>
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    21
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    22
theorem "((A \<longrightarrow> B) \<longrightarrow> A) \<longrightarrow> A"
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    23
proof
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    24
  assume "(A \<longrightarrow> B) \<longrightarrow> A"
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    25
  show A
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    26
  proof (rule classical)
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    27
    assume "\<not> A"
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    28
    have "A \<longrightarrow> B"
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    29
    proof
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    30
      assume A
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    31
      with \<open>\<not> A\<close> show B by contradiction
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    32
    qed
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    33
    with \<open>(A \<longrightarrow> B) \<longrightarrow> A\<close> show A ..
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    34
  qed
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    35
qed
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    36
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    37
text \<open>
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    38
  In the subsequent version the reasoning is rearranged by means of ``weak
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    39
  assumptions'' (as introduced by \<^theory_text>\<open>presume\<close>). Before assuming the negated
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    40
  goal \<open>\<not> A\<close>, its intended consequence \<open>A \<longrightarrow> B\<close> is put into place in order to
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    41
  solve the main problem. Nevertheless, we do not get anything for free, but
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    42
  have to establish \<open>A \<longrightarrow> B\<close> later on. The overall effect is that of a logical
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    43
  \<^emph>\<open>cut\<close>.
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    44
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    45
  Technically speaking, whenever some goal is solved by \<^theory_text>\<open>show\<close> in the context
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    46
  of weak assumptions then the latter give rise to new subgoals, which may be
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    47
  established separately. In contrast, strong assumptions (as introduced by
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    48
  \<^theory_text>\<open>assume\<close>) are solved immediately.
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    49
\<close>
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    50
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    51
theorem "((A \<longrightarrow> B) \<longrightarrow> A) \<longrightarrow> A"
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    52
proof
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    53
  assume "(A \<longrightarrow> B) \<longrightarrow> A"
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    54
  show A
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    55
  proof (rule classical)
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    56
    presume "A \<longrightarrow> B"
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    57
    with \<open>(A \<longrightarrow> B) \<longrightarrow> A\<close> show A ..
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    58
  next
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    59
    assume "\<not> A"
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    60
    show "A \<longrightarrow> B"
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    61
    proof
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    62
      assume A
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    63
      with \<open>\<not> A\<close> show B by contradiction
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    64
    qed
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    65
  qed
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    66
qed
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    67
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    68
text \<open>
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    69
  Note that the goals stemming from weak assumptions may be even left until
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    70
  qed time, where they get eventually solved ``by assumption'' as well. In
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    71
  that case there is really no fundamental difference between the two kinds of
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    72
  assumptions, apart from the order of reducing the individual parts of the
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    73
  proof configuration.
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    74
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    75
  Nevertheless, the ``strong'' mode of plain assumptions is quite important in
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    76
  practice to achieve robustness of proof text interpretation. By forcing both
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    77
  the conclusion \<^emph>\<open>and\<close> the assumptions to unify with the pending goal to be
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    78
  solved, goal selection becomes quite deterministic. For example,
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    79
  decomposition with rules of the ``case-analysis'' type usually gives rise to
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    80
  several goals that only differ in there local contexts. With strong
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    81
  assumptions these may be still solved in any order in a predictable way,
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    82
  while weak ones would quickly lead to great confusion, eventually demanding
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    83
  even some backtracking.
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    84
\<close>
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    85
bf085daea304 clarified sessions: "Notable Examples in Isabelle/HOL";
wenzelm
parents:
diff changeset
    86
end