src/ZF/Tools/datatype_package.ML
changeset 12187 a1000fcf636e
parent 12183 c10cea75dd56
child 12226 0474ed2b23aa
equal deleted inserted replaced
12186:9b7026a0b0ed 12187:a1000fcf636e
   241                    flat (ListPair.map mk_con_defs
   241                    flat (ListPair.map mk_con_defs
   242                          (1 upto npart, con_ty_lists))))
   242                          (1 upto npart, con_ty_lists))))
   243              |>> add_recursor
   243              |>> add_recursor
   244              |>> Theory.parent_path
   244              |>> Theory.parent_path
   245 
   245 
       
   246   val intr_names = map #2 (flat con_ty_lists);
   246   val (thy1, ind_result) =
   247   val (thy1, ind_result) =
   247          thy0  |> Ind_Package.add_inductive_i
   248     thy0 |> Ind_Package.add_inductive_i
   248                     false (rec_tms, dom_sum) (map (fn tm => (("", tm), [])) intr_tms)
   249       false (rec_tms, dom_sum) (map Thm.no_attributes (intr_names ~~ intr_tms))
   249                            (monos, con_defs,
   250       (monos, con_defs, type_intrs @ Datatype_Arg.intrs, type_elims @ Datatype_Arg.elims);
   250                            type_intrs @ Datatype_Arg.intrs,
       
   251                            type_elims @ Datatype_Arg.elims)
       
   252 
   251 
   253   (**** Now prove the datatype theorems in this theory ****)
   252   (**** Now prove the datatype theorems in this theory ****)
   254 
   253 
   255 
   254 
   256   (*** Prove the case theorems ***)
   255   (*** Prove the case theorems ***)
   280       prove_goalw_cterm []
   279       prove_goalw_cterm []
   281         (Ind_Syntax.traceIt "next case equation = "
   280         (Ind_Syntax.traceIt "next case equation = "
   282            (cterm_of (sign_of thy1) (mk_case_eqn arg)))
   281            (cterm_of (sign_of thy1) (mk_case_eqn arg)))
   283         (case_tacsf con_def);
   282         (case_tacsf con_def);
   284 
   283 
   285   val free_iffs = con_defs RL [Ind_Syntax.def_swap_iff];
   284   val free_iffs = map standard (con_defs RL [Ind_Syntax.def_swap_iff]);
   286 
   285 
   287   val case_eqns =
   286   val case_eqns =
   288       map prove_case_eqn
   287       map prove_case_eqn
   289          (flat con_ty_lists ~~ case_args ~~ tl con_defs);
   288          (flat con_ty_lists ~~ case_args ~~ tl con_defs);
   290 
   289 
   331       end
   330       end
   332 
   331 
   333   val constructors =
   332   val constructors =
   334       map (head_of o #1 o Logic.dest_equals o #prop o rep_thm) (tl con_defs);
   333       map (head_of o #1 o Logic.dest_equals o #prop o rep_thm) (tl con_defs);
   335 
   334 
   336   val free_SEs = Ind_Syntax.mk_free_SEs free_iffs;
   335   val free_SEs = map standard (Ind_Syntax.mk_free_SEs free_iffs);
   337 
   336 
   338   val {intrs, elim, induct, mutual_induct, ...} = ind_result
   337   val {intrs, elim, induct, mutual_induct, ...} = ind_result
   339 
   338 
   340   (*Typical theorems have the form ~con1=con2, con1=con2==>False,
   339   (*Typical theorems have the form ~con1=con2, con1=con2==>False,
   341     con1(x)=con1(y) ==> x=y, con1(x)=con1(y) <-> x=y, etc.  *)
   340     con1(x)=con1(y) ==> x=y, con1(x)=con1(y) <-> x=y, etc.  *)
   370  in
   369  in
   371   (*Updating theory components: simprules and datatype info*)
   370   (*Updating theory components: simprules and datatype info*)
   372   (thy1 |> Theory.add_path big_rec_base_name
   371   (thy1 |> Theory.add_path big_rec_base_name
   373         |> (#1 o PureThy.add_thmss
   372         |> (#1 o PureThy.add_thmss
   374          [(("simps", simps), [Simplifier.simp_add_global]),
   373          [(("simps", simps), [Simplifier.simp_add_global]),
   375           (("", intrs), [Classical.safe_intro_global])])
   374           (("", intrs), [Classical.safe_intro_global]),
       
   375           (("con_defs", con_defs), []),
       
   376           (("case_eqns", case_eqns), []),
       
   377           (("recursor_eqns", recursor_eqns), []),
       
   378           (("free_iffs", free_iffs), []),
       
   379           (("free_elims", free_SEs), [])])
   376         |> DatatypesData.map (fn tab => Symtab.update ((big_rec_name, dt_info), tab))
   380         |> DatatypesData.map (fn tab => Symtab.update ((big_rec_name, dt_info), tab))
   377         |> ConstructorsData.map (fn tab => foldr Symtab.update (con_pairs, tab))
   381         |> ConstructorsData.map (fn tab => foldr Symtab.update (con_pairs, tab))
   378         |> Theory.parent_path,
   382         |> Theory.parent_path,
   379    ind_result,
   383    ind_result,
   380    {con_defs = con_defs,
   384    {con_defs = con_defs,