src/HOL/HOL.thy
author wenzelm
Wed Oct 31 21:58:04 2001 +0100 (2001-10-31)
changeset 12003 c09427e5f554
parent 11989 d4bcba4e080e
child 12023 d982f98e0f0d
permissions -rw-r--r--
removed obsolete (rule equal_intr_rule);
     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]: "(!!C. (A ==> B ==> PROP C) ==> PROP C) == Trueprop (A & B)"
   236 proof
   237   assume "!!C. (A ==> B ==> PROP C) ==> PROP C"
   238   show "A & B" by (rule conjI)
   239 next
   240   fix C
   241   assume "A & B"
   242   assume "A ==> B ==> PROP C"
   243   thus "PROP C"
   244   proof this
   245     show A by (rule conjunct1)
   246     show B by (rule conjunct2)
   247   qed
   248 qed
   249 
   250 
   251 subsubsection {* Classical Reasoner setup *}
   252 
   253 use "cladata.ML"
   254 setup hypsubst_setup
   255 
   256 declare atomize_all [symmetric, rulify]  atomize_imp [symmetric, rulify]
   257 
   258 setup Classical.setup
   259 setup clasetup
   260 
   261 declare ext [intro?]
   262 declare disjI1 [elim?]  disjI2 [elim?]  ex1_implies_ex [elim?]  sym [elim?]
   263 
   264 use "blastdata.ML"
   265 setup Blast.setup
   266 
   267 
   268 subsubsection {* Simplifier setup *}
   269 
   270 use "simpdata.ML"
   271 setup Simplifier.setup
   272 setup "Simplifier.method_setup Splitter.split_modifiers" setup simpsetup
   273 setup Splitter.setup setup Clasimp.setup
   274 
   275 
   276 subsubsection {* Generic cases and induction *}
   277 
   278 constdefs
   279   induct_forall :: "('a => bool) => bool"
   280   "induct_forall P == \<forall>x. P x"
   281   induct_implies :: "bool => bool => bool"
   282   "induct_implies A B == A --> B"
   283   induct_equal :: "'a => 'a => bool"
   284   "induct_equal x y == x = y"
   285   induct_conj :: "bool => bool => bool"
   286   "induct_conj A B == A & B"
   287 
   288 lemma induct_forall_eq: "(!!x. P x) == Trueprop (induct_forall (\<lambda>x. P x))"
   289   by (simp only: atomize_all induct_forall_def)
   290 
   291 lemma induct_implies_eq: "(A ==> B) == Trueprop (induct_implies A B)"
   292   by (simp only: atomize_imp induct_implies_def)
   293 
   294 lemma induct_equal_eq: "(x == y) == Trueprop (induct_equal x y)"
   295   by (simp only: atomize_eq induct_equal_def)
   296 
   297 lemma induct_forall_conj: "induct_forall (\<lambda>x. induct_conj (A x) (B x)) =
   298     induct_conj (induct_forall A) (induct_forall B)"
   299   by (unfold induct_forall_def induct_conj_def) blast
   300 
   301 lemma induct_implies_conj: "induct_implies C (induct_conj A B) =
   302     induct_conj (induct_implies C A) (induct_implies C B)"
   303   by (unfold induct_implies_def induct_conj_def) blast
   304 
   305 lemma induct_conj_curry: "(induct_conj A B ==> C) == (A ==> B ==> C)"
   306   by (simp only: atomize_imp atomize_eq induct_conj_def) (rule equal_intr_rule, blast+)
   307 
   308 lemma induct_impliesI: "(A ==> B) ==> induct_implies A B"
   309   by (simp add: induct_implies_def)
   310 
   311 lemmas induct_atomize = induct_forall_eq induct_implies_eq induct_equal_eq
   312 lemmas induct_rulify1 = induct_atomize [symmetric, standard]
   313 lemmas induct_rulify2 =
   314   induct_forall_def induct_implies_def induct_equal_def induct_conj_def
   315 lemmas induct_conj = induct_forall_conj induct_implies_conj induct_conj_curry
   316 
   317 hide const induct_forall induct_implies induct_equal induct_conj
   318 
   319 
   320 text {* Method setup. *}
   321 
   322 ML {*
   323   structure InductMethod = InductMethodFun
   324   (struct
   325     val dest_concls = HOLogic.dest_concls;
   326     val cases_default = thm "case_split";
   327     val local_impI = thm "induct_impliesI";
   328     val conjI = thm "conjI";
   329     val atomize = thms "induct_atomize";
   330     val rulify1 = thms "induct_rulify1";
   331     val rulify2 = thms "induct_rulify2";
   332   end);
   333 *}
   334 
   335 setup InductMethod.setup
   336 
   337 
   338 subsection {* Order signatures and orders *}
   339 
   340 axclass
   341   ord < "term"
   342 
   343 syntax
   344   "op <"        :: "['a::ord, 'a] => bool"             ("op <")
   345   "op <="       :: "['a::ord, 'a] => bool"             ("op <=")
   346 
   347 global
   348 
   349 consts
   350   "op <"        :: "['a::ord, 'a] => bool"             ("(_/ < _)"  [50, 51] 50)
   351   "op <="       :: "['a::ord, 'a] => bool"             ("(_/ <= _)" [50, 51] 50)
   352 
   353 local
   354 
   355 syntax (symbols)
   356   "op <="       :: "['a::ord, 'a] => bool"             ("op \<le>")
   357   "op <="       :: "['a::ord, 'a] => bool"             ("(_/ \<le> _)"  [50, 51] 50)
   358 
   359 (*Tell blast about overloading of < and <= to reduce the risk of
   360   its applying a rule for the wrong type*)
   361 ML {*
   362 Blast.overloaded ("op <" , domain_type);
   363 Blast.overloaded ("op <=", domain_type);
   364 *}
   365 
   366 
   367 subsubsection {* Monotonicity *}
   368 
   369 constdefs
   370   mono :: "['a::ord => 'b::ord] => bool"
   371   "mono f == ALL A B. A <= B --> f A <= f B"
   372 
   373 lemma monoI [intro?]: "(!!A B. A <= B ==> f A <= f B) ==> mono f"
   374   by (unfold mono_def) blast
   375 
   376 lemma monoD [dest?]: "mono f ==> A <= B ==> f A <= f B"
   377   by (unfold mono_def) blast
   378 
   379 constdefs
   380   min :: "['a::ord, 'a] => 'a"
   381   "min a b == (if a <= b then a else b)"
   382   max :: "['a::ord, 'a] => 'a"
   383   "max a b == (if a <= b then b else a)"
   384 
   385 lemma min_leastL: "(!!x. least <= x) ==> min least x = least"
   386   by (simp add: min_def)
   387 
   388 lemma min_of_mono:
   389     "ALL x y. (f x <= f y) = (x <= y) ==> min (f m) (f n) = f (min m n)"
   390   by (simp add: min_def)
   391 
   392 lemma max_leastL: "(!!x. least <= x) ==> max least x = x"
   393   by (simp add: max_def)
   394 
   395 lemma max_of_mono:
   396     "ALL x y. (f x <= f y) = (x <= y) ==> max (f m) (f n) = f (max m n)"
   397   by (simp add: max_def)
   398 
   399 
   400 subsubsection "Orders"
   401 
   402 axclass order < ord
   403   order_refl [iff]: "x <= x"
   404   order_trans: "x <= y ==> y <= z ==> x <= z"
   405   order_antisym: "x <= y ==> y <= x ==> x = y"
   406   order_less_le: "(x < y) = (x <= y & x ~= y)"
   407 
   408 
   409 text {* Reflexivity. *}
   410 
   411 lemma order_eq_refl: "!!x::'a::order. x = y ==> x <= y"
   412     -- {* This form is useful with the classical reasoner. *}
   413   apply (erule ssubst)
   414   apply (rule order_refl)
   415   done
   416 
   417 lemma order_less_irrefl [simp]: "~ x < (x::'a::order)"
   418   by (simp add: order_less_le)
   419 
   420 lemma order_le_less: "((x::'a::order) <= y) = (x < y | x = y)"
   421     -- {* NOT suitable for iff, since it can cause PROOF FAILED. *}
   422   apply (simp add: order_less_le)
   423   apply (blast intro!: order_refl)
   424   done
   425 
   426 lemmas order_le_imp_less_or_eq = order_le_less [THEN iffD1, standard]
   427 
   428 lemma order_less_imp_le: "!!x::'a::order. x < y ==> x <= y"
   429   by (simp add: order_less_le)
   430 
   431 
   432 text {* Asymmetry. *}
   433 
   434 lemma order_less_not_sym: "(x::'a::order) < y ==> ~ (y < x)"
   435   by (simp add: order_less_le order_antisym)
   436 
   437 lemma order_less_asym: "x < (y::'a::order) ==> (~P ==> y < x) ==> P"
   438   apply (drule order_less_not_sym)
   439   apply (erule contrapos_np)
   440   apply simp
   441   done
   442 
   443 
   444 text {* Transitivity. *}
   445 
   446 lemma order_less_trans: "!!x::'a::order. [| x < y; y < z |] ==> x < z"
   447   apply (simp add: order_less_le)
   448   apply (blast intro: order_trans order_antisym)
   449   done
   450 
   451 lemma order_le_less_trans: "!!x::'a::order. [| x <= y; y < z |] ==> x < z"
   452   apply (simp add: order_less_le)
   453   apply (blast intro: order_trans order_antisym)
   454   done
   455 
   456 lemma order_less_le_trans: "!!x::'a::order. [| x < y; y <= z |] ==> x < z"
   457   apply (simp add: order_less_le)
   458   apply (blast intro: order_trans order_antisym)
   459   done
   460 
   461 
   462 text {* Useful for simplification, but too risky to include by default. *}
   463 
   464 lemma order_less_imp_not_less: "(x::'a::order) < y ==>  (~ y < x) = True"
   465   by (blast elim: order_less_asym)
   466 
   467 lemma order_less_imp_triv: "(x::'a::order) < y ==>  (y < x --> P) = True"
   468   by (blast elim: order_less_asym)
   469 
   470 lemma order_less_imp_not_eq: "(x::'a::order) < y ==>  (x = y) = False"
   471   by auto
   472 
   473 lemma order_less_imp_not_eq2: "(x::'a::order) < y ==>  (y = x) = False"
   474   by auto
   475 
   476 
   477 text {* Other operators. *}
   478 
   479 lemma min_leastR: "(!!x::'a::order. least <= x) ==> min x least = least"
   480   apply (simp add: min_def)
   481   apply (blast intro: order_antisym)
   482   done
   483 
   484 lemma max_leastR: "(!!x::'a::order. least <= x) ==> max x least = x"
   485   apply (simp add: max_def)
   486   apply (blast intro: order_antisym)
   487   done
   488 
   489 
   490 subsubsection {* Least value operator *}
   491 
   492 constdefs
   493   Least :: "('a::ord => bool) => 'a"               (binder "LEAST " 10)
   494   "Least P == THE x. P x & (ALL y. P y --> x <= y)"
   495     -- {* We can no longer use LeastM because the latter requires Hilbert-AC. *}
   496 
   497 lemma LeastI2:
   498   "[| P (x::'a::order);
   499       !!y. P y ==> x <= y;
   500       !!x. [| P x; ALL y. P y --> x \<le> y |] ==> Q x |]
   501    ==> Q (Least P)";
   502   apply (unfold Least_def)
   503   apply (rule theI2)
   504     apply (blast intro: order_antisym)+
   505   done
   506 
   507 lemma Least_equality:
   508     "[| P (k::'a::order); !!x. P x ==> k <= x |] ==> (LEAST x. P x) = k";
   509   apply (simp add: Least_def)
   510   apply (rule the_equality)
   511   apply (auto intro!: order_antisym)
   512   done
   513 
   514 
   515 subsubsection "Linear / total orders"
   516 
   517 axclass linorder < order
   518   linorder_linear: "x <= y | y <= x"
   519 
   520 lemma linorder_less_linear: "!!x::'a::linorder. x<y | x=y | y<x"
   521   apply (simp add: order_less_le)
   522   apply (insert linorder_linear)
   523   apply blast
   524   done
   525 
   526 lemma linorder_cases [case_names less equal greater]:
   527     "((x::'a::linorder) < y ==> P) ==> (x = y ==> P) ==> (y < x ==> P) ==> P"
   528   apply (insert linorder_less_linear)
   529   apply blast
   530   done
   531 
   532 lemma linorder_not_less: "!!x::'a::linorder. (~ x < y) = (y <= x)"
   533   apply (simp add: order_less_le)
   534   apply (insert linorder_linear)
   535   apply (blast intro: order_antisym)
   536   done
   537 
   538 lemma linorder_not_le: "!!x::'a::linorder. (~ x <= y) = (y < x)"
   539   apply (simp add: order_less_le)
   540   apply (insert linorder_linear)
   541   apply (blast intro: order_antisym)
   542   done
   543 
   544 lemma linorder_neq_iff: "!!x::'a::linorder. (x ~= y) = (x<y | y<x)"
   545   apply (cut_tac x = x and y = y in linorder_less_linear)
   546   apply auto
   547   done
   548 
   549 lemma linorder_neqE: "x ~= (y::'a::linorder) ==> (x < y ==> R) ==> (y < x ==> R) ==> R"
   550   apply (simp add: linorder_neq_iff)
   551   apply blast
   552   done
   553 
   554 
   555 subsubsection "Min and max on (linear) orders"
   556 
   557 lemma min_same [simp]: "min (x::'a::order) x = x"
   558   by (simp add: min_def)
   559 
   560 lemma max_same [simp]: "max (x::'a::order) x = x"
   561   by (simp add: max_def)
   562 
   563 lemma le_max_iff_disj: "!!z::'a::linorder. (z <= max x y) = (z <= x | z <= y)"
   564   apply (simp add: max_def)
   565   apply (insert linorder_linear)
   566   apply (blast intro: order_trans)
   567   done
   568 
   569 lemma le_maxI1: "(x::'a::linorder) <= max x y"
   570   by (simp add: le_max_iff_disj)
   571 
   572 lemma le_maxI2: "(y::'a::linorder) <= max x y"
   573     -- {* CANNOT use with @{text "[intro!]"} because blast will give PROOF FAILED. *}
   574   by (simp add: le_max_iff_disj)
   575 
   576 lemma less_max_iff_disj: "!!z::'a::linorder. (z < max x y) = (z < x | z < y)"
   577   apply (simp add: max_def order_le_less)
   578   apply (insert linorder_less_linear)
   579   apply (blast intro: order_less_trans)
   580   done
   581 
   582 lemma max_le_iff_conj [simp]:
   583     "!!z::'a::linorder. (max x y <= z) = (x <= z & y <= z)"
   584   apply (simp add: max_def)
   585   apply (insert linorder_linear)
   586   apply (blast intro: order_trans)
   587   done
   588 
   589 lemma max_less_iff_conj [simp]:
   590     "!!z::'a::linorder. (max x y < z) = (x < z & y < z)"
   591   apply (simp add: order_le_less max_def)
   592   apply (insert linorder_less_linear)
   593   apply (blast intro: order_less_trans)
   594   done
   595 
   596 lemma le_min_iff_conj [simp]:
   597     "!!z::'a::linorder. (z <= min x y) = (z <= x & z <= y)"
   598     -- {* @{text "[iff]"} screws up a Q{text blast} in MiniML *}
   599   apply (simp add: min_def)
   600   apply (insert linorder_linear)
   601   apply (blast intro: order_trans)
   602   done
   603 
   604 lemma min_less_iff_conj [simp]:
   605     "!!z::'a::linorder. (z < min x y) = (z < x & z < y)"
   606   apply (simp add: order_le_less min_def)
   607   apply (insert linorder_less_linear)
   608   apply (blast intro: order_less_trans)
   609   done
   610 
   611 lemma min_le_iff_disj: "!!z::'a::linorder. (min x y <= z) = (x <= z | y <= z)"
   612   apply (simp add: min_def)
   613   apply (insert linorder_linear)
   614   apply (blast intro: order_trans)
   615   done
   616 
   617 lemma min_less_iff_disj: "!!z::'a::linorder. (min x y < z) = (x < z | y < z)"
   618   apply (simp add: min_def order_le_less)
   619   apply (insert linorder_less_linear)
   620   apply (blast intro: order_less_trans)
   621   done
   622 
   623 lemma split_min:
   624     "P (min (i::'a::linorder) j) = ((i <= j --> P(i)) & (~ i <= j --> P(j)))"
   625   by (simp add: min_def)
   626 
   627 lemma split_max:
   628     "P (max (i::'a::linorder) j) = ((i <= j --> P(j)) & (~ i <= j --> P(i)))"
   629   by (simp add: max_def)
   630 
   631 
   632 subsubsection "Bounded quantifiers"
   633 
   634 syntax
   635   "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3ALL _<_./ _)"  [0, 0, 10] 10)
   636   "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3EX _<_./ _)"  [0, 0, 10] 10)
   637   "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3ALL _<=_./ _)" [0, 0, 10] 10)
   638   "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3EX _<=_./ _)" [0, 0, 10] 10)
   639 
   640 syntax (symbols)
   641   "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_<_./ _)"  [0, 0, 10] 10)
   642   "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_<_./ _)"  [0, 0, 10] 10)
   643   "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10)
   644   "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10)
   645 
   646 syntax (HOL)
   647   "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3! _<_./ _)"  [0, 0, 10] 10)
   648   "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3? _<_./ _)"  [0, 0, 10] 10)
   649   "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3! _<=_./ _)" [0, 0, 10] 10)
   650   "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3? _<=_./ _)" [0, 0, 10] 10)
   651 
   652 translations
   653  "ALL x<y. P"   =>  "ALL x. x < y --> P"
   654  "EX x<y. P"    =>  "EX x. x < y  & P"
   655  "ALL x<=y. P"  =>  "ALL x. x <= y --> P"
   656  "EX x<=y. P"   =>  "EX x. x <= y & P"
   657 
   658 end