src/HOL/Ord.thy
author paulson
Mon, 25 Jun 2001 15:36:55 +0200
changeset 11378 5c84a5ca3a21
parent 11367 7b2dbfb5cc3d
child 11451 8abfb4f7bd02
permissions -rw-r--r--
Simprocs for type "nat" no longer introduce numerals unless
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     1
(*  Title:      HOL/Ord.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     3
    Author:     Tobias Nipkow, Cambridge University Computer Laboratory
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     5
2624
ab311b6e5e29 fixed comment;
wenzelm
parents: 2608
diff changeset
     6
Type classes for order signatures and orders.
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     8
11140
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
     9
theory Ord = HOL:
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    10
5889
d3ecef6b5682 Classical.setup, attrib_setup;
wenzelm
parents: 4640
diff changeset
    11
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    12
axclass
11140
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    13
  ord < "term"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
3820
46b255e140dc fixed infix syntax;
wenzelm
parents: 3143
diff changeset
    15
syntax
11140
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    16
  "op <"        :: "['a::ord, 'a] => bool"             ("op <")
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    17
  "op <="       :: "['a::ord, 'a] => bool"             ("op <=")
3820
46b255e140dc fixed infix syntax;
wenzelm
parents: 3143
diff changeset
    18
8882
9df44a4f1bf7 fewer consts declared as global;
wenzelm
parents: 7357
diff changeset
    19
global
9df44a4f1bf7 fewer consts declared as global;
wenzelm
parents: 7357
diff changeset
    20
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    21
consts
11140
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    22
  "op <"        :: "['a::ord, 'a] => bool"             ("(_/ < _)"  [50, 51] 50)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    23
  "op <="       :: "['a::ord, 'a] => bool"             ("(_/ <= _)" [50, 51] 50)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    24
8882
9df44a4f1bf7 fewer consts declared as global;
wenzelm
parents: 7357
diff changeset
    25
local
2608
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 2259
diff changeset
    26
3820
46b255e140dc fixed infix syntax;
wenzelm
parents: 3143
diff changeset
    27
syntax (symbols)
11144
wenzelm
parents: 11140
diff changeset
    28
  "op <="       :: "['a::ord, 'a] => bool"             ("op \<le>")
wenzelm
parents: 11140
diff changeset
    29
  "op <="       :: "['a::ord, 'a] => bool"             ("(_/ \<le> _)"  [50, 51] 50)
11140
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    30
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    31
(*Tell Blast_tac about overloading of < and <= to reduce the risk of
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    32
  its applying a rule for the wrong type*)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    33
ML {*
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    34
Blast.overloaded ("op <" , domain_type);
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    35
Blast.overloaded ("op <=", domain_type);
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    36
*}
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    37
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    38
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    39
constdefs
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    40
  mono          :: "['a::ord => 'b::ord] => bool"      (*monotonicity*)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    41
                "mono(f)   == (!A B. A <= B --> f(A) <= f(B))"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    42
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    43
lemma monoI [intro?]: "[| !!A B. A <= B ==> f(A) <= f(B) |] ==> mono(f)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    44
apply (unfold mono_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    45
apply fast
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    46
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    47
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    48
lemma monoD [dest?]: "[| mono(f);  A <= B |] ==> f(A) <= f(B)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    49
apply (unfold mono_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    50
apply fast
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    51
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    52
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    53
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    54
constdefs
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    55
  min     :: "['a::ord, 'a] => 'a"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    56
             "min a b   == (if a <= b then a else b)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    57
  max     :: "['a::ord, 'a] => 'a"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    58
             "max a b   == (if a <= b then b else a)"
2259
e6d738f2b9a9 fixed comment;
wenzelm
parents: 2006
diff changeset
    59
11140
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    60
lemma min_leastL: "(!!x. least <= x) ==> min least x = least"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    61
apply (simp add: min_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    62
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    63
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    64
lemma min_of_mono: 
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    65
  "!x y. (f x <= f y) = (x <= y) ==> min (f m) (f n) = f (min m n)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    66
apply (simp add: min_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    67
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    68
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    69
lemma max_leastL: "(!!x. least <= x) ==> max least x = x"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    70
apply (simp add: max_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    71
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    72
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    73
lemma max_of_mono: 
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    74
  "!x y. (f x <= f y) = (x <= y) ==> max (f m) (f n) = f (max m n)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    75
apply (simp add: max_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    76
done
3947
eb707467f8c5 adapted to qualified names;
wenzelm
parents: 3820
diff changeset
    77
11367
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
    78
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
    79
(** Least value operator **)
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
    80
11140
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    81
constdefs
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    82
  LeastM   :: "['a => 'b::ord, 'a => bool] => 'a"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    83
              "LeastM m P == @x. P x & (!y. P y --> m x <= m y)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    84
  Least    :: "('a::ord => bool) => 'a"               (binder "LEAST " 10)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    85
              "Least     == LeastM (%x. x)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    86
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    87
syntax
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    88
 "@LeastM" :: "[pttrn, 'a=>'b::ord, bool] => 'a" ("LEAST _ WRT _. _" [0,4,10]10)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    89
translations
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    90
                "LEAST x WRT m. P" == "LeastM m (%x. P)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    91
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    92
lemma LeastMI2: "[| P x; !!y. P y ==> m x <= m y;
11144
wenzelm
parents: 11140
diff changeset
    93
 !!x. [| P x; \<forall>y. P y --> m x \<le> m y |] ==> Q x
11140
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    94
		 |] ==> Q (LeastM m P)";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    95
apply (unfold LeastM_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    96
apply (rule someI2_ex)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    97
apply  blast
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    98
apply blast
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
    99
done
2608
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 2259
diff changeset
   100
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 2259
diff changeset
   101
11367
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   102
(** Greatest value operator **)
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   103
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   104
constdefs
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   105
  GreatestM   :: "['a => 'b::ord, 'a => bool] => 'a"
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   106
              "GreatestM m P == @x. P x & (!y. P y --> m y <= m x)"
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   107
  
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   108
  Greatest    :: "('a::ord => bool) => 'a"         (binder "GREATEST " 10)
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   109
              "Greatest     == GreatestM (%x. x)"
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   110
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   111
syntax
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   112
 "@GreatestM" :: "[pttrn, 'a=>'b::ord, bool] => 'a"
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   113
                                        ("GREATEST _ WRT _. _" [0,4,10]10)
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   114
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   115
translations
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   116
              "GREATEST x WRT m. P" == "GreatestM m (%x. P)"
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   117
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   118
lemma GreatestMI2:
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   119
     "[| P x;
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   120
	 !!y. P y ==> m y <= m x;
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   121
         !!x. [| P x; \<forall>y. P y --> m y \<le> m x |] ==> Q x |]
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   122
      ==> Q (GreatestM m P)";
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   123
apply (unfold GreatestM_def)
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   124
apply (rule someI2_ex)
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   125
apply  blast
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   126
apply blast
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   127
done
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   128
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   129
11140
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   130
section "Orders"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   131
2608
450c9b682a92 New class "order" and accompanying changes.
nipkow
parents: 2259
diff changeset
   132
axclass order < ord
11140
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   133
  order_refl [iff]:                          "x <= x"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   134
  order_trans:      "[| x <= y; y <= z |] ==> x <= z"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   135
  order_antisym:    "[| x <= y; y <= x |] ==> x = y"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   136
  order_less_le:    "x < y = (x <= y & x ~= y)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   137
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   138
(** Reflexivity **)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   139
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   140
(*This form is useful with the classical reasoner*)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   141
lemma order_eq_refl: "!!x::'a::order. x = y ==> x <= y"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   142
apply (erule ssubst)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   143
apply (rule order_refl)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   144
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   145
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   146
lemma order_less_irrefl [simp]: "~ x < (x::'a::order)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   147
apply (simp (no_asm) add: order_less_le)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   148
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   149
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   150
lemma order_le_less: "(x::'a::order) <= y = (x < y | x = y)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   151
apply (simp (no_asm) add: order_less_le)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   152
   (*NOT suitable for AddIffs, since it can cause PROOF FAILED*)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   153
apply (blast intro!: order_refl)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   154
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   155
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   156
lemmas order_le_imp_less_or_eq = order_le_less [THEN iffD1, standard]
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   157
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   158
lemma order_less_imp_le: "!!x::'a::order. x < y ==> x <= y"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   159
apply (simp add: order_less_le)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   160
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   161
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   162
(** Asymmetry **)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   163
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   164
lemma order_less_not_sym: "(x::'a::order) < y ==> ~ (y<x)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   165
apply (simp add: order_less_le order_antisym)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   166
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   167
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   168
(* [| n<m;  ~P ==> m<n |] ==> P *)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   169
lemmas order_less_asym = order_less_not_sym [THEN contrapos_np, standard]
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   170
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   171
(* Transitivity *)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   172
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   173
lemma order_less_trans: "!!x::'a::order. [| x < y; y < z |] ==> x < z"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   174
apply (simp add: order_less_le)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   175
apply (blast intro: order_trans order_antisym)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   176
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   177
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   178
lemma order_le_less_trans: "!!x::'a::order. [| x <= y; y < z |] ==> x < z"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   179
apply (simp add: order_less_le)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   180
apply (blast intro: order_trans order_antisym)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   181
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   182
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   183
lemma order_less_le_trans: "!!x::'a::order. [| x < y; y <= z |] ==> x < z"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   184
apply (simp add: order_less_le)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   185
apply (blast intro: order_trans order_antisym)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   186
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   187
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   188
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   189
(** Useful for simplification, but too risky to include by default. **)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   190
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   191
lemma order_less_imp_not_less: "(x::'a::order) < y ==>  (~ y < x) = True"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   192
apply (blast elim: order_less_asym)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   193
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   194
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   195
lemma order_less_imp_triv: "(x::'a::order) < y ==>  (y < x --> P) = True"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   196
apply (blast elim: order_less_asym)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   197
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   198
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   199
lemma order_less_imp_not_eq: "(x::'a::order) < y ==>  (x = y) = False"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   200
apply auto
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   201
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   202
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   203
lemma order_less_imp_not_eq2: "(x::'a::order) < y ==>  (y = x) = False"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   204
apply auto
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   205
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   206
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   207
(* Other operators *)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   208
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   209
lemma min_leastR: "(!!x::'a::order. least <= x) ==> min x least = least"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   210
apply (simp (no_asm_simp) add: min_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   211
apply (blast intro: order_antisym)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   212
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   213
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   214
lemma max_leastR: "(!!x::'a::order. least <= x) ==> max x least = x"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   215
apply (simp add: max_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   216
apply (blast intro: order_antisym)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   217
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   218
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   219
lemma LeastM_equality:
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   220
 "[| P k; !!x. P x ==> m k <= m x |] ==> m (LEAST x WRT m. P x) = 
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   221
     (m k::'a::order)";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   222
apply (rule LeastMI2)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   223
apply   assumption
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   224
apply  blast
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   225
apply (blast intro!: order_antisym) 
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   226
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   227
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   228
lemma Least_equality:
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   229
  "[| P (k::'a::order); !!x. P x ==> k <= x |] ==> (LEAST x. P x) = k";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   230
apply (unfold Least_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   231
apply (erule LeastM_equality)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   232
apply blast
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   233
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   234
11367
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   235
lemma GreatestM_equality:
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   236
 "[| P k;  !!x. P x ==> m x <= m k |]
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   237
  ==> m (GREATEST x WRT m. P x) = (m k::'a::order)";
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   238
apply (rule_tac m=m in GreatestMI2)
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   239
apply   assumption
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   240
apply  blast
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   241
apply (blast intro!: order_antisym) 
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   242
done
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   243
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   244
lemma Greatest_equality:
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   245
  "[| P (k::'a::order); !!x. P x ==> x <= k |] ==> (GREATEST x. P x) = k";
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   246
apply (unfold Greatest_def)
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   247
apply (erule GreatestM_equality)
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   248
apply blast
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   249
done
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   250
11140
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   251
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   252
section "Linear/Total Orders"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   253
4640
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 3947
diff changeset
   254
axclass linorder < order
11140
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   255
  linorder_linear: "x <= y | y <= x"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   256
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   257
lemma linorder_less_linear: "!!x::'a::linorder. x<y | x=y | y<x"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   258
apply (simp (no_asm) add: order_less_le)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   259
apply (cut_tac linorder_linear)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   260
apply blast
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   261
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   262
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   263
lemma linorder_less_split: 
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   264
  "[| (x::'a::linorder)<y ==> P; x=y ==> P; y<x ==> P |] ==> P"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   265
apply (cut_tac linorder_less_linear)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   266
apply blast
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   267
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   268
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   269
lemma linorder_not_less: "!!x::'a::linorder. (~ x < y) = (y <= x)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   270
apply (simp (no_asm) add: order_less_le)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   271
apply (cut_tac linorder_linear)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   272
apply (blast intro: order_antisym)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   273
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   274
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   275
lemma linorder_not_le: "!!x::'a::linorder. (~ x <= y) = (y < x)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   276
apply (simp (no_asm) add: order_less_le)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   277
apply (cut_tac linorder_linear)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   278
apply (blast intro: order_antisym)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   279
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   280
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   281
lemma linorder_neq_iff: "!!x::'a::linorder. (x ~= y) = (x<y | y<x)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   282
apply (cut_tac x = "x" and y = "y" in linorder_less_linear)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   283
apply auto
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   284
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   285
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   286
(* eliminates ~= in premises *)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   287
lemmas linorder_neqE = linorder_neq_iff [THEN iffD1, THEN disjE, standard]
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   288
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   289
section "min & max on (linear) orders"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   290
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   291
lemma min_same [simp]: "min (x::'a::order) x = x"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   292
apply (simp add: min_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   293
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   294
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   295
lemma max_same [simp]: "max (x::'a::order) x = x"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   296
apply (simp add: max_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   297
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   298
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   299
lemma le_max_iff_disj: "!!z::'a::linorder. (z <= max x y) = (z <= x | z <= y)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   300
apply (unfold max_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   301
apply (simp (no_asm))
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   302
apply (cut_tac linorder_linear)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   303
apply (blast intro: order_trans)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   304
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   305
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   306
lemma le_maxI1: "(x::'a::linorder) <= max x y"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   307
apply (simp (no_asm) add: le_max_iff_disj)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   308
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   309
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   310
lemma le_maxI2: "(y::'a::linorder) <= max x y"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   311
apply (simp (no_asm) add: le_max_iff_disj)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   312
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   313
(*CANNOT use with AddSIs because blast_tac will give PROOF FAILED.*)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   314
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   315
lemma less_max_iff_disj: "!!z::'a::linorder. (z < max x y) = (z < x | z < y)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   316
apply (simp (no_asm) add: max_def order_le_less)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   317
apply (cut_tac linorder_less_linear)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   318
apply (blast intro: order_less_trans)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   319
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   320
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   321
lemma max_le_iff_conj [simp]: 
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   322
  "!!z::'a::linorder. (max x y <= z) = (x <= z & y <= z)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   323
apply (simp (no_asm) add: max_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   324
apply (cut_tac linorder_linear)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   325
apply (blast intro: order_trans)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   326
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   327
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   328
lemma max_less_iff_conj [simp]: 
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   329
  "!!z::'a::linorder. (max x y < z) = (x < z & y < z)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   330
apply (simp (no_asm) add: order_le_less max_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   331
apply (cut_tac linorder_less_linear)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   332
apply (blast intro: order_less_trans)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   333
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   334
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   335
lemma le_min_iff_conj [simp]: 
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   336
  "!!z::'a::linorder. (z <= min x y) = (z <= x & z <= y)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   337
apply (simp (no_asm) add: min_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   338
apply (cut_tac linorder_linear)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   339
apply (blast intro: order_trans)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   340
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   341
(* AddIffs screws up a blast_tac in MiniML *)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   342
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   343
lemma min_less_iff_conj [simp]:
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   344
  "!!z::'a::linorder. (z < min x y) = (z < x & z < y)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   345
apply (simp (no_asm) add: order_le_less min_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   346
apply (cut_tac linorder_less_linear)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   347
apply (blast intro: order_less_trans)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   348
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   349
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   350
lemma min_le_iff_disj: "!!z::'a::linorder. (min x y <= z) = (x <= z | y <= z)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   351
apply (unfold min_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   352
apply (simp (no_asm))
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   353
apply (cut_tac linorder_linear)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   354
apply (blast intro: order_trans)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   355
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   356
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   357
lemma min_less_iff_disj: "!!z::'a::linorder. (min x y < z) = (x < z | y < z)"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   358
apply (unfold min_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   359
apply (simp (no_asm) add: order_le_less)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   360
apply (cut_tac linorder_less_linear)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   361
apply (blast intro: order_less_trans)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   362
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   363
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   364
lemma split_min: 
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   365
 "P(min (i::'a::linorder) j) = ((i <= j --> P(i)) & (~ i <= j --> P(j)))"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   366
apply (simp (no_asm) add: min_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   367
done
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   368
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   369
lemma split_max: 
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   370
 "P(max (i::'a::linorder) j) = ((i <= j --> P(j)) & (~ i <= j --> P(i)))"
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   371
apply (simp (no_asm) add: max_def)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   372
done
4640
ac6cf9f18653 Congruence rules use == in premises now.
nipkow
parents: 3947
diff changeset
   373
7238
36e58620ffc8 replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents: 6855
diff changeset
   374
11140
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   375
section "bounded quantifiers"
7238
36e58620ffc8 replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents: 6855
diff changeset
   376
6402
2b23e14dd386 New bounded quantifier syntax: !x<i. P etc
nipkow
parents: 5953
diff changeset
   377
syntax
11140
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   378
  "_lessAll" :: "[idt, 'a, bool] => bool"  ("(3ALL _<_./ _)"  [0, 0, 10] 10)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   379
  "_lessEx"  :: "[idt, 'a, bool] => bool"  ("(3EX _<_./ _)"  [0, 0, 10] 10)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   380
  "_leAll"   :: "[idt, 'a, bool] => bool"  ("(3ALL _<=_./ _)" [0, 0, 10] 10)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   381
  "_leEx"    :: "[idt, 'a, bool] => bool"  ("(3EX _<=_./ _)" [0, 0, 10] 10)
7238
36e58620ffc8 replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents: 6855
diff changeset
   382
36e58620ffc8 replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents: 6855
diff changeset
   383
syntax (symbols)
11144
wenzelm
parents: 11140
diff changeset
   384
  "_lessAll" :: "[idt, 'a, bool] => bool"  ("(3\<forall>_<_./ _)"  [0, 0, 10] 10)
wenzelm
parents: 11140
diff changeset
   385
  "_lessEx"  :: "[idt, 'a, bool] => bool"  ("(3\<exists>_<_./ _)"  [0, 0, 10] 10)
wenzelm
parents: 11140
diff changeset
   386
  "_leAll"   :: "[idt, 'a, bool] => bool"  ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10)
wenzelm
parents: 11140
diff changeset
   387
  "_leEx"    :: "[idt, 'a, bool] => bool"  ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10)
7238
36e58620ffc8 replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents: 6855
diff changeset
   388
36e58620ffc8 replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents: 6855
diff changeset
   389
syntax (HOL)
11140
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   390
  "_lessAll" :: "[idt, 'a, bool] => bool"  ("(3! _<_./ _)"  [0, 0, 10] 10)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   391
  "_lessEx"  :: "[idt, 'a, bool] => bool"  ("(3? _<_./ _)"  [0, 0, 10] 10)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   392
  "_leAll"   :: "[idt, 'a, bool] => bool"  ("(3! _<=_./ _)" [0, 0, 10] 10)
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   393
  "_leEx"    :: "[idt, 'a, bool] => bool"  ("(3? _<=_./ _)" [0, 0, 10] 10)
7238
36e58620ffc8 replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents: 6855
diff changeset
   394
6402
2b23e14dd386 New bounded quantifier syntax: !x<i. P etc
nipkow
parents: 5953
diff changeset
   395
translations
7238
36e58620ffc8 replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents: 6855
diff changeset
   396
 "ALL x<y. P"   =>  "ALL x. x < y --> P"
36e58620ffc8 replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents: 6855
diff changeset
   397
 "EX x<y. P"    =>  "EX x. x < y  & P"
36e58620ffc8 replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents: 6855
diff changeset
   398
 "ALL x<=y. P"  =>  "ALL x. x <= y --> P"
36e58620ffc8 replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents: 6855
diff changeset
   399
 "EX x<=y. P"   =>  "EX x. x <= y & P"
36e58620ffc8 replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents: 6855
diff changeset
   400
6402
2b23e14dd386 New bounded quantifier syntax: !x<i. P etc
nipkow
parents: 5953
diff changeset
   401
11140
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   402
ML
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   403
{*
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   404
val mono_def = thm "mono_def";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   405
val monoI = thm "monoI";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   406
val monoD = thm "monoD";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   407
val min_def = thm "min_def";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   408
val min_of_mono = thm "min_of_mono";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   409
val max_def = thm "max_def";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   410
val max_of_mono = thm "max_of_mono";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   411
val min_leastL = thm "min_leastL";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   412
val max_leastL = thm "max_leastL";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   413
val LeastMI2 = thm "LeastMI2";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   414
val LeastM_equality = thm "LeastM_equality";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   415
val Least_def = thm "Least_def";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   416
val Least_equality = thm "Least_equality";
11367
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   417
val GreatestM_def = thm "GreatestM_def";
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   418
val GreatestMI2 = thm "GreatestMI2";
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   419
val GreatestM_equality = thm "GreatestM_equality";
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   420
val Greatest_def = thm "Greatest_def";
7b2dbfb5cc3d addition of the GREATEST quantifier
paulson
parents: 11144
diff changeset
   421
val Greatest_equality = thm "Greatest_equality";
11140
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   422
val min_leastR = thm "min_leastR";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   423
val max_leastR = thm "max_leastR";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   424
val order_eq_refl = thm "order_eq_refl";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   425
val order_less_irrefl = thm "order_less_irrefl";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   426
val order_le_less = thm "order_le_less";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   427
val order_le_imp_less_or_eq = thm "order_le_imp_less_or_eq";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   428
val order_less_imp_le = thm "order_less_imp_le";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   429
val order_less_not_sym = thm "order_less_not_sym";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   430
val order_less_asym = thm "order_less_asym";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   431
val order_less_trans = thm "order_less_trans";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   432
val order_le_less_trans = thm "order_le_less_trans";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   433
val order_less_le_trans = thm "order_less_le_trans";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   434
val order_less_imp_not_less = thm "order_less_imp_not_less";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   435
val order_less_imp_triv = thm "order_less_imp_triv";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   436
val order_less_imp_not_eq = thm "order_less_imp_not_eq";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   437
val order_less_imp_not_eq2 = thm "order_less_imp_not_eq2";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   438
val linorder_less_linear = thm "linorder_less_linear";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   439
val linorder_less_split = thm "linorder_less_split";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   440
val linorder_not_less = thm "linorder_not_less";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   441
val linorder_not_le = thm "linorder_not_le";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   442
val linorder_neq_iff = thm "linorder_neq_iff";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   443
val linorder_neqE = thm "linorder_neqE";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   444
val min_same = thm "min_same";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   445
val max_same = thm "max_same";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   446
val le_max_iff_disj = thm "le_max_iff_disj";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   447
val le_maxI1 = thm "le_maxI1";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   448
val le_maxI2 = thm "le_maxI2";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   449
val less_max_iff_disj = thm "less_max_iff_disj";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   450
val max_le_iff_conj = thm "max_le_iff_conj";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   451
val max_less_iff_conj = thm "max_less_iff_conj";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   452
val le_min_iff_conj = thm "le_min_iff_conj";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   453
val min_less_iff_conj = thm "min_less_iff_conj";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   454
val min_le_iff_disj = thm "min_le_iff_disj";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   455
val min_less_iff_disj = thm "min_less_iff_disj";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   456
val split_min = thm "split_min";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   457
val split_max = thm "split_max";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   458
val order_refl = thm "order_refl";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   459
val order_trans = thm "order_trans";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   460
val order_antisym = thm "order_antisym";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   461
val order_less_le = thm "order_less_le";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   462
val linorder_linear = thm "linorder_linear";
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   463
*}
a46eaedbeb2d Ord.thy/.ML converted to Isar
oheimb
parents: 10460
diff changeset
   464
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   465
end