src/HOL/Orderings.thy
author wenzelm
Sun Nov 05 21:44:33 2006 +0100 (2006-11-05)
changeset 21180 f27f12bcafb8
parent 21091 5061e3e56484
child 21194 7e48158e50f6
permissions -rw-r--r--
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
nipkow@15524
     1
(*  Title:      HOL/Orderings.thy
nipkow@15524
     2
    ID:         $Id$
nipkow@15524
     3
    Author:     Tobias Nipkow, Markus Wenzel, and Larry Paulson
nipkow@15524
     4
*)
nipkow@15524
     5
haftmann@21083
     6
header {* Abstract orderings *}
nipkow@15524
     7
nipkow@15524
     8
theory Orderings
haftmann@21044
     9
imports Code_Generator Lattice_Locales
nipkow@15524
    10
begin
nipkow@15524
    11
haftmann@21083
    12
section {* Abstract orderings *}
haftmann@21083
    13
haftmann@21083
    14
subsection {* Order signatures *}
nipkow@15524
    15
haftmann@20588
    16
class ord = eq +
haftmann@20714
    17
  constrains eq :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (*FIXME: class_package should do the job*)
haftmann@20588
    18
  fixes less_eq :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
haftmann@20588
    19
  fixes less    :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
nipkow@15524
    20
wenzelm@19656
    21
const_syntax
wenzelm@19656
    22
  less  ("op <")
wenzelm@19656
    23
  less  ("(_/ < _)"  [50, 51] 50)
wenzelm@19656
    24
  less_eq  ("op <=")
wenzelm@19656
    25
  less_eq  ("(_/ <= _)" [50, 51] 50)
nipkow@15524
    26
wenzelm@19656
    27
const_syntax (xsymbols)
wenzelm@19656
    28
  less_eq  ("op \<le>")
wenzelm@19656
    29
  less_eq  ("(_/ \<le> _)"  [50, 51] 50)
wenzelm@19656
    30
wenzelm@19656
    31
const_syntax (HTML output)
wenzelm@19656
    32
  less_eq  ("op \<le>")
wenzelm@19656
    33
  less_eq  ("(_/ \<le> _)"  [50, 51] 50)
nipkow@15524
    34
haftmann@20714
    35
haftmann@20714
    36
abbreviation (in ord)
haftmann@20714
    37
  "less_eq_syn \<equiv> less_eq"
haftmann@20714
    38
  "less_syn \<equiv> less"
haftmann@20714
    39
haftmann@20714
    40
const_syntax (in ord) 
haftmann@20714
    41
  less_eq_syn  ("op \<^loc><=")
haftmann@20714
    42
  less_eq_syn  ("(_/ \<^loc><= _)" [50, 51] 50)
haftmann@20714
    43
  less_syn  ("op \<^loc><")
haftmann@20714
    44
  less_syn  ("(_/ \<^loc>< _)"  [50, 51] 50)
haftmann@20714
    45
  
haftmann@20714
    46
const_syntax (in ord) (xsymbols)
haftmann@20714
    47
  less_eq_syn  ("op \<^loc>\<le>")
haftmann@20714
    48
  less_eq_syn  ("(_/ \<^loc>\<le> _)"  [50, 51] 50)
haftmann@20714
    49
haftmann@20714
    50
const_syntax (in ord) (HTML output)
haftmann@20714
    51
  less_eq_syn  ("op \<^loc>\<le>")
haftmann@20714
    52
  less_eq_syn  ("(_/ \<^loc>\<le> _)"  [50, 51] 50)
haftmann@20714
    53
haftmann@20714
    54
wenzelm@19536
    55
abbreviation (input)
wenzelm@19536
    56
  greater  (infixl ">" 50)
haftmann@20714
    57
  "x > y \<equiv> y < x"
wenzelm@19536
    58
  greater_eq  (infixl ">=" 50)
haftmann@20714
    59
  "x >= y \<equiv> y <= x"
haftmann@20714
    60
  
wenzelm@19656
    61
const_syntax (xsymbols)
wenzelm@19656
    62
  greater_eq  (infixl "\<ge>" 50)
nipkow@15524
    63
haftmann@20714
    64
abbreviation (in ord) (input)
haftmann@20714
    65
  greater  (infix "\<^loc>>" 50)
haftmann@20714
    66
  "x \<^loc>> y \<equiv> y \<^loc>< x"
haftmann@20714
    67
  greater_eq  (infix "\<^loc>>=" 50)
haftmann@20714
    68
  "x \<^loc>>= y \<equiv> y \<^loc><= x"
haftmann@20714
    69
haftmann@20714
    70
const_syntax (in ord) (xsymbols)
haftmann@20714
    71
  greater_eq  (infixl "\<^loc>\<ge>" 50)
haftmann@20714
    72
nipkow@15524
    73
haftmann@21083
    74
subsection {* Partial orderings *}
nipkow@15524
    75
nipkow@15524
    76
axclass order < ord
nipkow@15524
    77
  order_refl [iff]: "x <= x"
nipkow@15524
    78
  order_trans: "x <= y ==> y <= z ==> x <= z"
nipkow@15524
    79
  order_antisym: "x <= y ==> y <= x ==> x = y"
nipkow@15524
    80
  order_less_le: "(x < y) = (x <= y & x ~= y)"
nipkow@15524
    81
haftmann@21083
    82
text {* Connection to locale: *}
nipkow@15524
    83
ballarin@15837
    84
interpretation order:
nipkow@15780
    85
  partial_order["op \<le> :: 'a::order \<Rightarrow> 'a \<Rightarrow> bool"]
nipkow@15524
    86
apply(rule partial_order.intro)
nipkow@15524
    87
apply(rule order_refl, erule (1) order_trans, erule (1) order_antisym)
nipkow@15524
    88
done
nipkow@15524
    89
nipkow@15524
    90
text {* Reflexivity. *}
nipkow@15524
    91
nipkow@15524
    92
lemma order_eq_refl: "!!x::'a::order. x = y ==> x <= y"
nipkow@15524
    93
    -- {* This form is useful with the classical reasoner. *}
nipkow@15524
    94
  apply (erule ssubst)
nipkow@15524
    95
  apply (rule order_refl)
nipkow@15524
    96
  done
nipkow@15524
    97
nipkow@15524
    98
lemma order_less_irrefl [iff]: "~ x < (x::'a::order)"
nipkow@15524
    99
  by (simp add: order_less_le)
nipkow@15524
   100
