src/HOL/HOL.thy
author wenzelm
Sat Nov 24 16:54:10 2001 +0100 (2001-11-24)
changeset 12281 3bd113b8f7a6
parent 12256 26243ebf2831
child 12338 de0f4a63baa5
permissions -rw-r--r--
converted simp lemmas;
clasohm@923
     1
(*  Title:      HOL/HOL.thy
clasohm@923
     2
    ID:         $Id$
wenzelm@11750
     3
    Author:     Tobias Nipkow, Markus Wenzel, and Larry Paulson
wenzelm@11750
     4
*)
clasohm@923
     5
wenzelm@11750
     6
header {* The basis of Higher-Order Logic *}
clasohm@923
     7
wenzelm@7357
     8
theory HOL = CPure
paulson@11451
     9
files ("HOL_lemmas.ML") ("cladata.ML") ("blastdata.ML") ("simpdata.ML"):
clasohm@923
    10
wenzelm@2260
    11
wenzelm@11750
    12
subsection {* Primitive logic *}
wenzelm@11750
    13
wenzelm@11750
    14
subsubsection {* Core syntax *}
wenzelm@2260
    15
wenzelm@3947
    16
global
wenzelm@3947
    17
wenzelm@7357
    18
classes "term" < logic
wenzelm@7357
    19
defaultsort "term"
clasohm@923
    20
wenzelm@7357
    21
typedecl bool
clasohm@923
    22
clasohm@923
    23
arities
wenzelm@7357
    24
  bool :: "term"
wenzelm@7357
    25
  fun :: ("term", "term") "term"
clasohm@923
    26
wenzelm@11750
    27
judgment
wenzelm@11750
    28
  Trueprop      :: "bool => prop"                   ("(_)" 5)
clasohm@923
    29
wenzelm@11750
    30
consts
wenzelm@7357
    31
  Not           :: "bool => bool"                   ("~ _" [40] 40)
wenzelm@7357
    32
  True          :: bool
wenzelm@7357
    33
  False         :: bool
wenzelm@7357
    34
  If            :: "[bool, 'a, 'a] => 'a"           ("(if (_)/ then (_)/ else (_))" 10)
wenzelm@3947
    35
  arbitrary     :: 'a
clasohm@923
    36
wenzelm@11432
    37
  The           :: "('a => bool) => 'a"
wenzelm@7357
    38
  All           :: "('a => bool) => bool"           (binder "ALL " 10)
wenzelm@7357
    39
  Ex            :: "('a => bool) => bool"           (binder "EX " 10)
wenzelm@7357
    40
  Ex1           :: "('a => bool) => bool"           (binder "EX! " 10)
wenzelm@7357
    41
  Let           :: "['a, 'a => 'b] => 'b"
clasohm@923
    42
wenzelm@7357
    43
  "="           :: "['a, 'a] => bool"               (infixl 50)
wenzelm@7357
    44
  &             :: "[bool, bool] => bool"           (infixr 35)
wenzelm@7357
    45
  "|"           :: "[bool, bool] => bool"           (infixr 30)
wenzelm@7357
    46
  -->           :: "[bool, bool] => bool"           (infixr 25)
clasohm@923
    47
wenzelm@10432
    48
local
wenzelm@10432
    49
wenzelm@2260
    50
wenzelm@11750
    51
subsubsection {* Additional concrete syntax *}
wenzelm@2260
    52
wenzelm@4868
    53
nonterminals
clasohm@923
    54
  letbinds  letbind
clasohm@923
    55
  case_syn  cases_syn
clasohm@923
    56
clasohm@923
    57
syntax
wenzelm@7357
    58
  ~=            :: "['a, 'a] => bool"                    (infixl 50)
wenzelm@11432
    59
  "_The"        :: "[pttrn, bool] => 'a"                 ("(3THE _./ _)" [0, 10] 10)
clasohm@923
    60
wenzelm@7357
    61
  "_bind"       :: "[pttrn, 'a] => letbind"              ("(2_ =/ _)" 10)
wenzelm@7357
    62
  ""            :: "letbind => letbinds"                 ("_")
wenzelm@7357
    63
  "_binds"      :: "[letbind, letbinds] => letbinds"     ("_;/ _")
wenzelm@7357
    64
  "_Let"        :: "[letbinds, 'a] => 'a"                ("(let (_)/ in (_))" 10)
clasohm@923
    65
wenzelm@9060
    66
  "_case_syntax":: "['a, cases_syn] => 'b"               ("(case _ of/ _)" 10)
wenzelm@9060
    67
  "_case1"      :: "['a, 'b] => case_syn"                ("(2_ =>/ _)" 10)
wenzelm@7357
    68
  ""            :: "case_syn => cases_syn"               ("_")
wenzelm@9060
    69
  "_case2"      :: "[case_syn, cases_syn] => cases_syn"  ("_/ | _")
clasohm@923
    70
clasohm@923
    71
translations
wenzelm@7238
    72
  "x ~= y"                == "~ (x = y)"
wenzelm@11432
    73
  "THE x. P"              == "The (%x. P)"
clasohm@923
    74
  "_Let (_binds b bs) e"  == "_Let b (_Let bs e)"
nipkow@1114
    75
  "let x = a in e"        == "Let a (%x. e)"
clasohm@923
    76
wenzelm@3820
    77
syntax ("" output)
wenzelm@11687
    78
  "="           :: "['a, 'a] => bool"                    (infix 50)
wenzelm@11687
    79
  "~="          :: "['a, 'a] => bool"                    (infix 50)
wenzelm@2260
    80
wenzelm@12114
    81
syntax (xsymbols)
wenzelm@11687
    82
  Not           :: "bool => bool"                        ("\<not> _" [40] 40)
wenzelm@11687
    83
  "op &"        :: "[bool, bool] => bool"                (infixr "\<and>" 35)
wenzelm@11687
    84
  "op |"        :: "[bool, bool] => bool"                (infixr "\<or>" 30)
wenzelm@12114
    85
  "op -->"      :: "[bool, bool] => bool"                (infixr "\<longrightarrow>" 25)
wenzelm@11687
    86
  "op ~="       :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
wenzelm@11687
    87
  "ALL "        :: "[idts, bool] => bool"                ("(3\<forall>_./ _)" [0, 10] 10)
wenzelm@11687
    88
  "EX "         :: "[idts, bool] => bool"                ("(3\<exists>_./ _)" [0, 10] 10)
wenzelm@11687
    89
  "EX! "        :: "[idts, bool] => bool"                ("(3\<exists>!_./ _)" [0, 10] 10)
wenzelm@11687
    90
  "_case1"      :: "['a, 'b] => case_syn"                ("(2_ \<Rightarrow>/ _)" 10)
wenzelm@9060
    91
(*"_case2"      :: "[case_syn, cases_syn] => cases_syn"  ("_/ \\<orelse> _")*)
wenzelm@2372
    92
wenzelm@12114
    93
syntax (xsymbols output)
wenzelm@11687
    94
  "op ~="       :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
wenzelm@3820
    95
wenzelm@6340
    96
syntax (HTML output)
wenzelm@11687
    97
  Not           :: "bool => bool"                        ("\<not> _" [40] 40)
wenzelm@6340
    98
wenzelm@7238
    99
syntax (HOL)
wenzelm@7357
   100
  "ALL "        :: "[idts, bool] => bool"                ("(3! _./ _)" [0, 10] 10)
