src/HOL/HOL.thy
author nipkow
Fri, 07 Sep 2007 17:56:03 +0200
changeset 24553 9b19da7b2b08
parent 24506 020db6ec334a
child 24633 0a3a02066244
permissions -rw-r--r--
added lemma
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     1
(*  Title:      HOL/HOL.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
11750
3e400964893e judgment Trueprop;
wenzelm
parents: 11724
diff changeset
     3
    Author:     Tobias Nipkow, Markus Wenzel, and Larry Paulson
3e400964893e judgment Trueprop;
wenzelm
parents: 11724
diff changeset
     4
*)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     5
11750
3e400964893e judgment Trueprop;
wenzelm
parents: 11724
diff changeset
     6
header {* The basis of Higher-Order Logic *}
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15103
diff changeset
     8
theory HOL
15140
322485b816ac import -> imports
nipkow
parents: 15131
diff changeset
     9
imports CPure
23163
eef345eff987 proper loading of ML files;
wenzelm
parents: 23037
diff changeset
    10
uses
23247
b99dce43d252 merged Code_Generator.thy into HOL.thy
haftmann
parents: 23171
diff changeset
    11
  "~~/src/Tools/integer.ML"
23553
af8ae54238f5 use hologic.ML in basic HOL context;
wenzelm
parents: 23530
diff changeset
    12
  ("hologic.ML")
23171
861f63a35d31 moved IsaPlanner from Provers to Tools;
wenzelm
parents: 23163
diff changeset
    13
  "~~/src/Tools/IsaPlanner/zipper.ML"
861f63a35d31 moved IsaPlanner from Provers to Tools;
wenzelm
parents: 23163
diff changeset
    14
  "~~/src/Tools/IsaPlanner/isand.ML"
861f63a35d31 moved IsaPlanner from Provers to Tools;
wenzelm
parents: 23163
diff changeset
    15
  "~~/src/Tools/IsaPlanner/rw_tools.ML"
861f63a35d31 moved IsaPlanner from Provers to Tools;
wenzelm
parents: 23163
diff changeset
    16
  "~~/src/Tools/IsaPlanner/rw_inst.ML"
23263
0c227412b285 tuned boostrap
haftmann
parents: 23247
diff changeset
    17
  "~~/src/Provers/project_rule.ML"
23163
eef345eff987 proper loading of ML files;
wenzelm
parents: 23037
diff changeset
    18
  "~~/src/Provers/induct_method.ML"
23263
0c227412b285 tuned boostrap
haftmann
parents: 23247
diff changeset
    19
  "~~/src/Provers/hypsubst.ML"
0c227412b285 tuned boostrap
haftmann
parents: 23247
diff changeset
    20
  "~~/src/Provers/splitter.ML"
23163
eef345eff987 proper loading of ML files;
wenzelm
parents: 23037
diff changeset
    21
  "~~/src/Provers/classical.ML"
eef345eff987 proper loading of ML files;
wenzelm
parents: 23037
diff changeset
    22
  "~~/src/Provers/blast.ML"
eef345eff987 proper loading of ML files;
wenzelm
parents: 23037
diff changeset
    23
  "~~/src/Provers/clasimp.ML"
23263
0c227412b285 tuned boostrap
haftmann
parents: 23247
diff changeset
    24
  "~~/src/Provers/eqsubst.ML"
23163
eef345eff987 proper loading of ML files;
wenzelm
parents: 23037
diff changeset
    25
  "~~/src/Provers/quantifier1.ML"
eef345eff987 proper loading of ML files;
wenzelm
parents: 23037
diff changeset
    26
  ("simpdata.ML")
24280
c9867bdf2424 updated code generator setup
haftmann
parents: 24219
diff changeset
    27
  "~~/src/Tools/code/code_name.ML"
c9867bdf2424 updated code generator setup
haftmann
parents: 24219
diff changeset
    28
  "~~/src/Tools/code/code_funcgr.ML"
c9867bdf2424 updated code generator setup
haftmann
parents: 24219
diff changeset
    29
  "~~/src/Tools/code/code_thingol.ML"
c9867bdf2424 updated code generator setup
haftmann
parents: 24219
diff changeset
    30
  "~~/src/Tools/code/code_target.ML"
c9867bdf2424 updated code generator setup
haftmann
parents: 24219
diff changeset
    31
  "~~/src/Tools/code/code_package.ML"
24166
7b28dc69bdbb new nbe implementation
haftmann
parents: 24035
diff changeset
    32
  "~~/src/Tools/nbe.ML"
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15103
diff changeset
    33
begin
2260
b59781f2b809 added symbols syntax;
wenzelm
parents: 1674
diff changeset
    34
11750
3e400964893e judgment Trueprop;
wenzelm
parents: 11724
diff changeset
    35
subsection {* Primitive logic *}
3e400964893e judgment Trueprop;
wenzelm
parents: 11724
diff changeset
    36
3e400964893e judgment Trueprop;
wenzelm
parents: 11724
diff changeset
    37
subsubsection {* Core syntax *}
2260
b59781f2b809 added symbols syntax;
wenzelm
parents: 1674
diff changeset
    38
14854
61bdf2ae4dc5 removed obsolete sort 'logic';
wenzelm
parents: 14749
diff changeset
    39
classes type
12338
de0f4a63baa5 renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents: 12281
diff changeset
    40
defaultsort type
3947
eb707467f8c5 adapted to qualified names;
wenzelm
parents: 3842
diff changeset
    41
12338
de0f4a63baa5 renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents: 12281
diff changeset
    42
global
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    43
7357
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
    44
typedecl bool
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    45
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    46
arities
12338
de0f4a63baa5 renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents: 12281
diff changeset
    47
  bool :: type
20590
bf92900995f8 introduced syntactic classes; moved some setup to Pure/codegen, Pure/nbe or OperationalEquality.thy
haftmann
parents: 20453
diff changeset
    48
  "fun" :: (type, type) type
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    49
11750
3e400964893e judgment Trueprop;
wenzelm
parents: 11724
diff changeset
    50
