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