src/HOL/HOL.thy
author kleing
Mon Jun 21 10:25:57 2004 +0200 (2004-06-21)
changeset 14981 e73f8140af78
parent 14854 61bdf2ae4dc5
child 15079 2ef899e4526d
permissions -rw-r--r--
Merged in license change from Isabelle2004
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@14854
    16
classes type
wenzelm@12338
    17
defaultsort type
wenzelm@3947
    18
wenzelm@12338
    19
global
clasohm@923
    20
wenzelm@7357
    21
typedecl bool
clasohm@923
    22
clasohm@923
    23
arities
wenzelm@12338
    24
  bool :: type
wenzelm@12338
    25
  fun :: (type, type) type
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@12650
    58
  "_not_equal"  :: "['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)"
nipkow@13764
    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
nipkow@13763
    77
print_translation {*
nipkow@13763
    78
(* To avoid eta-contraction of body: *)
nipkow@13763
    79
[("The", fn [Abs abs] =>
nipkow@13763
    80
     let val (x,t) = atomic_abs_tr' abs
nipkow@13763
    81
     in Syntax.const "_The" $ x $ t end)]
nipkow@13763
    82
*}
nipkow@13763
    83
wenzelm@12633
    84
syntax (output)
wenzelm@11687
    85
  "="           :: "['a, 'a] => bool"                    (infix 50)
wenzelm@12650
    86
  "_not_equal"  :: "['a, 'a] => bool"                    (infix "~=" 50)
wenzelm@2260
    87
wenzelm@12114
    88
syntax (xsymbols)
wenzelm@11687
    89
  Not           :: "bool => bool"                        ("\<not> _" [40] 40)
wenzelm@11687
    90
  "op &"        :: "[bool, bool] => bool"                (infixr "\<and>" 35)
wenzelm@11687
    91
  "op |"        :: "[bool, bool] => bool"                (infixr "\<or>" 30)
wenzelm@12114
    92
  "op -->"      :: "[bool, bool] => bool"                (infixr "\<longrightarrow>" 25)
wenzelm@12650
    93
  "_not_equal"  :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
wenzelm@11687
    94
  "ALL "        :: "[idts, bool] => bool"                ("(3\<forall>_./ _)" [0, 10] 10)
wenzelm@11687
    95
  "EX "         :: "[idts, bool] => bool"                ("(3\<exists>_./ _)" [0, 10] 10)
wenzelm@11687
    96
  "EX! "        :: "[idts, bool] => bool"                ("(3\<exists>!_./ _)" [0, 10] 10)
wenzelm@11687
    97
  "_case1"      :: "['a, 'b] => case_syn"                ("(2_ \<Rightarrow>/ _)" 10)
schirmer@14361
    98
(*"_case2"      :: "[case_syn, cases_syn] => cases_syn"  ("_/ \<orelse> _")*)
wenzelm@2372
    99
wenzelm@12114
   100
syntax (xsymbols output)
wenzelm@12650
   101
  "_not_equal"  :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
wenzelm@3820
   102
wenzelm@6340
   103
syntax (HTML output)
kleing@14565
   104
  "_not_equal"  :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
wenzelm@11687
   105
  Not           :: "bool => bool"                        ("\<not> _" [40] 40)
kleing@14565
   106
  "op &"        :: "[bool, bool] => bool"                (infixr "\<and>" 35)
kleing@14565
   107
  "op |"        :: "[bool, bool] => bool"                (infixr "\<or>" 30)
kleing@14565
   108
  "_not_equal"  :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
kleing@14565
   109
  "ALL "        :: "[idts, bool] => bool"                ("(3\<forall>_./ _)" [0, 10] 10)
kleing@14565
   110
  "EX "         :: "[idts, bool] => bool"                ("(3\<exists>_./ _)" [0, 10] 10)
kleing@14565
   111
  "EX! "        :: "[idts, bool] => bool"                ("(3\<exists>!_./ _)" [0, 10] 10)
wenzelm@6340
   112
wenzelm@7238
   113
syntax (HOL)
wenzelm@7357
   114
  "ALL "        :: "[idts, bool] => bool"                ("(3! _./ _)" [0, 10] 10)
wenzelm@7357
   115
  "EX "         :: "[idts, bool] => bool"                ("(3? _./ _)" [0, 10] 10)
wenzelm@7357
   116
  "EX! "        :: "[idts, bool] => bool"                ("(3?! _./ _)" [0, 10] 10)
wenzelm@7238
   117
wenzelm@7238
   118
wenzelm@11750
   119
subsubsection {* Axioms and basic definitions *}
wenzelm@2260
   120
wenzelm@7357
   121
axioms
wenzelm@7357
   122
  eq_reflection: "(x=y) ==> (x==y)"
clasohm@923
   123
wenzelm@7357
   124
  refl:         "t = (t::'a)"
wenzelm@7357
   125
  subst:        "[| s = t; P(s) |] ==> P(t::'a)"
paulson@6289
   126
wenzelm@7357
   127
  ext:          "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)"
wenzelm@11750
   128
    -- {* Extensionality is built into the meta-logic, and this rule expresses *}
wenzelm@11750
   129
    -- {* a related property.  It is an eta-expanded version of the traditional *}
wenzelm@11750
   130
    -- {* rule, and similar to the ABS rule of HOL *}
paulson@6289
   131
wenzelm@11432
   132
  the_eq_trivial: "(THE x. x = a) = (a::'a)"
clasohm@923
   133
wenzelm@7357
   134
  impI:         "(P ==> Q) ==> P-->Q"
wenzelm@7357
   135
  mp:           "[| P-->Q;  P |] ==> Q"
clasohm@923
   136
clasohm@923
   137
defs
wenzelm@7357
   138
  True_def:     "True      == ((%x::bool. x) = (%x. x))"
wenzelm@7357
   139
  All_def:      "All(P)    == (P = (%x. True))"
paulson@11451
   140
  Ex_def:       "Ex(P)     == !Q. (!x. P x --> Q) --> Q"
wenzelm@7357
   141
  False_def:    "False     == (!P. P)"
wenzelm@7357
   142
  not_def:      "~ P       == P-->False"
wenzelm@7357
   143
  and_def:      "P & Q     == !R. (P-->Q-->R) --> R"
wenzelm@7357
   144
  or_def:       "P | Q     == !R. (P-->R) --> (Q-->R) --> R"
wenzelm@7357
   145
  Ex1_def:      "Ex1(P)    == ? x. P(x) & (! y. P(y) --> y=x)"
clasohm@923
   146
wenzelm@7357
   147
axioms
wenzelm@7357
   148
  iff:          "(P-->Q) --> (Q-->P) --> (P=Q)"
wenzelm@7357
   149
  True_or_False:  "(P=True) | (P=False)"
clasohm@923
   150
clasohm@923
   151
defs
wenzelm@7357
   152
  Let_def:      "Let s f == f(s)"
paulson@11451
   153
  if_def:       "If P x y == THE z::'a. (P=True --> z=x) & (P=False --> z=y)"
wenzelm@5069
   154
skalberg@14223
   155
finalconsts
skalberg@14223
   156
  "op ="
skalberg@14223
   157
  "op -->"
skalberg@14223
   158
  The
skalberg@14223
   159
  arbitrary
nipkow@3320
   160
wenzelm@11750
   161
subsubsection {* Generic algebraic operations *}
wenzelm@4868
   162
wenzelm@12338
   163
axclass zero < type
wenzelm@12338
   164
axclass one < type
wenzelm@12338
   165
axclass plus < type
wenzelm@12338
   166
axclass minus < type
wenzelm@12338
   167
axclass times < type
wenzelm@12338
   168
axclass inverse < type
wenzelm@11750
   169
wenzelm@11750
   170
global
wenzelm@11750
   171
wenzelm@11750
   172
consts
wenzelm@11750
   173
  "0"           :: "'a::zero"                       ("0")
wenzelm@11750
   174
  "1"           :: "'a::one"                        ("1")
wenzelm@11750
   175
  "+"           :: "['a::plus, 'a]  => 'a"          (infixl 65)
wenzelm@11750
   176
  -             :: "['a::minus, 'a] => 'a"          (infixl 65)
wenzelm@11750
   177
  uminus        :: "['a::minus] => 'a"              ("- _" [81] 80)
wenzelm@11750
   178
  *             :: "['a::times, 'a] => 'a"          (infixl 70)
wenzelm@11750
   179
wenzelm@13456
   180
syntax
wenzelm@13456
   181
  "_index1"  :: index    ("\<^sub>1")
wenzelm@13456
   182
translations
wenzelm@14690
   183
  (index) "\<^sub>1" => (index) "\<^bsub>\<struct>\<^esub>"
wenzelm@13456
   184
wenzelm@11750
   185
local
wenzelm@11750
   186
wenzelm@11750
   187