judgment
3e400964893e judgment Trueprop;
wenzelm
parents: 11724
diff changeset
    51
  Trueprop      :: "bool => prop"                   ("(_)" 5)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    52
11750
3e400964893e judgment Trueprop;
wenzelm
parents: 11724
diff changeset
    53
consts
7357
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
    54
  Not           :: "bool => bool"                   ("~ _" [40] 40)
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
    55
  True          :: bool
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
    56
  False         :: bool
3947
eb707467f8c5 adapted to qualified names;
wenzelm
parents: 3842
diff changeset
    57
  arbitrary     :: 'a
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    58
11432
8a203ae6efe3 added "The" (definite description operator) (by Larry);
wenzelm
parents: 10489
diff changeset
    59
  The           :: "('a => bool) => 'a"
7357
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
    60
  All           :: "('a => bool) => bool"           (binder "ALL " 10)
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
    61
  Ex            :: "('a => bool) => bool"           (binder "EX " 10)
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
    62
  Ex1           :: "('a => bool) => bool"           (binder "EX! " 10)
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
    63
  Let           :: "['a, 'a => 'b] => 'b"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    64
22839
ede26eb5e549 dropped HOL.ML
haftmann
parents: 22744
diff changeset
    65
  "op ="        :: "['a, 'a] => bool"               (infixl "=" 50)
ede26eb5e549 dropped HOL.ML
haftmann
parents: 22744
diff changeset
    66
  "op &"        :: "[bool, bool] => bool"           (infixr "&" 35)
ede26eb5e549 dropped HOL.ML
haftmann
parents: 22744
diff changeset
    67
  "op |"        :: "[bool, bool] => bool"           (infixr "|" 30)
ede26eb5e549 dropped HOL.ML
haftmann
parents: 22744
diff changeset
    68
  "op -->"      :: "[bool, bool] => bool"           (infixr "-->" 25)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    69
10432
3dfbc913d184 added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents: 10383
diff changeset
    70
local
3dfbc913d184 added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents: 10383
diff changeset
    71
16587
b34c8aa657a5 Constant "If" is now local
paulson
parents: 16417
diff changeset
    72
consts
b34c8aa657a5 Constant "If" is now local
paulson
parents: 16417
diff changeset
    73
  If            :: "[bool, 'a, 'a] => 'a"           ("(if (_)/ then (_)/ else (_))" 10)
2260
b59781f2b809 added symbols syntax;
wenzelm
parents: 1674
diff changeset
    74
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
    75
11750
3e400964893e judgment Trueprop;
wenzelm
parents: 11724
diff changeset
    76
subsubsection {* Additional concrete syntax *}
2260
b59781f2b809 added symbols syntax;
wenzelm
parents: 1674
diff changeset
    77
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 21179
diff changeset
    78
notation (output)
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
    79
  "op ="  (infix "=" 50)
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
    80
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
    81
abbreviation
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21250
diff changeset
    82
  not_equal :: "['a, 'a] => bool"  (infixl "~=" 50) where
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
    83
  "x ~= y == ~ (x = y)"
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
    84
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 21179
diff changeset
    85
notation (output)
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
    86
  not_equal  (infix "~=" 50)
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
    87
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 21179
diff changeset
    88
notation (xsymbols)
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21250
diff changeset
    89
  Not  ("\<not> _" [40] 40) and
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21250
diff changeset
    90
  "op &"  (infixr "\<and>" 35) and
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21250
diff changeset
    91
  "op |"  (infixr "\<or>" 30) and
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21250
diff changeset
    92
  "op -->"  (infixr "\<longrightarrow>" 25) and
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
    93
  not_equal  (infix "\<noteq>" 50)
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
    94
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 21179
diff changeset
    95
notation (HTML output)
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21250
diff changeset
    96
  Not  ("\<not> _" [40] 40) and
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21250
diff changeset
    97
  "op &"  (infixr "\<and>" 35) and
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21250
diff changeset
    98
  "op |"  (infixr "\<or>" 30) and
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
    99
  not_equal  (infix "\<noteq>" 50)
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
   100
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
   101
abbreviation (iff)
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21250
diff changeset
   102
  iff :: "[bool, bool] => bool"  (infixr "<->" 25) where
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
   103
  "A <-> B == A = B"
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
   104
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 21179
diff changeset
   105
notation (xsymbols)
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
   106
  iff  (infixr "\<longleftrightarrow>" 25)
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
   107
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
   108
4868
843a9f5b3c3d nonterminals;
wenzelm
parents: 4793
diff changeset
   109
nonterminals
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   110
  letbinds  letbind
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   111
  case_syn  cases_syn
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   112
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   113
syntax
11432
8a203ae6efe3 added "The" (definite description operator) (by Larry);
wenzelm
parents: 10489
diff changeset
   114
  "_The"        :: "[pttrn, bool] => 'a"                 ("(3THE _./ _)" [0, 10] 10)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   115
7357
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
   116
  "_bind"       :: "[pttrn, 'a] => letbind"              ("(2_ =/ _)" 10)
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
   117
  ""            :: "letbind => letbinds"                 ("_")
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
   118
  "_binds"      :: "[letbind, letbinds] => letbinds"     ("_;/ _")
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
   119
  "_Let"        :: "[letbinds, 'a] => 'a"                ("(let (_)/ in (_))" 10)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   120
9060
b0dd884b1848 rename @case to _case_syntax (improves on low-level errors);
wenzelm
parents: 8959
diff changeset
   121
  "_case_syntax":: "['a, cases_syn] => 'b"               ("(case _ of/ _)" 10)
b0dd884b1848 rename @case to _case_syntax (improves on low-level errors);
wenzelm
parents: 8959
diff changeset
   122
  "_case1"      :: "['a, 'b] => case_syn"                ("(2_ =>/ _)" 10)
7357
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
   123
  ""            :: "case_syn => cases_syn"               ("_")
