src/HOL/Orderings.thy
author wenzelm
Tue, 16 May 2006 21:33:01 +0200
changeset 19656 09be06943252
parent 19637 d33a71ffb9e3
child 19931 fb32b43e7f80
permissions -rw-r--r--
tuned concrete syntax -- abbreviation/const_syntax;
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
FIXME: derive more of the min/max laws generically via semilattices
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
     6
*)
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
header {* Type classes for $\le$ *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
     9
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    10
theory Orderings
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    11
imports Lattice_Locales
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 16121
diff changeset
    12
uses ("antisym_setup.ML")
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    13
begin
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    14
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    15
subsection {* Order signatures and orders *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    16
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    17
axclass
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    18
  ord < type
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    19
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    20
consts
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19637
diff changeset
    21
  less  :: "['a::ord, 'a] => bool"
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19637
diff changeset
    22
  less_eq  :: "['a::ord, 'a] => bool"
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    23
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19637
diff changeset
    24
const_syntax
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19637
diff changeset
    25
  less  ("op <")
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19637
diff changeset
    26
  less  ("(_/ < _)"  [50, 51] 50)
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19637
diff changeset
    27
  less_eq  ("op <=")
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19637
diff changeset
    28
  less_eq  ("(_/ <= _)" [50, 51] 50)
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    29
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19637
diff changeset
    30
const_syntax (xsymbols)
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19637
diff changeset
    31
  less_eq  ("op \<le>")
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19637
diff changeset
    32
  less_eq  ("(_/ \<le> _)"  [50, 51] 50)
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19637
diff changeset
    33
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19637
diff changeset
    34
const_syntax (HTML output)
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19637
diff changeset
    35
  less_eq  ("op \<le>")
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19637
diff changeset
    36
  less_eq  ("(_/ \<le> _)"  [50, 51] 50)
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    37
19536
1a3a3cf8b4fa replaced syntax/translations by abbreviation;
wenzelm
parents: 19527
diff changeset
    38
abbreviation (input)
1a3a3cf8b4fa replaced syntax/translations by abbreviation;
wenzelm
parents: 19527
diff changeset
    39
  greater  (infixl ">" 50)
1a3a3cf8b4fa replaced syntax/translations by abbreviation;
wenzelm
parents: 19527
diff changeset
    40
  "x > y == y < x"
1a3a3cf8b4fa replaced syntax/translations by abbreviation;
wenzelm
parents: 19527
diff changeset
    41
  greater_eq  (infixl ">=" 50)
1a3a3cf8b4fa replaced syntax/translations by abbreviation;
wenzelm
parents: 19527
diff changeset
    42
  "x >= y == y <= x"
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    43
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19637
diff changeset
    44
const_syntax (xsymbols)
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19637
diff changeset
    45
  greater_eq  (infixl "\<ge>" 50)
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    46
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    47
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    48
subsection {* Monotonicity *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    49
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    50
locale mono =
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    51
  fixes f
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    52
  assumes mono: "A <= B ==> f A <= f B"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    53
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    54
lemmas monoI [intro?] = mono.intro
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    55
  and monoD [dest?] = mono.mono
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    56
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    57
constdefs
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    58
  min :: "['a::ord, 'a] => 'a"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    59
  "min a b == (if a <= b then a else b)"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    60
  max :: "['a::ord, 'a] => 'a"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    61
  "max a b == (if a <= b then b else a)"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    62
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    63
lemma min_leastL: "(!!x. least <= x) ==> min least x = least"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    64
  by (simp add: min_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    65
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    66
lemma min_of_mono:
19527
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19277
diff changeset
    67
    "(!!x y. (f x <= f y) = (x <= y)) ==> min (f m) (f n) = f (min m n)"
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    68
  by (simp add: min_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    69
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    70
lemma max_leastL: "(!!x. least <= x) ==> max least x = x"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    71
  by (simp add: max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    72
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    73
lemma max_of_mono:
19527
9b5c38e8e780 some facts about min, max and add, diff
paulson
parents: 19277
diff changeset
    74
    "(!!x y. (f x <= f y) = (x <= y)) ==> max (f m) (f n) = f (max m n)"
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    75
  by (simp add: max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    76
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    77
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    78
subsection "Orders"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    79
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    80
axclass order < ord
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    81
  order_refl [iff]: "x <= x"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    82
  order_trans: "x <= y ==> y <= z ==> x <= z"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    83
  order_antisym: "x <= y ==> y <= x ==> x = y"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    84
  order_less_le: "(x < y) = (x <= y & x ~= y)"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    85
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    86
text{* Connection to locale: *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    87
15837
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15822
diff changeset
    88
interpretation order:
15780
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
    89
  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
    90
apply(rule partial_order.intro)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    91
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
    92
done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    93
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    94
text {* Reflexivity. *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    95
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    96
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
    97
    -- {* This form is useful with the classical reasoner. *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    98
  apply (erule ssubst)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
    99
  apply (rule order_refl)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   100
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   101
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   102
lemma order_less_irrefl [iff]: "~ x < (x::'a::order)"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   103
  by (simp add: order_less_le)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   104
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   105
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
   106
    -- {* NOT suitable for iff, since it can cause PROOF FAILED. *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   107
  apply (simp add: order_less_le, blast)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   108
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   109
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   110
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
   111
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   112
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
   113
  by (simp add: order_less_le)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   114
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   115
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   116
text {* Asymmetry. *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   117
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   118
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
   119
  by (simp add: order_less_le order_antisym)
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_less_asym: "x < (y::'a::order) ==> (~P ==> y < x) ==> P"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   122
  apply (drule order_less_not_sym)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   123
  apply (erule contrapos_np, simp)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   124
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   125
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   126
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
   127
by (blast intro: order_antisym)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   128
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   129
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
   130
by(blast intro:order_antisym)
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
text {* Transitivity. *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   133
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   134
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
   135
  apply (simp add: order_less_le)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   136
  apply (blast intro: order_trans order_antisym)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   137
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   138
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   139
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
   140
  apply (simp add: order_less_le)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   141
  apply (blast intro: order_trans order_antisym)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   142
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   143
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   144
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
   145
  apply (simp add: order_less_le)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   146
  apply (blast intro: order_trans order_antisym)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   147
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   148
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   149
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
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   164
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   165
text {* Other operators. *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   166
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   167
lemma min_leastR: "(!!x::'a::order. least <= x) ==> min x least = least"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   168
  apply (simp add: min_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   169
  apply (blast intro: order_antisym)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   170
  done
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 max_leastR: "(!!x::'a::order. least <= x) ==> max x least = x"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   173
  apply (simp add: max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   174
  apply (blast intro: order_antisym)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   175
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   176
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   177
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   178
subsection {* Transitivity rules for calculational reasoning *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   179
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   180
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   181
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
   182
  by (simp add: order_less_le)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   183
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   184
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
   185
  by (simp add: order_less_le)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   186
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   187
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
   188
  by (rule order_less_asym)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   189
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   190
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   191
subsection {* Least value operator *}
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
constdefs
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   194
  Least :: "('a::ord => bool) => 'a"               (binder "LEAST " 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   195
  "Least P == THE x. P x & (ALL y. P y --> x <= y)"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   196
    -- {* We can no longer use LeastM because the latter requires Hilbert-AC. *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   197
15950
5c067c956a20 Added thms by Brian Huffmann
nipkow
parents: 15837
diff changeset
   198
lemma LeastI2_order:
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   199
  "[| P (x::'a::order);
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   200
      !!y. P y ==> x <= y;
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   201
      !!x. [| P x; ALL y. P y --> x \<le> y |] ==> Q x |]
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   202
   ==> Q (Least P)"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   203
  apply (unfold Least_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   204
  apply (rule theI2)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   205
    apply (blast intro: order_antisym)+
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   206
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   207
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   208
lemma Least_equality:
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   209
    "[| P (k::'a::order); !!x. P x ==> k <= x |] ==> (LEAST x. P x) = k"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   210
  apply (simp add: Least_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   211
  apply (rule the_equality)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   212
  apply (auto intro!: order_antisym)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   213
  done
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
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   216
subsection "Linear / total orders"
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
axclass linorder < order
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   219
  linorder_linear: "x <= y | y <= x"
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_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
   222
  apply (simp add: order_less_le)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   223
  apply (insert linorder_linear, blast)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   224
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   225
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   226
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
   227
  by (simp add: order_le_less linorder_less_linear)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   228
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   229
lemma linorder_le_cases [case_names le ge]:
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   230
    "((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
   231
  by (insert linorder_linear, blast)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   232
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   233
lemma linorder_cases [case_names less equal greater]:
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   234
    "((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
   235
  by (insert linorder_less_linear, blast)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   236
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   237
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
   238
  apply (simp add: order_less_le)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   239
  apply (insert linorder_linear)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   240
  apply (blast intro: order_antisym)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   241
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   242
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   243
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
   244
  apply (simp add: order_less_le)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   245
  apply (insert linorder_linear)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   246
  apply (blast intro: order_antisym)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   247
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   248
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   249
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
   250
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
   251
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   252
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
   253
by (simp add: linorder_neq_iff, blast)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   254
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   255
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
   256
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
   257
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   258
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
   259
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
   260
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   261
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
   262
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
   263
16796
140f1e0ea846 generlization of some "nat" theorems
paulson
parents: 16743
diff changeset
   264
text{*Replacing the old Nat.leI*}
140f1e0ea846 generlization of some "nat" theorems
paulson
parents: 16743
diff changeset
   265
lemma leI: "~ x < y ==> y <= (x::'a::linorder)"
140f1e0ea846 generlization of some "nat" theorems
paulson
parents: 16743
diff changeset
   266
  by (simp only: linorder_not_less)
140f1e0ea846 generlization of some "nat" theorems
paulson
parents: 16743
diff changeset
   267
140f1e0ea846 generlization of some "nat" theorems
paulson
parents: 16743
diff changeset
   268
lemma leD: "y <= (x::'a::linorder) ==> ~ x < y"
140f1e0ea846 generlization of some "nat" theorems
paulson
parents: 16743
diff changeset
   269
  by (simp only: linorder_not_less)
140f1e0ea846 generlization of some "nat" theorems
paulson
parents: 16743
diff changeset
   270
140f1e0ea846 generlization of some "nat" theorems
paulson
parents: 16743
diff changeset
   271
(*FIXME inappropriate name (or delete altogether)*)
140f1e0ea846 generlization of some "nat" theorems
paulson
parents: 16743
diff changeset
   272
lemma not_leE: "~ y <= (x::'a::linorder) ==> x < y"
140f1e0ea846 generlization of some "nat" theorems
paulson
parents: 16743
diff changeset
   273
  by (simp only: linorder_not_le)
140f1e0ea846 generlization of some "nat" theorems
paulson
parents: 16743
diff changeset
   274
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   275
use "antisym_setup.ML";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   276
setup antisym_setup
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   277
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   278
subsection {* Setup of transitivity reasoner as Solver *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   279
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   280
lemma less_imp_neq: "[| (x::'a::order) < y |] ==> x ~= y"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   281
  by (erule contrapos_pn, erule subst, rule order_less_irrefl)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   282
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   283
lemma eq_neq_eq_imp_neq: "[| x = a ; a ~= b; b = y |] ==> x ~= y"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   284
  by (erule subst, erule ssubst, assumption)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   285
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   286
ML_setup {*
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   287
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   288
(* 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
   289
   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
   290
   Quasi_Tac.quasi_tac are not of much use. *)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   291
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   292
fun decomp_gen sort sign (Trueprop $ t) =
15622
4723248c982b Transitivity reasoner ignores types amenable to linear arithmetic.
ballarin
parents: 15531
diff changeset
   293
  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
   294
        (* exclude numeric types: linear arithmetic subsumes transitivity *)
4723248c982b Transitivity reasoner ignores types amenable to linear arithmetic.
ballarin
parents: 15531
diff changeset
   295
        T <> HOLogic.natT andalso T <> HOLogic.intT andalso
4723248c982b Transitivity reasoner ignores types amenable to linear arithmetic.
ballarin
parents: 15531
diff changeset
   296
        T <> HOLogic.realT andalso Sign.of_sort sign (T, sort) end
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   297
  fun dec (Const ("Not", _) $ t) = (
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   298
	  case dec t of
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   299
	    NONE => NONE
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   300
	  | SOME (t1, rel, t2) => SOME (t1, "~" ^ rel, t2))
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   301
	| dec (Const ("op =",  _) $ t1 $ t2) =
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   302
	    if of_sort t1
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   303
	    then SOME (t1, "=", t2)
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   304
	    else NONE
19277
f7602e74d948 renamed op < <= to Orderings.less(_eq)
haftmann
parents: 19039
diff changeset
   305
	| dec (Const ("Orderings.less_eq",  _) $ t1 $ t2) =
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   306
	    if of_sort t1
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   307
	    then SOME (t1, "<=", t2)
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   308
	    else NONE
19277
f7602e74d948 renamed op < <= to Orderings.less(_eq)
haftmann
parents: 19039
diff changeset
   309
	| dec (Const ("Orderings.less",  _) $ t1 $ t2) =
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   310
	    if of_sort t1
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   311
	    then SOME (t1, "<", t2)
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   312
	    else NONE
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15524
diff changeset
   313
	| dec _ = NONE
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   314
  in dec t end;
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   315
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   316
structure Quasi_Tac = Quasi_Tac_Fun (
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   317
  struct
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   318
    val le_trans = thm "order_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   319
    val le_refl = thm "order_refl";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   320
    val eqD1 = thm "order_eq_refl";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   321
    val eqD2 = thm "sym" RS thm "order_eq_refl";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   322
    val less_reflE = thm "order_less_irrefl" RS thm "notE";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   323
    val less_imp_le = thm "order_less_imp_le";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   324
    val le_neq_trans = thm "order_le_neq_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   325
    val neq_le_trans = thm "order_neq_le_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   326
    val less_imp_neq = thm "less_imp_neq";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   327
    val decomp_trans = decomp_gen ["Orderings.order"];
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   328
    val decomp_quasi = decomp_gen ["Orderings.order"];
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   329
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   330
  end);  (* struct *)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   331
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   332
structure Order_Tac = Order_Tac_Fun (
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   333
  struct
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   334
    val less_reflE = thm "order_less_irrefl" RS thm "notE";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   335
    val le_refl = thm "order_refl";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   336
    val less_imp_le = thm "order_less_imp_le";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   337
    val not_lessI = thm "linorder_not_less" RS thm "iffD2";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   338
    val not_leI = thm "linorder_not_le" RS thm "iffD2";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   339
    val not_lessD = thm "linorder_not_less" RS thm "iffD1";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   340
    val not_leD = thm "linorder_not_le" RS thm "iffD1";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   341
    val eqI = thm "order_antisym";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   342
    val eqD1 = thm "order_eq_refl";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   343
    val eqD2 = thm "sym" RS thm "order_eq_refl";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   344
    val less_trans = thm "order_less_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   345
    val less_le_trans = thm "order_less_le_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   346
    val le_less_trans = thm "order_le_less_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   347
    val le_trans = thm "order_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   348
    val le_neq_trans = thm "order_le_neq_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   349
    val neq_le_trans = thm "order_neq_le_trans";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   350
    val less_imp_neq = thm "less_imp_neq";
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   351
    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
   352
    val not_sym = thm "not_sym";
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   353
    val decomp_part = decomp_gen ["Orderings.order"];
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   354
    val decomp_lin = decomp_gen ["Orderings.linorder"];
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   355
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   356
  end);  (* struct *)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   357
17876
b9c92f384109 change_claset/simpset;
wenzelm
parents: 17012
diff changeset
   358
change_simpset (fn ss => ss
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   359
    addSolver (mk_solver "Trans_linear" (fn _ => Order_Tac.linear_tac))
17876
b9c92f384109 change_claset/simpset;
wenzelm
parents: 17012
diff changeset
   360
    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
   361
  (* 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
   362
     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
   363
     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
   364
     of 5 March 2004, was observed). *)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   365
*}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   366
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   367
(* Optional setup of methods *)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   368
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   369
(*
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   370
method_setup trans_partial =
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   371
  {* 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
   372
  {* transitivity reasoner for partial orders *}	
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   373
method_setup trans_linear =
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   374
  {* 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
   375
  {* transitivity reasoner for linear orders *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   376
*)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   377
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   378
(*
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   379
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
   380
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   381
can currently not be removed, abel_cancel relies on it.
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
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   385
subsection "Min and max on (linear) orders"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   386
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   387
text{* Instantiate locales: *}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   388
15837
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15822
diff changeset
   389
interpretation min_max:
15780
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   390
  lower_semilattice["op \<le>" "min :: 'a::linorder \<Rightarrow> 'a \<Rightarrow> 'a"]
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   391
apply(rule lower_semilattice_axioms.intro)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   392
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
   393
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
   394
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
   395
done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   396
15837
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15822
diff changeset
   397
interpretation min_max:
15780
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   398
  upper_semilattice["op \<le>" "max :: 'a::linorder \<Rightarrow> 'a \<Rightarrow> 'a"]
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   399
apply -
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   400
apply(rule upper_semilattice_axioms.intro)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   401
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
   402
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
   403
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
   404
done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   405
15837
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15822
diff changeset
   406
interpretation min_max:
15780
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   407
  lattice["op \<le>" "min :: 'a::linorder \<Rightarrow> 'a \<Rightarrow> 'a" "max"]
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   408
.
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   409
15837
7a567dcd4cda Subsumption of locale interpretations.
ballarin
parents: 15822
diff changeset
   410
interpretation min_max:
15780
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   411
  distrib_lattice["op \<le>" "min :: 'a::linorder \<Rightarrow> 'a \<Rightarrow> 'a" "max"]
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   412
apply(rule distrib_lattice_axioms.intro)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   413
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
   414
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
   415
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
   416
apply(simp add:min_def max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   417
apply(simp add:min_def max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   418
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
   419
apply(simp add:min_def max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   420
apply(simp add:min_def max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   421
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
   422
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
   423
apply(simp add:min_def max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   424
apply(simp add:min_def max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   425
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
   426
apply(simp add:min_def max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   427
apply(simp add:min_def max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   428
done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   429
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   430
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
   431
  apply(simp add:max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   432
  apply (insert linorder_linear)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   433
  apply (blast intro: order_trans)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   434
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   435
15780
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   436
lemmas le_maxI1 = min_max.sup_ge1
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   437
lemmas le_maxI2 = min_max.sup_ge2
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   438
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   439
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
   440
  apply (simp add: max_def order_le_less)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   441
  apply (insert linorder_less_linear)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   442
  apply (blast intro: order_less_trans)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   443
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   444
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   445
lemma max_less_iff_conj [simp]:
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   446
    "!!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
   447
  apply (simp add: order_le_less max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   448
  apply (insert linorder_less_linear)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   449
  apply (blast intro: order_less_trans)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   450
  done
15791
446ec11266be tuning locales
nipkow
parents: 15780
diff changeset
   451
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   452
lemma min_less_iff_conj [simp]:
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   453
    "!!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
   454
  apply (simp add: order_le_less min_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   455
  apply (insert linorder_less_linear)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   456
  apply (blast intro: order_less_trans)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   457
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   458
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   459
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
   460
  apply (simp add: min_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   461
  apply (insert linorder_linear)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   462
  apply (blast intro: order_trans)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   463
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   464
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   465
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
   466
  apply (simp add: min_def order_le_less)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   467
  apply (insert linorder_less_linear)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   468
  apply (blast intro: order_less_trans)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   469
  done
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   470
15780
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   471
lemmas max_ac = min_max.sup_assoc min_max.sup_commute
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   472
               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
   473
15780
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   474
lemmas min_ac = min_max.inf_assoc min_max.inf_commute
6744bba5561d Used locale interpretations everywhere.
nipkow
parents: 15622
diff changeset
   475
               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
   476
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   477
lemma split_min:
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   478
    "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
   479
  by (simp add: min_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   480
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   481
lemma split_max:
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   482
    "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
   483
  by (simp add: max_def)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   484
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   485
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   486
subsection "Bounded quantifiers"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   487
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   488
syntax
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   489
  "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3ALL _<_./ _)"  [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   490
  "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3EX _<_./ _)"  [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   491
  "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3ALL _<=_./ _)" [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   492
  "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3EX _<=_./ _)" [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   493
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   494
  "_gtAll" :: "[idt, 'a, bool] => bool"   ("(3ALL _>_./ _)"  [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   495
  "_gtEx"  :: "[idt, 'a, bool] => bool"   ("(3EX _>_./ _)"  [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   496
  "_geAll"   :: "[idt, 'a, bool] => bool"   ("(3ALL _>=_./ _)" [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   497
  "_geEx"    :: "[idt, 'a, bool] => bool"   ("(3EX _>=_./ _)" [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   498
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   499
syntax (xsymbols)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   500
  "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_<_./ _)"  [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   501
  "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_<_./ _)"  [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   502
  "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   503
  "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   504
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   505
  "_gtAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_>_./ _)"  [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   506
  "_gtEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_>_./ _)"  [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   507
  "_geAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<ge>_./ _)" [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   508
  "_geEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<ge>_./ _)" [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   509
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   510
syntax (HOL)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   511
  "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3! _<_./ _)"  [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   512
  "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3? _<_./ _)"  [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   513
  "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3! _<=_./ _)" [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   514
  "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3? _<=_./ _)" [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   515
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   516
syntax (HTML output)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   517
  "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_<_./ _)"  [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   518
  "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_<_./ _)"  [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   519
  "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   520
  "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   521
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   522
  "_gtAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_>_./ _)"  [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   523
  "_gtEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_>_./ _)"  [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   524
  "_geAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<ge>_./ _)" [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   525
  "_geEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<ge>_./ _)" [0, 0, 10] 10)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   526
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   527
translations
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   528
 "ALL x<y. P"   =>  "ALL x. x < y --> P"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   529
 "EX x<y. P"    =>  "EX x. x < y  & P"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   530
 "ALL x<=y. P"  =>  "ALL x. x <= y --> P"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   531
 "EX x<=y. P"   =>  "EX x. x <= y & P"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   532
 "ALL x>y. P"   =>  "ALL x. x > y --> P"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   533
 "EX x>y. P"    =>  "EX x. x > y  & P"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   534
 "ALL x>=y. P"  =>  "ALL x. x >= y --> P"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   535
 "EX x>=y. P"   =>  "EX x. x >= y & P"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   536
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   537
print_translation {*
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   538
let
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   539
  fun mk v v' q n P =
16861
7446b4be013b tuned fold on terms;
wenzelm
parents: 16796
diff changeset
   540
    if v=v' andalso not (v mem (map fst (Term.add_frees n [])))
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   541
    then Syntax.const q $ Syntax.mark_bound v' $ n $ P else raise Match;
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   542
  fun all_tr' [Const ("_bound",_) $ Free (v,_),
19637
d33a71ffb9e3 reactivated translations for less/less_eq;
wenzelm
parents: 19536
diff changeset
   543
               Const("op -->",_) $ (Const ("less",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] =
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   544
    mk v v' "_lessAll" n P
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   545
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   546
  | all_tr' [Const ("_bound",_) $ Free (v,_),
19637
d33a71ffb9e3 reactivated translations for less/less_eq;
wenzelm
parents: 19536
diff changeset
   547
               Const("op -->",_) $ (Const ("less_eq",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] =
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   548
    mk v v' "_leAll" n P
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   549
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   550
  | all_tr' [Const ("_bound",_) $ Free (v,_),
19637
d33a71ffb9e3 reactivated translations for less/less_eq;
wenzelm
parents: 19536
diff changeset
   551
               Const("op -->",_) $ (Const ("less",_) $ n $ (Const ("_bound",_) $ Free (v',_))) $ P] =
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   552
    mk v v' "_gtAll" n P
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   553
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   554
  | all_tr' [Const ("_bound",_) $ Free (v,_),
19637
d33a71ffb9e3 reactivated translations for less/less_eq;
wenzelm
parents: 19536
diff changeset
   555
               Const("op -->",_) $ (Const ("less_eq",_) $ n $ (Const ("_bound",_) $ Free (v',_))) $ P] =
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   556
    mk v v' "_geAll" n P;
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   557
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   558
  fun ex_tr' [Const ("_bound",_) $ Free (v,_),
19637
d33a71ffb9e3 reactivated translations for less/less_eq;
wenzelm
parents: 19536
diff changeset
   559
               Const("op &",_) $ (Const ("less",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] =
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   560
    mk v v' "_lessEx" n P
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   561
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   562
  | ex_tr' [Const ("_bound",_) $ Free (v,_),
19637
d33a71ffb9e3 reactivated translations for less/less_eq;
wenzelm
parents: 19536
diff changeset
   563
               Const("op &",_) $ (Const ("less_eq",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] =
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   564
    mk v v' "_leEx" n P
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   565
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   566
  | ex_tr' [Const ("_bound",_) $ Free (v,_),
19637
d33a71ffb9e3 reactivated translations for less/less_eq;
wenzelm
parents: 19536
diff changeset
   567
               Const("op &",_) $ (Const ("less",_) $ n $ (Const ("_bound",_) $ Free (v',_))) $ P] =
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   568
    mk v v' "_gtEx" n P
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   569
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   570
  | ex_tr' [Const ("_bound",_) $ Free (v,_),
19637
d33a71ffb9e3 reactivated translations for less/less_eq;
wenzelm
parents: 19536
diff changeset
   571
               Const("op &",_) $ (Const ("less_eq",_) $ n $ (Const ("_bound",_) $ Free (v',_))) $ P] =
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   572
    mk v v' "_geEx" n P
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   573
in
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   574
[("ALL ", all_tr'), ("EX ", ex_tr')]
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   575
end
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   576
*}
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   577
17012
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   578
subsection {* Extra transitivity rules *}
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   579
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   580
text {* These support proving chains of decreasing inequalities
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   581
    a >= b >= c ... in Isar proofs. *}
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   582
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   583
lemma xt1: "a = b ==> b > c ==> a > c"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   584
by simp
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   585
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   586
lemma xt2: "a > b ==> b = c ==> a > c"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   587
by simp
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   588
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   589
lemma xt3: "a = b ==> b >= c ==> a >= c"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   590
by simp
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   591
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   592
lemma xt4: "a >= b ==> b = c ==> a >= c"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   593
by simp
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   594
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   595
lemma xt5: "(x::'a::order) >= y ==> y >= x ==> x = y"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   596
by simp
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   597
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   598
lemma xt6: "(x::'a::order) >= y ==> y >= z ==> x >= z"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   599
by simp
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   600
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   601
lemma xt7: "(x::'a::order) > y ==> y >= z ==> x > z"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   602
by simp
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   603
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   604
lemma xt8: "(x::'a::order) >= y ==> y > z ==> x > z"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   605
by simp
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   606
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   607
lemma xt9: "(a::'a::order) > b ==> b > a ==> ?P"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   608
by simp
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   609
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   610
lemma xt10: "(x::'a::order) > y ==> y > z ==> x > z"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   611
by simp
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   612
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   613
lemma xt11: "(a::'a::order) >= b ==> a ~= b ==> a > b"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   614
by simp
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   615
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   616
lemma xt12: "(a::'a::order) ~= b ==> a >= b ==> a > b"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   617
by simp
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   618
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   619
lemma xt13: "a = f b ==> b > c ==> (!!x y. x > y ==> f x > f y) ==>
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   620
    a > f c" 
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   621
by simp
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   622
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   623
lemma xt14: "a > b ==> f b = c ==> (!!x y. x > y ==> f x > f y) ==>
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   624
    f a > c"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   625
by auto
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   626
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   627
lemma xt15: "a = f b ==> b >= c ==> (!!x y. x >= y ==> f x >= f y) ==>
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   628
    a >= f c"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   629
by simp
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   630
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   631
lemma xt16: "a >= b ==> f b = c ==> (!! x y. x >= y ==> f x >= f y) ==>
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   632
    f a >= c"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   633
by auto
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   634
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   635
lemma xt17: "(a::'a::order) >= f b ==> b >= c ==> 
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   636
    (!!x y. x >= y ==> f x >= f y) ==> a >= f c"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   637
by (subgoal_tac "f b >= f c", force, force)
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   638
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   639
lemma xt18: "(a::'a::order) >= b ==> (f b::'b::order) >= c ==> 
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   640
    (!!x y. x >= y ==> f x >= f y) ==> f a >= c"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   641
by (subgoal_tac "f a >= f b", force, force)
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   642
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   643
lemma xt19: "(a::'a::order) > f b ==> (b::'b::order) >= c ==>
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   644
  (!!x y. x >= y ==> f x >= f y) ==> a > f c"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   645
by (subgoal_tac "f b >= f c", force, force)
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   646
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   647
lemma xt20: "(a::'a::order) > b ==> (f b::'b::order) >= c==>
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   648
    (!!x y. x > y ==> f x > f y) ==> f a > c"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   649
by (subgoal_tac "f a > f b", force, force)
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   650
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   651
lemma xt21: "(a::'a::order) >= f b ==> b > c ==>
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   652
    (!!x y. x > y ==> f x > f y) ==> a > f c"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   653
by (subgoal_tac "f b > f c", force, force)
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   654
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   655
lemma xt22: "(a::'a::order) >= b ==> (f b::'b::order) > c ==>
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   656
    (!!x y. x >= y ==> f x >= f y) ==> f a > c"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   657
by (subgoal_tac "f a >= f b", force, force)
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   658
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   659
lemma xt23: "(a::'a::order) > f b ==> (b::'b::order) > c ==>
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   660
    (!!x y. x > y ==> f x > f y) ==> a > f c"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   661
by (subgoal_tac "f b > f c", force, force)
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   662
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   663
lemma xt24: "(a::'a::order) > b ==> (f b::'b::order) > c ==>
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   664
    (!!x y. x > y ==> f x > f y) ==> f a > c"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   665
by (subgoal_tac "f a > f b", force, force)
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   666
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   667
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   668
lemmas xtrans = xt1 xt2 xt3 xt4 xt5 xt6 xt7 xt8 xt9 xt10 xt11 xt12
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   669
    xt13 xt14 xt15 xt15 xt17 xt18 xt19 xt20 xt21 xt22 xt23 xt24
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   670
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   671
(* 
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   672
  Since "a >= b" abbreviates "b <= a", the abbreviation "..." stands
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   673
  for the wrong thing in an Isar proof.
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   674
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   675
  The extra transitivity rules can be used as follows: 
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   676
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   677
lemma "(a::'a::order) > z"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   678
proof -
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   679
  have "a >= b" (is "_ >= ?rhs")
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   680
    sorry
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   681
  also have "?rhs >= c" (is "_ >= ?rhs")
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   682
    sorry
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   683
  also (xtrans) have "?rhs = d" (is "_ = ?rhs")
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   684
    sorry
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   685
  also (xtrans) have "?rhs >= e" (is "_ >= ?rhs")
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   686
    sorry
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   687
  also (xtrans) have "?rhs > f" (is "_ > ?rhs")
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   688
    sorry
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   689
  also (xtrans) have "?rhs > z"
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   690
    sorry
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   691
  finally (xtrans) show ?thesis .
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   692
qed
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   693
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   694
  Alternatively, one can use "declare xtrans [trans]" and then
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   695
  leave out the "(xtrans)" above.
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   696
*)
036c46df9576 added extra transitivity rules
avigad
parents: 16861
diff changeset
   697
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
diff changeset
   698
end