typed_print_translation {*
wenzelm@11750
   188
  let
wenzelm@11750
   189
    fun tr' c = (c, fn show_sorts => fn T => fn ts =>
wenzelm@11750
   190
      if T = dummyT orelse not (! show_types) andalso can Term.dest_Type T then raise Match
wenzelm@11750
   191
      else Syntax.const Syntax.constrainC $ Syntax.const c $ Syntax.term_of_typ show_sorts T);
wenzelm@11750
   192
  in [tr' "0", tr' "1"] end;
wenzelm@11750
   193
*} -- {* show types that are presumably too general *}
wenzelm@11750
   194
wenzelm@11750
   195
wenzelm@11750
   196
consts
wenzelm@11750
   197
  abs           :: "'a::minus => 'a"
wenzelm@11750
   198
  inverse       :: "'a::inverse => 'a"
wenzelm@11750
   199
  divide        :: "['a::inverse, 'a] => 'a"        (infixl "'/" 70)
wenzelm@11750
   200
wenzelm@11750
   201
syntax (xsymbols)
wenzelm@11750
   202
  abs :: "'a::minus => 'a"    ("\<bar>_\<bar>")
wenzelm@11750
   203
syntax (HTML output)
wenzelm@11750
   204
  abs :: "'a::minus => 'a"    ("\<bar>_\<bar>")
wenzelm@11750
   205
wenzelm@11750
   206
wenzelm@11750
   207
subsection {* Theory and package setup *}
wenzelm@11750
   208
wenzelm@11750
   209
subsubsection {* Basic lemmas *}
wenzelm@4868
   210
nipkow@9736
   211
use "HOL_lemmas.ML"
wenzelm@11687
   212
theorems case_split = case_split_thm [case_names True False]
wenzelm@9869
   213
wenzelm@12386
   214
wenzelm@12386
   215
subsubsection {* Intuitionistic Reasoning *}
wenzelm@12386
   216
wenzelm@12386
   217
lemma impE':
wenzelm@12937
   218
  assumes 1: "P --> Q"
wenzelm@12937
   219
    and 2: "Q ==> R"
wenzelm@12937
   220
    and 3: "P --> Q ==> P"
wenzelm@12937
   221
  shows R
wenzelm@12386
   222
proof -
wenzelm@12386
   223
  from 3 and 1 have P .
wenzelm@12386
   224
  with 1 have Q by (rule impE)
wenzelm@12386
   225
  with 2 show R .
wenzelm@12386
   226
qed
wenzelm@12386
   227
wenzelm@12386
   228
lemma allE':
wenzelm@12937
   229
  assumes 1: "ALL x. P x"
wenzelm@12937
   230
    and 2: "P x ==> ALL x. P x ==> Q"
wenzelm@12937
   231
  shows Q
wenzelm@12386
   232
proof -
wenzelm@12386
   233
  from 1 have "P x" by (rule spec)
wenzelm@12386
   234
  from this and 1 show Q by (rule 2)
wenzelm@12386
   235
qed
wenzelm@12386
   236
wenzelm@12937
   237
lemma notE':
wenzelm@12937
   238
  assumes 1: "~ P"
wenzelm@12937
   239
    and 2: "~ P ==> P"
wenzelm@12937
   240
  shows R
wenzelm@12386
   241
proof -
wenzelm@12386
   242
  from 2 and 1 have P .
wenzelm@12386
   243
  with 1 show R by (rule notE)
wenzelm@12386
   244
qed
wenzelm@12386
   245
wenzelm@12386
   246
lemmas [CPure.elim!] = disjE iffE FalseE conjE exE
wenzelm@12386
   247
  and [CPure.intro!] = iffI conjI impI TrueI notI allI refl
wenzelm@12386
   248
  and [CPure.elim 2] = allE notE' impE'
wenzelm@12386
   249
  and [CPure.intro] = exI disjI2 disjI1
wenzelm@12386
   250
wenzelm@12386
   251
lemmas [trans] = trans
wenzelm@12386
   252
  and [sym] = sym not_sym
wenzelm@12386
   253
  and [CPure.elim?] = iffD1 iffD2 impE
wenzelm@11750
   254
wenzelm@11438
   255
wenzelm@11750
   256
subsubsection {* Atomizing meta-level connectives *}
wenzelm@11750
   257
wenzelm@11750
   258
lemma atomize_all [atomize]: "(!!x. P x) == Trueprop (ALL x. P x)"
wenzelm@12003
   259
proof
wenzelm@9488
   260
  assume "!!x. P x"
wenzelm@10383
   261
  show "ALL x. P x" by (rule allI)
wenzelm@9488
   262
next
wenzelm@9488
   263
  assume "ALL x. P x"
wenzelm@10383
   264
  thus "!!x. P x" by (rule allE)
wenzelm@9488
   265
qed
wenzelm@9488
   266
wenzelm@11750
   267
lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A --> B)"
wenzelm@12003
   268
proof
wenzelm@9488
   269
  assume r: "A ==> B"
wenzelm@10383
   270
  show "A --> B" by (rule impI) (rule r)
wenzelm@9488
   271
next
wenzelm@9488
   272
  assume "A --> B" and A
wenzelm@10383
   273
  thus B by (rule mp)
wenzelm@9488
   274
qed
wenzelm@9488
   275
paulson@14749
   276
lemma atomize_not: "(A ==> False) == Trueprop (~A)"
paulson@14749
   277
proof
paulson@14749
   278
  assume r: "A ==> False"
paulson@14749
   279
  show "~A" by (rule notI) (rule r)
paulson@14749
   280
next
paulson@14749
   281
  assume "~A" and A
paulson@14749
   282
  thus False by (rule notE)
paulson@14749
   283
qed
paulson@14749
   284
wenzelm@11750
   285
lemma atomize_eq [atomize]: "(x == y) == Trueprop (x = y)"
wenzelm@12003
   286
proof
wenzelm@10432
   287
  assume "x == y"
wenzelm@10432
   288
  show "x = y" by (unfold prems) (rule refl)
wenzelm@10432
   289
next
wenzelm@10432
   290
  assume "x = y"
wenzelm@10432
   291
  thus "x == y" by (rule eq_reflection)
wenzelm@10432
   292
qed
wenzelm@10432
   293
wenzelm@12023
   294
lemma atomize_conj [atomize]:
wenzelm@12023
   295
  "(!!C. (A ==> B ==> PROP C) ==> PROP C) == Trueprop (A & B)"
wenzelm@12003
   296
proof
wenzelm@11953
   297
  assume "!!C. (A ==> B ==> PROP C) ==> PROP C"
wenzelm@11953
   298
  show "A & B" by (rule conjI)
wenzelm@11953
   299
next
wenzelm@11953
   300
  fix C
wenzelm@11953
   301
  assume "A & B"
wenzelm@11953
   302
  assume "A ==> B ==> PROP C"
wenzelm@11953
   303
  thus "PROP C"
wenzelm@11953
   304
  proof this
wenzelm@11953
   305
    show A by (rule conjunct1)
wenzelm@11953
   306
    show B by (rule conjunct2)
wenzelm@11953
   307
  qed
wenzelm@11953
   308
qed
wenzelm@11953
   309
wenzelm@12386
   310
lemmas [symmetric, rulify] = atomize_all atomize_imp
wenzelm@12386
   311
wenzelm@11750
   312
wenzelm@11750
   313
subsubsection {* Classical Reasoner setup *}
wenzelm@9529
   314
wenzelm@10383
   315
use "cladata.ML"
wenzelm@10383
   316
setup hypsubst_setup
wenzelm@11977
   317
wenzelm@12386
   318
ML_setup {*
wenzelm@12386
   319
  Context.>> (ContextRules.addSWrapper (fn tac => hyp_subst_tac' ORELSE' tac));
wenzelm@12386
   320
*}
wenzelm@11977
   321
wenzelm@10383
   322
setup Classical.setup
wenzelm@10383
   323
setup clasetup
wenzelm@10383
   324
wenzelm@12386
   325
lemmas [intro?] = ext
wenzelm@12386
   326
  and [elim?] = ex1_implies_ex
wenzelm@11977
   327
wenzelm@9869
   328
use "blastdata.ML"
wenzelm@9869
   329
setup Blast.setup
wenzelm@4868
   330
wenzelm@11750
   331
wenzelm@11750
   332
subsubsection {* Simplifier setup *}
wenzelm@11750
   333
wenzelm@12281
   334
lemma meta_eq_to_obj_eq: "x == y ==> x = y"
wenzelm@12281
   335
proof -
wenzelm@12281
   336
  assume r: "x == y"
wenzelm@12281
   337
  show "x = y" by (unfold r) (rule refl)
wenzelm@12281
   338
qed
wenzelm@12281
   339
wenzelm@12281
   340
lemma eta_contract_eq: "(%s. f s) = f" ..
wenzelm@12281
   341
wenzelm@12281
   342
lemma simp_thms:
wenzelm@12937
   343
  shows not_not: "(~ ~ P) = P"
wenzelm@12937
   344
  and
berghofe@12436
   345
    "(P ~= Q) = (P = (~Q))"