9060
b0dd884b1848 rename @case to _case_syntax (improves on low-level errors);
wenzelm
parents: 8959
diff changeset
   124
  "_case2"      :: "[case_syn, cases_syn] => cases_syn"  ("_/ | _")
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   125
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   126
translations
13764
3e180bf68496 removed some problems with print translations
nipkow
parents: 13763
diff changeset
   127
  "THE x. P"              == "The (%x. P)"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   128
  "_Let (_binds b bs) e"  == "_Let b (_Let bs e)"
1114
c8dfb56a7e95 Prod is now a parent of Lfp.
nipkow
parents: 1068
diff changeset
   129
  "let x = a in e"        == "Let a (%x. e)"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   130
13763
f94b569cd610 added print translations tha avoid eta contraction for important binders.
nipkow
parents: 13723
diff changeset
   131
print_translation {*
f94b569cd610 added print translations tha avoid eta contraction for important binders.
nipkow
parents: 13723
diff changeset
   132
(* To avoid eta-contraction of body: *)
f94b569cd610 added print translations tha avoid eta contraction for important binders.
nipkow
parents: 13723
diff changeset
   133
[("The", fn [Abs abs] =>
f94b569cd610 added print translations tha avoid eta contraction for important binders.
nipkow
parents: 13723
diff changeset
   134
     let val (x,t) = atomic_abs_tr' abs
f94b569cd610 added print translations tha avoid eta contraction for important binders.
nipkow
parents: 13723
diff changeset
   135
     in Syntax.const "_The" $ x $ t end)]
f94b569cd610 added print translations tha avoid eta contraction for important binders.
nipkow
parents: 13723
diff changeset
   136
*}
f94b569cd610 added print translations tha avoid eta contraction for important binders.
nipkow
parents: 13723
diff changeset
   137
12114
a8e860c86252 eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents: 12023
diff changeset
   138
syntax (xsymbols)
11687
b0fe6e522559 non-oriented infix = and ~= (output only);
wenzelm
parents: 11451
diff changeset
   139
  "_case1"      :: "['a, 'b] => case_syn"                ("(2_ \<Rightarrow>/ _)" 10)
21524
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   140
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   141
notation (xsymbols)
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   142
  All  (binder "\<forall>" 10) and
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   143
  Ex  (binder "\<exists>" 10) and
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   144
  Ex1  (binder "\<exists>!" 10)
2372
a2999e19703b fixed alternative quantifier symbol syntax;
wenzelm
parents: 2368
diff changeset
   145
21524
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   146
notation (HTML output)
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   147
  All  (binder "\<forall>" 10) and
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   148
  Ex  (binder "\<exists>" 10) and
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   149
  Ex1  (binder "\<exists>!" 10)
6340
7d5cbd5819a0 HTML output;
wenzelm
parents: 6289
diff changeset
   150
21524
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   151
notation (HOL)
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   152
  All  (binder "! " 10) and
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   153
  Ex  (binder "? " 10) and
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   154
  Ex1  (binder "?! " 10)
7238
36e58620ffc8 replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents: 7220
diff changeset
   155
36e58620ffc8 replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents: 7220
diff changeset
   156
11750
3e400964893e judgment Trueprop;
wenzelm
parents: 11724
diff changeset
   157
subsubsection {* Axioms and basic definitions *}
2260
b59781f2b809 added symbols syntax;
wenzelm
parents: 1674
diff changeset
   158
7357
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
   159
axioms
15380
455cfa766dad proof of subst by S Merz
paulson
parents: 15363
diff changeset
   160
  eq_reflection:  "(x=y) ==> (x==y)"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   161
15380
455cfa766dad proof of subst by S Merz
paulson
parents: 15363
diff changeset
   162
  refl:           "t = (t::'a)"
6289
062aa156a300 added a commment on the "ext" rule
paulson
parents: 6027
diff changeset
   163
15380
455cfa766dad proof of subst by S Merz
paulson
parents: 15363
diff changeset
   164
  ext:            "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)"
455cfa766dad proof of subst by S Merz
paulson
parents: 15363
diff changeset
   165
    -- {*Extensionality is built into the meta-logic, and this rule expresses
455cfa766dad proof of subst by S Merz
paulson
parents: 15363
diff changeset
   166
         a related property.  It is an eta-expanded version of the traditional
455cfa766dad proof of subst by S Merz
paulson
parents: 15363
diff changeset
   167
         rule, and similar to the ABS rule of HOL*}
6289
062aa156a300 added a commment on the "ext" rule
paulson
parents: 6027
diff changeset
   168
11432
8a203ae6efe3 added "The" (definite description operator) (by Larry);
wenzelm
parents: 10489
diff changeset
   169
  the_eq_trivial: "(THE x. x = a) = (a::'a)"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   170
15380
455cfa766dad proof of subst by S Merz
paulson
parents: 15363
diff changeset
   171
  impI:           "(P ==> Q) ==> P-->Q"
455cfa766dad proof of subst by S Merz
paulson
parents: 15363
diff changeset
   172
  mp:             "[| P-->Q;  P |] ==> Q"
455cfa766dad proof of subst by S Merz
paulson
parents: 15363
diff changeset
   173
455cfa766dad proof of subst by S Merz
paulson
parents: 15363
diff changeset
   174
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   175
defs
7357
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
   176
  True_def:     "True      == ((%x::bool. x) = (%x. x))"
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
   177
  All_def:      "All(P)    == (P = (%x. True))"
11451
8abfb4f7bd02 partial restructuring to reduce dependence on Axiom of Choice
paulson
parents: 11438
diff changeset
   178
  Ex_def:       "Ex(P)     == !Q. (!x. P x --> Q) --> Q"
7357
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
   179
  False_def:    "False     == (!P. P)"
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
   180
  not_def:      "~ P       == P-->False"
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
   181
  and_def:      "P & Q     == !R. (P-->Q-->R) --> R"
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
   182
  or_def:       "P | Q     == !R. (P-->R) --> (Q-->R) --> R"
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
   183
  Ex1_def:      "Ex1(P)    == ? x. P(x) & (! y. P(y) --> y=x)"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   184