wenzelm@7357
   101
  "EX "         :: "[idts, bool] => bool"                ("(3? _./ _)" [0, 10] 10)
wenzelm@7357
   102
  "EX! "        :: "[idts, bool] => bool"                ("(3?! _./ _)" [0, 10] 10)
wenzelm@7238
   103
wenzelm@7238
   104
wenzelm@11750
   105
subsubsection {* Axioms and basic definitions *}
wenzelm@2260
   106
wenzelm@7357
   107
axioms
wenzelm@7357
   108
  eq_reflection: "(x=y) ==> (x==y)"
clasohm@923
   109
wenzelm@7357
   110
  refl:         "t = (t::'a)"
wenzelm@7357
   111
  subst:        "[| s = t; P(s) |] ==> P(t::'a)"
paulson@6289
   112
wenzelm@7357
   113
  ext:          "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)"
wenzelm@11750
   114
    -- {* Extensionality is built into the meta-logic, and this rule expresses *}
wenzelm@11750
   115
    -- {* a related property.  It is an eta-expanded version of the traditional *}
wenzelm@11750
   116
    -- {* rule, and similar to the ABS rule of HOL *}
paulson@6289
   117
wenzelm@11432
   118
  the_eq_trivial: "(THE x. x = a) = (a::'a)"
clasohm@923
   119
wenzelm@7357
   120
  impI:         "(P ==> Q) ==> P-->Q"
wenzelm@7357
   121
  mp:           "[| P-->Q;  P |] ==> Q"
clasohm@923
   122
clasohm@923
   123
defs
wenzelm@7357
   124
  True_def:     "True      == ((%x::bool. x) = (%x. x))"
wenzelm@7357
   125
  All_def:      "All(P)    == (P = (%x. True))"
paulson@11451
   126
  Ex_def:       "Ex(P)     == !Q. (!x. P x --> Q) --> Q"
wenzelm@7357
   127
  False_def:    "False     == (!P. P)"
wenzelm@7357
   128
  not_def:      "~ P       == P-->False"
wenzelm@7357
   129
  and_def:      "P & Q     == !R. (P-->Q-->R) --> R"
wenzelm@7357
   130
  or_def:       "P | Q     == !R. (P-->R) --> (Q-->R) --> R"
wenzelm@7357
   131
  Ex1_def:      "Ex1(P)    == ? x. P(x) & (! y. P(y) --> y=x)"
clasohm@923
   132
wenzelm@7357
   133
axioms
wenzelm@7357
   134
  iff:          "(P-->Q) --> (Q-->P) --> (P=Q)"
wenzelm@7357
   135
  True_or_False:  "(P=True) | (P=False)"
clasohm@923
   136
clasohm@923
   137
defs
wenzelm@7357
   138
  Let_def:      "Let s f == f(s)"
paulson@11451
   139
  if_def:       "If P x y == THE z::'a. (P=True --> z=x) & (P=False --> z=y)"
wenzelm@5069
   140
paulson@11451
   141
  arbitrary_def:  "False ==> arbitrary == (THE x. False)"
wenzelm@11750
   142
    -- {* @{term arbitrary} is completely unspecified, but is made to appear as a
wenzelm@11750
   143
    definition syntactically *}
clasohm@923
   144
nipkow@3320
   145
wenzelm@11750
   146
subsubsection {* Generic algebraic operations *}
wenzelm@4868
   147
wenzelm@11750
   148
axclass zero < "term"
wenzelm@11750
   149
axclass one < "term"
wenzelm@11750
   150
axclass plus < "term"
wenzelm@11750
   151
axclass minus < "term"
wenzelm@11750
   152
axclass times < "term"
wenzelm@11750
   153
axclass inverse < "term"
wenzelm@11750
   154
wenzelm@11750
   155
global
wenzelm@11750
   156
wenzelm@11750
   157
consts
wenzelm@11750
   158
  "0"           :: "'a::zero"                       ("0")
wenzelm@11750
   159
  "1"           :: "'a::one"                        ("1")
wenzelm@11750
   160
  "+"           :: "['a::plus, 'a]  => 'a"          (infixl 65)
wenzelm@11750
   161
  -             :: "['a::minus, 'a] => 'a"          (infixl 65)
wenzelm@11750
   162
  uminus        :: "['a::minus] => 'a"              ("- _" [81] 80)
wenzelm@11750
   163
  *             :: "['a::times, 'a] => 'a"          (infixl 70)
wenzelm@11750
   164
wenzelm@11750
   165
local
wenzelm@11750
   166
wenzelm@11750
   167
typed_print_translation {*
wenzelm@11750
   168
  let
wenzelm@11750
   169
    fun tr' c = (c, fn show_sorts => fn T => fn ts =>
wenzelm@11750
   170
      if T = dummyT orelse not (! show_types) andalso can Term.dest_Type T then raise Match
wenzelm@11750
   171
      else Syntax.const Syntax.constrainC $ Syntax.const c $ Syntax.term_of_typ show_sorts T);
wenzelm@11750
   172
  in [tr' "0", tr' "1"] end;
wenzelm@11750
   173
*} -- {* show types that are presumably too general *}
wenzelm@11750
   174
wenzelm@11750
   175
wenzelm@11750
   176
consts
wenzelm@11750
   177
  abs           :: "'a::minus => 'a"
wenzelm@11750
   178
  inverse       :: "'a::inverse => 'a"
wenzelm@11750
   179
  divide        :: "['a::inverse, 'a] => 'a"        (infixl "'/" 70)
wenzelm@11750
   180
wenzelm@11750
   181
syntax (xsymbols)
wenzelm@11750
   182
  abs :: "'a::minus => 'a"    ("\<bar>_\<bar>")
wenzelm@11750
   183
syntax (HTML output)
wenzelm@11750
   184
  abs :: "'a::minus => 'a"    ("\<bar>_\<bar>")
wenzelm@11750
   185
wenzelm@11750
   186
axclass plus_ac0 < plus, zero
wenzelm@11750
   187
  commute: "x + y = y + x"
wenzelm@11750
   188
  assoc:   "(x + y) + z = x + (y + z)"
wenzelm@11750
   189
  zero:    "0 + x = x"
wenzelm@11750
   190
wenzelm@11750
   191
wenzelm@11750
   192
subsection {* Theory and package setup *}
wenzelm@11750
   193
wenzelm@11750
   194
subsubsection {* Basic lemmas *}
wenzelm@4868
   195
nipkow@9736
   196
use "HOL_lemmas.ML"
wenzelm@11687
   197
theorems case_split = case_split_thm [case_names True False]
wenzelm@9869
   198
wenzelm@11750
   199
declare trans [trans]
wenzelm@11750
   200
declare impE [CPure.elim]  iffD1 [CPure.elim]  iffD2 [CPure.elim]
wenzelm@11750
   201
wenzelm@11438
   202
wenzelm@11750
   203
subsubsection {* Atomizing meta-level connectives *}
wenzelm@11750
   204
wenzelm@11750
   205
lemma atomize_all [atomize]: "(!!x. P x) == Trueprop (ALL x. P x)"
wenzelm@12003
   206
proof
wenzelm@9488
   207
  assume "!!x. P x"
wenzelm@10383
   208
  show "ALL x. P x" by (rule allI)
wenzelm@9488
   209
next
wenzelm@9488
   210
  assume "ALL x. P x"