nipkow@15524
   101
lemma order_le_less: "((x::'a::order) <= y) = (x < y | x = y)"
nipkow@15524
   102
    -- {* NOT suitable for iff, since it can cause PROOF FAILED. *}
nipkow@15524
   103
  apply (simp add: order_less_le, blast)
nipkow@15524
   104
  done
nipkow@15524
   105
nipkow@15524
   106
lemmas order_le_imp_less_or_eq = order_le_less [THEN iffD1, standard]
nipkow@15524
   107
nipkow@15524
   108
lemma order_less_imp_le: "!!x::'a::order. x < y ==> x <= y"
nipkow@15524
   109
  by (simp add: order_less_le)
nipkow@15524
   110
nipkow@15524
   111
text {* Asymmetry. *}
nipkow@15524
   112
nipkow@15524
   113
lemma order_less_not_sym: "(x::'a::order) < y ==> ~ (y < x)"
nipkow@15524
   114
  by (simp add: order_less_le order_antisym)
nipkow@15524
   115
nipkow@15524
   116
lemma order_less_asym: "x < (y::'a::order) ==> (~P ==> y < x) ==> P"
nipkow@15524
   117
  apply (drule order_less_not_sym)
nipkow@15524
   118
  apply (erule contrapos_np, simp)
nipkow@15524
   119
  done
nipkow@15524
   120
nipkow@15524
   121
lemma order_eq_iff: "!!x::'a::order. (x = y) = (x \<le> y & y \<le> x)"
nipkow@15524
   122
by (blast intro: order_antisym)
nipkow@15524
   123
nipkow@15524
   124
lemma order_antisym_conv: "(y::'a::order) <= x ==> (x <= y) = (x = y)"
nipkow@15524
   125
by(blast intro:order_antisym)
nipkow@15524
   126
haftmann@21083
   127
lemma less_imp_neq: "[| (x::'a::order) < y |] ==> x ~= y"
haftmann@21083
   128
  by (erule contrapos_pn, erule subst, rule order_less_irrefl)
haftmann@21083
   129
nipkow@15524
   130
text {* Transitivity. *}
nipkow@15524
   131
nipkow@15524
   132
lemma order_less_trans: "!!x::'a::order. [| x < y; y < z |] ==> x < z"
nipkow@15524
   133
  apply (simp add: order_less_le)
nipkow@15524
   134
  apply (blast intro: order_trans order_antisym)
nipkow@15524
   135
  done
nipkow@15524
   136
nipkow@15524
   137
lemma order_le_less_trans: "!!x::'a::order. [| x <= y; y < z |] ==> x < z"
nipkow@15524
   138
  apply (simp add: order_less_le)
nipkow@15524
   139
  apply (blast intro: order_trans order_antisym)
nipkow@15524
   140
  done
nipkow@15524
   141
nipkow@15524
   142
lemma order_less_le_trans: "!!x::'a::order. [| x < y; y <= z |] ==> x < z"
nipkow@15524
   143
  apply (simp add: order_less_le)
nipkow@15524
   144
  apply (blast intro: order_trans order_antisym)
nipkow@15524
   145
  done
nipkow@15524
   146
haftmann@21083
   147
lemma eq_neq_eq_imp_neq: "[| x = a ; a ~= b; b = y |] ==> x ~= y"
haftmann@21083
   148
  by (erule subst, erule ssubst, assumption)
nipkow@15524
   149
nipkow@15524
   150
text {* Useful for simplification, but too risky to include by default. *}
nipkow@15524
   151
nipkow@15524
   152
lemma order_less_imp_not_less: "(x::'a::order) < y ==>  (~ y < x) = True"
nipkow@15524
   153
  by (blast elim: order_less_asym)
nipkow@15524
   154
nipkow@15524
   155
lemma order_less_imp_triv: "(x::'a::order) < y ==>  (y < x --> P) = True"
nipkow@15524
   156
  by (blast elim: order_less_asym)
nipkow@15524
   157
nipkow@15524
   158
lemma order_less_imp_not_eq: "(x::'a::order) < y ==>  (x = y) = False"
nipkow@15524
   159
  by auto
nipkow@15524
   160
nipkow@15524
   161
lemma order_less_imp_not_eq2: "(x::'a::order) < y ==>  (y = x) = False"
nipkow@15524
   162
  by auto
nipkow@15524
   163
haftmann@21083
   164
text {* Transitivity rules for calculational reasoning *}
nipkow@15524
   165
nipkow@15524
   166
lemma order_neq_le_trans: "a ~= b ==> (a::'a::order) <= b ==> a < b"
nipkow@15524
   167
  by (simp add: order_less_le)
nipkow@15524
   168
nipkow@15524
   169
lemma order_le_neq_trans: "(a::'a::order) <= b ==> a ~= b ==> a < b"
nipkow@15524
   170
  by (simp add: order_less_le)
nipkow@15524
   171
nipkow@15524
   172
lemma order_less_asym': "(a::'a::order) < b ==> b < a ==> P"
nipkow@15524
   173
  by (rule order_less_asym)
nipkow@15524
   174
nipkow@15524
   175
haftmann@21083
   176
subsection {* Total orderings *}
nipkow@15524
   177
nipkow@15524
   178
axclass linorder < order
nipkow@15524
   179
  linorder_linear: "x <= y | y <= x"
nipkow@15524
   180
nipkow@15524
   181
lemma linorder_less_linear: "!!x::'a::linorder. x<y | x=y | y<x"
nipkow@15524
   182
  apply (simp add: order_less_le)
nipkow@15524
   183
  apply (insert linorder_linear, blast)
nipkow@15524
   184
  done
nipkow@15524
   185
nipkow@15524
   186
lemma linorder_le_less_linear: "!!x::'a::linorder. x\<le>y | y<x"
nipkow@15524
   187
  by (simp add: order_le_less linorder_less_linear)
nipkow@15524
   188
nipkow@15524
   189
lemma linorder_le_cases [case_names le ge]:
nipkow@15524
   190
    "((x::'a::linorder) \<le> y ==> P) ==> (y \<le> x ==> P) ==> P"
nipkow@15524
   191
  by (insert linorder_linear, blast)
nipkow@15524
   192
nipkow@15524
   193
lemma linorder_cases [case_names less equal greater]:
nipkow@15524
   194
    "((x::'a::linorder) < y ==> P) ==> (x = y ==> P) ==> (y < x ==> P) ==> P"
nipkow@15524
   195
  by (insert linorder_less_linear, blast)
