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