berghofe@12436
   346
    "(P | ~P) = True"    "(~P | P) = True"
berghofe@12436
   347
    "((~P) = (~Q)) = (P=Q)"
wenzelm@12281
   348
    "(x = x) = True"
wenzelm@12281
   349
    "(~True) = False"  "(~False) = True"
berghofe@12436
   350
    "(~P) ~= P"  "P ~= (~P)"
wenzelm@12281
   351
    "(True=P) = P"  "(P=True) = P"  "(False=P) = (~P)"  "(P=False) = (~P)"
wenzelm@12281
   352
    "(True --> P) = P"  "(False --> P) = True"
wenzelm@12281
   353
    "(P --> True) = True"  "(P --> P) = True"
wenzelm@12281
   354
    "(P --> False) = (~P)"  "(P --> ~P) = (~P)"
wenzelm@12281
   355
    "(P & True) = P"  "(True & P) = P"
wenzelm@12281
   356
    "(P & False) = False"  "(False & P) = False"
wenzelm@12281
   357
    "(P & P) = P"  "(P & (P & Q)) = (P & Q)"
wenzelm@12281
   358
    "(P & ~P) = False"    "(~P & P) = False"
wenzelm@12281
   359
    "(P | True) = True"  "(True | P) = True"
wenzelm@12281
   360
    "(P | False) = P"  "(False | P) = P"
berghofe@12436
   361
    "(P | P) = P"  "(P | (P | Q)) = (P | Q)" and
wenzelm@12281
   362
    "(ALL x. P) = P"  "(EX x. P) = P"  "EX x. x=t"  "EX x. t=x"
wenzelm@12281
   363
    -- {* needed for the one-point-rule quantifier simplification procs *}
wenzelm@12281
   364
    -- {* essential for termination!! *} and
wenzelm@12281
   365
    "!!P. (EX x. x=t & P(x)) = P(t)"
wenzelm@12281
   366
    "!!P. (EX x. t=x & P(x)) = P(t)"
wenzelm@12281
   367
    "!!P. (ALL x. x=t --> P(x)) = P(t)"
wenzelm@12937
   368
    "!!P. (ALL x. t=x --> P(x)) = P(t)"
berghofe@12436
   369
  by (blast, blast, blast, blast, blast, rules+)
wenzelm@13421
   370
wenzelm@12281
   371
lemma imp_cong: "(P = P') ==> (P' ==> (Q = Q')) ==> ((P --> Q) = (P' --> Q'))"
wenzelm@12354
   372
  by rules
wenzelm@12281
   373
wenzelm@12281
   374
lemma ex_simps:
wenzelm@12281
   375
  "!!P Q. (EX x. P x & Q)   = ((EX x. P x) & Q)"
wenzelm@12281
   376
  "!!P Q. (EX x. P & Q x)   = (P & (EX x. Q x))"
wenzelm@12281
   377
  "!!P Q. (EX x. P x | Q)   = ((EX x. P x) | Q)"
wenzelm@12281
   378
  "!!P Q. (EX x. P | Q x)   = (P | (EX x. Q x))"
wenzelm@12281
   379
  "!!P Q. (EX x. P x --> Q) = ((ALL x. P x) --> Q)"
wenzelm@12281
   380
  "!!P Q. (EX x. P --> Q x) = (P --> (EX x. Q x))"
wenzelm@12281
   381
  -- {* Miniscoping: pushing in existential quantifiers. *}
berghofe@12436
   382
  by (rules | blast)+
wenzelm@12281
   383
wenzelm@12281
   384
lemma all_simps:
wenzelm@12281
   385
  "!!P Q. (ALL x. P x & Q)   = ((ALL x. P x) & Q)"
wenzelm@12281
   386
  "!!P Q. (ALL x. P & Q x)   = (P & (ALL x. Q x))"
wenzelm@12281
   387
  "!!P Q. (ALL x. P x | Q)   = ((ALL x. P x) | Q)"
wenzelm@12281
   388
  "!!P Q. (ALL x. P | Q x)   = (P | (ALL x. Q x))"
wenzelm@12281
   389
  "!!P Q. (ALL x. P x --> Q) = ((EX x. P x) --> Q)"
wenzelm@12281
   390
  "!!P Q. (ALL x. P --> Q x) = (P --> (ALL x. Q x))"
wenzelm@12281
   391
  -- {* Miniscoping: pushing in universal quantifiers. *}
berghofe@12436
   392
  by (rules | blast)+
wenzelm@12281
   393
paulson@14201
   394
lemma disj_absorb: "(A | A) = A"
paulson@14201
   395
  by blast
paulson@14201
   396
paulson@14201
   397
lemma disj_left_absorb: "(A | (A | B)) = (A | B)"
paulson@14201
   398
  by blast
paulson@14201
   399
paulson@14201
   400
lemma conj_absorb: "(A & A) = A"
paulson@14201
   401
  by blast
paulson@14201
   402
paulson@14201
   403
lemma conj_left_absorb: "(A & (A & B)) = (A & B)"
paulson@14201
   404
  by blast
paulson@14201
   405
wenzelm@12281
   406
lemma eq_ac:
wenzelm@12937
   407
  shows eq_commute: "(a=b) = (b=a)"
wenzelm@12937
   408
    and eq_left_commute: "(P=(Q=R)) = (Q=(P=R))"
wenzelm@12937
   409
    and eq_assoc: "((P=Q)=R) = (P=(Q=R))" by (rules, blast+)
berghofe@12436
   410
lemma neq_commute: "(a~=b) = (b~=a)" by rules
wenzelm@12281
   411
wenzelm@12281
   412
lemma conj_comms:
wenzelm@12937
   413
  shows conj_commute: "(P&Q) = (Q&P)"
wenzelm@12937
   414
    and conj_left_commute: "(P&(Q&R)) = (Q&(P&R))" by rules+
berghofe@12436
   415
lemma conj_assoc: "((P&Q)&R) = (P&(Q&R))" by rules
wenzelm@12281
   416
wenzelm@12281
   417
lemma disj_comms:
wenzelm@12937
   418
  shows disj_commute: "(P|Q) = (Q|P)"
wenzelm@12937
   419
    and disj_left_commute: "(P|(Q|R)) = (Q|(P|R))" by rules+
berghofe@12436
   420
lemma disj_assoc: "((P|Q)|R) = (P|(Q|R))" by rules
wenzelm@12281
   421
berghofe@12436
   422
lemma conj_disj_distribL: "(P&(Q|R)) = (P&Q | P&R)" by rules
berghofe@12436
   423
lemma conj_disj_distribR: "((P|Q)&R) = (P&R | Q&R)" by rules
wenzelm@12281
   424
berghofe@12436
   425
lemma disj_conj_distribL: "(P|(Q&R)) = ((P|Q) & (P|R))" by rules
berghofe@12436
   426
lemma disj_conj_distribR: "((P&Q)|R) = ((P|R) & (Q|R))" by rules
wenzelm@12281
   427
berghofe@12436
   428
lemma imp_conjR: "(P --> (Q&R)) = ((P-->Q) & (P-->R))" by rules
berghofe@12436
   429
lemma imp_conjL: "((P&Q) -->R)  = (P --> (Q --> R))" by rules
berghofe@12436
   430
lemma imp_disjL: "((P|Q) --> R) = ((P-->R)&(Q-->R))" by rules
wenzelm@12281
   431
wenzelm@12281
   432
text {* These two are specialized, but @{text imp_disj_not1} is useful in @{text "Auth/Yahalom"}. *}
wenzelm@12281
   433
lemma imp_disj_not1: "(P --> Q | R) = (~Q --> P --> R)" by blast
wenzelm@12281
   434
lemma imp_disj_not2: "(P --> Q | R) = (~R --> P --> Q)" by blast
wenzelm@12281
   435
wenzelm@12281
   436
lemma imp_disj1: "((P-->Q)|R) = (P--> Q|R)" by blast
wenzelm@12281
   437
lemma imp_disj2: "(Q|(P-->R)) = (P--> Q|R)" by blast
wenzelm@12281
   438
berghofe@12436
   439
lemma de_Morgan_disj: "(~(P | Q)) = (~P & ~Q)" by rules
wenzelm@12281
   440
lemma de_Morgan_conj: "(~(P & Q)) = (~P | ~Q)" by blast
wenzelm@12281
   441
lemma not_imp: "(~(P --> Q)) = (P & ~Q)" by blast
wenzelm@12281
   442
lemma not_iff: "(P~=Q) = (P = (~Q))" by blast
wenzelm@12281
   443
lemma disj_not1: "(~P | Q) = (P --> Q)" by blast
wenzelm@12281
   444
