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