src/HOL/Orderings.thy
author haftmann
Fri, 20 Oct 2006 18:20:22 +0200
changeset 21083 a1de02f047d0
parent 21044 9690be52ee5d
child 21091 5061e3e56484
permissions -rw-r--r--
cleaned up
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
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   238
setup {*
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   239
let
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   240
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   241
val order_antisym_conv = thm "order_antisym_conv"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   242
val linorder_antisym_conv1 = thm "linorder_antisym_conv1"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   243
val linorder_antisym_conv2 = thm "linorder_antisym_conv2"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   244
val linorder_antisym_conv3 = thm "linorder_antisym_conv3"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   245
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   246
fun prp t thm = (#prop (rep_thm thm) = t);
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   247
21083
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   248
fun prove_antisym_le sg ss ((le as Const(_,T)) $ r $ s) =
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   249
  let val prems = prems_of_ss ss;
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   250
      val less = Const("Orderings.less",T);
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   251
      val t = HOLogic.mk_Trueprop(le $ s $ r);
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   252
  in case find_first (prp t) prems of
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   253
       NONE =>
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   254
         let val t = HOLogic.mk_Trueprop(HOLogic.Not $ (less $ r $ s))
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   255
         in case find_first (prp t) prems of
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   256
              NONE => NONE
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   257
            | SOME thm => SOME(mk_meta_eq(thm RS linorder_antisym_conv1))
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   258
         end
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   259
     | SOME thm => SOME(mk_meta_eq(thm RS order_antisym_conv))
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   260
  end
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   261
  handle THM _ => NONE;
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   262
21083
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   263
fun prove_antisym_less sg ss (NotC $ ((less as Const(_,T)) $ r $ s)) =
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   264
  let val prems = prems_of_ss ss;
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   265
      val le = Const("Orderings.less_eq",T);
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   266
      val t = HOLogic.mk_Trueprop(le $ r $ s);
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   267
  in case find_first (prp t) prems of
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   268
       NONE =>
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   269
         let val t = HOLogic.mk_Trueprop(NotC $ (less $ s $ r))
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   270
         in case find_first (prp t) prems of
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   271
              NONE => NONE
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   272
            | SOME thm => SOME(mk_meta_eq(thm RS linorder_antisym_conv3))
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   273
         end
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   274
     | SOME thm => SOME(mk_meta_eq(thm RS linorder_antisym_conv2))
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   275
  end
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   276
  handle THM _ => NONE;
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   277
21083
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   278
val antisym_le = Simplifier.simproc (the_context())
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   279
  "antisym le" ["(x::'a::order) <= y"] prove_antisym_le;
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   280
val antisym_less = Simplifier.simproc (the_context())
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   281
  "antisym less" ["~ (x::'a::linorder) < y"] prove_antisym_less;
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   282
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   283
in
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   284
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   285
 (fn thy => (Simplifier.change_simpset_of thy
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   286
  (fn ss => ss addsimprocs [antisym_le, antisym_less]); thy))
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   287
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   288
end
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   289
*}
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   290
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   291
ML_setup {*
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   292
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   293
(* The setting up of Quasi_Tac serves as a demo.  Since there is no
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   294
   class for quasi orders, the tactics Quasi_Tac.trans_tac and
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   295
   Quasi_Tac.quasi_tac are not of much use. *)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   296
21044
9690be52ee5d fixed print translations for bounded quantification
haftmann
parents: 20714
diff changeset
   297
fun decomp_gen sort thy (Trueprop $ t) =
15622
4723248c982b Transitivity reasoner ignores types amenable to linear arithmetic.
ballarin
parents: 15531
diff changeset
   298
  let fun of_sort t = let val T = type_of t in
4723248c982b Transitivity reasoner ignores types amenable to linear arithmetic.
ballarin
parents: 15531
diff changeset
   299
        (* exclude numeric types: linear arithmetic subsumes transitivity *)
4723248c982b Transitivity reasoner ignores types amenable to linear arithmetic.
ballarin
parents: 15531
diff changeset
   300
        T <> HOLogic.natT andalso T <> HOLogic.intT andalso
21044
9690be52ee5d fixed print translations for bounded quantification
haftmann
parents: 20714
diff changeset
   301
        T <> HOLogic.realT andalso Sign.of_sort thy (T, sort) end
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   302
  fun dec (Const ("Not", _) $ t) = (
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   303
	  case dec t of
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   304
	    NONE => NONE
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   305
	  | SOME (t1, rel, t2) => SOME (t1, "~" ^ rel, t2))
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   306
	| dec (Const ("op =",  _) $ t1 $ t2) =
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   307
	    if of_sort t1
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   308
	    then SOME (t1, "=", t2)
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   309
	    else NONE
19277
f7602e74d948 renamed op < <= to Orderings.less(_eq)
haftmann
parents: 19039
diff changeset
   310
	| dec (Const ("Orderings.less_eq",  _) $ t1 $ t2) =
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   311
	    if of_sort t1
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   312
	    then SOME (t1, "<=", t2)
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   313
	    else NONE
19277
f7602e74d948 renamed op < <= to Orderings.less(_eq)
haftmann
parents: 19039
diff changeset
   314
	| dec (Const ("Orderings.less",  _) $ t1 $ t2) =
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   315
	    if of_sort t1
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   316
	    then SOME (t1, "<", t2)
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   317
	    else NONE
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   318
	| dec _ = NONE
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   319
  in dec t end;
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   320
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   321
structure Quasi_Tac = Quasi_Tac_Fun (
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   322
  struct
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   323
    val le_trans = thm "order_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   324
    val le_refl = thm "order_refl";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   325
    val eqD1 = thm "order_eq_refl";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   326
    val eqD2 = thm "sym" RS thm "order_eq_refl";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   327
    val less_reflE = thm "order_less_irrefl" RS thm "notE";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   328
    val less_imp_le = thm "order_less_imp_le";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   329
    val le_neq_trans = thm "order_le_neq_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   330
    val neq_le_trans = thm "order_neq_le_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   331
    val less_imp_neq = thm "less_imp_neq";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   332
    val decomp_trans = decomp_gen ["Orderings.order"];
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   333
    val decomp_quasi = decomp_gen ["Orderings.order"];
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   334
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   335
  end);  (* struct *)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   336
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   337
structure Order_Tac = Order_Tac_Fun (
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   338
  struct
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   339
    val less_reflE = thm "order_less_irrefl" RS thm "notE";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   340
    val le_refl = thm "order_refl";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   341
    val less_imp_le = thm "order_less_imp_le";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   342
    val not_lessI = thm "linorder_not_less" RS thm "iffD2";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   343
    val not_leI = thm "linorder_not_le" RS thm "iffD2";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   344
    val not_lessD = thm "linorder_not_less" RS thm "iffD1";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   345
    val not_leD = thm "linorder_not_le" RS thm "iffD1";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   346
    val eqI = thm "order_antisym";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   347
    val eqD1 = thm "order_eq_refl";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   348
    val eqD2 = thm "sym" RS thm "order_eq_refl";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   349
    val less_trans = thm "order_less_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   350
    val less_le_trans = thm "order_less_le_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   351
    val le_less_trans = thm "order_le_less_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   352
    val le_trans = thm "order_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   353
    val le_neq_trans = thm "order_le_neq_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   354
    val neq_le_trans = thm "order_neq_le_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   355
    val less_imp_neq = thm "less_imp_neq";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   356
    val eq_neq_eq_imp_neq = thm "eq_neq_eq_imp_neq";
16743
21dbff595bf6 1) all theorems in Orderings can now be given as a parameter
obua
parents: 16417
diff changeset
   357
    val not_sym = thm "not_sym";
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   358
    val decomp_part = decomp_gen ["Orderings.order"];
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   359
    val decomp_lin = decomp_gen ["Orderings.linorder"];
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   360
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   361
  end);  (* struct *)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   362
17876
b9c92f384109 change_claset/simpset;
wenzelm
parents: 17012
diff changeset
   363
change_simpset (fn ss => ss
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   364
    addSolver (mk_solver "Trans_linear" (fn _ => Order_Tac.linear_tac))
17876
b9c92f384109 change_claset/simpset;
wenzelm
parents: 17012
diff changeset
   365
    addSolver (mk_solver "Trans_partial" (fn _ => Order_Tac.partial_tac)));
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   366
  (* Adding the transitivity reasoners also as safe solvers showed a slight
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   367
     speed up, but the reasoning strength appears to be not higher (at least
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   368
     no breaking of additional proofs in the entire HOL distribution, as
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   369
     of 5 March 2004, was observed). *)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   370
*}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   371
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   372
(* Optional setup of methods *)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   373
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   374
(*
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   375
method_setup trans_partial =
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   376
  {* Method.no_args (Method.SIMPLE_METHOD' HEADGOAL (Order_Tac.partial_tac)) *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   377
  {* transitivity reasoner for partial orders *}	
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   378
method_setup trans_linear =
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   379
  {* Method.no_args (Method.SIMPLE_METHOD' HEADGOAL (Order_Tac.linear_tac)) *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   380
  {* transitivity reasoner for linear orders *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   381
*)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   382
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   383
(*
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   384
declare order.order_refl [simp del] order_less_irrefl [simp del]
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   385
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   386
can currently not be removed, abel_cancel relies on it.
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   387
*)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   388
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   389
21083
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   390
subsection {* Bounded quantifiers *}
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   391
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   392
syntax
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   393
  "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3ALL _<_./ _)"  [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   394
  "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3EX _<_./ _)"  [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   395
  "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3ALL _<=_./ _)" [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   396
  "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3EX _<=_./ _)" [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   397
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   398
  "_gtAll" :: "[idt, 'a, bool] => bool"   ("(3ALL _>_./ _)"  [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   399
  "_gtEx"  :: "[idt, 'a, bool] => bool"   ("(3EX _>_./ _)"  [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   400
  "_geAll"   :: "[idt, 'a, bool] => bool"   ("(3ALL _>=_./ _)" [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   401
  "_geEx"    :: "[idt, 'a, bool] => bool"   ("(3EX _>=_./ _)" [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   402
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   403
syntax (xsymbols)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   404
  "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_<_./ _)"  [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   405
  "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_<_./ _)"  [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   406
  "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   407
  "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   408
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   409
  "_gtAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_>_./ _)"  [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   410
  "_gtEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_>_./ _)"  [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   411
  "_geAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<ge>_./ _)" [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   412
  "_geEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<ge>_./ _)" [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   413
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   414
syntax (HOL)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   415
  "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3! _<_./ _)"  [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   416
  "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3? _<_./ _)"  [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   417
  "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3! _<=_./ _)" [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   418
  "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3? _<=_./ _)" [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   419
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   420
syntax (HTML output)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   421
  "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_<_./ _)"  [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   422
  "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_<_./ _)"  [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   423
  "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   424
  "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   425
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   426
  "_gtAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_>_./ _)"  [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   427
  "_gtEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_>_./ _)"  [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   428
  "_geAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<ge>_./ _)" [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   429
  "_geEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<ge>_./ _)" [0, 0, 10] 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   430
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   431
translations
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   432
  "ALL x<y. P"   =>  "ALL x. x < y \<longrightarrow> P"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   433
  "EX x<y. P"    =>  "EX x. x < y \<and> P"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   434
  "ALL x<=y. P"  =>  "ALL x. x <= y \<longrightarrow> P"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   435
  "EX x<=y. P"   =>  "EX x. x <= y \<and> P"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   436
  "ALL x>y. P"   =>  "ALL x. x > y \<longrightarrow> P"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   437
  "EX x>y. P"    =>  "EX x. x > y \<and> P"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   438
  "ALL x>=y. P"  =>  "ALL x. x >= y \<longrightarrow> P"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   439
  "EX x>=y. P"   =>  "EX x. x >= y \<and> P"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   440
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   441
print_translation {*
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   442
let
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   443
  fun mk v v' c n P =
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   444
    if v = v' andalso not (member (op =) (map fst (Term.add_frees n [])) v)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   445
    then Syntax.const c $ Syntax.mark_bound v' $ n $ P else raise Match;
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   446
  fun mk_all "\\<^const>Scratch.less" f =
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   447
        f ("_lessAll", "_gtAll")
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   448
    | mk_all "\\<^const>Scratch.less_eq" f =
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   449
        f ("_leAll", "_geAll")
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   450
  fun mk_ex "\\<^const>Scratch.less" f =
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   451
        f ("_lessEx", "_gtEx")
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   452
    | mk_ex "\\<^const>Scratch.less_eq" f =
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   453
        f ("_leEx", "_geEx");
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   454
  fun tr_all' [Const ("_bound", _) $ Free (v, _), Const("op -->", _)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   455
          $ (Const (c, _) $ (Const ("_bound", _) $ Free (v', _)) $ n) $ P] =
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   456
        mk v v' (mk_all c fst) n P
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   457
    | tr_all' [Const ("_bound", _) $ Free (v, _), Const("op -->", _)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   458
          $ (Const (c, _) $ n $ (Const ("_bound", _) $ Free (v', _))) $ P] =
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   459
        mk v v' (mk_all c snd) n P;
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   460
  fun tr_ex' [Const ("_bound", _) $ Free (v, _), Const("op &", _)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   461
          $ (Const (c, _) $ (Const ("_bound", _) $ Free (v', _)) $ n) $ P] =
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   462
        mk v v' (mk_ex c fst) n P
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   463
    | tr_ex' [Const ("_bound", _) $ Free (v, _), Const("op &", _)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   464
          $ (Const (c, _) $ n $ (Const ("_bound", _) $ Free (v', _))) $ P] =
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   465
        mk v v' (mk_ex c snd) n P;
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   466
in
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   467
  [("ALL ", tr_all'), ("EX ", tr_ex')]
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   468
end
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   469
*}
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   470
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   471
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   472
subsection {* Transitivity reasoning on decreasing inequalities *}
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   473
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   474
text {* These support proving chains of decreasing inequalities
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   475
    a >= b >= c ... in Isar proofs. *}
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   476
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   477
lemma xt1:
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   478
  "a = b ==> b > c ==> a > c"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   479
  "a > b ==> b = c ==> a > c"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   480
  "a = b ==> b >= c ==> a >= c"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   481
  "a >= b ==> b = c ==> a >= c"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   482
  "(x::'a::order) >= y ==> y >= x ==> x = y"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   483
  "(x::'a::order) >= y ==> y >= z ==> x >= z"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   484
  "(x::'a::order) > y ==> y >= z ==> x > z"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   485
  "(x::'a::order) >= y ==> y > z ==> x > z"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   486
  "(a::'a::order) > b ==> b > a ==> ?P"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   487
  "(x::'a::order) > y ==> y > z ==> x > z"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   488
  "(a::'a::order) >= b ==> a ~= b ==> a > b"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   489
  "(a::'a::order) ~= b ==> a >= b ==> a > b"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   490
  "a = f b ==> b > c ==> (!!x y. x > y ==> f x > f y) ==> a > f c" 
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   491
  "a > b ==> f b = c ==> (!!x y. x > y ==> f x > f y) ==> f a > c"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   492
  "a = f b ==> b >= c ==> (!!x y. x >= y ==> f x >= f y) ==> a >= f c"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   493
  "a >= b ==> f b = c ==> (!! x y. x >= y ==> f x >= f y) ==> f a >= c"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   494
by auto
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   495
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   496
lemma xt2:
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   497
  "(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
   498
by (subgoal_tac "f b >= f c", force, force)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   499
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   500
lemma xt3: "(a::'a::order) >= b ==> (f b::'b::order) >= c ==> 
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   501
    (!!x y. x >= y ==> f x >= f y) ==> f a >= c"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   502
by (subgoal_tac "f a >= f b", force, force)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   503
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   504
lemma xt4: "(a::'a::order) > f b ==> (b::'b::order) >= c ==>
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   505
  (!!x y. x >= y ==> f x >= f y) ==> a > f c"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   506
by (subgoal_tac "f b >= f c", force, force)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   507
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   508
lemma xt5: "(a::'a::order) > b ==> (f b::'b::order) >= c==>
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   509
    (!!x y. x > y ==> f x > f y) ==> f a > c"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   510
by (subgoal_tac "f a > f b", force, force)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   511
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   512
lemma xt6: "(a::'a::order) >= f b ==> b > c ==>
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   513
    (!!x y. x > y ==> f x > f y) ==> a > f c"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   514
by (subgoal_tac "f b > f c", force, force)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   515
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   516
lemma xt7: "(a::'a::order) >= b ==> (f b::'b::order) > c ==>
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   517
    (!!x y. x >= y ==> f x >= f y) ==> f a > c"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   518
by (subgoal_tac "f a >= f b", force, force)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   519
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   520
lemma xt8: "(a::'a::order) > f b ==> (b::'b::order) > c ==>
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   521
    (!!x y. x > y ==> f x > f y) ==> a > f c"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   522
by (subgoal_tac "f b > f c", force, force)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   523
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   524
lemma xt9: "(a::'a::order) > b ==> (f b::'b::order) > c ==>
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   525
    (!!x y. x > y ==> f x > f y) ==> f a > c"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   526
by (subgoal_tac "f a > f b", force, force)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   527
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   528
lemmas xtrans = xt1 xt2 xt3 xt4 xt5 xt6 xt7 xt8 xt9
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   529
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   530
(* 
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   531
  Since "a >= b" abbreviates "b <= a", the abbreviation "..." stands
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   532
  for the wrong thing in an Isar proof.
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   533
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   534
  The extra transitivity rules can be used as follows: 
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   535
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   536
lemma "(a::'a::order) > z"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   537
proof -
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   538
  have "a >= b" (is "_ >= ?rhs")
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   539
    sorry
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   540
  also have "?rhs >= c" (is "_ >= ?rhs")
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   541
    sorry
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   542
  also (xtrans) have "?rhs = d" (is "_ = ?rhs")
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   543
    sorry
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   544
  also (xtrans) have "?rhs >= e" (is "_ >= ?rhs")
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   545
    sorry
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   546
  also (xtrans) have "?rhs > f" (is "_ > ?rhs")
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   547
    sorry
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   548
  also (xtrans) have "?rhs > z"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   549
    sorry
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   550
  finally (xtrans) show ?thesis .
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   551
qed
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   552
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   553
  Alternatively, one can use "declare xtrans [trans]" and then
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   554
  leave out the "(xtrans)" above.
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   555
*)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   556
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   557
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   558
subsection {* Least value operator, monotonicity and min/max *}
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   559
 
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   560
(*FIXME: derive more of the min/max laws generically via semilattices*)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   561
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   562
constdefs
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   563
  Least :: "('a::ord => bool) => 'a"               (binder "LEAST " 10)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   564
  "Least P == THE x. P x & (ALL y. P y --> x <= y)"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   565
    -- {* We can no longer use LeastM because the latter requires Hilbert-AC. *}
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   566
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   567
lemma LeastI2_order:
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   568
  "[| P (x::'a::order);
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   569
      !!y. P y ==> x <= y;
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   570
      !!x. [| P x; ALL y. P y --> x \<le> y |] ==> Q x |]
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   571
   ==> Q (Least P)"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   572
  apply (unfold Least_def)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   573
  apply (rule theI2)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   574
    apply (blast intro: order_antisym)+
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   575
  done
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   576
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   577
lemma Least_equality:
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   578
    "[| P (k::'a::order); !!x. P x ==> k <= x |] ==> (LEAST x. P x) = k"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   579
  apply (simp add: Least_def)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   580
  apply (rule the_equality)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   581
  apply (auto intro!: order_antisym)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   582
  done
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   583
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   584
locale mono =
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   585
  fixes f
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   586
  assumes mono: "A <= B ==> f A <= f B"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   587
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   588
lemmas monoI [intro?] = mono.intro
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   589
  and monoD [dest?] = mono.mono
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   590
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   591
constdefs
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   592
  min :: "['a::ord, 'a] => 'a"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   593
  "min a b == (if a <= b then a else b)"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   594
  max :: "['a::ord, 'a] => 'a"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   595
  "max a b == (if a <= b then b else a)"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   596
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   597
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
   598
  apply (simp add: min_def)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   599
  apply (blast intro: order_antisym)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   600
  done
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   601
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   602
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
   603
  apply (simp add: max_def)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   604
  apply (blast intro: order_antisym)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   605
  done
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   606
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   607
lemma min_leastL: "(!!x. least <= x) ==> min least x = least"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   608
  by (simp add: min_def)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   609
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   610
lemma max_leastL: "(!!x. least <= x) ==> max least x = x"
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   611
  by (simp add: max_def)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   612
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   613
lemma min_of_mono:
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   614
    "(!!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
   615
  by (simp add: min_def)
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   616
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   617
lemma max_of_mono:
a1de02f047d0 cleaned up
haftmann
parents: 21044
diff changeset
   618
    "(!!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
   619
  by (simp add: max_def)
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   620
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   621
text{* Instantiate locales: *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   622
15837
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15822
diff changeset
   623
interpretation min_max:
15780
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   624
  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
   625
apply unfold_locales
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   626
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
   627
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
   628
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
   629
done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   630
15837
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15822
diff changeset
   631
interpretation min_max:
15780
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   632
  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
   633
apply unfold_locales
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   634
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
   635
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
   636
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
   637
done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   638
15837
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15822
diff changeset
   639
interpretation min_max:
15780
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   640
  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
   641
  by unfold_locales
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   642
15837
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15822
diff changeset
   643
interpretation min_max:
15780
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   644
  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
   645
apply unfold_locales
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   646
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
   647
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
   648
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
   649
apply(simp add:min_def max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   650
apply(simp add:min_def max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   651
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
   652
apply(simp add:min_def max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   653
apply(simp add:min_def max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   654
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
   655
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
   656
apply(simp add:min_def max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   657
apply(simp add:min_def max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   658
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
   659
apply(simp add:min_def max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   660
apply(simp add:min_def max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   661
done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   662
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   663
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
   664
  apply(simp add:max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   665
  apply (insert linorder_linear)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   666
  apply (blast intro: order_trans)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   667
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   668
15780
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   669
lemmas le_maxI1 = min_max.sup_ge1
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   670
lemmas le_maxI2 = min_max.sup_ge2
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   671
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   672
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
   673
  apply (simp add: max_def order_le_less)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   674
  apply (insert linorder_less_linear)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   675
  apply (blast intro: order_less_trans)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   676
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   677
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   678
lemma max_less_iff_conj [simp]:
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   679
    "!!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
   680
  apply (simp add: order_le_less max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   681
  apply (insert linorder_less_linear)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   682
  apply (blast intro: order_less_trans)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   683
  done
15791
446ec11266be tuning locales
nipkow
parents: 15780
diff changeset
   684
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   685
lemma min_less_iff_conj [simp]:
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   686
    "!!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
   687
  apply (simp add: order_le_less min_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   688
  apply (insert linorder_less_linear)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   689
  apply (blast intro: order_less_trans)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   690
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   691
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   692
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
   693
  apply (simp add: min_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   694
  apply (insert linorder_linear)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   695
  apply (blast intro: order_trans)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   696
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   697
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   698
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
   699
  apply (simp add: min_def order_le_less)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   700
  apply (insert linorder_less_linear)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   701
  apply (blast intro: order_less_trans)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   702
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   703
15780
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   704
lemmas max_ac = min_max.sup_assoc min_max.sup_commute
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   705
               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
   706
15780
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   707
lemmas min_ac = min_max.inf_assoc min_max.inf_commute
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   708
               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
   709
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   710
lemma split_min:
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   711
    "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
   712
  by (simp add: min_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   713
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   714
lemma split_max:
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   715
    "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
   716
  by (simp add: max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   717
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   718
end