src/HOL/HOL.thy
author paulson
Tue Jun 28 15:27:45 2005 +0200 (2005-06-28)
changeset 16587 b34c8aa657a5
parent 16417 9bc16273c2d4
child 16633 208ebc9311f2
permissions -rw-r--r--
Constant "If" is now local
     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
     9 imports CPure
    10 uses ("cladata.ML") ("blastdata.ML") ("simpdata.ML") ("eqrule_HOL_data.ML")
    11       ("~~/src/Provers/eqsubst.ML")
    12 begin
    13 
    14 subsection {* Primitive logic *}
    15 
    16 subsubsection {* Core syntax *}
    17 
    18 classes type
    19 defaultsort type
    20 
    21 global
    22 
    23 typedecl bool
    24 
    25 arities
    26   bool :: type
    27   fun :: (type, type) type
    28 
    29 judgment
    30   Trueprop      :: "bool => prop"                   ("(_)" 5)
    31 
    32 consts
    33   Not           :: "bool => bool"                   ("~ _" [40] 40)
    34   True          :: bool
    35   False         :: bool
    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 consts
    52   If            :: "[bool, 'a, 'a] => 'a"           ("(if (_)/ then (_)/ else (_))" 10)
    53 
    54 subsubsection {* Additional concrete syntax *}
    55 
    56 nonterminals
    57   letbinds  letbind
    58   case_syn  cases_syn
    59 
    60 syntax
    61   "_not_equal"  :: "['a, 'a] => bool"                    (infixl "~=" 50)
    62   "_The"        :: "[pttrn, bool] => 'a"                 ("(3THE _./ _)" [0, 10] 10)
    63 
    64   "_bind"       :: "[pttrn, 'a] => letbind"              ("(2_ =/ _)" 10)
    65   ""            :: "letbind => letbinds"                 ("_")
    66   "_binds"      :: "[letbind, letbinds] => letbinds"     ("_;/ _")
    67   "_Let"        :: "[letbinds, 'a] => 'a"                ("(let (_)/ in (_))" 10)
    68 
    69   "_case_syntax":: "['a, cases_syn] => 'b"               ("(case _ of/ _)" 10)
    70   "_case1"      :: "['a, 'b] => case_syn"                ("(2_ =>/ _)" 10)
    71   ""            :: "case_syn => cases_syn"               ("_")
    72   "_case2"      :: "[case_syn, cases_syn] => cases_syn"  ("_/ | _")
    73 
    74 translations
    75   "x ~= y"                == "~ (x = y)"
    76   "THE x. P"              == "The (%x. P)"
    77   "_Let (_binds b bs) e"  == "_Let b (_Let bs e)"
    78   "let x = a in e"        == "Let a (%x. e)"
    79 
    80 print_translation {*
    81 (* To avoid eta-contraction of body: *)
    82 [("The", fn [Abs abs] =>
    83      let val (x,t) = atomic_abs_tr' abs
    84      in Syntax.const "_The" $ x $ t end)]
    85 *}
    86 
    87 syntax (output)
    88   "="           :: "['a, 'a] => bool"                    (infix 50)
    89   "_not_equal"  :: "['a, 'a] => bool"                    (infix "~=" 50)
    90 
    91 syntax (xsymbols)
    92   Not           :: "bool => bool"                        ("\<not> _" [40] 40)
    93   "op &"        :: "[bool, bool] => bool"                (infixr "\<and>" 35)
    94   "op |"        :: "[bool, bool] => bool"                (infixr "\<or>" 30)
    95   "op -->"      :: "[bool, bool] => bool"                (infixr "\<longrightarrow>" 25)
    96   "_not_equal"  :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
    97   "ALL "        :: "[idts, bool] => bool"                ("(3\<forall>_./ _)" [0, 10] 10)
    98   "EX "         :: "[idts, bool] => bool"                ("(3\<exists>_./ _)" [0, 10] 10)
    99   "EX! "        :: "[idts, bool] => bool"                ("(3\<exists>!_./ _)" [0, 10] 10)
   100   "_case1"      :: "['a, 'b] => case_syn"                ("(2_ \<Rightarrow>/ _)" 10)
   101 (*"_case2"      :: "[case_syn, cases_syn] => cases_syn"  ("_/ \<orelse> _")*)
   102 
   103 syntax (xsymbols output)
   104   "_not_equal"  :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
   105 
   106 syntax (HTML output)
   107   "_not_equal"  :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
   108   Not           :: "bool => bool"                        ("\<not> _" [40] 40)
   109   "op &"        :: "[bool, bool] => bool"                (infixr "\<and>" 35)
   110   "op |"        :: "[bool, bool] => bool"                (infixr "\<or>" 30)
   111   "_not_equal"  :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
   112   "ALL "        :: "[idts, bool] => bool"                ("(3\<forall>_./ _)" [0, 10] 10)
   113   "EX "         :: "[idts, bool] => bool"                ("(3\<exists>_./ _)" [0, 10] 10)
   114   "EX! "        :: "[idts, bool] => bool"                ("(3\<exists>!_./ _)" [0, 10] 10)
   115 
   116 syntax (HOL)
   117   "ALL "        :: "[idts, bool] => bool"                ("(3! _./ _)" [0, 10] 10)
   118   "EX "         :: "[idts, bool] => bool"                ("(3? _./ _)" [0, 10] 10)
   119   "EX! "        :: "[idts, bool] => bool"                ("(3?! _./ _)" [0, 10] 10)
   120 
   121 
   122 subsubsection {* Axioms and basic definitions *}
   123 
   124 axioms
   125   eq_reflection:  "(x=y) ==> (x==y)"
   126 
   127   refl:           "t = (t::'a)"
   128 
   129   ext:            "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)"
   130     -- {*Extensionality is built into the meta-logic, and this rule expresses
   131          a related property.  It is an eta-expanded version of the traditional
   132          rule, and similar to the ABS rule of HOL*}
   133 
   134   the_eq_trivial: "(THE x. x = a) = (a::'a)"
   135 
   136   impI:           "(P ==> Q) ==> P-->Q"
   137   mp:             "[| P-->Q;  P |] ==> Q"
   138 
   139 
   140 text{*Thanks to Stephan Merz*}
   141 theorem subst:
   142   assumes eq: "s = t" and p: "P(s)"
   143   shows "P(t::'a)"
   144 proof -
   145   from eq have meta: "s \<equiv> t"
   146     by (rule eq_reflection)
   147   from p show ?thesis
   148     by (unfold meta)
   149 qed
   150 
   151 defs
   152   True_def:     "True      == ((%x::bool. x) = (%x. x))"
   153   All_def:      "All(P)    == (P = (%x. True))"
   154   Ex_def:       "Ex(P)     == !Q. (!x. P x --> Q) --> Q"
   155   False_def:    "False     == (!P. P)"
   156   not_def:      "~ P       == P-->False"
   157   and_def:      "P & Q     == !R. (P-->Q-->R) --> R"
   158   or_def:       "P | Q     == !R. (P-->R) --> (Q-->R) --> R"
   159   Ex1_def:      "Ex1(P)    == ? x. P(x) & (! y. P(y) --> y=x)"
   160 
   161 axioms
   162   iff:          "(P-->Q) --> (Q-->P) --> (P=Q)"
   163   True_or_False:  "(P=True) | (P=False)"
   164 
   165 defs
   166   Let_def:      "Let s f == f(s)"
   167   if_def:       "If P x y == THE z::'a. (P=True --> z=x) & (P=False --> z=y)"
   168 
   169 finalconsts
   170   "op ="
   171   "op -->"
   172   The
   173   arbitrary
   174 
   175 subsubsection {* Generic algebraic operations *}
   176 
   177 axclass zero < type
   178 axclass one < type
   179 axclass plus < type
   180 axclass minus < type
   181 axclass times < type
   182 axclass inverse < type
   183 
   184 global
   185 
   186 consts
   187   "0"           :: "'a::zero"                       ("0")
   188   "1"           :: "'a::one"                        ("1")
   189   "+"           :: "['a::plus, 'a]  => 'a"          (infixl 65)
   190   -             :: "['a::minus, 'a] => 'a"          (infixl 65)
   191   uminus        :: "['a::minus] => 'a"              ("- _" [81] 80)
   192   *             :: "['a::times, 'a] => 'a"          (infixl 70)
   193 
   194 syntax
   195   "_index1"  :: index    ("\<^sub>1")
   196 translations
   197   (index) "\<^sub>1" => (index) "\<^bsub>\<struct>\<^esub>"
   198 
   199 local
   200 
   201 typed_print_translation {*
   202   let
   203     fun tr' c = (c, fn show_sorts => fn T => fn ts =>
   204       if T = dummyT orelse not (! show_types) andalso can Term.dest_Type T then raise Match
   205       else Syntax.const Syntax.constrainC $ Syntax.const c $ Syntax.term_of_typ show_sorts T);
   206   in [tr' "0", tr' "1"] end;
   207 *} -- {* show types that are presumably too general *}
   208 
   209 
   210 consts
   211   abs           :: "'a::minus => 'a"
   212   inverse       :: "'a::inverse => 'a"
   213   divide        :: "['a::inverse, 'a] => 'a"        (infixl "'/" 70)
   214 
   215 syntax (xsymbols)
   216   abs :: "'a::minus => 'a"    ("\<bar>_\<bar>")
   217 syntax (HTML output)
   218   abs :: "'a::minus => 'a"    ("\<bar>_\<bar>")
   219 
   220 
   221 subsection {*Equality*}
   222 
   223 lemma sym: "s=t ==> t=s"
   224 apply (erule subst)
   225 apply (rule refl)
   226 done
   227 
   228 (*calling "standard" reduces maxidx to 0*)
   229 lemmas ssubst = sym [THEN subst, standard]
   230 
   231 lemma trans: "[| r=s; s=t |] ==> r=t"
   232 apply (erule subst , assumption)
   233 done
   234 
   235 lemma def_imp_eq:  assumes meq: "A == B" shows "A = B"
   236 apply (unfold meq)
   237 apply (rule refl)
   238 done
   239 
   240 (*Useful with eresolve_tac for proving equalties from known equalities.
   241         a = b
   242         |   |
   243         c = d   *)
   244 lemma box_equals: "[| a=b;  a=c;  b=d |] ==> c=d"
   245 apply (rule trans)
   246 apply (rule trans)
   247 apply (rule sym)
   248 apply assumption+
   249 done
   250 
   251 text {* For calculational reasoning: *}
   252 
   253 lemma forw_subst: "a = b ==> P b ==> P a"
   254   by (rule ssubst)
   255 
   256 lemma back_subst: "P a ==> a = b ==> P b"
   257   by (rule subst)
   258 
   259 
   260 subsection {*Congruence rules for application*}
   261 
   262 (*similar to AP_THM in Gordon's HOL*)
   263 lemma fun_cong: "(f::'a=>'b) = g ==> f(x)=g(x)"
   264 apply (erule subst)
   265 apply (rule refl)
   266 done
   267 
   268 (*similar to AP_TERM in Gordon's HOL and FOL's subst_context*)
   269 lemma arg_cong: "x=y ==> f(x)=f(y)"
   270 apply (erule subst)
   271 apply (rule refl)
   272 done
   273 
   274 lemma arg_cong2: "\<lbrakk> a = b; c = d \<rbrakk> \<Longrightarrow> f a c = f b d"
   275 apply (erule ssubst)+
   276 apply (rule refl)
   277 done
   278 
   279 
   280 lemma cong: "[| f = g; (x::'a) = y |] ==> f(x) = g(y)"
   281 apply (erule subst)+
   282 apply (rule refl)
   283 done
   284 
   285 
   286 subsection {*Equality of booleans -- iff*}
   287 
   288 lemma iffI: assumes prems: "P ==> Q" "Q ==> P" shows "P=Q"
   289 apply (rules intro: iff [THEN mp, THEN mp] impI prems)
   290 done
   291 
   292 lemma iffD2: "[| P=Q; Q |] ==> P"
   293 apply (erule ssubst)
   294 apply assumption
   295 done
   296 
   297 lemma rev_iffD2: "[| Q; P=Q |] ==> P"
   298 apply (erule iffD2)
   299 apply assumption
   300 done
   301 
   302 lemmas iffD1 = sym [THEN iffD2, standard]
   303 lemmas rev_iffD1 = sym [THEN [2] rev_iffD2, standard]
   304 
   305 lemma iffE:
   306   assumes major: "P=Q"
   307       and minor: "[| P --> Q; Q --> P |] ==> R"
   308   shows "R"
   309 by (rules intro: minor impI major [THEN iffD2] major [THEN iffD1])
   310 
   311 
   312 subsection {*True*}
   313 
   314 lemma TrueI: "True"
   315 apply (unfold True_def)
   316 apply (rule refl)
   317 done
   318 
   319 lemma eqTrueI: "P ==> P=True"
   320 by (rules intro: iffI TrueI)
   321 
   322 lemma eqTrueE: "P=True ==> P"
   323 apply (erule iffD2)
   324 apply (rule TrueI)
   325 done
   326 
   327 
   328 subsection {*Universal quantifier*}
   329 
   330 lemma allI: assumes p: "!!x::'a. P(x)" shows "ALL x. P(x)"
   331 apply (unfold All_def)
   332 apply (rules intro: ext eqTrueI p)
   333 done
   334 
   335 lemma spec: "ALL x::'a. P(x) ==> P(x)"
   336 apply (unfold All_def)
   337 apply (rule eqTrueE)
   338 apply (erule fun_cong)
   339 done
   340 
   341 lemma allE:
   342   assumes major: "ALL x. P(x)"
   343       and minor: "P(x) ==> R"
   344   shows "R"
   345 by (rules intro: minor major [THEN spec])
   346 
   347 lemma all_dupE:
   348   assumes major: "ALL x. P(x)"
   349       and minor: "[| P(x); ALL x. P(x) |] ==> R"
   350   shows "R"
   351 by (rules intro: minor major major [THEN spec])
   352 
   353 
   354 subsection {*False*}
   355 (*Depends upon spec; it is impossible to do propositional logic before quantifiers!*)
   356 
   357 lemma FalseE: "False ==> P"
   358 apply (unfold False_def)
   359 apply (erule spec)
   360 done
   361 
   362 lemma False_neq_True: "False=True ==> P"
   363 by (erule eqTrueE [THEN FalseE])
   364 
   365 
   366 subsection {*Negation*}
   367 
   368 lemma notI:
   369   assumes p: "P ==> False"
   370   shows "~P"
   371 apply (unfold not_def)
   372 apply (rules intro: impI p)
   373 done
   374 
   375 lemma False_not_True: "False ~= True"
   376 apply (rule notI)
   377 apply (erule False_neq_True)
   378 done
   379 
   380 lemma True_not_False: "True ~= False"
   381 apply (rule notI)
   382 apply (drule sym)
   383 apply (erule False_neq_True)
   384 done
   385 
   386 lemma notE: "[| ~P;  P |] ==> R"
   387 apply (unfold not_def)
   388 apply (erule mp [THEN FalseE])
   389 apply assumption
   390 done
   391 
   392 (* Alternative ~ introduction rule: [| P ==> ~ Pa; P ==> Pa |] ==> ~ P *)
   393 lemmas notI2 = notE [THEN notI, standard]
   394 
   395 
   396 subsection {*Implication*}
   397 
   398 lemma impE:
   399   assumes "P-->Q" "P" "Q ==> R"
   400   shows "R"
   401 by (rules intro: prems mp)
   402 
   403 (* Reduces Q to P-->Q, allowing substitution in P. *)
   404 lemma rev_mp: "[| P;  P --> Q |] ==> Q"
   405 by (rules intro: mp)
   406 
   407 lemma contrapos_nn:
   408   assumes major: "~Q"
   409       and minor: "P==>Q"
   410   shows "~P"
   411 by (rules intro: notI minor major [THEN notE])
   412 
   413 (*not used at all, but we already have the other 3 combinations *)
   414 lemma contrapos_pn:
   415   assumes major: "Q"
   416       and minor: "P ==> ~Q"
   417   shows "~P"
   418 by (rules intro: notI minor major notE)
   419 
   420 lemma not_sym: "t ~= s ==> s ~= t"
   421 apply (erule contrapos_nn)
   422 apply (erule sym)
   423 done
   424 
   425 (*still used in HOLCF*)
   426 lemma rev_contrapos:
   427   assumes pq: "P ==> Q"
   428       and nq: "~Q"
   429   shows "~P"
   430 apply (rule nq [THEN contrapos_nn])
   431 apply (erule pq)
   432 done
   433 
   434 subsection {*Existential quantifier*}
   435 
   436 lemma exI: "P x ==> EX x::'a. P x"
   437 apply (unfold Ex_def)
   438 apply (rules intro: allI allE impI mp)
   439 done
   440 
   441 lemma exE:
   442   assumes major: "EX x::'a. P(x)"
   443       and minor: "!!x. P(x) ==> Q"
   444   shows "Q"
   445 apply (rule major [unfolded Ex_def, THEN spec, THEN mp])
   446 apply (rules intro: impI [THEN allI] minor)
   447 done
   448 
   449 
   450 subsection {*Conjunction*}
   451 
   452 lemma conjI: "[| P; Q |] ==> P&Q"
   453 apply (unfold and_def)
   454 apply (rules intro: impI [THEN allI] mp)
   455 done
   456 
   457 lemma conjunct1: "[| P & Q |] ==> P"
   458 apply (unfold and_def)
   459 apply (rules intro: impI dest: spec mp)
   460 done
   461 
   462 lemma conjunct2: "[| P & Q |] ==> Q"
   463 apply (unfold and_def)
   464 apply (rules intro: impI dest: spec mp)
   465 done
   466 
   467 lemma conjE:
   468   assumes major: "P&Q"
   469       and minor: "[| P; Q |] ==> R"
   470   shows "R"
   471 apply (rule minor)
   472 apply (rule major [THEN conjunct1])
   473 apply (rule major [THEN conjunct2])
   474 done
   475 
   476 lemma context_conjI:
   477   assumes prems: "P" "P ==> Q" shows "P & Q"
   478 by (rules intro: conjI prems)
   479 
   480 
   481 subsection {*Disjunction*}
   482 
   483 lemma disjI1: "P ==> P|Q"
   484 apply (unfold or_def)
   485 apply (rules intro: allI impI mp)
   486 done
   487 
   488 lemma disjI2: "Q ==> P|Q"
   489 apply (unfold or_def)
   490 apply (rules intro: allI impI mp)
   491 done
   492 
   493 lemma disjE:
   494   assumes major: "P|Q"
   495       and minorP: "P ==> R"
   496       and minorQ: "Q ==> R"
   497   shows "R"
   498 by (rules intro: minorP minorQ impI
   499                  major [unfolded or_def, THEN spec, THEN mp, THEN mp])
   500 
   501 
   502 subsection {*Classical logic*}
   503 
   504 
   505 lemma classical:
   506   assumes prem: "~P ==> P"
   507   shows "P"
   508 apply (rule True_or_False [THEN disjE, THEN eqTrueE])
   509 apply assumption
   510 apply (rule notI [THEN prem, THEN eqTrueI])
   511 apply (erule subst)
   512 apply assumption
   513 done
   514 
   515 lemmas ccontr = FalseE [THEN classical, standard]
   516 
   517 (*notE with premises exchanged; it discharges ~R so that it can be used to
   518   make elimination rules*)
   519 lemma rev_notE:
   520   assumes premp: "P"
   521       and premnot: "~R ==> ~P"
   522   shows "R"
   523 apply (rule ccontr)
   524 apply (erule notE [OF premnot premp])
   525 done
   526 
   527 (*Double negation law*)
   528 lemma notnotD: "~~P ==> P"
   529 apply (rule classical)
   530 apply (erule notE)
   531 apply assumption
   532 done
   533 
   534 lemma contrapos_pp:
   535   assumes p1: "Q"
   536       and p2: "~P ==> ~Q"
   537   shows "P"
   538 by (rules intro: classical p1 p2 notE)
   539 
   540 
   541 subsection {*Unique existence*}
   542 
   543 lemma ex1I:
   544   assumes prems: "P a" "!!x. P(x) ==> x=a"
   545   shows "EX! x. P(x)"
   546 by (unfold Ex1_def, rules intro: prems exI conjI allI impI)
   547 
   548 text{*Sometimes easier to use: the premises have no shared variables.  Safe!*}
   549 lemma ex_ex1I:
   550   assumes ex_prem: "EX x. P(x)"
   551       and eq: "!!x y. [| P(x); P(y) |] ==> x=y"
   552   shows "EX! x. P(x)"
   553 by (rules intro: ex_prem [THEN exE] ex1I eq)
   554 
   555 lemma ex1E:
   556   assumes major: "EX! x. P(x)"
   557       and minor: "!!x. [| P(x);  ALL y. P(y) --> y=x |] ==> R"
   558   shows "R"
   559 apply (rule major [unfolded Ex1_def, THEN exE])
   560 apply (erule conjE)
   561 apply (rules intro: minor)
   562 done
   563 
   564 lemma ex1_implies_ex: "EX! x. P x ==> EX x. P x"
   565 apply (erule ex1E)
   566 apply (rule exI)
   567 apply assumption
   568 done
   569 
   570 
   571 subsection {*THE: definite description operator*}
   572 
   573 lemma the_equality:
   574   assumes prema: "P a"
   575       and premx: "!!x. P x ==> x=a"
   576   shows "(THE x. P x) = a"
   577 apply (rule trans [OF _ the_eq_trivial])
   578 apply (rule_tac f = "The" in arg_cong)
   579 apply (rule ext)
   580 apply (rule iffI)
   581  apply (erule premx)
   582 apply (erule ssubst, rule prema)
   583 done
   584 
   585 lemma theI:
   586   assumes "P a" and "!!x. P x ==> x=a"
   587   shows "P (THE x. P x)"
   588 by (rules intro: prems the_equality [THEN ssubst])
   589 
   590 lemma theI': "EX! x. P x ==> P (THE x. P x)"
   591 apply (erule ex1E)
   592 apply (erule theI)
   593 apply (erule allE)
   594 apply (erule mp)
   595 apply assumption
   596 done
   597 
   598 (*Easier to apply than theI: only one occurrence of P*)
   599 lemma theI2:
   600   assumes "P a" "!!x. P x ==> x=a" "!!x. P x ==> Q x"
   601   shows "Q (THE x. P x)"
   602 by (rules intro: prems theI)
   603 
   604 lemma the1_equality: "[| EX!x. P x; P a |] ==> (THE x. P x) = a"
   605 apply (rule the_equality)
   606 apply  assumption
   607 apply (erule ex1E)
   608 apply (erule all_dupE)
   609 apply (drule mp)
   610 apply  assumption
   611 apply (erule ssubst)
   612 apply (erule allE)
   613 apply (erule mp)
   614 apply assumption
   615 done
   616 
   617 lemma the_sym_eq_trivial: "(THE y. x=y) = x"
   618 apply (rule the_equality)
   619 apply (rule refl)
   620 apply (erule sym)
   621 done
   622 
   623 
   624 subsection {*Classical intro rules for disjunction and existential quantifiers*}
   625 
   626 lemma disjCI:
   627   assumes "~Q ==> P" shows "P|Q"
   628 apply (rule classical)
   629 apply (rules intro: prems disjI1 disjI2 notI elim: notE)
   630 done
   631 
   632 lemma excluded_middle: "~P | P"
   633 by (rules intro: disjCI)
   634 
   635 text{*case distinction as a natural deduction rule. Note that @{term "~P"}
   636    is the second case, not the first.*}
   637 lemma case_split_thm:
   638   assumes prem1: "P ==> Q"
   639       and prem2: "~P ==> Q"
   640   shows "Q"
   641 apply (rule excluded_middle [THEN disjE])
   642 apply (erule prem2)
   643 apply (erule prem1)
   644 done
   645 
   646 (*Classical implies (-->) elimination. *)
   647 lemma impCE:
   648   assumes major: "P-->Q"
   649       and minor: "~P ==> R" "Q ==> R"
   650   shows "R"
   651 apply (rule excluded_middle [of P, THEN disjE])
   652 apply (rules intro: minor major [THEN mp])+
   653 done
   654 
   655 (*This version of --> elimination works on Q before P.  It works best for
   656   those cases in which P holds "almost everywhere".  Can't install as
   657   default: would break old proofs.*)
   658 lemma impCE':
   659   assumes major: "P-->Q"
   660       and minor: "Q ==> R" "~P ==> R"
   661   shows "R"
   662 apply (rule excluded_middle [of P, THEN disjE])
   663 apply (rules intro: minor major [THEN mp])+
   664 done
   665 
   666 (*Classical <-> elimination. *)
   667 lemma iffCE:
   668   assumes major: "P=Q"
   669       and minor: "[| P; Q |] ==> R"  "[| ~P; ~Q |] ==> R"
   670   shows "R"
   671 apply (rule major [THEN iffE])
   672 apply (rules intro: minor elim: impCE notE)
   673 done
   674 
   675 lemma exCI:
   676   assumes "ALL x. ~P(x) ==> P(a)"
   677   shows "EX x. P(x)"
   678 apply (rule ccontr)
   679 apply (rules intro: prems exI allI notI notE [of "\<exists>x. P x"])
   680 done
   681 
   682 
   683 
   684 subsection {* Theory and package setup *}
   685 
   686 ML
   687 {*
   688 val plusI = thm "plusI"
   689 val minusI = thm "minusI"
   690 val timesI = thm "timesI"
   691 val eq_reflection = thm "eq_reflection"
   692 val refl = thm "refl"
   693 val subst = thm "subst"
   694 val ext = thm "ext"
   695 val impI = thm "impI"
   696 val mp = thm "mp"
   697 val True_def = thm "True_def"
   698 val All_def = thm "All_def"
   699 val Ex_def = thm "Ex_def"
   700 val False_def = thm "False_def"
   701 val not_def = thm "not_def"
   702 val and_def = thm "and_def"
   703 val or_def = thm "or_def"
   704 val Ex1_def = thm "Ex1_def"
   705 val iff = thm "iff"
   706 val True_or_False = thm "True_or_False"
   707 val Let_def = thm "Let_def"
   708 val if_def = thm "if_def"
   709 val sym = thm "sym"
   710 val ssubst = thm "ssubst"
   711 val trans = thm "trans"
   712 val def_imp_eq = thm "def_imp_eq"
   713 val box_equals = thm "box_equals"
   714 val fun_cong = thm "fun_cong"
   715 val arg_cong = thm "arg_cong"
   716 val cong = thm "cong"
   717 val iffI = thm "iffI"
   718 val iffD2 = thm "iffD2"
   719 val rev_iffD2 = thm "rev_iffD2"
   720 val iffD1 = thm "iffD1"
   721 val rev_iffD1 = thm "rev_iffD1"
   722 val iffE = thm "iffE"
   723 val TrueI = thm "TrueI"
   724 val eqTrueI = thm "eqTrueI"
   725 val eqTrueE = thm "eqTrueE"
   726 val allI = thm "allI"
   727 val spec = thm "spec"
   728 val allE = thm "allE"
   729 val all_dupE = thm "all_dupE"
   730 val FalseE = thm "FalseE"
   731 val False_neq_True = thm "False_neq_True"
   732 val notI = thm "notI"
   733 val False_not_True = thm "False_not_True"
   734 val True_not_False = thm "True_not_False"
   735 val notE = thm "notE"
   736 val notI2 = thm "notI2"
   737 val impE = thm "impE"
   738 val rev_mp = thm "rev_mp"
   739 val contrapos_nn = thm "contrapos_nn"
   740 val contrapos_pn = thm "contrapos_pn"
   741 val not_sym = thm "not_sym"
   742 val rev_contrapos = thm "rev_contrapos"
   743 val exI = thm "exI"
   744 val exE = thm "exE"
   745 val conjI = thm "conjI"
   746 val conjunct1 = thm "conjunct1"
   747 val conjunct2 = thm "conjunct2"
   748 val conjE = thm "conjE"
   749 val context_conjI = thm "context_conjI"
   750 val disjI1 = thm "disjI1"
   751 val disjI2 = thm "disjI2"
   752 val disjE = thm "disjE"
   753 val classical = thm "classical"
   754 val ccontr = thm "ccontr"
   755 val rev_notE = thm "rev_notE"
   756 val notnotD = thm "notnotD"
   757 val contrapos_pp = thm "contrapos_pp"
   758 val ex1I = thm "ex1I"
   759 val ex_ex1I = thm "ex_ex1I"
   760 val ex1E = thm "ex1E"
   761 val ex1_implies_ex = thm "ex1_implies_ex"
   762 val the_equality = thm "the_equality"
   763 val theI = thm "theI"
   764 val theI' = thm "theI'"
   765 val theI2 = thm "theI2"
   766 val the1_equality = thm "the1_equality"
   767 val the_sym_eq_trivial = thm "the_sym_eq_trivial"
   768 val disjCI = thm "disjCI"
   769 val excluded_middle = thm "excluded_middle"
   770 val case_split_thm = thm "case_split_thm"
   771 val impCE = thm "impCE"
   772 val impCE = thm "impCE"
   773 val iffCE = thm "iffCE"
   774 val exCI = thm "exCI"
   775 
   776 (* combination of (spec RS spec RS ...(j times) ... spec RS mp) *)
   777 local
   778   fun wrong_prem (Const ("All", _) $ (Abs (_, _, t))) = wrong_prem t
   779   |   wrong_prem (Bound _) = true
   780   |   wrong_prem _ = false
   781   val filter_right = List.filter (fn t => not (wrong_prem (HOLogic.dest_Trueprop (hd (Thm.prems_of t)))))
   782 in
   783   fun smp i = funpow i (fn m => filter_right ([spec] RL m)) ([mp])
   784   fun smp_tac j = EVERY'[dresolve_tac (smp j), atac]
   785 end
   786 
   787 
   788 fun strip_tac i = REPEAT(resolve_tac [impI,allI] i)
   789 
   790 (*Obsolete form of disjunctive case analysis*)
   791 fun excluded_middle_tac sP =
   792     res_inst_tac [("Q",sP)] (excluded_middle RS disjE)
   793 
   794 fun case_tac a = res_inst_tac [("P",a)] case_split_thm
   795 *}
   796 
   797 theorems case_split = case_split_thm [case_names True False]
   798 
   799 
   800 subsubsection {* Intuitionistic Reasoning *}
   801 
   802 lemma impE':
   803   assumes 1: "P --> Q"
   804     and 2: "Q ==> R"
   805     and 3: "P --> Q ==> P"
   806   shows R
   807 proof -
   808   from 3 and 1 have P .
   809   with 1 have Q by (rule impE)
   810   with 2 show R .
   811 qed
   812 
   813 lemma allE':
   814   assumes 1: "ALL x. P x"
   815     and 2: "P x ==> ALL x. P x ==> Q"
   816   shows Q
   817 proof -
   818   from 1 have "P x" by (rule spec)
   819   from this and 1 show Q by (rule 2)
   820 qed
   821 
   822 lemma notE':
   823   assumes 1: "~ P"
   824     and 2: "~ P ==> P"
   825   shows R
   826 proof -
   827   from 2 and 1 have P .
   828   with 1 show R by (rule notE)
   829 qed
   830 
   831 lemmas [Pure.elim!] = disjE iffE FalseE conjE exE
   832   and [Pure.intro!] = iffI conjI impI TrueI notI allI refl
   833   and [Pure.elim 2] = allE notE' impE'
   834   and [Pure.intro] = exI disjI2 disjI1
   835 
   836 lemmas [trans] = trans
   837   and [sym] = sym not_sym
   838   and [Pure.elim?] = iffD1 iffD2 impE
   839 
   840 
   841 subsubsection {* Atomizing meta-level connectives *}
   842 
   843 lemma atomize_all [atomize]: "(!!x. P x) == Trueprop (ALL x. P x)"
   844 proof
   845   assume "!!x. P x"
   846   show "ALL x. P x" by (rule allI)
   847 next
   848   assume "ALL x. P x"
   849   thus "!!x. P x" by (rule allE)
   850 qed
   851 
   852 lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A --> B)"
   853 proof
   854   assume r: "A ==> B"
   855   show "A --> B" by (rule impI) (rule r)
   856 next
   857   assume "A --> B" and A
   858   thus B by (rule mp)
   859 qed
   860 
   861 lemma atomize_not: "(A ==> False) == Trueprop (~A)"
   862 proof
   863   assume r: "A ==> False"
   864   show "~A" by (rule notI) (rule r)
   865 next
   866   assume "~A" and A
   867   thus False by (rule notE)
   868 qed
   869 
   870 lemma atomize_eq [atomize]: "(x == y) == Trueprop (x = y)"
   871 proof
   872   assume "x == y"
   873   show "x = y" by (unfold prems) (rule refl)
   874 next
   875   assume "x = y"
   876   thus "x == y" by (rule eq_reflection)
   877 qed
   878 
   879 lemma atomize_conj [atomize]:
   880   "(!!C. (A ==> B ==> PROP C) ==> PROP C) == Trueprop (A & B)"
   881 proof
   882   assume "!!C. (A ==> B ==> PROP C) ==> PROP C"
   883   show "A & B" by (rule conjI)
   884 next
   885   fix C
   886   assume "A & B"
   887   assume "A ==> B ==> PROP C"
   888   thus "PROP C"
   889   proof this
   890     show A by (rule conjunct1)
   891     show B by (rule conjunct2)
   892   qed
   893 qed
   894 
   895 lemmas [symmetric, rulify] = atomize_all atomize_imp
   896 
   897 
   898 subsubsection {* Classical Reasoner setup *}
   899 
   900 use "cladata.ML"
   901 setup hypsubst_setup
   902 
   903 setup {*
   904   [ContextRules.addSWrapper (fn tac => hyp_subst_tac' ORELSE' tac)]
   905 *}
   906 
   907 setup Classical.setup
   908 setup clasetup
   909 
   910 lemmas [intro?] = ext
   911   and [elim?] = ex1_implies_ex
   912 
   913 use "blastdata.ML"
   914 setup Blast.setup
   915 
   916 
   917 subsection {* Simplifier setup *}
   918 
   919 lemma meta_eq_to_obj_eq: "x == y ==> x = y"
   920 proof -
   921   assume r: "x == y"
   922   show "x = y" by (unfold r) (rule refl)
   923 qed
   924 
   925 lemma eta_contract_eq: "(%s. f s) = f" ..
   926 
   927 lemma simp_thms:
   928   shows not_not: "(~ ~ P) = P"
   929   and Not_eq_iff: "((~P) = (~Q)) = (P = Q)"
   930   and
   931     "(P ~= Q) = (P = (~Q))"
   932     "(P | ~P) = True"    "(~P | P) = True"
   933     "(x = x) = True"
   934     "(~True) = False"  "(~False) = True"
   935     "(~P) ~= P"  "P ~= (~P)"
   936     "(True=P) = P"  "(P=True) = P"  "(False=P) = (~P)"  "(P=False) = (~P)"
   937     "(True --> P) = P"  "(False --> P) = True"
   938     "(P --> True) = True"  "(P --> P) = True"
   939     "(P --> False) = (~P)"  "(P --> ~P) = (~P)"
   940     "(P & True) = P"  "(True & P) = P"
   941     "(P & False) = False"  "(False & P) = False"
   942     "(P & P) = P"  "(P & (P & Q)) = (P & Q)"
   943     "(P & ~P) = False"    "(~P & P) = False"
   944     "(P | True) = True"  "(True | P) = True"
   945     "(P | False) = P"  "(False | P) = P"
   946     "(P | P) = P"  "(P | (P | Q)) = (P | Q)" and
   947     "(ALL x. P) = P"  "(EX x. P) = P"  "EX x. x=t"  "EX x. t=x"
   948     -- {* needed for the one-point-rule quantifier simplification procs *}
   949     -- {* essential for termination!! *} and
   950     "!!P. (EX x. x=t & P(x)) = P(t)"
   951     "!!P. (EX x. t=x & P(x)) = P(t)"
   952     "!!P. (ALL x. x=t --> P(x)) = P(t)"
   953     "!!P. (ALL x. t=x --> P(x)) = P(t)"
   954   by (blast, blast, blast, blast, blast, rules+)
   955 
   956 lemma imp_cong: "(P = P') ==> (P' ==> (Q = Q')) ==> ((P --> Q) = (P' --> Q'))"
   957   by rules
   958 
   959 lemma ex_simps:
   960   "!!P Q. (EX x. P x & Q)   = ((EX x. P x) & Q)"
   961   "!!P Q. (EX x. P & Q x)   = (P & (EX x. Q x))"
   962   "!!P Q. (EX x. P x | Q)   = ((EX x. P x) | Q)"
   963   "!!P Q. (EX x. P | Q x)   = (P | (EX x. Q x))"
   964   "!!P Q. (EX x. P x --> Q) = ((ALL x. P x) --> Q)"
   965   "!!P Q. (EX x. P --> Q x) = (P --> (EX x. Q x))"
   966   -- {* Miniscoping: pushing in existential quantifiers. *}
   967   by (rules | blast)+
   968 
   969 lemma all_simps:
   970   "!!P Q. (ALL x. P x & Q)   = ((ALL x. P x) & Q)"
   971   "!!P Q. (ALL x. P & Q x)   = (P & (ALL x. Q x))"
   972   "!!P Q. (ALL x. P x | Q)   = ((ALL x. P x) | Q)"
   973   "!!P Q. (ALL x. P | Q x)   = (P | (ALL x. Q x))"
   974   "!!P Q. (ALL x. P x --> Q) = ((EX x. P x) --> Q)"
   975   "!!P Q. (ALL x. P --> Q x) = (P --> (ALL x. Q x))"
   976   -- {* Miniscoping: pushing in universal quantifiers. *}
   977   by (rules | blast)+
   978 
   979 lemma disj_absorb: "(A | A) = A"
   980   by blast
   981 
   982 lemma disj_left_absorb: "(A | (A | B)) = (A | B)"
   983   by blast
   984 
   985 lemma conj_absorb: "(A & A) = A"
   986   by blast
   987 
   988 lemma conj_left_absorb: "(A & (A & B)) = (A & B)"
   989   by blast
   990 
   991 lemma eq_ac:
   992   shows eq_commute: "(a=b) = (b=a)"
   993     and eq_left_commute: "(P=(Q=R)) = (Q=(P=R))"
   994     and eq_assoc: "((P=Q)=R) = (P=(Q=R))" by (rules, blast+)
   995 lemma neq_commute: "(a~=b) = (b~=a)" by rules
   996 
   997 lemma conj_comms:
   998   shows conj_commute: "(P&Q) = (Q&P)"
   999     and conj_left_commute: "(P&(Q&R)) = (Q&(P&R))" by rules+
  1000 lemma conj_assoc: "((P&Q)&R) = (P&(Q&R))" by rules
  1001 
  1002 lemma disj_comms:
  1003   shows disj_commute: "(P|Q) = (Q|P)"
  1004     and disj_left_commute: "(P|(Q|R)) = (Q|(P|R))" by rules+
  1005 lemma disj_assoc: "((P|Q)|R) = (P|(Q|R))" by rules
  1006 
  1007 lemma conj_disj_distribL: "(P&(Q|R)) = (P&Q | P&R)" by rules
  1008 lemma conj_disj_distribR: "((P|Q)&R) = (P&R | Q&R)" by rules
  1009 
  1010 lemma disj_conj_distribL: "(P|(Q&R)) = ((P|Q) & (P|R))" by rules
  1011 lemma disj_conj_distribR: "((P&Q)|R) = ((P|R) & (Q|R))" by rules
  1012 
  1013 lemma imp_conjR: "(P --> (Q&R)) = ((P-->Q) & (P-->R))" by rules
  1014 lemma imp_conjL: "((P&Q) -->R)  = (P --> (Q --> R))" by rules
  1015 lemma imp_disjL: "((P|Q) --> R) = ((P-->R)&(Q-->R))" by rules
  1016 
  1017 text {* These two are specialized, but @{text imp_disj_not1} is useful in @{text "Auth/Yahalom"}. *}
  1018 lemma imp_disj_not1: "(P --> Q | R) = (~Q --> P --> R)" by blast
  1019 lemma imp_disj_not2: "(P --> Q | R) = (~R --> P --> Q)" by blast
  1020 
  1021 lemma imp_disj1: "((P-->Q)|R) = (P--> Q|R)" by blast
  1022 lemma imp_disj2: "(Q|(P-->R)) = (P--> Q|R)" by blast
  1023 
  1024 lemma de_Morgan_disj: "(~(P | Q)) = (~P & ~Q)" by rules
  1025 lemma de_Morgan_conj: "(~(P & Q)) = (~P | ~Q)" by blast
  1026 lemma not_imp: "(~(P --> Q)) = (P & ~Q)" by blast
  1027 lemma not_iff: "(P~=Q) = (P = (~Q))" by blast
  1028 lemma disj_not1: "(~P | Q) = (P --> Q)" by blast
  1029 lemma disj_not2: "(P | ~Q) = (Q --> P)"  -- {* changes orientation :-( *}
  1030   by blast
  1031 lemma imp_conv_disj: "(P --> Q) = ((~P) | Q)" by blast
  1032 
  1033 lemma iff_conv_conj_imp: "(P = Q) = ((P --> Q) & (Q --> P))" by rules
  1034 
  1035 
  1036 lemma cases_simp: "((P --> Q) & (~P --> Q)) = Q"
  1037   -- {* Avoids duplication of subgoals after @{text split_if}, when the true and false *}
  1038   -- {* cases boil down to the same thing. *}
  1039   by blast
  1040 
  1041 lemma not_all: "(~ (! x. P(x))) = (? x.~P(x))" by blast
  1042 lemma imp_all: "((! x. P x) --> Q) = (? x. P x --> Q)" by blast
  1043 lemma not_ex: "(~ (? x. P(x))) = (! x.~P(x))" by rules
  1044 lemma imp_ex: "((? x. P x) --> Q) = (! x. P x --> Q)" by rules
  1045 
  1046 lemma ex_disj_distrib: "(? x. P(x) | Q(x)) = ((? x. P(x)) | (? x. Q(x)))" by rules
  1047 lemma all_conj_distrib: "(!x. P(x) & Q(x)) = ((! x. P(x)) & (! x. Q(x)))" by rules
  1048 
  1049 text {*
  1050   \medskip The @{text "&"} congruence rule: not included by default!
  1051   May slow rewrite proofs down by as much as 50\% *}
  1052 
  1053 lemma conj_cong:
  1054     "(P = P') ==> (P' ==> (Q = Q')) ==> ((P & Q) = (P' & Q'))"
  1055   by rules
  1056 
  1057 lemma rev_conj_cong:
  1058     "(Q = Q') ==> (Q' ==> (P = P')) ==> ((P & Q) = (P' & Q'))"
  1059   by rules
  1060 
  1061 text {* The @{text "|"} congruence rule: not included by default! *}
  1062 
  1063 lemma disj_cong:
  1064     "(P = P') ==> (~P' ==> (Q = Q')) ==> ((P | Q) = (P' | Q'))"
  1065   by blast
  1066 
  1067 lemma eq_sym_conv: "(x = y) = (y = x)"
  1068   by rules
  1069 
  1070 
  1071 text {* \medskip if-then-else rules *}
  1072 
  1073 lemma if_True: "(if True then x else y) = x"
  1074   by (unfold if_def) blast
  1075 
  1076 lemma if_False: "(if False then x else y) = y"
  1077   by (unfold if_def) blast
  1078 
  1079 lemma if_P: "P ==> (if P then x else y) = x"
  1080   by (unfold if_def) blast
  1081 
  1082 lemma if_not_P: "~P ==> (if P then x else y) = y"
  1083   by (unfold if_def) blast
  1084 
  1085 lemma split_if: "P (if Q then x else y) = ((Q --> P(x)) & (~Q --> P(y)))"
  1086   apply (rule case_split [of Q])
  1087    apply (simplesubst if_P)
  1088     prefer 3 apply (simplesubst if_not_P, blast+)
  1089   done
  1090 
  1091 lemma split_if_asm: "P (if Q then x else y) = (~((Q & ~P x) | (~Q & ~P y)))"
  1092 by (simplesubst split_if, blast)
  1093 
  1094 lemmas if_splits = split_if split_if_asm
  1095 
  1096 lemma if_def2: "(if Q then x else y) = ((Q --> x) & (~ Q --> y))"
  1097   by (rule split_if)
  1098 
  1099 lemma if_cancel: "(if c then x else x) = x"
  1100 by (simplesubst split_if, blast)
  1101 
  1102 lemma if_eq_cancel: "(if x = y then y else x) = x"
  1103 by (simplesubst split_if, blast)
  1104 
  1105 lemma if_bool_eq_conj: "(if P then Q else R) = ((P-->Q) & (~P-->R))"
  1106   -- {* This form is useful for expanding @{text if}s on the RIGHT of the @{text "==>"} symbol. *}
  1107   by (rule split_if)
  1108 
  1109 lemma if_bool_eq_disj: "(if P then Q else R) = ((P&Q) | (~P&R))"
  1110   -- {* And this form is useful for expanding @{text if}s on the LEFT. *}
  1111   apply (simplesubst split_if, blast)
  1112   done
  1113 
  1114 lemma Eq_TrueI: "P ==> P == True" by (unfold atomize_eq) rules
  1115 lemma Eq_FalseI: "~P ==> P == False" by (unfold atomize_eq) rules
  1116 
  1117 text {* \medskip let rules for simproc *}
  1118 
  1119 lemma Let_folded: "f x \<equiv> g x \<Longrightarrow>  Let x f \<equiv> Let x g"
  1120   by (unfold Let_def)
  1121 
  1122 lemma Let_unfold: "f x \<equiv> g \<Longrightarrow>  Let x f \<equiv> g"
  1123   by (unfold Let_def)
  1124 
  1125 subsubsection {* Actual Installation of the Simplifier *}
  1126 
  1127 use "simpdata.ML"
  1128 setup "Simplifier.method_setup Splitter.split_modifiers" setup simpsetup
  1129 setup Splitter.setup setup Clasimp.setup
  1130 
  1131 
  1132 subsubsection {* Lucas Dixon's eqstep tactic *}
  1133 
  1134 use "~~/src/Provers/eqsubst.ML";
  1135 use "eqrule_HOL_data.ML";
  1136 
  1137 setup EQSubstTac.setup
  1138 
  1139 
  1140 subsection {* Other simple lemmas *}
  1141 
  1142 declare disj_absorb [simp] conj_absorb [simp]
  1143 
  1144 lemma ex1_eq[iff]: "EX! x. x = t" "EX! x. t = x"
  1145 by blast+
  1146 
  1147 
  1148 theorem choice_eq: "(ALL x. EX! y. P x y) = (EX! f. ALL x. P x (f x))"
  1149   apply (rule iffI)
  1150   apply (rule_tac a = "%x. THE y. P x y" in ex1I)
  1151   apply (fast dest!: theI')
  1152   apply (fast intro: ext the1_equality [symmetric])
  1153   apply (erule ex1E)
  1154   apply (rule allI)
  1155   apply (rule ex1I)
  1156   apply (erule spec)
  1157   apply (erule_tac x = "%z. if z = x then y else f z" in allE)
  1158   apply (erule impE)
  1159   apply (rule allI)
  1160   apply (rule_tac P = "xa = x" in case_split_thm)
  1161   apply (drule_tac [3] x = x in fun_cong, simp_all)
  1162   done
  1163 
  1164 text{*Needs only HOL-lemmas:*}
  1165 lemma mk_left_commute:
  1166   assumes a: "\<And>x y z. f (f x y) z = f x (f y z)" and
  1167           c: "\<And>x y. f x y = f y x"
  1168   shows "f x (f y z) = f y (f x z)"
  1169 by(rule trans[OF trans[OF c a] arg_cong[OF c, of "f y"]])
  1170 
  1171 
  1172 subsection {* Generic cases and induction *}
  1173 
  1174 constdefs
  1175   induct_forall :: "('a => bool) => bool"
  1176   "induct_forall P == \<forall>x. P x"
  1177   induct_implies :: "bool => bool => bool"
  1178   "induct_implies A B == A --> B"
  1179   induct_equal :: "'a => 'a => bool"
  1180   "induct_equal x y == x = y"
  1181   induct_conj :: "bool => bool => bool"
  1182   "induct_conj A B == A & B"
  1183 
  1184 lemma induct_forall_eq: "(!!x. P x) == Trueprop (induct_forall (\<lambda>x. P x))"
  1185   by (simp only: atomize_all induct_forall_def)
  1186 
  1187 lemma induct_implies_eq: "(A ==> B) == Trueprop (induct_implies A B)"
  1188   by (simp only: atomize_imp induct_implies_def)
  1189 
  1190 lemma induct_equal_eq: "(x == y) == Trueprop (induct_equal x y)"
  1191   by (simp only: atomize_eq induct_equal_def)
  1192 
  1193 lemma induct_forall_conj: "induct_forall (\<lambda>x. induct_conj (A x) (B x)) =
  1194     induct_conj (induct_forall A) (induct_forall B)"
  1195   by (unfold induct_forall_def induct_conj_def) rules
  1196 
  1197 lemma induct_implies_conj: "induct_implies C (induct_conj A B) =
  1198     induct_conj (induct_implies C A) (induct_implies C B)"
  1199   by (unfold induct_implies_def induct_conj_def) rules
  1200 
  1201 lemma induct_conj_curry: "(induct_conj A B ==> PROP C) == (A ==> B ==> PROP C)"
  1202 proof
  1203   assume r: "induct_conj A B ==> PROP C" and A B
  1204   show "PROP C" by (rule r) (simp! add: induct_conj_def)
  1205 next
  1206   assume r: "A ==> B ==> PROP C" and "induct_conj A B"
  1207   show "PROP C" by (rule r) (simp! add: induct_conj_def)+
  1208 qed
  1209 
  1210 lemma induct_impliesI: "(A ==> B) ==> induct_implies A B"
  1211   by (simp add: induct_implies_def)
  1212 
  1213 lemmas induct_atomize = atomize_conj induct_forall_eq induct_implies_eq induct_equal_eq
  1214 lemmas induct_rulify1 [symmetric, standard] = induct_forall_eq induct_implies_eq induct_equal_eq
  1215 lemmas induct_rulify2 = induct_forall_def induct_implies_def induct_equal_def induct_conj_def
  1216 lemmas induct_conj = induct_forall_conj induct_implies_conj induct_conj_curry
  1217 
  1218 hide const induct_forall induct_implies induct_equal induct_conj
  1219 
  1220 
  1221 text {* Method setup. *}
  1222 
  1223 ML {*
  1224   structure InductMethod = InductMethodFun
  1225   (struct
  1226     val dest_concls = HOLogic.dest_concls
  1227     val cases_default = thm "case_split"
  1228     val local_impI = thm "induct_impliesI"
  1229     val conjI = thm "conjI"
  1230     val atomize = thms "induct_atomize"
  1231     val rulify1 = thms "induct_rulify1"
  1232     val rulify2 = thms "induct_rulify2"
  1233     val localize = [Thm.symmetric (thm "induct_implies_def")]
  1234   end);
  1235 *}
  1236 
  1237 setup InductMethod.setup
  1238 
  1239 
  1240 end
  1241