src/HOL/Nominal/nominal_datatype.ML
changeset 45735 7d7d7af647a9
parent 45701 615da8b8d758
child 45740 132a3e1c0fe5
equal deleted inserted replaced
45734:1024dd30da42 45735:7d7d7af647a9
   318                let val [T1, T2] = binder_types T
   318                let val [T1, T2] = binder_types T
   319                in HOLogic.mk_eq (Const c $ pi $ Free (x, T2),
   319                in HOLogic.mk_eq (Const c $ pi $ Free (x, T2),
   320                  Const ("Nominal.perm", T) $ pi $ Free (x, T2))
   320                  Const ("Nominal.perm", T) $ pi $ Free (x, T2))
   321                end)
   321                end)
   322              (perm_names_types ~~ perm_indnames))))
   322              (perm_names_types ~~ perm_indnames))))
   323           (fn _ => EVERY [indtac induct perm_indnames 1,
   323           (fn _ => EVERY [Datatype_Aux.ind_tac induct perm_indnames 1,
   324             ALLGOALS (asm_full_simp_tac
   324             ALLGOALS (asm_full_simp_tac
   325               (global_simpset_of thy2 addsimps [perm_fun_def]))])),
   325               (global_simpset_of thy2 addsimps [perm_fun_def]))])),
   326         length new_type_names));
   326         length new_type_names));
   327 
   327 
   328     (**** prove [] \<bullet> t = t ****)
   328     (**** prove [] \<bullet> t = t ****)
   339                   (Const (s, permT --> T --> T) $
   339                   (Const (s, permT --> T --> T) $
   340                      Const ("List.list.Nil", permT) $ Free (x, T),
   340                      Const ("List.list.Nil", permT) $ Free (x, T),
   341                    Free (x, T)))
   341                    Free (x, T)))
   342                (perm_names ~~
   342                (perm_names ~~
   343                 map body_type perm_types ~~ perm_indnames)))))
   343                 map body_type perm_types ~~ perm_indnames)))))
   344           (fn _ => EVERY [indtac induct perm_indnames 1,
   344           (fn _ => EVERY [Datatype_Aux.ind_tac induct perm_indnames 1,
   345             ALLGOALS (asm_full_simp_tac (global_simpset_of thy2))])),
   345             ALLGOALS (asm_full_simp_tac (global_simpset_of thy2))])),
   346         length new_type_names))
   346         length new_type_names))
   347       end)
   347       end)
   348       atoms;
   348       atoms;
   349 
   349 
   374                          pi1 $ pi2) $ Free (x, T),
   374                          pi1 $ pi2) $ Free (x, T),
   375                        perm $ pi1 $ (perm $ pi2 $ Free (x, T)))
   375                        perm $ pi1 $ (perm $ pi2 $ Free (x, T)))
   376                     end)
   376                     end)
   377                   (perm_names ~~
   377                   (perm_names ~~
   378                    map body_type perm_types ~~ perm_indnames)))))
   378                    map body_type perm_types ~~ perm_indnames)))))
   379            (fn _ => EVERY [indtac induct perm_indnames 1,
   379            (fn _ => EVERY [Datatype_Aux.ind_tac induct perm_indnames 1,
   380               ALLGOALS (asm_full_simp_tac (global_simpset_of thy2 addsimps [pt2', pt2_ax]))]))),
   380               ALLGOALS (asm_full_simp_tac (global_simpset_of thy2 addsimps [pt2', pt2_ax]))]))),
   381          length new_type_names)
   381          length new_type_names)
   382       end) atoms;
   382       end) atoms;
   383 
   383 
   384     (**** prove pi1 ~ pi2 ==> pi1 \<bullet> t = pi2 \<bullet> t ****)
   384     (**** prove pi1 ~ pi2 ==> pi1 \<bullet> t = pi2 \<bullet> t ****)
   410                       (perm $ pi1 $ Free (x, T),
   410                       (perm $ pi1 $ Free (x, T),
   411                        perm $ pi2 $ Free (x, T))
   411                        perm $ pi2 $ Free (x, T))
   412                     end)
   412                     end)
   413                   (perm_names ~~
   413                   (perm_names ~~
   414                    map body_type perm_types ~~ perm_indnames))))))
   414                    map body_type perm_types ~~ perm_indnames))))))
   415            (fn _ => EVERY [indtac induct perm_indnames 1,
   415            (fn _ => EVERY [Datatype_Aux.ind_tac induct perm_indnames 1,
   416               ALLGOALS (asm_full_simp_tac (global_simpset_of thy2 addsimps [pt3', pt3_rev', pt3_ax]))]))),
   416               ALLGOALS (asm_full_simp_tac (global_simpset_of thy2 addsimps [pt3', pt3_rev', pt3_ax]))]))),
   417          length new_type_names)
   417          length new_type_names)
   418       end) atoms;
   418       end) atoms;
   419 
   419 
   420     (**** prove pi1 \<bullet> (pi2 \<bullet> t) = (pi1 \<bullet> pi2) \<bullet> (pi1 \<bullet> t) ****)
   420     (**** prove pi1 \<bullet> (pi2 \<bullet> t) = (pi1 \<bullet> pi2) \<bullet> (pi1 \<bullet> t) ****)
   462                   in HOLogic.mk_eq
   462                   in HOLogic.mk_eq
   463                     (perm1 $ pi1 $ (perm2 $ pi2 $ Free (x, T)),
   463                     (perm1 $ pi1 $ (perm2 $ pi2 $ Free (x, T)),
   464                      perm2 $ (perm3 $ pi1 $ pi2) $ (perm1 $ pi1 $ Free (x, T)))
   464                      perm2 $ (perm3 $ pi1 $ pi2) $ (perm1 $ pi1 $ Free (x, T)))
   465                   end)
   465                   end)
   466                 (perm_names ~~ Ts ~~ perm_indnames)))))
   466                 (perm_names ~~ Ts ~~ perm_indnames)))))
   467           (fn _ => EVERY [indtac induct perm_indnames 1,
   467           (fn _ => EVERY [Datatype_Aux.ind_tac induct perm_indnames 1,
   468              ALLGOALS (asm_full_simp_tac simps)]))
   468              ALLGOALS (asm_full_simp_tac simps)]))
   469       in
   469       in
   470         fold (fn (s, tvs) => fn thy => AxClass.prove_arity
   470         fold (fn (s, tvs) => fn thy => AxClass.prove_arity
   471             (s, map (inter_sort thy sort o snd) tvs, [cp_class])
   471             (s, map (inter_sort thy sort o snd) tvs, [cp_class])
   472             (Class.intro_classes_tac [] THEN ALLGOALS (resolve_tac thms)) thy)
   472             (Class.intro_classes_tac [] THEN ALLGOALS (resolve_tac thms)) thy)
   597                in HOLogic.mk_imp (S $ Free (x, T),
   597                in HOLogic.mk_imp (S $ Free (x, T),
   598                  S $ (Const ("Nominal.perm", permT --> T --> T) $
   598                  S $ (Const ("Nominal.perm", permT --> T --> T) $
   599                    Free ("pi", permT) $ Free (x, T)))
   599                    Free ("pi", permT) $ Free (x, T)))
   600                end) (rep_set_names'' ~~ recTs' ~~ perm_indnames')))))
   600                end) (rep_set_names'' ~~ recTs' ~~ perm_indnames')))))
   601         (fn _ => EVERY
   601         (fn _ => EVERY
   602            [indtac rep_induct [] 1,
   602            [Datatype_Aux.ind_tac rep_induct [] 1,
   603             ALLGOALS (simp_tac (global_simpset_of thy4 addsimps
   603             ALLGOALS (simp_tac (global_simpset_of thy4 addsimps
   604               (Thm.symmetric perm_fun_def :: abs_perm))),
   604               (Thm.symmetric perm_fun_def :: abs_perm))),
   605             ALLGOALS (resolve_tac rep_intrs THEN_ALL_NEW assume_tac)])),
   605             ALLGOALS (resolve_tac rep_intrs THEN_ALL_NEW assume_tac)])),
   606         length new_type_names));
   606         length new_type_names));
   607 
   607 
  1069     val dt_induct_prop = Datatype_Prop.make_ind descr' sorts;
  1069     val dt_induct_prop = Datatype_Prop.make_ind descr' sorts;
  1070     val dt_induct = Goal.prove_global thy8 []
  1070     val dt_induct = Goal.prove_global thy8 []
  1071       (Logic.strip_imp_prems dt_induct_prop) (Logic.strip_imp_concl dt_induct_prop)
  1071       (Logic.strip_imp_prems dt_induct_prop) (Logic.strip_imp_concl dt_induct_prop)
  1072       (fn {prems, ...} => EVERY
  1072       (fn {prems, ...} => EVERY
  1073         [rtac indrule_lemma' 1,
  1073         [rtac indrule_lemma' 1,
  1074          (indtac rep_induct [] THEN_ALL_NEW Object_Logic.atomize_prems_tac) 1,
  1074          (Datatype_Aux.ind_tac rep_induct [] THEN_ALL_NEW Object_Logic.atomize_prems_tac) 1,
  1075          EVERY (map (fn (prem, r) => (EVERY
  1075          EVERY (map (fn (prem, r) => (EVERY
  1076            [REPEAT (eresolve_tac Abs_inverse_thms' 1),
  1076            [REPEAT (eresolve_tac Abs_inverse_thms' 1),
  1077             simp_tac (HOL_basic_ss addsimps [Thm.symmetric r]) 1,
  1077             simp_tac (HOL_basic_ss addsimps [Thm.symmetric r]) 1,
  1078             DEPTH_SOLVE_1 (ares_tac [prem] 1 ORELSE etac allE 1)]))
  1078             DEPTH_SOLVE_1 (ares_tac [prem] 1 ORELSE etac allE 1)]))
  1079                 (prems ~~ constr_defs))]);
  1079                 (prems ~~ constr_defs))]);
  1097              (HOLogic.mk_Trueprop
  1097              (HOLogic.mk_Trueprop
  1098                (foldr1 HOLogic.mk_conj (map (fn (s, T) =>
  1098                (foldr1 HOLogic.mk_conj (map (fn (s, T) =>
  1099                  Const ("Finite_Set.finite", HOLogic.mk_setT atomT --> HOLogic.boolT) $
  1099                  Const ("Finite_Set.finite", HOLogic.mk_setT atomT --> HOLogic.boolT) $
  1100                    (Const ("Nominal.supp", T --> HOLogic.mk_setT atomT) $ Free (s, T)))
  1100                    (Const ("Nominal.supp", T --> HOLogic.mk_setT atomT) $ Free (s, T)))
  1101                    (indnames ~~ recTs)))))
  1101                    (indnames ~~ recTs)))))
  1102            (fn _ => indtac dt_induct indnames 1 THEN
  1102            (fn _ => Datatype_Aux.ind_tac dt_induct indnames 1 THEN
  1103             ALLGOALS (asm_full_simp_tac (global_simpset_of thy8 addsimps
  1103             ALLGOALS (asm_full_simp_tac (global_simpset_of thy8 addsimps
  1104               (abs_supp @ supp_atm @
  1104               (abs_supp @ supp_atm @
  1105                Global_Theory.get_thms thy8 ("fs_" ^ Long_Name.base_name atom ^ "1") @
  1105                Global_Theory.get_thms thy8 ("fs_" ^ Long_Name.base_name atom ^ "1") @
  1106                flat supp_thms))))),
  1106                flat supp_thms))))),
  1107          length new_type_names))
  1107          length new_type_names))
  1310         val ind_ss5 = HOL_basic_ss addsimps pt1_atoms;
  1310         val ind_ss5 = HOL_basic_ss addsimps pt1_atoms;
  1311         val ind_ss6 = HOL_basic_ss addsimps flat perm_simps';
  1311         val ind_ss6 = HOL_basic_ss addsimps flat perm_simps';
  1312         val th = Goal.prove context [] []
  1312         val th = Goal.prove context [] []
  1313           (augment_sort thy9 fs_cp_sort aux_ind_concl)
  1313           (augment_sort thy9 fs_cp_sort aux_ind_concl)
  1314           (fn {context = context1, ...} =>
  1314           (fn {context = context1, ...} =>
  1315              EVERY (indtac dt_induct tnames 1 ::
  1315              EVERY (Datatype_Aux.ind_tac dt_induct tnames 1 ::
  1316                maps (fn ((_, (_, _, constrs)), (_, constrs')) =>
  1316                maps (fn ((_, (_, _, constrs)), (_, constrs')) =>
  1317                  map (fn ((cname, cargs), is) =>
  1317                  map (fn ((cname, cargs), is) =>
  1318                    REPEAT (rtac allI 1) THEN
  1318                    REPEAT (rtac allI 1) THEN
  1319                    SUBPROOF (fn {prems = iprems, params, concl,
  1319                    SUBPROOF (fn {prems = iprems, params, concl,
  1320                        context = context2, ...} =>
  1320                        context = context2, ...} =>