src/HOL/Orderings.thy
author haftmann
Sat Feb 10 09:26:14 2007 +0100 (2007-02-10)
changeset 22295 5f8a2898668c
parent 22206 8cc04341de38
child 22316 f662831459de
permissions -rw-r--r--
changed name of interpretation linorder to order
     1 (*  Title:      HOL/Orderings.thy
     2     ID:         $Id$
     3     Author:     Tobias Nipkow, Markus Wenzel, and Larry Paulson
     4 *)
     5 
     6 header {* Syntactic and abstract orders *}
     7 
     8 theory Orderings
     9 imports HOL
    10 begin
    11 
    12 subsection {* Order syntax *}
    13 
    14 class ord =
    15   fixes less_eq :: "'a \<Rightarrow> 'a \<Rightarrow> bool"  (infix "\<sqsubseteq>" 50)
    16     and less :: "'a \<Rightarrow> 'a \<Rightarrow> bool"  (infix "\<sqsubset>" 50)
    17 begin
    18 
    19 notation
    20   less_eq  ("op \<^loc><=") and
    21   less_eq  ("(_/ \<^loc><= _)" [51, 51] 50) and
    22   less  ("op \<^loc><") and
    23   less  ("(_/ \<^loc>< _)"  [51, 51] 50)
    24   
    25 notation (xsymbols)
    26   less_eq  ("op \<^loc>\<le>") and
    27   less_eq  ("(_/ \<^loc>\<le> _)"  [51, 51] 50)
    28 
    29 notation (HTML output)
    30   less_eq  ("op \<^loc>\<le>") and
    31   less_eq  ("(_/ \<^loc>\<le> _)"  [51, 51] 50)
    32 
    33 abbreviation (input)
    34   greater  (infix "\<^loc>>" 50) where
    35   "x \<^loc>> y \<equiv> y \<^loc>< x"
    36 
    37 abbreviation (input)
    38   greater_eq  (infix "\<^loc>>=" 50) where
    39   "x \<^loc>>= y \<equiv> y \<^loc><= x"
    40 
    41 notation (input)
    42   greater_eq  (infix "\<^loc>\<ge>" 50)
    43 
    44 end
    45 
    46 notation
    47   less_eq  ("op <=") and
    48   less_eq  ("(_/ <= _)" [51, 51] 50) and
    49   less  ("op <") and
    50   less  ("(_/ < _)"  [51, 51] 50)
    51   
    52 notation (xsymbols)
    53   less_eq  ("op \<le>") and
    54   less_eq  ("(_/ \<le> _)"  [51, 51] 50)
    55 
    56 notation (HTML output)
    57   less_eq  ("op \<le>") and
    58   less_eq  ("(_/ \<le> _)"  [51, 51] 50)
    59 
    60 abbreviation (input)
    61   greater  (infix ">" 50) where
    62   "x > y \<equiv> y < x"
    63 
    64 abbreviation (input)
    65   greater_eq  (infix ">=" 50) where
    66   "x >= y \<equiv> y <= x"
    67 
    68 notation (input)
    69   greater_eq  (infix "\<ge>" 50)
    70 
    71 
    72 subsection {* Quasiorders (preorders) *}
    73 
    74 locale preorder = ord +
    75   assumes refl [iff]: "x \<sqsubseteq> x"
    76   and trans: "x \<sqsubseteq> y \<Longrightarrow> y \<sqsubseteq> z \<Longrightarrow> x \<sqsubseteq> z"
    77   and less_le: "x \<sqsubset> y \<longleftrightarrow> x \<sqsubseteq> y \<and> x \<noteq> y"
    78 begin
    79 
    80 text {* Reflexivity. *}
    81 
    82 lemma eq_refl: "x = y \<Longrightarrow> x \<sqsubseteq> y"
    83     -- {* This form is useful with the classical reasoner. *}
    84   by (erule ssubst) (rule refl)
    85 
    86 lemma less_irrefl [iff]: "\<not> x \<sqsubset> x"
    87   by (simp add: less_le)
    88 
    89 lemma le_less: "x \<sqsubseteq> y \<longleftrightarrow> x \<sqsubset> y \<or> x = y"
    90     -- {* NOT suitable for iff, since it can cause PROOF FAILED. *}
    91   by (simp add: less_le) blast
    92 
    93 lemma le_imp_less_or_eq: "x \<sqsubseteq> y \<Longrightarrow> x \<sqsubset> y \<or> x = y"
    94   unfolding less_le by blast
    95 
    96 lemma less_imp_le: "x \<sqsubset> y \<Longrightarrow> x \<sqsubseteq> y"
    97   unfolding less_le by blast
    98 
    99 lemma less_imp_neq: "x \<sqsubset> y \<Longrightarrow> x \<noteq> y"
   100   by (erule contrapos_pn, erule subst, rule less_irrefl)
   101 
   102 
   103 text {* Useful for simplification, but too risky to include by default. *}
   104 
   105 lemma less_imp_not_eq: "x \<sqsubset> y \<Longrightarrow> (x = y) \<longleftrightarrow> False"
   106   by auto
   107 
   108 lemma less_imp_not_eq2: "x \<sqsubset> y \<Longrightarrow> (y = x) \<longleftrightarrow> False"
   109   by auto
   110 
   111 
   112 text {* Transitivity rules for calculational reasoning *}
   113 
   114 lemma neq_le_trans: "\<lbrakk> a \<noteq> b; a \<sqsubseteq> b \<rbrakk> \<Longrightarrow> a \<sqsubset> b"
   115   by (simp add: less_le)
   116 
   117 lemma le_neq_trans: "\<lbrakk> a \<sqsubseteq> b; a \<noteq> b \<rbrakk> \<Longrightarrow> a \<sqsubset> b"
   118   by (simp add: less_le)
   119 
   120 end
   121 
   122 
   123 subsection {* Partial orderings *}
   124 
   125 locale order = preorder + 
   126   assumes antisym: "x \<sqsubseteq> y \<Longrightarrow> y \<sqsubseteq> x \<Longrightarrow> x = y"
   127 
   128 context order
   129 begin
   130 
   131 text {* Asymmetry. *}
   132 
   133 lemma less_not_sym: "x \<sqsubset> y \<Longrightarrow> \<not> (y \<sqsubset> x)"
   134   by (simp add: less_le antisym)
   135 
   136 lemma less_asym: "x \<sqsubset> y \<Longrightarrow> (\<not> P \<Longrightarrow> y \<sqsubset> x) \<Longrightarrow> P"
   137   by (drule less_not_sym, erule contrapos_np) simp
   138 
   139 lemma eq_iff: "x = y \<longleftrightarrow> x \<sqsubseteq> y \<and> y \<sqsubseteq> x"
   140   by (blast intro: antisym)
   141 
   142 lemma antisym_conv: "y \<sqsubseteq> x \<Longrightarrow> x \<sqsubseteq> y \<longleftrightarrow> x = y"
   143   by (blast intro: antisym)
   144 
   145 lemma less_imp_neq: "x \<sqsubset> y \<Longrightarrow> x \<noteq> y"
   146   by (erule contrapos_pn, erule subst, rule less_irrefl)
   147 
   148 
   149 text {* Transitivity. *}
   150 
   151 lemma less_trans: "\<lbrakk> x \<sqsubset> y; y \<sqsubset> z \<rbrakk> \<Longrightarrow> x \<sqsubset> z"
   152   by (simp add: less_le) (blast intro: trans antisym)
   153 
   154 lemma le_less_trans: "\<lbrakk> x \<sqsubseteq> y; y \<sqsubset> z \<rbrakk> \<Longrightarrow> x \<sqsubset> z"
   155   by (simp add: less_le) (blast intro: trans antisym)
   156 
   157 lemma less_le_trans: "\<lbrakk> x \<sqsubset> y; y \<sqsubseteq> z \<rbrakk> \<Longrightarrow> x \<sqsubset> z"
   158   by (simp add: less_le) (blast intro: trans antisym)
   159 
   160 
   161 text {* Useful for simplification, but too risky to include by default. *}
   162 
   163 lemma less_imp_not_less: "x \<sqsubset> y \<Longrightarrow> (\<not> y \<sqsubset> x) \<longleftrightarrow> True"
   164   by (blast elim: less_asym)
   165 
   166 lemma less_imp_triv: "x \<sqsubset> y \<Longrightarrow> (y \<sqsubset> x \<longrightarrow> P) \<longleftrightarrow> True"
   167   by (blast elim: less_asym)
   168 
   169 
   170 text {* Transitivity rules for calculational reasoning *}
   171 
   172 lemma less_asym': "\<lbrakk> a \<sqsubset> b; b \<sqsubset> a \<rbrakk> \<Longrightarrow> P"
   173   by (rule less_asym)
   174 
   175 end
   176 
   177 axclass order < ord
   178   order_refl [iff]: "x <= x"
   179   order_trans: "x <= y ==> y <= z ==> x <= z"
   180   order_antisym: "x <= y ==> y <= x ==> x = y"
   181   order_less_le: "(x < y) = (x <= y & x ~= y)"
   182 
   183 interpretation order:
   184   order ["op \<le> \<Colon> 'a\<Colon>order \<Rightarrow> 'a \<Rightarrow> bool" "op < \<Colon> 'a\<Colon>order \<Rightarrow> 'a \<Rightarrow> bool"]
   185 apply unfold_locales
   186 apply (rule order_refl)
   187 apply (erule (1) order_trans)
   188 apply (rule order_less_le)
   189 apply (erule (1) order_antisym)
   190 done
   191 
   192 
   193 subsection {* Linear (total) orders *}
   194 
   195 locale linorder = order +
   196   assumes linear: "x \<sqsubseteq> y \<or> y \<sqsubseteq> x"
   197 begin
   198 
   199 lemma less_linear: "x \<sqsubset> y \<or> x = y \<or> y \<sqsubset> x"
   200   unfolding less_le using less_le linear by blast 
   201 
   202 lemma le_less_linear: "x \<sqsubseteq> y \<or> y \<sqsubset> x"
   203   by (simp add: le_less less_linear)
   204 
   205 lemma le_cases [case_names le ge]:
   206   "\<lbrakk> x \<sqsubseteq> y \<Longrightarrow> P; y \<sqsubseteq> x \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"
   207   using linear by blast
   208 
   209 lemma cases [case_names less equal greater]:
   210     "\<lbrakk> x \<sqsubset> y \<Longrightarrow> P; x = y \<Longrightarrow> P; y \<sqsubset> x \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"
   211   using less_linear by blast
   212 
   213 lemma not_less: "\<not> x \<sqsubset> y \<longleftrightarrow> y \<sqsubseteq> x"
   214   apply (simp add: less_le)
   215   using linear apply (blast intro: antisym)
   216   done
   217 
   218 lemma not_le: "\<not> x \<sqsubseteq> y \<longleftrightarrow> y \<sqsubset> x"
   219   apply (simp add: less_le)
   220   using linear apply (blast intro: antisym)
   221   done
   222 
   223 lemma neq_iff: "x \<noteq> y \<longleftrightarrow> x \<sqsubset> y \<or> y \<sqsubset> x"
   224   by (cut_tac x = x and y = y in less_linear, auto)
   225 
   226 lemma neqE: "\<lbrakk> x \<noteq> y; x \<sqsubset> y \<Longrightarrow> R; y \<sqsubset> x \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R"
   227   by (simp add: neq_iff) blast
   228 
   229 lemma antisym_conv1: "\<not> x \<sqsubset> y \<Longrightarrow> x \<sqsubseteq> y \<longleftrightarrow> x = y"
   230   by (blast intro: antisym dest: not_less [THEN iffD1])
   231 
   232 lemma antisym_conv2: "x \<sqsubseteq> y \<Longrightarrow> \<not> x \<sqsubset> y \<longleftrightarrow> x = y"
   233   by (blast intro: antisym dest: not_less [THEN iffD1])
   234 
   235 lemma antisym_conv3: "\<not> y \<sqsubset> x \<Longrightarrow> \<not> x \<sqsubset> y \<longleftrightarrow> x = y"
   236   by (blast intro: antisym dest: not_less [THEN iffD1])
   237 
   238 text{*Replacing the old Nat.leI*}
   239 lemma leI: "\<not> x \<sqsubset> y \<Longrightarrow> y \<sqsubseteq> x"
   240   unfolding not_less .
   241 
   242 lemma leD: "y \<sqsubseteq> x \<Longrightarrow> \<not> x \<sqsubset> y"
   243   unfolding not_less .
   244 
   245 (*FIXME inappropriate name (or delete altogether)*)
   246 lemma not_leE: "\<not> y \<sqsubseteq> x \<Longrightarrow> x \<sqsubset> y"
   247   unfolding not_le .
   248 
   249 (* min/max *)
   250 
   251 definition
   252   min :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" where
   253   "min a b = (if a \<sqsubseteq> b then a else b)"
   254 
   255 definition
   256   max :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" where
   257   "max a b = (if a \<sqsubseteq> b then b else a)"
   258 
   259 lemma min_le_iff_disj:
   260   "min x y \<sqsubseteq> z \<longleftrightarrow> x \<sqsubseteq> z \<or> y \<sqsubseteq> z"
   261   unfolding min_def using linear by (auto intro: trans)
   262 
   263 lemma le_max_iff_disj:
   264   "z \<sqsubseteq> max x y \<longleftrightarrow> z \<sqsubseteq> x \<or> z \<sqsubseteq> y"
   265   unfolding max_def using linear by (auto intro: trans)
   266 
   267 lemma min_less_iff_disj:
   268   "min x y \<sqsubset> z \<longleftrightarrow> x \<sqsubset> z \<or> y \<sqsubset> z"
   269   unfolding min_def le_less using less_linear by (auto intro: less_trans)
   270 
   271 lemma less_max_iff_disj:
   272   "z \<sqsubset> max x y \<longleftrightarrow> z \<sqsubset> x \<or> z \<sqsubset> y"
   273   unfolding max_def le_less using less_linear by (auto intro: less_trans)
   274 
   275 lemma min_less_iff_conj [simp]:
   276   "z \<sqsubset> min x y \<longleftrightarrow> z \<sqsubset> x \<and> z \<sqsubset> y"
   277   unfolding min_def le_less using less_linear by (auto intro: less_trans)
   278 
   279 lemma max_less_iff_conj [simp]:
   280   "max x y \<sqsubset> z \<longleftrightarrow> x \<sqsubset> z \<and> y \<sqsubset> z"
   281   unfolding max_def le_less using less_linear by (auto intro: less_trans)
   282 
   283 lemma split_min:
   284   "P (min i j) \<longleftrightarrow> (i \<sqsubseteq> j \<longrightarrow> P i) \<and> (\<not> i \<sqsubseteq> j \<longrightarrow> P j)"
   285   by (simp add: min_def)
   286 
   287 lemma split_max:
   288   "P (max i j) \<longleftrightarrow> (i \<sqsubseteq> j \<longrightarrow> P j) \<and> (\<not> i \<sqsubseteq> j \<longrightarrow> P i)"
   289   by (simp add: max_def)
   290 
   291 end
   292 
   293 axclass linorder < order
   294   linorder_linear: "x <= y | y <= x"
   295 
   296 interpretation order:
   297   linorder ["op \<le> \<Colon> 'a\<Colon>linorder \<Rightarrow> 'a \<Rightarrow> bool" "op < \<Colon> 'a\<Colon>linorder \<Rightarrow> 'a \<Rightarrow> bool"]
   298   by unfold_locales (rule linorder_linear)
   299 
   300 
   301 subsection {* Name duplicates *}
   302 
   303 lemmas order_eq_refl [where 'b = "?'a::order"] = order.eq_refl
   304 lemmas order_less_irrefl [where 'b = "?'a::order"] = order.less_irrefl
   305 lemmas order_le_less [where 'b = "?'a::order"] = order.le_less
   306 lemmas order_le_imp_less_or_eq [where 'b = "?'a::order"] = order.le_imp_less_or_eq
   307 lemmas order_less_imp_le [where 'b = "?'a::order"] = order.less_imp_le
   308 lemmas order_less_not_sym [where 'b = "?'a::order"] = order.less_not_sym
   309 lemmas order_less_asym [where 'b = "?'a::order"] = order.less_asym
   310 lemmas order_eq_iff [where 'b = "?'a::order"] = order.eq_iff
   311 lemmas order_antisym_conv [where 'b = "?'a::order"] = order.antisym_conv
   312 lemmas less_imp_neq [where 'b = "?'a::order"] = order.less_imp_neq
   313 lemmas order_less_trans [where 'b = "?'a::order"] = order.less_trans
   314 lemmas order_le_less_trans [where 'b = "?'a::order"] = order.le_less_trans
   315 lemmas order_less_le_trans [where 'b = "?'a::order"] = order.less_le_trans
   316 lemmas order_less_imp_not_less [where 'b = "?'a::order"] = order.less_imp_not_less
   317 lemmas order_less_imp_triv [where 'b = "?'a::order"] = order.less_imp_triv
   318 lemmas order_less_imp_not_eq [where 'b = "?'a::order"] = order.less_imp_not_eq
   319 lemmas order_less_imp_not_eq2 [where 'b = "?'a::order"] = order.less_imp_not_eq2
   320 lemmas order_neq_le_trans [where 'b = "?'a::order"] = order.neq_le_trans
   321 lemmas order_le_neq_trans [where 'b = "?'a::order"] = order.le_neq_trans
   322 lemmas order_less_asym' [where 'b = "?'a::order"] = order.less_asym'
   323 lemmas linorder_less_linear [where 'b = "?'a::linorder"] = order.less_linear
   324 lemmas linorder_le_less_linear [where 'b = "?'a::linorder"] = order.le_less_linear
   325 lemmas linorder_le_cases [where 'b = "?'a::linorder"] = order.le_cases
   326 lemmas linorder_cases [where 'b = "?'a::linorder"] = order.cases
   327 lemmas linorder_not_less [where 'b = "?'a::linorder"] = order.not_less
   328 lemmas linorder_not_le [where 'b = "?'a::linorder"] = order.not_le
   329 lemmas linorder_neq_iff [where 'b = "?'a::linorder"] = order.neq_iff
   330 lemmas linorder_neqE [where 'b = "?'a::linorder"] = order.neqE
   331 lemmas linorder_antisym_conv1 [where 'b = "?'a::linorder"] = order.antisym_conv1
   332 lemmas linorder_antisym_conv2 [where 'b = "?'a::linorder"] = order.antisym_conv2
   333 lemmas linorder_antisym_conv3 [where 'b = "?'a::linorder"] = order.antisym_conv3
   334 lemmas leI [where 'b = "?'a::linorder"] = order.leI
   335 lemmas leD [where 'b = "?'a::linorder"] = order.leD
   336 lemmas not_leE [where 'b = "?'a::linorder"] = order.not_leE
   337 
   338 
   339 subsection {* Reasoning tools setup *}
   340 
   341 ML {*
   342 local
   343 
   344 fun decomp_gen sort thy (Trueprop $ t) =
   345   let
   346     fun of_sort t =
   347       let
   348         val T = type_of t
   349       in
   350         (* exclude numeric types: linear arithmetic subsumes transitivity *)
   351         T <> HOLogic.natT andalso T <> HOLogic.intT
   352           andalso T <> HOLogic.realT andalso Sign.of_sort thy (T, sort)
   353       end;
   354     fun dec (Const ("Not", _) $ t) = (case dec t
   355           of NONE => NONE
   356            | SOME (t1, rel, t2) => SOME (t1, "~" ^ rel, t2))
   357       | dec (Const ("op =",  _) $ t1 $ t2) =
   358           if of_sort t1
   359           then SOME (t1, "=", t2)
   360           else NONE
   361       | dec (Const ("Orderings.less_eq",  _) $ t1 $ t2) =
   362           if of_sort t1
   363           then SOME (t1, "<=", t2)
   364           else NONE
   365       | dec (Const ("Orderings.less",  _) $ t1 $ t2) =
   366           if of_sort t1
   367           then SOME (t1, "<", t2)
   368           else NONE
   369       | dec _ = NONE;
   370   in dec t end;
   371 
   372 in
   373 
   374 (* The setting up of Quasi_Tac serves as a demo.  Since there is no
   375    class for quasi orders, the tactics Quasi_Tac.trans_tac and
   376    Quasi_Tac.quasi_tac are not of much use. *)
   377 
   378 structure Quasi_Tac = Quasi_Tac_Fun (
   379 struct
   380   val le_trans = thm "order_trans";
   381   val le_refl = thm "order_refl";
   382   val eqD1 = thm "order_eq_refl";
   383   val eqD2 = thm "sym" RS thm "order_eq_refl";
   384   val less_reflE = thm "order_less_irrefl" RS thm "notE";
   385   val less_imp_le = thm "order_less_imp_le";
   386   val le_neq_trans = thm "order_le_neq_trans";
   387   val neq_le_trans = thm "order_neq_le_trans";
   388   val less_imp_neq = thm "less_imp_neq";
   389   val decomp_trans = decomp_gen ["Orderings.order"];
   390   val decomp_quasi = decomp_gen ["Orderings.order"];
   391 end);
   392 
   393 structure Order_Tac = Order_Tac_Fun (
   394 struct
   395   val less_reflE = thm "order_less_irrefl" RS thm "notE";
   396   val le_refl = thm "order_refl";
   397   val less_imp_le = thm "order_less_imp_le";
   398   val not_lessI = thm "linorder_not_less" RS thm "iffD2";
   399   val not_leI = thm "linorder_not_le" RS thm "iffD2";
   400   val not_lessD = thm "linorder_not_less" RS thm "iffD1";
   401   val not_leD = thm "linorder_not_le" RS thm "iffD1";
   402   val eqI = thm "order_antisym";
   403   val eqD1 = thm "order_eq_refl";
   404   val eqD2 = thm "sym" RS thm "order_eq_refl";
   405   val less_trans = thm "order_less_trans";
   406   val less_le_trans = thm "order_less_le_trans";
   407   val le_less_trans = thm "order_le_less_trans";
   408   val le_trans = thm "order_trans";
   409   val le_neq_trans = thm "order_le_neq_trans";
   410   val neq_le_trans = thm "order_neq_le_trans";
   411   val less_imp_neq = thm "less_imp_neq";
   412   val eq_neq_eq_imp_neq = thm "eq_neq_eq_imp_neq";
   413   val not_sym = thm "not_sym";
   414   val decomp_part = decomp_gen ["Orderings.order"];
   415   val decomp_lin = decomp_gen ["Orderings.linorder"];
   416 end);
   417 
   418 end;
   419 *}
   420 
   421 setup {*
   422 let
   423 
   424 val order_antisym_conv = thm "order_antisym_conv"
   425 val linorder_antisym_conv1 = thm "linorder_antisym_conv1"
   426 val linorder_antisym_conv2 = thm "linorder_antisym_conv2"
   427 val linorder_antisym_conv3 = thm "linorder_antisym_conv3"
   428 
   429 fun prp t thm = (#prop (rep_thm thm) = t);
   430 
   431 fun prove_antisym_le sg ss ((le as Const(_,T)) $ r $ s) =
   432   let val prems = prems_of_ss ss;
   433       val less = Const("Orderings.less",T);
   434       val t = HOLogic.mk_Trueprop(le $ s $ r);
   435   in case find_first (prp t) prems of
   436        NONE =>
   437          let val t = HOLogic.mk_Trueprop(HOLogic.Not $ (less $ r $ s))
   438          in case find_first (prp t) prems of
   439               NONE => NONE
   440             | SOME thm => SOME(mk_meta_eq(thm RS linorder_antisym_conv1))
   441          end
   442      | SOME thm => SOME(mk_meta_eq(thm RS order_antisym_conv))
   443   end
   444   handle THM _ => NONE;
   445 
   446 fun prove_antisym_less sg ss (NotC $ ((less as Const(_,T)) $ r $ s)) =
   447   let val prems = prems_of_ss ss;
   448       val le = Const("Orderings.less_eq",T);
   449       val t = HOLogic.mk_Trueprop(le $ r $ s);
   450   in case find_first (prp t) prems of
   451        NONE =>
   452          let val t = HOLogic.mk_Trueprop(NotC $ (less $ s $ r))
   453          in case find_first (prp t) prems of
   454               NONE => NONE
   455             | SOME thm => SOME(mk_meta_eq(thm RS linorder_antisym_conv3))
   456          end
   457      | SOME thm => SOME(mk_meta_eq(thm RS linorder_antisym_conv2))
   458   end
   459   handle THM _ => NONE;
   460 
   461 fun add_simprocs procs thy =
   462   (Simplifier.change_simpset_of thy (fn ss => ss
   463     addsimprocs (map (fn (name, raw_ts, proc) =>
   464       Simplifier.simproc thy name raw_ts proc)) procs); thy);
   465 fun add_solver name tac thy =
   466   (Simplifier.change_simpset_of thy (fn ss => ss addSolver
   467     (mk_solver name (K tac))); thy);
   468 
   469 in
   470   add_simprocs [
   471        ("antisym le", ["(x::'a::order) <= y"], prove_antisym_le),
   472        ("antisym less", ["~ (x::'a::linorder) < y"], prove_antisym_less)
   473      ]
   474   #> add_solver "Trans_linear" Order_Tac.linear_tac
   475   #> add_solver "Trans_partial" Order_Tac.partial_tac
   476   (* Adding the transitivity reasoners also as safe solvers showed a slight
   477      speed up, but the reasoning strength appears to be not higher (at least
   478      no breaking of additional proofs in the entire HOL distribution, as
   479      of 5 March 2004, was observed). *)
   480 end
   481 *}
   482 
   483 
   484 subsection {* Bounded quantifiers *}
   485 
   486 syntax
   487   "_All_less" :: "[idt, 'a, bool] => bool"    ("(3ALL _<_./ _)"  [0, 0, 10] 10)
   488   "_Ex_less" :: "[idt, 'a, bool] => bool"    ("(3EX _<_./ _)"  [0, 0, 10] 10)
   489   "_All_less_eq" :: "[idt, 'a, bool] => bool"    ("(3ALL _<=_./ _)" [0, 0, 10] 10)
   490   "_Ex_less_eq" :: "[idt, 'a, bool] => bool"    ("(3EX _<=_./ _)" [0, 0, 10] 10)
   491 
   492   "_All_greater" :: "[idt, 'a, bool] => bool"    ("(3ALL _>_./ _)"  [0, 0, 10] 10)
   493   "_Ex_greater" :: "[idt, 'a, bool] => bool"    ("(3EX _>_./ _)"  [0, 0, 10] 10)
   494   "_All_greater_eq" :: "[idt, 'a, bool] => bool"    ("(3ALL _>=_./ _)" [0, 0, 10] 10)
   495   "_Ex_greater_eq" :: "[idt, 'a, bool] => bool"    ("(3EX _>=_./ _)" [0, 0, 10] 10)
   496 
   497 syntax (xsymbols)
   498   "_All_less" :: "[idt, 'a, bool] => bool"    ("(3\<forall>_<_./ _)"  [0, 0, 10] 10)
   499   "_Ex_less" :: "[idt, 'a, bool] => bool"    ("(3\<exists>_<_./ _)"  [0, 0, 10] 10)
   500   "_All_less_eq" :: "[idt, 'a, bool] => bool"    ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10)
   501   "_Ex_less_eq" :: "[idt, 'a, bool] => bool"    ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10)
   502 
   503   "_All_greater" :: "[idt, 'a, bool] => bool"    ("(3\<forall>_>_./ _)"  [0, 0, 10] 10)
   504   "_Ex_greater" :: "[idt, 'a, bool] => bool"    ("(3\<exists>_>_./ _)"  [0, 0, 10] 10)
   505   "_All_greater_eq" :: "[idt, 'a, bool] => bool"    ("(3\<forall>_\<ge>_./ _)" [0, 0, 10] 10)
   506   "_Ex_greater_eq" :: "[idt, 'a, bool] => bool"    ("(3\<exists>_\<ge>_./ _)" [0, 0, 10] 10)
   507 
   508 syntax (HOL)
   509   "_All_less" :: "[idt, 'a, bool] => bool"    ("(3! _<_./ _)"  [0, 0, 10] 10)
   510   "_Ex_less" :: "[idt, 'a, bool] => bool"    ("(3? _<_./ _)"  [0, 0, 10] 10)
   511   "_All_less_eq" :: "[idt, 'a, bool] => bool"    ("(3! _<=_./ _)" [0, 0, 10] 10)
   512   "_Ex_less_eq" :: "[idt, 'a, bool] => bool"    ("(3? _<=_./ _)" [0, 0, 10] 10)
   513 
   514 syntax (HTML output)
   515   "_All_less" :: "[idt, 'a, bool] => bool"    ("(3\<forall>_<_./ _)"  [0, 0, 10] 10)
   516   "_Ex_less" :: "[idt, 'a, bool] => bool"    ("(3\<exists>_<_./ _)"  [0, 0, 10] 10)
   517   "_All_less_eq" :: "[idt, 'a, bool] => bool"    ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10)
   518   "_Ex_less_eq" :: "[idt, 'a, bool] => bool"    ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10)
   519 
   520   "_All_greater" :: "[idt, 'a, bool] => bool"    ("(3\<forall>_>_./ _)"  [0, 0, 10] 10)
   521   "_Ex_greater" :: "[idt, 'a, bool] => bool"    ("(3\<exists>_>_./ _)"  [0, 0, 10] 10)
   522   "_All_greater_eq" :: "[idt, 'a, bool] => bool"    ("(3\<forall>_\<ge>_./ _)" [0, 0, 10] 10)
   523   "_Ex_greater_eq" :: "[idt, 'a, bool] => bool"    ("(3\<exists>_\<ge>_./ _)" [0, 0, 10] 10)
   524 
   525 translations
   526   "ALL x<y. P"   =>  "ALL x. x < y \<longrightarrow> P"
   527   "EX x<y. P"    =>  "EX x. x < y \<and> P"
   528   "ALL x<=y. P"  =>  "ALL x. x <= y \<longrightarrow> P"
   529   "EX x<=y. P"   =>  "EX x. x <= y \<and> P"
   530   "ALL x>y. P"   =>  "ALL x. x > y \<longrightarrow> P"
   531   "EX x>y. P"    =>  "EX x. x > y \<and> P"
   532   "ALL x>=y. P"  =>  "ALL x. x >= y \<longrightarrow> P"
   533   "EX x>=y. P"   =>  "EX x. x >= y \<and> P"
   534 
   535 print_translation {*
   536 let
   537   val syntax_name = Sign.const_syntax_name (the_context ());
   538   val binder_name = Syntax.binder_name o syntax_name;
   539   val All_binder = binder_name "All";
   540   val Ex_binder = binder_name "Ex";
   541   val impl = syntax_name "op -->";
   542   val conj = syntax_name "op &";
   543   val less = syntax_name "Orderings.less";
   544   val less_eq = syntax_name "Orderings.less_eq";
   545 
   546   val trans =
   547    [((All_binder, impl, less), ("_All_less", "_All_greater")),
   548     ((All_binder, impl, less_eq), ("_All_less_eq", "_All_greater_eq")),
   549     ((Ex_binder, conj, less), ("_Ex_less", "_Ex_greater")),
   550     ((Ex_binder, conj, less_eq), ("_Ex_less_eq", "_Ex_greater_eq"))];
   551 
   552   fun mk v v' c n P =
   553     if v = v' andalso not (Term.exists_subterm (fn Free (x, _) => x = v | _ => false) n)
   554     then Syntax.const c $ Syntax.mark_bound v' $ n $ P else raise Match;
   555 
   556   fun tr' q = (q,
   557     fn [Const ("_bound", _) $ Free (v, _), Const (c, _) $ (Const (d, _) $ t $ u) $ P] =>
   558       (case AList.lookup (op =) trans (q, c, d) of
   559         NONE => raise Match
   560       | SOME (l, g) =>
   561           (case (t, u) of
   562             (Const ("_bound", _) $ Free (v', _), n) => mk v v' l n P
   563           | (n, Const ("_bound", _) $ Free (v', _)) => mk v v' g n P
   564           | _ => raise Match))
   565      | _ => raise Match);
   566 in [tr' All_binder, tr' Ex_binder] end
   567 *}
   568 
   569 
   570 subsection {* Transitivity reasoning *}
   571 
   572 lemma ord_le_eq_trans: "a <= b ==> b = c ==> a <= c"
   573   by (rule subst)
   574 
   575 lemma ord_eq_le_trans: "a = b ==> b <= c ==> a <= c"
   576   by (rule ssubst)
   577 
   578 lemma ord_less_eq_trans: "a < b ==> b = c ==> a < c"
   579   by (rule subst)
   580 
   581 lemma ord_eq_less_trans: "a = b ==> b < c ==> a < c"
   582   by (rule ssubst)
   583 
   584 lemma order_less_subst2: "(a::'a::order) < b ==> f b < (c::'c::order) ==>
   585   (!!x y. x < y ==> f x < f y) ==> f a < c"
   586 proof -
   587   assume r: "!!x y. x < y ==> f x < f y"
   588   assume "a < b" hence "f a < f b" by (rule r)
   589   also assume "f b < c"
   590   finally (order_less_trans) show ?thesis .
   591 qed
   592 
   593 lemma order_less_subst1: "(a::'a::order) < f b ==> (b::'b::order) < c ==>
   594   (!!x y. x < y ==> f x < f y) ==> a < f c"
   595 proof -
   596   assume r: "!!x y. x < y ==> f x < f y"
   597   assume "a < f b"
   598   also assume "b < c" hence "f b < f c" by (rule r)
   599   finally (order_less_trans) show ?thesis .
   600 qed
   601 
   602 lemma order_le_less_subst2: "(a::'a::order) <= b ==> f b < (c::'c::order) ==>
   603   (!!x y. x <= y ==> f x <= f y) ==> f a < c"
   604 proof -
   605   assume r: "!!x y. x <= y ==> f x <= f y"
   606   assume "a <= b" hence "f a <= f b" by (rule r)
   607   also assume "f b < c"
   608   finally (order_le_less_trans) show ?thesis .
   609 qed
   610 
   611 lemma order_le_less_subst1: "(a::'a::order) <= f b ==> (b::'b::order) < c ==>
   612   (!!x y. x < y ==> f x < f y) ==> a < f c"
   613 proof -
   614   assume r: "!!x y. x < y ==> f x < f y"
   615   assume "a <= f b"
   616   also assume "b < c" hence "f b < f c" by (rule r)
   617   finally (order_le_less_trans) show ?thesis .
   618 qed
   619 
   620 lemma order_less_le_subst2: "(a::'a::order) < b ==> f b <= (c::'c::order) ==>
   621   (!!x y. x < y ==> f x < f y) ==> f a < c"
   622 proof -
   623   assume r: "!!x y. x < y ==> f x < f y"
   624   assume "a < b" hence "f a < f b" by (rule r)
   625   also assume "f b <= c"
   626   finally (order_less_le_trans) show ?thesis .
   627 qed
   628 
   629 lemma order_less_le_subst1: "(a::'a::order) < f b ==> (b::'b::order) <= c ==>
   630   (!!x y. x <= y ==> f x <= f y) ==> a < f c"
   631 proof -
   632   assume r: "!!x y. x <= y ==> f x <= f y"
   633   assume "a < f b"
   634   also assume "b <= c" hence "f b <= f c" by (rule r)
   635   finally (order_less_le_trans) show ?thesis .
   636 qed
   637 
   638 lemma order_subst1: "(a::'a::order) <= f b ==> (b::'b::order) <= c ==>
   639   (!!x y. x <= y ==> f x <= f y) ==> a <= f c"
   640 proof -
   641   assume r: "!!x y. x <= y ==> f x <= f y"
   642   assume "a <= f b"
   643   also assume "b <= c" hence "f b <= f c" by (rule r)
   644   finally (order_trans) show ?thesis .
   645 qed
   646 
   647 lemma order_subst2: "(a::'a::order) <= b ==> f b <= (c::'c::order) ==>
   648   (!!x y. x <= y ==> f x <= f y) ==> f a <= c"
   649 proof -
   650   assume r: "!!x y. x <= y ==> f x <= f y"
   651   assume "a <= b" hence "f a <= f b" by (rule r)
   652   also assume "f b <= c"
   653   finally (order_trans) show ?thesis .
   654 qed
   655 
   656 lemma ord_le_eq_subst: "a <= b ==> f b = c ==>
   657   (!!x y. x <= y ==> f x <= f y) ==> f a <= c"
   658 proof -
   659   assume r: "!!x y. x <= y ==> f x <= f y"
   660   assume "a <= b" hence "f a <= f b" by (rule r)
   661   also assume "f b = c"
   662   finally (ord_le_eq_trans) show ?thesis .
   663 qed
   664 
   665 lemma ord_eq_le_subst: "a = f b ==> b <= c ==>
   666   (!!x y. x <= y ==> f x <= f y) ==> a <= f c"
   667 proof -
   668   assume r: "!!x y. x <= y ==> f x <= f y"
   669   assume "a = f b"
   670   also assume "b <= c" hence "f b <= f c" by (rule r)
   671   finally (ord_eq_le_trans) show ?thesis .
   672 qed
   673 
   674 lemma ord_less_eq_subst: "a < b ==> f b = c ==>
   675   (!!x y. x < y ==> f x < f y) ==> f a < c"
   676 proof -
   677   assume r: "!!x y. x < y ==> f x < f y"
   678   assume "a < b" hence "f a < f b" by (rule r)
   679   also assume "f b = c"
   680   finally (ord_less_eq_trans) show ?thesis .
   681 qed
   682 
   683 lemma ord_eq_less_subst: "a = f b ==> b < c ==>
   684   (!!x y. x < y ==> f x < f y) ==> a < f c"
   685 proof -
   686   assume r: "!!x y. x < y ==> f x < f y"
   687   assume "a = f b"
   688   also assume "b < c" hence "f b < f c" by (rule r)
   689   finally (ord_eq_less_trans) show ?thesis .
   690 qed
   691 
   692 text {*
   693   Note that this list of rules is in reverse order of priorities.
   694 *}
   695 
   696 lemmas order_trans_rules [trans] =
   697   order_less_subst2
   698   order_less_subst1
   699   order_le_less_subst2
   700   order_le_less_subst1
   701   order_less_le_subst2
   702   order_less_le_subst1
   703   order_subst2
   704   order_subst1
   705   ord_le_eq_subst
   706   ord_eq_le_subst
   707   ord_less_eq_subst
   708   ord_eq_less_subst
   709   forw_subst
   710   back_subst
   711   rev_mp
   712   mp
   713   order_neq_le_trans
   714   order_le_neq_trans
   715   order_less_trans
   716   order_less_asym'
   717   order_le_less_trans
   718   order_less_le_trans
   719   order_trans
   720   order_antisym
   721   ord_le_eq_trans
   722   ord_eq_le_trans
   723   ord_less_eq_trans
   724   ord_eq_less_trans
   725   trans
   726 
   727 
   728 (* FIXME cleanup *)
   729 
   730 text {* These support proving chains of decreasing inequalities
   731     a >= b >= c ... in Isar proofs. *}
   732 
   733 lemma xt1:
   734   "a = b ==> b > c ==> a > c"
   735   "a > b ==> b = c ==> a > c"
   736   "a = b ==> b >= c ==> a >= c"
   737   "a >= b ==> b = c ==> a >= c"
   738   "(x::'a::order) >= y ==> y >= x ==> x = y"
   739   "(x::'a::order) >= y ==> y >= z ==> x >= z"
   740   "(x::'a::order) > y ==> y >= z ==> x > z"
   741   "(x::'a::order) >= y ==> y > z ==> x > z"
   742   "(a::'a::order) > b ==> b > a ==> ?P"
   743   "(x::'a::order) > y ==> y > z ==> x > z"
   744   "(a::'a::order) >= b ==> a ~= b ==> a > b"
   745   "(a::'a::order) ~= b ==> a >= b ==> a > b"
   746   "a = f b ==> b > c ==> (!!x y. x > y ==> f x > f y) ==> a > f c" 
   747   "a > b ==> f b = c ==> (!!x y. x > y ==> f x > f y) ==> f a > c"
   748   "a = f b ==> b >= c ==> (!!x y. x >= y ==> f x >= f y) ==> a >= f c"
   749   "a >= b ==> f b = c ==> (!! x y. x >= y ==> f x >= f y) ==> f a >= c"
   750 by auto
   751 
   752 lemma xt2:
   753   "(a::'a::order) >= f b ==> b >= c ==> (!!x y. x >= y ==> f x >= f y) ==> a >= f c"
   754 by (subgoal_tac "f b >= f c", force, force)
   755 
   756 lemma xt3: "(a::'a::order) >= b ==> (f b::'b::order) >= c ==> 
   757     (!!x y. x >= y ==> f x >= f y) ==> f a >= c"
   758 by (subgoal_tac "f a >= f b", force, force)
   759 
   760 lemma xt4: "(a::'a::order) > f b ==> (b::'b::order) >= c ==>
   761   (!!x y. x >= y ==> f x >= f y) ==> a > f c"
   762 by (subgoal_tac "f b >= f c", force, force)
   763 
   764 lemma xt5: "(a::'a::order) > b ==> (f b::'b::order) >= c==>
   765     (!!x y. x > y ==> f x > f y) ==> f a > c"
   766 by (subgoal_tac "f a > f b", force, force)
   767 
   768 lemma xt6: "(a::'a::order) >= f b ==> b > c ==>
   769     (!!x y. x > y ==> f x > f y) ==> a > f c"
   770 by (subgoal_tac "f b > f c", force, force)
   771 
   772 lemma xt7: "(a::'a::order) >= b ==> (f b::'b::order) > c ==>
   773     (!!x y. x >= y ==> f x >= f y) ==> f a > c"
   774 by (subgoal_tac "f a >= f b", force, force)
   775 
   776 lemma xt8: "(a::'a::order) > f b ==> (b::'b::order) > c ==>
   777     (!!x y. x > y ==> f x > f y) ==> a > f c"
   778 by (subgoal_tac "f b > f c", force, force)
   779 
   780 lemma xt9: "(a::'a::order) > b ==> (f b::'b::order) > c ==>
   781     (!!x y. x > y ==> f x > f y) ==> f a > c"
   782 by (subgoal_tac "f a > f b", force, force)
   783 
   784 lemmas xtrans = xt1 xt2 xt3 xt4 xt5 xt6 xt7 xt8 xt9
   785 
   786 (* 
   787   Since "a >= b" abbreviates "b <= a", the abbreviation "..." stands
   788   for the wrong thing in an Isar proof.
   789 
   790   The extra transitivity rules can be used as follows: 
   791 
   792 lemma "(a::'a::order) > z"
   793 proof -
   794   have "a >= b" (is "_ >= ?rhs")
   795     sorry
   796   also have "?rhs >= c" (is "_ >= ?rhs")
   797     sorry
   798   also (xtrans) have "?rhs = d" (is "_ = ?rhs")
   799     sorry
   800   also (xtrans) have "?rhs >= e" (is "_ >= ?rhs")
   801     sorry
   802   also (xtrans) have "?rhs > f" (is "_ > ?rhs")
   803     sorry
   804   also (xtrans) have "?rhs > z"
   805     sorry
   806   finally (xtrans) show ?thesis .
   807 qed
   808 
   809   Alternatively, one can use "declare xtrans [trans]" and then
   810   leave out the "(xtrans)" above.
   811 *)
   812 
   813 subsection {* Order on bool *}
   814 
   815 instance bool :: linorder 
   816   le_bool_def: "P \<le> Q \<equiv> P \<longrightarrow> Q"
   817   less_bool_def: "P < Q \<equiv> P \<le> Q \<and> P \<noteq> Q"
   818   by default (auto simp add: le_bool_def less_bool_def)
   819 
   820 lemma le_boolI: "(P \<Longrightarrow> Q) \<Longrightarrow> P \<le> Q"
   821   by (simp add: le_bool_def)
   822 
   823 lemma le_boolI': "P \<longrightarrow> Q \<Longrightarrow> P \<le> Q"
   824   by (simp add: le_bool_def)
   825 
   826 lemma le_boolE: "P \<le> Q \<Longrightarrow> P \<Longrightarrow> (Q \<Longrightarrow> R) \<Longrightarrow> R"
   827   by (simp add: le_bool_def)
   828 
   829 lemma le_boolD: "P \<le> Q \<Longrightarrow> P \<longrightarrow> Q"
   830   by (simp add: le_bool_def)
   831 
   832 subsection {* Monotonicity, syntactic least value operator and min/max *}
   833 
   834 locale mono =
   835   fixes f
   836   assumes mono: "A \<le> B \<Longrightarrow> f A \<le> f B"
   837 
   838 lemmas monoI [intro?] = mono.intro
   839   and monoD [dest?] = mono.mono
   840 
   841 constdefs
   842   Least :: "('a::ord => bool) => 'a"               (binder "LEAST " 10)
   843   "Least P == THE x. P x & (ALL y. P y --> x <= y)"
   844     -- {* We can no longer use LeastM because the latter requires Hilbert-AC. *}
   845 
   846 lemma LeastI2_order:
   847   "[| P (x::'a::order);
   848       !!y. P y ==> x <= y;
   849       !!x. [| P x; ALL y. P y --> x \<le> y |] ==> Q x |]
   850    ==> Q (Least P)"
   851   apply (unfold Least_def)
   852   apply (rule theI2)
   853     apply (blast intro: order_antisym)+
   854   done
   855 
   856 lemma Least_equality:
   857     "[| P (k::'a::order); !!x. P x ==> k <= x |] ==> (LEAST x. P x) = k"
   858   apply (simp add: Least_def)
   859   apply (rule the_equality)
   860   apply (auto intro!: order_antisym)
   861   done
   862 
   863 constdefs
   864   min :: "['a::ord, 'a] => 'a"
   865   "min a b == (if a <= b then a else b)"
   866   max :: "['a::ord, 'a] => 'a"
   867   "max a b == (if a <= b then b else a)"
   868 
   869 hide const order.less_eq_less.max order.less_eq_less.min  (* FIXME !? *)
   870 
   871 lemma min_linorder:
   872   "linorder.min (op \<le> \<Colon> 'a\<Colon>linorder \<Rightarrow> 'a \<Rightarrow> bool) = min"
   873   by (rule+) (simp add: min_def order.min_def)
   874 
   875 lemma max_linorder:
   876   "linorder.max (op \<le> \<Colon> 'a\<Colon>linorder \<Rightarrow> 'a \<Rightarrow> bool) = max"
   877   by (rule+) (simp add: max_def order.max_def)
   878 
   879 lemmas min_le_iff_disj = order.min_le_iff_disj [where 'b = "?'a::linorder", unfolded min_linorder]
   880 lemmas le_max_iff_disj = order.le_max_iff_disj [where 'b = "?'a::linorder", unfolded max_linorder]
   881 lemmas min_less_iff_disj = order.min_less_iff_disj [where 'b = "?'a::linorder", unfolded min_linorder]
   882 lemmas less_max_iff_disj = order.less_max_iff_disj [where 'b = "?'a::linorder", unfolded max_linorder]
   883 lemmas min_less_iff_conj [simp] = order.min_less_iff_conj [where 'b = "?'a::linorder", unfolded min_linorder]
   884 lemmas max_less_iff_conj [simp] = order.max_less_iff_conj [where 'b = "?'a::linorder", unfolded max_linorder]
   885 lemmas split_min = order.split_min [where 'b = "?'a::linorder", unfolded min_linorder]
   886 lemmas split_max = order.split_max [where 'b = "?'a::linorder", unfolded max_linorder]
   887 
   888 lemma min_leastL: "(!!x. least <= x) ==> min least x = least"
   889   by (simp add: min_def)
   890 
   891 lemma max_leastL: "(!!x. least <= x) ==> max least x = x"
   892   by (simp add: max_def)
   893 
   894 lemma min_leastR: "(\<And>x\<Colon>'a\<Colon>order. least \<le> x) \<Longrightarrow> min x least = least"
   895   apply (simp add: min_def)
   896   apply (blast intro: order_antisym)
   897   done
   898 
   899 lemma max_leastR: "(\<And>x\<Colon>'a\<Colon>order. least \<le> x) \<Longrightarrow> max x least = x"
   900   apply (simp add: max_def)
   901   apply (blast intro: order_antisym)
   902   done
   903 
   904 lemma min_of_mono:
   905     "(!!x y. (f x <= f y) = (x <= y)) ==> min (f m) (f n) = f (min m n)"
   906   by (simp add: min_def)
   907 
   908 lemma max_of_mono:
   909     "(!!x y. (f x <= f y) = (x <= y)) ==> max (f m) (f n) = f (max m n)"
   910   by (simp add: max_def)
   911 
   912 
   913 subsection {* Basic ML bindings *}
   914 
   915 ML {*
   916 val leD = thm "leD";
   917 val leI = thm "leI";
   918 val linorder_neqE = thm "linorder_neqE";
   919 val linorder_neq_iff = thm "linorder_neq_iff";
   920 val linorder_not_le = thm "linorder_not_le";
   921 val linorder_not_less = thm "linorder_not_less";
   922 val monoD = thm "monoD";
   923 val monoI = thm "monoI";
   924 val order_antisym = thm "order_antisym";
   925 val order_less_irrefl = thm "order_less_irrefl";
   926 val order_refl = thm "order_refl";
   927 val order_trans = thm "order_trans";
   928 val split_max = thm "split_max";
   929 val split_min = thm "split_min";
   930 *}
   931 
   932 ML {*
   933 structure HOL =
   934 struct
   935   val thy = theory "HOL";
   936 end;
   937 *}  -- "belongs to theory HOL"
   938 
   939 end