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