wenzelm@10383
   211
  thus "!!x. P x" by (rule allE)
wenzelm@9488
   212
qed
wenzelm@9488
   213
wenzelm@11750
   214
lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A --> B)"
wenzelm@12003
   215
proof
wenzelm@9488
   216
  assume r: "A ==> B"
wenzelm@10383
   217
  show "A --> B" by (rule impI) (rule r)
wenzelm@9488
   218
next
wenzelm@9488
   219
  assume "A --> B" and A
wenzelm@10383
   220
  thus B by (rule mp)
wenzelm@9488
   221
qed
wenzelm@9488
   222
wenzelm@11750
   223
lemma atomize_eq [atomize]: "(x == y) == Trueprop (x = y)"
wenzelm@12003
   224
proof
wenzelm@10432
   225
  assume "x == y"
wenzelm@10432
   226
  show "x = y" by (unfold prems) (rule refl)
wenzelm@10432
   227
next
wenzelm@10432
   228
  assume "x = y"
wenzelm@10432
   229
  thus "x == y" by (rule eq_reflection)
wenzelm@10432
   230
qed
wenzelm@10432
   231
wenzelm@12023
   232
lemma atomize_conj [atomize]:
wenzelm@12023
   233
  "(!!C. (A ==> B ==> PROP C) ==> PROP C) == Trueprop (A & B)"
wenzelm@12003
   234
proof
wenzelm@11953
   235
  assume "!!C. (A ==> B ==> PROP C) ==> PROP C"
wenzelm@11953
   236
  show "A & B" by (rule conjI)
wenzelm@11953
   237
next
wenzelm@11953
   238
  fix C
wenzelm@11953
   239
  assume "A & B"
wenzelm@11953
   240
  assume "A ==> B ==> PROP C"
wenzelm@11953
   241
  thus "PROP C"
wenzelm@11953
   242
  proof this
wenzelm@11953
   243
    show A by (rule conjunct1)
wenzelm@11953
   244
    show B by (rule conjunct2)
wenzelm@11953
   245
  qed
wenzelm@11953
   246
qed
wenzelm@11953
   247
wenzelm@11750
   248
wenzelm@11750
   249
subsubsection {* Classical Reasoner setup *}
wenzelm@9529
   250
wenzelm@10383
   251
use "cladata.ML"
wenzelm@10383
   252
setup hypsubst_setup
wenzelm@11977
   253
wenzelm@11770
   254
declare atomize_all [symmetric, rulify]  atomize_imp [symmetric, rulify]
wenzelm@11977
   255
wenzelm@10383
   256
setup Classical.setup
wenzelm@10383
   257
setup clasetup
wenzelm@10383
   258
wenzelm@11977
   259
declare ext [intro?]
wenzelm@11977
   260
declare disjI1 [elim?]  disjI2 [elim?]  ex1_implies_ex [elim?]  sym [elim?]
wenzelm@11977
   261
wenzelm@9869
   262
use "blastdata.ML"
wenzelm@9869
   263
setup Blast.setup
wenzelm@4868
   264
wenzelm@11750
   265
wenzelm@11750
   266
subsubsection {* Simplifier setup *}
wenzelm@11750
   267
wenzelm@12281
   268
lemma meta_eq_to_obj_eq: "x == y ==> x = y"
wenzelm@12281
   269
proof -
wenzelm@12281
   270
  assume r: "x == y"
wenzelm@12281
   271
  show "x = y" by (unfold r) (rule refl)
wenzelm@12281
   272
qed
wenzelm@12281
   273
wenzelm@12281
   274
lemma eta_contract_eq: "(%s. f s) = f" ..
wenzelm@12281
   275
wenzelm@12281
   276
lemma simp_thms:
wenzelm@12281
   277
  (not_not: "(~ ~ P) = P" and
wenzelm@12281
   278
    "(x = x) = True"
wenzelm@12281
   279
    "(~True) = False"  "(~False) = True"
wenzelm@12281
   280
    "(~P) ~= P"  "P ~= (~P)"  "(P ~= Q) = (P = (~Q))"
wenzelm@12281
   281
    "(True=P) = P"  "(P=True) = P"  "(False=P) = (~P)"  "(P=False) = (~P)"
wenzelm@12281
   282
    "(True --> P) = P"  "(False --> P) = True"
wenzelm@12281
   283
    "(P --> True) = True"  "(P --> P) = True"
wenzelm@12281
   284
    "(P --> False) = (~P)"  "(P --> ~P) = (~P)"
wenzelm@12281
   285
    "(P & True) = P"  "(True & P) = P"
wenzelm@12281
   286
    "(P & False) = False"  "(False & P) = False"
wenzelm@12281
   287
    "(P & P) = P"  "(P & (P & Q)) = (P & Q)"
wenzelm@12281
   288
    "(P & ~P) = False"    "(~P & P) = False"
wenzelm@12281
   289
    "(P | True) = True"  "(True | P) = True"
wenzelm@12281
   290
    "(P | False) = P"  "(False | P) = P"
wenzelm@12281
   291
    "(P | P) = P"  "(P | (P | Q)) = (P | Q)"
wenzelm@12281
   292
    "(P | ~P) = True"    "(~P | P) = True"
wenzelm@12281
   293
    "((~P) = (~Q)) = (P=Q)" and
wenzelm@12281
   294
    "(ALL x. P) = P"  "(EX x. P) = P"  "EX x. x=t"  "EX x. t=x"
wenzelm@12281
   295
    -- {* needed for the one-point-rule quantifier simplification procs *}
wenzelm@12281
   296
    -- {* essential for termination!! *} and
wenzelm@12281
   297
    "!!P. (EX x. x=t & P(x)) = P(t)"
wenzelm@12281
   298
    "!!P. (EX x. t=x & P(x)) = P(t)"
wenzelm@12281
   299
    "!!P. (ALL x. x=t --> P(x)) = P(t)"
wenzelm@12281
   300
    "!!P. (ALL x. t=x --> P(x)) = P(t)")
wenzelm@12281
   301
  by blast+
wenzelm@12281
   302
wenzelm@12281
   303
lemma imp_cong: "(P = P') ==> (P' ==> (Q = Q')) ==> ((P --> Q) = (P' --> Q'))"
wenzelm@12281
   304
  by blast
wenzelm@12281
   305
wenzelm@12281
   306
lemma ex_simps:
wenzelm@12281
   307
  "!!P Q. (EX x. P x & Q)   = ((EX x. P x) & Q)"
wenzelm@12281
   308
  "!!P Q. (EX x. P & Q x)   = (P & (EX x. Q x))"
wenzelm@12281
   309
  "!!P Q. (EX x. P x | Q)   = ((EX x. P x) | Q)"
wenzelm@12281
   310
  "!!P Q. (EX x. P | Q x)   = (P | (EX x. Q x))"
wenzelm@12281
   311
  "!!P Q. (EX x. P x --> Q) = ((ALL x. P x) --> Q)"
wenzelm@12281
   312
  "!!P Q. (EX x. P --> Q x) = (P --> (EX x. Q x))"
wenzelm@12281
   313
  -- {* Miniscoping: pushing in existential quantifiers. *}
wenzelm@12281
   314
  by blast+
wenzelm@12281
   315
wenzelm@12281
   316
lemma all_simps:
wenzelm@12281
   317
  "!!P Q. (ALL x. P x & Q)   = ((ALL x. P x) & Q)"
