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