src/HOL/HOL.thy
author haftmann
Wed Aug 15 08:57:39 2007 +0200 (2007-08-15)
changeset 24280 c9867bdf2424
parent 24219 e558fe311376
child 24286 7619080e49f0
permissions -rw-r--r--
updated code generator setup
     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
    11   "~~/src/Tools/integer.ML"
    12   ("hologic.ML")
    13   "~~/src/Tools/IsaPlanner/zipper.ML"
    14   "~~/src/Tools/IsaPlanner/isand.ML"
    15   "~~/src/Tools/IsaPlanner/rw_tools.ML"
    16   "~~/src/Tools/IsaPlanner/rw_inst.ML"
    17   "~~/src/Provers/project_rule.ML"
    18   "~~/src/Provers/induct_method.ML"
    19   "~~/src/Provers/hypsubst.ML"
    20   "~~/src/Provers/splitter.ML"
    21   "~~/src/Provers/classical.ML"
    22   "~~/src/Provers/blast.ML"
    23   "~~/src/Provers/clasimp.ML"
    24   "~~/src/Provers/eqsubst.ML"
    25   "~~/src/Provers/quantifier1.ML"
    26   ("simpdata.ML")
    27   "~~/src/Pure/codegen.ML"
    28   "~~/src/Tools/code/code_name.ML"
    29   "~~/src/Tools/code/code_funcgr.ML"
    30   "~~/src/Tools/code/code_thingol.ML"
    31   "~~/src/Tools/code/code_target.ML"
    32   "~~/src/Tools/code/code_package.ML"
    33   "~~/src/Tools/nbe.ML"
    34 begin
    35 
    36 subsection {* Primitive logic *}
    37 
    38 subsubsection {* Core syntax *}
    39 
    40 classes type
    41 defaultsort type
    42 
    43 global
    44 
    45 typedecl bool
    46 
    47 arities
    48   bool :: type
    49   "fun" :: (type, type) type
    50 
    51 judgment
    52   Trueprop      :: "bool => prop"                   ("(_)" 5)
    53 
    54 consts
    55   Not           :: "bool => bool"                   ("~ _" [40] 40)
    56   True          :: bool
    57   False         :: bool
    58   arbitrary     :: 'a
    59 
    60   The           :: "('a => bool) => 'a"
    61   All           :: "('a => bool) => bool"           (binder "ALL " 10)
    62   Ex            :: "('a => bool) => bool"           (binder "EX " 10)
    63   Ex1           :: "('a => bool) => bool"           (binder "EX! " 10)
    64   Let           :: "['a, 'a => 'b] => 'b"
    65 
    66   "op ="        :: "['a, 'a] => bool"               (infixl "=" 50)
    67   "op &"        :: "[bool, bool] => bool"           (infixr "&" 35)
    68   "op |"        :: "[bool, bool] => bool"           (infixr "|" 30)
    69   "op -->"      :: "[bool, bool] => bool"           (infixr "-->" 25)
    70 
    71 local
    72 
    73 consts
    74   If            :: "[bool, 'a, 'a] => 'a"           ("(if (_)/ then (_)/ else (_))" 10)
    75 
    76 
    77 subsubsection {* Additional concrete syntax *}
    78 
    79 notation (output)
    80   "op ="  (infix "=" 50)
    81 
    82 abbreviation
    83   not_equal :: "['a, 'a] => bool"  (infixl "~=" 50) where
    84   "x ~= y == ~ (x = y)"
    85 
    86 notation (output)
    87   not_equal  (infix "~=" 50)
    88 
    89 notation (xsymbols)
    90   Not  ("\<not> _" [40] 40) and
    91   "op &"  (infixr "\<and>" 35) and
    92   "op |"  (infixr "\<or>" 30) and
    93   "op -->"  (infixr "\<longrightarrow>" 25) and
    94   not_equal  (infix "\<noteq>" 50)
    95 
    96 notation (HTML output)
    97   Not  ("\<not> _" [40] 40) and
    98   "op &"  (infixr "\<and>" 35) and
    99   "op |"  (infixr "\<or>" 30) and
   100   not_equal  (infix "\<noteq>" 50)
   101 
   102 abbreviation (iff)
   103   iff :: "[bool, bool] => bool"  (infixr "<->" 25) where
   104   "A <-> B == A = B"
   105 
   106 notation (xsymbols)
   107   iff  (infixr "\<longleftrightarrow>" 25)
   108 
   109 
   110 nonterminals
   111   letbinds  letbind
   112   case_syn  cases_syn
   113 
   114 syntax
   115   "_The"        :: "[pttrn, bool] => 'a"                 ("(3THE _./ _)" [0, 10] 10)
   116 
   117   "_bind"       :: "[pttrn, 'a] => letbind"              ("(2_ =/ _)" 10)
   118   ""            :: "letbind => letbinds"                 ("_")
   119   "_binds"      :: "[letbind, letbinds] => letbinds"     ("_;/ _")
   120   "_Let"        :: "[letbinds, 'a] => 'a"                ("(let (_)/ in (_))" 10)
   121 
   122   "_case_syntax":: "['a, cases_syn] => 'b"               ("(case _ of/ _)" 10)
   123   "_case1"      :: "['a, 'b] => case_syn"                ("(2_ =>/ _)" 10)
   124   ""            :: "case_syn => cases_syn"               ("_")
   125   "_case2"      :: "[case_syn, cases_syn] => cases_syn"  ("_/ | _")
   126 
   127 translations
   128   "THE x. P"              == "The (%x. P)"
   129   "_Let (_binds b bs) e"  == "_Let b (_Let bs e)"
   130   "let x = a in e"        == "Let a (%x. e)"
   131 
   132 print_translation {*
   133 (* To avoid eta-contraction of body: *)
   134 [("The", fn [Abs abs] =>
   135      let val (x,t) = atomic_abs_tr' abs
   136      in Syntax.const "_The" $ x $ t end)]
   137 *}
   138 
   139 syntax (xsymbols)
   140   "_case1"      :: "['a, 'b] => case_syn"                ("(2_ \<Rightarrow>/ _)" 10)
   141 
   142 notation (xsymbols)
   143   All  (binder "\<forall>" 10) and
   144   Ex  (binder "\<exists>" 10) and
   145   Ex1  (binder "\<exists>!" 10)
   146 
   147 notation (HTML output)
   148   All  (binder "\<forall>" 10) and
   149   Ex  (binder "\<exists>" 10) and
   150   Ex1  (binder "\<exists>!" 10)
   151 
   152 notation (HOL)
   153   All  (binder "! " 10) and
   154   Ex  (binder "? " 10) and
   155   Ex1  (binder "?! " 10)
   156 
   157 
   158 subsubsection {* Axioms and basic definitions *}
   159 
   160 axioms
   161   eq_reflection:  "(x=y) ==> (x==y)"
   162 
   163   refl:           "t = (t::'a)"
   164 
   165   ext:            "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)"
   166     -- {*Extensionality is built into the meta-logic, and this rule expresses
   167          a related property.  It is an eta-expanded version of the traditional
   168          rule, and similar to the ABS rule of HOL*}
   169 
   170   the_eq_trivial: "(THE x. x = a) = (a::'a)"
   171 
   172   impI:           "(P ==> Q) ==> P-->Q"
   173   mp:             "[| P-->Q;  P |] ==> Q"
   174 
   175 
   176 defs
   177   True_def:     "True      == ((%x::bool. x) = (%x. x))"
   178   All_def:      "All(P)    == (P = (%x. True))"
   179   Ex_def:       "Ex(P)     == !Q. (!x. P x --> Q) --> Q"
   180   False_def:    "False     == (!P. P)"
   181   not_def:      "~ P       == P-->False"
   182   and_def:      "P & Q     == !R. (P-->Q-->R) --> R"
   183   or_def:       "P | Q     == !R. (P-->R) --> (Q-->R) --> R"
   184   Ex1_def:      "Ex1(P)    == ? x. P(x) & (! y. P(y) --> y=x)"
   185 
   186 axioms
   187   iff:          "(P-->Q) --> (Q-->P) --> (P=Q)"
   188   True_or_False:  "(P=True) | (P=False)"
   189 
   190 defs
   191   Let_def:      "Let s f == f(s)"
   192   if_def:       "If P x y == THE z::'a. (P=True --> z=x) & (P=False --> z=y)"
   193 
   194 finalconsts
   195   "op ="
   196   "op -->"
   197   The
   198   arbitrary
   199 
   200 axiomatization
   201   undefined :: 'a
   202 
   203 axiomatization where
   204   undefined_fun: "undefined x = undefined"
   205 
   206 
   207 subsubsection {* Generic classes and algebraic operations *}
   208 
   209 class default = type +
   210   fixes default :: "'a"
   211 
   212 class zero = type + 
   213   fixes zero :: "'a"  ("\<^loc>0")
   214 
   215 class one = type +
   216   fixes one  :: "'a"  ("\<^loc>1")
   217 
   218 hide (open) const zero one
   219 
   220 class plus = type +
   221   fixes plus :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixl "\<^loc>+" 65)
   222 
   223 class minus = type +
   224   fixes uminus :: "'a \<Rightarrow> 'a" 
   225     and minus :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixl "\<^loc>-" 65)
   226 
   227 class times = type +
   228   fixes times :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixl "\<^loc>*" 70)
   229 
   230 class inverse = type +
   231   fixes inverse :: "'a \<Rightarrow> 'a"
   232     and divide :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixl "\<^loc>'/" 70)
   233 
   234 class abs = type +
   235   fixes abs :: "'a \<Rightarrow> 'a"
   236 
   237 notation
   238   uminus  ("- _" [81] 80)
   239 
   240 notation (xsymbols)
   241   abs  ("\<bar>_\<bar>")
   242 notation (HTML output)
   243   abs  ("\<bar>_\<bar>")
   244 
   245 class ord = type +
   246   fixes less_eq :: "'a \<Rightarrow> 'a \<Rightarrow> bool"  (infix "\<sqsubseteq>" 50)
   247     and less :: "'a \<Rightarrow> 'a \<Rightarrow> bool"  (infix "\<sqsubset>" 50)
   248 begin
   249 
   250 notation
   251   less_eq  ("op \<^loc><=") and
   252   less_eq  ("(_/ \<^loc><= _)" [51, 51] 50) and
   253   less  ("op \<^loc><") and
   254   less  ("(_/ \<^loc>< _)"  [51, 51] 50)
   255   
   256 notation (xsymbols)
   257   less_eq  ("op \<^loc>\<le>") and
   258   less_eq  ("(_/ \<^loc>\<le> _)"  [51, 51] 50)
   259 
   260 notation (HTML output)
   261   less_eq  ("op \<^loc>\<le>") and
   262   less_eq  ("(_/ \<^loc>\<le> _)"  [51, 51] 50)
   263 
   264 abbreviation (input)
   265   greater  (infix "\<^loc>>" 50) where
   266   "x \<^loc>> y \<equiv> y \<^loc>< x"
   267 
   268 abbreviation (input)
   269   greater_eq  (infix "\<^loc>>=" 50) where
   270   "x \<^loc>>= y \<equiv> y \<^loc><= x"
   271 
   272 notation (input)
   273   greater_eq  (infix "\<^loc>\<ge>" 50)
   274 
   275 definition
   276   Least :: "('a \<Rightarrow> bool) \<Rightarrow> 'a" (binder "\<^loc>LEAST " 10)
   277 where
   278   "Least P == (THE x. P x \<and> (\<forall>y. P y \<longrightarrow> x \<^loc>\<le> y))"
   279 
   280 end
   281 
   282 notation
   283   less_eq  ("op <=") and
   284   less_eq  ("(_/ <= _)" [51, 51] 50) and
   285   less  ("op <") and
   286   less  ("(_/ < _)"  [51, 51] 50)
   287   
   288 notation (xsymbols)
   289   less_eq  ("op \<le>") and
   290   less_eq  ("(_/ \<le> _)"  [51, 51] 50)
   291 
   292 notation (HTML output)
   293   less_eq  ("op \<le>") and
   294   less_eq  ("(_/ \<le> _)"  [51, 51] 50)
   295 
   296 abbreviation (input)
   297   greater  (infix ">" 50) where
   298   "x > y \<equiv> y < x"
   299 
   300 abbreviation (input)
   301   greater_eq  (infix ">=" 50) where
   302   "x >= y \<equiv> y <= x"
   303 
   304 notation (input)
   305   greater_eq  (infix "\<ge>" 50)
   306 
   307 syntax
   308   "_index1"  :: index    ("\<^sub>1")
   309 translations
   310   (index) "\<^sub>1" => (index) "\<^bsub>\<struct>\<^esub>"
   311 
   312 typed_print_translation {*
   313 let
   314   fun tr' c = (c, fn show_sorts => fn T => fn ts =>
   315     if T = dummyT orelse not (! show_types) andalso can Term.dest_Type T then raise Match
   316     else Syntax.const Syntax.constrainC $ Syntax.const c $ Syntax.term_of_typ show_sorts T);
   317 in map tr' [@{const_syntax HOL.one}, @{const_syntax HOL.zero}] end;
   318 *} -- {* show types that are presumably too general *}
   319 
   320 
   321 subsection {* Fundamental rules *}
   322 
   323 subsubsection {* Equality *}
   324 
   325 text {* Thanks to Stephan Merz *}
   326 lemma subst:
   327   assumes eq: "s = t" and p: "P s"
   328   shows "P t"
   329 proof -
   330   from eq have meta: "s \<equiv> t"
   331     by (rule eq_reflection)
   332   from p show ?thesis
   333     by (unfold meta)
   334 qed
   335 
   336 lemma sym: "s = t ==> t = s"
   337   by (erule subst) (rule refl)
   338 
   339 lemma ssubst: "t = s ==> P s ==> P t"
   340   by (drule sym) (erule subst)
   341 
   342 lemma trans: "[| r=s; s=t |] ==> r=t"
   343   by (erule subst)
   344 
   345 lemma meta_eq_to_obj_eq: 
   346   assumes meq: "A == B"
   347   shows "A = B"
   348   by (unfold meq) (rule refl)
   349 
   350 text {* Useful with @{text erule} for proving equalities from known equalities. *}
   351      (* a = b
   352         |   |
   353         c = d   *)
   354 lemma box_equals: "[| a=b;  a=c;  b=d |] ==> c=d"
   355 apply (rule trans)
   356 apply (rule trans)
   357 apply (rule sym)
   358 apply assumption+
   359 done
   360 
   361 text {* For calculational reasoning: *}
   362 
   363 lemma forw_subst: "a = b ==> P b ==> P a"
   364   by (rule ssubst)
   365 
   366 lemma back_subst: "P a ==> a = b ==> P b"
   367   by (rule subst)
   368 
   369 
   370 subsubsection {*Congruence rules for application*}
   371 
   372 (*similar to AP_THM in Gordon's HOL*)
   373 lemma fun_cong: "(f::'a=>'b) = g ==> f(x)=g(x)"
   374 apply (erule subst)
   375 apply (rule refl)
   376 done
   377 
   378 (*similar to AP_TERM in Gordon's HOL and FOL's subst_context*)
   379 lemma arg_cong: "x=y ==> f(x)=f(y)"
   380 apply (erule subst)
   381 apply (rule refl)
   382 done
   383 
   384 lemma arg_cong2: "\<lbrakk> a = b; c = d \<rbrakk> \<Longrightarrow> f a c = f b d"
   385 apply (erule ssubst)+
   386 apply (rule refl)
   387 done
   388 
   389 lemma cong: "[| f = g; (x::'a) = y |] ==> f(x) = g(y)"
   390 apply (erule subst)+
   391 apply (rule refl)
   392 done
   393 
   394 
   395 subsubsection {*Equality of booleans -- iff*}
   396 
   397 lemma iffI: assumes "P ==> Q" and "Q ==> P" shows "P=Q"
   398   by (iprover intro: iff [THEN mp, THEN mp] impI assms)
   399 
   400 lemma iffD2: "[| P=Q; Q |] ==> P"
   401   by (erule ssubst)
   402 
   403 lemma rev_iffD2: "[| Q; P=Q |] ==> P"
   404   by (erule iffD2)
   405 
   406 lemma iffD1: "Q = P \<Longrightarrow> Q \<Longrightarrow> P"
   407   by (drule sym) (rule iffD2)
   408 
   409 lemma rev_iffD1: "Q \<Longrightarrow> Q = P \<Longrightarrow> P"
   410   by (drule sym) (rule rev_iffD2)
   411 
   412 lemma iffE:
   413   assumes major: "P=Q"
   414     and minor: "[| P --> Q; Q --> P |] ==> R"
   415   shows R
   416   by (iprover intro: minor impI major [THEN iffD2] major [THEN iffD1])
   417 
   418 
   419 subsubsection {*True*}
   420 
   421 lemma TrueI: "True"
   422   unfolding True_def by (rule refl)
   423 
   424 lemma eqTrueI: "P ==> P = True"
   425   by (iprover intro: iffI TrueI)
   426 
   427 lemma eqTrueE: "P = True ==> P"
   428   by (erule iffD2) (rule TrueI)
   429 
   430 
   431 subsubsection {*Universal quantifier*}
   432 
   433 lemma allI: assumes "!!x::'a. P(x)" shows "ALL x. P(x)"
   434   unfolding All_def by (iprover intro: ext eqTrueI assms)
   435 
   436 lemma spec: "ALL x::'a. P(x) ==> P(x)"
   437 apply (unfold All_def)
   438 apply (rule eqTrueE)
   439 apply (erule fun_cong)
   440 done
   441 
   442 lemma allE:
   443   assumes major: "ALL x. P(x)"
   444     and minor: "P(x) ==> R"
   445   shows R
   446   by (iprover intro: minor major [THEN spec])
   447 
   448 lemma all_dupE:
   449   assumes major: "ALL x. P(x)"
   450     and minor: "[| P(x); ALL x. P(x) |] ==> R"
   451   shows R
   452   by (iprover intro: minor major major [THEN spec])
   453 
   454 
   455 subsubsection {* False *}
   456 
   457 text {*
   458   Depends upon @{text spec}; it is impossible to do propositional
   459   logic before quantifiers!
   460 *}
   461 
   462 lemma FalseE: "False ==> P"
   463   apply (unfold False_def)
   464   apply (erule spec)
   465   done
   466 
   467 lemma False_neq_True: "False = True ==> P"
   468   by (erule eqTrueE [THEN FalseE])
   469 
   470 
   471 subsubsection {* Negation *}
   472 
   473 lemma notI:
   474   assumes "P ==> False"
   475   shows "~P"
   476   apply (unfold not_def)
   477   apply (iprover intro: impI assms)
   478   done
   479 
   480 lemma False_not_True: "False ~= True"
   481   apply (rule notI)
   482   apply (erule False_neq_True)
   483   done
   484 
   485 lemma True_not_False: "True ~= False"
   486   apply (rule notI)
   487   apply (drule sym)
   488   apply (erule False_neq_True)
   489   done
   490 
   491 lemma notE: "[| ~P;  P |] ==> R"
   492   apply (unfold not_def)
   493   apply (erule mp [THEN FalseE])
   494   apply assumption
   495   done
   496 
   497 lemma notI2: "(P \<Longrightarrow> \<not> Pa) \<Longrightarrow> (P \<Longrightarrow> Pa) \<Longrightarrow> \<not> P"
   498   by (erule notE [THEN notI]) (erule meta_mp)
   499 
   500 
   501 subsubsection {*Implication*}
   502 
   503 lemma impE:
   504   assumes "P-->Q" "P" "Q ==> R"
   505   shows "R"
   506 by (iprover intro: assms mp)
   507 
   508 (* Reduces Q to P-->Q, allowing substitution in P. *)
   509 lemma rev_mp: "[| P;  P --> Q |] ==> Q"
   510 by (iprover intro: mp)
   511 
   512 lemma contrapos_nn:
   513   assumes major: "~Q"
   514       and minor: "P==>Q"
   515   shows "~P"
   516 by (iprover intro: notI minor major [THEN notE])
   517 
   518 (*not used at all, but we already have the other 3 combinations *)
   519 lemma contrapos_pn:
   520   assumes major: "Q"
   521       and minor: "P ==> ~Q"
   522   shows "~P"
   523 by (iprover intro: notI minor major notE)
   524 
   525 lemma not_sym: "t ~= s ==> s ~= t"
   526   by (erule contrapos_nn) (erule sym)
   527 
   528 lemma eq_neq_eq_imp_neq: "[| x = a ; a ~= b; b = y |] ==> x ~= y"
   529   by (erule subst, erule ssubst, assumption)
   530 
   531 (*still used in HOLCF*)
   532 lemma rev_contrapos:
   533   assumes pq: "P ==> Q"
   534       and nq: "~Q"
   535   shows "~P"
   536 apply (rule nq [THEN contrapos_nn])
   537 apply (erule pq)
   538 done
   539 
   540 subsubsection {*Existential quantifier*}
   541 
   542 lemma exI: "P x ==> EX x::'a. P x"
   543 apply (unfold Ex_def)
   544 apply (iprover intro: allI allE impI mp)
   545 done
   546 
   547 lemma exE:
   548   assumes major: "EX x::'a. P(x)"
   549       and minor: "!!x. P(x) ==> Q"
   550   shows "Q"
   551 apply (rule major [unfolded Ex_def, THEN spec, THEN mp])
   552 apply (iprover intro: impI [THEN allI] minor)
   553 done
   554 
   555 
   556 subsubsection {*Conjunction*}
   557 
   558 lemma conjI: "[| P; Q |] ==> P&Q"
   559 apply (unfold and_def)
   560 apply (iprover intro: impI [THEN allI] mp)
   561 done
   562 
   563 lemma conjunct1: "[| P & Q |] ==> P"
   564 apply (unfold and_def)
   565 apply (iprover intro: impI dest: spec mp)
   566 done
   567 
   568 lemma conjunct2: "[| P & Q |] ==> Q"
   569 apply (unfold and_def)
   570 apply (iprover intro: impI dest: spec mp)
   571 done
   572 
   573 lemma conjE:
   574   assumes major: "P&Q"
   575       and minor: "[| P; Q |] ==> R"
   576   shows "R"
   577 apply (rule minor)
   578 apply (rule major [THEN conjunct1])
   579 apply (rule major [THEN conjunct2])
   580 done
   581 
   582 lemma context_conjI:
   583   assumes "P" "P ==> Q" shows "P & Q"
   584 by (iprover intro: conjI assms)
   585 
   586 
   587 subsubsection {*Disjunction*}
   588 
   589 lemma disjI1: "P ==> P|Q"
   590 apply (unfold or_def)
   591 apply (iprover intro: allI impI mp)
   592 done
   593 
   594 lemma disjI2: "Q ==> P|Q"
   595 apply (unfold or_def)
   596 apply (iprover intro: allI impI mp)
   597 done
   598 
   599 lemma disjE:
   600   assumes major: "P|Q"
   601       and minorP: "P ==> R"
   602       and minorQ: "Q ==> R"
   603   shows "R"
   604 by (iprover intro: minorP minorQ impI
   605                  major [unfolded or_def, THEN spec, THEN mp, THEN mp])
   606 
   607 
   608 subsubsection {*Classical logic*}
   609 
   610 lemma classical:
   611   assumes prem: "~P ==> P"
   612   shows "P"
   613 apply (rule True_or_False [THEN disjE, THEN eqTrueE])
   614 apply assumption
   615 apply (rule notI [THEN prem, THEN eqTrueI])
   616 apply (erule subst)
   617 apply assumption
   618 done
   619 
   620 lemmas ccontr = FalseE [THEN classical, standard]
   621 
   622 (*notE with premises exchanged; it discharges ~R so that it can be used to
   623   make elimination rules*)
   624 lemma rev_notE:
   625   assumes premp: "P"
   626       and premnot: "~R ==> ~P"
   627   shows "R"
   628 apply (rule ccontr)
   629 apply (erule notE [OF premnot premp])
   630 done
   631 
   632 (*Double negation law*)
   633 lemma notnotD: "~~P ==> P"
   634 apply (rule classical)
   635 apply (erule notE)
   636 apply assumption
   637 done
   638 
   639 lemma contrapos_pp:
   640   assumes p1: "Q"
   641       and p2: "~P ==> ~Q"
   642   shows "P"
   643 by (iprover intro: classical p1 p2 notE)
   644 
   645 
   646 subsubsection {*Unique existence*}
   647 
   648 lemma ex1I:
   649   assumes "P a" "!!x. P(x) ==> x=a"
   650   shows "EX! x. P(x)"
   651 by (unfold Ex1_def, iprover intro: assms exI conjI allI impI)
   652 
   653 text{*Sometimes easier to use: the premises have no shared variables.  Safe!*}
   654 lemma ex_ex1I:
   655   assumes ex_prem: "EX x. P(x)"
   656       and eq: "!!x y. [| P(x); P(y) |] ==> x=y"
   657   shows "EX! x. P(x)"
   658 by (iprover intro: ex_prem [THEN exE] ex1I eq)
   659 
   660 lemma ex1E:
   661   assumes major: "EX! x. P(x)"
   662       and minor: "!!x. [| P(x);  ALL y. P(y) --> y=x |] ==> R"
   663   shows "R"
   664 apply (rule major [unfolded Ex1_def, THEN exE])
   665 apply (erule conjE)
   666 apply (iprover intro: minor)
   667 done
   668 
   669 lemma ex1_implies_ex: "EX! x. P x ==> EX x. P x"
   670 apply (erule ex1E)
   671 apply (rule exI)
   672 apply assumption
   673 done
   674 
   675 
   676 subsubsection {*THE: definite description operator*}
   677 
   678 lemma the_equality:
   679   assumes prema: "P a"
   680       and premx: "!!x. P x ==> x=a"
   681   shows "(THE x. P x) = a"
   682 apply (rule trans [OF _ the_eq_trivial])
   683 apply (rule_tac f = "The" in arg_cong)
   684 apply (rule ext)
   685 apply (rule iffI)
   686  apply (erule premx)
   687 apply (erule ssubst, rule prema)
   688 done
   689 
   690 lemma theI:
   691   assumes "P a" and "!!x. P x ==> x=a"
   692   shows "P (THE x. P x)"
   693 by (iprover intro: assms the_equality [THEN ssubst])
   694 
   695 lemma theI': "EX! x. P x ==> P (THE x. P x)"
   696 apply (erule ex1E)
   697 apply (erule theI)
   698 apply (erule allE)
   699 apply (erule mp)
   700 apply assumption
   701 done
   702 
   703 (*Easier to apply than theI: only one occurrence of P*)
   704 lemma theI2:
   705   assumes "P a" "!!x. P x ==> x=a" "!!x. P x ==> Q x"
   706   shows "Q (THE x. P x)"
   707 by (iprover intro: assms theI)
   708 
   709 lemma the1_equality [elim?]: "[| EX!x. P x; P a |] ==> (THE x. P x) = a"
   710 apply (rule the_equality)
   711 apply  assumption
   712 apply (erule ex1E)
   713 apply (erule all_dupE)
   714 apply (drule mp)
   715 apply  assumption
   716 apply (erule ssubst)
   717 apply (erule allE)
   718 apply (erule mp)
   719 apply assumption
   720 done
   721 
   722 lemma the_sym_eq_trivial: "(THE y. x=y) = x"
   723 apply (rule the_equality)
   724 apply (rule refl)
   725 apply (erule sym)
   726 done
   727 
   728 
   729 subsubsection {*Classical intro rules for disjunction and existential quantifiers*}
   730 
   731 lemma disjCI:
   732   assumes "~Q ==> P" shows "P|Q"
   733 apply (rule classical)
   734 apply (iprover intro: assms disjI1 disjI2 notI elim: notE)
   735 done
   736 
   737 lemma excluded_middle: "~P | P"
   738 by (iprover intro: disjCI)
   739 
   740 text {*
   741   case distinction as a natural deduction rule.
   742   Note that @{term "~P"} is the second case, not the first
   743 *}
   744 lemma case_split_thm:
   745   assumes prem1: "P ==> Q"
   746       and prem2: "~P ==> Q"
   747   shows "Q"
   748 apply (rule excluded_middle [THEN disjE])
   749 apply (erule prem2)
   750 apply (erule prem1)
   751 done
   752 lemmas case_split = case_split_thm [case_names True False]
   753 
   754 (*Classical implies (-->) elimination. *)
   755 lemma impCE:
   756   assumes major: "P-->Q"
   757       and minor: "~P ==> R" "Q ==> R"
   758   shows "R"
   759 apply (rule excluded_middle [of P, THEN disjE])
   760 apply (iprover intro: minor major [THEN mp])+
   761 done
   762 
   763 (*This version of --> elimination works on Q before P.  It works best for
   764   those cases in which P holds "almost everywhere".  Can't install as
   765   default: would break old proofs.*)
   766 lemma impCE':
   767   assumes major: "P-->Q"
   768       and minor: "Q ==> R" "~P ==> R"
   769   shows "R"
   770 apply (rule excluded_middle [of P, THEN disjE])
   771 apply (iprover intro: minor major [THEN mp])+
   772 done
   773 
   774 (*Classical <-> elimination. *)
   775 lemma iffCE:
   776   assumes major: "P=Q"
   777       and minor: "[| P; Q |] ==> R"  "[| ~P; ~Q |] ==> R"
   778   shows "R"
   779 apply (rule major [THEN iffE])
   780 apply (iprover intro: minor elim: impCE notE)
   781 done
   782 
   783 lemma exCI:
   784   assumes "ALL x. ~P(x) ==> P(a)"
   785   shows "EX x. P(x)"
   786 apply (rule ccontr)
   787 apply (iprover intro: assms exI allI notI notE [of "\<exists>x. P x"])
   788 done
   789 
   790 
   791 subsubsection {* Intuitionistic Reasoning *}
   792 
   793 lemma impE':
   794   assumes 1: "P --> Q"
   795     and 2: "Q ==> R"
   796     and 3: "P --> Q ==> P"
   797   shows R
   798 proof -
   799   from 3 and 1 have P .
   800   with 1 have Q by (rule impE)
   801   with 2 show R .
   802 qed
   803 
   804 lemma allE':
   805   assumes 1: "ALL x. P x"
   806     and 2: "P x ==> ALL x. P x ==> Q"
   807   shows Q
   808 proof -
   809   from 1 have "P x" by (rule spec)
   810   from this and 1 show Q by (rule 2)
   811 qed
   812 
   813 lemma notE':
   814   assumes 1: "~ P"
   815     and 2: "~ P ==> P"
   816   shows R
   817 proof -
   818   from 2 and 1 have P .
   819   with 1 show R by (rule notE)
   820 qed
   821 
   822 lemma TrueE: "True ==> P ==> P" .
   823 lemma notFalseE: "~ False ==> P ==> P" .
   824 
   825 lemmas [Pure.elim!] = disjE iffE FalseE conjE exE TrueE notFalseE
   826   and [Pure.intro!] = iffI conjI impI TrueI notI allI refl
   827   and [Pure.elim 2] = allE notE' impE'
   828   and [Pure.intro] = exI disjI2 disjI1
   829 
   830 lemmas [trans] = trans
   831   and [sym] = sym not_sym
   832   and [Pure.elim?] = iffD1 iffD2 impE
   833 
   834 use "hologic.ML"
   835 
   836 
   837 subsubsection {* Atomizing meta-level connectives *}
   838 
   839 lemma atomize_all [atomize]: "(!!x. P x) == Trueprop (ALL x. P x)"
   840 proof
   841   assume "!!x. P x"
   842   then show "ALL x. P x" ..
   843 next
   844   assume "ALL x. P x"
   845   then show "!!x. P x" by (rule allE)
   846 qed
   847 
   848 lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A --> B)"
   849 proof
   850   assume r: "A ==> B"
   851   show "A --> B" by (rule impI) (rule r)
   852 next
   853   assume "A --> B" and A
   854   then show B by (rule mp)
   855 qed
   856 
   857 lemma atomize_not: "(A ==> False) == Trueprop (~A)"
   858 proof
   859   assume r: "A ==> False"
   860   show "~A" by (rule notI) (rule r)
   861 next
   862   assume "~A" and A
   863   then show False by (rule notE)
   864 qed
   865 
   866 lemma atomize_eq [atomize]: "(x == y) == Trueprop (x = y)"
   867 proof
   868   assume "x == y"
   869   show "x = y" by (unfold `x == y`) (rule refl)
   870 next
   871   assume "x = y"
   872   then show "x == y" by (rule eq_reflection)
   873 qed
   874 
   875 lemma atomize_conj [atomize]:
   876   includes meta_conjunction_syntax
   877   shows "(A && B) == Trueprop (A & B)"
   878 proof
   879   assume conj: "A && B"
   880   show "A & B"
   881   proof (rule conjI)
   882     from conj show A by (rule conjunctionD1)
   883     from conj show B by (rule conjunctionD2)
   884   qed
   885 next
   886   assume conj: "A & B"
   887   show "A && B"
   888   proof -
   889     from conj show A ..
   890     from conj show B ..
   891   qed
   892 qed
   893 
   894 lemmas [symmetric, rulify] = atomize_all atomize_imp
   895   and [symmetric, defn] = atomize_all atomize_imp atomize_eq
   896 
   897 
   898 subsection {* Package setup *}
   899 
   900 subsubsection {* Classical Reasoner setup *}
   901 
   902 lemma thin_refl:
   903   "\<And>X. \<lbrakk> x=x; PROP W \<rbrakk> \<Longrightarrow> PROP W" .
   904 
   905 ML {*
   906 structure Hypsubst = HypsubstFun(
   907 struct
   908   structure Simplifier = Simplifier
   909   val dest_eq = HOLogic.dest_eq
   910   val dest_Trueprop = HOLogic.dest_Trueprop
   911   val dest_imp = HOLogic.dest_imp
   912   val eq_reflection = @{thm HOL.eq_reflection}
   913   val rev_eq_reflection = @{thm HOL.meta_eq_to_obj_eq}
   914   val imp_intr = @{thm HOL.impI}
   915   val rev_mp = @{thm HOL.rev_mp}
   916   val subst = @{thm HOL.subst}
   917   val sym = @{thm HOL.sym}
   918   val thin_refl = @{thm thin_refl};
   919 end);
   920 open Hypsubst;
   921 
   922 structure Classical = ClassicalFun(
   923 struct
   924   val mp = @{thm HOL.mp}
   925   val not_elim = @{thm HOL.notE}
   926   val classical = @{thm HOL.classical}
   927   val sizef = Drule.size_of_thm
   928   val hyp_subst_tacs = [Hypsubst.hyp_subst_tac]
   929 end);
   930 
   931 structure BasicClassical: BASIC_CLASSICAL = Classical; 
   932 open BasicClassical;
   933 
   934 ML_Context.value_antiq "claset"
   935   (Scan.succeed ("claset", "Classical.local_claset_of (ML_Context.the_local_context ())"));
   936 
   937 structure ResAtpset = NamedThmsFun(val name = "atp" val description = "ATP rules");
   938 *}
   939 
   940 setup {*
   941 let
   942   (*prevent substitution on bool*)
   943   fun hyp_subst_tac' i thm = if i <= Thm.nprems_of thm andalso
   944     Term.exists_Const (fn ("op =", Type (_, [T, _])) => T <> Type ("bool", []) | _ => false)
   945       (nth (Thm.prems_of thm) (i - 1)) then Hypsubst.hyp_subst_tac i thm else no_tac thm;
   946 in
   947   Hypsubst.hypsubst_setup
   948   #> ContextRules.addSWrapper (fn tac => hyp_subst_tac' ORELSE' tac)
   949   #> Classical.setup
   950   #> ResAtpset.setup
   951 end
   952 *}
   953 
   954 declare iffI [intro!]
   955   and notI [intro!]
   956   and impI [intro!]
   957   and disjCI [intro!]
   958   and conjI [intro!]
   959   and TrueI [intro!]
   960   and refl [intro!]
   961 
   962 declare iffCE [elim!]
   963   and FalseE [elim!]
   964   and impCE [elim!]
   965   and disjE [elim!]
   966   and conjE [elim!]
   967   and conjE [elim!]
   968 
   969 declare ex_ex1I [intro!]
   970   and allI [intro!]
   971   and the_equality [intro]
   972   and exI [intro]
   973 
   974 declare exE [elim!]
   975   allE [elim]
   976 
   977 ML {* val HOL_cs = @{claset} *}
   978 
   979 lemma contrapos_np: "~ Q ==> (~ P ==> Q) ==> P"
   980   apply (erule swap)
   981   apply (erule (1) meta_mp)
   982   done
   983 
   984 declare ex_ex1I [rule del, intro! 2]
   985   and ex1I [intro]
   986 
   987 lemmas [intro?] = ext
   988   and [elim?] = ex1_implies_ex
   989 
   990 (*Better then ex1E for classical reasoner: needs no quantifier duplication!*)
   991 lemma alt_ex1E [elim!]:
   992   assumes major: "\<exists>!x. P x"
   993       and prem: "\<And>x. \<lbrakk> P x; \<forall>y y'. P y \<and> P y' \<longrightarrow> y = y' \<rbrakk> \<Longrightarrow> R"
   994   shows R
   995 apply (rule ex1E [OF major])
   996 apply (rule prem)
   997 apply (tactic {* ares_tac @{thms allI} 1 *})+
   998 apply (tactic {* etac (Classical.dup_elim @{thm allE}) 1 *})
   999 apply iprover
  1000 done
  1001 
  1002 ML {*
  1003 structure Blast = BlastFun(
  1004 struct
  1005   type claset = Classical.claset
  1006   val equality_name = @{const_name "op ="}
  1007   val not_name = @{const_name Not}
  1008   val notE = @{thm HOL.notE}
  1009   val ccontr = @{thm HOL.ccontr}
  1010   val contr_tac = Classical.contr_tac
  1011   val dup_intr = Classical.dup_intr
  1012   val hyp_subst_tac = Hypsubst.blast_hyp_subst_tac
  1013   val claset = Classical.claset
  1014   val rep_cs = Classical.rep_cs
  1015   val cla_modifiers = Classical.cla_modifiers
  1016   val cla_meth' = Classical.cla_meth'
  1017 end);
  1018 val Blast_tac = Blast.Blast_tac;
  1019 val blast_tac = Blast.blast_tac;
  1020 *}
  1021 
  1022 setup Blast.setup
  1023 
  1024 
  1025 subsubsection {* Simplifier *}
  1026 
  1027 lemma eta_contract_eq: "(%s. f s) = f" ..
  1028 
  1029 lemma simp_thms:
  1030   shows not_not: "(~ ~ P) = P"
  1031   and Not_eq_iff: "((~P) = (~Q)) = (P = Q)"
  1032   and
  1033     "(P ~= Q) = (P = (~Q))"
  1034     "(P | ~P) = True"    "(~P | P) = True"
  1035     "(x = x) = True"
  1036   and not_True_eq_False: "(\<not> True) = False"
  1037   and not_False_eq_True: "(\<not> False) = True"
  1038   and
  1039     "(~P) ~= P"  "P ~= (~P)"
  1040     "(True=P) = P"
  1041   and eq_True: "(P = True) = P"
  1042   and "(False=P) = (~P)"
  1043   and eq_False: "(P = False) = (\<not> P)"
  1044   and
  1045     "(True --> P) = P"  "(False --> P) = True"
  1046     "(P --> True) = True"  "(P --> P) = True"
  1047     "(P --> False) = (~P)"  "(P --> ~P) = (~P)"
  1048     "(P & True) = P"  "(True & P) = P"
  1049     "(P & False) = False"  "(False & P) = False"
  1050     "(P & P) = P"  "(P & (P & Q)) = (P & Q)"
  1051     "(P & ~P) = False"    "(~P & P) = False"
  1052     "(P | True) = True"  "(True | P) = True"
  1053     "(P | False) = P"  "(False | P) = P"
  1054     "(P | P) = P"  "(P | (P | Q)) = (P | Q)" and
  1055     "(ALL x. P) = P"  "(EX x. P) = P"  "EX x. x=t"  "EX x. t=x"
  1056     -- {* needed for the one-point-rule quantifier simplification procs *}
  1057     -- {* essential for termination!! *} and
  1058     "!!P. (EX x. x=t & P(x)) = P(t)"
  1059     "!!P. (EX x. t=x & P(x)) = P(t)"
  1060     "!!P. (ALL x. x=t --> P(x)) = P(t)"
  1061     "!!P. (ALL x. t=x --> P(x)) = P(t)"
  1062   by (blast, blast, blast, blast, blast, iprover+)
  1063 
  1064 lemma disj_absorb: "(A | A) = A"
  1065   by blast
  1066 
  1067 lemma disj_left_absorb: "(A | (A | B)) = (A | B)"
  1068   by blast
  1069 
  1070 lemma conj_absorb: "(A & A) = A"
  1071   by blast
  1072 
  1073 lemma conj_left_absorb: "(A & (A & B)) = (A & B)"
  1074   by blast
  1075 
  1076 lemma eq_ac:
  1077   shows eq_commute: "(a=b) = (b=a)"
  1078     and eq_left_commute: "(P=(Q=R)) = (Q=(P=R))"
  1079     and eq_assoc: "((P=Q)=R) = (P=(Q=R))" by (iprover, blast+)
  1080 lemma neq_commute: "(a~=b) = (b~=a)" by iprover
  1081 
  1082 lemma conj_comms:
  1083   shows conj_commute: "(P&Q) = (Q&P)"
  1084     and conj_left_commute: "(P&(Q&R)) = (Q&(P&R))" by iprover+
  1085 lemma conj_assoc: "((P&Q)&R) = (P&(Q&R))" by iprover
  1086 
  1087 lemmas conj_ac = conj_commute conj_left_commute conj_assoc
  1088 
  1089 lemma disj_comms:
  1090   shows disj_commute: "(P|Q) = (Q|P)"
  1091     and disj_left_commute: "(P|(Q|R)) = (Q|(P|R))" by iprover+
  1092 lemma disj_assoc: "((P|Q)|R) = (P|(Q|R))" by iprover
  1093 
  1094 lemmas disj_ac = disj_commute disj_left_commute disj_assoc
  1095 
  1096 lemma conj_disj_distribL: "(P&(Q|R)) = (P&Q | P&R)" by iprover
  1097 lemma conj_disj_distribR: "((P|Q)&R) = (P&R | Q&R)" by iprover
  1098 
  1099 lemma disj_conj_distribL: "(P|(Q&R)) = ((P|Q) & (P|R))" by iprover
  1100 lemma disj_conj_distribR: "((P&Q)|R) = ((P|R) & (Q|R))" by iprover
  1101 
  1102 lemma imp_conjR: "(P --> (Q&R)) = ((P-->Q) & (P-->R))" by iprover
  1103 lemma imp_conjL: "((P&Q) -->R)  = (P --> (Q --> R))" by iprover
  1104 lemma imp_disjL: "((P|Q) --> R) = ((P-->R)&(Q-->R))" by iprover
  1105 
  1106 text {* These two are specialized, but @{text imp_disj_not1} is useful in @{text "Auth/Yahalom"}. *}
  1107 lemma imp_disj_not1: "(P --> Q | R) = (~Q --> P --> R)" by blast
  1108 lemma imp_disj_not2: "(P --> Q | R) = (~R --> P --> Q)" by blast
  1109 
  1110 lemma imp_disj1: "((P-->Q)|R) = (P--> Q|R)" by blast
  1111 lemma imp_disj2: "(Q|(P-->R)) = (P--> Q|R)" by blast
  1112 
  1113 lemma imp_cong: "(P = P') ==> (P' ==> (Q = Q')) ==> ((P --> Q) = (P' --> Q'))"
  1114   by iprover
  1115 
  1116 lemma de_Morgan_disj: "(~(P | Q)) = (~P & ~Q)" by iprover
  1117 lemma de_Morgan_conj: "(~(P & Q)) = (~P | ~Q)" by blast
  1118 lemma not_imp: "(~(P --> Q)) = (P & ~Q)" by blast
  1119 lemma not_iff: "(P~=Q) = (P = (~Q))" by blast
  1120 lemma disj_not1: "(~P | Q) = (P --> Q)" by blast
  1121 lemma disj_not2: "(P | ~Q) = (Q --> P)"  -- {* changes orientation :-( *}
  1122   by blast
  1123 lemma imp_conv_disj: "(P --> Q) = ((~P) | Q)" by blast
  1124 
  1125 lemma iff_conv_conj_imp: "(P = Q) = ((P --> Q) & (Q --> P))" by iprover
  1126 
  1127 
  1128 lemma cases_simp: "((P --> Q) & (~P --> Q)) = Q"
  1129   -- {* Avoids duplication of subgoals after @{text split_if}, when the true and false *}
  1130   -- {* cases boil down to the same thing. *}
  1131   by blast
  1132 
  1133 lemma not_all: "(~ (! x. P(x))) = (? x.~P(x))" by blast
  1134 lemma imp_all: "((! x. P x) --> Q) = (? x. P x --> Q)" by blast
  1135 lemma not_ex: "(~ (? x. P(x))) = (! x.~P(x))" by iprover
  1136 lemma imp_ex: "((? x. P x) --> Q) = (! x. P x --> Q)" by iprover
  1137 lemma all_not_ex: "(ALL x. P x) = (~ (EX x. ~ P x ))" by blast
  1138 
  1139 lemma ex_disj_distrib: "(? x. P(x) | Q(x)) = ((? x. P(x)) | (? x. Q(x)))" by iprover
  1140 lemma all_conj_distrib: "(!x. P(x) & Q(x)) = ((! x. P(x)) & (! x. Q(x)))" by iprover
  1141 
  1142 text {*
  1143   \medskip The @{text "&"} congruence rule: not included by default!
  1144   May slow rewrite proofs down by as much as 50\% *}
  1145 
  1146 lemma conj_cong:
  1147     "(P = P') ==> (P' ==> (Q = Q')) ==> ((P & Q) = (P' & Q'))"
  1148   by iprover
  1149 
  1150 lemma rev_conj_cong:
  1151     "(Q = Q') ==> (Q' ==> (P = P')) ==> ((P & Q) = (P' & Q'))"
  1152   by iprover
  1153 
  1154 text {* The @{text "|"} congruence rule: not included by default! *}
  1155 
  1156 lemma disj_cong:
  1157     "(P = P') ==> (~P' ==> (Q = Q')) ==> ((P | Q) = (P' | Q'))"
  1158   by blast
  1159 
  1160 
  1161 text {* \medskip if-then-else rules *}
  1162 
  1163 lemma if_True: "(if True then x else y) = x"
  1164   by (unfold if_def) blast
  1165 
  1166 lemma if_False: "(if False then x else y) = y"
  1167   by (unfold if_def) blast
  1168 
  1169 lemma if_P: "P ==> (if P then x else y) = x"
  1170   by (unfold if_def) blast
  1171 
  1172 lemma if_not_P: "~P ==> (if P then x else y) = y"
  1173   by (unfold if_def) blast
  1174 
  1175 lemma split_if: "P (if Q then x else y) = ((Q --> P(x)) & (~Q --> P(y)))"
  1176   apply (rule case_split [of Q])
  1177    apply (simplesubst if_P)
  1178     prefer 3 apply (simplesubst if_not_P, blast+)
  1179   done
  1180 
  1181 lemma split_if_asm: "P (if Q then x else y) = (~((Q & ~P x) | (~Q & ~P y)))"
  1182 by (simplesubst split_if, blast)
  1183 
  1184 lemmas if_splits = split_if split_if_asm
  1185 
  1186 lemma if_cancel: "(if c then x else x) = x"
  1187 by (simplesubst split_if, blast)
  1188 
  1189 lemma if_eq_cancel: "(if x = y then y else x) = x"
  1190 by (simplesubst split_if, blast)
  1191 
  1192 lemma if_bool_eq_conj: "(if P then Q else R) = ((P-->Q) & (~P-->R))"
  1193   -- {* This form is useful for expanding @{text "if"}s on the RIGHT of the @{text "==>"} symbol. *}
  1194   by (rule split_if)
  1195 
  1196 lemma if_bool_eq_disj: "(if P then Q else R) = ((P&Q) | (~P&R))"
  1197   -- {* And this form is useful for expanding @{text "if"}s on the LEFT. *}
  1198   apply (simplesubst split_if, blast)
  1199   done
  1200 
  1201 lemma Eq_TrueI: "P ==> P == True" by (unfold atomize_eq) iprover
  1202 lemma Eq_FalseI: "~P ==> P == False" by (unfold atomize_eq) iprover
  1203 
  1204 text {* \medskip let rules for simproc *}
  1205 
  1206 lemma Let_folded: "f x \<equiv> g x \<Longrightarrow>  Let x f \<equiv> Let x g"
  1207   by (unfold Let_def)
  1208 
  1209 lemma Let_unfold: "f x \<equiv> g \<Longrightarrow>  Let x f \<equiv> g"
  1210   by (unfold Let_def)
  1211 
  1212 text {*
  1213   The following copy of the implication operator is useful for
  1214   fine-tuning congruence rules.  It instructs the simplifier to simplify
  1215   its premise.
  1216 *}
  1217 
  1218 constdefs
  1219   simp_implies :: "[prop, prop] => prop"  (infixr "=simp=>" 1)
  1220   "simp_implies \<equiv> op ==>"
  1221 
  1222 lemma simp_impliesI:
  1223   assumes PQ: "(PROP P \<Longrightarrow> PROP Q)"
  1224   shows "PROP P =simp=> PROP Q"
  1225   apply (unfold simp_implies_def)
  1226   apply (rule PQ)
  1227   apply assumption
  1228   done
  1229 
  1230 lemma simp_impliesE:
  1231   assumes PQ:"PROP P =simp=> PROP Q"
  1232   and P: "PROP P"
  1233   and QR: "PROP Q \<Longrightarrow> PROP R"
  1234   shows "PROP R"
  1235   apply (rule QR)
  1236   apply (rule PQ [unfolded simp_implies_def])
  1237   apply (rule P)
  1238   done
  1239 
  1240 lemma simp_implies_cong:
  1241   assumes PP' :"PROP P == PROP P'"
  1242   and P'QQ': "PROP P' ==> (PROP Q == PROP Q')"
  1243   shows "(PROP P =simp=> PROP Q) == (PROP P' =simp=> PROP Q')"
  1244 proof (unfold simp_implies_def, rule equal_intr_rule)
  1245   assume PQ: "PROP P \<Longrightarrow> PROP Q"
  1246   and P': "PROP P'"
  1247   from PP' [symmetric] and P' have "PROP P"
  1248     by (rule equal_elim_rule1)
  1249   then have "PROP Q" by (rule PQ)
  1250   with P'QQ' [OF P'] show "PROP Q'" by (rule equal_elim_rule1)
  1251 next
  1252   assume P'Q': "PROP P' \<Longrightarrow> PROP Q'"
  1253   and P: "PROP P"
  1254   from PP' and P have P': "PROP P'" by (rule equal_elim_rule1)
  1255   then have "PROP Q'" by (rule P'Q')
  1256   with P'QQ' [OF P', symmetric] show "PROP Q"
  1257     by (rule equal_elim_rule1)
  1258 qed
  1259 
  1260 lemma uncurry:
  1261   assumes "P \<longrightarrow> Q \<longrightarrow> R"
  1262   shows "P \<and> Q \<longrightarrow> R"
  1263   using assms by blast
  1264 
  1265 lemma iff_allI:
  1266   assumes "\<And>x. P x = Q x"
  1267   shows "(\<forall>x. P x) = (\<forall>x. Q x)"
  1268   using assms by blast
  1269 
  1270 lemma iff_exI:
  1271   assumes "\<And>x. P x = Q x"
  1272   shows "(\<exists>x. P x) = (\<exists>x. Q x)"
  1273   using assms by blast
  1274 
  1275 lemma all_comm:
  1276   "(\<forall>x y. P x y) = (\<forall>y x. P x y)"
  1277   by blast
  1278 
  1279 lemma ex_comm:
  1280   "(\<exists>x y. P x y) = (\<exists>y x. P x y)"
  1281   by blast
  1282 
  1283 use "simpdata.ML"
  1284 ML {* open Simpdata *}
  1285 
  1286 setup {*
  1287   Simplifier.method_setup Splitter.split_modifiers
  1288   #> (fn thy => (change_simpset_of thy (fn _ => Simpdata.simpset_simprocs); thy))
  1289   #> Splitter.setup
  1290   #> Clasimp.setup
  1291   #> EqSubst.setup
  1292 *}
  1293 
  1294 text {* Simproc for proving @{text "(y = x) == False"} from premise @{text "~(x = y)"}: *}
  1295 
  1296 simproc_setup neq ("x = y") = {* fn _ =>
  1297 let
  1298   val neq_to_EQ_False = @{thm not_sym} RS @{thm Eq_FalseI};
  1299   fun is_neq eq lhs rhs thm =
  1300     (case Thm.prop_of thm of
  1301       _ $ (Not $ (eq' $ l' $ r')) =>
  1302         Not = HOLogic.Not andalso eq' = eq andalso
  1303         r' aconv lhs andalso l' aconv rhs
  1304     | _ => false);
  1305   fun proc ss ct =
  1306     (case Thm.term_of ct of
  1307       eq $ lhs $ rhs =>
  1308         (case find_first (is_neq eq lhs rhs) (Simplifier.prems_of_ss ss) of
  1309           SOME thm => SOME (thm RS neq_to_EQ_False)
  1310         | NONE => NONE)
  1311      | _ => NONE);
  1312 in proc end;
  1313 *}
  1314 
  1315 simproc_setup let_simp ("Let x f") = {*
  1316 let
  1317   val (f_Let_unfold, x_Let_unfold) =
  1318     let val [(_$(f$x)$_)] = prems_of @{thm Let_unfold}
  1319     in (cterm_of @{theory} f, cterm_of @{theory} x) end
  1320   val (f_Let_folded, x_Let_folded) =
  1321     let val [(_$(f$x)$_)] = prems_of @{thm Let_folded}
  1322     in (cterm_of @{theory} f, cterm_of @{theory} x) end;
  1323   val g_Let_folded =
  1324     let val [(_$_$(g$_))] = prems_of @{thm Let_folded} in cterm_of @{theory} g end;
  1325 
  1326   fun proc _ ss ct =
  1327     let
  1328       val ctxt = Simplifier.the_context ss;
  1329       val thy = ProofContext.theory_of ctxt;
  1330       val t = Thm.term_of ct;
  1331       val ([t'], ctxt') = Variable.import_terms false [t] ctxt;
  1332     in Option.map (hd o Variable.export ctxt' ctxt o single)
  1333       (case t' of Const ("Let",_) $ x $ f => (* x and f are already in normal form *)
  1334         if is_Free x orelse is_Bound x orelse is_Const x
  1335         then SOME @{thm Let_def}
  1336         else
  1337           let
  1338             val n = case f of (Abs (x,_,_)) => x | _ => "x";
  1339             val cx = cterm_of thy x;
  1340             val {T=xT,...} = rep_cterm cx;
  1341             val cf = cterm_of thy f;
  1342             val fx_g = Simplifier.rewrite ss (Thm.capply cf cx);
  1343             val (_$_$g) = prop_of fx_g;
  1344             val g' = abstract_over (x,g);
  1345           in (if (g aconv g')
  1346                then
  1347                   let
  1348                     val rl =
  1349                       cterm_instantiate [(f_Let_unfold,cf),(x_Let_unfold,cx)] @{thm Let_unfold};
  1350                   in SOME (rl OF [fx_g]) end
  1351                else if Term.betapply (f,x) aconv g then NONE (*avoid identity conversion*)
  1352                else let
  1353                      val abs_g'= Abs (n,xT,g');
  1354                      val g'x = abs_g'$x;
  1355                      val g_g'x = symmetric (beta_conversion false (cterm_of thy g'x));
  1356                      val rl = cterm_instantiate
  1357                                [(f_Let_folded,cterm_of thy f),(x_Let_folded,cx),
  1358                                 (g_Let_folded,cterm_of thy abs_g')]
  1359                                @{thm Let_folded};
  1360                    in SOME (rl OF [transitive fx_g g_g'x])
  1361                    end)
  1362           end
  1363       | _ => NONE)
  1364     end
  1365 in proc end *}
  1366 
  1367 
  1368 lemma True_implies_equals: "(True \<Longrightarrow> PROP P) \<equiv> PROP P"
  1369 proof
  1370   assume "True \<Longrightarrow> PROP P"
  1371   from this [OF TrueI] show "PROP P" .
  1372 next
  1373   assume "PROP P"
  1374   then show "PROP P" .
  1375 qed
  1376 
  1377 lemma ex_simps:
  1378   "!!P Q. (EX x. P x & Q)   = ((EX x. P x) & Q)"
  1379   "!!P Q. (EX x. P & Q x)   = (P & (EX x. Q x))"
  1380   "!!P Q. (EX x. P x | Q)   = ((EX x. P x) | Q)"
  1381   "!!P Q. (EX x. P | Q x)   = (P | (EX x. Q x))"
  1382   "!!P Q. (EX x. P x --> Q) = ((ALL x. P x) --> Q)"
  1383   "!!P Q. (EX x. P --> Q x) = (P --> (EX x. Q x))"
  1384   -- {* Miniscoping: pushing in existential quantifiers. *}
  1385   by (iprover | blast)+
  1386 
  1387 lemma all_simps:
  1388   "!!P Q. (ALL x. P x & Q)   = ((ALL x. P x) & Q)"
  1389   "!!P Q. (ALL x. P & Q x)   = (P & (ALL x. Q x))"
  1390   "!!P Q. (ALL x. P x | Q)   = ((ALL x. P x) | Q)"
  1391   "!!P Q. (ALL x. P | Q x)   = (P | (ALL x. Q x))"
  1392   "!!P Q. (ALL x. P x --> Q) = ((EX x. P x) --> Q)"
  1393   "!!P Q. (ALL x. P --> Q x) = (P --> (ALL x. Q x))"
  1394   -- {* Miniscoping: pushing in universal quantifiers. *}
  1395   by (iprover | blast)+
  1396 
  1397 lemmas [simp] =
  1398   triv_forall_equality (*prunes params*)
  1399   True_implies_equals  (*prune asms `True'*)
  1400   if_True
  1401   if_False
  1402   if_cancel
  1403   if_eq_cancel
  1404   imp_disjL
  1405   (*In general it seems wrong to add distributive laws by default: they
  1406     might cause exponential blow-up.  But imp_disjL has been in for a while
  1407     and cannot be removed without affecting existing proofs.  Moreover,
  1408     rewriting by "(P|Q --> R) = ((P-->R)&(Q-->R))" might be justified on the
  1409     grounds that it allows simplification of R in the two cases.*)
  1410   conj_assoc
  1411   disj_assoc
  1412   de_Morgan_conj
  1413   de_Morgan_disj
  1414   imp_disj1
  1415   imp_disj2
  1416   not_imp
  1417   disj_not1
  1418   not_all
  1419   not_ex
  1420   cases_simp
  1421   the_eq_trivial
  1422   the_sym_eq_trivial
  1423   ex_simps
  1424   all_simps
  1425   simp_thms
  1426 
  1427 lemmas [cong] = imp_cong simp_implies_cong
  1428 lemmas [split] = split_if
  1429 
  1430 ML {* val HOL_ss = @{simpset} *}
  1431 
  1432 text {* Simplifies x assuming c and y assuming ~c *}
  1433 lemma if_cong:
  1434   assumes "b = c"
  1435       and "c \<Longrightarrow> x = u"
  1436       and "\<not> c \<Longrightarrow> y = v"
  1437   shows "(if b then x else y) = (if c then u else v)"
  1438   unfolding if_def using assms by simp
  1439 
  1440 text {* Prevents simplification of x and y:
  1441   faster and allows the execution of functional programs. *}
  1442 lemma if_weak_cong [cong]:
  1443   assumes "b = c"
  1444   shows "(if b then x else y) = (if c then x else y)"
  1445   using assms by (rule arg_cong)
  1446 
  1447 text {* Prevents simplification of t: much faster *}
  1448 lemma let_weak_cong:
  1449   assumes "a = b"
  1450   shows "(let x = a in t x) = (let x = b in t x)"
  1451   using assms by (rule arg_cong)
  1452 
  1453 text {* To tidy up the result of a simproc.  Only the RHS will be simplified. *}
  1454 lemma eq_cong2:
  1455   assumes "u = u'"
  1456   shows "(t \<equiv> u) \<equiv> (t \<equiv> u')"
  1457   using assms by simp
  1458 
  1459 lemma if_distrib:
  1460   "f (if c then x else y) = (if c then f x else f y)"
  1461   by simp
  1462 
  1463 text {* This lemma restricts the effect of the rewrite rule u=v to the left-hand
  1464   side of an equality.  Used in @{text "{Integ,Real}/simproc.ML"} *}
  1465 lemma restrict_to_left:
  1466   assumes "x = y"
  1467   shows "(x = z) = (y = z)"
  1468   using assms by simp
  1469 
  1470 
  1471 subsubsection {* Generic cases and induction *}
  1472 
  1473 text {* Rule projections: *}
  1474 
  1475 ML {*
  1476 structure ProjectRule = ProjectRuleFun
  1477 (struct
  1478   val conjunct1 = @{thm conjunct1};
  1479   val conjunct2 = @{thm conjunct2};
  1480   val mp = @{thm mp};
  1481 end)
  1482 *}
  1483 
  1484 constdefs
  1485   induct_forall where "induct_forall P == \<forall>x. P x"
  1486   induct_implies where "induct_implies A B == A \<longrightarrow> B"
  1487   induct_equal where "induct_equal x y == x = y"
  1488   induct_conj where "induct_conj A B == A \<and> B"
  1489 
  1490 lemma induct_forall_eq: "(!!x. P x) == Trueprop (induct_forall (\<lambda>x. P x))"
  1491   by (unfold atomize_all induct_forall_def)
  1492 
  1493 lemma induct_implies_eq: "(A ==> B) == Trueprop (induct_implies A B)"
  1494   by (unfold atomize_imp induct_implies_def)
  1495 
  1496 lemma induct_equal_eq: "(x == y) == Trueprop (induct_equal x y)"
  1497   by (unfold atomize_eq induct_equal_def)
  1498 
  1499 lemma induct_conj_eq:
  1500   includes meta_conjunction_syntax
  1501   shows "(A && B) == Trueprop (induct_conj A B)"
  1502   by (unfold atomize_conj induct_conj_def)
  1503 
  1504 lemmas induct_atomize = induct_forall_eq induct_implies_eq induct_equal_eq induct_conj_eq
  1505 lemmas induct_rulify [symmetric, standard] = induct_atomize
  1506 lemmas induct_rulify_fallback =
  1507   induct_forall_def induct_implies_def induct_equal_def induct_conj_def
  1508 
  1509 
  1510 lemma induct_forall_conj: "induct_forall (\<lambda>x. induct_conj (A x) (B x)) =
  1511     induct_conj (induct_forall A) (induct_forall B)"
  1512   by (unfold induct_forall_def induct_conj_def) iprover
  1513 
  1514 lemma induct_implies_conj: "induct_implies C (induct_conj A B) =
  1515     induct_conj (induct_implies C A) (induct_implies C B)"
  1516   by (unfold induct_implies_def induct_conj_def) iprover
  1517 
  1518 lemma induct_conj_curry: "(induct_conj A B ==> PROP C) == (A ==> B ==> PROP C)"
  1519 proof
  1520   assume r: "induct_conj A B ==> PROP C" and A B
  1521   show "PROP C" by (rule r) (simp add: induct_conj_def `A` `B`)
  1522 next
  1523   assume r: "A ==> B ==> PROP C" and "induct_conj A B"
  1524   show "PROP C" by (rule r) (simp_all add: `induct_conj A B` [unfolded induct_conj_def])
  1525 qed
  1526 
  1527 lemmas induct_conj = induct_forall_conj induct_implies_conj induct_conj_curry
  1528 
  1529 hide const induct_forall induct_implies induct_equal induct_conj
  1530 
  1531 text {* Method setup. *}
  1532 
  1533 ML {*
  1534   structure InductMethod = InductMethodFun
  1535   (struct
  1536     val cases_default = @{thm case_split}
  1537     val atomize = @{thms induct_atomize}
  1538     val rulify = @{thms induct_rulify}
  1539     val rulify_fallback = @{thms induct_rulify_fallback}
  1540   end);
  1541 *}
  1542 
  1543 setup InductMethod.setup
  1544 
  1545 
  1546 
  1547 subsection {* Other simple lemmas and lemma duplicates *}
  1548 
  1549 lemma Let_0 [simp]: "Let 0 f = f 0"
  1550   unfolding Let_def ..
  1551 
  1552 lemma Let_1 [simp]: "Let 1 f = f 1"
  1553   unfolding Let_def ..
  1554 
  1555 lemma ex1_eq [iff]: "EX! x. x = t" "EX! x. t = x"
  1556   by blast+
  1557 
  1558 lemma choice_eq: "(ALL x. EX! y. P x y) = (EX! f. ALL x. P x (f x))"
  1559   apply (rule iffI)
  1560   apply (rule_tac a = "%x. THE y. P x y" in ex1I)
  1561   apply (fast dest!: theI')
  1562   apply (fast intro: ext the1_equality [symmetric])
  1563   apply (erule ex1E)
  1564   apply (rule allI)
  1565   apply (rule ex1I)
  1566   apply (erule spec)
  1567   apply (erule_tac x = "%z. if z = x then y else f z" in allE)
  1568   apply (erule impE)
  1569   apply (rule allI)
  1570   apply (rule_tac P = "xa = x" in case_split_thm)
  1571   apply (drule_tac [3] x = x in fun_cong, simp_all)
  1572   done
  1573 
  1574 lemma mk_left_commute:
  1575   fixes f (infix "\<otimes>" 60)
  1576   assumes a: "\<And>x y z. (x \<otimes> y) \<otimes> z = x \<otimes> (y \<otimes> z)" and
  1577           c: "\<And>x y. x \<otimes> y = y \<otimes> x"
  1578   shows "x \<otimes> (y \<otimes> z) = y \<otimes> (x \<otimes> z)"
  1579   by (rule trans [OF trans [OF c a] arg_cong [OF c, of "f y"]])
  1580 
  1581 lemmas eq_sym_conv = eq_commute
  1582 
  1583 lemma nnf_simps:
  1584   "(\<not>(P \<and> Q)) = (\<not> P \<or> \<not> Q)" "(\<not> (P \<or> Q)) = (\<not> P \<and> \<not>Q)" "(P \<longrightarrow> Q) = (\<not>P \<or> Q)" 
  1585   "(P = Q) = ((P \<and> Q) \<or> (\<not>P \<and> \<not> Q))" "(\<not>(P = Q)) = ((P \<and> \<not> Q) \<or> (\<not>P \<and> Q))" 
  1586   "(\<not> \<not>(P)) = P"
  1587 by blast+
  1588 
  1589 
  1590 subsection {* Basic ML bindings *}
  1591 
  1592 ML {*
  1593 val FalseE = @{thm FalseE}
  1594 val Let_def = @{thm Let_def}
  1595 val TrueI = @{thm TrueI}
  1596 val allE = @{thm allE}
  1597 val allI = @{thm allI}
  1598 val all_dupE = @{thm all_dupE}
  1599 val arg_cong = @{thm arg_cong}
  1600 val box_equals = @{thm box_equals}
  1601 val ccontr = @{thm ccontr}
  1602 val classical = @{thm classical}
  1603 val conjE = @{thm conjE}
  1604 val conjI = @{thm conjI}
  1605 val conjunct1 = @{thm conjunct1}
  1606 val conjunct2 = @{thm conjunct2}
  1607 val disjCI = @{thm disjCI}
  1608 val disjE = @{thm disjE}
  1609 val disjI1 = @{thm disjI1}
  1610 val disjI2 = @{thm disjI2}
  1611 val eq_reflection = @{thm eq_reflection}
  1612 val ex1E = @{thm ex1E}
  1613 val ex1I = @{thm ex1I}
  1614 val ex1_implies_ex = @{thm ex1_implies_ex}
  1615 val exE = @{thm exE}
  1616 val exI = @{thm exI}
  1617 val excluded_middle = @{thm excluded_middle}
  1618 val ext = @{thm ext}
  1619 val fun_cong = @{thm fun_cong}
  1620 val iffD1 = @{thm iffD1}
  1621 val iffD2 = @{thm iffD2}
  1622 val iffI = @{thm iffI}
  1623 val impE = @{thm impE}
  1624 val impI = @{thm impI}
  1625 val meta_eq_to_obj_eq = @{thm meta_eq_to_obj_eq}
  1626 val mp = @{thm mp}
  1627 val notE = @{thm notE}
  1628 val notI = @{thm notI}
  1629 val not_all = @{thm not_all}
  1630 val not_ex = @{thm not_ex}
  1631 val not_iff = @{thm not_iff}
  1632 val not_not = @{thm not_not}
  1633 val not_sym = @{thm not_sym}
  1634 val refl = @{thm refl}
  1635 val rev_mp = @{thm rev_mp}
  1636 val spec = @{thm spec}
  1637 val ssubst = @{thm ssubst}
  1638 val subst = @{thm subst}
  1639 val sym = @{thm sym}
  1640 val trans = @{thm trans}
  1641 *}
  1642 
  1643 
  1644 subsection {* Code generator basic setup -- see further @{text Code_Setup.thy} *}
  1645 
  1646 setup "CodeName.setup #> CodeTarget.setup #> Codegen.setup"
  1647 
  1648 class eq (attach "op =") = type
  1649 
  1650 code_datatype True False
  1651 
  1652 lemma [code func]:
  1653   shows "False \<and> x \<longleftrightarrow> False"
  1654     and "True \<and> x \<longleftrightarrow> x"
  1655     and "x \<and> False \<longleftrightarrow> False"
  1656     and "x \<and> True \<longleftrightarrow> x" by simp_all
  1657 
  1658 lemma [code func]:
  1659   shows "False \<or> x \<longleftrightarrow> x"
  1660     and "True \<or> x \<longleftrightarrow> True"
  1661     and "x \<or> False \<longleftrightarrow> x"
  1662     and "x \<or> True \<longleftrightarrow> True" by simp_all
  1663 
  1664 lemma [code func]:
  1665   shows "\<not> True \<longleftrightarrow> False"
  1666     and "\<not> False \<longleftrightarrow> True" by (rule HOL.simp_thms)+
  1667 
  1668 instance bool :: eq ..
  1669 
  1670 lemma [code func]:
  1671   shows "False = P \<longleftrightarrow> \<not> P"
  1672     and "True = P \<longleftrightarrow> P" 
  1673     and "P = False \<longleftrightarrow> \<not> P" 
  1674     and "P = True \<longleftrightarrow> P" by simp_all
  1675 
  1676 code_datatype Trueprop "prop"
  1677 
  1678 code_datatype "TYPE('a)"
  1679 
  1680 
  1681 subsection {* Legacy tactics and ML bindings *}
  1682 
  1683 ML {*
  1684 fun strip_tac i = REPEAT (resolve_tac [impI, allI] i);
  1685 
  1686 (* combination of (spec RS spec RS ...(j times) ... spec RS mp) *)
  1687 local
  1688   fun wrong_prem (Const ("All", _) $ (Abs (_, _, t))) = wrong_prem t
  1689     | wrong_prem (Bound _) = true
  1690     | wrong_prem _ = false;
  1691   val filter_right = filter (not o wrong_prem o HOLogic.dest_Trueprop o hd o Thm.prems_of);
  1692 in
  1693   fun smp i = funpow i (fn m => filter_right ([spec] RL m)) ([mp]);
  1694   fun smp_tac j = EVERY'[dresolve_tac (smp j), atac];
  1695 end;
  1696 
  1697 val all_conj_distrib = thm "all_conj_distrib";
  1698 val all_simps = thms "all_simps";
  1699 val atomize_not = thm "atomize_not";
  1700 val case_split = thm "case_split_thm";
  1701 val case_split_thm = thm "case_split_thm"
  1702 val cases_simp = thm "cases_simp";
  1703 val choice_eq = thm "choice_eq"
  1704 val cong = thm "cong"
  1705 val conj_comms = thms "conj_comms";
  1706 val conj_cong = thm "conj_cong";
  1707 val de_Morgan_conj = thm "de_Morgan_conj";
  1708 val de_Morgan_disj = thm "de_Morgan_disj";
  1709 val disj_assoc = thm "disj_assoc";
  1710 val disj_comms = thms "disj_comms";
  1711 val disj_cong = thm "disj_cong";
  1712 val eq_ac = thms "eq_ac";
  1713 val eq_cong2 = thm "eq_cong2"
  1714 val Eq_FalseI = thm "Eq_FalseI";
  1715 val Eq_TrueI = thm "Eq_TrueI";
  1716 val Ex1_def = thm "Ex1_def"
  1717 val ex_disj_distrib = thm "ex_disj_distrib";
  1718 val ex_simps = thms "ex_simps";
  1719 val if_cancel = thm "if_cancel";
  1720 val if_eq_cancel = thm "if_eq_cancel";
  1721 val if_False = thm "if_False";
  1722 val iff_conv_conj_imp = thm "iff_conv_conj_imp";
  1723 val iff = thm "iff"
  1724 val if_splits = thms "if_splits";
  1725 val if_True = thm "if_True";
  1726 val if_weak_cong = thm "if_weak_cong"
  1727 val imp_all = thm "imp_all";
  1728 val imp_cong = thm "imp_cong";
  1729 val imp_conjL = thm "imp_conjL";
  1730 val imp_conjR = thm "imp_conjR";
  1731 val imp_conv_disj = thm "imp_conv_disj";
  1732 val simp_implies_def = thm "simp_implies_def";
  1733 val simp_thms = thms "simp_thms";
  1734 val split_if = thm "split_if";
  1735 val the1_equality = thm "the1_equality"
  1736 val theI = thm "theI"
  1737 val theI' = thm "theI'"
  1738 val True_implies_equals = thm "True_implies_equals";
  1739 val nnf_conv = Simplifier.rewrite (HOL_basic_ss addsimps simp_thms @ @{thms "nnf_simps"})
  1740 
  1741 *}
  1742 
  1743 end