wenzelm@12281
   318
  "!!P Q. (ALL x. P & Q x)   = (P & (ALL x. Q x))"
wenzelm@12281
   319
  "!!P Q. (ALL x. P x | Q)   = ((ALL x. P x) | Q)"
wenzelm@12281
   320
  "!!P Q. (ALL x. P | Q x)   = (P | (ALL x. Q x))"
wenzelm@12281
   321
  "!!P Q. (ALL x. P x --> Q) = ((EX x. P x) --> Q)"
wenzelm@12281
   322
  "!!P Q. (ALL x. P --> Q x) = (P --> (ALL x. Q x))"
wenzelm@12281
   323
  -- {* Miniscoping: pushing in universal quantifiers. *}
wenzelm@12281
   324
  by blast+
wenzelm@12281
   325
wenzelm@12281
   326
lemma eq_ac:
wenzelm@12281
   327
 (eq_commute: "(a=b) = (b=a)" and
wenzelm@12281
   328
  eq_left_commute: "(P=(Q=R)) = (Q=(P=R))" and
wenzelm@12281
   329
  eq_assoc: "((P=Q)=R) = (P=(Q=R))") by blast+
wenzelm@12281
   330
lemma neq_commute: "(a~=b) = (b~=a)" by blast
wenzelm@12281
   331
wenzelm@12281
   332
lemma conj_comms:
wenzelm@12281
   333
 (conj_commute: "(P&Q) = (Q&P)" and
wenzelm@12281
   334
  conj_left_commute: "(P&(Q&R)) = (Q&(P&R))") by blast+
wenzelm@12281
   335
lemma conj_assoc: "((P&Q)&R) = (P&(Q&R))" by blast
wenzelm@12281
   336
wenzelm@12281
   337
lemma disj_comms:
wenzelm@12281
   338
 (disj_commute: "(P|Q) = (Q|P)" and
wenzelm@12281
   339
  disj_left_commute: "(P|(Q|R)) = (Q|(P|R))") by blast+
wenzelm@12281
   340
lemma disj_assoc: "((P|Q)|R) = (P|(Q|R))" by blast
wenzelm@12281
   341
wenzelm@12281
   342
lemma conj_disj_distribL: "(P&(Q|R)) = (P&Q | P&R)" by blast
wenzelm@12281
   343
lemma conj_disj_distribR: "((P|Q)&R) = (P&R | Q&R)" by blast
wenzelm@12281
   344
wenzelm@12281
   345
lemma disj_conj_distribL: "(P|(Q&R)) = ((P|Q) & (P|R))" by blast
wenzelm@12281
   346
lemma disj_conj_distribR: "((P&Q)|R) = ((P|R) & (Q|R))" by blast
wenzelm@12281
   347
wenzelm@12281
   348
lemma imp_conjR: "(P --> (Q&R)) = ((P-->Q) & (P-->R))" by blast
wenzelm@12281
   349
lemma imp_conjL: "((P&Q) -->R)  = (P --> (Q --> R))" by blast
wenzelm@12281
   350
lemma imp_disjL: "((P|Q) --> R) = ((P-->R)&(Q-->R))" by blast
wenzelm@12281
   351
wenzelm@12281
   352
text {* These two are specialized, but @{text imp_disj_not1} is useful in @{text "Auth/Yahalom"}. *}
wenzelm@12281
   353
lemma imp_disj_not1: "(P --> Q | R) = (~Q --> P --> R)" by blast
wenzelm@12281
   354
lemma imp_disj_not2: "(P --> Q | R) = (~R --> P --> Q)" by blast
wenzelm@12281
   355
wenzelm@12281
   356
lemma imp_disj1: "((P-->Q)|R) = (P--> Q|R)" by blast
wenzelm@12281
   357
lemma imp_disj2: "(Q|(P-->R)) = (P--> Q|R)" by blast
wenzelm@12281
   358
wenzelm@12281
   359
lemma de_Morgan_disj: "(~(P | Q)) = (~P & ~Q)" by blast
wenzelm@12281
   360
lemma de_Morgan_conj: "(~(P & Q)) = (~P | ~Q)" by blast
wenzelm@12281
   361
lemma not_imp: "(~(P --> Q)) = (P & ~Q)" by blast
wenzelm@12281
   362
lemma not_iff: "(P~=Q) = (P = (~Q))" by blast
wenzelm@12281
   363
lemma disj_not1: "(~P | Q) = (P --> Q)" by blast
wenzelm@12281
   364
