src/HOL/Isar_Examples/Peirce.thy
author immler
Thu, 03 May 2018 15:07:14 +0200
changeset 68073 fad29d2a17a5
parent 63585 f4a308fdf664
permissions -rw-r--r--
merged; resolved conflicts manually (esp. lemmas that have been moved from Linear_Algebra and Cartesian_Euclidean_Space)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33026
8f35633c4922 modernized session Isar_Examples;
wenzelm
parents: 31758
diff changeset
     1
(*  Title:      HOL/Isar_Examples/Peirce.thy
61932
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
     2
    Author:     Makarius
6444
2ebe9e630cab Miscellaneous Isabelle/Isar examples for Higher-Order Logic.
wenzelm
parents:
diff changeset
     3
*)
2ebe9e630cab Miscellaneous Isabelle/Isar examples for Higher-Order Logic.
wenzelm
parents:
diff changeset
     4
58882
6e2010ab8bd9 modernized header;
wenzelm
parents: 58614
diff changeset
     5
section \<open>Peirce's Law\<close>
6444
2ebe9e630cab Miscellaneous Isabelle/Isar examples for Higher-Order Logic.
wenzelm
parents:
diff changeset
     6
31758
3edd5f813f01 observe standard theory naming conventions;
wenzelm
parents: 23373
diff changeset
     7
theory Peirce
63585
wenzelm
parents: 61932
diff changeset
     8
  imports Main
31758
3edd5f813f01 observe standard theory naming conventions;
wenzelm
parents: 23373
diff changeset
     9
begin
6444
2ebe9e630cab Miscellaneous Isabelle/Isar examples for Higher-Order Logic.
wenzelm
parents:
diff changeset
    10
61932
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    11
text \<open>
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    12
  We consider Peirce's Law: \<open>((A \<longrightarrow> B) \<longrightarrow> A) \<longrightarrow> A\<close>. This is an inherently
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    13
  non-intuitionistic statement, so its proof will certainly involve some form
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    14
  of classical contradiction.
7860
7819547df4d8 improved presentation;
wenzelm
parents: 7748
diff changeset
    15
61541
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    16
  The first proof is again a well-balanced combination of plain backward and
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    17
  forward reasoning. The actual classical step is where the negated goal may
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    18
  be introduced as additional assumption. This eventually leads to a
61932
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    19
  contradiction.\<^footnote>\<open>The rule involved there is negation elimination; it holds in
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    20
  intuitionistic logic as well.\<close>\<close>
7860
7819547df4d8 improved presentation;
wenzelm
parents: 7748
diff changeset
    21
55640
abc140f21caa tuned proofs;
wenzelm
parents: 37671
diff changeset
    22
theorem "((A \<longrightarrow> B) \<longrightarrow> A) \<longrightarrow> A"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    23
proof
55640
abc140f21caa tuned proofs;
wenzelm
parents: 37671
diff changeset
    24
  assume "(A \<longrightarrow> B) \<longrightarrow> A"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    25
  show A
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    26
  proof (rule classical)
55640
abc140f21caa tuned proofs;
wenzelm
parents: 37671
diff changeset
    27
    assume "\<not> A"
abc140f21caa tuned proofs;
wenzelm
parents: 37671
diff changeset
    28
    have "A \<longrightarrow> B"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    29
    proof
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    30
      assume A
58614
7338eb25226c more cartouches;
wenzelm
parents: 55640
diff changeset
    31
      with \<open>\<not> A\<close> show B by contradiction
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    32
    qed
58614
7338eb25226c more cartouches;
wenzelm
parents: 55640
diff changeset
    33
    with \<open>(A \<longrightarrow> B) \<longrightarrow> A\<close> show A ..
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    34
  qed
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    35
qed
6444
2ebe9e630cab Miscellaneous Isabelle/Isar examples for Higher-Order Logic.
wenzelm
parents:
diff changeset
    36
