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