nipkow@15524
   196
nipkow@15524
   197
lemma linorder_not_less: "!!x::'a::linorder. (~ x < y) = (y <= x)"
nipkow@15524
   198
  apply (simp add: order_less_le)
nipkow@15524
   199
  apply (insert linorder_linear)
nipkow@15524
   200
  apply (blast intro: order_antisym)
nipkow@15524
   201
  done
nipkow@15524
   202
nipkow@15524
   203
lemma linorder_not_le: "!!x::'a::linorder. (~ x <= y) = (y < x)"
nipkow@15524
   204
  apply (simp add: order_less_le)
nipkow@15524
   205
  apply (insert linorder_linear)
nipkow@15524
   206
  apply (blast intro: order_antisym)
nipkow@15524
   207
  done
nipkow@15524
   208
nipkow@15524
   209
lemma linorder_neq_iff: "!!x::'a::linorder. (x ~= y) = (x<y | y<x)"
nipkow@15524
   210
by (cut_tac x = x and y = y in linorder_less_linear, auto)
nipkow@15524
   211
nipkow@15524
   212
lemma linorder_neqE: "x ~= (y::'a::linorder) ==> (x < y ==> R) ==> (y < x ==> R) ==> R"
nipkow@15524
   213
by (simp add: linorder_neq_iff, blast)
nipkow@15524
   214
nipkow@15524
   215
lemma linorder_antisym_conv1: "~ (x::'a::linorder) < y ==> (x <= y) = (x = y)"
nipkow@15524
   216
by(blast intro:order_antisym dest:linorder_not_less[THEN iffD1])
nipkow@15524
   217
nipkow@15524
   218
lemma linorder_antisym_conv2: "(x::'a::linorder) <= y ==> (~ x < y) = (x = y)"
nipkow@15524
   219
by(blast intro:order_antisym dest:linorder_not_less[THEN iffD1])
nipkow@15524
   220
nipkow@15524
   221
lemma linorder_antisym_conv3: "~ (y::'a::linorder) < x ==> (~ x < y) = (x = y)"
nipkow@15524
   222
by(blast intro:order_antisym dest:linorder_not_less[THEN iffD1])
nipkow@15524
   223
paulson@16796
   224
text{*Replacing the old Nat.leI*}
paulson@16796
   225
lemma leI: "~ x < y ==> y <= (x::'a::linorder)"
paulson@16796
   226
  by (simp only: linorder_not_less)
paulson@16796
   227
paulson@16796
   228
lemma leD: "y <= (x::'a::linorder) ==> ~ x < y"
paulson@16796
   229
  by (simp only: linorder_not_less)
paulson@16796
   230
paulson@16796
   231
(*FIXME inappropriate name (or delete altogether)*)
paulson@16796
   232
lemma not_leE: "~ y <= (x::'a::linorder) ==> x < y"
paulson@16796
   233
  by (simp only: linorder_not_le)
paulson@16796
   234
haftmann@21083
   235
haftmann@21083
   236
subsection {* Reasoning tools setup *}
haftmann@21083
   237
haftmann@21091
   238
ML {*
haftmann@21091
   239
local
haftmann@21091
   240
haftmann@21091
   241
fun decomp_gen sort thy (Trueprop $ t) =
haftmann@21091
   242
  let fun of_sort t = let val T = type_of t in
haftmann@21091
   243
        (* exclude numeric types: linear arithmetic subsumes transitivity *)
haftmann@21091
   244
        T <> HOLogic.natT andalso T <> HOLogic.intT andalso
haftmann@21091
   245
        T <> HOLogic.realT andalso Sign.of_sort thy (T, sort) end
haftmann@21091
   246
  fun dec (Const ("Not", _) $ t) = (
haftmann@21091
   247
	  case dec t of
haftmann@21091
   248
	    NONE => NONE
haftmann@21091
   249
	  | SOME (t1, rel, t2) => SOME (t1, "~" ^ rel, t2))
haftmann@21091
   250
	| dec (Const ("op =",  _) $ t1 $ t2) =
haftmann@21091
   251
	    if of_sort t1
haftmann@21091
   252
	    then SOME (t1, "=", t2)
haftmann@21091
   253
	    else NONE
haftmann@21091
   254
	| dec (Const ("Orderings.less_eq",  _) $ t1 $ t2) =
haftmann@21091
   255
	    if of_sort t1
haftmann@21091
   256
	    then SOME (t1, "<=", t2)
haftmann@21091
   257
	    else NONE
haftmann@21091
   258
	| dec (Const ("Orderings.less",  _) $ t1 $ t2) =
haftmann@21091
   259
	    if of_sort t1
haftmann@21091
   260
	    then SOME (t1, "<", t2)
haftmann@21091
   261
	    else NONE
haftmann@21091
   262
	| dec _ = NONE
haftmann@21091
   263
  in dec t end;
haftmann@21091
   264
haftmann@21091
   265
in
haftmann@21091
   266
haftmann@21091
   267
structure Quasi_Tac = Quasi_Tac_Fun (
haftmann@21091
   268
(* The setting up of Quasi_Tac serves as a demo.  Since there is no
haftmann@21091
   269
   class for quasi orders, the tactics Quasi_Tac.trans_tac and
haftmann@21091
   270
   Quasi_Tac.quasi_tac are not of much use. *)
haftmann@21091
   271
  struct
haftmann@21091
   272
    val le_trans = thm "order_trans";
haftmann@21091
   273
    val le_refl = thm "order_refl";
haftmann@21091
   274
    val eqD1 = thm "order_eq_refl";
haftmann@21091
   275
    val eqD2 = thm "sym" RS thm "order_eq_refl";
haftmann@21091
   276
    val less_reflE = thm "order_less_irrefl" RS thm "notE";
haftmann@21091
   277
    val less_imp_le = thm "order_less_imp_le";
haftmann@21091
   278
    val le_neq_trans = thm "order_le_neq_trans";
haftmann@21091
   279
    val neq_le_trans = thm "order_neq_le_trans";
haftmann@21091
   280
    val less_imp_neq = thm "less_imp_neq";
haftmann@21091
   281
    val decomp_trans = decomp_gen ["Orderings.order"];
haftmann@21091
   282
    val decomp_quasi = decomp_gen ["Orderings.order"];
haftmann@21091
   283
haftmann@21091
   284
  end);
haftmann@21091
   285
haftmann@21091
   286
structure Order_Tac = Order_Tac_Fun (
haftmann@21091
   287
  struct
haftmann@21091
   288
    val less_reflE = thm "order_less_irrefl" RS thm "notE";
haftmann@21091
   289
    val le_refl = thm "order_refl";
haftmann@21091
   290
    val less_imp_le = thm "order_less_imp_le";
haftmann@21091
   291
    val not_lessI = thm "linorder_not_less" RS thm "iffD2";
haftmann@21091
   292
    val not_leI = thm "linorder_not_le" RS thm "iffD2";
haftmann@21091
   293
    val not_lessD = thm "linorder_not_less" RS thm "iffD1";
haftmann@21091
   294
    val not_leD = thm "linorder_not_le" RS thm "iffD1";
haftmann@21091
   295
    val eqI = thm "order_antisym";
haftmann@21091
   296
    val eqD1 = thm "order_eq_refl";
haftmann@21091
   297
    val eqD2 = thm "sym" RS thm "order_eq_refl";
haftmann@21091
   298
    val less_trans = thm "order_less_trans";
haftmann@21091
   299
    val less_le_trans = thm "order_less_le_trans";
haftmann@21091
   300
    val le_less_trans = thm "order_le_less_trans";
haftmann@21091
   301
    val le_trans = thm "order_trans";
haftmann@21091
   302
    val le_neq_trans = thm "order_le_neq_trans";
haftmann@21091
   303
    val neq_le_trans = thm "order_neq_le_trans";
haftmann@21091
   304
    val less_imp_neq = thm "less_imp_neq";
haftmann@21091
   305
    val eq_neq_eq_imp_neq = thm "eq_neq_eq_imp_neq";
haftmann@21091
   306
    val not_sym = thm "not_sym";
haftmann@21091
   307
    val decomp_part = decomp_gen ["Orderings.order"];
haftmann@21091
   308
    val decomp_lin = decomp_gen ["Orderings.linorder"];
haftmann@21091
   309
haftmann@21091
   310
  end);
haftmann@21091
   311
haftmann@21091
   312
end;
haftmann@21091
   313
*}
haftmann@21091
   314