61932
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    37
text \<open>
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    38
  In the subsequent version the reasoning is rearranged by means of ``weak
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    39
  assumptions'' (as introduced by \<^theory_text>\<open>presume\<close>). Before assuming the negated
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    40
  goal \<open>\<not> A\<close>, its intended consequence \<open>A \<longrightarrow> B\<close> is put into place in order to
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    41
  solve the main problem. Nevertheless, we do not get anything for free, but
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    42
  have to establish \<open>A \<longrightarrow> B\<close> later on. The overall effect is that of a logical
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    43
  \<^emph>\<open>cut\<close>.
7860
7819547df4d8 improved presentation;
wenzelm
parents: 7748
diff changeset
    44
61932
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    45
  Technically speaking, whenever some goal is solved by \<^theory_text>\<open>show\<close> in the context
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    46
  of weak assumptions then the latter give rise to new subgoals, which may be
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    47
  established separately. In contrast, strong assumptions (as introduced by
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    48
  \<^theory_text>\<open>assume\<close>) are solved immediately.
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    49
\<close>
7860
7819547df4d8 improved presentation;
wenzelm
parents: 7748
diff changeset
    50
55640
abc140f21caa tuned proofs;
wenzelm
parents: 37671
diff changeset
    51
theorem "((A \<longrightarrow> B) \<longrightarrow> A) \<longrightarrow> A"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    52
proof
55640
abc140f21caa tuned proofs;
wenzelm
parents: 37671
diff changeset
    53
  assume "(A \<longrightarrow> B) \<longrightarrow> A"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    54
  show A
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    55
  proof (rule classical)
55640
abc140f21caa tuned proofs;
wenzelm
parents: 37671
diff changeset
    56
    presume "A \<longrightarrow> B"
58614
7338eb25226c more cartouches;
wenzelm
parents: 55640
diff changeset
    57
    with \<open>(A \<longrightarrow> B) \<longrightarrow> A\<close> show A ..
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    58
  next
55640
abc140f21caa tuned proofs;
wenzelm
parents: 37671
diff changeset
    59
    assume "\<not> A"
abc140f21caa tuned proofs;
wenzelm
parents: 37671
diff changeset
    60
    show "A \<longrightarrow> B"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    61
    proof
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    62
      assume A
58614
7338eb25226c more cartouches;
wenzelm
parents: 55640
diff changeset
    63
      with \<open>\<not> A\<close> show B by contradiction
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    64
    qed
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    65
  qed
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    66
qed
6444
2ebe9e630cab Miscellaneous Isabelle/Isar examples for Higher-Order Logic.
wenzelm
parents:
diff changeset
    67
61932
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    68
text \<open>
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    69
  Note that the goals stemming from weak assumptions may be even left until
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    70
  qed time, where they get eventually solved ``by assumption'' as well. In
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    71
  that case there is really no fundamental difference between the two kinds of
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    72
  assumptions, apart from the order of reducing the individual parts of the
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    73
  proof configuration.
7860
7819547df4d8 improved presentation;
wenzelm
parents: 7748
diff changeset
    74
61932
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    75
  Nevertheless, the ``strong'' mode of plain assumptions is quite important in
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    76
  practice to achieve robustness of proof text interpretation. By forcing both
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    77
  the conclusion \<^emph>\<open>and\<close> the assumptions to unify with the pending goal to be
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    78
  solved, goal selection becomes quite deterministic. For example,
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    79
  decomposition with rules of the ``case-analysis'' type usually gives rise to
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    80
  several goals that only differ in there local contexts. With strong
61541
846c72206207 tuned document;
wenzelm
parents: 58882
diff changeset
    81
  assumptions these may be still solved in any order in a predictable way,
61932
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    82
  while weak ones would quickly lead to great confusion, eventually demanding
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    83
  even some backtracking.
2e48182cc82c misc tuning and modernization;
wenzelm
parents: 61541
diff changeset
    84
\<close>
7860
7819547df4d8 improved presentation;
wenzelm
parents: 7748
diff changeset
    85
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 7982
diff changeset
    86
end