lemma disj_not2: "(P | ~Q) = (Q --> P)"  -- {* changes orientation :-( *}
wenzelm@12281
   365
  by blast
wenzelm@12281
   366
lemma imp_conv_disj: "(P --> Q) = ((~P) | Q)" by blast
wenzelm@12281
   367
wenzelm@12281
   368
lemma iff_conv_conj_imp: "(P = Q) = ((P --> Q) & (Q --> P))" by blast
wenzelm@12281
   369
wenzelm@12281
   370
wenzelm@12281
   371
lemma cases_simp: "((P --> Q) & (~P --> Q)) = Q"
wenzelm@12281
   372
  -- {* Avoids duplication of subgoals after @{text split_if}, when the true and false *}
wenzelm@12281
   373
  -- {* cases boil down to the same thing. *}
wenzelm@12281
   374
  by blast
wenzelm@12281
   375
wenzelm@12281
   376
lemma not_all: "(~ (! x. P(x))) = (? x.~P(x))" by blast
wenzelm@12281
   377
lemma imp_all: "((! x. P x) --> Q) = (? x. P x --> Q)" by blast
wenzelm@12281
   378
lemma not_ex: "(~ (? x. P(x))) = (! x.~P(x))" by blast
wenzelm@12281
   379
lemma imp_ex: "((? x. P x) --> Q) = (! x. P x --> Q)" by blast
wenzelm@12281
   380
wenzelm@12281
   381
lemma ex_disj_distrib: "(? x. P(x) | Q(x)) = ((? x. P(x)) | (? x. Q(x)))" by blast
wenzelm@12281
   382
lemma all_conj_distrib: "(!x. P(x) & Q(x)) = ((! x. P(x)) & (! x. Q(x)))" by blast
wenzelm@12281
   383
wenzelm@12281
   384
text {*
wenzelm@12281
   385
  \medskip The @{text "&"} congruence rule: not included by default!
wenzelm@12281
   386
  May slow rewrite proofs down by as much as 50\% *}
wenzelm@12281
   387
wenzelm@12281
   388
lemma conj_cong:
wenzelm@12281
   389
    "(P = P') ==> (P' ==> (Q = Q')) ==> ((P & Q) = (P' & Q'))"
wenzelm@12281
   390
  by blast
wenzelm@12281
   391
wenzelm@12281
   392
lemma rev_conj_cong:
wenzelm@12281
   393
    "(Q = Q') ==> (Q' ==> (P = P')) ==> ((P & Q) = (P' & Q'))"
wenzelm@12281
   394
  by blast
wenzelm@12281
   395
wenzelm@12281
   396
text {* The @{text "|"} congruence rule: not included by default! *}
wenzelm@12281
   397
wenzelm@12281
   398
lemma disj_cong:
wenzelm@12281
   399
    "(P = P') ==> (~P' ==> (Q = Q')) ==> ((P | Q) = (P' | Q'))"
wenzelm@12281
   400
  by blast
wenzelm@12281
   401
wenzelm@12281
   402
lemma eq_sym_conv: "(x = y) = (y = x)"
wenzelm@12281
   403
  by blast
wenzelm@12281
   404
wenzelm@12281
   405
wenzelm@12281
   406
text {* \medskip if-then-else rules *}
wenzelm@12281
   407
wenzelm@12281
   408
lemma if_True: "(if True then x else y) = x"
wenzelm@12281
   409
  by (unfold if_def) blast
wenzelm@12281
   410
wenzelm@12281
   411
lemma if_False: "(if False then x else y) = y"
wenzelm@12281
   412
  by (unfold if_def) blast
wenzelm@12281
   413
wenzelm@12281
   414
lemma if_P: "P ==> (if P then x else y) = x"
wenzelm@12281
   415
  by (unfold if_def) blast
wenzelm@12281
   416
wenzelm@12281
   417
lemma if_not_P: "~P ==> (if P then x else y) = y"
wenzelm@12281
   418
  by (unfold if_def) blast
wenzelm@12281
   419
wenzelm@12281
   420
lemma split_if: "P (if Q then x else y) = ((Q --> P(x)) & (~Q --> P(y)))"
wenzelm@12281
   421
  apply (rule case_split [of Q])
wenzelm@12281
   422
   apply (subst if_P)
wenzelm@12281
   423
    prefer 3 apply (subst if_not_P)
wenzelm@12281
   424
     apply blast+
wenzelm@12281
   425
  done
wenzelm@12281
   426
wenzelm@12281
   427
lemma split_if_asm: "P (if Q then x else y) = (~((Q & ~P x) | (~Q & ~P y)))"
wenzelm@12281
   428
  apply (subst split_if)
wenzelm@12281
   429
  apply blast
wenzelm@12281
   430
  done
wenzelm@12281
   431
wenzelm@12281
   432
lemmas if_splits = split_if split_if_asm
wenzelm@12281
   433
wenzelm@12281
   434
lemma if_def2: "(if Q then x else y) = ((Q --> x) & (~ Q --> y))"
wenzelm@12281
   435
  by (rule split_if)
wenzelm@12281
   436
wenzelm@12281
   437
lemma if_cancel: "(if c then x else x) = x"
wenzelm@12281
   438
  apply (subst split_if)
wenzelm@12281
   439
  apply blast
wenzelm@12281
   440
  done
wenzelm@12281
   441
wenzelm@12281
   442
lemma if_eq_cancel: "(if x = y then y else x) = x"
wenzelm@12281
   443
  apply (subst split_if)
wenzelm@12281
   444
  apply blast
wenzelm@12281
   445
  done
wenzelm@12281
   446
wenzelm@12281
   447
lemma if_bool_eq_conj: "(if P then Q else R) = ((P-->Q) & (~P-->R))"
wenzelm@12281
   448
  -- {* This form is useful for expanding @{text if}s on the RIGHT of the @{text "==>"} symbol. *}
wenzelm@12281
   449
  by (rule split_if)
wenzelm@12281
   450
wenzelm@12281
   451
lemma if_bool_eq_disj: "(if P then Q else R) = ((P&Q) | (~P&R))"
wenzelm@12281
   452
  -- {* And this form is useful for expanding @{text if}s on the LEFT. *}
wenzelm@12281
   453
  apply (subst split_if)
wenzelm@12281
   454
  apply blast
wenzelm@12281
   455
  done
wenzelm@12281
   456
wenzelm@12281
   457
lemma Eq_TrueI: "P ==> P == True" by (unfold atomize_eq) blast
wenzelm@12281
   458
lemma Eq_FalseI: "~P ==> P == False" by (unfold atomize_eq) blast
wenzelm@12281
   459
wenzelm@9869
   460
use "simpdata.ML"
wenzelm@9869
   461
setup Simplifier.setup
wenzelm@9869
   462
setup "Simplifier.method_setup Splitter.split_modifiers" setup simpsetup
wenzelm@9869
   463
setup Splitter.setup setup Clasimp.setup
wenzelm@9869
   464
wenzelm@11750
   465
wenzelm@11824
   466
subsubsection {* Generic cases and induction *}
wenzelm@11824
   467
wenzelm@11824
   468
constdefs
wenzelm@11989
   469
  induct_forall :: "('a => bool) => bool"
wenzelm@11989
   470
  "induct_forall P == \<forall>x. P x"
wenzelm@11989
   471
  induct_implies :: "bool => bool => bool"
wenzelm@11989
   472
  "induct_implies A B == A --> B"
wenzelm@11989
   473
  induct_equal :: "'a => 'a => bool"
wenzelm@11989
   474
  "induct_equal x y == x = y"
wenzelm@11989
   475
  induct_conj :: "bool => bool => bool"
wenzelm@11989
   476
  "induct_conj A B == A & B"
wenzelm@11824
   477
wenzelm@11989
   478
lemma induct_forall_eq: "(!!x. P x) == Trueprop (induct_forall (\<lambda>x. P x))"
wenzelm@11989
   479
  by (simp only: atomize_all induct_forall_def)
wenzelm@11824
   480
wenzelm@11989
   481
lemma induct_implies_eq: "(A ==> B) == Trueprop (induct_implies A B)"
wenzelm@11989
   482
  by (simp only: atomize_imp induct_implies_def)
wenzelm@11824
   483
wenzelm@11989
   484
lemma induct_equal_eq: "(x == y) == Trueprop (induct_equal x y)"
wenzelm@11989
   485
  by (simp only: atomize_eq induct_equal_def)
wenzelm@11824
   486
wenzelm@11989
   487
lemma induct_forall_conj: "induct_forall (\<lambda>x. induct_conj (A x) (B x)) =
wenzelm@11989
   488
    induct_conj (induct_forall A) (induct_forall B)"
wenzelm@11989
   489
  by (unfold induct_forall_def induct_conj_def) blast
wenzelm@11824
   490
wenzelm@11989
   491
lemma induct_implies_conj: "induct_implies C (induct_conj A B) =
wenzelm@11989
   492
    induct_conj (induct_implies C A) (induct_implies C B)"
wenzelm@11989
   493
  by (unfold induct_implies_def induct_conj_def) blast
wenzelm@11989
   494
wenzelm@11989
   495
lemma induct_conj_curry: "(induct_conj A B ==> C) == (A ==> B ==> C)"
wenzelm@11989
   496
  by (simp only: atomize_imp atomize_eq induct_conj_def) (rule equal_intr_rule, blast+)
wenzelm@11824
   497
wenzelm@11989
   498
lemma induct_impliesI: "(A ==> B) ==> induct_implies A B"
wenzelm@11989
   499
  by (simp add: induct_implies_def)
wenzelm@11824
   500
wenzelm@12161
   501
lemmas induct_atomize = atomize_conj induct_forall_eq induct_implies_eq induct_equal_eq
wenzelm@12161
   502
lemmas induct_rulify1 [symmetric, standard] = induct_forall_eq induct_implies_eq induct_equal_eq
wenzelm@12161
   503
lemmas induct_rulify2 = induct_forall_def induct_implies_def induct_equal_def induct_conj_def
wenzelm@11989
   504
lemmas induct_conj = induct_forall_conj induct_implies_conj induct_conj_curry
wenzelm@11824
   505
wenzelm@11989
   506
hide const induct_forall induct_implies induct_equal induct_conj
wenzelm@11824
   507
wenzelm@11824
   508
wenzelm@11824
   509
text {* Method setup. *}
wenzelm@11824
   510
wenzelm@11824
   511
ML {*
wenzelm@11824
   512
  structure InductMethod = InductMethodFun
wenzelm@11824
   513
  (struct
wenzelm@11824
   514
    val dest_concls = HOLogic.dest_concls;
wenzelm@11824
   515
    val cases_default = thm "case_split";
wenzelm@11989
   516
    val local_impI = thm "induct_impliesI";
wenzelm@11824
   517
    val conjI = thm "conjI";
wenzelm@11989
   518
    val atomize = thms "induct_atomize";
wenzelm@11989
   519
    val rulify1 = thms "induct_rulify1";
wenzelm@11989
   520
    val rulify2 = thms "induct_rulify2";
wenzelm@12240
   521
    val localize = [Thm.symmetric (thm "induct_implies_def")];
wenzelm@11824
   522
  end);
wenzelm@11824
   523
*}
wenzelm@11824
   524
wenzelm@11824
   525
setup InductMethod.setup
wenzelm@11824
   526
wenzelm@11824
   527
wenzelm@11750
   528
subsection {* Order signatures and orders *}
wenzelm@11750
   529
wenzelm@11750
   530
axclass
wenzelm@11750
   531
  ord < "term"
wenzelm@11750
   532
wenzelm@11750
   533
syntax
wenzelm@11750
   534
  "op <"        :: "['a::ord, 'a] => bool"             ("op <")
wenzelm@11750
   535
  "op <="       :: "['a::ord, 'a] => bool"             ("op <=")
wenzelm@11750
   536
wenzelm@11750
   537
global
wenzelm@11750
   538
wenzelm@11750
   539
consts
wenzelm@11750
   540
  "op <"        :: "['a::ord, 'a] => bool"             ("(_/ < _)"  [50, 51] 50)
wenzelm@11750
   541
  "op <="       :: "['a::ord, 'a] => bool"             ("(_/ <= _)" [50, 51] 50)
wenzelm@11750
   542
wenzelm@11750
   543
local
wenzelm@11750
   544
wenzelm@12114
   545
syntax (xsymbols)
wenzelm@11750
   546
  "op <="       :: "['a::ord, 'a] => bool"             ("op \<le>")
wenzelm@11750
   547
  "op <="       :: "['a::ord, 'a] => bool"             ("(_/ \<le> _)"  [50, 51] 50)
wenzelm@11750
   548
wenzelm@11750
   549
(*Tell blast about overloading of < and <= to reduce the risk of
wenzelm@11750
   550
  its applying a rule for the wrong type*)
wenzelm@11750
   551
ML {*
wenzelm@11750
   552
Blast.overloaded ("op <" , domain_type);
wenzelm@11750
   553
Blast.overloaded ("op <=", domain_type);
wenzelm@11750
   554
*}
wenzelm@11750
   555
wenzelm@11750
   556
wenzelm@11750
   557
subsubsection {* Monotonicity *}
wenzelm@11750
   558
wenzelm@11750
   559
constdefs
wenzelm@11750
   560
  mono :: "['a::ord => 'b::ord] => bool"
wenzelm@11750
   561
  "mono f == ALL A B. A <= B --> f A <= f B"
wenzelm@11750
   562
wenzelm@11750
   563
lemma monoI [intro?]: "(!!A B. A <= B ==> f A <= f B) ==> mono f"
wenzelm@11750
   564
  by (unfold mono_def) blast
wenzelm@11750
   565
wenzelm@11750
   566
lemma monoD [dest?]: "mono f ==> A <= B ==> f A <= f B"
wenzelm@11750
   567
  by (unfold mono_def) blast
wenzelm@11750
   568
wenzelm@11750
   569
constdefs
wenzelm@11750
   570
  min :: "['a::ord, 'a] => 'a"
wenzelm@11750
   571
  "min a b == (if a <= b then a else b)"
wenzelm@11750
   572
  max :: "['a::ord, 'a] => 'a"
wenzelm@11750
   573
  "max a b == (if a <= b then b else a)"
wenzelm@11750
   574
wenzelm@11750
   575
lemma min_leastL: "(!!x. least <= x) ==> min least x = least"
wenzelm@11750
   576
  by (simp add: min_def)
wenzelm@11750
   577
wenzelm@11750
   578
lemma min_of_mono:
wenzelm@11750
   579
    "ALL x y. (f x <= f y) = (x <= y) ==> min (f m) (f n) = f (min m n)"
wenzelm@11750
   580
  by (simp add: min_def)
wenzelm@11750
   581
wenzelm@11750
   582
lemma max_leastL: "(!!x. least <= x) ==> max least x = x"
wenzelm@11750
   583
  by (simp add: max_def)
wenzelm@11750
   584
wenzelm@11750
   585
lemma max_of_mono:
wenzelm@11750
   586
    "ALL x y. (f x <= f y) = (x <= y) ==> max (f m) (f n) = f (max m n)"
wenzelm@11750
   587
  by (simp add: max_def)
wenzelm@11750
   588
wenzelm@11750
   589
wenzelm@11750
   590
subsubsection "Orders"
wenzelm@11750
   591
wenzelm@11750
   592
axclass order < ord
wenzelm@11750
   593
  order_refl [iff]: "x <= x"
wenzelm@11750
   594
  order_trans: "x <= y ==> y <= z ==> x <= z"
wenzelm@11750
   595
  order_antisym: "x <= y ==> y <= x ==> x = y"
wenzelm@11750
   596
  order_less_le: "(x < y) = (x <= y & x ~= y)"
wenzelm@11750
   597
wenzelm@11750
   598
wenzelm@11750
   599
text {* Reflexivity. *}
wenzelm@11750
   600
wenzelm@11750
   601
lemma order_eq_refl: "!!x::'a::order. x = y ==> x <= y"
wenzelm@11750
   602
    -- {* This form is useful with the classical reasoner. *}
wenzelm@11750
   603
  apply (erule ssubst)
wenzelm@11750
   604
  apply (rule order_refl)
wenzelm@11750
   605
  done
wenzelm@11750
   606
wenzelm@11750
   607
lemma order_less_irrefl [simp]: "~ x < (x::'a::order)"
wenzelm@11750
   608
  by (simp add: order_less_le)
wenzelm@11750
   609
wenzelm@11750
   610
lemma order_le_less: "((x::'a::order) <= y) = (x < y | x = y)"
wenzelm@11750
   611
    -- {* NOT suitable for iff, since it can cause PROOF FAILED. *}
wenzelm@11750
   612
  apply (simp add: order_less_le)
wenzelm@12256
   613
  apply blast
wenzelm@11750
   614
  done
wenzelm@11750
   615
wenzelm@11750
   616
lemmas order_le_imp_less_or_eq = order_le_less [THEN iffD1, standard]
wenzelm@11750
   617
wenzelm@11750
   618
lemma order_less_imp_le: "!!x::'a::order. x < y ==> x <= y"
wenzelm@11750
   619
  by (simp add: order_less_le)
wenzelm@11750
   620
wenzelm@11750
   621
wenzelm@11750
   622
text {* Asymmetry. *}
wenzelm@11750
   623
wenzelm@11750
   624
lemma order_less_not_sym: "(x::'a::order) < y ==> ~ (y < x)"
wenzelm@11750
   625
  by (simp add: order_less_le order_antisym)
wenzelm@11750
   626
wenzelm@11750
   627
lemma order_less_asym: "x < (y::'a::order) ==> (~P ==> y < x) ==> P"
wenzelm@11750
   628
  apply (drule order_less_not_sym)
wenzelm@11750
   629
  apply (erule contrapos_np)
wenzelm@11750
   630
  apply simp
wenzelm@11750
   631
  done
wenzelm@11750
   632
wenzelm@11750
   633
wenzelm@11750
   634
text {* Transitivity. *}
wenzelm@11750
   635
wenzelm@11750
   636
lemma order_less_trans: "!!x::'a::order. [| x < y; y < z |] ==> x < z"
wenzelm@11750
   637
  apply (simp add: order_less_le)
wenzelm@11750
   638
  apply (blast intro: order_trans order_antisym)
wenzelm@11750
   639
  done
wenzelm@11750
   640
wenzelm@11750
   641
lemma order_le_less_trans: "!!x::'a::order. [| x <= y; y < z |] ==> x < z"
wenzelm@11750
   642
  apply (simp add: order_less_le)
wenzelm@11750
   643
  apply (blast intro: order_trans order_antisym)
wenzelm@11750
   644
  done
wenzelm@11750
   645
wenzelm@11750
   646
lemma order_less_le_trans: "!!x::'a::order. [| x < y; y <= z |] ==> x < z"
wenzelm@11750
   647
  apply (simp add: order_less_le)
wenzelm@11750
   648
  apply (blast intro: order_trans order_antisym)
wenzelm@11750
   649
  done
wenzelm@11750
   650
wenzelm@11750
   651
wenzelm@11750
   652
text {* Useful for simplification, but too risky to include by default. *}
wenzelm@11750
   653
wenzelm@11750
   654
lemma order_less_imp_not_less: "(x::'a::order) < y ==>  (~ y < x) = True"
wenzelm@11750
   655
  by (blast elim: order_less_asym)
wenzelm@11750
   656
wenzelm@11750
   657
lemma order_less_imp_triv: "(x::'a::order) < y ==>  (y < x --> P) = True"
wenzelm@11750
   658
  by (blast elim: order_less_asym)
wenzelm@11750
   659
wenzelm@11750
   660
lemma order_less_imp_not_eq: "(x::'a::order) < y ==>  (x = y) = False"
wenzelm@11750
   661
  by auto
wenzelm@11750
   662
wenzelm@11750
   663
lemma order_less_imp_not_eq2: "(x::'a::order) < y ==>  (y = x) = False"
wenzelm@11750
   664
  by auto
wenzelm@11750
   665
wenzelm@11750
   666
wenzelm@11750
   667
text {* Other operators. *}
wenzelm@11750
   668
wenzelm@11750
   669
lemma min_leastR: "(!!x::'a::order. least <= x) ==> min x least = least"
wenzelm@11750
   670
  apply (simp add: min_def)
wenzelm@11750
   671
  apply (blast intro: order_antisym)
wenzelm@11750
   672
  done
wenzelm@11750
   673
wenzelm@11750
   674
lemma max_leastR: "(!!x::'a::order. least <= x) ==> max x least = x"
wenzelm@11750
   675
  apply (simp add: max_def)
wenzelm@11750
   676
  apply (blast intro: order_antisym)
wenzelm@11750
   677
  done
wenzelm@11750
   678
wenzelm@11750
   679
wenzelm@11750
   680
subsubsection {* Least value operator *}
wenzelm@11750
   681
wenzelm@11750
   682
constdefs
wenzelm@11750
   683
  Least :: "('a::ord => bool) => 'a"               (binder "LEAST " 10)
wenzelm@11750
   684
  "Least P == THE x. P x & (ALL y. P y --> x <= y)"
wenzelm@11750
   685
    -- {* We can no longer use LeastM because the latter requires Hilbert-AC. *}
wenzelm@11750
   686
wenzelm@11750
   687
lemma LeastI2:
wenzelm@11750
   688
  "[| P (x::'a::order);
wenzelm@11750
   689
      !!y. P y ==> x <= y;
wenzelm@11750
   690
      !!x. [| P x; ALL y. P y --> x \<le> y |] ==> Q x |]