lemma disj_not2: "(P | ~Q) = (Q --> P)"  -- {* changes orientation :-( *}
wenzelm@12281
   445
  by blast
wenzelm@12281
   446
lemma imp_conv_disj: "(P --> Q) = ((~P) | Q)" by blast
wenzelm@12281
   447
berghofe@12436
   448
lemma iff_conv_conj_imp: "(P = Q) = ((P --> Q) & (Q --> P))" by rules
wenzelm@12281
   449
wenzelm@12281
   450
wenzelm@12281
   451
lemma cases_simp: "((P --> Q) & (~P --> Q)) = Q"
wenzelm@12281
   452
  -- {* Avoids duplication of subgoals after @{text split_if}, when the true and false *}
wenzelm@12281
   453
  -- {* cases boil down to the same thing. *}
wenzelm@12281
   454
  by blast
wenzelm@12281
   455
wenzelm@12281
   456
lemma not_all: "(~ (! x. P(x))) = (? x.~P(x))" by blast
wenzelm@12281
   457
lemma imp_all: "((! x. P x) --> Q) = (? x. P x --> Q)" by blast
berghofe@12436
   458
lemma not_ex: "(~ (? x. P(x))) = (! x.~P(x))" by rules
berghofe@12436
   459
lemma imp_ex: "((? x. P x) --> Q) = (! x. P x --> Q)" by rules
wenzelm@12281
   460
berghofe@12436
   461
lemma ex_disj_distrib: "(? x. P(x) | Q(x)) = ((? x. P(x)) | (? x. Q(x)))" by rules
berghofe@12436
   462
lemma all_conj_distrib: "(!x. P(x) & Q(x)) = ((! x. P(x)) & (! x. Q(x)))" by rules
wenzelm@12281
   463
wenzelm@12281
   464
text {*
wenzelm@12281
   465
  \medskip The @{text "&"} congruence rule: not included by default!
wenzelm@12281
   466
  May slow rewrite proofs down by as much as 50\% *}
wenzelm@12281
   467
wenzelm@12281
   468
lemma conj_cong:
wenzelm@12281
   469
    "(P = P') ==> (P' ==> (Q = Q')) ==> ((P & Q) = (P' & Q'))"
wenzelm@12354
   470
  by rules
wenzelm@12281
   471
wenzelm@12281
   472
lemma rev_conj_cong:
wenzelm@12281
   473
    "(Q = Q') ==> (Q' ==> (P = P')) ==> ((P & Q) = (P' & Q'))"
wenzelm@12354
   474
  by rules
wenzelm@12281
   475
wenzelm@12281
   476
text {* The @{text "|"} congruence rule: not included by default! *}
wenzelm@12281
   477
wenzelm@12281
   478
lemma disj_cong:
wenzelm@12281
   479
    "(P = P') ==> (~P' ==> (Q = Q')) ==> ((P | Q) = (P' | Q'))"
wenzelm@12281
   480
  by blast
wenzelm@12281
   481
wenzelm@12281
   482
lemma eq_sym_conv: "(x = y) = (y = x)"
wenzelm@12354
   483
  by rules
wenzelm@12281
   484
wenzelm@12281
   485
wenzelm@12281
   486
text {* \medskip if-then-else rules *}
wenzelm@12281
   487
wenzelm@12281
   488
lemma if_True: "(if True then x else y) = x"
wenzelm@12281
   489
  by (unfold if_def) blast
wenzelm@12281
   490
wenzelm@12281
   491
lemma if_False: "(if False then x else y) = y"
wenzelm@12281
   492
  by (unfold if_def) blast
wenzelm@12281
   493
wenzelm@12281
   494
lemma if_P: "P ==> (if P then x else y) = x"
wenzelm@12281
   495
  by (unfold if_def) blast
wenzelm@12281
   496
wenzelm@12281
   497
lemma if_not_P: "~P ==> (if P then x else y) = y"
wenzelm@12281
   498
  by (unfold if_def) blast
wenzelm@12281
   499
wenzelm@12281
   500
lemma split_if: "P (if Q then x else y) = ((Q --> P(x)) & (~Q --> P(y)))"
wenzelm@12281
   501
  apply (rule case_split [of Q])
wenzelm@12281
   502
   apply (subst if_P)
paulson@14208
   503
    prefer 3 apply (subst if_not_P, blast+)
wenzelm@12281
   504
  done
wenzelm@12281
   505
wenzelm@12281
   506
lemma split_if_asm: "P (if Q then x else y) = (~((Q & ~P x) | (~Q & ~P y)))"
paulson@14208
   507
by (subst split_if, blast)
wenzelm@12281
   508
wenzelm@12281
   509
lemmas if_splits = split_if split_if_asm
wenzelm@12281
   510
wenzelm@12281
   511
lemma if_def2: "(if Q then x else y) = ((Q --> x) & (~ Q --> y))"
wenzelm@12281
   512
  by (rule split_if)
wenzelm@12281
   513
wenzelm@12281
   514
lemma if_cancel: "(if c then x else x) = x"
paulson@14208
   515
by (subst split_if, blast)
wenzelm@12281
   516
wenzelm@12281
   517
lemma if_eq_cancel: "(if x = y then y else x) = x"
paulson@14208
   518
by (subst split_if, blast)
wenzelm@12281
   519
wenzelm@12281
   520
lemma if_bool_eq_conj: "(if P then Q else R) = ((P-->Q) & (~P-->R))"
wenzelm@12281
   521
  -- {* This form is useful for expanding @{text if}s on the RIGHT of the @{text "==>"} symbol. *}
wenzelm@12281
   522
  by (rule split_if)
wenzelm@12281
   523
wenzelm@12281
   524
lemma if_bool_eq_disj: "(if P then Q else R) = ((P&Q) | (~P&R))"
wenzelm@12281
   525
  -- {* And this form is useful for expanding @{text if}s on the LEFT. *}
paulson@14208
   526
  apply (subst split_if, blast)
wenzelm@12281
   527
  done
wenzelm@12281
   528
berghofe@12436
   529
lemma Eq_TrueI: "P ==> P == True" by (unfold atomize_eq) rules
berghofe@12436
   530
lemma Eq_FalseI: "~P ==> P == False" by (unfold atomize_eq) rules
wenzelm@12281
   531
paulson@14201
   532
subsubsection {* Actual Installation of the Simplifier *}
paulson@14201
   533
wenzelm@9869
   534
use "simpdata.ML"
wenzelm@9869
   535
setup Simplifier.setup
wenzelm@9869
   536
setup "Simplifier.method_setup Splitter.split_modifiers" setup simpsetup
wenzelm@9869
   537
setup Splitter.setup setup Clasimp.setup
wenzelm@9869
   538
paulson@14201
   539
declare disj_absorb [simp] conj_absorb [simp] 
paulson@14201
   540
nipkow@13723
   541
lemma ex1_eq[iff]: "EX! x. x = t" "EX! x. t = x"
nipkow@13723
   542
by blast+
nipkow@13723
   543
berghofe@13638
   544
theorem choice_eq: "(ALL x. EX! y. P x y) = (EX! f. ALL x. P x (f x))"
berghofe@13638
   545
  apply (rule iffI)
berghofe@13638
   546
  apply (rule_tac a = "%x. THE y. P x y" in ex1I)
berghofe@13638
   547
  apply (fast dest!: theI')
berghofe@13638
   548
  apply (fast intro: ext the1_equality [symmetric])
berghofe@13638
   549
  apply (erule ex1E)
berghofe@13638
   550
  apply (rule allI)
berghofe@13638
   551
  apply (rule ex1I)
berghofe@13638
   552
  apply (erule spec)
berghofe@13638
   553
  apply (erule_tac x = "%z. if z = x then y else f z" in allE)
berghofe@13638
   554
  apply (erule impE)
berghofe@13638
   555
  apply (rule allI)
berghofe@13638
   556
  apply (rule_tac P = "xa = x" in case_split_thm)
paulson@14208
   557
  apply (drule_tac [3] x = x in fun_cong, simp_all)
berghofe@13638
   558
  done
berghofe@13638
   559
nipkow@13438
   560
text{*Needs only HOL-lemmas:*}
nipkow@13438
   561
lemma mk_left_commute:
nipkow@13438
   562
  assumes a: "\<And>x y z. f (f x y) z = f x (f y z)" and
nipkow@13438
   563
          c: "\<And>x y. f x y = f y x"
nipkow@13438
   564
  shows "f x (f y z) = f y (f x z)"
nipkow@13438
   565
by(rule trans[OF trans[OF c a] arg_cong[OF c, of "f y"]])
nipkow@13438
   566
wenzelm@11750
   567
wenzelm@11824
   568
subsubsection {* Generic cases and induction *}
wenzelm@11824
   569
wenzelm@11824
   570
constdefs
wenzelm@11989
   571
  induct_forall :: "('a => bool) => bool"
wenzelm@11989
   572
  "induct_forall P == \<forall>x. P x"
wenzelm@11989
   573
  induct_implies :: "bool => bool => bool"
wenzelm@11989
   574
  "induct_implies A B == A --> B"
wenzelm@11989
   575
  induct_equal :: "'a => 'a => bool"
wenzelm@11989
   576
  "induct_equal x y == x = y"
wenzelm@11989
   577
  induct_conj :: "bool => bool => bool"
wenzelm@11989
   578
  "induct_conj A B == A & B"
wenzelm@11824
   579
wenzelm@11989
   580
lemma induct_forall_eq: "(!!x. P x) == Trueprop (induct_forall (\<lambda>x. P x))"
wenzelm@11989
   581
  by (simp only: atomize_all induct_forall_def)
wenzelm@11824
   582
wenzelm@11989
   583
lemma induct_implies_eq: "(A ==> B) == Trueprop (induct_implies A B)"
wenzelm@11989
   584
  by (simp only: atomize_imp induct_implies_def)
wenzelm@11824
   585
wenzelm@11989
   586
lemma induct_equal_eq: "(x == y) == Trueprop (induct_equal x y)"
wenzelm@11989
   587
  by (simp only: atomize_eq induct_equal_def)
wenzelm@11824
   588
wenzelm@11989
   589
lemma induct_forall_conj: "induct_forall (\<lambda>x. induct_conj (A x) (B x)) =
wenzelm@11989
   590
    induct_conj (induct_forall A) (induct_forall B)"
wenzelm@12354
   591
  by (unfold induct_forall_def induct_conj_def) rules
wenzelm@11824
   592
wenzelm@11989
   593
lemma induct_implies_conj: "induct_implies C (induct_conj A B) =
wenzelm@11989
   594
    induct_conj (induct_implies C A) (induct_implies C B)"
wenzelm@12354
   595
  by (unfold induct_implies_def induct_conj_def) rules
wenzelm@11989
   596
berghofe@13598
   597
lemma induct_conj_curry: "(induct_conj A B ==> PROP C) == (A ==> B ==> PROP C)"
berghofe@13598
   598
proof
berghofe@13598
   599
  assume r: "induct_conj A B ==> PROP C" and A B
berghofe@13598
   600
  show "PROP C" by (rule r) (simp! add: induct_conj_def)
berghofe@13598
   601
next
berghofe@13598
   602
  assume r: "A ==> B ==> PROP C" and "induct_conj A B"
berghofe@13598
   603
  show "PROP C" by (rule r) (simp! add: induct_conj_def)+
berghofe@13598
   604
qed
wenzelm@11824
   605
wenzelm@11989
   606
lemma induct_impliesI: "(A ==> B) ==> induct_implies A B"
wenzelm@11989
   607
  by (simp add: induct_implies_def)
wenzelm@11824
   608
wenzelm@12161
   609
lemmas induct_atomize = atomize_conj induct_forall_eq induct_implies_eq induct_equal_eq
wenzelm@12161
   610
lemmas induct_rulify1 [symmetric, standard] = induct_forall_eq induct_implies_eq induct_equal_eq
wenzelm@12161
   611
lemmas induct_rulify2 = induct_forall_def induct_implies_def induct_equal_def induct_conj_def
wenzelm@11989
   612
lemmas induct_conj = induct_forall_conj induct_implies_conj induct_conj_curry
wenzelm@11824
   613
wenzelm@11989
   614
hide const induct_forall induct_implies induct_equal induct_conj
wenzelm@11824
   615
wenzelm@11824
   616
wenzelm@11824
   617
text {* Method setup. *}
wenzelm@11824
   618
wenzelm@11824
   619
ML {*
wenzelm@11824
   620
  structure InductMethod = InductMethodFun
wenzelm@11824
   621
  (struct
wenzelm@11824
   622
    val dest_concls = HOLogic.dest_concls;
wenzelm@11824
   623
    val cases_default = thm "case_split";
wenzelm@11989
   624
    val local_impI = thm "induct_impliesI";
wenzelm@11824
   625
    val conjI = thm "conjI";
wenzelm@11989
   626
    val atomize = thms "induct_atomize";
wenzelm@11989
   627
    val rulify1 = thms "induct_rulify1";
wenzelm@11989
   628
    val rulify2 = thms "induct_rulify2";
wenzelm@12240
   629
    val localize = [Thm.symmetric (thm "induct_implies_def")];
wenzelm@11824
   630
  end);
wenzelm@11824
   631
*}
wenzelm@11824
   632
wenzelm@11824
   633
setup InductMethod.setup
wenzelm@11824
   634
wenzelm@11824
   635
wenzelm@11750
   636
subsection {* Order signatures and orders *}
wenzelm@11750
   637
wenzelm@11750
   638
axclass
wenzelm@12338
   639
  ord < type
wenzelm@11750
   640
wenzelm@11750
   641
syntax
wenzelm@11750
   642
  "op <"        :: "['a::ord, 'a] => bool"             ("op <")
wenzelm@11750
   643
  "op <="       :: "['a::ord, 'a] => bool"             ("op <=")
wenzelm@11750
   644
wenzelm@11750
   645
global
wenzelm@11750
   646
wenzelm@11750
   647
consts
wenzelm@11750
   648
  "op <"        :: "['a::ord, 'a] => bool"             ("(_/ < _)"  [50, 51] 50)
wenzelm@11750
   649
  "op <="       :: "['a::ord, 'a] => bool"             ("(_/ <= _)" [50, 51] 50)
wenzelm@11750
   650
wenzelm@11750
   651
local
wenzelm@11750
   652
wenzelm@12114
   653
syntax (xsymbols)
wenzelm@11750
   654
  "op <="       :: "['a::ord, 'a] => bool"             ("op \<le>")
wenzelm@11750
   655
  "op <="       :: "['a::ord, 'a] => bool"             ("(_/ \<le> _)"  [50, 51] 50)
wenzelm@11750
   656
kleing@14565
   657
syntax (HTML output)
kleing@14565
   658
  "op <="       :: "['a::ord, 'a] => bool"             ("op \<le>")
kleing@14565
   659
  "op <="       :: "['a::ord, 'a] => bool"             ("(_/ \<le> _)"  [50, 51] 50)
kleing@14565
   660
wenzelm@11750
   661
paulson@14295
   662
lemma Not_eq_iff: "((~P) = (~Q)) = (P = Q)"
paulson@14295
   663
by blast
paulson@14295
   664
wenzelm@11750
   665
subsubsection {* Monotonicity *}
wenzelm@11750
   666
wenzelm@13412
   667
locale mono =
wenzelm@13412
   668
  fixes f
wenzelm@13412
   669
  assumes mono: "A <= B ==> f A <= f B"
wenzelm@11750
   670
wenzelm@13421
   671
lemmas monoI [intro?] = mono.intro
wenzelm@13412
   672
  and monoD [dest?] = mono.mono
wenzelm@11750
   673
wenzelm@11750
   674
constdefs
wenzelm@11750
   675
  min :: "['a::ord, 'a] => 'a"
wenzelm@11750
   676
  "min a b == (if a <= b then a else b)"
wenzelm@11750
   677
  max :: "['a::ord, 'a] => 'a"
wenzelm@11750
   678
  "max a b == (if a <= b then b else a)"
wenzelm@11750
   679
wenzelm@11750
   680
lemma min_leastL: "(!!x. least <= x) ==> min least x = least"
wenzelm@11750
   681
  by (simp add: min_def)
wenzelm@11750
   682
wenzelm@11750
   683
lemma min_of_mono:
wenzelm@11750
   684
    "ALL x y. (f x <= f y) = (x <= y) ==> min (f m) (f n) = f (min m n)"
wenzelm@11750
   685
  by (simp add: min_def)
wenzelm@11750
   686
wenzelm@11750
   687
lemma max_leastL: "(!!x. least <= x) ==> max least x = x"
wenzelm@11750
   688
  by (simp add: max_def)
wenzelm@11750
   689
wenzelm@11750
   690
lemma max_of_mono:
wenzelm@11750
   691
    "ALL x y. (f x <= f y) = (x <= y) ==> max (f m) (f n) = f (max m n)"
wenzelm@11750
   692
  by (simp add: max_def)
wenzelm@11750
   693
wenzelm@11750
   694
wenzelm@11750
   695
subsubsection "Orders"
wenzelm@11750
   696
wenzelm@11750
   697
axclass order < ord
wenzelm@11750
   698
  order_refl [iff]: "x <= x"
wenzelm@11750
   699
  order_trans: "x <= y ==> y <= z ==> x <= z"
wenzelm@11750
   700
  order_antisym: "x <= y ==> y <= x ==> x = y"
wenzelm@11750
   701
  order_less_le: "(x < y) = (x <= y & x ~= y)"
wenzelm@11750
   702
wenzelm@11750
   703
wenzelm@11750
   704
text {* Reflexivity. *}
wenzelm@11750
   705
wenzelm@11750
   706
lemma order_eq_refl: "!!x::'a::order. x = y ==> x <= y"
wenzelm@11750
   707
    -- {* This form is useful with the classical reasoner. *}
wenzelm@11750
   708
  apply (erule ssubst)
wenzelm@11750
   709
  apply (rule order_refl)
wenzelm@11750
   710
  done
wenzelm@11750
   711
nipkow@13553
   712
lemma order_less_irrefl [iff]: "~ x < (x::'a::order)"
wenzelm@11750
   713
  by (simp add: order_less_le)
wenzelm@11750
   714
wenzelm@11750
   715
lemma order_le_less: "((x::'a::order) <= y) = (x < y | x = y)"
wenzelm@11750
   716
    -- {* NOT suitable for iff, since it can cause PROOF FAILED. *}
paulson@14208
   717
  apply (simp add: order_less_le, blast)
wenzelm@11750
   718
  done
wenzelm@11750
   719
wenzelm@11750
   720
lemmas order_le_imp_less_or_eq = order_le_less [THEN iffD1, standard]
wenzelm@11750
   721
wenzelm@11750
   722
lemma order_less_imp_le: "!!x::'a::order. x < y ==> x <= y"
wenzelm@11750
   723
  by (simp add: order_less_le)
wenzelm@11750
   724
wenzelm@11750
   725
wenzelm@11750
   726
text {* Asymmetry. *}
wenzelm@11750
   727
wenzelm@11750
   728
lemma order_less_not_sym: "(x::'a::order) < y ==> ~ (y < x)"
wenzelm@11750
   729
  by (simp add: order_less_le order_antisym)
wenzelm@11750
   730
wenzelm@11750
   731
lemma order_less_asym: "x < (y::'a::order) ==> (~P ==> y < x) ==> P"
wenzelm@11750
   732
  apply (drule order_less_not_sym)
paulson@14208
   733
  apply (erule contrapos_np, simp)
wenzelm@11750
   734
  done
wenzelm@11750
   735
paulson@14295
   736
lemma order_eq_iff: "!!x::'a::order. (x = y) = (x \<le> y & y \<le> x)"  
paulson@14295
   737
by (blast intro: order_antisym)
paulson@14295
   738
wenzelm@11750
   739
wenzelm@11750
   740
text {* Transitivity. *}
wenzelm@11750
   741
wenzelm@11750
   742
lemma order_less_trans: "!!x::'a::order. [| x < y; y < z |] ==> x < z"
wenzelm@11750
   743
  apply (simp add: order_less_le)
wenzelm@11750
   744
  apply (blast intro: order_trans order_antisym)
wenzelm@11750
   745
  done
wenzelm@11750
   746
wenzelm@11750
   747
lemma order_le_less_trans: "!!x::'a::order. [| x <= y; y < z |] ==> x < z"
wenzelm@11750
   748
  apply (simp add: order_less_le)
wenzelm@11750
   749
  apply (blast intro: order_trans order_antisym)
wenzelm@11750
   750
  done
wenzelm@11750
   751
wenzelm@11750
   752
lemma order_less_le_trans: "!!x::'a::order. [| x < y; y <= z |] ==> x < z"
wenzelm@11750
   753
  apply (simp add: order_less_le)
wenzelm@11750
   754
  apply (blast intro: order_trans order_antisym)
wenzelm@11750
   755
  done
wenzelm@11750
   756
wenzelm@11750
   757
wenzelm@11750
   758
text {* Useful for simplification, but too risky to include by default. *}
wenzelm@11750
   759
wenzelm@11750
   760
lemma order_less_imp_not_less: "(x::'a::order) < y ==>  (~ y < x) = True"
wenzelm@11750
   761
  by (blast elim: order_less_asym)
wenzelm@11750
   762
wenzelm@11750
   763
lemma order_less_imp_triv: "(x::'a::order) < y ==>  (y < x --> P) = True"
wenzelm@11750
   764
  by (blast elim: order_less_asym)
wenzelm@11750
   765
wenzelm@11750
   766
lemma order_less_imp_not_eq: "(x::'a::order) < y ==>  (x = y) = False"
wenzelm@11750
   767
  by auto
wenzelm@11750
   768
wenzelm@11750
   769
lemma order_less_imp_not_eq2: "(x::'a::order) < y ==>  (y = x) = False"
wenzelm@11750
   770
  by auto
wenzelm@11750
   771
wenzelm@11750
   772
wenzelm@11750
   773
text {* Other operators. *}
wenzelm@11750
   774
wenzelm@11750
   775
lemma min_leastR: "(!!x::'a::order. least <= x) ==> min x least = least"
wenzelm@11750
   776
  apply (simp add: min_def)
wenzelm@11750
   777
  apply (blast intro: order_antisym)
wenzelm@11750
   778
  done
wenzelm@11750
   779
wenzelm@11750
   780
lemma max_leastR: "(!!x::'a::order. least <= x) ==> max x least = x"
wenzelm@11750
   781
  apply (simp add: max_def)
wenzelm@11750
   782
  apply (blast intro: order_antisym)
wenzelm@11750
   783
  done
wenzelm@11750
   784
wenzelm@11750
   785
wenzelm@11750
   786
subsubsection {* Least value operator *}
wenzelm@11750
   787
wenzelm@11750
   788
constdefs
wenzelm@11750
   789
  Least :: "('a::ord => bool) => 'a"               (binder "LEAST " 10)
wenzelm@11750
   790
  "Least P == THE x. P x & (ALL y. P y --> x <= y)"
wenzelm@11750
   791
    -- {* We can no longer use LeastM because the latter requires Hilbert-AC. *}
wenzelm@11750
   792
wenzelm@11750
   793
lemma LeastI2:
wenzelm@11750
   794
  "[| P (x::'a::order);
wenzelm@11750
   795
      !!y. P y ==> x <= y;
wenzelm@11750
   796
      !!x. [| P x; ALL y. P y --> x \<le> y |] ==> Q x |]
wenzelm@12281
   797
   ==> Q (Least P)"
wenzelm@11750
   798
  apply (unfold Least_def)
wenzelm@11750
   799
  apply (rule theI2)
wenzelm@11750
   800
    apply (blast intro: order_antisym)+
wenzelm@11750
   801
  done
wenzelm@11750
   802
wenzelm@11750
   803
lemma Least_equality:
wenzelm@12281
   804
    "[| P (k::'a::order); !!x. P x ==> k <= x |] ==> (LEAST x. P x) = k"
wenzelm@11750
   805
  apply (simp add: Least_def)
wenzelm@11750
   806
  apply (rule the_equality)
wenzelm@11750
   807
  apply (auto intro!: order_antisym)
wenzelm@11750
   808
  done
wenzelm@11750
   809
wenzelm@11750
   810
wenzelm@11750
   811
subsubsection "Linear / total orders"
wenzelm@11750
   812
wenzelm@11750
   813
axclass linorder < order
wenzelm@11750
   814
  linorder_linear: "x <= y | y <= x"
wenzelm@11750
   815
wenzelm@11750
   816
lemma linorder_less_linear: "!!x::'a::linorder. x<y | x=y | y<x"
wenzelm@11750
   817
  apply (simp add: order_less_le)
paulson@14208
   818
  apply (insert linorder_linear, blast)
wenzelm@11750
   819
  done
wenzelm@11750
   820
paulson@14365
   821
lemma linorder_le_cases [case_names le ge]:
paulson@14365
   822
    "((x::'a::linorder) \<le> y ==> P) ==> (y \<le> x ==> P) ==> P"
paulson@14365
   823
  by (insert linorder_linear, blast)
paulson@14365
   824
wenzelm@11750
   825
lemma linorder_cases [case_names less equal greater]:
wenzelm@11750
   826
    "((x::'a::linorder) < y ==> P) ==> (x = y ==> P) ==> (y < x ==> P) ==> P"
paulson@14365
   827
  by (insert linorder_less_linear, blast)
wenzelm@11750
   828
wenzelm@11750
   829
lemma linorder_not_less: "!!x::'a::linorder. (~ x < y) = (y <= x)"
wenzelm@11750
   830
  apply (simp add: order_less_le)
wenzelm@11750
   831
  apply (insert linorder_linear)
wenzelm@11750
   832
  apply (blast intro: order_antisym)
wenzelm@11750
   833
  done
wenzelm@11750
   834
wenzelm@11750
   835
lemma linorder_not_le: "!!x::'a::linorder. (~ x <= y) = (y < x)"
wenzelm@11750
   836
  apply (simp add: order_less_le)
wenzelm@11750
   837
  apply (insert linorder_linear)
wenzelm@11750
   838
  apply (blast intro: order_antisym)
wenzelm@11750
   839
  done
wenzelm@11750
   840
wenzelm@11750
   841
lemma linorder_neq_iff: "!!x::'a::linorder. (x ~= y) = (x<y | y<x)"
paulson@14208
   842
by (cut_tac x = x and y = y in linorder_less_linear, auto)
wenzelm@11750
   843
wenzelm@11750
   844
lemma linorder_neqE: "x ~= (y::'a::linorder) ==> (x < y ==> R) ==> (y < x ==> R) ==> R"
paulson@14208
   845
by (simp add: linorder_neq_iff, blast)
wenzelm@11750
   846
wenzelm@11750
   847
wenzelm@11750
   848
subsubsection "Min and max on (linear) orders"
wenzelm@11750
   849
wenzelm@11750
   850
lemma min_same [simp]: "min (x::'a::order) x = x"
wenzelm@11750
   851
  by (simp add: min_def)
wenzelm@11750
   852
wenzelm@11750
   853
lemma max_same [simp]: "max (x::'a::order) x = x"
wenzelm@11750
   854
  by (simp add: max_def)
wenzelm@11750
   855
wenzelm@11750
   856
lemma le_max_iff_disj: "!!z::'a::linorder. (z <= max x y) = (z <= x | z <= y)"
wenzelm@11750
   857
  apply (simp add: max_def)
wenzelm@11750
   858
  apply (insert linorder_linear)
wenzelm@11750
   859
  apply (blast intro: order_trans)
wenzelm@11750
   860
  done
wenzelm@11750
   861
wenzelm@11750
   862
lemma le_maxI1: "(x::'a::linorder) <= max x y"
wenzelm@11750
   863
  by (simp add: le_max_iff_disj)
wenzelm@11750
   864
wenzelm@11750
   865
lemma le_maxI2: "(y::'a::linorder) <= max x y"
wenzelm@11750
   866
    -- {* CANNOT use with @{text "[intro!]"} because blast will give PROOF FAILED. *}
wenzelm@11750
   867
  by (simp add: le_max_iff_disj)
wenzelm@11750
   868
wenzelm@11750
   869
lemma less_max_iff_disj: "!!z::'a::linorder. (z < max x y) = (z < x | z < y)"
wenzelm@11750
   870
  apply (simp add: max_def order_le_less)
wenzelm@11750
   871
  apply (insert linorder_less_linear)
wenzelm@11750
   872
  apply (blast intro: order_less_trans)
wenzelm@11750
   873
  done
wenzelm@11750
   874
wenzelm@11750
   875
lemma max_le_iff_conj [simp]:
wenzelm@11750
   876
    "!!z::'a::linorder. (max x y <= z) = (x <= z & y <= z)"
wenzelm@11750
   877
  apply (simp add: max_def)
wenzelm@11750
   878
  apply (insert linorder_linear)
wenzelm@11750
   879
  apply (blast intro: order_trans)
wenzelm@11750
   880
  done
wenzelm@11750
   881
wenzelm@11750
   882
lemma max_less_iff_conj [simp]:
wenzelm@11750
   883
    "!!z::'a::linorder. (max x y < z) = (x < z & y < z)"
wenzelm@11750
   884
  apply (simp add: order_le_less max_def)
wenzelm@11750
   885
  apply (insert linorder_less_linear)
wenzelm@11750
   886
  apply (blast intro: order_less_trans)
wenzelm@11750
   887
  done
wenzelm@11750
   888
wenzelm@11750
   889
lemma le_min_iff_conj [simp]:
wenzelm@11750
   890
    "!!z::'a::linorder. (z <= min x y) = (z <= x & z <= y)"
wenzelm@12892
   891
    -- {* @{text "[iff]"} screws up a @{text blast} in MiniML *}
wenzelm@11750
   892
  apply (simp add: min_def)
wenzelm@11750
   893
  apply (insert linorder_linear)
wenzelm@11750
   894
  apply (blast intro: order_trans)
wenzelm@11750
   895
  done
wenzelm@11750
   896
wenzelm@11750
   897
lemma min_less_iff_conj [simp]:
wenzelm@11750
   898
    "!!z::'a::linorder. (z < min x y) = (z < x & z < y)"
wenzelm@11750
   899
  apply (simp add: order_le_less min_def)
wenzelm@11750
   900
  apply (insert linorder_less_linear)
wenzelm@11750
   901
  apply (blast intro: order_less_trans)
wenzelm@11750
   902
  done
wenzelm@11750
   903
wenzelm@11750
   904
lemma min_le_iff_disj: "!!z::'a::linorder. (min x y <= z) = (x <= z | y <= z)"
wenzelm@11750
   905
  apply (simp add: min_def)
wenzelm@11750
   906
  apply (insert linorder_linear)
wenzelm@11750
   907
  apply (blast intro: order_trans)
wenzelm@11750
   908
  done
wenzelm@11750
   909
wenzelm@11750
   910
lemma min_less_iff_disj: "!!z::'a::linorder. (min x y < z) = (x < z | y < z)"
wenzelm@11750
   911
  apply (simp add: min_def order_le_less)
wenzelm@11750
   912
  apply (insert linorder_less_linear)
wenzelm@11750
   913
  apply (blast intro: order_less_trans)
wenzelm@11750
   914
  done
wenzelm@11750
   915
nipkow@13438
   916
lemma max_assoc: "!!x::'a::linorder. max (max x y) z = max x (max y z)"
nipkow@13438
   917
apply(simp add:max_def)
nipkow@13438
   918
apply(rule conjI)
nipkow@13438
   919
apply(blast intro:order_trans)
nipkow@13438
   920
apply(simp add:linorder_not_le)
nipkow@13438
   921
apply(blast dest: order_less_trans order_le_less_trans)
nipkow@13438
   922
done
nipkow@13438
   923
nipkow@13438
   924
lemma max_commute: "!!x::'a::linorder. max x y = max y x"
nipkow@13438
   925
apply(simp add:max_def)
nipkow@13438
   926
apply(rule conjI)
nipkow@13438
   927
apply(blast intro:order_antisym)
nipkow@13438
   928
apply(simp add:linorder_not_le)
nipkow@13438
   929
apply(blast dest: order_less_trans)
nipkow@13438
   930
done
nipkow@13438
   931
nipkow@13438
   932
lemmas max_ac = max_assoc max_commute
nipkow@13438
   933
                mk_left_commute[of max,OF max_assoc max_commute]
nipkow@13438
   934
nipkow@13438
   935
lemma min_assoc: "!!x::'a::linorder. min (min x y) z = min x (min y z)"
nipkow@13438
   936
apply(simp add:min_def)
nipkow@13438
   937
apply(rule conjI)
nipkow@13438
   938
apply(blast intro:order_trans)
nipkow@13438
   939
apply(simp add:linorder_not_le)
nipkow@13438
   940
apply(blast dest: order_less_trans order_le_less_trans)
nipkow@13438
   941
done
nipkow@13438
   942
nipkow@13438
   943
lemma min_commute: "!!x::'a::linorder. min x y = min y x"
nipkow@13438
   944
apply(simp add:min_def)
nipkow@13438
   945
apply(rule conjI)
nipkow@13438
   946
apply(blast intro:order_antisym)
nipkow@13438
   947
apply(simp add:linorder_not_le)
nipkow@13438
   948
apply(blast dest: order_less_trans)
nipkow@13438
   949
done
nipkow@13438
   950
nipkow@13438
   951
lemmas min_ac = min_assoc min_commute
nipkow@13438
   952
                mk_left_commute[of min,OF min_assoc min_commute]
nipkow@13438
   953
wenzelm@11750
   954
lemma split_min:
wenzelm@11750
   955
    "P (min (i::'a::linorder) j) = ((i <= j --> P(i)) & (~ i <= j --> P(j)))"
wenzelm@11750
   956
  by (simp add: min_def)
wenzelm@11750
   957
wenzelm@11750
   958
lemma split_max:
wenzelm@11750
   959
    "P (max (i::'a::linorder) j) = ((i <= j --> P(j)) & (~ i <= j --> P(i)))"
wenzelm@11750
   960
  by (simp add: max_def)
wenzelm@11750
   961
wenzelm@11750
   962
ballarin@14398
   963
subsubsection {* Transitivity rules for calculational reasoning *}
ballarin@14398
   964
ballarin@14398
   965
ballarin@14398
   966
lemma order_neq_le_trans: "a ~= b ==> (a::'a::order) <= b ==> a < b"
ballarin@14398
   967
  by (simp add: order_less_le)
ballarin@14398
   968
ballarin@14398
   969
lemma order_le_neq_trans: "(a::'a::order) <= b ==> a ~= b ==> a < b"
ballarin@14398
   970
  by (simp add: order_less_le)
ballarin@14398
   971
ballarin@14398
   972
lemma order_less_asym': "(a::'a::order) < b ==> b < a ==> P"
ballarin@14398
   973
  by (rule order_less_asym)
