src/FOL/IFOL.thy
author wenzelm
Mon Dec 03 21:03:06 2001 +0100 (2001-12-03)
changeset 12349 94e812f9683e
parent 12114 a8e860c86252
child 12352 92c48cc45e78
permissions -rw-r--r--
setup "rules" method;
clasohm@1268
     1
(*  Title:      FOL/IFOL.thy
lcp@35
     2
    ID:         $Id$
wenzelm@11677
     3
    Author:     Lawrence C Paulson and Markus Wenzel
wenzelm@11677
     4
*)
lcp@35
     5
wenzelm@11677
     6
header {* Intuitionistic first-order logic *}
lcp@35
     7
wenzelm@7355
     8
theory IFOL = Pure
wenzelm@7355
     9
files ("IFOL_lemmas.ML") ("fologic.ML") ("hypsubstdata.ML") ("intprover.ML"):
wenzelm@7355
    10
clasohm@0
    11
wenzelm@11677
    12
subsection {* Syntax and axiomatic basis *}
wenzelm@11677
    13
wenzelm@3906
    14
global
wenzelm@3906
    15
wenzelm@7355
    16
classes "term" < logic
wenzelm@7355
    17
defaultsort "term"
clasohm@0
    18
wenzelm@7355
    19
typedecl o
wenzelm@79
    20
wenzelm@11747
    21
judgment
wenzelm@11747
    22
  Trueprop      :: "o => prop"                  ("(_)" 5)
clasohm@0
    23
wenzelm@11747
    24
consts
wenzelm@7355
    25
  True          :: o
wenzelm@7355
    26
  False         :: o
wenzelm@79
    27
wenzelm@79
    28
  (* Connectives *)
wenzelm@79
    29
wenzelm@7355
    30
  "="           :: "['a, 'a] => o"              (infixl 50)
lcp@35
    31
wenzelm@7355
    32
  Not           :: "o => o"                     ("~ _" [40] 40)
wenzelm@7355
    33
  &             :: "[o, o] => o"                (infixr 35)
wenzelm@7355
    34
  "|"           :: "[o, o] => o"                (infixr 30)
wenzelm@7355
    35
  -->           :: "[o, o] => o"                (infixr 25)
wenzelm@7355
    36
  <->           :: "[o, o] => o"                (infixr 25)
wenzelm@79
    37
wenzelm@79
    38
  (* Quantifiers *)
wenzelm@79
    39
wenzelm@7355
    40
  All           :: "('a => o) => o"             (binder "ALL " 10)
wenzelm@7355
    41
  Ex            :: "('a => o) => o"             (binder "EX " 10)
wenzelm@7355
    42
  Ex1           :: "('a => o) => o"             (binder "EX! " 10)
wenzelm@79
    43
clasohm@0
    44
lcp@928
    45
syntax
wenzelm@7355
    46
  "~="          :: "['a, 'a] => o"              (infixl 50)
lcp@35
    47
translations
wenzelm@79
    48
  "x ~= y"      == "~ (x = y)"
wenzelm@79
    49
wenzelm@12114
    50
syntax (xsymbols)
wenzelm@11677
    51
  Not           :: "o => o"                     ("\<not> _" [40] 40)
wenzelm@11677
    52
  "op &"        :: "[o, o] => o"                (infixr "\<and>" 35)
wenzelm@11677
    53
  "op |"        :: "[o, o] => o"                (infixr "\<or>" 30)
wenzelm@11677
    54
  "ALL "        :: "[idts, o] => o"             ("(3\<forall>_./ _)" [0, 10] 10)
wenzelm@11677
    55
  "EX "         :: "[idts, o] => o"             ("(3\<exists>_./ _)" [0, 10] 10)
wenzelm@11677
    56
  "EX! "        :: "[idts, o] => o"             ("(3\<exists>!_./ _)" [0, 10] 10)
wenzelm@11677
    57
  "op ~="       :: "['a, 'a] => o"              (infixl "\<noteq>" 50)
wenzelm@11677
    58
  "op -->"      :: "[o, o] => o"                (infixr "\<longrightarrow>" 25)
wenzelm@11677
    59
  "op <->"      :: "[o, o] => o"                (infixr "\<longleftrightarrow>" 25)
lcp@35
    60
wenzelm@6340
    61
syntax (HTML output)
wenzelm@11677
    62
  Not           :: "o => o"                     ("\<not> _" [40] 40)
wenzelm@6340
    63
wenzelm@6340
    64
wenzelm@3932
    65
local
wenzelm@3906
    66
wenzelm@7355
    67
axioms
clasohm@0
    68
wenzelm@79
    69
  (* Equality *)
clasohm@0
    70
