src/HOL/HOL.thy
author wenzelm
Sat Nov 03 01:33:54 2001 +0100 (2001-11-03)
changeset 12023 d982f98e0f0d
parent 12003 c09427e5f554
child 12114 a8e860c86252
permissions -rw-r--r--
tuned;
     1 (*  Title:      HOL/HOL.thy
     2     ID:         $Id$
     3     Author:     Tobias Nipkow, Markus Wenzel, and Larry Paulson
     4 *)
     5 
     6 header {* The basis of Higher-Order Logic *}
     7 
     8 theory HOL = CPure
     9 files ("HOL_lemmas.ML") ("cladata.ML") ("blastdata.ML") ("simpdata.ML"):
    10 
    11 
    12 subsection {* Primitive logic *}
    13 
    14 subsubsection {* Core syntax *}
    15 
    16 global
    17 
    18 classes "term" < logic
    19 defaultsort "term"
    20 
    21 typedecl bool
    22 
    23 arities
    24   bool :: "term"
    25   fun :: ("term", "term") "term"
    26 
    27 judgment
    28   Trueprop      :: "bool => prop"                   ("(_)" 5)
    29 
    30 consts
    31   Not           :: "bool => bool"                   ("~ _" [40] 40)
    32   True          :: bool
    33   False         :: bool
    34   If            :: "[bool, 'a, 'a] => 'a"           ("(if (_)/ then (_)/ else (_))" 10)
    35   arbitrary     :: 'a
    36 
    37   The           :: "('a => bool) => 'a"
    38   All           :: "('a => bool) => bool"           (binder "ALL " 10)
    39   Ex            :: "('a => bool) => bool"           (binder "EX " 10)
    40   Ex1           :: "('a => bool) => bool"           (binder "EX! " 10)
    41   Let           :: "['a, 'a => 'b] => 'b"
    42 
    43   "="           :: "['a, 'a] => bool"               (infixl 50)
    44   &             :: "[bool, bool] => bool"           (infixr 35)
    45   "|"           :: "[bool, bool] => bool"           (infixr 30)
    46   -->           :: "[bool, bool] => bool"           (infixr 25)
    47 
    48 local
    49 
    50 
    51 subsubsection {* Additional concrete syntax *}
    52 
    53 nonterminals
    54   letbinds  letbind
    55   case_syn  cases_syn
    56 
    57 syntax
    58   ~=            :: "['a, 'a] => bool"                    (infixl 50)
    59   "_The"        :: "[pttrn, bool] => 'a"                 ("(3THE _./ _)" [0, 10] 10)
    60 
    61   "_bind"       :: "[pttrn, 'a] => letbind"              ("(2_ =/ _)" 10)
    62   ""            :: "letbind => letbinds"                 ("_")
    63   "_binds"      :: "[letbind, letbinds] => letbinds"     ("_;/ _")
    64   "_Let"        :: "[letbinds, 'a] => 'a"                ("(let (_)/ in (_))" 10)
    65 
    66   "_case_syntax":: "['a, cases_syn] => 'b"               ("(case _ of/ _)" 10)
    67   "_case1"      :: "['a, 'b] => case_syn"                ("(2_ =>/ _)" 10)
    68   ""            :: "case_syn => cases_syn"               ("_")
    69   "_case2"      :: "[case_syn, cases_syn] => cases_syn"  ("_/ | _")
    70 
    71 translations
    72   "x ~= y"                == "~ (x = y)"
    73   "THE x. P"              == "The (%x. P)"
    74   "_Let (_binds b bs) e"  == "_Let b (_Let bs e)"
    75   "let x = a in e"        == "Let a (%x. e)"
    76 
    77 syntax ("" output)
    78   "="           :: "['a, 'a] => bool"                    (infix 50)
    79   "~="          :: "['a, 'a] => bool"                    (infix 50)
    80 
    81 syntax (symbols)
    82   Not           :: "bool => bool"                        ("\<not> _" [40] 40)
    83   "op &"        :: "[bool, bool] => bool"                (infixr "\<and>" 35)
    84   "op |"        :: "[bool, bool] => bool"                (infixr "\<or>" 30)
    85   "op -->"      :: "[bool, bool] => bool"                (infixr "\<midarrow>\<rightarrow>" 25)
    86   "op ~="       :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
    87   "ALL "        :: "[idts, bool] => bool"                ("(3\<forall>_./ _)" [0, 10] 10)
    88   "EX "         :: "[idts, bool] => bool"                ("(3\<exists>_./ _)" [0, 10] 10)
    89   "EX! "        :: "[idts, bool] => bool"                ("(3\<exists>!_./ _)" [0, 10] 10)
    90   "_case1"      :: "['a, 'b] => case_syn"                ("(2_ \<Rightarrow>/ _)" 10)
    91 (*"_case2"      :: "[case_syn, cases_syn] => cases_syn"  ("_/ \\<orelse> _")*)
    92 
    93 syntax (symbols output)
    94   "op ~="       :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
    95 
    96 syntax (xsymbols)
    97   "op -->"      :: "[bool, bool] => bool"                (infixr "\<longrightarrow>" 25)
    98 
    99 syntax (HTML output)
   100   Not           :: "bool => bool"                        ("\<not> _" [40] 40)
   101 
   102 syntax (HOL)
   103   "ALL "        :: "[idts, bool] => bool"                ("(3! _./ _)" [0, 10] 10)
   104   "EX "         :: "[idts, bool] => bool"                ("(3? _./ _)" [0, 10] 10)
   105   "EX! "        :: "[idts, bool] => bool"                ("(3?! _./ _)" [0, 10] 10)
   106 
   107 
   108 subsubsection {* Axioms and basic definitions *}
   109 
   110 axioms
   111   eq_reflection: "(x=y) ==> (x==y)"
   112 
   113   refl:         "t = (t::'a)"
   114   subst:        "[| s = t; P(s) |] ==> P(t::'a)"
   115 
   116   ext:          "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)"
   117     -- {* Extensionality is built into the meta-logic, and this rule expresses *}
   118     -- {* a related property.  It is an eta-expanded version of the traditional *}
   119     -- {* rule, and similar to the ABS rule of HOL *}
   120 
   121   the_eq_trivial: "(THE x. x = a) = (a::'a)"
   122 
   123   impI:         "(P ==> Q) ==> P-->Q"
   124   mp:           "[| P-->Q;  P |] ==> Q"
   125 
   126 defs
   127   True_def:     "True      == ((%x::bool. x) = (%x. x))"
   128   All_def:      "All(P)    == (P = (%x. True))"
   129   Ex_def:       "Ex(P)     == !Q. (!x. P x --> Q) --> Q"
   130   False_def:    "False     == (!P. P)"
   131   not_def:      "~ P       == P-->False"
   132   and_def:      "P & Q     == !R. (P-->Q-->R) --> R"
   133   or_def:       "P | Q     == !R. (P-->R) --> (Q-->R) --> R"
   134   Ex1_def:      "Ex1(P)    == ? x. P(x) & (! y. P(y) --> y=x)"
   135 
   136 axioms
   137   iff:          "(P-->Q) --> (Q-->P) --> (P=Q)"
   138   True_or_False:  "(P=True) | (P=False)"
   139 
   140 defs
   141   Let_def:      "Let s f == f(s)"
   142   if_def:       "If P x y == THE z::'a. (P=True --> z=x) & (P=False --> z=y)"
   143 
   144   arbitrary_def:  "False ==> arbitrary == (THE x. False)"
   145     -- {* @{term arbitrary} is completely unspecified, but is made to appear as a
   146     definition syntactically *}
   147 
   148 
   149 subsubsection {* Generic algebraic operations *}
   150 
   151 axclass zero < "term"
   152 axclass one < "term"
   153 axclass plus < "term"
   154 axclass minus < "term"
   155 axclass times < "term"
   156 axclass inverse < "term"
   157 
   158 global
   159 
   160 consts
   161   "0"           :: "'a::zero"                       ("0")
   162   "1"           :: "'a::one"                        ("1")
   163   "+"           :: "['a::plus, 'a]  => 'a"          (infixl 65)
   164   -             :: "['a::minus, 'a] => 'a"          (infixl 65)
   165   uminus        :: "['a::minus] => 'a"              ("- _" [81] 80)
   166   *             :: "['a::times, 'a] => 'a"          (infixl 70)
   167 
   168 local
   169 
   170 typed_print_translation {*
   171   let
   172     fun tr' c = (c, fn show_sorts => fn T => fn ts =>
   173       if T = dummyT orelse not (! show_types) andalso can Term.dest_Type T then raise Match
   174       else Syntax.const Syntax.constrainC $ Syntax.const c $ Syntax.term_of_typ show_sorts T);
   175   in [tr' "0", tr' "1"] end;
   176 *} -- {* show types that are presumably too general *}
   177 
   178 
   179 consts
   180   abs           :: "'a::minus => 'a"
   181   inverse       :: "'a::inverse => 'a"
   182   divide        :: "['a::inverse, 'a] => 'a"        (infixl "'/" 70)
   183 
   184 syntax (xsymbols)
   185   abs :: "'a::minus => 'a"    ("\<bar>_\<bar>")
   186 syntax (HTML output)
   187   abs :: "'a::minus => 'a"    ("\<bar>_\<bar>")
   188 
   189 axclass plus_ac0 < plus, zero
   190   commute: "x + y = y + x"
   191   assoc:   "(x + y) + z = x + (y + z)"
   192   zero:    "0 + x = x"
   193 
   194 
   195 subsection {* Theory and package setup *}
   196 
   197 subsubsection {* Basic lemmas *}
   198 
   199 use "HOL_lemmas.ML"
   200 theorems case_split = case_split_thm [case_names True False]
   201 
   202 declare trans [trans]
   203 declare impE [CPure.elim]  iffD1 [CPure.elim]  iffD2 [CPure.elim]
   204 
   205 
   206 subsubsection {* Atomizing meta-level connectives *}
   207 
   208 lemma atomize_all [atomize]: "(!!x. P x) == Trueprop (ALL x. P x)"
   209 proof
   210   assume "!!x. P x"
   211   show "ALL x. P x" by (rule allI)
   212 next
   213   assume "ALL x. P x"
   214   thus "!!x. P x" by (rule allE)
   215 qed
   216 
   217 lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A --> B)"
   218 proof
   219   assume r: "A ==> B"
   220   show "A --> B" by (rule impI) (rule r)
   221 next
   222   assume "A --> B" and A
   223   thus B by (rule mp)
   224 qed
   225 
   226 lemma atomize_eq [atomize]: "(x == y) == Trueprop (x = y)"
   227 proof
   228   assume "x == y"
   229   show "x = y" by (unfold prems) (rule refl)
   230 next
   231   assume "x = y"
   232   thus "x == y" by (rule eq_reflection)
   233 qed
   234 
   235 lemma atomize_conj [atomize]:
   236   "(!!C. (A ==> B ==> PROP C) ==> PROP C) == Trueprop (A & B)"
   237 proof
   238   assume "!!C. (A ==> B ==> PROP C) ==> PROP C"
   239   show "A & B" by (rule conjI)
   240 next
   241   fix C
   242   assume "A & B"
   243   assume "A ==> B ==> PROP C"
   244   thus "PROP C"
   245   proof this
   246     show A by (rule conjunct1)
   247     show B by (rule conjunct2)
   248   qed
   249 qed
   250 
   251 
   252 subsubsection {* Classical Reasoner setup *}
   253 
   254 use "cladata.ML"
   255 setup hypsubst_setup
   256 
   257 declare atomize_all [symmetric, rulify]  atomize_imp [symmetric, rulify]
   258 
   259 setup Classical.setup
   260 setup clasetup
   261 
   262 declare ext [intro?]
   263 declare disjI1 [elim?]  disjI2 [elim?]  ex1_implies_ex [elim?]  sym [elim?]
   264 
   265 use "blastdata.ML"
   266 setup Blast.setup
   267 
   268 
   269 subsubsection {* Simplifier setup *}
   270 
   271 use "simpdata.ML"
   272 setup Simplifier.setup
   273 setup "Simplifier.method_setup Splitter.split_modifiers" setup simpsetup
   274 setup Splitter.setup setup Clasimp.setup
   275 
   276 
   277 subsubsection {* Generic cases and induction *}
   278 
   279 constdefs
   280   induct_forall :: "('a => bool) => bool"
   281   "induct_forall P == \<forall>x. P x"
   282   induct_implies :: "bool => bool => bool"
   283   "induct_implies A B == A --> B"
   284   induct_equal :: "'a => 'a => bool"
   285   "induct_equal x y == x = y"
   286   induct_conj :: "bool => bool => bool"
   287   "induct_conj A B == A & B"
   288 
   289 lemma induct_forall_eq: "(!!x. P x) == Trueprop (induct_forall (\<lambda>x. P x))"
   290   by (simp only: atomize_all induct_forall_def)
   291 
   292 lemma induct_implies_eq: "(A ==> B) == Trueprop (induct_implies A B)"
   293   by (simp only: atomize_imp induct_implies_def)
   294 
   295 lemma induct_equal_eq: "(x == y) == Trueprop (induct_equal x y)"
   296   by (simp only: atomize_eq induct_equal_def)
   297 
   298 lemma induct_forall_conj: "induct_forall (\<lambda>x. induct_conj (A x) (B x)) =
   299     induct_conj (induct_forall A) (induct_forall B)"
   300   by (unfold induct_forall_def induct_conj_def) blast
   301 
   302 lemma induct_implies_conj: "induct_implies C (induct_conj A B) =
   303     induct_conj (induct_implies C A) (induct_implies C B)"
   304   by (unfold induct_implies_def induct_conj_def) blast
   305 
   306 lemma induct_conj_curry: "(induct_conj A B ==> C) == (A ==> B ==> C)"
   307   by (simp only: atomize_imp atomize_eq induct_conj_def) (rule equal_intr_rule, blast+)
   308 
   309 lemma induct_impliesI: "(A ==> B) ==> induct_implies A B"
   310   by (simp add: induct_implies_def)
   311 
   312 lemmas induct_atomize = induct_forall_eq induct_implies_eq induct_equal_eq
   313 lemmas induct_rulify1 = induct_atomize [symmetric, standard]
   314 lemmas induct_rulify2 =
   315   induct_forall_def induct_implies_def induct_equal_def induct_conj_def
   316 lemmas induct_conj = induct_forall_conj induct_implies_conj induct_conj_curry
   317 
   318 hide const induct_forall induct_implies induct_equal induct_conj
   319 
   320 
   321 text {* Method setup. *}
   322 
   323 ML {*
   324   structure InductMethod = InductMethodFun
   325   (struct
   326     val dest_concls = HOLogic.dest_concls;
   327     val cases_default = thm "case_split";
   328     val local_impI = thm "induct_impliesI";
   329     val conjI = thm "conjI";
   330     val atomize = thms "induct_atomize";
   331     val rulify1 = thms "induct_rulify1";
   332     val rulify2 = thms "induct_rulify2";
   333   end);
   334 *}
   335 
   336 setup InductMethod.setup
   337 
   338 
   339 subsection {* Order signatures and orders *}
   340 
   341 axclass
   342   ord < "term"
   343 
   344 syntax
   345   "op <"        :: "['a::ord, 'a] => bool"             ("op <")
   346   "op <="       :: "['a::ord, 'a] => bool"             ("op <=")
   347 
   348 global
   349 
   350 consts
   351   "op <"        :: "['a::ord, 'a] => bool"             ("(_/ < _)"  [50, 51] 50)
   352   "op <="       :: "['a::ord, 'a] => bool"             ("(_/ <= _)" [50, 51] 50)
   353 
   354 local
   355 
   356 syntax (symbols)
   357   "op <="       :: "['a::ord, 'a] => bool"             ("op \<le>")
   358   "op <="       :: "['a::ord, 'a] => bool"             ("(_/ \<le> _)"  [50, 51] 50)
   359 
   360 (*Tell blast about overloading of < and <= to reduce the risk of
   361   its applying a rule for the wrong type*)
   362 ML {*
   363 Blast.overloaded ("op <" , domain_type);
   364 Blast.overloaded ("op <=", domain_type);
   365 *}
   366 
   367 
   368 subsubsection {* Monotonicity *}
   369 
   370 constdefs
   371   mono :: "['a::ord => 'b::ord] => bool"
   372   "mono f == ALL A B. A <= B --> f A <= f B"
   373 
   374 lemma monoI [intro?]: "(!!A B. A <= B ==> f A <= f B) ==> mono f"
   375   by (unfold mono_def) blast
   376 
   377 lemma monoD [dest?]: "mono f ==> A <= B ==> f A <= f B"
   378   by (unfold mono_def) blast
   379 
   380 constdefs
   381   min :: "['a::ord, 'a] => 'a"
   382   "min a b == (if a <= b then a else b)"
   383   max :: "['a::ord, 'a] => 'a"
   384   "max a b == (if a <= b then b else a)"
   385 
   386 lemma min_leastL: "(!!x. least <= x) ==> min least x = least"
   387   by (simp add: min_def)
   388 
   389 lemma min_of_mono:
   390     "ALL x y. (f x <= f y) = (x <= y) ==> min (f m) (f n) = f (min m n)"
   391   by (simp add: min_def)
   392 
   393 lemma max_leastL: "(!!x. least <= x) ==> max least x = x"
   394   by (simp add: max_def)
   395 
   396 lemma max_of_mono:
   397     "ALL x y. (f x <= f y) = (x <= y) ==> max (f m) (f n) = f (max m n)"
   398   by (simp add: max_def)
   399 
   400 
   401 subsubsection "Orders"
   402 
   403 axclass order < ord
   404   order_refl [iff]: "x <= x"
   405   order_trans: "x <= y ==> y <= z ==> x <= z"
   406   order_antisym: "x <= y ==> y <= x ==> x = y"
   407   order_less_le: "(x < y) = (x <= y & x ~= y)"
   408 
   409 
   410 text {* Reflexivity. *}
   411 
   412 lemma order_eq_refl: "!!x::'a::order. x = y ==> x <= y"
   413     -- {* This form is useful with the classical reasoner. *}
   414   apply (erule ssubst)
   415   apply (rule order_refl)
   416   done
   417 
   418 lemma order_less_irrefl [simp]: "~ x < (x::'a::order)"
   419   by (simp add: order_less_le)
   420 
   421 lemma order_le_less: "((x::'a::order) <= y) = (x < y | x = y)"
   422     -- {* NOT suitable for iff, since it can cause PROOF FAILED. *}
   423   apply (simp add: order_less_le)
   424   apply (blast intro!: order_refl)
   425   done
   426 
   427 lemmas order_le_imp_less_or_eq = order_le_less [THEN iffD1, standard]
   428 
   429 lemma order_less_imp_le: "!!x::'a::order. x < y ==> x <= y"
   430   by (simp add: order_less_le)
   431 
   432 
   433 text {* Asymmetry. *}
   434 
   435 lemma order_less_not_sym: "(x::'a::order) < y ==> ~ (y < x)"
   436   by (simp add: order_less_le order_antisym)
   437 
   438 lemma order_less_asym: "x < (y::'a::order) ==> (~P ==> y < x) ==> P"
   439   apply (drule order_less_not_sym)
   440   apply (erule contrapos_np)
   441   apply simp
   442   done
   443 
   444 
   445 text {* Transitivity. *}
   446 
   447 lemma order_less_trans: "!!x::'a::order. [| x < y; y < z |] ==> x < z"
   448   apply (simp add: order_less_le)
   449   apply (blast intro: order_trans order_antisym)
   450   done
   451 
   452 lemma order_le_less_trans: "!!x::'a::order. [| x <= y; y < z |] ==> x < z"
   453   apply (simp add: order_less_le)
   454   apply (blast intro: order_trans order_antisym)
   455   done
   456 
   457 lemma order_less_le_trans: "!!x::'a::order. [| x < y; y <= z |] ==> x < z"
   458   apply (simp add: order_less_le)
   459   apply (blast intro: order_trans order_antisym)
   460   done
   461 
   462 
   463 text {* Useful for simplification, but too risky to include by default. *}
   464 
   465 lemma order_less_imp_not_less: "(x::'a::order) < y ==>  (~ y < x) = True"
   466   by (blast elim: order_less_asym)
   467 
   468 lemma order_less_imp_triv: "(x::'a::order) < y ==>  (y < x --> P) = True"
   469   by (blast elim: order_less_asym)
   470 
   471 lemma order_less_imp_not_eq: "(x::'a::order) < y ==>  (x = y) = False"
   472   by auto
   473 
   474 lemma order_less_imp_not_eq2: "(x::'a::order) < y ==>  (y = x) = False"
   475   by auto
   476 
   477 
   478 text {* Other operators. *}
   479 
   480 lemma min_leastR: "(!!x::'a::order. least <= x) ==> min x least = least"
   481   apply (simp add: min_def)
   482   apply (blast intro: order_antisym)
   483   done
   484 
   485 lemma max_leastR: "(!!x::'a::order. least <= x) ==> max x least = x"
   486   apply (simp add: max_def)
   487   apply (blast intro: order_antisym)
   488   done
   489 
   490 
   491 subsubsection {* Least value operator *}
   492 
   493 constdefs
   494   Least :: "('a::ord => bool) => 'a"               (binder "LEAST " 10)
   495   "Least P == THE x. P x & (ALL y. P y --> x <= y)"
   496     -- {* We can no longer use LeastM because the latter requires Hilbert-AC. *}
   497 
   498 lemma LeastI2:
   499   "[| P (x::'a::order);
   500       !!y. P y ==> x <= y;
   501       !!x. [| P x; ALL y. P y --> x \<le> y |] ==> Q x |]
   502    ==> Q (Least P)";
   503   apply (unfold Least_def)
   504   apply (rule theI2)
   505     apply (blast intro: order_antisym)+
   506   done
   507 
   508 lemma Least_equality:
   509     "[| P (k::'a::order); !!x. P x ==> k <= x |] ==> (LEAST x. P x) = k";
   510   apply (simp add: Least_def)
   511   apply (rule the_equality)
   512   apply (auto intro!: order_antisym)
   513   done
   514 
   515 
   516 subsubsection "Linear / total orders"
   517 
   518 axclass linorder < order
   519   linorder_linear: "x <= y | y <= x"
   520 
   521 lemma linorder_less_linear: "!!x::'a::linorder. x<y | x=y | y<x"
   522   apply (simp add: order_less_le)
   523   apply (insert linorder_linear)
   524   apply blast
   525   done
   526 
   527 lemma linorder_cases [case_names less equal greater]:
   528     "((x::'a::linorder) < y ==> P) ==> (x = y ==> P) ==> (y < x ==> P) ==> P"
   529   apply (insert linorder_less_linear)
   530   apply blast
   531   done
   532 
   533 lemma linorder_not_less: "!!x::'a::linorder. (~ x < y) = (y <= x)"
   534   apply (simp add: order_less_le)
   535   apply (insert linorder_linear)
   536   apply (blast intro: order_antisym)
   537   done
   538 
   539 lemma linorder_not_le: "!!x::'a::linorder. (~ x <= y) = (y < x)"
   540   apply (simp add: order_less_le)
   541   apply (insert linorder_linear)
   542   apply (blast intro: order_antisym)
   543   done
   544 
   545 lemma linorder_neq_iff: "!!x::'a::linorder. (x ~= y) = (x<y | y<x)"
   546   apply (cut_tac x = x and y = y in linorder_less_linear)
   547   apply auto
   548   done
   549 
   550 lemma linorder_neqE: "x ~= (y::'a::linorder) ==> (x < y ==> R) ==> (y < x ==> R) ==> R"
   551   apply (simp add: linorder_neq_iff)
   552   apply blast
   553   done
   554 
   555 
   556 subsubsection "Min and max on (linear) orders"
   557 
   558 lemma min_same [simp]: "min (x::'a::order) x = x"
   559   by (simp add: min_def)
   560 
   561 lemma max_same [simp]: "max (x::'a::order) x = x"
   562   by (simp add: max_def)
   563 
   564 lemma le_max_iff_disj: "!!z::'a::linorder. (z <= max x y) = (z <= x | z <= y)"
   565   apply (simp add: max_def)
   566   apply (insert linorder_linear)
   567   apply (blast intro: order_trans)
   568   done
   569 
   570 lemma le_maxI1: "(x::'a::linorder) <= max x y"
   571   by (simp add: le_max_iff_disj)
   572 
   573 lemma le_maxI2: "(y::'a::linorder) <= max x y"
   574     -- {* CANNOT use with @{text "[intro!]"} because blast will give PROOF FAILED. *}
   575   by (simp add: le_max_iff_disj)
   576 
   577 lemma less_max_iff_disj: "!!z::'a::linorder. (z < max x y) = (z < x | z < y)"
   578   apply (simp add: max_def order_le_less)
   579   apply (insert linorder_less_linear)
   580   apply (blast intro: order_less_trans)
   581   done
   582 
   583 lemma max_le_iff_conj [simp]:
   584     "!!z::'a::linorder. (max x y <= z) = (x <= z & y <= z)"
   585   apply (simp add: max_def)
   586   apply (insert linorder_linear)
   587   apply (blast intro: order_trans)
   588   done
   589 
   590 lemma max_less_iff_conj [simp]:
   591     "!!z::'a::linorder. (max x y < z) = (x < z & y < z)"
   592   apply (simp add: order_le_less max_def)
   593   apply (insert linorder_less_linear)
   594   apply (blast intro: order_less_trans)
   595   done
   596 
   597 lemma le_min_iff_conj [simp]:
   598     "!!z::'a::linorder. (z <= min x y) = (z <= x & z <= y)"
   599     -- {* @{text "[iff]"} screws up a Q{text blast} in MiniML *}
   600   apply (simp add: min_def)
   601   apply (insert linorder_linear)
   602   apply (blast intro: order_trans)
   603   done
   604 
   605 lemma min_less_iff_conj [simp]:
   606     "!!z::'a::linorder. (z < min x y) = (z < x & z < y)"
   607   apply (simp add: order_le_less min_def)
   608   apply (insert linorder_less_linear)
   609   apply (blast intro: order_less_trans)
   610   done
   611 
   612 lemma min_le_iff_disj: "!!z::'a::linorder. (min x y <= z) = (x <= z | y <= z)"
   613   apply (simp add: min_def)
   614   apply (insert linorder_linear)
   615   apply (blast intro: order_trans)
   616   done
   617 
   618 lemma min_less_iff_disj: "!!z::'a::linorder. (min x y < z) = (x < z | y < z)"
   619   apply (simp add: min_def order_le_less)
   620   apply (insert linorder_less_linear)
   621   apply (blast intro: order_less_trans)
   622   done
   623 
   624 lemma split_min:
   625     "P (min (i::'a::linorder) j) = ((i <= j --> P(i)) & (~ i <= j --> P(j)))"
   626   by (simp add: min_def)
   627 
   628 lemma split_max:
   629     "P (max (i::'a::linorder) j) = ((i <= j --> P(j)) & (~ i <= j --> P(i)))"
   630   by (simp add: max_def)
   631 
   632 
   633 subsubsection "Bounded quantifiers"
   634 
   635 syntax
   636   "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3ALL _<_./ _)"  [0, 0, 10] 10)
   637   "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3EX _<_./ _)"  [0, 0, 10] 10)
   638   "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3ALL _<=_./ _)" [0, 0, 10] 10)
   639   "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3EX _<=_./ _)" [0, 0, 10] 10)
   640 
   641 syntax (symbols)
   642   "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_<_./ _)"  [0, 0, 10] 10)
   643   "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_<_./ _)"  [0, 0, 10] 10)
   644   "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10)
   645   "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10)
   646 
   647 syntax (HOL)
   648   "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3! _<_./ _)"  [0, 0, 10] 10)
   649   "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3? _<_./ _)"  [0, 0, 10] 10)
   650   "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3! _<=_./ _)" [0, 0, 10] 10)
   651   "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3? _<=_./ _)" [0, 0, 10] 10)
   652 
   653 translations
   654  "ALL x<y. P"   =>  "ALL x. x < y --> P"
   655  "EX x<y. P"    =>  "EX x. x < y  & P"
   656  "ALL x<=y. P"  =>  "ALL x. x <= y --> P"
   657  "EX x<=y. P"   =>  "EX x. x <= y & P"
   658 
   659 end