src/HOL/HOL.thy
author kleing
Wed Apr 14 14:13:05 2004 +0200 (2004-04-14)
changeset 14565 c6dc17aab88a
parent 14444 24724afce166
child 14590 276ef51cedbf
permissions -rw-r--r--
use more symbols in HTML output
     1 (*  Title:      HOL/HOL.thy
     2     ID:         $Id$
     3     Author:     Tobias Nipkow, Markus Wenzel, and Larry Paulson
     4     License:    GPL (GNU GENERAL PUBLIC LICENSE)
     5 *)
     6 
     7 header {* The basis of Higher-Order Logic *}
     8 
     9 theory HOL = CPure
    10 files ("HOL_lemmas.ML") ("cladata.ML") ("blastdata.ML") ("simpdata.ML"):
    11 
    12 
    13 subsection {* Primitive logic *}
    14 
    15 subsubsection {* Core syntax *}
    16 
    17 classes type < logic
    18 defaultsort type
    19 
    20 global
    21 
    22 typedecl bool
    23 
    24 arities
    25   bool :: type
    26   fun :: (type, type) type
    27 
    28 judgment
    29   Trueprop      :: "bool => prop"                   ("(_)" 5)
    30 
    31 consts
    32   Not           :: "bool => bool"                   ("~ _" [40] 40)
    33   True          :: bool
    34   False         :: bool
    35   If            :: "[bool, 'a, 'a] => 'a"           ("(if (_)/ then (_)/ else (_))" 10)
    36   arbitrary     :: 'a
    37 
    38   The           :: "('a => bool) => 'a"
    39   All           :: "('a => bool) => bool"           (binder "ALL " 10)
    40   Ex            :: "('a => bool) => bool"           (binder "EX " 10)
    41   Ex1           :: "('a => bool) => bool"           (binder "EX! " 10)
    42   Let           :: "['a, 'a => 'b] => 'b"
    43 
    44   "="           :: "['a, 'a] => bool"               (infixl 50)
    45   &             :: "[bool, bool] => bool"           (infixr 35)
    46   "|"           :: "[bool, bool] => bool"           (infixr 30)
    47   -->           :: "[bool, bool] => bool"           (infixr 25)
    48 
    49 local
    50 
    51 
    52 subsubsection {* Additional concrete syntax *}
    53 
    54 nonterminals
    55   letbinds  letbind
    56   case_syn  cases_syn
    57 
    58 syntax
    59   "_not_equal"  :: "['a, 'a] => bool"                    (infixl "~=" 50)
    60   "_The"        :: "[pttrn, bool] => 'a"                 ("(3THE _./ _)" [0, 10] 10)
    61 
    62   "_bind"       :: "[pttrn, 'a] => letbind"              ("(2_ =/ _)" 10)
    63   ""            :: "letbind => letbinds"                 ("_")
    64   "_binds"      :: "[letbind, letbinds] => letbinds"     ("_;/ _")
    65   "_Let"        :: "[letbinds, 'a] => 'a"                ("(let (_)/ in (_))" 10)
    66 
    67   "_case_syntax":: "['a, cases_syn] => 'b"               ("(case _ of/ _)" 10)
    68   "_case1"      :: "['a, 'b] => case_syn"                ("(2_ =>/ _)" 10)
    69   ""            :: "case_syn => cases_syn"               ("_")
    70   "_case2"      :: "[case_syn, cases_syn] => cases_syn"  ("_/ | _")
    71 
    72 translations
    73   "x ~= y"                == "~ (x = y)"
    74   "THE x. P"              == "The (%x. P)"
    75   "_Let (_binds b bs) e"  == "_Let b (_Let bs e)"
    76   "let x = a in e"        == "Let a (%x. e)"
    77 
    78 print_translation {*
    79 (* To avoid eta-contraction of body: *)
    80 [("The", fn [Abs abs] =>
    81      let val (x,t) = atomic_abs_tr' abs
    82      in Syntax.const "_The" $ x $ t end)]
    83 *}
    84 
    85 syntax (output)
    86   "="           :: "['a, 'a] => bool"                    (infix 50)
    87   "_not_equal"  :: "['a, 'a] => bool"                    (infix "~=" 50)
    88 
    89 syntax (xsymbols)
    90   Not           :: "bool => bool"                        ("\<not> _" [40] 40)
    91   "op &"        :: "[bool, bool] => bool"                (infixr "\<and>" 35)
    92   "op |"        :: "[bool, bool] => bool"                (infixr "\<or>" 30)
    93   "op -->"      :: "[bool, bool] => bool"                (infixr "\<longrightarrow>" 25)
    94   "_not_equal"  :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
    95   "ALL "        :: "[idts, bool] => bool"                ("(3\<forall>_./ _)" [0, 10] 10)
    96   "EX "         :: "[idts, bool] => bool"                ("(3\<exists>_./ _)" [0, 10] 10)
    97   "EX! "        :: "[idts, bool] => bool"                ("(3\<exists>!_./ _)" [0, 10] 10)
    98   "_case1"      :: "['a, 'b] => case_syn"                ("(2_ \<Rightarrow>/ _)" 10)
    99 (*"_case2"      :: "[case_syn, cases_syn] => cases_syn"  ("_/ \<orelse> _")*)
   100 
   101 syntax (xsymbols output)
   102   "_not_equal"  :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
   103 
   104 syntax (HTML output)
   105   "_not_equal"  :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
   106   Not           :: "bool => bool"                        ("\<not> _" [40] 40)
   107   "op &"        :: "[bool, bool] => bool"                (infixr "\<and>" 35)
   108   "op |"        :: "[bool, bool] => bool"                (infixr "\<or>" 30)
   109   "_not_equal"  :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
   110   "ALL "        :: "[idts, bool] => bool"                ("(3\<forall>_./ _)" [0, 10] 10)
   111   "EX "         :: "[idts, bool] => bool"                ("(3\<exists>_./ _)" [0, 10] 10)
   112   "EX! "        :: "[idts, bool] => bool"                ("(3\<exists>!_./ _)" [0, 10] 10)
   113 
   114 syntax (HOL)
   115   "ALL "        :: "[idts, bool] => bool"                ("(3! _./ _)" [0, 10] 10)
   116   "EX "         :: "[idts, bool] => bool"                ("(3? _./ _)" [0, 10] 10)
   117   "EX! "        :: "[idts, bool] => bool"                ("(3?! _./ _)" [0, 10] 10)
   118 
   119 
   120 subsubsection {* Axioms and basic definitions *}
   121 
   122 axioms
   123   eq_reflection: "(x=y) ==> (x==y)"
   124 
   125   refl:         "t = (t::'a)"
   126   subst:        "[| s = t; P(s) |] ==> P(t::'a)"
   127 
   128   ext:          "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)"
   129     -- {* Extensionality is built into the meta-logic, and this rule expresses *}
   130     -- {* a related property.  It is an eta-expanded version of the traditional *}
   131     -- {* rule, and similar to the ABS rule of HOL *}
   132 
   133   the_eq_trivial: "(THE x. x = a) = (a::'a)"
   134 
   135   impI:         "(P ==> Q) ==> P-->Q"
   136   mp:           "[| P-->Q;  P |] ==> Q"
   137 
   138 defs
   139   True_def:     "True      == ((%x::bool. x) = (%x. x))"
   140   All_def:      "All(P)    == (P = (%x. True))"
   141   Ex_def:       "Ex(P)     == !Q. (!x. P x --> Q) --> Q"
   142   False_def:    "False     == (!P. P)"
   143   not_def:      "~ P       == P-->False"
   144   and_def:      "P & Q     == !R. (P-->Q-->R) --> R"
   145   or_def:       "P | Q     == !R. (P-->R) --> (Q-->R) --> R"
   146   Ex1_def:      "Ex1(P)    == ? x. P(x) & (! y. P(y) --> y=x)"
   147 
   148 axioms
   149   iff:          "(P-->Q) --> (Q-->P) --> (P=Q)"
   150   True_or_False:  "(P=True) | (P=False)"
   151 
   152 defs
   153   Let_def:      "Let s f == f(s)"
   154   if_def:       "If P x y == THE z::'a. (P=True --> z=x) & (P=False --> z=y)"
   155 
   156 finalconsts
   157   "op ="
   158   "op -->"
   159   The
   160   arbitrary
   161 
   162 subsubsection {* Generic algebraic operations *}
   163 
   164 axclass zero < type
   165 axclass one < type
   166 axclass plus < type
   167 axclass minus < type
   168 axclass times < type
   169 axclass inverse < type
   170 
   171 global
   172 
   173 consts
   174   "0"           :: "'a::zero"                       ("0")
   175   "1"           :: "'a::one"                        ("1")
   176   "+"           :: "['a::plus, 'a]  => 'a"          (infixl 65)
   177   -             :: "['a::minus, 'a] => 'a"          (infixl 65)
   178   uminus        :: "['a::minus] => 'a"              ("- _" [81] 80)
   179   *             :: "['a::times, 'a] => 'a"          (infixl 70)
   180 
   181 syntax
   182   "_index1"  :: index    ("\<^sub>1")
   183 translations
   184   (index) "\<^sub>1" == "_index 1"
   185 
   186 local
   187 
   188 typed_print_translation {*
   189   let
   190     fun tr' c = (c, fn show_sorts => fn T => fn ts =>
   191       if T = dummyT orelse not (! show_types) andalso can Term.dest_Type T then raise Match
   192       else Syntax.const Syntax.constrainC $ Syntax.const c $ Syntax.term_of_typ show_sorts T);
   193   in [tr' "0", tr' "1"] end;
   194 *} -- {* show types that are presumably too general *}
   195 
   196 
   197 consts
   198   abs           :: "'a::minus => 'a"
   199   inverse       :: "'a::inverse => 'a"
   200   divide        :: "['a::inverse, 'a] => 'a"        (infixl "'/" 70)
   201 
   202 syntax (xsymbols)
   203   abs :: "'a::minus => 'a"    ("\<bar>_\<bar>")
   204 syntax (HTML output)
   205   abs :: "'a::minus => 'a"    ("\<bar>_\<bar>")
   206 
   207 
   208 subsection {* Theory and package setup *}
   209 
   210 subsubsection {* Basic lemmas *}
   211 
   212 use "HOL_lemmas.ML"
   213 theorems case_split = case_split_thm [case_names True False]
   214 
   215 
   216 subsubsection {* Intuitionistic Reasoning *}
   217 
   218 lemma impE':
   219   assumes 1: "P --> Q"
   220     and 2: "Q ==> R"
   221     and 3: "P --> Q ==> P"
   222   shows R
   223 proof -
   224   from 3 and 1 have P .
   225   with 1 have Q by (rule impE)
   226   with 2 show R .
   227 qed
   228 
   229 lemma allE':
   230   assumes 1: "ALL x. P x"
   231     and 2: "P x ==> ALL x. P x ==> Q"
   232   shows Q
   233 proof -
   234   from 1 have "P x" by (rule spec)
   235   from this and 1 show Q by (rule 2)
   236 qed
   237 
   238 lemma notE':
   239   assumes 1: "~ P"
   240     and 2: "~ P ==> P"
   241   shows R
   242 proof -
   243   from 2 and 1 have P .
   244   with 1 show R by (rule notE)
   245 qed
   246 
   247 lemmas [CPure.elim!] = disjE iffE FalseE conjE exE
   248   and [CPure.intro!] = iffI conjI impI TrueI notI allI refl
   249   and [CPure.elim 2] = allE notE' impE'
   250   and [CPure.intro] = exI disjI2 disjI1
   251 
   252 lemmas [trans] = trans
   253   and [sym] = sym not_sym
   254   and [CPure.elim?] = iffD1 iffD2 impE
   255 
   256 
   257 subsubsection {* Atomizing meta-level connectives *}
   258 
   259 lemma atomize_all [atomize]: "(!!x. P x) == Trueprop (ALL x. P x)"
   260 proof
   261   assume "!!x. P x"
   262   show "ALL x. P x" by (rule allI)
   263 next
   264   assume "ALL x. P x"
   265   thus "!!x. P x" by (rule allE)
   266 qed
   267 
   268 lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A --> B)"
   269 proof
   270   assume r: "A ==> B"
   271   show "A --> B" by (rule impI) (rule r)
   272 next
   273   assume "A --> B" and A
   274   thus B by (rule mp)
   275 qed
   276 
   277 lemma atomize_eq [atomize]: "(x == y) == Trueprop (x = y)"
   278 proof
   279   assume "x == y"
   280   show "x = y" by (unfold prems) (rule refl)
   281 next
   282   assume "x = y"
   283   thus "x == y" by (rule eq_reflection)
   284 qed
   285 
   286 lemma atomize_conj [atomize]:
   287   "(!!C. (A ==> B ==> PROP C) ==> PROP C) == Trueprop (A & B)"
   288 proof
   289   assume "!!C. (A ==> B ==> PROP C) ==> PROP C"
   290   show "A & B" by (rule conjI)
   291 next
   292   fix C
   293   assume "A & B"
   294   assume "A ==> B ==> PROP C"
   295   thus "PROP C"
   296   proof this
   297     show A by (rule conjunct1)
   298     show B by (rule conjunct2)
   299   qed
   300 qed
   301 
   302 lemmas [symmetric, rulify] = atomize_all atomize_imp
   303 
   304 
   305 subsubsection {* Classical Reasoner setup *}
   306 
   307 use "cladata.ML"
   308 setup hypsubst_setup
   309 
   310 ML_setup {*
   311   Context.>> (ContextRules.addSWrapper (fn tac => hyp_subst_tac' ORELSE' tac));
   312 *}
   313 
   314 setup Classical.setup
   315 setup clasetup
   316 
   317 lemmas [intro?] = ext
   318   and [elim?] = ex1_implies_ex
   319 
   320 use "blastdata.ML"
   321 setup Blast.setup
   322 
   323 
   324 subsubsection {* Simplifier setup *}
   325 
   326 lemma meta_eq_to_obj_eq: "x == y ==> x = y"
   327 proof -
   328   assume r: "x == y"
   329   show "x = y" by (unfold r) (rule refl)
   330 qed
   331 
   332 lemma eta_contract_eq: "(%s. f s) = f" ..
   333 
   334 lemma simp_thms:
   335   shows not_not: "(~ ~ P) = P"
   336   and
   337     "(P ~= Q) = (P = (~Q))"
   338     "(P | ~P) = True"    "(~P | P) = True"
   339     "((~P) = (~Q)) = (P=Q)"
   340     "(x = x) = True"
   341     "(~True) = False"  "(~False) = True"
   342     "(~P) ~= P"  "P ~= (~P)"
   343     "(True=P) = P"  "(P=True) = P"  "(False=P) = (~P)"  "(P=False) = (~P)"
   344     "(True --> P) = P"  "(False --> P) = True"
   345     "(P --> True) = True"  "(P --> P) = True"
   346     "(P --> False) = (~P)"  "(P --> ~P) = (~P)"
   347     "(P & True) = P"  "(True & P) = P"
   348     "(P & False) = False"  "(False & P) = False"
   349     "(P & P) = P"  "(P & (P & Q)) = (P & Q)"
   350     "(P & ~P) = False"    "(~P & P) = False"
   351     "(P | True) = True"  "(True | P) = True"
   352     "(P | False) = P"  "(False | P) = P"
   353     "(P | P) = P"  "(P | (P | Q)) = (P | Q)" and
   354     "(ALL x. P) = P"  "(EX x. P) = P"  "EX x. x=t"  "EX x. t=x"
   355     -- {* needed for the one-point-rule quantifier simplification procs *}
   356     -- {* essential for termination!! *} and
   357     "!!P. (EX x. x=t & P(x)) = P(t)"
   358     "!!P. (EX x. t=x & P(x)) = P(t)"
   359     "!!P. (ALL x. x=t --> P(x)) = P(t)"
   360     "!!P. (ALL x. t=x --> P(x)) = P(t)"
   361   by (blast, blast, blast, blast, blast, rules+)
   362 
   363 lemma imp_cong: "(P = P') ==> (P' ==> (Q = Q')) ==> ((P --> Q) = (P' --> Q'))"
   364   by rules
   365 
   366 lemma ex_simps:
   367   "!!P Q. (EX x. P x & Q)   = ((EX x. P x) & Q)"
   368   "!!P Q. (EX x. P & Q x)   = (P & (EX x. Q x))"
   369   "!!P Q. (EX x. P x | Q)   = ((EX x. P x) | Q)"
   370   "!!P Q. (EX x. P | Q x)   = (P | (EX x. Q x))"
   371   "!!P Q. (EX x. P x --> Q) = ((ALL x. P x) --> Q)"
   372   "!!P Q. (EX x. P --> Q x) = (P --> (EX x. Q x))"
   373   -- {* Miniscoping: pushing in existential quantifiers. *}
   374   by (rules | blast)+
   375 
   376 lemma all_simps:
   377   "!!P Q. (ALL x. P x & Q)   = ((ALL x. P x) & Q)"
   378   "!!P Q. (ALL x. P & Q x)   = (P & (ALL x. Q x))"
   379   "!!P Q. (ALL x. P x | Q)   = ((ALL x. P x) | Q)"
   380   "!!P Q. (ALL x. P | Q x)   = (P | (ALL x. Q x))"
   381   "!!P Q. (ALL x. P x --> Q) = ((EX x. P x) --> Q)"
   382   "!!P Q. (ALL x. P --> Q x) = (P --> (ALL x. Q x))"
   383   -- {* Miniscoping: pushing in universal quantifiers. *}
   384   by (rules | blast)+
   385 
   386 lemma disj_absorb: "(A | A) = A"
   387   by blast
   388 
   389 lemma disj_left_absorb: "(A | (A | B)) = (A | B)"
   390   by blast
   391 
   392 lemma conj_absorb: "(A & A) = A"
   393   by blast
   394 
   395 lemma conj_left_absorb: "(A & (A & B)) = (A & B)"
   396   by blast
   397 
   398 lemma eq_ac:
   399   shows eq_commute: "(a=b) = (b=a)"
   400     and eq_left_commute: "(P=(Q=R)) = (Q=(P=R))"
   401     and eq_assoc: "((P=Q)=R) = (P=(Q=R))" by (rules, blast+)
   402 lemma neq_commute: "(a~=b) = (b~=a)" by rules
   403 
   404 lemma conj_comms:
   405   shows conj_commute: "(P&Q) = (Q&P)"
   406     and conj_left_commute: "(P&(Q&R)) = (Q&(P&R))" by rules+
   407 lemma conj_assoc: "((P&Q)&R) = (P&(Q&R))" by rules
   408 
   409 lemma disj_comms:
   410   shows disj_commute: "(P|Q) = (Q|P)"
   411     and disj_left_commute: "(P|(Q|R)) = (Q|(P|R))" by rules+
   412 lemma disj_assoc: "((P|Q)|R) = (P|(Q|R))" by rules
   413 
   414 lemma conj_disj_distribL: "(P&(Q|R)) = (P&Q | P&R)" by rules
   415 lemma conj_disj_distribR: "((P|Q)&R) = (P&R | Q&R)" by rules
   416 
   417 lemma disj_conj_distribL: "(P|(Q&R)) = ((P|Q) & (P|R))" by rules
   418 lemma disj_conj_distribR: "((P&Q)|R) = ((P|R) & (Q|R))" by rules
   419 
   420 lemma imp_conjR: "(P --> (Q&R)) = ((P-->Q) & (P-->R))" by rules
   421 lemma imp_conjL: "((P&Q) -->R)  = (P --> (Q --> R))" by rules
   422 lemma imp_disjL: "((P|Q) --> R) = ((P-->R)&(Q-->R))" by rules
   423 
   424 text {* These two are specialized, but @{text imp_disj_not1} is useful in @{text "Auth/Yahalom"}. *}
   425 lemma imp_disj_not1: "(P --> Q | R) = (~Q --> P --> R)" by blast
   426 lemma imp_disj_not2: "(P --> Q | R) = (~R --> P --> Q)" by blast
   427 
   428 lemma imp_disj1: "((P-->Q)|R) = (P--> Q|R)" by blast
   429 lemma imp_disj2: "(Q|(P-->R)) = (P--> Q|R)" by blast
   430 
   431 lemma de_Morgan_disj: "(~(P | Q)) = (~P & ~Q)" by rules
   432 lemma de_Morgan_conj: "(~(P & Q)) = (~P | ~Q)" by blast
   433 lemma not_imp: "(~(P --> Q)) = (P & ~Q)" by blast
   434 lemma not_iff: "(P~=Q) = (P = (~Q))" by blast
   435 lemma disj_not1: "(~P | Q) = (P --> Q)" by blast
   436 lemma disj_not2: "(P | ~Q) = (Q --> P)"  -- {* changes orientation :-( *}
   437   by blast
   438 lemma imp_conv_disj: "(P --> Q) = ((~P) | Q)" by blast
   439 
   440 lemma iff_conv_conj_imp: "(P = Q) = ((P --> Q) & (Q --> P))" by rules
   441 
   442 
   443 lemma cases_simp: "((P --> Q) & (~P --> Q)) = Q"
   444   -- {* Avoids duplication of subgoals after @{text split_if}, when the true and false *}
   445   -- {* cases boil down to the same thing. *}
   446   by blast
   447 
   448 lemma not_all: "(~ (! x. P(x))) = (? x.~P(x))" by blast
   449 lemma imp_all: "((! x. P x) --> Q) = (? x. P x --> Q)" by blast
   450 lemma not_ex: "(~ (? x. P(x))) = (! x.~P(x))" by rules
   451 lemma imp_ex: "((? x. P x) --> Q) = (! x. P x --> Q)" by rules
   452 
   453 lemma ex_disj_distrib: "(? x. P(x) | Q(x)) = ((? x. P(x)) | (? x. Q(x)))" by rules
   454 lemma all_conj_distrib: "(!x. P(x) & Q(x)) = ((! x. P(x)) & (! x. Q(x)))" by rules
   455 
   456 text {*
   457   \medskip The @{text "&"} congruence rule: not included by default!
   458   May slow rewrite proofs down by as much as 50\% *}
   459 
   460 lemma conj_cong:
   461     "(P = P') ==> (P' ==> (Q = Q')) ==> ((P & Q) = (P' & Q'))"
   462   by rules
   463 
   464 lemma rev_conj_cong:
   465     "(Q = Q') ==> (Q' ==> (P = P')) ==> ((P & Q) = (P' & Q'))"
   466   by rules
   467 
   468 text {* The @{text "|"} congruence rule: not included by default! *}
   469 
   470 lemma disj_cong:
   471     "(P = P') ==> (~P' ==> (Q = Q')) ==> ((P | Q) = (P' | Q'))"
   472   by blast
   473 
   474 lemma eq_sym_conv: "(x = y) = (y = x)"
   475   by rules
   476 
   477 
   478 text {* \medskip if-then-else rules *}
   479 
   480 lemma if_True: "(if True then x else y) = x"
   481   by (unfold if_def) blast
   482 
   483 lemma if_False: "(if False then x else y) = y"
   484   by (unfold if_def) blast
   485 
   486 lemma if_P: "P ==> (if P then x else y) = x"
   487   by (unfold if_def) blast
   488 
   489 lemma if_not_P: "~P ==> (if P then x else y) = y"
   490   by (unfold if_def) blast
   491 
   492 lemma split_if: "P (if Q then x else y) = ((Q --> P(x)) & (~Q --> P(y)))"
   493   apply (rule case_split [of Q])
   494    apply (subst if_P)
   495     prefer 3 apply (subst if_not_P, blast+)
   496   done
   497 
   498 lemma split_if_asm: "P (if Q then x else y) = (~((Q & ~P x) | (~Q & ~P y)))"
   499 by (subst split_if, blast)
   500 
   501 lemmas if_splits = split_if split_if_asm
   502 
   503 lemma if_def2: "(if Q then x else y) = ((Q --> x) & (~ Q --> y))"
   504   by (rule split_if)
   505 
   506 lemma if_cancel: "(if c then x else x) = x"
   507 by (subst split_if, blast)
   508 
   509 lemma if_eq_cancel: "(if x = y then y else x) = x"
   510 by (subst split_if, blast)
   511 
   512 lemma if_bool_eq_conj: "(if P then Q else R) = ((P-->Q) & (~P-->R))"
   513   -- {* This form is useful for expanding @{text if}s on the RIGHT of the @{text "==>"} symbol. *}
   514   by (rule split_if)
   515 
   516 lemma if_bool_eq_disj: "(if P then Q else R) = ((P&Q) | (~P&R))"
   517   -- {* And this form is useful for expanding @{text if}s on the LEFT. *}
   518   apply (subst split_if, blast)
   519   done
   520 
   521 lemma Eq_TrueI: "P ==> P == True" by (unfold atomize_eq) rules
   522 lemma Eq_FalseI: "~P ==> P == False" by (unfold atomize_eq) rules
   523 
   524 subsubsection {* Actual Installation of the Simplifier *}
   525 
   526 use "simpdata.ML"
   527 setup Simplifier.setup
   528 setup "Simplifier.method_setup Splitter.split_modifiers" setup simpsetup
   529 setup Splitter.setup setup Clasimp.setup
   530 
   531 declare disj_absorb [simp] conj_absorb [simp] 
   532 
   533 lemma ex1_eq[iff]: "EX! x. x = t" "EX! x. t = x"
   534 by blast+
   535 
   536 theorem choice_eq: "(ALL x. EX! y. P x y) = (EX! f. ALL x. P x (f x))"
   537   apply (rule iffI)
   538   apply (rule_tac a = "%x. THE y. P x y" in ex1I)
   539   apply (fast dest!: theI')
   540   apply (fast intro: ext the1_equality [symmetric])
   541   apply (erule ex1E)
   542   apply (rule allI)
   543   apply (rule ex1I)
   544   apply (erule spec)
   545   apply (erule_tac x = "%z. if z = x then y else f z" in allE)
   546   apply (erule impE)
   547   apply (rule allI)
   548   apply (rule_tac P = "xa = x" in case_split_thm)
   549   apply (drule_tac [3] x = x in fun_cong, simp_all)
   550   done
   551 
   552 text{*Needs only HOL-lemmas:*}
   553 lemma mk_left_commute:
   554   assumes a: "\<And>x y z. f (f x y) z = f x (f y z)" and
   555           c: "\<And>x y. f x y = f y x"
   556   shows "f x (f y z) = f y (f x z)"
   557 by(rule trans[OF trans[OF c a] arg_cong[OF c, of "f y"]])
   558 
   559 
   560 subsubsection {* Generic cases and induction *}
   561 
   562 constdefs
   563   induct_forall :: "('a => bool) => bool"
   564   "induct_forall P == \<forall>x. P x"
   565   induct_implies :: "bool => bool => bool"
   566   "induct_implies A B == A --> B"
   567   induct_equal :: "'a => 'a => bool"
   568   "induct_equal x y == x = y"
   569   induct_conj :: "bool => bool => bool"
   570   "induct_conj A B == A & B"
   571 
   572 lemma induct_forall_eq: "(!!x. P x) == Trueprop (induct_forall (\<lambda>x. P x))"
   573   by (simp only: atomize_all induct_forall_def)
   574 
   575 lemma induct_implies_eq: "(A ==> B) == Trueprop (induct_implies A B)"
   576   by (simp only: atomize_imp induct_implies_def)
   577 
   578 lemma induct_equal_eq: "(x == y) == Trueprop (induct_equal x y)"
   579   by (simp only: atomize_eq induct_equal_def)
   580 
   581 lemma induct_forall_conj: "induct_forall (\<lambda>x. induct_conj (A x) (B x)) =
   582     induct_conj (induct_forall A) (induct_forall B)"
   583   by (unfold induct_forall_def induct_conj_def) rules
   584 
   585 lemma induct_implies_conj: "induct_implies C (induct_conj A B) =
   586     induct_conj (induct_implies C A) (induct_implies C B)"
   587   by (unfold induct_implies_def induct_conj_def) rules
   588 
   589 lemma induct_conj_curry: "(induct_conj A B ==> PROP C) == (A ==> B ==> PROP C)"
   590 proof
   591   assume r: "induct_conj A B ==> PROP C" and A B
   592   show "PROP C" by (rule r) (simp! add: induct_conj_def)
   593 next
   594   assume r: "A ==> B ==> PROP C" and "induct_conj A B"
   595   show "PROP C" by (rule r) (simp! add: induct_conj_def)+
   596 qed
   597 
   598 lemma induct_impliesI: "(A ==> B) ==> induct_implies A B"
   599   by (simp add: induct_implies_def)
   600 
   601 lemmas induct_atomize = atomize_conj induct_forall_eq induct_implies_eq induct_equal_eq
   602 lemmas induct_rulify1 [symmetric, standard] = induct_forall_eq induct_implies_eq induct_equal_eq
   603 lemmas induct_rulify2 = induct_forall_def induct_implies_def induct_equal_def induct_conj_def
   604 lemmas induct_conj = induct_forall_conj induct_implies_conj induct_conj_curry
   605 
   606 hide const induct_forall induct_implies induct_equal induct_conj
   607 
   608 
   609 text {* Method setup. *}
   610 
   611 ML {*
   612   structure InductMethod = InductMethodFun
   613   (struct
   614     val dest_concls = HOLogic.dest_concls;
   615     val cases_default = thm "case_split";
   616     val local_impI = thm "induct_impliesI";
   617     val conjI = thm "conjI";
   618     val atomize = thms "induct_atomize";
   619     val rulify1 = thms "induct_rulify1";
   620     val rulify2 = thms "induct_rulify2";
   621     val localize = [Thm.symmetric (thm "induct_implies_def")];
   622   end);
   623 *}
   624 
   625 setup InductMethod.setup
   626 
   627 
   628 subsection {* Order signatures and orders *}
   629 
   630 axclass
   631   ord < type
   632 
   633 syntax
   634   "op <"        :: "['a::ord, 'a] => bool"             ("op <")
   635   "op <="       :: "['a::ord, 'a] => bool"             ("op <=")
   636 
   637 global
   638 
   639 consts
   640   "op <"        :: "['a::ord, 'a] => bool"             ("(_/ < _)"  [50, 51] 50)
   641   "op <="       :: "['a::ord, 'a] => bool"             ("(_/ <= _)" [50, 51] 50)
   642 
   643 local
   644 
   645 syntax (xsymbols)
   646   "op <="       :: "['a::ord, 'a] => bool"             ("op \<le>")
   647   "op <="       :: "['a::ord, 'a] => bool"             ("(_/ \<le> _)"  [50, 51] 50)
   648 
   649 syntax (HTML output)
   650   "op <="       :: "['a::ord, 'a] => bool"             ("op \<le>")
   651   "op <="       :: "['a::ord, 'a] => bool"             ("(_/ \<le> _)"  [50, 51] 50)
   652 
   653 
   654 lemma Not_eq_iff: "((~P) = (~Q)) = (P = Q)"
   655 by blast
   656 
   657 subsubsection {* Monotonicity *}
   658 
   659 locale mono =
   660   fixes f
   661   assumes mono: "A <= B ==> f A <= f B"
   662 
   663 lemmas monoI [intro?] = mono.intro
   664   and monoD [dest?] = mono.mono
   665 
   666 constdefs
   667   min :: "['a::ord, 'a] => 'a"
   668   "min a b == (if a <= b then a else b)"
   669   max :: "['a::ord, 'a] => 'a"
   670   "max a b == (if a <= b then b else a)"
   671 
   672 lemma min_leastL: "(!!x. least <= x) ==> min least x = least"
   673   by (simp add: min_def)
   674 
   675 lemma min_of_mono:
   676     "ALL x y. (f x <= f y) = (x <= y) ==> min (f m) (f n) = f (min m n)"
   677   by (simp add: min_def)
   678 
   679 lemma max_leastL: "(!!x. least <= x) ==> max least x = x"
   680   by (simp add: max_def)
   681 
   682 lemma max_of_mono:
   683     "ALL x y. (f x <= f y) = (x <= y) ==> max (f m) (f n) = f (max m n)"
   684   by (simp add: max_def)
   685 
   686 
   687 subsubsection "Orders"
   688 
   689 axclass order < ord
   690   order_refl [iff]: "x <= x"
   691   order_trans: "x <= y ==> y <= z ==> x <= z"
   692   order_antisym: "x <= y ==> y <= x ==> x = y"
   693   order_less_le: "(x < y) = (x <= y & x ~= y)"
   694 
   695 
   696 text {* Reflexivity. *}
   697 
   698 lemma order_eq_refl: "!!x::'a::order. x = y ==> x <= y"
   699     -- {* This form is useful with the classical reasoner. *}
   700   apply (erule ssubst)
   701   apply (rule order_refl)
   702   done
   703 
   704 lemma order_less_irrefl [iff]: "~ x < (x::'a::order)"
   705   by (simp add: order_less_le)
   706 
   707 lemma order_le_less: "((x::'a::order) <= y) = (x < y | x = y)"
   708     -- {* NOT suitable for iff, since it can cause PROOF FAILED. *}
   709   apply (simp add: order_less_le, blast)
   710   done
   711 
   712 lemmas order_le_imp_less_or_eq = order_le_less [THEN iffD1, standard]
   713 
   714 lemma order_less_imp_le: "!!x::'a::order. x < y ==> x <= y"
   715   by (simp add: order_less_le)
   716 
   717 
   718 text {* Asymmetry. *}
   719 
   720 lemma order_less_not_sym: "(x::'a::order) < y ==> ~ (y < x)"
   721   by (simp add: order_less_le order_antisym)
   722 
   723 lemma order_less_asym: "x < (y::'a::order) ==> (~P ==> y < x) ==> P"
   724   apply (drule order_less_not_sym)
   725   apply (erule contrapos_np, simp)
   726   done
   727 
   728 lemma order_eq_iff: "!!x::'a::order. (x = y) = (x \<le> y & y \<le> x)"  
   729 by (blast intro: order_antisym)
   730 
   731 
   732 text {* Transitivity. *}
   733 
   734 lemma order_less_trans: "!!x::'a::order. [| x < y; y < z |] ==> x < z"
   735   apply (simp add: order_less_le)
   736   apply (blast intro: order_trans order_antisym)
   737   done
   738 
   739 lemma order_le_less_trans: "!!x::'a::order. [| x <= y; y < z |] ==> x < z"
   740   apply (simp add: order_less_le)
   741   apply (blast intro: order_trans order_antisym)
   742   done
   743 
   744 lemma order_less_le_trans: "!!x::'a::order. [| x < y; y <= z |] ==> x < z"
   745   apply (simp add: order_less_le)
   746   apply (blast intro: order_trans order_antisym)
   747   done
   748 
   749 
   750 text {* Useful for simplification, but too risky to include by default. *}
   751 
   752 lemma order_less_imp_not_less: "(x::'a::order) < y ==>  (~ y < x) = True"
   753   by (blast elim: order_less_asym)
   754 
   755 lemma order_less_imp_triv: "(x::'a::order) < y ==>  (y < x --> P) = True"
   756   by (blast elim: order_less_asym)
   757 
   758 lemma order_less_imp_not_eq: "(x::'a::order) < y ==>  (x = y) = False"
   759   by auto
   760 
   761 lemma order_less_imp_not_eq2: "(x::'a::order) < y ==>  (y = x) = False"
   762   by auto
   763 
   764 
   765 text {* Other operators. *}
   766 
   767 lemma min_leastR: "(!!x::'a::order. least <= x) ==> min x least = least"
   768   apply (simp add: min_def)
   769   apply (blast intro: order_antisym)
   770   done
   771 
   772 lemma max_leastR: "(!!x::'a::order. least <= x) ==> max x least = x"
   773   apply (simp add: max_def)
   774   apply (blast intro: order_antisym)
   775   done
   776 
   777 
   778 subsubsection {* Least value operator *}
   779 
   780 constdefs
   781   Least :: "('a::ord => bool) => 'a"               (binder "LEAST " 10)
   782   "Least P == THE x. P x & (ALL y. P y --> x <= y)"
   783     -- {* We can no longer use LeastM because the latter requires Hilbert-AC. *}
   784 
   785 lemma LeastI2:
   786   "[| P (x::'a::order);
   787       !!y. P y ==> x <= y;
   788       !!x. [| P x; ALL y. P y --> x \<le> y |] ==> Q x |]
   789    ==> Q (Least P)"
   790   apply (unfold Least_def)
   791   apply (rule theI2)
   792     apply (blast intro: order_antisym)+
   793   done
   794 
   795 lemma Least_equality:
   796     "[| P (k::'a::order); !!x. P x ==> k <= x |] ==> (LEAST x. P x) = k"
   797   apply (simp add: Least_def)
   798   apply (rule the_equality)
   799   apply (auto intro!: order_antisym)
   800   done
   801 
   802 
   803 subsubsection "Linear / total orders"
   804 
   805 axclass linorder < order
   806   linorder_linear: "x <= y | y <= x"
   807 
   808 lemma linorder_less_linear: "!!x::'a::linorder. x<y | x=y | y<x"
   809   apply (simp add: order_less_le)
   810   apply (insert linorder_linear, blast)
   811   done
   812 
   813 lemma linorder_le_cases [case_names le ge]:
   814     "((x::'a::linorder) \<le> y ==> P) ==> (y \<le> x ==> P) ==> P"
   815   by (insert linorder_linear, blast)
   816 
   817 lemma linorder_cases [case_names less equal greater]:
   818     "((x::'a::linorder) < y ==> P) ==> (x = y ==> P) ==> (y < x ==> P) ==> P"
   819   by (insert linorder_less_linear, blast)
   820 
   821 lemma linorder_not_less: "!!x::'a::linorder. (~ x < y) = (y <= x)"
   822   apply (simp add: order_less_le)
   823   apply (insert linorder_linear)
   824   apply (blast intro: order_antisym)
   825   done
   826 
   827 lemma linorder_not_le: "!!x::'a::linorder. (~ x <= y) = (y < x)"
   828   apply (simp add: order_less_le)
   829   apply (insert linorder_linear)
   830   apply (blast intro: order_antisym)
   831   done
   832 
   833 lemma linorder_neq_iff: "!!x::'a::linorder. (x ~= y) = (x<y | y<x)"
   834 by (cut_tac x = x and y = y in linorder_less_linear, auto)
   835 
   836 lemma linorder_neqE: "x ~= (y::'a::linorder) ==> (x < y ==> R) ==> (y < x ==> R) ==> R"
   837 by (simp add: linorder_neq_iff, blast)
   838 
   839 
   840 subsubsection "Min and max on (linear) orders"
   841 
   842 lemma min_same [simp]: "min (x::'a::order) x = x"
   843   by (simp add: min_def)
   844 
   845 lemma max_same [simp]: "max (x::'a::order) x = x"
   846   by (simp add: max_def)
   847 
   848 lemma le_max_iff_disj: "!!z::'a::linorder. (z <= max x y) = (z <= x | z <= y)"
   849   apply (simp add: max_def)
   850   apply (insert linorder_linear)
   851   apply (blast intro: order_trans)
   852   done
   853 
   854 lemma le_maxI1: "(x::'a::linorder) <= max x y"
   855   by (simp add: le_max_iff_disj)
   856 
   857 lemma le_maxI2: "(y::'a::linorder) <= max x y"
   858     -- {* CANNOT use with @{text "[intro!]"} because blast will give PROOF FAILED. *}
   859   by (simp add: le_max_iff_disj)
   860 
   861 lemma less_max_iff_disj: "!!z::'a::linorder. (z < max x y) = (z < x | z < y)"
   862   apply (simp add: max_def order_le_less)
   863   apply (insert linorder_less_linear)
   864   apply (blast intro: order_less_trans)
   865   done
   866 
   867 lemma max_le_iff_conj [simp]:
   868     "!!z::'a::linorder. (max x y <= z) = (x <= z & y <= z)"
   869   apply (simp add: max_def)
   870   apply (insert linorder_linear)
   871   apply (blast intro: order_trans)
   872   done
   873 
   874 lemma max_less_iff_conj [simp]:
   875     "!!z::'a::linorder. (max x y < z) = (x < z & y < z)"
   876   apply (simp add: order_le_less max_def)
   877   apply (insert linorder_less_linear)
   878   apply (blast intro: order_less_trans)
   879   done
   880 
   881 lemma le_min_iff_conj [simp]:
   882     "!!z::'a::linorder. (z <= min x y) = (z <= x & z <= y)"
   883     -- {* @{text "[iff]"} screws up a @{text blast} in MiniML *}
   884   apply (simp add: min_def)
   885   apply (insert linorder_linear)
   886   apply (blast intro: order_trans)
   887   done
   888 
   889 lemma min_less_iff_conj [simp]:
   890     "!!z::'a::linorder. (z < min x y) = (z < x & z < y)"
   891   apply (simp add: order_le_less min_def)
   892   apply (insert linorder_less_linear)
   893   apply (blast intro: order_less_trans)
   894   done
   895 
   896 lemma min_le_iff_disj: "!!z::'a::linorder. (min x y <= z) = (x <= z | y <= z)"
   897   apply (simp add: min_def)
   898   apply (insert linorder_linear)
   899   apply (blast intro: order_trans)
   900   done
   901 
   902 lemma min_less_iff_disj: "!!z::'a::linorder. (min x y < z) = (x < z | y < z)"
   903   apply (simp add: min_def order_le_less)
   904   apply (insert linorder_less_linear)
   905   apply (blast intro: order_less_trans)
   906   done
   907 
   908 lemma max_assoc: "!!x::'a::linorder. max (max x y) z = max x (max y z)"
   909 apply(simp add:max_def)
   910 apply(rule conjI)
   911 apply(blast intro:order_trans)
   912 apply(simp add:linorder_not_le)
   913 apply(blast dest: order_less_trans order_le_less_trans)
   914 done
   915 
   916 lemma max_commute: "!!x::'a::linorder. max x y = max y x"
   917 apply(simp add:max_def)
   918 apply(rule conjI)
   919 apply(blast intro:order_antisym)
   920 apply(simp add:linorder_not_le)
   921 apply(blast dest: order_less_trans)
   922 done
   923 
   924 lemmas max_ac = max_assoc max_commute
   925                 mk_left_commute[of max,OF max_assoc max_commute]
   926 
   927 lemma min_assoc: "!!x::'a::linorder. min (min x y) z = min x (min y z)"
   928 apply(simp add:min_def)
   929 apply(rule conjI)
   930 apply(blast intro:order_trans)
   931 apply(simp add:linorder_not_le)
   932 apply(blast dest: order_less_trans order_le_less_trans)
   933 done
   934 
   935 lemma min_commute: "!!x::'a::linorder. min x y = min y x"
   936 apply(simp add:min_def)
   937 apply(rule conjI)
   938 apply(blast intro:order_antisym)
   939 apply(simp add:linorder_not_le)
   940 apply(blast dest: order_less_trans)
   941 done
   942 
   943 lemmas min_ac = min_assoc min_commute
   944                 mk_left_commute[of min,OF min_assoc min_commute]
   945 
   946 lemma split_min:
   947     "P (min (i::'a::linorder) j) = ((i <= j --> P(i)) & (~ i <= j --> P(j)))"
   948   by (simp add: min_def)
   949 
   950 lemma split_max:
   951     "P (max (i::'a::linorder) j) = ((i <= j --> P(j)) & (~ i <= j --> P(i)))"
   952   by (simp add: max_def)
   953 
   954 
   955 subsubsection {* Transitivity rules for calculational reasoning *}
   956 
   957 
   958 lemma order_neq_le_trans: "a ~= b ==> (a::'a::order) <= b ==> a < b"
   959   by (simp add: order_less_le)
   960 
   961 lemma order_le_neq_trans: "(a::'a::order) <= b ==> a ~= b ==> a < b"
   962   by (simp add: order_less_le)
   963 
   964 lemma order_less_asym': "(a::'a::order) < b ==> b < a ==> P"
   965   by (rule order_less_asym)
   966 
   967 
   968 subsubsection {* Setup of transitivity reasoner as Solver *}
   969 
   970 lemma less_imp_neq: "[| (x::'a::order) < y |] ==> x ~= y"
   971   by (erule contrapos_pn, erule subst, rule order_less_irrefl)
   972 
   973 lemma eq_neq_eq_imp_neq: "[| x = a ; a ~= b; b = y |] ==> x ~= y"
   974   by (erule subst, erule ssubst, assumption)
   975 
   976 ML_setup {*
   977 
   978 structure Trans_Tac = Trans_Tac_Fun (
   979   struct
   980     val less_reflE = thm "order_less_irrefl" RS thm "notE";
   981     val le_refl = thm "order_refl";
   982     val less_imp_le = thm "order_less_imp_le";
   983     val not_lessI = thm "linorder_not_less" RS thm "iffD2";
   984     val not_leI = thm "linorder_not_le" RS thm "iffD2";
   985     val not_lessD = thm "linorder_not_less" RS thm "iffD1";
   986     val not_leD = thm "linorder_not_le" RS thm "iffD1";
   987     val eqI = thm "order_antisym";
   988     val eqD1 = thm "order_eq_refl";
   989     val eqD2 = thm "sym" RS thm "order_eq_refl";
   990     val less_trans = thm "order_less_trans";
   991     val less_le_trans = thm "order_less_le_trans";
   992     val le_less_trans = thm "order_le_less_trans";
   993     val le_trans = thm "order_trans";
   994     val le_neq_trans = thm "order_le_neq_trans";
   995     val neq_le_trans = thm "order_neq_le_trans";
   996     val less_imp_neq = thm "less_imp_neq";
   997     val eq_neq_eq_imp_neq = thm "eq_neq_eq_imp_neq";
   998 
   999     fun decomp_gen sort sign (Trueprop $ t) =
  1000       let fun of_sort t = Sign.of_sort sign (type_of t, sort)
  1001       fun dec (Const ("Not", _) $ t) = (
  1002               case dec t of
  1003                 None => None
  1004               | Some (t1, rel, t2) => Some (t1, "~" ^ rel, t2))
  1005             | dec (Const ("op =",  _) $ t1 $ t2) = 
  1006                 if of_sort t1
  1007                 then Some (t1, "=", t2)
  1008                 else None
  1009             | dec (Const ("op <=",  _) $ t1 $ t2) = 
  1010                 if of_sort t1
  1011                 then Some (t1, "<=", t2)
  1012                 else None
  1013             | dec (Const ("op <",  _) $ t1 $ t2) = 
  1014                 if of_sort t1
  1015                 then Some (t1, "<", t2)
  1016                 else None
  1017             | dec _ = None
  1018       in dec t end;
  1019 
  1020     val decomp_part = decomp_gen ["HOL.order"];
  1021     val decomp_lin = decomp_gen ["HOL.linorder"];
  1022 
  1023   end);  (* struct *)
  1024 
  1025 Context.>> (fn thy => (simpset_ref_of thy :=
  1026   simpset_of thy
  1027     addSolver (mk_solver "Trans_linear" (fn _ => Trans_Tac.linear_tac))
  1028     addSolver (mk_solver "Trans_partial" (fn _ => Trans_Tac.partial_tac));
  1029   (* Adding the transitivity reasoners also as safe solvers showed a slight
  1030      speed up, but the reasoning strength appears to be not higher (at least
  1031      no breaking of additional proofs in the entire HOL distribution, as
  1032      of 5 March 2004, was observed). *)
  1033   thy))
  1034 *}
  1035 
  1036 (* Optional methods
  1037 
  1038 method_setup trans_partial =
  1039   {* Method.no_args (Method.SIMPLE_METHOD' HEADGOAL (trans_tac_partial)) *}
  1040   {* simple transitivity reasoner *}	    
  1041 method_setup trans_linear =
  1042   {* Method.no_args (Method.SIMPLE_METHOD' HEADGOAL (trans_tac_linear)) *}
  1043   {* simple transitivity reasoner *}
  1044 *)
  1045 
  1046 (*
  1047 declare order.order_refl [simp del] order_less_irrefl [simp del]
  1048 *)
  1049 
  1050 subsubsection "Bounded quantifiers"
  1051 
  1052 syntax
  1053   "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3ALL _<_./ _)"  [0, 0, 10] 10)
  1054   "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3EX _<_./ _)"  [0, 0, 10] 10)
  1055   "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3ALL _<=_./ _)" [0, 0, 10] 10)
  1056   "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3EX _<=_./ _)" [0, 0, 10] 10)
  1057 
  1058 syntax (xsymbols)
  1059   "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_<_./ _)"  [0, 0, 10] 10)
  1060   "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_<_./ _)"  [0, 0, 10] 10)
  1061   "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10)
  1062   "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10)
  1063 
  1064 syntax (HOL)
  1065   "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3! _<_./ _)"  [0, 0, 10] 10)
  1066   "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3? _<_./ _)"  [0, 0, 10] 10)
  1067   "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3! _<=_./ _)" [0, 0, 10] 10)
  1068   "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3? _<=_./ _)" [0, 0, 10] 10)
  1069 
  1070 syntax (HTML output)
  1071   "_lessAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_<_./ _)"  [0, 0, 10] 10)
  1072   "_lessEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_<_./ _)"  [0, 0, 10] 10)
  1073   "_leAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10)
  1074   "_leEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10)
  1075 
  1076 translations
  1077  "ALL x<y. P"   =>  "ALL x. x < y --> P"
  1078  "EX x<y. P"    =>  "EX x. x < y  & P"
  1079  "ALL x<=y. P"  =>  "ALL x. x <= y --> P"
  1080  "EX x<=y. P"   =>  "EX x. x <= y & P"
  1081 
  1082 print_translation {*
  1083 let
  1084   fun all_tr' [Const ("_bound",_) $ Free (v,_), 
  1085                Const("op -->",_) $ (Const ("op <",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] = 
  1086   (if v=v' then Syntax.const "_lessAll" $ Syntax.mark_bound v' $ n $ P else raise Match)
  1087 
  1088   | all_tr' [Const ("_bound",_) $ Free (v,_), 
  1089                Const("op -->",_) $ (Const ("op <=",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] = 
  1090   (if v=v' then Syntax.const "_leAll" $ Syntax.mark_bound v' $ n $ P else raise Match);
  1091 
  1092   fun ex_tr' [Const ("_bound",_) $ Free (v,_), 
  1093                Const("op &",_) $ (Const ("op <",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] = 
  1094   (if v=v' then Syntax.const "_lessEx" $ Syntax.mark_bound v' $ n $ P else raise Match)
  1095 
  1096   | ex_tr' [Const ("_bound",_) $ Free (v,_), 
  1097                Const("op &",_) $ (Const ("op <=",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] = 
  1098   (if v=v' then Syntax.const "_leEx" $ Syntax.mark_bound v' $ n $ P else raise Match)
  1099 in
  1100 [("ALL ", all_tr'), ("EX ", ex_tr')]
  1101 end
  1102 *}
  1103 
  1104 end