wenzelm@12281
   691
   ==> Q (Least P)"
wenzelm@11750
   692
  apply (unfold Least_def)
wenzelm@11750
   693
  apply (rule theI2)
wenzelm@11750
   694
    apply (blast intro: order_antisym)+
wenzelm@11750
   695
  done
wenzelm@11750
   696
wenzelm@11750
   697
lemma Least_equality:
wenzelm@12281
   698
    "[| P (k::'a::order); !!x. P x ==> k <= x |] ==> (LEAST x. P x) = k"
wenzelm@11750
   699
  apply (simp add: Least_def)
wenzelm@11750
   700
  apply (rule the_equality)
wenzelm@11750
   701
  apply (auto intro!: order_antisym)
wenzelm@11750
   702
  done
wenzelm@11750
   703
wenzelm@11750
   704
wenzelm@11750
   705
subsubsection "Linear / total orders"
wenzelm@11750
   706
wenzelm@11750
   707
axclass linorder < order
wenzelm@11750
   708
  linorder_linear: "x <= y | y <= x"
wenzelm@11750
   709
wenzelm@11750
   710
lemma linorder_less_linear: "!!x::'a::linorder. x<y | x=y | y<x"
wenzelm@11750
   711
  apply (simp add: order_less_le)
wenzelm@11750
   712
  apply (insert linorder_linear)
