@@ -603,7 +603,7 @@ fun create_tvsubst_of_mrsbnf qualify fp_res mrsbnf rec_mrbnf vvsubst_ctor map_pe
603603 val ((((fs, rhos), hs), x), _) = lthy
604604 |> mk_Frees " f" (map ((fn a => a --> a) o HOLogic.dest_setT o body_type o fastype_of) (BMV_Monad_Def.leader BMV_Monad_Def.RVrs_of_bmv_monad bmv))
605605 ||>> mk_Frees " \< rho>" (map fastype_of (BMV_Monad_Def.leader BMV_Monad_Def.Injs_of_bmv_monad bmv))
606- ||>> mk_Frees " h" (replicate 2 (#T quot --> #T quot))
606+ ||>> mk_Frees " h" (replicate nrecs (#T quot --> #T quot))
607607 ||>> apfst hd o mk_Frees " x" [domain_type (fastype_of (#ctor quot))];
608608
609609 val prems = flat (BMV_Monad_Def.mk_small_prems_of_bmv_monad bmv
@@ -671,8 +671,11 @@ fun create_tvsubst_of_mrsbnf qualify fp_res mrsbnf rec_mrbnf vvsubst_ctor map_pe
671671
672672 val rho_prems = Proof_Context.get_thms lthy " f_prems" ;
673673
674- val avoiding_sets = map (foldl1 mk_Un o map_filter I) (transpose IImsuppss);
674+ val avoiding_sets = map2 (fn free =>
675+ the_default (mk_bot free) o try (foldl1 mk_Un) o map_filter I
676+ ) frees (transpose (filter_out null IImsuppss));
675677
678+ val _ = @{print} " 3"
676679 val Uctor =
677680 let
678681 val ctor = #ctor quot;
@@ -855,9 +858,9 @@ fun create_tvsubst_of_mrsbnf qualify fp_res mrsbnf rec_mrbnf vvsubst_ctor map_pe
855858 ],
856859 REPEAT_DETERM o rtac ctxt @{thm Un_mono'},
857860 SELECT_GOAL (Local_Defs.unfold0_tac ctxt (no_reflexive (#set_Vrs mrsbnf_axioms))),
858- EqSubst.eqsubst_tac ctxt [0 ] (#Vrs_Sbs bmv_axioms),
861+ EqSubst.eqsubst_tac ctxt [0 ] (#Sb_Inj bmv_axioms :: # Vrs_Sbs bmv_axioms),
859862 REPEAT_DETERM o resolve_tac ctxt (@{thms supp_id_bound} @ rho_prems),
860- K (Local_Defs.unfold0_tac ctxt @{thms image_id}),
863+ K (Local_Defs.unfold0_tac ctxt @{thms image_id id_apply }),
861864 rtac ctxt @{thm Un_upper1} ORELSE' EVERY' [
862865 rtac ctxt @{thm subsetI},
863866 etac ctxt @{thm UN_E},
@@ -893,14 +896,15 @@ fun create_tvsubst_of_mrsbnf qualify fp_res mrsbnf rec_mrbnf vvsubst_ctor map_pe
893896 rtac ctxt @{thm UN_mono[OF subset_refl]},
894897 resolve_tac ctxt prems,
895898 SELECT_GOAL (Local_Defs.unfold0_tac ctxt @{thms prod.collapse}),
896- eresolve_tac ctxt @{thms UnI1 UnI2}
899+ eresolve_tac ctxt @{thms UnI1 UnI2} ORELSE' assume_tac ctxt
897900 ]
898901 ]) ctxt
899902 ])), Position.no_range), NONE ) state;
900903
901904 val (tvsubst, lthy) = mk_def_t true Binding.empty I (Binding.name_of tvsubst_b) 0
902905 (hd (MRBNF_Recursor.get_RECs true " tvsubst" lthy)) lthy;
903906
907+ val _ = @{print} " 4"
904908 val tvsubst_not_isInj =
905909 let
906910 val x = Free (" x" , domain_type (fastype_of (#ctor quot)));
@@ -1143,6 +1147,7 @@ fun create_tvsubst_of_mrsbnf qualify fp_res mrsbnf rec_mrbnf vvsubst_ctor map_pe
11431147 | _ => error " only works for datatypes"
11441148 val fresh_induct = #fresh_induct fp_thms;
11451149
1150+ (* needs to account for vars that are not injections on RHS *)
11461151 val FVars_tvsubsts = map (fn FVars =>
11471152 let
11481153 val t = Free (" t" , domain_type (fastype_of FVars));
@@ -1159,6 +1164,7 @@ fun create_tvsubst_of_mrsbnf qualify fp_res mrsbnf rec_mrbnf vvsubst_ctor map_pe
11591164 FVars $ (Term.list_comb (fst tvsubst, map_filter I rhos) $ t),
11601165 foldl1 mk_Un rhss
11611166 );
1167+ val _ = @{print} (Thm.cterm_of lthy goal)
11621168 in Goal.prove_sorry lthy (names (map_filter I rhos @ [t])) rho_prems' goal (fn {context=ctxt, prems} => EVERY1 [
11631169 DETERM o rtac ctxt (infer_instantiate' ctxt (map (SOME o Thm.cterm_of ctxt) avoiding_sets) fresh_induct),
11641170 REPEAT_DETERM_N nvars o SELECT_GOAL (REPEAT_DETERM (FIRST1 [
@@ -1184,25 +1190,42 @@ fun create_tvsubst_of_mrsbnf qualify fp_res mrsbnf rec_mrbnf vvsubst_ctor map_pe
11841190 EqSubst.eqsubst_tac ctxt [0 ] (#Vrs_Sbs bmv_axioms),
11851191 REPEAT_DETERM o resolve_tac ctxt (@{thms supp_id_bound} @ prems)
11861192 ],
1187- K (Local_Defs.unfold0_tac ctxt (@{thms image_id UN_Un} @ #Vrs_Map (the (BMV_Monad_Def.leader BMV_Monad_Def.params_of_bmv_monad bmv)))),
1193+ K (Local_Defs.unfold0_tac ctxt (@{thms image_id UN_Un id_apply}
1194+ @ #Vrs_Map (the (BMV_Monad_Def.leader BMV_Monad_Def.params_of_bmv_monad bmv))
1195+ @ [#Sb_Inj bmv_axioms]
1196+ )),
1197+ K (print_tac ctxt " 1" ),
11881198 rtac ctxt (mk_Un_cong (nrecs + 1 ) (length rhss)),
1189- REPEAT_DETERM o EVERY' [
1190- EqSubst.eqsubst_tac ctxt [0 ] (map_filter (Option.map (#eta_compl_free o #axioms)) defs),
1199+ REPEAT_DETERM_N 10 o EVERY' [ (* TODO: fix *)
1200+ EqSubst.eqsubst_tac ctxt [0 ] (@{print}(map_filter (Option.map (#eta_compl_free o #axioms)) defs)),
1201+ K (print_tac ctxt " 1.1" ),
11911202 SELECT_GOAL (Local_Defs.unfold0_tac ctxt (map_filter (Option.map (snd o #isInj)) defs)),
11921203 rotate_tac ~1 ,
11931204 etac ctxt @{thm contrapos_np},
1205+ K (print_tac ctxt " 1.2" ),
11941206 SELECT_GOAL (Local_Defs.unfold0_tac ctxt (@{thms not_all not_not comp_def} @ map_filter (Option.map (snd o #Inj)) defs)),
11951207 etac ctxt exE,
11961208 hyp_subst_tac ctxt,
1209+ K (print_tac ctxt " 1.3" ),
11971210 rtac ctxt exI,
1198- rtac ctxt refl
1211+ rtac ctxt refl,
1212+ K (print_tac ctxt " 1.35" )
11991213 ],
1200- K (Local_Defs.unfold0_tac ctxt @{thms UN_empty Un_empty_left Un_empty_right}),
1214+ K (Local_Defs.unfold0_tac ctxt (@{thms UN_empty Un_empty_left Un_empty_right image_id}
1215+ @ the_default [] (Option.map single (#Map_map mrsbnf_facts))
1216+ )),
1217+ TRY o EVERY' [
1218+ EqSubst.eqsubst_tac ctxt [0 ] (MRBNF_Def.set_map_of_mrbnf mrbnf),
1219+ REPEAT_DETERM o resolve_tac ctxt @{thms supp_id_bound bij_id}
1220+ ],
1221+ K (Local_Defs.unfold0_tac ctxt (@{thms image_id})),
1222+ K (print_tac ctxt " 1.4" ),
12011223 rtac ctxt refl,
12021224 rtac ctxt trans,
12031225 rtac ctxt @{thm arg_cong2[OF _ refl, of _ _ " minus" ]},
12041226 rtac ctxt @{thm UN_cong},
12051227 Goal.assume_rule_tac ctxt,
1228+ K (print_tac ctxt " 2" ),
12061229 REPEAT_DETERM o EVERY' [
12071230 EqSubst.eqsubst_tac ctxt [0 ] (maps (the_default []) IImsupp_Diffs @ maps (the_default [] o #IImsupp_Diffs) sugars),
12081231 REPEAT_DETERM o (assume_tac ctxt ORELSE' EVERY' [
@@ -1218,12 +1241,16 @@ fun create_tvsubst_of_mrsbnf qualify fp_res mrsbnf rec_mrbnf vvsubst_ctor map_pe
12181241 ])
12191242 ])
12201243 ],
1244+ K (print_tac ctxt " 3" ),
12211245 K (Local_Defs.unfold0_tac ctxt @{thms Un_Diff[symmetric]}),
12221246 rtac ctxt @{thm arg_cong2[OF _ refl, of _ _ " minus" ]},
12231247 K (Local_Defs.unfold0_tac ctxt @{thms UN_UN_flatten UN_Un_distrib[symmetric]}),
12241248 rtac ctxt refl,
1225- rtac ctxt @{thm UN_cong},
1226- Goal.assume_rule_tac ctxt,
1249+ TRY o EVERY' [
1250+ rtac ctxt @{thm UN_cong},
1251+ Goal.assume_rule_tac ctxt
1252+ ],
1253+ K (print_tac ctxt " 4" ),
12271254 EVERY' (map_filter (Option.map (fn def => EVERY' [
12281255 K (Local_Defs.unfold0_tac ctxt [snd (#isInj def)]),
12291256 etac ctxt exE,
@@ -1234,8 +1261,10 @@ fun create_tvsubst_of_mrsbnf qualify fp_res mrsbnf rec_mrbnf vvsubst_ctor map_pe
12341261 K (Local_Defs.unfold0_tac ctxt (@{thms UN_single UN_empty Un_empty_left Un_empty_right}
12351262 @ maps (the_default []) FVars_Injs
12361263 )),
1264+ K (print_tac ctxt " 5" ),
12371265 rtac ctxt refl
1238- ])) (rev defs))
1266+ ])) (rev defs)),
1267+ K (print_tac ctxt " end" )
12391268 ]) end
12401269 ) (#FVarss quot);
12411270
0 commit comments