ballarin@14398
   974
ballarin@14398
   975
ballarin@14444
   976
subsubsection {* Setup of transitivity reasoner as Solver *}
ballarin@14398
   977
ballarin@14398
   978
lemma less_imp_neq: "[| (x::'a::order) < y |] ==> x ~= y"
ballarin@14398
   979
  by (erule contrapos_pn, erule subst, rule order_less_irrefl)
ballarin@14398
   980
ballarin@14398
   981
lemma eq_neq_eq_imp_neq: "[| x = a ; a ~= b; b = y |] ==> x ~= y"
ballarin@14398
   982
  by (erule subst, erule ssubst, assumption)
ballarin@14398
   983
ballarin@14398
   984
ML_setup {*
ballarin@14398
   985
ballarin@14398
   986
structure Trans_Tac = Trans_Tac_Fun (
ballarin@14398
   987
  struct
ballarin@14398
   988
    val less_reflE = thm "order_less_irrefl" RS thm "notE";
ballarin@14398
   989
    val le_refl = thm "order_refl";
ballarin@14398
   990
    val less_imp_le = thm "order_less_imp_le";
ballarin@14398
   991
    val not_lessI = thm "linorder_not_less" RS thm "iffD2";
ballarin@14398
   992
    val not_leI = thm "linorder_not_le" RS thm "iffD2";
ballarin@14398
   993
    val not_lessD = thm "linorder_not_less" RS thm "iffD1";
ballarin@14398
   994
    val not_leD = thm "linorder_not_le" RS thm "iffD1";
ballarin@14398
   995
    val eqI = thm "order_antisym";
ballarin@14398
   996
    val eqD1 = thm "order_eq_refl";
ballarin@14398
   997
    val eqD2 = thm "sym" RS thm "order_eq_refl";
ballarin@14398
   998
    val less_trans = thm "order_less_trans";
ballarin@14398
   999
    val less_le_trans = thm "order_less_le_trans";
ballarin@14398
  1000
    val le_less_trans = thm "order_le_less_trans";
ballarin@14398
  1001
    val le_trans = thm "order_trans";
ballarin@14398
  1002
    val le_neq_trans = thm "order_le_neq_trans";
ballarin@14398
  1003
    val neq_le_trans = thm "order_neq_le_trans";
ballarin@14398
  1004
    val less_imp_neq = thm "less_imp_neq";
ballarin@14398
  1005
    val eq_neq_eq_imp_neq = thm "eq_neq_eq_imp_neq";
ballarin@14398
  1006
ballarin@14398
  1007
    fun decomp_gen sort sign (Trueprop $ t) =
ballarin@14398
  1008
      let fun of_sort t = Sign.of_sort sign (type_of t, sort)
ballarin@14398
  1009
      fun dec (Const ("Not", _) $ t) = (
ballarin@14398
  1010
              case dec t of
ballarin@14398
  1011
                None => None
ballarin@14398
  1012
              | Some (t1, rel, t2) => Some (t1, "~" ^ rel, t2))
ballarin@14398
  1013
            | dec (Const ("op =",  _) $ t1 $ t2) = 
ballarin@14398
  1014
                if of_sort t1
ballarin@14398
  1015
                then Some (t1, "=", t2)
ballarin@14398
  1016
                else None
ballarin@14398
  1017
            | dec (Const ("op <=",  _) $ t1 $ t2) = 
ballarin@14398
  1018
                if of_sort t1
ballarin@14398
  1019
                then Some (t1, "<=", t2)
ballarin@14398
  1020
                else None
ballarin@14398
  1021
            | dec (Const ("op <",  _) $ t1 $ t2) = 
ballarin@14398
  1022
                if of_sort t1
ballarin@14398
  1023
                then Some (t1, "<", t2)
ballarin@14398
  1024
                else None
ballarin@14398
  1025
            | dec _ = None
ballarin@14398
  1026
      in dec t end;
ballarin@14398
  1027
ballarin@14398
  1028
    val decomp_part = decomp_gen ["HOL.order"];
ballarin@14398
  1029
    val decomp_lin = decomp_gen ["HOL.linorder"];
ballarin@14398
  1030
ballarin@14398
  1031
  end);  (* struct *)
ballarin@14398
  1032
wenzelm@14590
  1033
simpset_ref() := simpset ()
ballarin@14398
  1034
    addSolver (mk_solver "Trans_linear" (fn _ => Trans_Tac.linear_tac))
ballarin@14398
  1035
    addSolver (mk_solver "Trans_partial" (fn _ => Trans_Tac.partial_tac));
ballarin@14444
  1036
  (* Adding the transitivity reasoners also as safe solvers showed a slight
ballarin@14444
  1037
     speed up, but the reasoning strength appears to be not higher (at least
ballarin@14444
  1038
     no breaking of additional proofs in the entire HOL distribution, as
ballarin@14444
  1039
     of 5 March 2004, was observed). *)
ballarin@14398
  1040
*}
ballarin@14398
  1041