wenzelm@11750
   713
  apply blast
wenzelm@11750
   714
  done
wenzelm@11750
   715
wenzelm@11750
   716
lemma linorder_cases [case_names less equal greater]:
wenzelm@11750
   717
    "((x::'a::linorder) < y ==> P) ==> (x = y ==> P) ==> (y < x ==> P) ==> P"
wenzelm@11750
   718
  apply (insert linorder_less_linear)
wenzelm@11750
   719
  apply blast
wenzelm@11750
   720
  done
wenzelm@11750
   721
wenzelm@11750
   722
lemma linorder_not_less: "!!x::'a::linorder. (~ x < y) = (y <= x)"
wenzelm@11750
   723
  apply (simp add: order_less_le)
wenzelm@11750
   724
  apply (insert linorder_linear)
wenzelm@11750
   725
  apply (blast intro: order_antisym)
wenzelm@11750
   726
  done
wenzelm@11750
   727
wenzelm@11750
   728
lemma linorder_not_le: "!!x::'a::linorder. (~ x <= y) = (y < x)"
wenzelm@11750
   729
  apply (simp add: order_less_le)
wenzelm@11750
   730
  apply (insert linorder_linear)
wenzelm@11750
   731
  apply (blast intro: order_antisym)
wenzelm@11750
   732
  done
wenzelm@11750
   733
wenzelm@11750
   734
lemma linorder_neq_iff: "!!x::'a::linorder. (x ~= y) = (x<y | y<x)"
wenzelm@11750
   735
  apply (cut_tac x = x and y = y in linorder_less_linear)
wenzelm@11750
   736
  apply auto
wenzelm@11750
   737
  done
wenzelm@11750
   738
wenzelm@11750
   739
lemma linorder_neqE: "x ~= (y::'a::linorder) ==> (x < y ==> R) ==> (y < x ==> R) ==> R"
wenzelm@11750
   740
  apply (simp add: linorder_neq_iff)
