304 |
304 |
305 val _ = warning ("length descr: " ^ string_of_int (length descr)); |
305 val _ = warning ("length descr: " ^ string_of_int (length descr)); |
306 val _ = warning ("length new_type_names: " ^ string_of_int (length new_type_names)); |
306 val _ = warning ("length new_type_names: " ^ string_of_int (length new_type_names)); |
307 |
307 |
308 val perm_indnames = Datatype_Prop.make_tnames (map body_type perm_types); |
308 val perm_indnames = Datatype_Prop.make_tnames (map body_type perm_types); |
309 val perm_fun_def = PureThy.get_thm thy2 "perm_fun_def"; |
309 val perm_fun_def = Global_Theory.get_thm thy2 "perm_fun_def"; |
310 |
310 |
311 val unfolded_perm_eq_thms = |
311 val unfolded_perm_eq_thms = |
312 if length descr = length new_type_names then [] |
312 if length descr = length new_type_names then [] |
313 else map Drule.export_without_context (List.drop (split_conj_thm |
313 else map Drule.export_without_context (List.drop (split_conj_thm |
314 (Goal.prove_global thy2 [] [] |
314 (Goal.prove_global thy2 [] [] |
349 (**** prove (pi1 @ pi2) \<bullet> t = pi1 \<bullet> (pi2 \<bullet> t) ****) |
349 (**** prove (pi1 @ pi2) \<bullet> t = pi1 \<bullet> (pi2 \<bullet> t) ****) |
350 |
350 |
351 val _ = warning "perm_append_thms"; |
351 val _ = warning "perm_append_thms"; |
352 |
352 |
353 (*FIXME: these should be looked up statically*) |
353 (*FIXME: these should be looked up statically*) |
354 val at_pt_inst = PureThy.get_thm thy2 "at_pt_inst"; |
354 val at_pt_inst = Global_Theory.get_thm thy2 "at_pt_inst"; |
355 val pt2 = PureThy.get_thm thy2 "pt2"; |
355 val pt2 = Global_Theory.get_thm thy2 "pt2"; |
356 |
356 |
357 val perm_append_thms = maps (fn a => |
357 val perm_append_thms = maps (fn a => |
358 let |
358 let |
359 val permT = mk_permT (Type (a, [])); |
359 val permT = mk_permT (Type (a, [])); |
360 val pi1 = Free ("pi1", permT); |
360 val pi1 = Free ("pi1", permT); |
361 val pi2 = Free ("pi2", permT); |
361 val pi2 = Free ("pi2", permT); |
362 val pt_inst = pt_inst_of thy2 a; |
362 val pt_inst = pt_inst_of thy2 a; |
363 val pt2' = pt_inst RS pt2; |
363 val pt2' = pt_inst RS pt2; |
364 val pt2_ax = PureThy.get_thm thy2 (Long_Name.map_base_name (fn s => "pt_" ^ s ^ "2") a); |
364 val pt2_ax = Global_Theory.get_thm thy2 (Long_Name.map_base_name (fn s => "pt_" ^ s ^ "2") a); |
365 in List.take (map Drule.export_without_context (split_conj_thm |
365 in List.take (map Drule.export_without_context (split_conj_thm |
366 (Goal.prove_global thy2 [] [] |
366 (Goal.prove_global thy2 [] [] |
367 (augment_sort thy2 [pt_class_of thy2 a] |
367 (augment_sort thy2 [pt_class_of thy2 a] |
368 (HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj |
368 (HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj |
369 (map (fn ((s, T), x) => |
369 (map (fn ((s, T), x) => |
382 |
382 |
383 (**** prove pi1 ~ pi2 ==> pi1 \<bullet> t = pi2 \<bullet> t ****) |
383 (**** prove pi1 ~ pi2 ==> pi1 \<bullet> t = pi2 \<bullet> t ****) |
384 |
384 |
385 val _ = warning "perm_eq_thms"; |
385 val _ = warning "perm_eq_thms"; |
386 |
386 |
387 val pt3 = PureThy.get_thm thy2 "pt3"; |
387 val pt3 = Global_Theory.get_thm thy2 "pt3"; |
388 val pt3_rev = PureThy.get_thm thy2 "pt3_rev"; |
388 val pt3_rev = Global_Theory.get_thm thy2 "pt3_rev"; |
389 |
389 |
390 val perm_eq_thms = maps (fn a => |
390 val perm_eq_thms = maps (fn a => |
391 let |
391 let |
392 val permT = mk_permT (Type (a, [])); |
392 val permT = mk_permT (Type (a, [])); |
393 val pi1 = Free ("pi1", permT); |
393 val pi1 = Free ("pi1", permT); |
394 val pi2 = Free ("pi2", permT); |
394 val pi2 = Free ("pi2", permT); |
395 val at_inst = at_inst_of thy2 a; |
395 val at_inst = at_inst_of thy2 a; |
396 val pt_inst = pt_inst_of thy2 a; |
396 val pt_inst = pt_inst_of thy2 a; |
397 val pt3' = pt_inst RS pt3; |
397 val pt3' = pt_inst RS pt3; |
398 val pt3_rev' = at_inst RS (pt_inst RS pt3_rev); |
398 val pt3_rev' = at_inst RS (pt_inst RS pt3_rev); |
399 val pt3_ax = PureThy.get_thm thy2 (Long_Name.map_base_name (fn s => "pt_" ^ s ^ "3") a); |
399 val pt3_ax = Global_Theory.get_thm thy2 (Long_Name.map_base_name (fn s => "pt_" ^ s ^ "3") a); |
400 in List.take (map Drule.export_without_context (split_conj_thm |
400 in List.take (map Drule.export_without_context (split_conj_thm |
401 (Goal.prove_global thy2 [] [] |
401 (Goal.prove_global thy2 [] [] |
402 (augment_sort thy2 [pt_class_of thy2 a] (Logic.mk_implies |
402 (augment_sort thy2 [pt_class_of thy2 a] (Logic.mk_implies |
403 (HOLogic.mk_Trueprop (Const ("Nominal.prm_eq", |
403 (HOLogic.mk_Trueprop (Const ("Nominal.prm_eq", |
404 permT --> permT --> HOLogic.boolT) $ pi1 $ pi2), |
404 permT --> permT --> HOLogic.boolT) $ pi1 $ pi2), |
416 length new_type_names) |
416 length new_type_names) |
417 end) atoms; |
417 end) atoms; |
418 |
418 |
419 (**** prove pi1 \<bullet> (pi2 \<bullet> t) = (pi1 \<bullet> pi2) \<bullet> (pi1 \<bullet> t) ****) |
419 (**** prove pi1 \<bullet> (pi2 \<bullet> t) = (pi1 \<bullet> pi2) \<bullet> (pi1 \<bullet> t) ****) |
420 |
420 |
421 val cp1 = PureThy.get_thm thy2 "cp1"; |
421 val cp1 = Global_Theory.get_thm thy2 "cp1"; |
422 val dj_cp = PureThy.get_thm thy2 "dj_cp"; |
422 val dj_cp = Global_Theory.get_thm thy2 "dj_cp"; |
423 val pt_perm_compose = PureThy.get_thm thy2 "pt_perm_compose"; |
423 val pt_perm_compose = Global_Theory.get_thm thy2 "pt_perm_compose"; |
424 val pt_perm_compose_rev = PureThy.get_thm thy2 "pt_perm_compose_rev"; |
424 val pt_perm_compose_rev = Global_Theory.get_thm thy2 "pt_perm_compose_rev"; |
425 val dj_perm_perm_forget = PureThy.get_thm thy2 "dj_perm_perm_forget"; |
425 val dj_perm_perm_forget = Global_Theory.get_thm thy2 "dj_perm_perm_forget"; |
426 |
426 |
427 fun composition_instance name1 name2 thy = |
427 fun composition_instance name1 name2 thy = |
428 let |
428 let |
429 val cp_class = cp_class_of thy name1 name2; |
429 val cp_class = cp_class_of thy name1 name2; |
430 val pt_class = |
430 val pt_class = |
484 resolve_tac perm_empty_thms 1, |
484 resolve_tac perm_empty_thms 1, |
485 resolve_tac perm_append_thms 1, |
485 resolve_tac perm_append_thms 1, |
486 resolve_tac perm_eq_thms 1, assume_tac 1]) thy) |
486 resolve_tac perm_eq_thms 1, assume_tac 1]) thy) |
487 (full_new_type_names' ~~ tyvars) thy |
487 (full_new_type_names' ~~ tyvars) thy |
488 end) atoms |> |
488 end) atoms |> |
489 PureThy.add_thmss |
489 Global_Theory.add_thmss |
490 [((Binding.name (space_implode "_" new_type_names ^ "_unfolded_perm_eq"), |
490 [((Binding.name (space_implode "_" new_type_names ^ "_unfolded_perm_eq"), |
491 unfolded_perm_eq_thms), [Simplifier.simp_add]), |
491 unfolded_perm_eq_thms), [Simplifier.simp_add]), |
492 ((Binding.name (space_implode "_" new_type_names ^ "_perm_empty"), |
492 ((Binding.name (space_implode "_" new_type_names ^ "_perm_empty"), |
493 perm_empty_thms), [Simplifier.simp_add]), |
493 perm_empty_thms), [Simplifier.simp_add]), |
494 ((Binding.name (space_implode "_" new_type_names ^ "_perm_append"), |
494 ((Binding.name (space_implode "_" new_type_names ^ "_perm_append"), |
576 |
576 |
577 (**** Prove that representing set is closed under permutation ****) |
577 (**** Prove that representing set is closed under permutation ****) |
578 |
578 |
579 val _ = warning "proving closure under permutation..."; |
579 val _ = warning "proving closure under permutation..."; |
580 |
580 |
581 val abs_perm = PureThy.get_thms thy4 "abs_perm"; |
581 val abs_perm = Global_Theory.get_thms thy4 "abs_perm"; |
582 |
582 |
583 val perm_indnames' = map_filter |
583 val perm_indnames' = map_filter |
584 (fn (x, (_, ("Nominal.noption", _, _))) => NONE | (x, _) => SOME x) |
584 (fn (x, (_, ("Nominal.noption", _, _))) => NONE | (x, _) => SOME x) |
585 (perm_indnames ~~ descr); |
585 (perm_indnames ~~ descr); |
586 |
586 |
624 val permT = mk_permT |
624 val permT = mk_permT |
625 (TFree (Name.variant (map fst tvs) "'a", HOLogic.typeS)); |
625 (TFree (Name.variant (map fst tvs) "'a", HOLogic.typeS)); |
626 val pi = Free ("pi", permT); |
626 val pi = Free ("pi", permT); |
627 val T = Type (Sign.intern_type thy name, map TFree tvs); |
627 val T = Type (Sign.intern_type thy name, map TFree tvs); |
628 in apfst (pair r o hd) |
628 in apfst (pair r o hd) |
629 (PureThy.add_defs_unchecked true [((Binding.name ("prm_" ^ name ^ "_def"), Logic.mk_equals |
629 (Global_Theory.add_defs_unchecked true [((Binding.name ("prm_" ^ name ^ "_def"), Logic.mk_equals |
630 (Const ("Nominal.perm", permT --> T --> T) $ pi $ Free ("x", T), |
630 (Const ("Nominal.perm", permT --> T --> T) $ pi $ Free ("x", T), |
631 Const (Sign.intern_const thy ("Abs_" ^ name), U --> T) $ |
631 Const (Sign.intern_const thy ("Abs_" ^ name), U --> T) $ |
632 (Const ("Nominal.perm", permT --> U --> U) $ pi $ |
632 (Const ("Nominal.perm", permT --> U --> U) $ pi $ |
633 (Const (Sign.intern_const thy ("Rep_" ^ name), T --> U) $ |
633 (Const (Sign.intern_const thy ("Rep_" ^ name), T --> U) $ |
634 Free ("x", T))))), [])] thy) |
634 Free ("x", T))))), [])] thy) |
660 (EVERY [Class.intro_classes_tac [], |
660 (EVERY [Class.intro_classes_tac [], |
661 rewrite_goals_tac [perm_def], |
661 rewrite_goals_tac [perm_def], |
662 asm_full_simp_tac (global_simpset_of thy addsimps [Rep_inverse]) 1, |
662 asm_full_simp_tac (global_simpset_of thy addsimps [Rep_inverse]) 1, |
663 asm_full_simp_tac (global_simpset_of thy addsimps |
663 asm_full_simp_tac (global_simpset_of thy addsimps |
664 [Rep RS perm_closed RS Abs_inverse]) 1, |
664 [Rep RS perm_closed RS Abs_inverse]) 1, |
665 asm_full_simp_tac (HOL_basic_ss addsimps [PureThy.get_thm thy |
665 asm_full_simp_tac (HOL_basic_ss addsimps [Global_Theory.get_thm thy |
666 ("pt_" ^ Long_Name.base_name atom ^ "3")]) 1]) thy |
666 ("pt_" ^ Long_Name.base_name atom ^ "3")]) 1]) thy |
667 end) |
667 end) |
668 (Abs_inverse_thms ~~ Rep_inverse_thms ~~ Rep_thms ~~ perm_defs ~~ |
668 (Abs_inverse_thms ~~ Rep_inverse_thms ~~ Rep_thms ~~ perm_defs ~~ |
669 new_type_names ~~ tyvars ~~ perm_closed_thms); |
669 new_type_names ~~ tyvars ~~ perm_closed_thms); |
670 |
670 |
799 val eqn = HOLogic.mk_Trueprop (HOLogic.mk_eq |
799 val eqn = HOLogic.mk_Trueprop (HOLogic.mk_eq |
800 (Const (rep_name, T --> T') $ lhs, rhs)); |
800 (Const (rep_name, T --> T') $ lhs, rhs)); |
801 val def_name = (Long_Name.base_name cname) ^ "_def"; |
801 val def_name = (Long_Name.base_name cname) ^ "_def"; |
802 val ([def_thm], thy') = thy |> |
802 val ([def_thm], thy') = thy |> |
803 Sign.add_consts_i [(Binding.name cname', constrT, mx)] |> |
803 Sign.add_consts_i [(Binding.name cname', constrT, mx)] |> |
804 (PureThy.add_defs false o map Thm.no_attributes) [(Binding.name def_name, def)] |
804 (Global_Theory.add_defs false o map Thm.no_attributes) [(Binding.name def_name, def)] |
805 in (thy', defs @ [def_thm], eqns @ [eqn]) end; |
805 in (thy', defs @ [def_thm], eqns @ [eqn]) end; |
806 |
806 |
807 fun dt_constr_defs ((((((_, (_, _, constrs)), |
807 fun dt_constr_defs ((((((_, (_, _, constrs)), |
808 (_, (_, _, constrs'))), tname), T), T'), constr_syntax) (thy, defs, eqns, dist_lemmas) = |
808 (_, (_, _, constrs'))), tname), T), T'), constr_syntax) (thy, defs, eqns, dist_lemmas) = |
809 let |
809 let |
933 end) (List.take (pdescr, length new_type_names) ~~ new_type_names ~~ constr_rep_thmss); |
933 end) (List.take (pdescr, length new_type_names) ~~ new_type_names ~~ constr_rep_thmss); |
934 |
934 |
935 (** prove injectivity of constructors **) |
935 (** prove injectivity of constructors **) |
936 |
936 |
937 val rep_inject_thms' = map (fn th => th RS sym) rep_inject_thms; |
937 val rep_inject_thms' = map (fn th => th RS sym) rep_inject_thms; |
938 val alpha = PureThy.get_thms thy8 "alpha"; |
938 val alpha = Global_Theory.get_thms thy8 "alpha"; |
939 val abs_fresh = PureThy.get_thms thy8 "abs_fresh"; |
939 val abs_fresh = Global_Theory.get_thms thy8 "abs_fresh"; |
940 |
940 |
941 val pt_cp_sort = |
941 val pt_cp_sort = |
942 map (pt_class_of thy8) dt_atoms @ |
942 map (pt_class_of thy8) dt_atoms @ |
943 maps (fn s => map (cp_class_of thy8 s) (remove (op =) s dt_atoms)) dt_atoms; |
943 maps (fn s => map (cp_class_of thy8 s) (remove (op =) s dt_atoms)) dt_atoms; |
944 |
944 |
1085 |
1085 |
1086 val _ = warning "proving finite support for the new datatype"; |
1086 val _ = warning "proving finite support for the new datatype"; |
1087 |
1087 |
1088 val indnames = Datatype_Prop.make_tnames recTs; |
1088 val indnames = Datatype_Prop.make_tnames recTs; |
1089 |
1089 |
1090 val abs_supp = PureThy.get_thms thy8 "abs_supp"; |
1090 val abs_supp = Global_Theory.get_thms thy8 "abs_supp"; |
1091 val supp_atm = PureThy.get_thms thy8 "supp_atm"; |
1091 val supp_atm = Global_Theory.get_thms thy8 "supp_atm"; |
1092 |
1092 |
1093 val finite_supp_thms = map (fn atom => |
1093 val finite_supp_thms = map (fn atom => |
1094 let val atomT = Type (atom, []) |
1094 let val atomT = Type (atom, []) |
1095 in map Drule.export_without_context (List.take |
1095 in map Drule.export_without_context (List.take |
1096 (split_conj_thm (Goal.prove_global thy8 [] [] |
1096 (split_conj_thm (Goal.prove_global thy8 [] [] |
1101 (Const ("Nominal.supp", T --> HOLogic.mk_setT atomT) $ Free (s, T))) |
1101 (Const ("Nominal.supp", T --> HOLogic.mk_setT atomT) $ Free (s, T))) |
1102 (indnames ~~ recTs))))) |
1102 (indnames ~~ recTs))))) |
1103 (fn _ => indtac dt_induct indnames 1 THEN |
1103 (fn _ => indtac dt_induct indnames 1 THEN |
1104 ALLGOALS (asm_full_simp_tac (global_simpset_of thy8 addsimps |
1104 ALLGOALS (asm_full_simp_tac (global_simpset_of thy8 addsimps |
1105 (abs_supp @ supp_atm @ |
1105 (abs_supp @ supp_atm @ |
1106 PureThy.get_thms thy8 ("fs_" ^ Long_Name.base_name atom ^ "1") @ |
1106 Global_Theory.get_thms thy8 ("fs_" ^ Long_Name.base_name atom ^ "1") @ |
1107 flat supp_thms))))), |
1107 flat supp_thms))))), |
1108 length new_type_names)) |
1108 length new_type_names)) |
1109 end) atoms; |
1109 end) atoms; |
1110 |
1110 |
1111 val simp_atts = replicate (length new_type_names) [Simplifier.simp_add]; |
1111 val simp_atts = replicate (length new_type_names) [Simplifier.simp_add]; |
1115 |
1115 |
1116 val simp_eqvt_atts = replicate (length new_type_names) [Simplifier.simp_add, NominalThmDecls.eqvt_add]; |
1116 val simp_eqvt_atts = replicate (length new_type_names) [Simplifier.simp_add, NominalThmDecls.eqvt_add]; |
1117 |
1117 |
1118 val (_, thy9) = thy8 |> |
1118 val (_, thy9) = thy8 |> |
1119 Sign.add_path big_name |> |
1119 Sign.add_path big_name |> |
1120 PureThy.add_thms [((Binding.name "induct", dt_induct), [case_names_induct])] ||>> |
1120 Global_Theory.add_thms [((Binding.name "induct", dt_induct), [case_names_induct])] ||>> |
1121 PureThy.add_thmss [((Binding.name "inducts", projections dt_induct), [case_names_induct])] ||> |
1121 Global_Theory.add_thmss [((Binding.name "inducts", projections dt_induct), [case_names_induct])] ||> |
1122 Sign.parent_path ||>> |
1122 Sign.parent_path ||>> |
1123 Datatype_Aux.store_thmss_atts "distinct" new_type_names simp_atts distinct_thms ||>> |
1123 Datatype_Aux.store_thmss_atts "distinct" new_type_names simp_atts distinct_thms ||>> |
1124 Datatype_Aux.store_thmss "constr_rep" new_type_names constr_rep_thmss ||>> |
1124 Datatype_Aux.store_thmss "constr_rep" new_type_names constr_rep_thmss ||>> |
1125 Datatype_Aux.store_thmss_atts "perm" new_type_names simp_eqvt_atts perm_simps' ||>> |
1125 Datatype_Aux.store_thmss_atts "perm" new_type_names simp_eqvt_atts perm_simps' ||>> |
1126 Datatype_Aux.store_thmss "inject" new_type_names inject_thms ||>> |
1126 Datatype_Aux.store_thmss "inject" new_type_names inject_thms ||>> |
1233 val fin_set_supp = map (fn s => |
1233 val fin_set_supp = map (fn s => |
1234 at_inst_of thy9 s RS at_fin_set_supp) dt_atoms; |
1234 at_inst_of thy9 s RS at_fin_set_supp) dt_atoms; |
1235 val fin_set_fresh = map (fn s => |
1235 val fin_set_fresh = map (fn s => |
1236 at_inst_of thy9 s RS at_fin_set_fresh) dt_atoms; |
1236 at_inst_of thy9 s RS at_fin_set_fresh) dt_atoms; |
1237 val pt1_atoms = map (fn Type (s, _) => |
1237 val pt1_atoms = map (fn Type (s, _) => |
1238 PureThy.get_thm thy9 ("pt_" ^ Long_Name.base_name s ^ "1")) dt_atomTs; |
1238 Global_Theory.get_thm thy9 ("pt_" ^ Long_Name.base_name s ^ "1")) dt_atomTs; |
1239 val pt2_atoms = map (fn Type (s, _) => |
1239 val pt2_atoms = map (fn Type (s, _) => |
1240 PureThy.get_thm thy9 ("pt_" ^ Long_Name.base_name s ^ "2") RS sym) dt_atomTs; |
1240 Global_Theory.get_thm thy9 ("pt_" ^ Long_Name.base_name s ^ "2") RS sym) dt_atomTs; |
1241 val exists_fresh' = PureThy.get_thms thy9 "exists_fresh'"; |
1241 val exists_fresh' = Global_Theory.get_thms thy9 "exists_fresh'"; |
1242 val fs_atoms = PureThy.get_thms thy9 "fin_supp"; |
1242 val fs_atoms = Global_Theory.get_thms thy9 "fin_supp"; |
1243 val abs_supp = PureThy.get_thms thy9 "abs_supp"; |
1243 val abs_supp = Global_Theory.get_thms thy9 "abs_supp"; |
1244 val perm_fresh_fresh = PureThy.get_thms thy9 "perm_fresh_fresh"; |
1244 val perm_fresh_fresh = Global_Theory.get_thms thy9 "perm_fresh_fresh"; |
1245 val calc_atm = PureThy.get_thms thy9 "calc_atm"; |
1245 val calc_atm = Global_Theory.get_thms thy9 "calc_atm"; |
1246 val fresh_atm = PureThy.get_thms thy9 "fresh_atm"; |
1246 val fresh_atm = Global_Theory.get_thms thy9 "fresh_atm"; |
1247 val fresh_left = PureThy.get_thms thy9 "fresh_left"; |
1247 val fresh_left = Global_Theory.get_thms thy9 "fresh_left"; |
1248 val perm_swap = PureThy.get_thms thy9 "perm_swap"; |
1248 val perm_swap = Global_Theory.get_thms thy9 "perm_swap"; |
1249 |
1249 |
1250 fun obtain_fresh_name' ths ts T (freshs1, freshs2, ctxt) = |
1250 fun obtain_fresh_name' ths ts T (freshs1, freshs2, ctxt) = |
1251 let |
1251 let |
1252 val p = foldr1 HOLogic.mk_prod (ts @ freshs1); |
1252 val p = foldr1 HOLogic.mk_prod (ts @ freshs1); |
1253 val ex = Goal.prove ctxt [] [] (HOLogic.mk_Trueprop |
1253 val ex = Goal.prove ctxt [] [] (HOLogic.mk_Trueprop |
1406 REPEAT ((resolve_tac prems THEN_ALL_NEW |
1406 REPEAT ((resolve_tac prems THEN_ALL_NEW |
1407 (etac @{thm meta_spec} ORELSE' full_simp_tac (HOL_basic_ss addsimps [fresh_def]))) 1)]) |
1407 (etac @{thm meta_spec} ORELSE' full_simp_tac (HOL_basic_ss addsimps [fresh_def]))) 1)]) |
1408 |
1408 |
1409 val (_, thy10) = thy9 |> |
1409 val (_, thy10) = thy9 |> |
1410 Sign.add_path big_name |> |
1410 Sign.add_path big_name |> |
1411 PureThy.add_thms [((Binding.name "strong_induct'", induct_aux), [])] ||>> |
1411 Global_Theory.add_thms [((Binding.name "strong_induct'", induct_aux), [])] ||>> |
1412 PureThy.add_thms [((Binding.name "strong_induct", induct), [case_names_induct])] ||>> |
1412 Global_Theory.add_thms [((Binding.name "strong_induct", induct), [case_names_induct])] ||>> |
1413 PureThy.add_thmss [((Binding.name "strong_inducts", projections induct), [case_names_induct])]; |
1413 Global_Theory.add_thmss [((Binding.name "strong_inducts", projections induct), [case_names_induct])]; |
1414 |
1414 |
1415 (**** recursion combinator ****) |
1415 (**** recursion combinator ****) |
1416 |
1416 |
1417 val _ = warning "defining recursion combinator ..."; |
1417 val _ = warning "defining recursion combinator ..."; |
1418 |
1418 |
1515 {quiet_mode = #quiet config, verbose = false, alt_name = Binding.name big_rec_name, |
1515 {quiet_mode = #quiet config, verbose = false, alt_name = Binding.name big_rec_name, |
1516 coind = false, no_elim = false, no_ind = false, skip_mono = true, fork_mono = false} |
1516 coind = false, no_elim = false, no_ind = false, skip_mono = true, fork_mono = false} |
1517 (map (fn (s, T) => ((Binding.name s, T), NoSyn)) (rec_set_names' ~~ rec_set_Ts)) |
1517 (map (fn (s, T) => ((Binding.name s, T), NoSyn)) (rec_set_names' ~~ rec_set_Ts)) |
1518 (map dest_Free rec_fns) |
1518 (map dest_Free rec_fns) |
1519 (map (fn x => (Attrib.empty_binding, x)) rec_intr_ts) [] |
1519 (map (fn x => (Attrib.empty_binding, x)) rec_intr_ts) [] |
1520 ||> PureThy.hide_fact true (Long_Name.append (Sign.full_bname thy10 big_rec_name) "induct") |
1520 ||> Global_Theory.hide_fact true (Long_Name.append (Sign.full_bname thy10 big_rec_name) "induct") |
1521 ||> Sign.restore_naming thy10; |
1521 ||> Sign.restore_naming thy10; |
1522 |
1522 |
1523 (** equivariance **) |
1523 (** equivariance **) |
1524 |
1524 |
1525 val fresh_bij = PureThy.get_thms thy11 "fresh_bij"; |
1525 val fresh_bij = Global_Theory.get_thms thy11 "fresh_bij"; |
1526 val perm_bij = PureThy.get_thms thy11 "perm_bij"; |
1526 val perm_bij = Global_Theory.get_thms thy11 "perm_bij"; |
1527 |
1527 |
1528 val (rec_equiv_thms, rec_equiv_thms') = ListPair.unzip (map (fn aT => |
1528 val (rec_equiv_thms, rec_equiv_thms') = ListPair.unzip (map (fn aT => |
1529 let |
1529 let |
1530 val permT = mk_permT aT; |
1530 val permT = mk_permT aT; |
1531 val pi = Free ("pi", permT); |
1531 val pi = Free ("pi", permT); |
1563 (** finite support **) |
1563 (** finite support **) |
1564 |
1564 |
1565 val rec_fin_supp_thms = map (fn aT => |
1565 val rec_fin_supp_thms = map (fn aT => |
1566 let |
1566 let |
1567 val name = Long_Name.base_name (fst (dest_Type aT)); |
1567 val name = Long_Name.base_name (fst (dest_Type aT)); |
1568 val fs_name = PureThy.get_thm thy11 ("fs_" ^ name ^ "1"); |
1568 val fs_name = Global_Theory.get_thm thy11 ("fs_" ^ name ^ "1"); |
1569 val aset = HOLogic.mk_setT aT; |
1569 val aset = HOLogic.mk_setT aT; |
1570 val finite = Const ("Finite_Set.finite", aset --> HOLogic.boolT); |
1570 val finite = Const ("Finite_Set.finite", aset --> HOLogic.boolT); |
1571 val fins = map (fn (f, T) => HOLogic.mk_Trueprop |
1571 val fins = map (fn (f, T) => HOLogic.mk_Trueprop |
1572 (finite $ (Const ("Nominal.supp", T --> aset) $ f))) |
1572 (finite $ (Const ("Nominal.supp", T --> aset) $ f))) |
1573 (rec_fns ~~ rec_fn_Ts) |
1573 (rec_fns ~~ rec_fn_Ts) |
1602 val rec_fns' = map (augment_sort thy11 fs_cp_sort) rec_fns; |
1602 val rec_fns' = map (augment_sort thy11 fs_cp_sort) rec_fns; |
1603 |
1603 |
1604 val rec_fresh_thms = map (fn ((aT, eqvt_ths), finite_prems) => |
1604 val rec_fresh_thms = map (fn ((aT, eqvt_ths), finite_prems) => |
1605 let |
1605 let |
1606 val name = Long_Name.base_name (fst (dest_Type aT)); |
1606 val name = Long_Name.base_name (fst (dest_Type aT)); |
1607 val fs_name = PureThy.get_thm thy11 ("fs_" ^ name ^ "1"); |
1607 val fs_name = Global_Theory.get_thm thy11 ("fs_" ^ name ^ "1"); |
1608 val a = Free ("a", aT); |
1608 val a = Free ("a", aT); |
1609 val freshs = map (fn (f, fT) => HOLogic.mk_Trueprop |
1609 val freshs = map (fn (f, fT) => HOLogic.mk_Trueprop |
1610 (fresh_const aT fT $ a $ f)) (rec_fns ~~ rec_fn_Ts) |
1610 (fresh_const aT fT $ a $ f)) (rec_fns ~~ rec_fn_Ts) |
1611 in |
1611 in |
1612 map (fn (((T, U), R), eqvt_th) => |
1612 map (fn (((T, U), R), eqvt_th) => |
2016 val (reccomb_defs, thy12) = |
2016 val (reccomb_defs, thy12) = |
2017 thy11 |
2017 thy11 |
2018 |> Sign.add_consts_i (map (fn ((name, T), T') => |
2018 |> Sign.add_consts_i (map (fn ((name, T), T') => |
2019 (Binding.name (Long_Name.base_name name), rec_fn_Ts @ [T] ---> T', NoSyn)) |
2019 (Binding.name (Long_Name.base_name name), rec_fn_Ts @ [T] ---> T', NoSyn)) |
2020 (reccomb_names ~~ recTs ~~ rec_result_Ts)) |
2020 (reccomb_names ~~ recTs ~~ rec_result_Ts)) |
2021 |> (PureThy.add_defs false o map Thm.no_attributes) (map (fn ((((name, comb), set), T), T') => |
2021 |> (Global_Theory.add_defs false o map Thm.no_attributes) (map (fn ((((name, comb), set), T), T') => |
2022 (Binding.name (Long_Name.base_name name ^ "_def"), Logic.mk_equals (comb, absfree ("x", T, |
2022 (Binding.name (Long_Name.base_name name ^ "_def"), Logic.mk_equals (comb, absfree ("x", T, |
2023 Const (@{const_name The}, (T' --> HOLogic.boolT) --> T') $ absfree ("y", T', |
2023 Const (@{const_name The}, (T' --> HOLogic.boolT) --> T') $ absfree ("y", T', |
2024 set $ Free ("x", T) $ Free ("y", T')))))) |
2024 set $ Free ("x", T) $ Free ("y", T')))))) |
2025 (reccomb_names ~~ reccombs ~~ rec_sets ~~ recTs ~~ rec_result_Ts)); |
2025 (reccomb_names ~~ reccombs ~~ rec_sets ~~ recTs ~~ rec_result_Ts)); |
2026 |
2026 |
2053 val dt_infos = map_index (make_dt_info pdescr sorts induct reccomb_names rec_thms) |
2053 val dt_infos = map_index (make_dt_info pdescr sorts induct reccomb_names rec_thms) |
2054 (descr1 ~~ distinct_thms ~~ inject_thms); |
2054 (descr1 ~~ distinct_thms ~~ inject_thms); |
2055 |
2055 |
2056 (* FIXME: theorems are stored in database for testing only *) |
2056 (* FIXME: theorems are stored in database for testing only *) |
2057 val (_, thy13) = thy12 |> |
2057 val (_, thy13) = thy12 |> |
2058 PureThy.add_thmss |
2058 Global_Theory.add_thmss |
2059 [((Binding.name "rec_equiv", flat rec_equiv_thms), []), |
2059 [((Binding.name "rec_equiv", flat rec_equiv_thms), []), |
2060 ((Binding.name "rec_equiv'", flat rec_equiv_thms'), []), |
2060 ((Binding.name "rec_equiv'", flat rec_equiv_thms'), []), |
2061 ((Binding.name "rec_fin_supp", flat rec_fin_supp_thms), []), |
2061 ((Binding.name "rec_fin_supp", flat rec_fin_supp_thms), []), |
2062 ((Binding.name "rec_fresh", flat rec_fresh_thms), []), |
2062 ((Binding.name "rec_fresh", flat rec_fresh_thms), []), |
2063 ((Binding.name "rec_unique", map Drule.export_without_context rec_unique_thms), []), |
2063 ((Binding.name "rec_unique", map Drule.export_without_context rec_unique_thms), []), |