wenzelm@7355
    71
  refl:         "a=a"
wenzelm@7355
    72
  subst:        "[| a=b;  P(a) |] ==> P(b)"
clasohm@0
    73
wenzelm@79
    74
  (* Propositional logic *)
clasohm@0
    75
wenzelm@7355
    76
  conjI:        "[| P;  Q |] ==> P&Q"
wenzelm@7355
    77
  conjunct1:    "P&Q ==> P"
wenzelm@7355
    78
  conjunct2:    "P&Q ==> Q"
clasohm@0
    79
wenzelm@7355
    80
  disjI1:       "P ==> P|Q"
wenzelm@7355
    81
  disjI2:       "Q ==> P|Q"
wenzelm@7355
    82
  disjE:        "[| P|Q;  P ==> R;  Q ==> R |] ==> R"
clasohm@0
    83
wenzelm@7355
    84
  impI:         "(P ==> Q) ==> P-->Q"
wenzelm@7355
    85
  mp:           "[| P-->Q;  P |] ==> Q"
clasohm@0
    86
wenzelm@7355
    87
  FalseE:       "False ==> P"
wenzelm@7355
    88
clasohm@0
    89
wenzelm@79
    90
  (* Definitions *)
clasohm@0
    91
wenzelm@7355
    92
  True_def:     "True  == False-->False"
wenzelm@7355
    93
  not_def:      "~P    == P-->False"
wenzelm@7355
    94
  iff_def:      "P<->Q == (P-->Q) & (Q-->P)"
wenzelm@79
    95
wenzelm@79
    96
  (* Unique existence *)
clasohm@0
    97
wenzelm@7355
    98
  ex1_def:      "EX! x. P(x) == EX x. P(x) & (ALL y. P(y) --> y=x)"
wenzelm@7355
    99
clasohm@0
   100
wenzelm@79
   101
  (* Quantifiers *)
clasohm@0
   102
wenzelm@7355
   103
  allI:         "(!!x. P(x)) ==> (ALL x. P(x))"
wenzelm@7355
   104
  spec:         "(ALL x. P(x)) ==> P(x)"
clasohm@0
   105
wenzelm@7355
   106
  exI:          "P(x) ==> (EX x. P(x))"
wenzelm@7355
   107
  exE:          "[| EX x. P(x);  !!x. P(x) ==> R |] ==> R"
clasohm@0
   108
clasohm@0
   109
  (* Reflection *)
clasohm@0
   110
wenzelm@7355
   111
  eq_reflection:  "(x=y)   ==> (x==y)"
wenzelm@7355
   112
  iff_reflection: "(P<->Q) ==> (P==Q)"
clasohm@0
   113
wenzelm@4092
   114
wenzelm@11677
   115
subsection {* Lemmas and proof tools *}
wenzelm@11677
   116
wenzelm@9886
   117
setup Simplifier.setup
wenzelm@9886
   118
use "IFOL_lemmas.ML"
wenzelm@11734
   119
wenzelm@12349
   120
declare impE [Pure.elim?]  iffD1 [Pure.elim?]  iffD2 [Pure.elim?]
wenzelm@11734
   121
wenzelm@7355
   122
use "fologic.ML"
wenzelm@9886
   123
use "hypsubstdata.ML"
wenzelm@9886
   124
setup hypsubst_setup
wenzelm@7355
   125
use "intprover.ML"
wenzelm@7355
   126
wenzelm@4092
   127
wenzelm@12349
   128
lemma impE':
wenzelm@12349
   129
  (assumes 1: "P --> Q" and 2: "Q ==> R" and 3: "P --> Q ==> P") R
wenzelm@12349
   130
proof -
wenzelm@12349
   131
  from 3 and 1 have P .
wenzelm@12349
   132
  with 1 have Q ..
wenzelm@12349
   133
  with 2 show R .
wenzelm@12349
   134
qed
wenzelm@12349
   135
wenzelm@12349
   136
lemma allE':
wenzelm@12349
   137
  (assumes 1: "ALL x. P(x)" and 2: "P(x) ==> ALL x. P(x) ==> Q") Q
wenzelm@12349
   138
proof -
wenzelm@12349
   139
  from 1 have "P(x)" by (rule spec)
wenzelm@12349
   140
  from this and 1 show Q by (rule 2)
wenzelm@12349
   141
qed
wenzelm@12349
   142
wenzelm@12349
   143
lemma notE': (assumes 1: "~ P" and 2: "~ P ==> P") R
wenzelm@12349
   144
proof -
wenzelm@12349
   145
  from 2 and 1 have P .
wenzelm@12349
   146
  with 1 show R by (rule notE)
wenzelm@12349
   147
