src/HOL/Product_Type.thy
author berghofe
Wed May 07 10:56:40 2008 +0200 (2008-05-07)
changeset 26798 a9134a089106
parent 26588 d83271bfaba5
child 26975 103dca19ef2e
permissions -rw-r--r--
split_beta is now declared as monotonicity rule, to allow bounded
quantifiers in introduction rules of inductive predicates.
     1 (*  Title:      HOL/Product_Type.thy
     2     ID:         $Id$
     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     4     Copyright   1992  University of Cambridge
     5 *)
     6 
     7 header {* Cartesian products *}
     8 
     9 theory Product_Type
    10 imports Inductive
    11 uses
    12   ("Tools/split_rule.ML")
    13   ("Tools/inductive_set_package.ML")
    14   ("Tools/inductive_realizer.ML")
    15   ("Tools/datatype_realizer.ML")
    16 begin
    17 
    18 subsection {* @{typ bool} is a datatype *}
    19 
    20 rep_datatype bool
    21   distinct True_not_False False_not_True
    22   induction bool_induct
    23 
    24 declare case_split [cases type: bool]
    25   -- "prefer plain propositional version"
    26 
    27 lemma [code func]:
    28   shows "False = P \<longleftrightarrow> \<not> P"
    29     and "True = P \<longleftrightarrow> P" 
    30     and "P = False \<longleftrightarrow> \<not> P" 
    31     and "P = True \<longleftrightarrow> P" by simp_all
    32 
    33 code_const "op = \<Colon> bool \<Rightarrow> bool \<Rightarrow> bool"
    34   (Haskell infixl 4 "==")
    35 
    36 code_instance bool :: eq
    37   (Haskell -)
    38 
    39 
    40 subsection {* Unit *}
    41 
    42 typedef unit = "{True}"
    43 proof
    44   show "True : ?unit" ..
    45 qed
    46 
    47 definition
    48   Unity :: unit    ("'(')")
    49 where
    50   "() = Abs_unit True"
    51 
    52 lemma unit_eq [noatp]: "u = ()"
    53   by (induct u) (simp add: unit_def Unity_def)
    54 
    55 text {*
    56   Simplification procedure for @{thm [source] unit_eq}.  Cannot use
    57   this rule directly --- it loops!
    58 *}
    59 
    60 ML {*
    61   val unit_eq_proc =
    62     let val unit_meta_eq = mk_meta_eq @{thm unit_eq} in
    63       Simplifier.simproc @{theory} "unit_eq" ["x::unit"]
    64       (fn _ => fn _ => fn t => if HOLogic.is_unit t then NONE else SOME unit_meta_eq)
    65     end;
    66 
    67   Addsimprocs [unit_eq_proc];
    68 *}
    69 
    70 lemma unit_induct [noatp,induct type: unit]: "P () ==> P x"
    71   by simp
    72 
    73 rep_datatype unit
    74   induction unit_induct
    75 
    76 lemma unit_all_eq1: "(!!x::unit. PROP P x) == PROP P ()"
    77   by simp
    78 
    79 lemma unit_all_eq2: "(!!x::unit. PROP P) == PROP P"
    80   by (rule triv_forall_equality)
    81 
    82 text {*
    83   This rewrite counters the effect of @{text unit_eq_proc} on @{term
    84   [source] "%u::unit. f u"}, replacing it by @{term [source]
    85   f} rather than by @{term [source] "%u. f ()"}.
    86 *}
    87 
    88 lemma unit_abs_eta_conv [simp,noatp]: "(%u::unit. f ()) = f"
    89   by (rule ext) simp
    90 
    91 
    92 text {* code generator setup *}
    93 
    94 instance unit :: eq ..
    95 
    96 lemma [code func]:
    97   "(u\<Colon>unit) = v \<longleftrightarrow> True" unfolding unit_eq [of u] unit_eq [of v] by rule+
    98 
    99 code_type unit
   100   (SML "unit")
   101   (OCaml "unit")
   102   (Haskell "()")
   103 
   104 code_instance unit :: eq
   105   (Haskell -)
   106 
   107 code_const "op = \<Colon> unit \<Rightarrow> unit \<Rightarrow> bool"
   108   (Haskell infixl 4 "==")
   109 
   110 code_const Unity
   111   (SML "()")
   112   (OCaml "()")
   113   (Haskell "()")
   114 
   115 code_reserved SML
   116   unit
   117 
   118 code_reserved OCaml
   119   unit
   120 
   121 
   122 subsection {* Pairs *}
   123 
   124 subsubsection {* Product type, basic operations and concrete syntax *}
   125 
   126 definition
   127   Pair_Rep :: "'a \<Rightarrow> 'b \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool"
   128 where
   129   "Pair_Rep a b = (\<lambda>x y. x = a \<and> y = b)"
   130 
   131 global
   132 
   133 typedef (Prod)
   134   ('a, 'b) "*"    (infixr "*" 20)
   135     = "{f. \<exists>a b. f = Pair_Rep (a\<Colon>'a) (b\<Colon>'b)}"
   136 proof
   137   fix a b show "Pair_Rep a b \<in> ?Prod"
   138     by rule+
   139 qed
   140 
   141 syntax (xsymbols)
   142   "*"      :: "[type, type] => type"         ("(_ \<times>/ _)" [21, 20] 20)
   143 syntax (HTML output)
   144   "*"      :: "[type, type] => type"         ("(_ \<times>/ _)" [21, 20] 20)
   145 
   146 consts
   147   Pair     :: "'a \<Rightarrow> 'b \<Rightarrow> 'a \<times> 'b"
   148   fst      :: "'a \<times> 'b \<Rightarrow> 'a"
   149   snd      :: "'a \<times> 'b \<Rightarrow> 'b"
   150   split    :: "('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> 'a \<times> 'b \<Rightarrow> 'c"
   151   curry    :: "('a \<times> 'b \<Rightarrow> 'c) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'c"
   152 
   153 local
   154 
   155 defs
   156   Pair_def:     "Pair a b == Abs_Prod (Pair_Rep a b)"
   157   fst_def:      "fst p == THE a. EX b. p = Pair a b"
   158   snd_def:      "snd p == THE b. EX a. p = Pair a b"
   159   split_def:    "split == (%c p. c (fst p) (snd p))"
   160   curry_def:    "curry == (%c x y. c (Pair x y))"
   161 
   162 text {*
   163   Patterns -- extends pre-defined type @{typ pttrn} used in
   164   abstractions.
   165 *}
   166 
   167 nonterminals
   168   tuple_args patterns
   169 
   170 syntax
   171   "_tuple"      :: "'a => tuple_args => 'a * 'b"        ("(1'(_,/ _'))")
   172   "_tuple_arg"  :: "'a => tuple_args"                   ("_")
   173   "_tuple_args" :: "'a => tuple_args => tuple_args"     ("_,/ _")
   174   "_pattern"    :: "[pttrn, patterns] => pttrn"         ("'(_,/ _')")
   175   ""            :: "pttrn => patterns"                  ("_")
   176   "_patterns"   :: "[pttrn, patterns] => patterns"      ("_,/ _")
   177 
   178 translations
   179   "(x, y)"       == "Pair x y"
   180   "_tuple x (_tuple_args y z)" == "_tuple x (_tuple_arg (_tuple y z))"
   181   "%(x,y,zs).b"  == "split(%x (y,zs).b)"
   182   "%(x,y).b"     == "split(%x y. b)"
   183   "_abs (Pair x y) t" => "%(x,y).t"
   184   (* The last rule accommodates tuples in `case C ... (x,y) ... => ...'
   185      The (x,y) is parsed as `Pair x y' because it is logic, not pttrn *)
   186 
   187 (* reconstructs pattern from (nested) splits, avoiding eta-contraction of body*)
   188 (* works best with enclosing "let", if "let" does not avoid eta-contraction   *)
   189 print_translation {*
   190 let fun split_tr' [Abs (x,T,t as (Abs abs))] =
   191       (* split (%x y. t) => %(x,y) t *)
   192       let val (y,t') = atomic_abs_tr' abs;
   193           val (x',t'') = atomic_abs_tr' (x,T,t');
   194     
   195       in Syntax.const "_abs" $ (Syntax.const "_pattern" $x'$y) $ t'' end
   196     | split_tr' [Abs (x,T,(s as Const ("split",_)$t))] =
   197        (* split (%x. (split (%y z. t))) => %(x,y,z). t *)
   198        let val (Const ("_abs",_)$(Const ("_pattern",_)$y$z)$t') = split_tr' [t];
   199            val (x',t'') = atomic_abs_tr' (x,T,t');
   200        in Syntax.const "_abs"$ 
   201            (Syntax.const "_pattern"$x'$(Syntax.const "_patterns"$y$z))$t'' end
   202     | split_tr' [Const ("split",_)$t] =
   203        (* split (split (%x y z. t)) => %((x,y),z). t *)   
   204        split_tr' [(split_tr' [t])] (* inner split_tr' creates next pattern *)
   205     | split_tr' [Const ("_abs",_)$x_y$(Abs abs)] =
   206        (* split (%pttrn z. t) => %(pttrn,z). t *)
   207        let val (z,t) = atomic_abs_tr' abs;
   208        in Syntax.const "_abs" $ (Syntax.const "_pattern" $x_y$z) $ t end
   209     | split_tr' _ =  raise Match;
   210 in [("split", split_tr')]
   211 end
   212 *}
   213 
   214 (* print "split f" as "\<lambda>(x,y). f x y" and "split (\<lambda>x. f x)" as "\<lambda>(x,y). f x y" *) 
   215 typed_print_translation {*
   216 let
   217   fun split_guess_names_tr' _ T [Abs (x,_,Abs _)] = raise Match
   218     | split_guess_names_tr' _ T  [Abs (x,xT,t)] =
   219         (case (head_of t) of
   220            Const ("split",_) => raise Match
   221          | _ => let 
   222                   val (_::yT::_) = binder_types (domain_type T) handle Bind => raise Match;
   223                   val (y,t') = atomic_abs_tr' ("y",yT,(incr_boundvars 1 t)$Bound 0); 
   224                   val (x',t'') = atomic_abs_tr' (x,xT,t');
   225                 in Syntax.const "_abs" $ (Syntax.const "_pattern" $x'$y) $ t'' end)
   226     | split_guess_names_tr' _ T [t] =
   227        (case (head_of t) of
   228            Const ("split",_) => raise Match 
   229          | _ => let 
   230                   val (xT::yT::_) = binder_types (domain_type T) handle Bind => raise Match;
   231                   val (y,t') = 
   232                         atomic_abs_tr' ("y",yT,(incr_boundvars 2 t)$Bound 1$Bound 0); 
   233                   val (x',t'') = atomic_abs_tr' ("x",xT,t');
   234                 in Syntax.const "_abs" $ (Syntax.const "_pattern" $x'$y) $ t'' end)
   235     | split_guess_names_tr' _ _ _ = raise Match;
   236 in [("split", split_guess_names_tr')]
   237 end 
   238 *}
   239 
   240 
   241 text {* Towards a datatype declaration *}
   242 
   243 lemma surj_pair [simp]: "EX x y. p = (x, y)"
   244   apply (unfold Pair_def)
   245   apply (rule Rep_Prod [unfolded Prod_def, THEN CollectE])
   246   apply (erule exE, erule exE, rule exI, rule exI)
   247   apply (rule Rep_Prod_inverse [symmetric, THEN trans])
   248   apply (erule arg_cong)
   249   done
   250 
   251 lemma PairE [cases type: *]:
   252   obtains x y where "p = (x, y)"
   253   using surj_pair [of p] by blast
   254 
   255 
   256 lemma prod_induct [induct type: *]: "(\<And>a b. P (a, b)) \<Longrightarrow> P x"
   257   by (cases x) simp
   258 
   259 lemma ProdI: "Pair_Rep a b \<in> Prod"
   260   unfolding Prod_def by rule+
   261 
   262 lemma Pair_Rep_inject: "Pair_Rep a b = Pair_Rep a' b' \<Longrightarrow> a = a' \<and> b = b'"
   263   unfolding Pair_Rep_def by (drule fun_cong, drule fun_cong) blast
   264 
   265 lemma inj_on_Abs_Prod: "inj_on Abs_Prod Prod"
   266   apply (rule inj_on_inverseI)
   267   apply (erule Abs_Prod_inverse)
   268   done
   269 
   270 lemma Pair_inject:
   271   assumes "(a, b) = (a', b')"
   272     and "a = a' ==> b = b' ==> R"
   273   shows R
   274   apply (insert prems [unfolded Pair_def])
   275   apply (rule inj_on_Abs_Prod [THEN inj_onD, THEN Pair_Rep_inject, THEN conjE])
   276   apply (assumption | rule ProdI)+
   277   done
   278 
   279 lemma Pair_eq [iff]: "((a, b) = (a', b')) = (a = a' & b = b')"
   280   by (blast elim!: Pair_inject)
   281 
   282 lemma fst_conv [simp, code]: "fst (a, b) = a"
   283   unfolding fst_def by blast
   284 
   285 lemma snd_conv [simp, code]: "snd (a, b) = b"
   286   unfolding snd_def by blast
   287 
   288 rep_datatype prod
   289   inject Pair_eq
   290   induction prod_induct
   291 
   292 
   293 subsubsection {* Basic rules and proof tools *}
   294 
   295 lemma fst_eqD: "fst (x, y) = a ==> x = a"
   296   by simp
   297 
   298 lemma snd_eqD: "snd (x, y) = a ==> y = a"
   299   by simp
   300 
   301 lemma pair_collapse [simp]: "(fst p, snd p) = p"
   302   by (cases p) simp
   303 
   304 lemmas surjective_pairing = pair_collapse [symmetric]
   305 
   306 lemma split_paired_all: "(!!x. PROP P x) == (!!a b. PROP P (a, b))"
   307 proof
   308   fix a b
   309   assume "!!x. PROP P x"
   310   then show "PROP P (a, b)" .
   311 next
   312   fix x
   313   assume "!!a b. PROP P (a, b)"
   314   from `PROP P (fst x, snd x)` show "PROP P x" by simp
   315 qed
   316 
   317 text {*
   318   The rule @{thm [source] split_paired_all} does not work with the
   319   Simplifier because it also affects premises in congrence rules,
   320   where this can lead to premises of the form @{text "!!a b. ... =
   321   ?P(a, b)"} which cannot be solved by reflexivity.
   322 *}
   323 
   324 lemmas split_tupled_all = split_paired_all unit_all_eq2
   325 
   326 ML {*
   327   (* replace parameters of product type by individual component parameters *)
   328   val safe_full_simp_tac = generic_simp_tac true (true, false, false);
   329   local (* filtering with exists_paired_all is an essential optimization *)
   330     fun exists_paired_all (Const ("all", _) $ Abs (_, T, t)) =
   331           can HOLogic.dest_prodT T orelse exists_paired_all t
   332       | exists_paired_all (t $ u) = exists_paired_all t orelse exists_paired_all u
   333       | exists_paired_all (Abs (_, _, t)) = exists_paired_all t
   334       | exists_paired_all _ = false;
   335     val ss = HOL_basic_ss
   336       addsimps [@{thm split_paired_all}, @{thm unit_all_eq2}, @{thm unit_abs_eta_conv}]
   337       addsimprocs [unit_eq_proc];
   338   in
   339     val split_all_tac = SUBGOAL (fn (t, i) =>
   340       if exists_paired_all t then safe_full_simp_tac ss i else no_tac);
   341     val unsafe_split_all_tac = SUBGOAL (fn (t, i) =>
   342       if exists_paired_all t then full_simp_tac ss i else no_tac);
   343     fun split_all th =
   344    if exists_paired_all (Thm.prop_of th) then full_simplify ss th else th;
   345   end;
   346 *}
   347 
   348 declaration {* fn _ =>
   349   Classical.map_cs (fn cs => cs addSbefore ("split_all_tac", split_all_tac))
   350 *}
   351 
   352 lemma split_paired_All [simp]: "(ALL x. P x) = (ALL a b. P (a, b))"
   353   -- {* @{text "[iff]"} is not a good idea because it makes @{text blast} loop *}
   354   by fast
   355 
   356 lemma split_paired_Ex [simp]: "(EX x. P x) = (EX a b. P (a, b))"
   357   by fast
   358 
   359 lemma Pair_fst_snd_eq: "s = t \<longleftrightarrow> fst s = fst t \<and> snd s = snd t"
   360   by (cases s, cases t) simp
   361 
   362 lemma prod_eqI [intro?]: "fst p = fst q \<Longrightarrow> snd p = snd q \<Longrightarrow> p = q"
   363   by (simp add: Pair_fst_snd_eq)
   364 
   365 
   366 subsubsection {* @{text split} and @{text curry} *}
   367 
   368 lemma split_conv [simp, code func]: "split f (a, b) = f a b"
   369   by (simp add: split_def)
   370 
   371 lemma curry_conv [simp, code func]: "curry f a b = f (a, b)"
   372   by (simp add: curry_def)
   373 
   374 lemmas split = split_conv  -- {* for backwards compatibility *}
   375 
   376 lemma splitI: "f a b \<Longrightarrow> split f (a, b)"
   377   by (rule split_conv [THEN iffD2])
   378 
   379 lemma splitD: "split f (a, b) \<Longrightarrow> f a b"
   380   by (rule split_conv [THEN iffD1])
   381 
   382 lemma curryI [intro!]: "f (a, b) \<Longrightarrow> curry f a b"
   383   by (simp add: curry_def)
   384 
   385 lemma curryD [dest!]: "curry f a b \<Longrightarrow> f (a, b)"
   386   by (simp add: curry_def)
   387 
   388 lemma curryE: "curry f a b \<Longrightarrow> (f (a, b) \<Longrightarrow> Q) \<Longrightarrow> Q"
   389   by (simp add: curry_def)
   390 
   391 lemma curry_split [simp]: "curry (split f) = f"
   392   by (simp add: curry_def split_def)
   393 
   394 lemma split_curry [simp]: "split (curry f) = f"
   395   by (simp add: curry_def split_def)
   396 
   397 lemma split_Pair [simp]: "(\<lambda>(x, y). (x, y)) = id"
   398   by (simp add: split_def id_def)
   399 
   400 lemma split_eta: "(\<lambda>(x, y). f (x, y)) = f"
   401   -- {* Subsumes the old @{text split_Pair} when @{term f} is the identity function. *}
   402   by (rule ext) auto
   403 
   404 lemma split_comp: "split (f \<circ> g) x = f (g (fst x)) (snd x)"
   405   by (cases x) simp
   406 
   407 lemma split_twice: "split f (split g p) = split (\<lambda>x y. split f (g x y)) p"
   408   unfolding split_def ..
   409 
   410 lemma split_paired_The: "(THE x. P x) = (THE (a, b). P (a, b))"
   411   -- {* Can't be added to simpset: loops! *}
   412   by (simp add: split_eta)
   413 
   414 lemma The_split: "The (split P) = (THE xy. P (fst xy) (snd xy))"
   415   by (simp add: split_def)
   416 
   417 lemma split_weak_cong: "p = q \<Longrightarrow> split c p = split c q"
   418   -- {* Prevents simplification of @{term c}: much faster *}
   419   by (erule arg_cong)
   420 
   421 lemma cond_split_eta: "(!!x y. f x y = g (x, y)) ==> (%(x, y). f x y) = g"
   422   by (simp add: split_eta)
   423 
   424 text {*
   425   Simplification procedure for @{thm [source] cond_split_eta}.  Using
   426   @{thm [source] split_eta} as a rewrite rule is not general enough,
   427   and using @{thm [source] cond_split_eta} directly would render some
   428   existing proofs very inefficient; similarly for @{text
   429   split_beta}.
   430 *}
   431 
   432 ML {*
   433 
   434 local
   435   val cond_split_eta_ss = HOL_basic_ss addsimps [thm "cond_split_eta"]
   436   fun  Pair_pat k 0 (Bound m) = (m = k)
   437   |    Pair_pat k i (Const ("Pair",  _) $ Bound m $ t) = i > 0 andalso
   438                         m = k+i andalso Pair_pat k (i-1) t
   439   |    Pair_pat _ _ _ = false;
   440   fun no_args k i (Abs (_, _, t)) = no_args (k+1) i t
   441   |   no_args k i (t $ u) = no_args k i t andalso no_args k i u
   442   |   no_args k i (Bound m) = m < k orelse m > k+i
   443   |   no_args _ _ _ = true;
   444   fun split_pat tp i (Abs  (_,_,t)) = if tp 0 i t then SOME (i,t) else NONE
   445   |   split_pat tp i (Const ("split", _) $ Abs (_, _, t)) = split_pat tp (i+1) t
   446   |   split_pat tp i _ = NONE;
   447   fun metaeq ss lhs rhs = mk_meta_eq (Goal.prove (Simplifier.the_context ss) [] []
   448         (HOLogic.mk_Trueprop (HOLogic.mk_eq (lhs,rhs)))
   449         (K (simp_tac (Simplifier.inherit_context ss cond_split_eta_ss) 1)));
   450 
   451   fun beta_term_pat k i (Abs (_, _, t)) = beta_term_pat (k+1) i t
   452   |   beta_term_pat k i (t $ u) = Pair_pat k i (t $ u) orelse
   453                         (beta_term_pat k i t andalso beta_term_pat k i u)
   454   |   beta_term_pat k i t = no_args k i t;
   455   fun  eta_term_pat k i (f $ arg) = no_args k i f andalso Pair_pat k i arg
   456   |    eta_term_pat _ _ _ = false;
   457   fun subst arg k i (Abs (x, T, t)) = Abs (x, T, subst arg (k+1) i t)
   458   |   subst arg k i (t $ u) = if Pair_pat k i (t $ u) then incr_boundvars k arg
   459                               else (subst arg k i t $ subst arg k i u)
   460   |   subst arg k i t = t;
   461   fun beta_proc ss (s as Const ("split", _) $ Abs (_, _, t) $ arg) =
   462         (case split_pat beta_term_pat 1 t of
   463         SOME (i,f) => SOME (metaeq ss s (subst arg 0 i f))
   464         | NONE => NONE)
   465   |   beta_proc _ _ = NONE;
   466   fun eta_proc ss (s as Const ("split", _) $ Abs (_, _, t)) =
   467         (case split_pat eta_term_pat 1 t of
   468           SOME (_,ft) => SOME (metaeq ss s (let val (f $ arg) = ft in f end))
   469         | NONE => NONE)
   470   |   eta_proc _ _ = NONE;
   471 in
   472   val split_beta_proc = Simplifier.simproc @{theory} "split_beta" ["split f z"] (K beta_proc);
   473   val split_eta_proc = Simplifier.simproc @{theory} "split_eta" ["split f"] (K eta_proc);
   474 end;
   475 
   476 Addsimprocs [split_beta_proc, split_eta_proc];
   477 *}
   478 
   479 lemma split_beta [mono]: "(%(x, y). P x y) z = P (fst z) (snd z)"
   480   by (subst surjective_pairing, rule split_conv)
   481 
   482 lemma split_split [noatp]: "R(split c p) = (ALL x y. p = (x, y) --> R(c x y))"
   483   -- {* For use with @{text split} and the Simplifier. *}
   484   by (insert surj_pair [of p], clarify, simp)
   485 
   486 text {*
   487   @{thm [source] split_split} could be declared as @{text "[split]"}
   488   done after the Splitter has been speeded up significantly;
   489   precompute the constants involved and don't do anything unless the
   490   current goal contains one of those constants.
   491 *}
   492 
   493 lemma split_split_asm [noatp]: "R (split c p) = (~(EX x y. p = (x, y) & (~R (c x y))))"
   494 by (subst split_split, simp)
   495 
   496 
   497 text {*
   498   \medskip @{term split} used as a logical connective or set former.
   499 
   500   \medskip These rules are for use with @{text blast}; could instead
   501   call @{text simp} using @{thm [source] split} as rewrite. *}
   502 
   503 lemma splitI2: "!!p. [| !!a b. p = (a, b) ==> c a b |] ==> split c p"
   504   apply (simp only: split_tupled_all)
   505   apply (simp (no_asm_simp))
   506   done
   507 
   508 lemma splitI2': "!!p. [| !!a b. (a, b) = p ==> c a b x |] ==> split c p x"
   509   apply (simp only: split_tupled_all)
   510   apply (simp (no_asm_simp))
   511   done
   512 
   513 lemma splitE: "split c p ==> (!!x y. p = (x, y) ==> c x y ==> Q) ==> Q"
   514   by (induct p) (auto simp add: split_def)
   515 
   516 lemma splitE': "split c p z ==> (!!x y. p = (x, y) ==> c x y z ==> Q) ==> Q"
   517   by (induct p) (auto simp add: split_def)
   518 
   519 lemma splitE2:
   520   "[| Q (split P z);  !!x y. [|z = (x, y); Q (P x y)|] ==> R |] ==> R"
   521 proof -
   522   assume q: "Q (split P z)"
   523   assume r: "!!x y. [|z = (x, y); Q (P x y)|] ==> R"
   524   show R
   525     apply (rule r surjective_pairing)+
   526     apply (rule split_beta [THEN subst], rule q)
   527     done
   528 qed
   529 
   530 lemma splitD': "split R (a,b) c ==> R a b c"
   531   by simp
   532 
   533 lemma mem_splitI: "z: c a b ==> z: split c (a, b)"
   534   by simp
   535 
   536 lemma mem_splitI2: "!!p. [| !!a b. p = (a, b) ==> z: c a b |] ==> z: split c p"
   537 by (simp only: split_tupled_all, simp)
   538 
   539 lemma mem_splitE:
   540   assumes major: "z: split c p"
   541     and cases: "!!x y. [| p = (x,y); z: c x y |] ==> Q"
   542   shows Q
   543   by (rule major [unfolded split_def] cases surjective_pairing)+
   544 
   545 declare mem_splitI2 [intro!] mem_splitI [intro!] splitI2' [intro!] splitI2 [intro!] splitI [intro!]
   546 declare mem_splitE [elim!] splitE' [elim!] splitE [elim!]
   547 
   548 ML {*
   549 local (* filtering with exists_p_split is an essential optimization *)
   550   fun exists_p_split (Const ("split",_) $ _ $ (Const ("Pair",_)$_$_)) = true
   551     | exists_p_split (t $ u) = exists_p_split t orelse exists_p_split u
   552     | exists_p_split (Abs (_, _, t)) = exists_p_split t
   553     | exists_p_split _ = false;
   554   val ss = HOL_basic_ss addsimps [thm "split_conv"];
   555 in
   556 val split_conv_tac = SUBGOAL (fn (t, i) =>
   557     if exists_p_split t then safe_full_simp_tac ss i else no_tac);
   558 end;
   559 *}
   560 
   561 (* This prevents applications of splitE for already splitted arguments leading
   562    to quite time-consuming computations (in particular for nested tuples) *)
   563 declaration {* fn _ =>
   564   Classical.map_cs (fn cs => cs addSbefore ("split_conv_tac", split_conv_tac))
   565 *}
   566 
   567 lemma split_eta_SetCompr [simp,noatp]: "(%u. EX x y. u = (x, y) & P (x, y)) = P"
   568   by (rule ext) fast
   569 
   570 lemma split_eta_SetCompr2 [simp,noatp]: "(%u. EX x y. u = (x, y) & P x y) = split P"
   571   by (rule ext) fast
   572 
   573 lemma split_part [simp]: "(%(a,b). P & Q a b) = (%ab. P & split Q ab)"
   574   -- {* Allows simplifications of nested splits in case of independent predicates. *}
   575   by (rule ext) blast
   576 
   577 (* Do NOT make this a simp rule as it
   578    a) only helps in special situations
   579    b) can lead to nontermination in the presence of split_def
   580 *)
   581 lemma split_comp_eq: 
   582   fixes f :: "'a => 'b => 'c" and g :: "'d => 'a"
   583   shows "(%u. f (g (fst u)) (snd u)) = (split (%x. f (g x)))"
   584   by (rule ext) auto
   585 
   586 lemma pair_imageI [intro]: "(a, b) : A ==> f a b : (%(a, b). f a b) ` A"
   587   apply (rule_tac x = "(a, b)" in image_eqI)
   588    apply auto
   589   done
   590 
   591 lemma The_split_eq [simp]: "(THE (x',y'). x = x' & y = y') = (x, y)"
   592   by blast
   593 
   594 (*
   595 the following  would be slightly more general,
   596 but cannot be used as rewrite rule:
   597 ### Cannot add premise as rewrite rule because it contains (type) unknowns:
   598 ### ?y = .x
   599 Goal "[| P y; !!x. P x ==> x = y |] ==> (@(x',y). x = x' & P y) = (x,y)"
   600 by (rtac some_equality 1)
   601 by ( Simp_tac 1)
   602 by (split_all_tac 1)
   603 by (Asm_full_simp_tac 1)
   604 qed "The_split_eq";
   605 *)
   606 
   607 text {*
   608   Setup of internal @{text split_rule}.
   609 *}
   610 
   611 definition
   612   internal_split :: "('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> 'a \<times> 'b \<Rightarrow> 'c"
   613 where
   614   "internal_split == split"
   615 
   616 lemma internal_split_conv: "internal_split c (a, b) = c a b"
   617   by (simp only: internal_split_def split_conv)
   618 
   619 hide const internal_split
   620 
   621 use "Tools/split_rule.ML"
   622 setup SplitRule.setup
   623 
   624 lemmas prod_caseI = prod.cases [THEN iffD2, standard]
   625 
   626 lemma prod_caseI2: "!!p. [| !!a b. p = (a, b) ==> c a b |] ==> prod_case c p"
   627   by auto
   628 
   629 lemma prod_caseI2': "!!p. [| !!a b. (a, b) = p ==> c a b x |] ==> prod_case c p x"
   630   by (auto simp: split_tupled_all)
   631 
   632 lemma prod_caseE: "prod_case c p ==> (!!x y. p = (x, y) ==> c x y ==> Q) ==> Q"
   633   by (induct p) auto
   634 
   635 lemma prod_caseE': "prod_case c p z ==> (!!x y. p = (x, y) ==> c x y z ==> Q) ==> Q"
   636   by (induct p) auto
   637 
   638 lemma prod_case_unfold: "prod_case = (%c p. c (fst p) (snd p))"
   639   by (simp add: expand_fun_eq)
   640 
   641 declare prod_caseI2' [intro!] prod_caseI2 [intro!] prod_caseI [intro!]
   642 declare prod_caseE' [elim!] prod_caseE [elim!]
   643 
   644 lemma prod_case_split:
   645   "prod_case = split"
   646   by (auto simp add: expand_fun_eq)
   647 
   648 lemma prod_case_beta:
   649   "prod_case f p = f (fst p) (snd p)"
   650   unfolding prod_case_split split_beta ..
   651 
   652 
   653 subsection {* Further cases/induct rules for tuples *}
   654 
   655 lemma prod_cases3 [cases type]:
   656   obtains (fields) a b c where "y = (a, b, c)"
   657   by (cases y, case_tac b) blast
   658 
   659 lemma prod_induct3 [case_names fields, induct type]:
   660     "(!!a b c. P (a, b, c)) ==> P x"
   661   by (cases x) blast
   662 
   663 lemma prod_cases4 [cases type]:
   664   obtains (fields) a b c d where "y = (a, b, c, d)"
   665   by (cases y, case_tac c) blast
   666 
   667 lemma prod_induct4 [case_names fields, induct type]:
   668     "(!!a b c d. P (a, b, c, d)) ==> P x"
   669   by (cases x) blast
   670 
   671 lemma prod_cases5 [cases type]:
   672   obtains (fields) a b c d e where "y = (a, b, c, d, e)"
   673   by (cases y, case_tac d) blast
   674 
   675 lemma prod_induct5 [case_names fields, induct type]:
   676     "(!!a b c d e. P (a, b, c, d, e)) ==> P x"
   677   by (cases x) blast
   678 
   679 lemma prod_cases6 [cases type]:
   680   obtains (fields) a b c d e f where "y = (a, b, c, d, e, f)"
   681   by (cases y, case_tac e) blast
   682 
   683 lemma prod_induct6 [case_names fields, induct type]:
   684     "(!!a b c d e f. P (a, b, c, d, e, f)) ==> P x"
   685   by (cases x) blast
   686 
   687 lemma prod_cases7 [cases type]:
   688   obtains (fields) a b c d e f g where "y = (a, b, c, d, e, f, g)"
   689   by (cases y, case_tac f) blast
   690 
   691 lemma prod_induct7 [case_names fields, induct type]:
   692     "(!!a b c d e f g. P (a, b, c, d, e, f, g)) ==> P x"
   693   by (cases x) blast
   694 
   695 
   696 subsubsection {* Derived operations *}
   697 
   698 text {*
   699   The composition-uncurry combinator.
   700 *}
   701 
   702 notation fcomp (infixl "o>" 60)
   703 
   704 definition
   705   scomp :: "('a \<Rightarrow> 'b \<times> 'c) \<Rightarrow> ('b \<Rightarrow> 'c \<Rightarrow> 'd) \<Rightarrow> 'a \<Rightarrow> 'd" (infixl "o\<rightarrow>" 60)
   706 where
   707   "f o\<rightarrow> g = (\<lambda>x. split g (f x))"
   708 
   709 lemma scomp_apply:  "(f o\<rightarrow> g) x = split g (f x)"
   710   by (simp add: scomp_def)
   711 
   712 lemma Pair_scomp: "Pair x o\<rightarrow> f = f x"
   713   by (simp add: expand_fun_eq scomp_apply)
   714 
   715 lemma scomp_Pair: "x o\<rightarrow> Pair = x"
   716   by (simp add: expand_fun_eq scomp_apply)
   717 
   718 lemma scomp_scomp: "(f o\<rightarrow> g) o\<rightarrow> h = f o\<rightarrow> (\<lambda>x. g x o\<rightarrow> h)"
   719   by (simp add: expand_fun_eq split_twice scomp_def)
   720 
   721 lemma scomp_fcomp: "(f o\<rightarrow> g) o> h = f o\<rightarrow> (\<lambda>x. g x o> h)"
   722   by (simp add: expand_fun_eq scomp_apply fcomp_def split_def)
   723 
   724 lemma fcomp_scomp: "(f o> g) o\<rightarrow> h = f o> (g o\<rightarrow> h)"
   725   by (simp add: expand_fun_eq scomp_apply fcomp_apply)
   726 
   727 no_notation fcomp (infixl "o>" 60)
   728 no_notation scomp (infixl "o\<rightarrow>" 60)
   729 
   730 
   731 text {*
   732   @{term prod_fun} --- action of the product functor upon
   733   functions.
   734 *}
   735 
   736 definition prod_fun :: "('a \<Rightarrow> 'c) \<Rightarrow> ('b \<Rightarrow> 'd) \<Rightarrow> 'a \<times> 'b \<Rightarrow> 'c \<times> 'd" where
   737   [code func del]: "prod_fun f g = (\<lambda>(x, y). (f x, g y))"
   738 
   739 lemma prod_fun [simp, code func]: "prod_fun f g (a, b) = (f a, g b)"
   740   by (simp add: prod_fun_def)
   741 
   742 lemma prod_fun_compose: "prod_fun (f1 o f2) (g1 o g2) = (prod_fun f1 g1 o prod_fun f2 g2)"
   743   by (rule ext) auto
   744 
   745 lemma prod_fun_ident [simp]: "prod_fun (%x. x) (%y. y) = (%z. z)"
   746   by (rule ext) auto
   747 
   748 lemma prod_fun_imageI [intro]: "(a, b) : r ==> (f a, g b) : prod_fun f g ` r"
   749   apply (rule image_eqI)
   750   apply (rule prod_fun [symmetric], assumption)
   751   done
   752 
   753 lemma prod_fun_imageE [elim!]:
   754   assumes major: "c: (prod_fun f g)`r"
   755     and cases: "!!x y. [| c=(f(x),g(y));  (x,y):r |] ==> P"
   756   shows P
   757   apply (rule major [THEN imageE])
   758   apply (rule_tac p = x in PairE)
   759   apply (rule cases)
   760    apply (blast intro: prod_fun)
   761   apply blast
   762   done
   763 
   764 definition
   765   apfst :: "('a \<Rightarrow> 'c) \<Rightarrow> 'a \<times> 'b \<Rightarrow> 'c \<times> 'b"
   766 where
   767   [code func del]: "apfst f = prod_fun f id"
   768 
   769 definition
   770   apsnd :: "('b \<Rightarrow> 'c) \<Rightarrow> 'a \<times> 'b \<Rightarrow> 'a \<times> 'c"
   771 where
   772   [code func del]: "apsnd f = prod_fun id f"
   773 
   774 lemma apfst_conv [simp, code]:
   775   "apfst f (x, y) = (f x, y)" 
   776   by (simp add: apfst_def)
   777 
   778 lemma upd_snd_conv [simp, code]:
   779   "apsnd f (x, y) = (x, f y)" 
   780   by (simp add: apsnd_def)
   781 
   782 
   783 text {*
   784   Disjoint union of a family of sets -- Sigma.
   785 *}
   786 
   787 definition  Sigma :: "['a set, 'a => 'b set] => ('a \<times> 'b) set" where
   788   Sigma_def: "Sigma A B == UN x:A. UN y:B x. {Pair x y}"
   789 
   790 abbreviation
   791   Times :: "['a set, 'b set] => ('a * 'b) set"
   792     (infixr "<*>" 80) where
   793   "A <*> B == Sigma A (%_. B)"
   794 
   795 notation (xsymbols)
   796   Times  (infixr "\<times>" 80)
   797 
   798 notation (HTML output)
   799   Times  (infixr "\<times>" 80)
   800 
   801 syntax
   802   "@Sigma" ::"[pttrn, 'a set, 'b set] => ('a * 'b) set" ("(3SIGMA _:_./ _)" [0, 0, 10] 10)
   803 
   804 translations
   805   "SIGMA x:A. B" == "Product_Type.Sigma A (%x. B)"
   806 
   807 lemma SigmaI [intro!]: "[| a:A;  b:B(a) |] ==> (a,b) : Sigma A B"
   808   by (unfold Sigma_def) blast
   809 
   810 lemma SigmaE [elim!]:
   811     "[| c: Sigma A B;
   812         !!x y.[| x:A;  y:B(x);  c=(x,y) |] ==> P
   813      |] ==> P"
   814   -- {* The general elimination rule. *}
   815   by (unfold Sigma_def) blast
   816 
   817 text {*
   818   Elimination of @{term "(a, b) : A \<times> B"} -- introduces no
   819   eigenvariables.
   820 *}
   821 
   822 lemma SigmaD1: "(a, b) : Sigma A B ==> a : A"
   823   by blast
   824 
   825 lemma SigmaD2: "(a, b) : Sigma A B ==> b : B a"
   826   by blast
   827 
   828 lemma SigmaE2:
   829     "[| (a, b) : Sigma A B;
   830         [| a:A;  b:B(a) |] ==> P
   831      |] ==> P"
   832   by blast
   833 
   834 lemma Sigma_cong:
   835      "\<lbrakk>A = B; !!x. x \<in> B \<Longrightarrow> C x = D x\<rbrakk>
   836       \<Longrightarrow> (SIGMA x: A. C x) = (SIGMA x: B. D x)"
   837   by auto
   838 
   839 lemma Sigma_mono: "[| A <= C; !!x. x:A ==> B x <= D x |] ==> Sigma A B <= Sigma C D"
   840   by blast
   841 
   842 lemma Sigma_empty1 [simp]: "Sigma {} B = {}"
   843   by blast
   844 
   845 lemma Sigma_empty2 [simp]: "A <*> {} = {}"
   846   by blast
   847 
   848 lemma UNIV_Times_UNIV [simp]: "UNIV <*> UNIV = UNIV"
   849   by auto
   850 
   851 lemma Compl_Times_UNIV1 [simp]: "- (UNIV <*> A) = UNIV <*> (-A)"
   852   by auto
   853 
   854 lemma Compl_Times_UNIV2 [simp]: "- (A <*> UNIV) = (-A) <*> UNIV"
   855   by auto
   856 
   857 lemma mem_Sigma_iff [iff]: "((a,b): Sigma A B) = (a:A & b:B(a))"
   858   by blast
   859 
   860 lemma Times_subset_cancel2: "x:C ==> (A <*> C <= B <*> C) = (A <= B)"
   861   by blast
   862 
   863 lemma Times_eq_cancel2: "x:C ==> (A <*> C = B <*> C) = (A = B)"
   864   by (blast elim: equalityE)
   865 
   866 lemma SetCompr_Sigma_eq:
   867     "Collect (split (%x y. P x & Q x y)) = (SIGMA x:Collect P. Collect (Q x))"
   868   by blast
   869 
   870 lemma Collect_split [simp]: "{(a,b). P a & Q b} = Collect P <*> Collect Q"
   871   by blast
   872 
   873 lemma UN_Times_distrib:
   874   "(UN (a,b):(A <*> B). E a <*> F b) = (UNION A E) <*> (UNION B F)"
   875   -- {* Suggested by Pierre Chartier *}
   876   by blast
   877 
   878 lemma split_paired_Ball_Sigma [simp,noatp]:
   879     "(ALL z: Sigma A B. P z) = (ALL x:A. ALL y: B x. P(x,y))"
   880   by blast
   881 
   882 lemma split_paired_Bex_Sigma [simp,noatp]:
   883     "(EX z: Sigma A B. P z) = (EX x:A. EX y: B x. P(x,y))"
   884   by blast
   885 
   886 lemma Sigma_Un_distrib1: "(SIGMA i:I Un J. C(i)) = (SIGMA i:I. C(i)) Un (SIGMA j:J. C(j))"
   887   by blast
   888 
   889 lemma Sigma_Un_distrib2: "(SIGMA i:I. A(i) Un B(i)) = (SIGMA i:I. A(i)) Un (SIGMA i:I. B(i))"
   890   by blast
   891 
   892 lemma Sigma_Int_distrib1: "(SIGMA i:I Int J. C(i)) = (SIGMA i:I. C(i)) Int (SIGMA j:J. C(j))"
   893   by blast
   894 
   895 lemma Sigma_Int_distrib2: "(SIGMA i:I. A(i) Int B(i)) = (SIGMA i:I. A(i)) Int (SIGMA i:I. B(i))"
   896   by blast
   897 
   898 lemma Sigma_Diff_distrib1: "(SIGMA i:I - J. C(i)) = (SIGMA i:I. C(i)) - (SIGMA j:J. C(j))"
   899   by blast
   900 
   901 lemma Sigma_Diff_distrib2: "(SIGMA i:I. A(i) - B(i)) = (SIGMA i:I. A(i)) - (SIGMA i:I. B(i))"
   902   by blast
   903 
   904 lemma Sigma_Union: "Sigma (Union X) B = (UN A:X. Sigma A B)"
   905   by blast
   906 
   907 text {*
   908   Non-dependent versions are needed to avoid the need for higher-order
   909   matching, especially when the rules are re-oriented.
   910 *}
   911 
   912 lemma Times_Un_distrib1: "(A Un B) <*> C = (A <*> C) Un (B <*> C)"
   913   by blast
   914 
   915 lemma Times_Int_distrib1: "(A Int B) <*> C = (A <*> C) Int (B <*> C)"
   916   by blast
   917 
   918 lemma Times_Diff_distrib1: "(A - B) <*> C = (A <*> C) - (B <*> C)"
   919   by blast
   920 
   921 
   922 subsubsection {* Code generator setup *}
   923 
   924 instance * :: (eq, eq) eq ..
   925 
   926 lemma [code func]:
   927   "(x1\<Colon>'a\<Colon>eq, y1\<Colon>'b\<Colon>eq) = (x2, y2) \<longleftrightarrow> x1 = x2 \<and> y1 = y2" by auto
   928 
   929 lemma split_case_cert:
   930   assumes "CASE \<equiv> split f"
   931   shows "CASE (a, b) \<equiv> f a b"
   932   using assms by simp
   933 
   934 setup {*
   935   Code.add_case @{thm split_case_cert}
   936 *}
   937 
   938 code_type *
   939   (SML infix 2 "*")
   940   (OCaml infix 2 "*")
   941   (Haskell "!((_),/ (_))")
   942 
   943 code_instance * :: eq
   944   (Haskell -)
   945 
   946 code_const "op = \<Colon> 'a\<Colon>eq \<times> 'b\<Colon>eq \<Rightarrow> 'a \<times> 'b \<Rightarrow> bool"
   947   (Haskell infixl 4 "==")
   948 
   949 code_const Pair
   950   (SML "!((_),/ (_))")
   951   (OCaml "!((_),/ (_))")
   952   (Haskell "!((_),/ (_))")
   953 
   954 code_const fst and snd
   955   (Haskell "fst" and "snd")
   956 
   957 types_code
   958   "*"     ("(_ */ _)")
   959 attach (term_of) {*
   960 fun term_of_id_42 aF aT bF bT (x, y) = HOLogic.pair_const aT bT $ aF x $ bF y;
   961 *}
   962 attach (test) {*
   963 fun gen_id_42 aG aT bG bT i =
   964   let
   965     val (x, t) = aG i;
   966     val (y, u) = bG i
   967   in ((x, y), fn () => HOLogic.pair_const aT bT $ t () $ u ()) end;
   968 *}
   969 
   970 consts_code
   971   "Pair"    ("(_,/ _)")
   972 
   973 setup {*
   974 
   975 let
   976 
   977 fun strip_abs_split 0 t = ([], t)
   978   | strip_abs_split i (Abs (s, T, t)) =
   979       let
   980         val s' = Codegen.new_name t s;
   981         val v = Free (s', T)
   982       in apfst (cons v) (strip_abs_split (i-1) (subst_bound (v, t))) end
   983   | strip_abs_split i (u as Const ("split", _) $ t) = (case strip_abs_split (i+1) t of
   984         (v :: v' :: vs, u) => (HOLogic.mk_prod (v, v') :: vs, u)
   985       | _ => ([], u))
   986   | strip_abs_split i t = ([], t);
   987 
   988 fun let_codegen thy defs gr dep thyname brack t = (case strip_comb t of
   989     (t1 as Const ("Let", _), t2 :: t3 :: ts) =>
   990     let
   991       fun dest_let (l as Const ("Let", _) $ t $ u) =
   992           (case strip_abs_split 1 u of
   993              ([p], u') => apfst (cons (p, t)) (dest_let u')
   994            | _ => ([], l))
   995         | dest_let t = ([], t);
   996       fun mk_code (gr, (l, r)) =
   997         let
   998           val (gr1, pl) = Codegen.invoke_codegen thy defs dep thyname false (gr, l);
   999           val (gr2, pr) = Codegen.invoke_codegen thy defs dep thyname false (gr1, r);
  1000         in (gr2, (pl, pr)) end
  1001     in case dest_let (t1 $ t2 $ t3) of
  1002         ([], _) => NONE
  1003       | (ps, u) =>
  1004           let
  1005             val (gr1, qs) = foldl_map mk_code (gr, ps);
  1006             val (gr2, pu) = Codegen.invoke_codegen thy defs dep thyname false (gr1, u);
  1007             val (gr3, pargs) = foldl_map
  1008               (Codegen.invoke_codegen thy defs dep thyname true) (gr2, ts)
  1009           in
  1010             SOME (gr3, Codegen.mk_app brack
  1011               (Pretty.blk (0, [Pretty.str "let ", Pretty.blk (0, List.concat
  1012                   (separate [Pretty.str ";", Pretty.brk 1] (map (fn (pl, pr) =>
  1013                     [Pretty.block [Pretty.str "val ", pl, Pretty.str " =",
  1014                        Pretty.brk 1, pr]]) qs))),
  1015                 Pretty.brk 1, Pretty.str "in ", pu,
  1016                 Pretty.brk 1, Pretty.str "end"])) pargs)
  1017           end
  1018     end
  1019   | _ => NONE);
  1020 
  1021 fun split_codegen thy defs gr dep thyname brack t = (case strip_comb t of
  1022     (t1 as Const ("split", _), t2 :: ts) =>
  1023       (case strip_abs_split 1 (t1 $ t2) of
  1024          ([p], u) =>
  1025            let
  1026              val (gr1, q) = Codegen.invoke_codegen thy defs dep thyname false (gr, p);
  1027              val (gr2, pu) = Codegen.invoke_codegen thy defs dep thyname false (gr1, u);
  1028              val (gr3, pargs) = foldl_map
  1029                (Codegen.invoke_codegen thy defs dep thyname true) (gr2, ts)
  1030            in
  1031              SOME (gr2, Codegen.mk_app brack
  1032                (Pretty.block [Pretty.str "(fn ", q, Pretty.str " =>",
  1033                  Pretty.brk 1, pu, Pretty.str ")"]) pargs)
  1034            end
  1035        | _ => NONE)
  1036   | _ => NONE);
  1037 
  1038 in
  1039 
  1040   Codegen.add_codegen "let_codegen" let_codegen
  1041   #> Codegen.add_codegen "split_codegen" split_codegen
  1042 
  1043 end
  1044 *}
  1045 
  1046 
  1047 subsection {* Legacy bindings *}
  1048 
  1049 ML {*
  1050 val Collect_split = thm "Collect_split";
  1051 val Compl_Times_UNIV1 = thm "Compl_Times_UNIV1";
  1052 val Compl_Times_UNIV2 = thm "Compl_Times_UNIV2";
  1053 val PairE = thm "PairE";
  1054 val Pair_Rep_inject = thm "Pair_Rep_inject";
  1055 val Pair_def = thm "Pair_def";
  1056 val Pair_eq = thm "Pair_eq";
  1057 val Pair_fst_snd_eq = thm "Pair_fst_snd_eq";
  1058 val ProdI = thm "ProdI";
  1059 val SetCompr_Sigma_eq = thm "SetCompr_Sigma_eq";
  1060 val SigmaD1 = thm "SigmaD1";
  1061 val SigmaD2 = thm "SigmaD2";
  1062 val SigmaE = thm "SigmaE";
  1063 val SigmaE2 = thm "SigmaE2";
  1064 val SigmaI = thm "SigmaI";
  1065 val Sigma_Diff_distrib1 = thm "Sigma_Diff_distrib1";
  1066 val Sigma_Diff_distrib2 = thm "Sigma_Diff_distrib2";
  1067 val Sigma_Int_distrib1 = thm "Sigma_Int_distrib1";
  1068 val Sigma_Int_distrib2 = thm "Sigma_Int_distrib2";
  1069 val Sigma_Un_distrib1 = thm "Sigma_Un_distrib1";
  1070 val Sigma_Un_distrib2 = thm "Sigma_Un_distrib2";
  1071 val Sigma_Union = thm "Sigma_Union";
  1072 val Sigma_def = thm "Sigma_def";
  1073 val Sigma_empty1 = thm "Sigma_empty1";
  1074 val Sigma_empty2 = thm "Sigma_empty2";
  1075 val Sigma_mono = thm "Sigma_mono";
  1076 val The_split = thm "The_split";
  1077 val The_split_eq = thm "The_split_eq";
  1078 val The_split_eq = thm "The_split_eq";
  1079 val Times_Diff_distrib1 = thm "Times_Diff_distrib1";
  1080 val Times_Int_distrib1 = thm "Times_Int_distrib1";
  1081 val Times_Un_distrib1 = thm "Times_Un_distrib1";
  1082 val Times_eq_cancel2 = thm "Times_eq_cancel2";
  1083 val Times_subset_cancel2 = thm "Times_subset_cancel2";
  1084 val UNIV_Times_UNIV = thm "UNIV_Times_UNIV";
  1085 val UN_Times_distrib = thm "UN_Times_distrib";
  1086 val Unity_def = thm "Unity_def";
  1087 val cond_split_eta = thm "cond_split_eta";
  1088 val fst_conv = thm "fst_conv";
  1089 val fst_def = thm "fst_def";
  1090 val fst_eqD = thm "fst_eqD";
  1091 val inj_on_Abs_Prod = thm "inj_on_Abs_Prod";
  1092 val mem_Sigma_iff = thm "mem_Sigma_iff";
  1093 val mem_splitE = thm "mem_splitE";
  1094 val mem_splitI = thm "mem_splitI";
  1095 val mem_splitI2 = thm "mem_splitI2";
  1096 val prod_eqI = thm "prod_eqI";
  1097 val prod_fun = thm "prod_fun";
  1098 val prod_fun_compose = thm "prod_fun_compose";
  1099 val prod_fun_def = thm "prod_fun_def";
  1100 val prod_fun_ident = thm "prod_fun_ident";
  1101 val prod_fun_imageE = thm "prod_fun_imageE";
  1102 val prod_fun_imageI = thm "prod_fun_imageI";
  1103 val prod_induct = thm "prod_induct";
  1104 val snd_conv = thm "snd_conv";
  1105 val snd_def = thm "snd_def";
  1106 val snd_eqD = thm "snd_eqD";
  1107 val split = thm "split";
  1108 val splitD = thm "splitD";
  1109 val splitD' = thm "splitD'";
  1110 val splitE = thm "splitE";
  1111 val splitE' = thm "splitE'";
  1112 val splitE2 = thm "splitE2";
  1113 val splitI = thm "splitI";
  1114 val splitI2 = thm "splitI2";
  1115 val splitI2' = thm "splitI2'";
  1116 val split_beta = thm "split_beta";
  1117 val split_conv = thm "split_conv";
  1118 val split_def = thm "split_def";
  1119 val split_eta = thm "split_eta";
  1120 val split_eta_SetCompr = thm "split_eta_SetCompr";
  1121 val split_eta_SetCompr2 = thm "split_eta_SetCompr2";
  1122 val split_paired_All = thm "split_paired_All";
  1123 val split_paired_Ball_Sigma = thm "split_paired_Ball_Sigma";
  1124 val split_paired_Bex_Sigma = thm "split_paired_Bex_Sigma";
  1125 val split_paired_Ex = thm "split_paired_Ex";
  1126 val split_paired_The = thm "split_paired_The";
  1127 val split_paired_all = thm "split_paired_all";
  1128 val split_part = thm "split_part";
  1129 val split_split = thm "split_split";
  1130 val split_split_asm = thm "split_split_asm";
  1131 val split_tupled_all = thms "split_tupled_all";
  1132 val split_weak_cong = thm "split_weak_cong";
  1133 val surj_pair = thm "surj_pair";
  1134 val surjective_pairing = thm "surjective_pairing";
  1135 val unit_abs_eta_conv = thm "unit_abs_eta_conv";
  1136 val unit_all_eq1 = thm "unit_all_eq1";
  1137 val unit_all_eq2 = thm "unit_all_eq2";
  1138 val unit_eq = thm "unit_eq";
  1139 *}
  1140 
  1141 
  1142 subsection {* Further inductive packages *}
  1143 
  1144 use "Tools/inductive_realizer.ML"
  1145 setup InductiveRealizer.setup
  1146 
  1147 use "Tools/inductive_set_package.ML"
  1148 setup InductiveSetPackage.setup
  1149 
  1150 use "Tools/datatype_realizer.ML"
  1151 setup DatatypeRealizer.setup
  1152 
  1153 end