wenzelm@11750
   741
  apply blast
wenzelm@11750
   742
  done
wenzelm@11750
   743
wenzelm@11750
   744
wenzelm@11750
   745
subsubsection "Min and max on (linear) orders"
wenzelm@11750
   746
wenzelm@11750
   747
lemma min_same [simp]: "min (x::'a::order) x = x"
wenzelm@11750
   748
  by (simp add: min_def)
wenzelm@11750
   749
wenzelm@11750
   750
lemma max_same [simp]: "max (x::'a::order) x = x"
wenzelm@11750
   751
  by (simp add: max_def)
wenzelm@11750
   752
wenzelm@11750
   753
lemma le_max_iff_disj: "!!z::'a::linorder. (z <= max x y) = (z <= x | z <= y)"
wenzelm@11750
   754
  apply (simp add: max_def)
wenzelm@11750
   755
  apply (insert linorder_linear)
wenzelm@11750
   756
  apply (blast intro: order_trans)
wenzelm@11750
   757
  done
wenzelm@11750
   758
wenzelm@11750
   759
lemma le_maxI1: "(x::'a::linorder) <= max x y"
wenzelm@11750
   760
  by (simp add: le_max_iff_disj)
wenzelm@11750
   761
wenzelm@11750
   762
lemma le_maxI2: "(y::'a::linorder) <= max x y"
wenzelm@11750
   763
    -- {* CANNOT use with @{text "[intro!]"} because blast will give PROOF FAILED. *}
wenzelm@11750
   764
  by (simp add: le_max_iff_disj)
wenzelm@11750
   765
wenzelm@11750
   766
lemma less_max_iff_disj: "!!z::'a::linorder. (z < max x y) = (z < x | z < y)"
wenzelm@11750
   767
  apply (simp add: max_def order_le_less)
wenzelm@11750
   768
  apply (insert linorder_less_linear)
wenzelm@11750
   769
  apply (blast intro: order_less_trans)
wenzelm@11750
   770
  done
wenzelm@11750
   771
wenzelm@11750
   772
lemma max_le_iff_conj [simp]:
wenzelm@11750
   773
    "!!z::'a::linorder. (max x y <= z) = (x <= z & y <= z)"
wenzelm@11750
   774
  apply (simp add: max_def)
wenzelm@11750
   775
  apply (insert linorder_linear)
wenzelm@11750
   776
  apply (blast intro: order_trans)
wenzelm@11750
   777
  done
wenzelm@11750
   778
wenzelm@11750
   779
lemma max_less_iff_conj [simp]:
wenzelm@11750
   780
    "!!z::'a::linorder. (max x y < z) = (x < z & y < z)"
wenzelm@11750
   781
  apply (simp add: order_le_less max_def)
wenzelm@11750
   782
  apply (insert linorder_less_linear)
wenzelm@11750
   783
  apply (blast intro: order_less_trans)
wenzelm@11750
   784
  done
wenzelm@11750
   785
wenzelm@11750
   786
lemma le_min_iff_conj [simp]:
wenzelm@11750
   787
    "!!z::'a::linorder. (z <= min x y) = (z <= x & z <= y)"
wenzelm@11750
   788
    -- {* @{text "[iff]"} screws up a Q{text blast} in MiniML *}
wenzelm@11750
   789
  apply (simp add: min_def)
wenzelm@11750
   790
  apply (insert linorder_linear)
wenzelm@11750
   791
  apply (blast intro: order_trans)
wenzelm@11750
   792
  done
wenzelm@11750
   793
wenzelm@11750
   794
lemma min_less_iff_conj [simp]:
wenzelm@11750
   795
    "!!z::'a::linorder. (z < min x y) = (z < x & z < y)"
wenzelm@11750
   796
  apply (simp add: order_le_less min_def)
wenzelm@11750
   797
  apply (insert linorder_less_linear)
wenzelm@11750
   798
  apply (blast intro: order_less_trans)
wenzelm@11750
   799
  done
wenzelm@11750
   800
wenzelm@11750
   801
lemma min_le_iff_disj: "!!z::'a::linorder. (min x y <= z) = (x <= z | y <= z)"
wenzelm@11750
   802
  apply (simp add: min_def)
wenzelm@11750
   803
  apply (insert linorder_linear)
wenzelm@11750
   804
  apply (blast intro: order_trans)
wenzelm@11750
   805
  done
wenzelm@11750
   806
wenzelm@11750
   807
lemma min_less_iff_disj: "!!z::'a::linorder. (min x y < z) = (x < z | y < z)"
wenzelm@11750
   808
  apply (simp add: min_def order_le_less)
wenzelm@11750
   809
  apply (insert linorder_less_linear)
wenzelm@11750
   810
  apply (blast intro: order_less_trans)
wenzelm@11750
   811
  done
wenzelm@11750
   812
wenzelm@11750
   813
lemma split_min:
wenzelm@11750
   814
    "P (min (i::'a::linorder) j) = ((i <= j --> P(i)) & (~ i <= j --> P(j)))"
wenzelm@11750
   815
  by (simp add: min_def)
wenzelm@11750
   816
wenzelm@11750
   817
lemma split_max:
wenzelm@11750
   818
    "P (max (i::'a::linorder) j) = ((i <= j --> P(j)) & (~ i <= j --> P(i)))"
wenzelm@11750
   819
  by (simp add: max_def)
wenzelm@11750
   820
wenzelm@11750
   821
wenzelm@11750
   822
subsubsection "Bounded quantifiers"
wenzelm@11750
   823
wenzelm@11750
   824
syntax
wenzelm@11750
   825
  "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3ALL _<_./ _)"  [0, 0, 10] 10)
wenzelm@11750
   826
  "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3EX _<_./ _)"  [0, 0, 10] 10)
wenzelm@11750
   827
  "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3ALL _<=_./ _)" [0, 0, 10] 10)
wenzelm@11750
   828
  "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3EX _<=_./ _)" [0, 0, 10] 10)
wenzelm@11750
   829
wenzelm@12114
   830
syntax (xsymbols)
wenzelm@11750
   831
  "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_<_./ _)"  [0, 0, 10] 10)
wenzelm@11750
   832
  "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_<_./ _)"  [0, 0, 10] 10)
wenzelm@11750
   833
  "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10)
wenzelm@11750
   834
  "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10)
wenzelm@11750
   835
wenzelm@11750
   836
syntax (HOL)
wenzelm@11750
   837
  "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3! _<_./ _)"  [0, 0, 10] 10)
wenzelm@11750
   838
  "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3? _<_./ _)"  [0, 0, 10] 10)
wenzelm@11750
   839
  "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3! _<=_./ _)" [0, 0, 10] 10)
wenzelm@11750
   840
  "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3? _<=_./ _)" [0, 0, 10] 10)
wenzelm@11750
   841
wenzelm@11750
   842
translations
wenzelm@11750
   843
 "ALL x<y. P"   =>  "ALL x. x < y --> P"
wenzelm@11750
   844
 "EX x<y. P"    =>  "EX x. x < y  & P"
wenzelm@11750
   845
 "ALL x<=y. P"  =>  "ALL x. x <= y --> P"
wenzelm@11750
   846
 "EX x<=y. P"   =>  "EX x. x <= y & P"
wenzelm@11750
   847
clasohm@923
   848
end