haftmann@21083
   315
setup {*
haftmann@21083
   316
let
haftmann@21083
   317
haftmann@21083
   318
val order_antisym_conv = thm "order_antisym_conv"
haftmann@21083
   319
val linorder_antisym_conv1 = thm "linorder_antisym_conv1"
haftmann@21083
   320
val linorder_antisym_conv2 = thm "linorder_antisym_conv2"
haftmann@21083
   321
val linorder_antisym_conv3 = thm "linorder_antisym_conv3"
haftmann@21083
   322
haftmann@21083
   323
fun prp t thm = (#prop (rep_thm thm) = t);
nipkow@15524
   324
haftmann@21083
   325
fun prove_antisym_le sg ss ((le as Const(_,T)) $ r $ s) =
haftmann@21083
   326
  let val prems = prems_of_ss ss;
haftmann@21083
   327
      val less = Const("Orderings.less",T);
haftmann@21083
   328
      val t = HOLogic.mk_Trueprop(le $ s $ r);
haftmann@21083
   329
  in case find_first (prp t) prems of
haftmann@21083
   330
       NONE =>
haftmann@21083
   331
         let val t = HOLogic.mk_Trueprop(HOLogic.Not $ (less $ r $ s))
haftmann@21083
   332
         in case find_first (prp t) prems of
haftmann@21083
   333
              NONE => NONE
haftmann@21083
   334
            | SOME thm => SOME(mk_meta_eq(thm RS linorder_antisym_conv1))
haftmann@21083
   335
         end
haftmann@21083
   336
     | SOME thm => SOME(mk_meta_eq(thm RS order_antisym_conv))
haftmann@21083
   337
  end
haftmann@21083
   338
  handle THM _ => NONE;
nipkow@15524
   339
haftmann@21083
   340
fun prove_antisym_less sg ss (NotC $ ((less as Const(_,T)) $ r $ s)) =
haftmann@21083
   341
  let val prems = prems_of_ss ss;
haftmann@21083
   342
      val le = Const("Orderings.less_eq",T);
haftmann@21083
   343
      val t = HOLogic.mk_Trueprop(le $ r $ s);
haftmann@21083
   344
  in case find_first (prp t) prems of
haftmann@21083
   345
       NONE =>
haftmann@21083
   346
         let val t = HOLogic.mk_Trueprop(NotC $ (less $ s $ r))
haftmann@21083
   347
         in case find_first (prp t) prems of
haftmann@21083
   348
              NONE => NONE
haftmann@21083
   349
            | SOME thm => SOME(mk_meta_eq(thm RS linorder_antisym_conv3))
haftmann@21083
   350
         end
haftmann@21083
   351
     | SOME thm => SOME(mk_meta_eq(thm RS linorder_antisym_conv2))
haftmann@21083
   352
  end
haftmann@21083
   353
  handle THM _ => NONE;
nipkow@15524
   354
haftmann@21083
   355
val antisym_le = Simplifier.simproc (the_context())
haftmann@21083
   356
  "antisym le" ["(x::'a::order) <= y"] prove_antisym_le;
haftmann@21083
   357
val antisym_less = Simplifier.simproc (the_context())
haftmann@21083
   358
  "antisym less" ["~ (x::'a::linorder) < y"] prove_antisym_less;
haftmann@21083
   359
haftmann@21083
   360
in
haftmann@21091
   361
  (fn thy => (Simplifier.change_simpset_of thy
haftmann@21091
   362
    (fn ss => ss
haftmann@21091
   363
       addsimprocs [antisym_le, antisym_less]
haftmann@21091
   364
       addSolver (mk_solver "Trans_linear" (fn _ => Order_Tac.linear_tac))
haftmann@21091
   365
       addSolver (mk_solver "Trans_partial" (fn _ => Order_Tac.partial_tac)))
haftmann@21091
   366
       (* Adding the transitivity reasoners also as safe solvers showed a slight
haftmann@21091
   367
          speed up, but the reasoning strength appears to be not higher (at least
haftmann@21091
   368
          no breaking of additional proofs in the entire HOL distribution, as
haftmann@21091
   369
          of 5 March 2004, was observed). *); thy))
haftmann@21083
   370
end
haftmann@21083
   371
*}
nipkow@15524
   372
nipkow@15524
   373
haftmann@21083
   374
subsection {* Bounded quantifiers *}
haftmann@21083
   375
haftmann@21083
   376
syntax
wenzelm@21180
   377
  "_All_less" :: "[idt, 'a, bool] => bool"    ("(3ALL _<_./ _)"  [0, 0, 10] 10)
wenzelm@21180
   378
  "_Ex_less" :: "[idt, 'a, bool] => bool"    ("(3EX _<_./ _)"  [0, 0, 10] 10)
wenzelm@21180
   379
  "_All_less_eq" :: "[idt, 'a, bool] => bool"    ("(3ALL _<=_./ _)" [0, 0, 10] 10)
wenzelm@21180
   380
  "_Ex_less_eq" :: "[idt, 'a, bool] => bool"    ("(3EX _<=_./ _)" [0, 0, 10] 10)
haftmann@21083
   381
wenzelm@21180
   382
  "_All_greater" :: "[idt, 'a, bool] => bool"    ("(3ALL _>_./ _)"  [0, 0, 10] 10)
wenzelm@21180
   383
  "_Ex_greater" :: "[idt, 'a, bool] => bool"    ("(3EX _>_./ _)"  [0, 0, 10] 10)
wenzelm@21180
   384
  "_All_greater_eq" :: "[idt, 'a, bool] => bool"    ("(3ALL _>=_./ _)" [0, 0, 10] 10)
wenzelm@21180
   385
  "_Ex_greater_eq" :: "[idt, 'a, bool] => bool"    ("(3EX _>=_./ _)" [0, 0, 10] 10)
haftmann@21083
   386
haftmann@21083
   387
syntax (xsymbols)
wenzelm@21180
   388
  "_All_less" :: "[idt, 'a, bool] => bool"    ("(3\<forall>_<_./ _)"  [0, 0, 10] 10)
wenzelm@21180
   389
  "_Ex_less" :: "[idt, 'a, bool] => bool"    ("(3\<exists>_<_./ _)"  [0, 0, 10] 10)
wenzelm@21180
   390
  "_All_less_eq" :: "[idt, 'a, bool] => bool"    ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10)
