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