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