qed
wenzelm@12349
   148
wenzelm@12349
   149
lemmas [Pure.elim!] = disjE iffE FalseE conjE exE
wenzelm@12349
   150
  and [Pure.intro!] = iffI conjI impI TrueI notI allI refl
wenzelm@12349
   151
  and [Pure.elim 2] = allE notE' impE'
wenzelm@12349
   152
  and [Pure.intro] = exI disjI2 disjI1
wenzelm@12349
   153
wenzelm@12349
   154
ML_setup {*
wenzelm@12349
   155
  Context.>> (RuleContext.addSWrapper (fn tac => hyp_subst_tac' ORELSE' tac));
wenzelm@12349
   156
*}
wenzelm@12349
   157
wenzelm@12349
   158
wenzelm@11677
   159
subsection {* Atomizing meta-level rules *}
wenzelm@11677
   160
wenzelm@11747
   161
lemma atomize_all [atomize]: "(!!x. P(x)) == Trueprop (ALL x. P(x))"
wenzelm@11976
   162
proof
wenzelm@11677
   163
  assume "!!x. P(x)"
wenzelm@11677
   164
  show "ALL x. P(x)" by (rule allI)
wenzelm@11677
   165
next
wenzelm@11677
   166
  assume "ALL x. P(x)"
wenzelm@11677
   167
  thus "!!x. P(x)" by (rule allE)
wenzelm@11677
   168
qed
wenzelm@11677
   169
wenzelm@11747
   170
lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A --> B)"
wenzelm@11976
   171
proof
wenzelm@11677
   172
  assume r: "A ==> B"
wenzelm@11677
   173
  show "A --> B" by (rule impI) (rule r)
wenzelm@11677
   174
next
wenzelm@11677
   175
  assume "A --> B" and A
wenzelm@11677
   176
  thus B by (rule mp)
wenzelm@11677
   177
qed
wenzelm@11677
   178
wenzelm@11747
   179
lemma atomize_eq [atomize]: "(x == y) == Trueprop (x = y)"
wenzelm@11976
   180
proof
wenzelm@11677
   181
  assume "x == y"
wenzelm@11677
   182
  show "x = y" by (unfold prems) (rule refl)
wenzelm@11677
   183
next
wenzelm@11677
   184
  assume "x = y"
wenzelm@11677
   185
  thus "x == y" by (rule eq_reflection)
wenzelm@11677
   186
qed
wenzelm@11677
   187
wenzelm@11953
   188
lemma atomize_conj [atomize]: "(!!C. (A ==> B ==> PROP C) ==> PROP C) == Trueprop (A & B)"
wenzelm@11976
   189
proof
wenzelm@11953
   190
  assume "!!C. (A ==> B ==> PROP C) ==> PROP C"
wenzelm@11953
   191
  show "A & B" by (rule conjI)
wenzelm@11953
   192
next
wenzelm@11953
   193
  fix C
wenzelm@11953
   194
  assume "A & B"
wenzelm@11953
   195
  assume "A ==> B ==> PROP C"
wenzelm@11953
   196
  thus "PROP C"
wenzelm@11953
   197
  proof this
wenzelm@11953
   198
    show A by (rule conjunct1)
wenzelm@11953
   199
    show B by (rule conjunct2)
wenzelm@11953
   200
  qed
wenzelm@11953
   201
qed
wenzelm@11953
   202
wenzelm@11771
   203
declare atomize_all [symmetric, rulify]  atomize_imp [symmetric, rulify]
wenzelm@11771
   204
wenzelm@11848
   205
wenzelm@11848
   206
subsection {* Calculational rules *}
wenzelm@11848
   207
wenzelm@11848
   208
lemma forw_subst: "a = b ==> P(b) ==> P(a)"
wenzelm@11848
   209
  by (rule ssubst)
wenzelm@11848
   210
wenzelm@11848
   211
lemma back_subst: "P(a) ==> a = b ==> P(b)"
wenzelm@11848
   212
  by (rule subst)
wenzelm@11848
   213
wenzelm@11848
   214
text {*
wenzelm@11848
   215
  Note that this list of rules is in reverse order of priorities.
wenzelm@11848
   216
*}
wenzelm@11848
   217
wenzelm@12019
   218
lemmas basic_trans_rules [trans] =
wenzelm@11848
   219
  forw_subst
wenzelm@11848
   220
  back_subst
wenzelm@11848
   221
  rev_mp
wenzelm@11848
   222
  mp
wenzelm@11848
   223
  trans
wenzelm@11848
   224
wenzelm@12349
   225
lemmas [Pure.elim?] = sym
wenzelm@11848
   226
wenzelm@4854
   227
end