wenzelm@21180
   391
  "_Ex_less_eq" :: "[idt, 'a, bool] => bool"    ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10)
haftmann@21083
   392
wenzelm@21180
   393
  "_All_greater" :: "[idt, 'a, bool] => bool"    ("(3\<forall>_>_./ _)"  [0, 0, 10] 10)
wenzelm@21180
   394
  "_Ex_greater" :: "[idt, 'a, bool] => bool"    ("(3\<exists>_>_./ _)"  [0, 0, 10] 10)
wenzelm@21180
   395
  "_All_greater_eq" :: "[idt, 'a, bool] => bool"    ("(3\<forall>_\<ge>_./ _)" [0, 0, 10] 10)
wenzelm@21180
   396
  "_Ex_greater_eq" :: "[idt, 'a, bool] => bool"    ("(3\<exists>_\<ge>_./ _)" [0, 0, 10] 10)
haftmann@21083
   397
haftmann@21083
   398
syntax (HOL)
wenzelm@21180
   399
  "_All_less" :: "[idt, 'a, bool] => bool"    ("(3! _<_./ _)"  [0, 0, 10] 10)
wenzelm@21180
   400
  "_Ex_less" :: "[idt, 'a, bool] => bool"    ("(3? _<_./ _)"  [0, 0, 10] 10)
wenzelm@21180
   401
  "_All_less_eq" :: "[idt, 'a, bool] => bool"    ("(3! _<=_./ _)" [0, 0, 10] 10)
wenzelm@21180
   402
  "_Ex_less_eq" :: "[idt, 'a, bool] => bool"    ("(3? _<=_./ _)" [0, 0, 10] 10)
haftmann@21083
   403
haftmann@21083
   404
syntax (HTML output)
wenzelm@21180
   405
  "_All_less" :: "[idt, 'a, bool] => bool"    ("(3\<forall>_<_./ _)"  [0, 0, 10] 10)
wenzelm@21180
   406
  "_Ex_less" :: "[idt, 'a, bool] => bool"    ("(3\<exists>_<_./ _)"  [0, 0, 10] 10)
wenzelm@21180
   407
  "_All_less_eq" :: "[idt, 'a, bool] => bool"    ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10)
wenzelm@21180
   408
  "_Ex_less_eq" :: "[idt, 'a, bool] => bool"    ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10)
haftmann@21083
   409
wenzelm@21180
   410
  "_All_greater" :: "[idt, 'a, bool] => bool"    ("(3\<forall>_>_./ _)"  [0, 0, 10] 10)
wenzelm@21180
   411
  "_Ex_greater" :: "[idt, 'a, bool] => bool"    ("(3\<exists>_>_./ _)"  [0, 0, 10] 10)
wenzelm@21180
   412
  "_All_greater_eq" :: "[idt, 'a, bool] => bool"    ("(3\<forall>_\<ge>_./ _)" [0, 0, 10] 10)
wenzelm@21180
   413
  "_Ex_greater_eq" :: "[idt, 'a, bool] => bool"    ("(3\<exists>_\<ge>_./ _)" [0, 0, 10] 10)
haftmann@21083
   414
haftmann@21083
   415
translations
haftmann@21083
   416
  "ALL x<y. P"   =>  "ALL x. x < y \<longrightarrow> P"
haftmann@21083
   417
  "EX x<y. P"    =>  "EX x. x < y \<and> P"
haftmann@21083
   418
  "ALL x<=y. P"  =>  "ALL x. x <= y \<longrightarrow> P"
haftmann@21083
   419
  "EX x<=y. P"   =>  "EX x. x <= y \<and> P"
haftmann@21083
   420
  "ALL x>y. P"   =>  "ALL x. x > y \<longrightarrow> P"
haftmann@21083
   421
  "EX x>y. P"    =>  "EX x. x > y \<and> P"
haftmann@21083
   422
  "ALL x>=y. P"  =>  "ALL x. x >= y \<longrightarrow> P"
haftmann@21083
   423
  "EX x>=y. P"   =>  "EX x. x >= y \<and> P"
haftmann@21083
   424
haftmann@21083
   425
