src/HOL/Isar_Examples/Higher_Order_Logic.thy
author wenzelm
Sat, 26 Dec 2015 19:27:46 +0100
changeset 61935 6512e84cc9f5
parent 61759 src/HOL/ex/Higher_Order_Logic.thy@49353865e539
child 61936 c51ce9ed0b1c
permissions -rw-r--r--
clarified sessions;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
61935
6512e84cc9f5 clarified sessions;
wenzelm
parents: 61759
diff changeset
     1
(*  Title:      HOL/Isar_Examples/Higher_Order_Logic.thy
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
     2
    Author:     Makarius
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
     3
*)
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
     4
59031
4c3bb56b8ce7 misc tuning and modernization;
wenzelm
parents: 58889
diff changeset
     5
section \<open>Foundations of HOL\<close>
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
     6
60769
cf7f3465eaf1 tuned proofs;
wenzelm
parents: 59031
diff changeset
     7
theory Higher_Order_Logic
cf7f3465eaf1 tuned proofs;
wenzelm
parents: 59031
diff changeset
     8
imports Pure
cf7f3465eaf1 tuned proofs;
wenzelm
parents: 59031
diff changeset
     9
begin
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    10
59031
4c3bb56b8ce7 misc tuning and modernization;
wenzelm
parents: 58889
diff changeset
    11
text \<open>
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    12
  The following theory development demonstrates Higher-Order Logic itself,
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    13
  represented directly within the Pure framework of Isabelle. The ``HOL''
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    14
  logic given here is essentially that of Gordon @{cite "Gordon:1985:HOL"},
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    15
  although we prefer to present basic concepts in a slightly more conventional
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    16
  manner oriented towards plain Natural Deduction.
59031
4c3bb56b8ce7 misc tuning and modernization;
wenzelm
parents: 58889
diff changeset
    17
\<close>
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    18
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    19
59031
4c3bb56b8ce7 misc tuning and modernization;
wenzelm
parents: 58889
diff changeset
    20
subsection \<open>Pure Logic\<close>
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    21
55380
4de48353034e prefer vacuous definitional type classes over axiomatic ones;
wenzelm
parents: 41460
diff changeset
    22
class type
36452
d37c6eed8117 renamed command 'defaultsort' to 'default_sort';
wenzelm
parents: 26957
diff changeset
    23
default_sort type
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    24
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    25
typedecl o
55380
4de48353034e prefer vacuous definitional type classes over axiomatic ones;
wenzelm
parents: 41460
diff changeset
    26
instance o :: type ..
4de48353034e prefer vacuous definitional type classes over axiomatic ones;
wenzelm
parents: 41460
diff changeset
    27
instance "fun" :: (type, type) type ..
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    28
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    29
59031
4c3bb56b8ce7 misc tuning and modernization;
wenzelm
parents: 58889
diff changeset
    30
subsubsection \<open>Basic logical connectives\<close>
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    31
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    32
judgment Trueprop :: "o \<Rightarrow> prop"  ("_" 5)
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    33
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    34
axiomatization imp :: "o \<Rightarrow> o \<Rightarrow> o"  (infixr "\<longrightarrow>" 25)
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    35
  where impI [intro]: "(A \<Longrightarrow> B) \<Longrightarrow> A \<longrightarrow> B"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    36
    and impE [dest, trans]: "A \<longrightarrow> B \<Longrightarrow> A \<Longrightarrow> B"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    37
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    38
axiomatization All :: "('a \<Rightarrow> o) \<Rightarrow> o"  (binder "\<forall>" 10)
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    39
  where allI [intro]: "(\<And>x. P x) \<Longrightarrow> \<forall>x. P x"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    40
    and allE [dest]: "\<forall>x. P x \<Longrightarrow> P a"
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    41
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    42
59031
4c3bb56b8ce7 misc tuning and modernization;
wenzelm
parents: 58889
diff changeset
    43
