src/HOL/Tools/datatype_rep_proofs.ML
changeset 29270 0eade173f77e
parent 28965 1de908189869
child 29389 0a49f940d729
equal deleted inserted replaced
29269:5c25a2012975 29270:0eade173f77e
     1 (*  Title:      HOL/Tools/datatype_rep_proofs.ML
     1 (*  Title:      HOL/Tools/datatype_rep_proofs.ML
     2     ID:         $Id$
       
     3     Author:     Stefan Berghofer, TU Muenchen
     2     Author:     Stefan Berghofer, TU Muenchen
     4 
     3 
     5 Definitional introduction of datatypes
     4 Definitional introduction of datatypes
     6 Proof of characteristic theorems:
     5 Proof of characteristic theorems:
     7 
     6 
     8  - injectivity of constructors
     7  - injectivity of constructors
     9  - distinctness of constructors
     8  - distinctness of constructors
    10  - induction theorem
     9  - induction theorem
    11 
       
    12 *)
    10 *)
    13 
    11 
    14 signature DATATYPE_REP_PROOFS =
    12 signature DATATYPE_REP_PROOFS =
    15 sig
    13 sig
    16   val distinctness_limit : int Config.T
    14   val distinctness_limit : int Config.T
    83     val leafTs' = get_nonrec_types descr' sorts;
    81     val leafTs' = get_nonrec_types descr' sorts;
    84     val branchTs = get_branching_types descr' sorts;
    82     val branchTs = get_branching_types descr' sorts;
    85     val branchT = if null branchTs then HOLogic.unitT
    83     val branchT = if null branchTs then HOLogic.unitT
    86       else BalancedTree.make (fn (T, U) => Type ("+", [T, U])) branchTs;
    84       else BalancedTree.make (fn (T, U) => Type ("+", [T, U])) branchTs;
    87     val arities = get_arities descr' \ 0;
    85     val arities = get_arities descr' \ 0;
    88     val unneeded_vars = hd tyvars \\ foldr add_typ_tfree_names [] (leafTs' @ branchTs);
    86     val unneeded_vars = hd tyvars \\ foldr OldTerm.add_typ_tfree_names [] (leafTs' @ branchTs);
    89     val leafTs = leafTs' @ (map (fn n => TFree (n, (the o AList.lookup (op =) sorts) n)) unneeded_vars);
    87     val leafTs = leafTs' @ (map (fn n => TFree (n, (the o AList.lookup (op =) sorts) n)) unneeded_vars);
    90     val recTs = get_rec_types descr' sorts;
    88     val recTs = get_rec_types descr' sorts;
    91     val newTs = Library.take (length (hd descr), recTs);
    89     val newTs = Library.take (length (hd descr), recTs);
    92     val oldTs = Library.drop (length (hd descr), recTs);
    90     val oldTs = Library.drop (length (hd descr), recTs);
    93     val sumT = if null leafTs then HOLogic.unitT
    91     val sumT = if null leafTs then HOLogic.unitT
   367     fun mk_funs_inv thy thm =
   365     fun mk_funs_inv thy thm =
   368       let
   366       let
   369         val prop = Thm.prop_of thm;
   367         val prop = Thm.prop_of thm;
   370         val _ $ (_ $ ((S as Const (_, Type (_, [U, _]))) $ _ )) $
   368         val _ $ (_ $ ((S as Const (_, Type (_, [U, _]))) $ _ )) $
   371           (_ $ (_ $ (r $ (a $ _)) $ _)) = Type.freeze prop;
   369           (_ $ (_ $ (r $ (a $ _)) $ _)) = Type.freeze prop;
   372         val used = add_term_tfree_names (a, []);
   370         val used = OldTerm.add_term_tfree_names (a, []);
   373 
   371 
   374         fun mk_thm i =
   372         fun mk_thm i =
   375           let
   373           let
   376             val Ts = map (TFree o rpair HOLogic.typeS)
   374             val Ts = map (TFree o rpair HOLogic.typeS)
   377               (Name.variant_list used (replicate i "'t"));
   375               (Name.variant_list used (replicate i "'t"));