ballarin@14398
  1042
(* Optional methods
ballarin@14398
  1043
ballarin@14398
  1044
method_setup trans_partial =
ballarin@14398
  1045
  {* Method.no_args (Method.SIMPLE_METHOD' HEADGOAL (trans_tac_partial)) *}
ballarin@14398
  1046
  {* simple transitivity reasoner *}	    
ballarin@14398
  1047
method_setup trans_linear =
ballarin@14398
  1048
  {* Method.no_args (Method.SIMPLE_METHOD' HEADGOAL (trans_tac_linear)) *}
ballarin@14398
  1049
  {* simple transitivity reasoner *}
ballarin@14398
  1050
*)
ballarin@14398
  1051
ballarin@14444
  1052
(*
ballarin@14444
  1053
declare order.order_refl [simp del] order_less_irrefl [simp del]
ballarin@14444
  1054
*)
ballarin@14444
  1055
wenzelm@11750
  1056
subsubsection "Bounded quantifiers"
wenzelm@11750
  1057
wenzelm@11750
  1058
syntax
wenzelm@11750
  1059
  "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3ALL _<_./ _)"  [0, 0, 10] 10)
wenzelm@11750
  1060
  "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3EX _<_./ _)"  [0, 0, 10] 10)
wenzelm@11750
  1061
  "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3ALL _<=_./ _)" [0, 0, 10] 10)
wenzelm@11750
  1062
  "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3EX _<=_./ _)" [0, 0, 10] 10)