subsubsection \<open>Extensional equality\<close>
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    44
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    45
axiomatization equal :: "'a \<Rightarrow> 'a \<Rightarrow> o"  (infixl "=" 50)
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    46
  where refl [intro]: "x = x"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    47
    and subst: "x = y \<Longrightarrow> P x \<Longrightarrow> P y"
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    48
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    49
axiomatization
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    50
  where ext [intro]: "(\<And>x. f x = g x) \<Longrightarrow> f = g"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    51
    and iff [intro]: "(A \<Longrightarrow> B) \<Longrightarrow> (B \<Longrightarrow> A) \<Longrightarrow> A = B"
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    52
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    53
theorem sym [sym]:
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    54
  assumes "x = y"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    55
  shows "y = x"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    56
  using assms by (rule subst) (rule refl)
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    57
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    58
lemma [trans]: "x = y \<Longrightarrow> P y \<Longrightarrow> P x"
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    59
  by (rule subst) (rule sym)
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    60
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    61
lemma [trans]: "P x \<Longrightarrow> x = y \<Longrightarrow> P y"
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    62
  by (rule subst)
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    63
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    64
theorem trans [trans]: "x = y \<Longrightarrow> y = z \<Longrightarrow> x = z"
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    65
  by (rule subst)
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    66
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    67
theorem iff1 [elim]: "A = B \<Longrightarrow> A \<Longrightarrow> B"
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    68
  by (rule subst)
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    69
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    70
theorem iff2 [elim]: "A = B \<Longrightarrow> B \<Longrightarrow> A"
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    71
  by (rule subst) (rule sym)
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    72
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    73
59031
4c3bb56b8ce7 misc tuning and modernization;
wenzelm
parents: 58889
diff changeset
    74
subsubsection \<open>Derived connectives\<close>
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    75
59031
4c3bb56b8ce7 misc tuning and modernization;
wenzelm
parents: 58889
diff changeset
    76
definition false :: o  ("\<bottom>") where "\<bottom> \<equiv> \<forall>A. A"
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20523
diff changeset
    77
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    78
theorem falseE [elim]:
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    79
  assumes "\<bottom>"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    80
  shows A
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    81
proof -
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    82
  from \<open>\<bottom>\<close> have "\<forall>A. A" unfolding false_def .
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    83
  then show A ..
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    84
qed
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    85
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    86
59031
4c3bb56b8ce7 misc tuning and modernization;
wenzelm
parents: 58889
diff changeset
    87
definition true :: o  ("\<top>") where "\<top> \<equiv> \<bottom> \<longrightarrow> \<bottom>"
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20523
diff changeset
    88
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    89
theorem trueI [intro]: \<top>
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    90
  unfolding true_def ..
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    91
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    92
59031
4c3bb56b8ce7 misc tuning and modernization;
wenzelm
parents: 58889
diff changeset
    93
definition not :: "o \<Rightarrow> o"  ("\<not> _" [40] 40)
4c3bb56b8ce7 misc tuning and modernization;
wenzelm
parents: 58889
diff changeset
    94
  where "not \<equiv> \<lambda>A. A \<longrightarrow> \<bottom>"
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20523
diff changeset
    95
59031
4c3bb56b8ce7 misc tuning and modernization;
wenzelm
parents: 58889
diff changeset
    96
abbreviation not_equal :: "'a \<Rightarrow> 'a \<Rightarrow> o"  (infixl "\<noteq>" 50)
4c3bb56b8ce7 misc tuning and modernization;
wenzelm
parents: 58889
diff changeset
    97
  where "x \<noteq> y \<equiv> \<not> (x = y)"
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
    98
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
    99
theorem notI [intro]:
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   100
  assumes "A \<Longrightarrow> \<bottom>"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   101
  shows "\<not> A"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   102
  using assms unfolding not_def ..
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   103
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   104
theorem notE [elim]:
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   105
  assumes "\<not> A" and A
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   106
  shows B
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   107
proof -
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   108
  from \<open>\<not> A\<close> have "A \<longrightarrow> \<bottom>" unfolding not_def .
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   109
  from this and \<open>A\<close> have "\<bottom>" ..
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 21404
diff changeset
   110
  then show B ..
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   111
qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   112
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   113
lemma notE': "A \<Longrightarrow> \<not> A \<Longrightarrow> B"
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   114
  by (rule notE)
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   115
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   116
lemmas contradiction = notE notE'  \<comment> \<open>proof by contradiction in any order\<close>
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   117
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   118
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   119
definition conj :: "o \<Rightarrow> o \<Rightarrow> o"  (infixr "\<and>" 35)
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   120
  where "conj \<equiv> \<lambda>A B. \<forall>C. (A \<longrightarrow> B \<longrightarrow> C) \<longrightarrow> C"
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   121
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   122
theorem conjI [intro]:
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   123
  assumes A and B
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   124
  shows "A \<and> B"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   125
  unfolding conj_def
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   126
proof
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   127
  fix C
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   128
  show "(A \<longrightarrow> B \<longrightarrow> C) \<longrightarrow> C"
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   129
  proof
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   130
    assume "A \<longrightarrow> B \<longrightarrow> C"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   131
    also note \<open>A\<close>
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   132
    also note \<open>B\<close>
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   133
    finally show C .
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   134
  qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   135
qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   136
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   137
theorem conjE [elim]:
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   138
  assumes "A \<and> B"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   139
  obtains A and B
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   140
proof
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   141
  from \<open>A \<and> B\<close> have *: "(A \<longrightarrow> B \<longrightarrow> C) \<longrightarrow> C" for C
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   142
    unfolding conj_def ..
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   143
  show A
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   144
  proof -
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   145
    note * [of A]
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   146
    also have "A \<longrightarrow> B \<longrightarrow> A"
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   147
    proof
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   148
      assume A
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 21404
diff changeset
   149
      then show "B \<longrightarrow> A" ..
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   150
    qed
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   151
    finally show ?thesis .
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   152
  qed
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   153
  show B
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   154
  proof -
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   155
    note * [of B]
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   156
    also have "A \<longrightarrow> B \<longrightarrow> B"
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   157
    proof
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   158
      show "B \<longrightarrow> B" ..
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   159
    qed
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   160
    finally show ?thesis .
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   161
  qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   162
qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   163
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   164
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   165
definition disj :: "o \<Rightarrow> o \<Rightarrow> o"  (infixr "\<or>" 30)
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   166
  where "disj \<equiv> \<lambda>A B. \<forall>C. (A \<longrightarrow> C) \<longrightarrow> (B \<longrightarrow> C) \<longrightarrow> C"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   167
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   168
theorem disjI1 [intro]:
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   169
  assumes A
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   170
  shows "A \<or> B"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   171
  unfolding disj_def
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   172
proof
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   173
  fix C
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   174
  show "(A \<longrightarrow> C) \<longrightarrow> (B \<longrightarrow> C) \<longrightarrow> C"
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   175
  proof
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   176
    assume "A \<longrightarrow> C"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   177
    from this and \<open>A\<close> have C ..
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   178
    then show "(B \<longrightarrow> C) \<longrightarrow> C" ..
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   179
  qed
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   180
qed
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   181
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   182
theorem disjI2 [intro]:
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   183
  assumes B
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   184
  shows "A \<or> B"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   185
  unfolding disj_def
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   186
proof
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   187
  fix C
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   188
  show "(A \<longrightarrow> C) \<longrightarrow> (B \<longrightarrow> C) \<longrightarrow> C"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   189
  proof
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   190
    show "(B \<longrightarrow> C) \<longrightarrow> C"
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   191
    proof
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   192
      assume "B \<longrightarrow> C"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   193
      from this and \<open>B\<close> show C ..
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   194
    qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   195
  qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   196
qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   197
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   198
theorem disjE [elim]:
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   199
  assumes "A \<or> B"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   200
  obtains (a) A | (b) B
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   201
proof -
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   202
  from \<open>A \<or> B\<close> have "(A \<longrightarrow> thesis) \<longrightarrow> (B \<longrightarrow> thesis) \<longrightarrow> thesis"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   203
    unfolding disj_def ..
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   204
  also have "A \<longrightarrow> thesis"
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   205
  proof
60769
cf7f3465eaf1 tuned proofs;
wenzelm
parents: 59031
diff changeset
   206
    assume A
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   207
    then show thesis by (rule a)
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   208
  qed
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   209
  also have "B \<longrightarrow> thesis"
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   210
  proof
60769
cf7f3465eaf1 tuned proofs;
wenzelm
parents: 59031
diff changeset
   211
    assume B
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   212
    then show thesis by (rule b)
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   213
  qed
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   214
  finally show thesis .
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   215
qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   216
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   217
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   218
definition Ex :: "('a \<Rightarrow> o) \<Rightarrow> o"  (binder "\<exists>" 10)
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   219
  where "\<exists>x. P x \<equiv> \<forall>C. (\<forall>x. P x \<longrightarrow> C) \<longrightarrow> C"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   220
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   221
theorem exI [intro]: "P a \<Longrightarrow> \<exists>x. P x"
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   222
  unfolding Ex_def
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   223
proof
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   224
  fix C
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   225
  assume "P a"
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   226
  show "(\<forall>x. P x \<longrightarrow> C) \<longrightarrow> C"
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   227
  proof
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   228
    assume "\<forall>x. P x \<longrightarrow> C"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   229
    then have "P a \<longrightarrow> C" ..
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   230
    from this and \<open>P a\<close> show C ..
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   231
  qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   232
qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   233
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   234
theorem exE [elim]:
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   235
  assumes "\<exists>x. P x"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   236
  obtains (that) x where "P x"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   237