7357
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
   185
axioms
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
   186
  iff:          "(P-->Q) --> (Q-->P) --> (P=Q)"
d0e16da40ea2 proper bootstrap of HOL theory and packages;
wenzelm
parents: 7238
diff changeset
   187
  True_or_False:  "(P=True) | (P=False)"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   188
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   189
defs
24219
e558fe311376 new structure for code generator modules
haftmann
parents: 24166
diff changeset
   190
  Let_def:      "Let s f == f(s)"
11451
8abfb4f7bd02 partial restructuring to reduce dependence on Axiom of Choice
paulson
parents: 11438
diff changeset
   191
  if_def:       "If P x y == THE z::'a. (P=True --> z=x) & (P=False --> z=y)"
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4868
diff changeset
   192
14223
0ee05eef881b Added support for making constants final, that is, ensuring that no
skalberg
parents: 14208
diff changeset
   193
finalconsts
0ee05eef881b Added support for making constants final, that is, ensuring that no
skalberg
parents: 14208
diff changeset
   194
  "op ="
0ee05eef881b Added support for making constants final, that is, ensuring that no
skalberg
parents: 14208
diff changeset
   195
  "op -->"
0ee05eef881b Added support for making constants final, that is, ensuring that no
skalberg
parents: 14208
diff changeset
   196
  The
0ee05eef881b Added support for making constants final, that is, ensuring that no
skalberg
parents: 14208
diff changeset
   197
  arbitrary
22481
79c2724c36b5 added class "default" and expansion axioms for undefined
haftmann
parents: 22473
diff changeset
   198
79c2724c36b5 added class "default" and expansion axioms for undefined
haftmann
parents: 22473
diff changeset
   199
axiomatization
79c2724c36b5 added class "default" and expansion axioms for undefined
haftmann
parents: 22473
diff changeset
   200
  undefined :: 'a
79c2724c36b5 added class "default" and expansion axioms for undefined
haftmann
parents: 22473
diff changeset
   201
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22481
diff changeset
   202
axiomatization where
22481
79c2724c36b5 added class "default" and expansion axioms for undefined
haftmann
parents: 22473
diff changeset
   203
  undefined_fun: "undefined x = undefined"