wenzelm@11750
  1063
wenzelm@12114
  1064
syntax (xsymbols)
wenzelm@11750
  1065
  "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_<_./ _)"  [0, 0, 10] 10)
wenzelm@11750
  1066
  "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_<_./ _)"  [0, 0, 10] 10)
wenzelm@11750
  1067
  "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10)
wenzelm@11750
  1068
  "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10)
wenzelm@11750
  1069
wenzelm@11750
  1070
syntax (HOL)
wenzelm@11750
  1071
  "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3! _<_./ _)"  [0, 0, 10] 10)
wenzelm@11750
  1072
  "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3? _<_./ _)"  [0, 0, 10] 10)
wenzelm@11750
  1073
  "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3! _<=_./ _)" [0, 0, 10] 10)
wenzelm@11750
  1074
  "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3? _<=_./ _)" [0, 0, 10] 10)
wenzelm@11750
  1075
kleing@14565
  1076
syntax (HTML output)
kleing@14565
  1077
  "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_<_./ _)"  [0, 0, 10] 10)
kleing@14565
  1078
  "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_<_./ _)"  [0, 0, 10] 10)
kleing@14565
  1079
  "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10)
kleing@14565
  1080
  "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10)
kleing@14565
  1081
wenzelm@11750
  1082
translations
wenzelm@11750
  1083
 "ALL x<y. P"   =>  "ALL x. x < y --> P"