print_translation {*
haftmann@21083
   426
let
wenzelm@21180
   427
  val syntax_name = Sign.const_syntax_name (the_context ());
wenzelm@21180
   428
  val impl = syntax_name "op -->";
wenzelm@21180
   429
  val conj = syntax_name "op &";
wenzelm@21180
   430
  val less = syntax_name "Orderings.less";
wenzelm@21180
   431
  val less_eq = syntax_name "Orderings.less_eq";
wenzelm@21180
   432
wenzelm@21180
   433
  val trans =
wenzelm@21180
   434
   [(("ALL ", impl, less), ("_All_less", "_All_greater")),
wenzelm@21180
   435
    (("ALL ", impl, less_eq), ("_All_less_eq", "_All_greater_eq")),
wenzelm@21180
   436
    (("EX ", conj, less), ("_Ex_less", "_Ex_greater")),
wenzelm@21180
   437
    (("EX ", conj, less_eq), ("_Ex_less_eq", "_Ex_greater_eq"))];
wenzelm@21180
   438
haftmann@21083
   439
  fun mk v v' c n P =
wenzelm@21180
   440
    if v = v' andalso not (Term.exists_subterm (fn Free (x, _) => x = v | _ => false) n)
haftmann@21083
   441
    then Syntax.const c $ Syntax.mark_bound v' $ n $ P else raise Match;
wenzelm@21180
   442
wenzelm@21180
   443
  fun tr' q = (q,
wenzelm@21180
   444
    fn [Const ("_bound", _) $ Free (v, _), Const (c, _) $ (Const (d, _) $ t $ u) $ P] =>
wenzelm@21180
   445
      (case AList.lookup (op =) trans (q, c, d) of
wenzelm@21180
   446
        NONE => raise Match
wenzelm@21180
   447
      | SOME (l, g) =>
wenzelm@21180
   448
          (case (t, u) of
wenzelm@21180
   449
            (Const ("_bound", _) $ Free (v', _), n) => mk v v' l n P
wenzelm@21180
   450
          | (n, Const ("_bound", _) $ Free (v', _)) => mk v v' g n P
wenzelm@21180
   451
          | _ => raise Match))
wenzelm@21180
   452
     | _ => raise Match);
wenzelm@21180
   453
in [tr' "ALL ", tr' "EX "] end
haftmann@21083
   454
*}
haftmann@21083
   455
haftmann@21083
   456
haftmann@21083
   457
subsection {* Transitivity reasoning on decreasing inequalities *}
haftmann@21083
   458
wenzelm@21180
   459
(* FIXME cleanup *)
wenzelm@21180
   460
haftmann@21083
   461
text {* These support proving chains of decreasing inequalities
haftmann@21083
   462
    a >= b >= c ... in Isar proofs. *}
haftmann@21083
   463
haftmann@21083
   464
lemma xt1:
haftmann@21083
   465
  "a = b ==> b > c ==> a > c"
haftmann@21083
   466
  "a > b ==> b = c ==> a > c"
haftmann@21083
   467
  "a = b ==> b >= c ==> a >= c"
haftmann@21083
   468
  "a >= b ==> b = c ==> a >= c"
haftmann@21083
   469
  "(x::'a::order) >= y ==> y >= x ==> x = y"
haftmann@21083
   470
  "(x::'a::order) >= y ==> y >= z ==> x >= z"
haftmann@21083
   471
  "(x::'a::order) > y ==> y >= z ==> x > z"
haftmann@21083
   472
  "(x::'a::order) >= y ==> y > z ==> x > z"
haftmann@21083
   473
  "(a::'a::order) > b ==> b > a ==> ?P"
haftmann@21083
   474
  "(x::'a::order) > y ==> y > z ==> x > z"
haftmann@21083
   475
  "(a::'a::order) >= b ==> a ~= b ==> a > b"
haftmann@21083
   476
  "(a::'a::order) ~= b ==> a >= b ==> a > b"
haftmann@21083
   477
  "a = f b ==> b > c ==> (!!x y. x > y ==> f x > f y) ==> a > f c" 
haftmann@21083
   478
  "a > b ==> f b = c ==> (!!x y. x > y ==> f x > f y) ==> f a > c"
haftmann@21083
   479
  "a = f b ==> b >= c ==> (!!x y. x >= y ==> f x >= f y) ==> a >= f c"
haftmann@21083
   480
  "a >= b ==> f b = c ==> (!! x y. x >= y ==> f x >= f y) ==> f a >= c"
haftmann@21083
   481
by auto
haftmann@21083
   482
haftmann@21083
   483
lemma xt2:
haftmann@21083
   484
  "(a::'a::order) >= f b ==> b >= c ==> (!!x y. x >= y ==> f x >= f y) ==> a >= f c"
haftmann@21083
   485
by (subgoal_tac "f b >= f c", force, force)
haftmann@21083
   486
haftmann@21083
   487
lemma xt3: "(a::'a::order) >= b ==> (f b::'b::order) >= c ==> 
haftmann@21083
   488
    (!!x y. x >= y ==> f x >= f y) ==> f a >= c"
haftmann@21083
   489
by (subgoal_tac "f a >= f b", force, force)
haftmann@21083
   490
haftmann@21083
   491
lemma xt4: "(a::'a::order) > f b ==> (b::'b::order) >= c ==>
haftmann@21083
   492
  (!!x y. x >= y ==> f x >= f y) ==> a > f c"
haftmann@21083
   493
by (subgoal_tac "f b >= f c", force, force)
haftmann@21083
   494
haftmann@21083
   495
lemma xt5: "(a::'a::order) > b ==> (f b::'b::order) >= c==>
haftmann@21083
   496
    (!!x y. x > y ==> f x > f y) ==> f a > c"
haftmann@21083
   497
by (subgoal_tac "f a > f b", force, force)
haftmann@21083
   498
haftmann@21083
   499
lemma xt6: "(a::'a::order) >= f b ==> b > c ==>
haftmann@21083
   500
    (!!x y. x > y ==> f x > f y) ==> a > f c"
haftmann@21083
   501
by (subgoal_tac "f b > f c", force, force)
haftmann@21083
   502
haftmann@21083
   503
lemma xt7: "(a::'a::order) >= b ==> (f b::'b::order) > c ==>
haftmann@21083
   504
    (!!x y. x >= y ==> f x >= f y) ==> f a > c"
haftmann@21083
   505
by (subgoal_tac "f a >= f b", force, force)
haftmann@21083
   506
haftmann@21083
   507
lemma xt8: "(a::'a::order) > f b ==> (b::'b::order) > c ==>
haftmann@21083
   508
    (!!x y. x > y ==> f x > f y) ==> a > f c"
haftmann@21083
   509
by (subgoal_tac "f b > f c", force, force)
haftmann@21083
   510
haftmann@21083
   511
lemma xt9: "(a::'a::order) > b ==> (f b::'b::order) > c ==>
haftmann@21083
   512
    (!!x y. x > y ==> f x > f y) ==> f a > c"
haftmann@21083
   513
by (subgoal_tac "f a > f b", force, force)
haftmann@21083
   514
haftmann@21083
   515
lemmas xtrans = xt1 xt2 xt3 xt4 xt5 xt6 xt7 xt8 xt9
haftmann@21083
   516
haftmann@21083
   517
(* 
haftmann@21083
   518
  Since "a >= b" abbreviates "b <= a", the abbreviation "..." stands
haftmann@21083
   519
  for the wrong thing in an Isar proof.
haftmann@21083
   520
haftmann@21083
   521
  The extra transitivity rules can be used as follows: 
haftmann@21083
   522
haftmann@21083
   523
lemma "(a::'a::order) > z"
haftmann@21083
   524
proof -
haftmann@21083
   525
  have "a >= b" (is "_ >= ?rhs")
haftmann@21083
   526
    sorry
haftmann@21083
   527
  also have "?rhs >= c" (is "_ >= ?rhs")
haftmann@21083
   528
    sorry
haftmann@21083
   529
  also (xtrans) have "?rhs = d" (is "_ = ?rhs")
haftmann@21083
   530
    sorry
haftmann@21083
   531
  also (xtrans) have "?rhs >= e" (is "_ >= ?rhs")
haftmann@21083
   532
    sorry
haftmann@21083
   533
  also (xtrans) have "?rhs > f" (is "_ > ?rhs")
haftmann@21083
   534
    sorry
haftmann@21083
   535
  also (xtrans) have "?rhs > z"
haftmann@21083
   536
    sorry
haftmann@21083
   537
  finally (xtrans) show ?thesis .
haftmann@21083
   538
qed
haftmann@21083
   539
haftmann@21083
   540
  Alternatively, one can use "declare xtrans [trans]" and then
haftmann@21083
   541
  leave out the "(xtrans)" above.
haftmann@21083
   542
*)
haftmann@21083
   543
haftmann@21083
   544
haftmann@21083
   545
subsection {* Least value operator, monotonicity and min/max *}
haftmann@21083
   546
 
haftmann@21083
   547
(*FIXME: derive more of the min/max laws generically via semilattices*)
haftmann@21083
   548
haftmann@21083
   549
constdefs
haftmann@21083
   550
  Least :: "('a::ord => bool) => 'a"               (binder "LEAST " 10)
haftmann@21083
   551
  "Least P == THE x. P x & (ALL y. P y --> x <= y)"
haftmann@21083
   552
    -- {* We can no longer use LeastM because the latter requires Hilbert-AC. *}
haftmann@21083
   553
haftmann@21083
   554
lemma LeastI2_order:
haftmann@21083
   555
  "[| P (x::'a::order);
haftmann@21083
   556
      !!y. P y ==> x <= y;
haftmann@21083
   557
      !!x. [| P x; ALL y. P y --> x \<le> y |] ==> Q x |]
haftmann@21083
   558
   ==> Q (Least P)"
haftmann@21083
   559
  apply (unfold Least_def)
haftmann@21083
   560
  apply (rule theI2)
haftmann@21083
   561
    apply (blast intro: order_antisym)+
haftmann@21083
   562
  done
haftmann@21083
   563
haftmann@21083
   564
lemma Least_equality:
haftmann@21083
   565
    "[| P (k::'a::order); !!x. P x ==> k <= x |] ==> (LEAST x. P x) = k"
haftmann@21083
   566
  apply (simp add: Least_def)
haftmann@21083
   567
  apply (rule the_equality)
haftmann@21083
   568
  apply (auto intro!: order_antisym)
haftmann@21083
   569
  done
haftmann@21083
   570
haftmann@21083
   571
locale mono =
haftmann@21083
   572
  fixes f
haftmann@21083
   573
  assumes mono: "A <= B ==> f A <= f B"
haftmann@21083
   574
haftmann@21083
   575
lemmas monoI [intro?] = mono.intro
haftmann@21083
   576
  and monoD [dest?] = mono.mono
haftmann@21083
   577
haftmann@21083
   578
constdefs
haftmann@21083
   579
  min :: "['a::ord, 'a] => 'a"
haftmann@21083
   580
  "min a b == (if a <= b then a else b)"
haftmann@21083
   581
  max :: "['a::ord, 'a] => 'a"
haftmann@21083
   582
  "max a b == (if a <= b then b else a)"
haftmann@21083
   583
haftmann@21083
   584
lemma min_leastR: "(\<And>x\<Colon>'a\<Colon>order. least \<le> x) \<Longrightarrow> min x least = least"
haftmann@21083
   585
  apply (simp add: min_def)
haftmann@21083
   586
  apply (blast intro: order_antisym)
haftmann@21083
   587
  done
haftmann@21083
   588
haftmann@21083
   589
lemma max_leastR: "(\<And>x\<Colon>'a\<Colon>order. least \<le> x) \<Longrightarrow> max x least = x"
haftmann@21083
   590
  apply (simp add: max_def)
haftmann@21083
   591
  apply (blast intro: order_antisym)
haftmann@21083
   592
  done
haftmann@21083
   593
haftmann@21083
   594
lemma min_leastL: "(!!x. least <= x) ==> min least x = least"
haftmann@21083
   595
  by (simp add: min_def)
haftmann@21083
   596
haftmann@21083
   597
lemma max_leastL: "(!!x. least <= x) ==> max least x = x"
haftmann@21083
   598
  by (simp add: max_def)
haftmann@21083
   599
haftmann@21083
   600
lemma min_of_mono:
haftmann@21083
   601
    "(!!x y. (f x <= f y) = (x <= y)) ==> min (f m) (f n) = f (min m n)"
haftmann@21083
   602
  by (simp add: min_def)
haftmann@21083
   603
haftmann@21083
   604
lemma max_of_mono:
haftmann@21083
   605
    "(!!x y. (f x <= f y) = (x <= y)) ==> max (f m) (f n) = f (max m n)"
haftmann@21083
   606
  by (simp add: max_def)
nipkow@15524
   607
nipkow@15524
   608
text{* Instantiate locales: *}
nipkow@15524
   609
ballarin@15837
   610
interpretation min_max:
nipkow@15780
   611
  lower_semilattice["op \<le>" "min :: 'a::linorder \<Rightarrow> 'a \<Rightarrow> 'a"]
ballarin@19984
   612
apply unfold_locales
nipkow@15524
   613
apply(simp add:min_def linorder_not_le order_less_imp_le)
nipkow@15524
   614
apply(simp add:min_def linorder_not_le order_less_imp_le)
nipkow@15524
   615
apply(simp add:min_def linorder_not_le order_less_imp_le)
nipkow@15524
   616
done
nipkow@15524
   617
ballarin@15837
   618
interpretation min_max:
nipkow@15780
   619
  upper_semilattice["op \<le>" "max :: 'a::linorder \<Rightarrow> 'a \<Rightarrow> 'a"]
ballarin@19984
   620
apply unfold_locales
nipkow@15524
   621
apply(simp add: max_def linorder_not_le order_less_imp_le)
nipkow@15524
   622
apply(simp add: max_def linorder_not_le order_less_imp_le)
nipkow@15524
   623
apply(simp add: max_def linorder_not_le order_less_imp_le)
nipkow@15524
   624
done
nipkow@15524
   625
ballarin@15837
   626
interpretation min_max:
nipkow@15780
   627
  lattice["op \<le>" "min :: 'a::linorder \<Rightarrow> 'a \<Rightarrow> 'a" "max"]
ballarin@19984
   628
  by unfold_locales
nipkow@15524
   629
ballarin@15837
   630
interpretation min_max:
nipkow@15780
   631
  distrib_lattice["op \<le>" "min :: 'a::linorder \<Rightarrow> 'a \<Rightarrow> 'a" "max"]
ballarin@19984
   632
apply unfold_locales
nipkow@15524
   633
apply(rule_tac x=x and y=y in linorder_le_cases)
nipkow@15524
   634
apply(rule_tac x=x and y=z in linorder_le_cases)
nipkow@15524
   635
apply(rule_tac x=y and y=z in linorder_le_cases)
nipkow@15524
   636
apply(simp add:min_def max_def)
nipkow@15524
   637
apply(simp add:min_def max_def)
nipkow@15524
   638
apply(rule_tac x=y and y=z in linorder_le_cases)
nipkow@15524
   639
apply(simp add:min_def max_def)
nipkow@15524
   640
apply(simp add:min_def max_def)
nipkow@15524
   641
apply(rule_tac x=x and y=z in linorder_le_cases)
nipkow@15524
   642
apply(rule_tac x=y and y=z in linorder_le_cases)
nipkow@15524
   643
apply(simp add:min_def max_def)
nipkow@15524
   644
apply(simp add:min_def max_def)
nipkow@15524
   645
apply(rule_tac x=y and y=z in linorder_le_cases)
nipkow@15524
   646
apply(simp add:min_def max_def)
nipkow@15524
   647
apply(simp add:min_def max_def)
nipkow@15524
   648
done
nipkow@15524
   649
nipkow@15524
   650
lemma le_max_iff_disj: "!!z::'a::linorder. (z <= max x y) = (z <= x | z <= y)"
nipkow@15524
   651
  apply(simp add:max_def)
nipkow@15524
   652
  apply (insert linorder_linear)
nipkow@15524
   653
  apply (blast intro: order_trans)
nipkow@15524
   654
  done
nipkow@15524
   655
nipkow@15780
   656
lemmas le_maxI1 = min_max.sup_ge1
nipkow@15780
   657
lemmas le_maxI2 = min_max.sup_ge2
nipkow@15524
   658
nipkow@15524
   659
lemma less_max_iff_disj: "!!z::'a::linorder. (z < max x y) = (z < x | z < y)"
nipkow@15524
   660
  apply (simp add: max_def order_le_less)
nipkow@15524
   661
  apply (insert linorder_less_linear)
nipkow@15524
   662
  apply (blast intro: order_less_trans)
nipkow@15524
   663
  done
nipkow@15524
   664
nipkow@15524
   665
lemma max_less_iff_conj [simp]:
nipkow@15524
   666
    "!!z::'a::linorder. (max x y < z) = (x < z & y < z)"
nipkow@15524
   667
  apply (simp add: order_le_less max_def)
nipkow@15524
   668
  apply (insert linorder_less_linear)
nipkow@15524
   669
  apply (blast intro: order_less_trans)
nipkow@15524
   670
  done
nipkow@15791
   671
nipkow@15524
   672
lemma min_less_iff_conj [simp]:
nipkow@15524
   673
    "!!z::'a::linorder. (z < min x y) = (z < x & z < y)"
nipkow@15524
   674
  apply (simp add: order_le_less min_def)
nipkow@15524
   675
  apply (insert linorder_less_linear)
nipkow@15524
   676
  apply (blast intro: order_less_trans)
nipkow@15524
   677
  done
nipkow@15524
   678
nipkow@15524
   679
lemma min_le_iff_disj: "!!z::'a::linorder. (min x y <= z) = (x <= z | y <= z)"
nipkow@15524
   680
  apply (simp add: min_def)
nipkow@15524
   681
  apply (insert linorder_linear)
nipkow@15524
   682
  apply (blast intro: order_trans)
nipkow@15524
   683
  done
nipkow@15524
   684
nipkow@15524
   685
lemma min_less_iff_disj: "!!z::'a::linorder. (min x y < z) = (x < z | y < z)"
nipkow@15524
   686
  apply (simp add: min_def order_le_less)
nipkow@15524
   687
  apply (insert linorder_less_linear)
nipkow@15524
   688
  apply (blast intro: order_less_trans)
nipkow@15524
   689
  done
nipkow@15524
   690
nipkow@15780
   691
lemmas max_ac = min_max.sup_assoc min_max.sup_commute
nipkow@15780
   692
               mk_left_commute[of max,OF min_max.sup_assoc min_max.sup_commute]
nipkow@15524
   693
nipkow@15780
   694
lemmas min_ac = min_max.inf_assoc min_max.inf_commute
nipkow@15780
   695
               mk_left_commute[of min,OF min_max.inf_assoc min_max.inf_commute]
nipkow@15524
   696
nipkow@15524
   697
lemma split_min:
nipkow@15524
   698
    "P (min (i::'a::linorder) j) = ((i <= j --> P(i)) & (~ i <= j --> P(j)))"
nipkow@15524
   699
  by (simp add: min_def)
nipkow@15524
   700
nipkow@15524
   701
lemma split_max:
nipkow@15524
   702
    "P (max (i::'a::linorder) j) = ((i <= j --> P(j)) & (~ i <= j --> P(i)))"
nipkow@15524
   703
  by (simp add: max_def)
nipkow@15524
   704
nipkow@15524
   705
end