3320
3a5e4930fb77 Added `arbitrary'
nipkow
parents: 3248
diff changeset
   204
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19607
diff changeset
   205
22481
79c2724c36b5 added class "default" and expansion axioms for undefined
haftmann
parents: 22473
diff changeset
   206
subsubsection {* Generic classes and algebraic operations *}
79c2724c36b5 added class "default" and expansion axioms for undefined
haftmann
parents: 22473
diff changeset
   207
79c2724c36b5 added class "default" and expansion axioms for undefined
haftmann
parents: 22473
diff changeset
   208
class default = type +
79c2724c36b5 added class "default" and expansion axioms for undefined
haftmann
parents: 22473
diff changeset
   209
  fixes default :: "'a"
4868
843a9f5b3c3d nonterminals;
wenzelm
parents: 4793
diff changeset
   210
22473
753123c89d72 explizit "type" superclass
haftmann
parents: 22467
diff changeset
   211
class zero = type + 
21524
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   212
  fixes zero :: "'a"  ("\<^loc>0")
20713
823967ef47f1 renamed 0 and 1 to HOL.zero and HOL.one respectivly; introduced corresponding syntactic classes
haftmann
parents: 20698
diff changeset
   213
22473
753123c89d72 explizit "type" superclass
haftmann
parents: 22467
diff changeset
   214
class one = type +
21524
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   215
  fixes one  :: "'a"  ("\<^loc>1")
20713
823967ef47f1 renamed 0 and 1 to HOL.zero and HOL.one respectivly; introduced corresponding syntactic classes
haftmann
parents: 20698
diff changeset
   216
823967ef47f1 renamed 0 and 1 to HOL.zero and HOL.one respectivly; introduced corresponding syntactic classes
haftmann
parents: 20698
diff changeset
   217
hide (open) const zero one
20590
bf92900995f8 introduced syntactic classes; moved some setup to Pure/codegen, Pure/nbe or OperationalEquality.thy
haftmann
parents: 20453
diff changeset
   218
22473
753123c89d72 explizit "type" superclass
haftmann
parents: 22467
diff changeset
   219
class plus = type +
21524
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   220
  fixes plus :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixl "\<^loc>+" 65)
11750
3e400964893e judgment Trueprop;
wenzelm
parents: 11724
diff changeset
   221
22473
753123c89d72 explizit "type" superclass
haftmann
parents: 22467
diff changeset
   222
class minus = type +
20590
bf92900995f8 introduced syntactic classes; moved some setup to Pure/codegen, Pure/nbe or OperationalEquality.thy
haftmann
parents: 20453
diff changeset
   223
  fixes uminus :: "'a \<Rightarrow> 'a" 
21524
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   224
    and minus :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixl "\<^loc>-" 65)
20590
bf92900995f8 introduced syntactic classes; moved some setup to Pure/codegen, Pure/nbe or OperationalEquality.thy
haftmann
parents: 20453
diff changeset
   225
22473
753123c89d72 explizit "type" superclass
haftmann
parents: 22467
diff changeset
   226
class times = type +
20713
823967ef47f1 renamed 0 and 1 to HOL.zero and HOL.one respectivly; introduced corresponding syntactic classes
haftmann
parents: 20698
diff changeset
   227
  fixes times :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixl "\<^loc>*" 70)
20590
bf92900995f8 introduced syntactic classes; moved some setup to Pure/codegen, Pure/nbe or OperationalEquality.thy
haftmann
parents: 20453
diff changeset
   228
22473
753123c89d72 explizit "type" superclass
haftmann
parents: 22467
diff changeset
   229
class inverse = type +
20590
bf92900995f8 introduced syntactic classes; moved some setup to Pure/codegen, Pure/nbe or OperationalEquality.thy
haftmann
parents: 20453
diff changeset
   230
  fixes inverse :: "'a \<Rightarrow> 'a"
21524
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   231
    and divide :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixl "\<^loc>'/" 70)
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   232
23878
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   233
class abs = type +
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   234
  fixes abs :: "'a \<Rightarrow> 'a"
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   235
24506
020db6ec334a final(?) iteration of sgn saga.
nipkow
parents: 24462
diff changeset
   236
class sgn = type +
020db6ec334a final(?) iteration of sgn saga.
nipkow
parents: 24462
diff changeset
   237
  fixes sgn :: "'a \<Rightarrow> 'a"
020db6ec334a final(?) iteration of sgn saga.
nipkow
parents: 24462
diff changeset
   238
21524
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   239
notation
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   240
  uminus  ("- _" [81] 80)
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   241
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   242
notation (xsymbols)
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   243
  abs  ("\<bar>_\<bar>")
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   244
notation (HTML output)
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 21504
diff changeset
   245
  abs  ("\<bar>_\<bar>")
11750
3e400964893e judgment Trueprop;
wenzelm
parents: 11724
diff changeset
   246
23878
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   247
class ord = type +
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   248
  fixes less_eq :: "'a \<Rightarrow> 'a \<Rightarrow> bool"  (infix "\<sqsubseteq>" 50)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   249
    and less :: "'a \<Rightarrow> 'a \<Rightarrow> bool"  (infix "\<sqsubset>" 50)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   250
begin
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   251
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   252
notation
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   253
  less_eq  ("op \<^loc><=") and
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   254
  less_eq  ("(_/ \<^loc><= _)" [51, 51] 50) and
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   255
  less  ("op \<^loc><") and
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   256
  less  ("(_/ \<^loc>< _)"  [51, 51] 50)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   257
  
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   258
notation (xsymbols)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   259
  less_eq  ("op \<^loc>\<le>") and
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   260
  less_eq  ("(_/ \<^loc>\<le> _)"  [51, 51] 50)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   261
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   262
notation (HTML output)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   263
  less_eq  ("op \<^loc>\<le>") and
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   264
  less_eq  ("(_/ \<^loc>\<le> _)"  [51, 51] 50)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   265
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   266
abbreviation (input)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   267
  greater  (infix "\<^loc>>" 50) where
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   268
  "x \<^loc>> y \<equiv> y \<^loc>< x"
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   269
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   270
abbreviation (input)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   271
  greater_eq  (infix "\<^loc>>=" 50) where
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   272
  "x \<^loc>>= y \<equiv> y \<^loc><= x"
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   273
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   274
notation (input)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   275
  greater_eq  (infix "\<^loc>\<ge>" 50)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   276
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   277
definition
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   278
  Least :: "('a \<Rightarrow> bool) \<Rightarrow> 'a" (binder "\<^loc>LEAST " 10)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   279
where
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   280
  "Least P == (THE x. P x \<and> (\<forall>y. P y \<longrightarrow> x \<^loc>\<le> y))"
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   281
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   282
end
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   283
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   284
notation
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   285
  less_eq  ("op <=") and
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   286
  less_eq  ("(_/ <= _)" [51, 51] 50) and
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   287
  less  ("op <") and
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   288
  less  ("(_/ < _)"  [51, 51] 50)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   289
  
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   290
notation (xsymbols)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   291
  less_eq  ("op \<le>") and
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   292
  less_eq  ("(_/ \<le> _)"  [51, 51] 50)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   293
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   294
notation (HTML output)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   295
  less_eq  ("op \<le>") and
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   296
  less_eq  ("(_/ \<le> _)"  [51, 51] 50)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   297
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   298
abbreviation (input)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   299
  greater  (infix ">" 50) where
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   300
  "x > y \<equiv> y < x"
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   301
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   302
abbreviation (input)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   303
  greater_eq  (infix ">=" 50) where
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   304
  "x >= y \<equiv> y <= x"
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   305
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   306
notation (input)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   307
  greater_eq  (infix "\<ge>" 50)
bd651ecd4b8a simplified HOL bootstrap
haftmann
parents: 23566
diff changeset
   308
13456
42601eb7553f special syntax for index "1" (plain numeral hidden by "1" symbol in HOL);
wenzelm
parents: 13438
diff changeset
   309
syntax
42601eb7553f special syntax for index "1" (plain numeral hidden by "1" symbol in HOL);
wenzelm
parents: 13438
diff changeset
   310
  "_index1"  :: index    ("\<^sub>1")
42601eb7553f special syntax for index "1" (plain numeral hidden by "1" symbol in HOL);
wenzelm
parents: 13438
diff changeset
   311
translations
14690
f61ea8bfa81e _index1: accomodate improved indexed syntax;
wenzelm
parents: 14590
diff changeset
   312
  (index) "\<^sub>1" => (index) "\<^bsub>\<struct>\<^esub>"
13456
42601eb7553f special syntax for index "1" (plain numeral hidden by "1" symbol in HOL);
wenzelm
parents: 13438
diff changeset
   313
11750
3e400964893e judgment Trueprop;
wenzelm
parents: 11724
diff changeset
   314
typed_print_translation {*
20713
823967ef47f1 renamed 0 and 1 to HOL.zero and HOL.one respectivly; introduced corresponding syntactic classes
haftmann
parents: 20698
diff changeset
   315
let
823967ef47f1 renamed 0 and 1 to HOL.zero and HOL.one respectivly; introduced corresponding syntactic classes
haftmann
parents: 20698
diff changeset
   316
  fun tr' c = (c, fn show_sorts => fn T => fn ts =>
823967ef47f1 renamed 0 and 1 to HOL.zero and HOL.one respectivly; introduced corresponding syntactic classes
haftmann
parents: 20698
diff changeset
   317
    if T = dummyT orelse not (! show_types) andalso can Term.dest_Type T then raise Match
823967ef47f1 renamed 0 and 1 to HOL.zero and HOL.one respectivly; introduced corresponding syntactic classes
haftmann
parents: 20698
diff changeset
   318
    else Syntax.const Syntax.constrainC $ Syntax.const c $ Syntax.term_of_typ show_sorts T);
22993
haftmann
parents: 22839
diff changeset
   319
in map tr' [@{const_syntax HOL.one}, @{const_syntax HOL.zero}] end;
11750
3e400964893e judgment Trueprop;
wenzelm
parents: 11724
diff changeset
   320
*} -- {* show types that are presumably too general *}
3e400964893e judgment Trueprop;
wenzelm
parents: 11724
diff changeset
   321
3e400964893e judgment Trueprop;
wenzelm
parents: 11724
diff changeset
   322
20944
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   323
subsection {* Fundamental rules *}
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   324
20973
0b8e436ed071 cleaned up HOL bootstrap
haftmann
parents: 20944
diff changeset
   325
subsubsection {* Equality *}
20944
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   326
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   327
text {* Thanks to Stephan Merz *}
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   328
lemma subst:
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   329
  assumes eq: "s = t" and p: "P s"
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   330
  shows "P t"
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   331
proof -
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   332
  from eq have meta: "s \<equiv> t"
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   333
    by (rule eq_reflection)
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   334
  from p show ?thesis
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   335
    by (unfold meta)
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   336
qed
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   337
18457
356a9f711899 structure ProjectRule;
wenzelm
parents: 17992
diff changeset
   338
lemma sym: "s = t ==> t = s"
356a9f711899 structure ProjectRule;
wenzelm
parents: 17992
diff changeset
   339
  by (erule subst) (rule refl)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   340
18457
356a9f711899 structure ProjectRule;
wenzelm
parents: 17992
diff changeset
   341
lemma ssubst: "t = s ==> P s ==> P t"
356a9f711899 structure ProjectRule;
wenzelm
parents: 17992
diff changeset
   342
  by (drule sym) (erule subst)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   343
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   344
lemma trans: "[| r=s; s=t |] ==> r=t"
18457
356a9f711899 structure ProjectRule;
wenzelm
parents: 17992
diff changeset
   345
  by (erule subst)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   346
20944
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   347
lemma meta_eq_to_obj_eq: 
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   348
  assumes meq: "A == B"
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   349
  shows "A = B"
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   350
  by (unfold meq) (rule refl)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   351
21502
7f3ea2b3bab6 prefer antiquotations over LaTeX macros;
wenzelm
parents: 21486
diff changeset
   352
text {* Useful with @{text erule} for proving equalities from known equalities. *}
20944
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   353
     (* a = b
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   354
        |   |
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   355
        c = d   *)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   356
lemma box_equals: "[| a=b;  a=c;  b=d |] ==> c=d"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   357
apply (rule trans)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   358
apply (rule trans)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   359
apply (rule sym)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   360
apply assumption+
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   361
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   362
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15481
diff changeset
   363
text {* For calculational reasoning: *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15481
diff changeset
   364
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15481
diff changeset
   365
lemma forw_subst: "a = b ==> P b ==> P a"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15481
diff changeset
   366
  by (rule ssubst)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15481
diff changeset
   367
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15481
diff changeset
   368
lemma back_subst: "P a ==> a = b ==> P b"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15481
diff changeset
   369
  by (rule subst)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15481
diff changeset
   370
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   371
20944
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   372
subsubsection {*Congruence rules for application*}
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   373
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   374
(*similar to AP_THM in Gordon's HOL*)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   375
lemma fun_cong: "(f::'a=>'b) = g ==> f(x)=g(x)"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   376
apply (erule subst)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   377
apply (rule refl)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   378
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   379
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   380
(*similar to AP_TERM in Gordon's HOL and FOL's subst_context*)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   381
lemma arg_cong: "x=y ==> f(x)=f(y)"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   382
apply (erule subst)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   383
apply (rule refl)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   384
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   385
15655
157f3988f775 arg_cong2 by Norbert Voelker
paulson
parents: 15570
diff changeset
   386
lemma arg_cong2: "\<lbrakk> a = b; c = d \<rbrakk> \<Longrightarrow> f a c = f b d"
157f3988f775 arg_cong2 by Norbert Voelker
paulson
parents: 15570
diff changeset
   387
apply (erule ssubst)+
157f3988f775 arg_cong2 by Norbert Voelker
paulson
parents: 15570
diff changeset
   388
apply (rule refl)
157f3988f775 arg_cong2 by Norbert Voelker
paulson
parents: 15570
diff changeset
   389
done
157f3988f775 arg_cong2 by Norbert Voelker
paulson
parents: 15570
diff changeset
   390
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   391
lemma cong: "[| f = g; (x::'a) = y |] ==> f(x) = g(y)"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   392
apply (erule subst)+
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   393
apply (rule refl)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   394
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   395
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   396
20944
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   397
subsubsection {*Equality of booleans -- iff*}
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   398
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   399
lemma iffI: assumes "P ==> Q" and "Q ==> P" shows "P=Q"
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   400
  by (iprover intro: iff [THEN mp, THEN mp] impI assms)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   401
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   402
lemma iffD2: "[| P=Q; Q |] ==> P"
18457
356a9f711899 structure ProjectRule;
wenzelm
parents: 17992
diff changeset
   403
  by (erule ssubst)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   404
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   405
lemma rev_iffD2: "[| Q; P=Q |] ==> P"
18457
356a9f711899 structure ProjectRule;
wenzelm
parents: 17992
diff changeset
   406
  by (erule iffD2)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   407
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   408
lemma iffD1: "Q = P \<Longrightarrow> Q \<Longrightarrow> P"
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   409
  by (drule sym) (rule iffD2)
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   410
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   411
lemma rev_iffD1: "Q \<Longrightarrow> Q = P \<Longrightarrow> P"
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   412
  by (drule sym) (rule rev_iffD2)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   413
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   414
lemma iffE:
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   415
  assumes major: "P=Q"
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   416
    and minor: "[| P --> Q; Q --> P |] ==> R"
18457
356a9f711899 structure ProjectRule;
wenzelm
parents: 17992
diff changeset
   417
  shows R
356a9f711899 structure ProjectRule;
wenzelm
parents: 17992
diff changeset
   418
  by (iprover intro: minor impI major [THEN iffD2] major [THEN iffD1])
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   419
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   420
20944
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   421
subsubsection {*True*}
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   422
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   423
lemma TrueI: "True"
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   424
  unfolding True_def by (rule refl)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   425
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   426
lemma eqTrueI: "P ==> P = True"
18457
356a9f711899 structure ProjectRule;
wenzelm
parents: 17992
diff changeset
   427
  by (iprover intro: iffI TrueI)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   428
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   429
lemma eqTrueE: "P = True ==> P"
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   430
  by (erule iffD2) (rule TrueI)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   431
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   432
20944
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   433
subsubsection {*Universal quantifier*}
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   434
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   435
lemma allI: assumes "!!x::'a. P(x)" shows "ALL x. P(x)"
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   436
  unfolding All_def by (iprover intro: ext eqTrueI assms)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   437
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   438
lemma spec: "ALL x::'a. P(x) ==> P(x)"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   439
apply (unfold All_def)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   440
apply (rule eqTrueE)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   441
apply (erule fun_cong)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   442
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   443
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   444
lemma allE:
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   445
  assumes major: "ALL x. P(x)"
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   446
    and minor: "P(x) ==> R"
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   447
  shows R
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   448
  by (iprover intro: minor major [THEN spec])
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   449
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   450
lemma all_dupE:
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   451
  assumes major: "ALL x. P(x)"
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   452
    and minor: "[| P(x); ALL x. P(x) |] ==> R"
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   453
  shows R
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   454
  by (iprover intro: minor major major [THEN spec])
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   455
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   456
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   457
subsubsection {* False *}
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   458
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   459
text {*
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   460
  Depends upon @{text spec}; it is impossible to do propositional
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   461
  logic before quantifiers!
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   462
*}
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   463
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   464
lemma FalseE: "False ==> P"
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   465
  apply (unfold False_def)
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   466
  apply (erule spec)
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   467
  done
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   468
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   469
lemma False_neq_True: "False = True ==> P"
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   470
  by (erule eqTrueE [THEN FalseE])
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   471
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   472
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   473
subsubsection {* Negation *}
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   474
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   475
lemma notI:
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   476
  assumes "P ==> False"
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   477
  shows "~P"
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   478
  apply (unfold not_def)
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   479
  apply (iprover intro: impI assms)
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   480
  done
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   481
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   482
lemma False_not_True: "False ~= True"
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   483
  apply (rule notI)
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   484
  apply (erule False_neq_True)
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   485
  done
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   486
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   487
lemma True_not_False: "True ~= False"
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   488
  apply (rule notI)
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   489
  apply (drule sym)
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   490
  apply (erule False_neq_True)
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   491
  done
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   492
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   493
lemma notE: "[| ~P;  P |] ==> R"
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   494
  apply (unfold not_def)
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   495
  apply (erule mp [THEN FalseE])
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   496
  apply assumption
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   497
  done
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   498
21504
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   499
lemma notI2: "(P \<Longrightarrow> \<not> Pa) \<Longrightarrow> (P \<Longrightarrow> Pa) \<Longrightarrow> \<not> P"
9c97af4a1567 tuned proofs;
wenzelm
parents: 21502
diff changeset
   500
  by (erule notE [THEN notI]) (erule meta_mp)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   501
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   502
20944
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   503
subsubsection {*Implication*}
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   504
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   505
lemma impE:
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   506
  assumes "P-->Q" "P" "Q ==> R"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   507
  shows "R"
23553
af8ae54238f5 use hologic.ML in basic HOL context;
wenzelm
parents: 23530
diff changeset
   508
by (iprover intro: assms mp)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   509
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   510
(* Reduces Q to P-->Q, allowing substitution in P. *)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   511
lemma rev_mp: "[| P;  P --> Q |] ==> Q"
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 17459
diff changeset
   512
by (iprover intro: mp)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   513
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   514
lemma contrapos_nn:
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   515
  assumes major: "~Q"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   516
      and minor: "P==>Q"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   517
  shows "~P"
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 17459
diff changeset
   518
by (iprover intro: notI minor major [THEN notE])
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   519
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   520
(*not used at all, but we already have the other 3 combinations *)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   521
lemma contrapos_pn:
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   522
  assumes major: "Q"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   523
      and minor: "P ==> ~Q"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   524
  shows "~P"
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 17459
diff changeset
   525
by (iprover intro: notI minor major notE)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   526
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   527
lemma not_sym: "t ~= s ==> s ~= t"
21250
a268f6288fb6 moved lemma eq_neq_eq_imp_neq to HOL
haftmann
parents: 21218
diff changeset
   528
  by (erule contrapos_nn) (erule sym)
a268f6288fb6 moved lemma eq_neq_eq_imp_neq to HOL
haftmann
parents: 21218
diff changeset
   529
a268f6288fb6 moved lemma eq_neq_eq_imp_neq to HOL
haftmann
parents: 21218
diff changeset
   530
lemma eq_neq_eq_imp_neq: "[| x = a ; a ~= b; b = y |] ==> x ~= y"
a268f6288fb6 moved lemma eq_neq_eq_imp_neq to HOL
haftmann
parents: 21218
diff changeset
   531
  by (erule subst, erule ssubst, assumption)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   532
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   533
(*still used in HOLCF*)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   534
lemma rev_contrapos:
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   535
  assumes pq: "P ==> Q"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   536
      and nq: "~Q"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   537
  shows "~P"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   538
apply (rule nq [THEN contrapos_nn])
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   539
apply (erule pq)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   540
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   541
20944
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   542
subsubsection {*Existential quantifier*}
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   543
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   544
lemma exI: "P x ==> EX x::'a. P x"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   545
apply (unfold Ex_def)
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 17459
diff changeset
   546
apply (iprover intro: allI allE impI mp)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   547
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   548
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   549
lemma exE:
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   550
  assumes major: "EX x::'a. P(x)"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   551
      and minor: "!!x. P(x) ==> Q"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   552
  shows "Q"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   553
apply (rule major [unfolded Ex_def, THEN spec, THEN mp])
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 17459
diff changeset
   554
apply (iprover intro: impI [THEN allI] minor)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   555
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   556
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   557
20944
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   558
subsubsection {*Conjunction*}
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   559
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   560
lemma conjI: "[| P; Q |] ==> P&Q"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   561
apply (unfold and_def)
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 17459
diff changeset
   562
apply (iprover intro: impI [THEN allI] mp)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   563
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   564
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   565
lemma conjunct1: "[| P & Q |] ==> P"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   566
apply (unfold and_def)
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 17459
diff changeset
   567
apply (iprover intro: impI dest: spec mp)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   568
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   569
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   570
lemma conjunct2: "[| P & Q |] ==> Q"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   571
apply (unfold and_def)
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 17459
diff changeset
   572
apply (iprover intro: impI dest: spec mp)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   573
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   574
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   575
lemma conjE:
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   576
  assumes major: "P&Q"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   577
      and minor: "[| P; Q |] ==> R"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   578
  shows "R"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   579
apply (rule minor)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   580
apply (rule major [THEN conjunct1])
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   581
apply (rule major [THEN conjunct2])
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   582
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   583
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   584
lemma context_conjI:
23553
af8ae54238f5 use hologic.ML in basic HOL context;
wenzelm
parents: 23530
diff changeset
   585
  assumes "P" "P ==> Q" shows "P & Q"
af8ae54238f5 use hologic.ML in basic HOL context;
wenzelm
parents: 23530
diff changeset
   586
by (iprover intro: conjI assms)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   587
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   588
20944
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   589
subsubsection {*Disjunction*}
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   590
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   591
lemma disjI1: "P ==> P|Q"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   592
apply (unfold or_def)
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 17459
diff changeset
   593
apply (iprover intro: allI impI mp)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   594
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   595
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   596
lemma disjI2: "Q ==> P|Q"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   597
apply (unfold or_def)
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 17459
diff changeset
   598
apply (iprover intro: allI impI mp)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   599
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   600
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   601
lemma disjE:
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   602
  assumes major: "P|Q"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   603
      and minorP: "P ==> R"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   604
      and minorQ: "Q ==> R"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   605
  shows "R"
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 17459
diff changeset
   606
by (iprover intro: minorP minorQ impI
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   607
                 major [unfolded or_def, THEN spec, THEN mp, THEN mp])
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   608
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   609
20944
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   610
subsubsection {*Classical logic*}
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   611
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   612
lemma classical:
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   613
  assumes prem: "~P ==> P"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   614
  shows "P"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   615
apply (rule True_or_False [THEN disjE, THEN eqTrueE])
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   616
apply assumption
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   617
apply (rule notI [THEN prem, THEN eqTrueI])
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   618
apply (erule subst)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   619
apply assumption
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   620
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   621
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   622
lemmas ccontr = FalseE [THEN classical, standard]
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   623
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   624
(*notE with premises exchanged; it discharges ~R so that it can be used to
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   625
  make elimination rules*)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   626
lemma rev_notE:
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   627
  assumes premp: "P"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   628
      and premnot: "~R ==> ~P"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   629
  shows "R"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   630
apply (rule ccontr)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   631
apply (erule notE [OF premnot premp])
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   632
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   633
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   634
(*Double negation law*)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   635
lemma notnotD: "~~P ==> P"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   636
apply (rule classical)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   637
apply (erule notE)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   638
apply assumption
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   639
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   640
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   641
lemma contrapos_pp:
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   642
  assumes p1: "Q"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   643
      and p2: "~P ==> ~Q"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   644
  shows "P"
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 17459
diff changeset
   645
by (iprover intro: classical p1 p2 notE)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   646
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   647
20944
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   648
subsubsection {*Unique existence*}
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   649
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   650
lemma ex1I:
23553
af8ae54238f5 use hologic.ML in basic HOL context;
wenzelm
parents: 23530
diff changeset
   651
  assumes "P a" "!!x. P(x) ==> x=a"
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   652
  shows "EX! x. P(x)"
23553
af8ae54238f5 use hologic.ML in basic HOL context;
wenzelm
parents: 23530
diff changeset
   653
by (unfold Ex1_def, iprover intro: assms exI conjI allI impI)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   654
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   655
text{*Sometimes easier to use: the premises have no shared variables.  Safe!*}
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   656
lemma ex_ex1I:
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   657
  assumes ex_prem: "EX x. P(x)"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   658
      and eq: "!!x y. [| P(x); P(y) |] ==> x=y"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   659
  shows "EX! x. P(x)"
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 17459
diff changeset
   660
by (iprover intro: ex_prem [THEN exE] ex1I eq)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   661
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   662
lemma ex1E:
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   663
  assumes major: "EX! x. P(x)"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   664
      and minor: "!!x. [| P(x);  ALL y. P(y) --> y=x |] ==> R"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   665
  shows "R"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   666
apply (rule major [unfolded Ex1_def, THEN exE])
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   667
apply (erule conjE)
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 17459
diff changeset
   668
apply (iprover intro: minor)
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   669
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   670
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   671
lemma ex1_implies_ex: "EX! x. P x ==> EX x. P x"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   672
apply (erule ex1E)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   673
apply (rule exI)
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   674
apply assumption
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   675
done
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   676
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   677
20944
34b2c1bb7178 cleanup basic HOL bootstrap
haftmann
parents: 20833
diff changeset
   678
subsubsection {*THE: definite description operator*}
15411
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   679
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   680
lemma the_equality:
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   681
  assumes prema: "P a"
1d195de59497 removal of HOL_Lemmas
paulson
parents: 15380
diff changeset
   682
      and premx: "!!x. P x ==> x=a"
1d195de59497 removal of HOL_Lemmas