wenzelm@11750
  1084
 "EX x<y. P"    =>  "EX x. x < y  & P"
wenzelm@11750
  1085
 "ALL x<=y. P"  =>  "ALL x. x <= y --> P"
wenzelm@11750
  1086
 "EX x<=y. P"   =>  "EX x. x <= y & P"
wenzelm@11750
  1087
kleing@14357
  1088
print_translation {*
kleing@14357
  1089
let
kleing@14357
  1090
  fun all_tr' [Const ("_bound",_) $ Free (v,_), 
kleing@14357
  1091
               Const("op -->",_) $ (Const ("op <",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] = 
kleing@14357
  1092
  (if v=v' then Syntax.const "_lessAll" $ Syntax.mark_bound v' $ n $ P else raise Match)
kleing@14357
  1093
kleing@14357
  1094
  | all_tr' [Const ("_bound",_) $ Free (v,_), 
kleing@14357
  1095
               Const("op -->",_) $ (Const ("op <=",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] = 
kleing@14357
  1096
  (if v=v' then Syntax.const "_leAll" $ Syntax.mark_bound v' $ n $ P else raise Match);
kleing@14357
  1097
kleing@14357
  1098
  fun ex_tr' [Const ("_bound",_) $ Free (v,_), 
kleing@14357
  1099
               Const("op &",_) $ (Const ("op <",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] = 
kleing@14357
  1100
  (if v=v' then Syntax.const "_lessEx" $ Syntax.mark_bound v' $ n $ P else raise Match)
kleing@14357
  1101
kleing@14357
  1102
  | ex_tr' [Const ("_bound",_) $ Free (v,_), 
kleing@14357
  1103
               Const("op &",_) $ (Const ("op <=",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] = 
kleing@14357
  1104
  (if v=v' then Syntax.const "_leEx" $ Syntax.mark_bound v' $ n $ P else raise Match)
kleing@14357
  1105
in
kleing@14357
  1106
[("ALL ", all_tr'), ("EX ", ex_tr')]
clasohm@923
  1107
end
kleing@14357
  1108
*}
kleing@14357
  1109
kleing@14357
  1110
end