proof -
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   238
  from \<open>\<exists>x. P x\<close> have "(\<forall>x. P x \<longrightarrow> thesis) \<longrightarrow> thesis"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   239
    unfolding Ex_def ..
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   240
  also have "\<forall>x. P x \<longrightarrow> thesis"
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   241
  proof
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   242
    fix x
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   243
    show "P x \<longrightarrow> thesis"
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   244
    proof
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   245
      assume "P x"
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   246
      then show thesis by (rule that)
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   247
    qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   248
  qed
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   249
  finally show thesis .
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   250
qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   251
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   252
59031
4c3bb56b8ce7 misc tuning and modernization;
wenzelm
parents: 58889
diff changeset
   253
subsection \<open>Classical logic\<close>
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   254
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   255
text \<open>
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   256
  The subsequent rules of classical reasoning are all equivalent.
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   257
\<close>
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   258
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   259
locale classical =
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   260
  assumes classical: "(\<not> A \<Longrightarrow> A) \<Longrightarrow> A"
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   261
60769
cf7f3465eaf1 tuned proofs;
wenzelm
parents: 59031
diff changeset
   262
theorem (in classical) Peirce's_Law: "((A \<longrightarrow> B) \<longrightarrow> A) \<longrightarrow> A"
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   263
proof
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   264
  assume a: "(A \<longrightarrow> B) \<longrightarrow> A"
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   265
  show A
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   266
  proof (rule classical)
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   267
    assume "\<not> A"
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   268
    have "A \<longrightarrow> B"
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   269
    proof
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   270
      assume A
59031
4c3bb56b8ce7 misc tuning and modernization;
wenzelm
parents: 58889
diff changeset
   271
      with \<open>\<not> A\<close> show B by (rule contradiction)
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   272
    qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   273
    with a show A ..
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   274
  qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   275
qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   276
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   277
theorem (in classical) double_negation:
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   278
  assumes "\<not> \<not> A"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   279
  shows A
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   280
proof (rule classical)
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   281
  assume "\<not> A"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   282
  with \<open>\<not> \<not> A\<close> show ?thesis by (rule contradiction)
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   283
qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   284
60769
cf7f3465eaf1 tuned proofs;
wenzelm
parents: 59031
diff changeset
   285
theorem (in classical) tertium_non_datur: "A \<or> \<not> A"
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   286
proof (rule double_negation)
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   287
  show "\<not> \<not> (A \<or> \<not> A)"
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   288
  proof
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   289
    assume "\<not> (A \<or> \<not> A)"
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   290
    have "\<not> A"
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   291
    proof
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 21404
diff changeset
   292
      assume A then have "A \<or> \<not> A" ..
59031
4c3bb56b8ce7 misc tuning and modernization;
wenzelm
parents: 58889
diff changeset
   293
      with \<open>\<not> (A \<or> \<not> A)\<close> show \<bottom> by (rule contradiction)
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   294
    qed
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 21404
diff changeset
   295
    then have "A \<or> \<not> A" ..
59031
4c3bb56b8ce7 misc tuning and modernization;
wenzelm
parents: 58889
diff changeset
   296
    with \<open>\<not> (A \<or> \<not> A)\<close> show \<bottom> by (rule contradiction)
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   297
  qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   298
qed
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   299
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   300
theorem (in classical) classical_cases:
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   301
  obtains A | "\<not> A"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   302
  using tertium_non_datur
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   303
proof
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   304
  assume A
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   305
  then show thesis ..
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   306
next
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   307
  assume "\<not> A"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   308
  then show thesis ..
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   309
qed
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   310
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   311
lemma
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   312
  assumes classical_cases: "\<And>A C. (A \<Longrightarrow> C) \<Longrightarrow> (\<not> A \<Longrightarrow> C) \<Longrightarrow> C"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   313
  shows "PROP classical"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   314
proof
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   315
  fix A
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   316
  assume *: "\<not> A \<Longrightarrow> A"
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   317
  show A
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   318
  proof (rule classical_cases)
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   319
    assume A
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   320
    then show A .
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   321
  next
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   322
    assume "\<not> A"
61759
49353865e539 misc tuning and modernization;
wenzelm
parents: 60769
diff changeset
   323
    then show A by (rule *)
12573
6226b35c04ca added lemma;
wenzelm
parents: 12394
diff changeset
   324
  qed
6226b35c04ca added lemma;
wenzelm
parents: 12394
diff changeset
   325
qed
6226b35c04ca added lemma;
wenzelm
parents: 12394
diff changeset
   326
12360
9c156045c8f2 added Higher_Order_Logic.thy;
wenzelm
parents:
diff changeset
   327
end