@@ -1532,9 +1532,9 @@ fun compose_bmv_monad qualify (outer : bmv_monad) (inners : (bmv_monad, typ) eit
15321532 val (x, _) = names_lthy
15331533 |> apfst hd o mk_Frees " x" [leader ops_of_bmv_monad outer];
15341534
1535- val new_Injs = filter (member (op =) frees o domain_type o fastype_of) (
1535+ val new_Injs = distinct ( op =) ( filter (member (op =) frees o domain_type o fastype_of) (
15361536 maps (leader Injs_of_bmv_monad) (outer :: inners')
1537- );
1537+ )) ;
15381538
15391539 fun option x f y = the_default x (Option.map f y)
15401540 val new_RVrs = map_filter (fn a =>
@@ -1609,9 +1609,11 @@ fun compose_bmv_monad qualify (outer : bmv_monad) (inners : (bmv_monad, typ) eit
16091609 );
16101610 val Supps = map (fn live => Term.absfree (dest_Free x) (foldl1 mk_Un (@{map_filter 2 } (
16111611 fn Inr _ => K NONE | Inl inner => fn set => if null (leader lives_of_bmv_monad inner) then NONE
1612- else Option.map (mk_UNION (set $ x)) (
1613- List.find (curry (op =) live o HOLogic.dest_setT o body_type o fastype_of) (the (leader Supps_of_bmv_monad inner))
1614- )
1612+ else case filter (curry (op =) live o HOLogic.dest_setT o body_type o fastype_of) (the (leader Supps_of_bmv_monad inner)) of
1613+ [] => NONE
1614+ | xs => SOME (mk_UNION (set $ x) (Term.abs (" a" , HOLogic.dest_setT (fastype_of (set $ x))) (
1615+ foldl1 mk_Un (map (fn s => s $ Bound 0 ) xs)))
1616+ )
16151617 ) inners (the (leader Supps_of_bmv_monad outer))))) lives;
16161618 in SOME { Map = Map, Supps = Supps } end ;
16171619
@@ -1670,14 +1672,26 @@ fun compose_bmv_monad qualify (outer : bmv_monad) (inners : (bmv_monad, typ) eit
16701672 ],
16711673 Supp_Map = map (fn _ => fn ctxt => EVERY1 [
16721674 K (Local_Defs.unfold0_tac ctxt @{thms image_Un image_UN}),
1673- REPEAT_DETERM o rtac ctxt @{thm arg_cong2[of _ _ _ _ " (\< union>)" ]},
1674- REPEAT_DETERM o EVERY' [
1675- EqSubst.eqsubst_tac ctxt [0 ] (#Supp_Map (#axioms param)),
1676- SELECT_GOAL (Local_Defs.unfold0_tac ctxt @{thms image_comp[unfolded comp_def] image_Un image_UN}),
1677- rtac ctxt @{thm UN_cong},
1678- SELECT_GOAL (Local_Defs.unfold0_tac ctxt @{thms image_UN[symmetric]}),
1679- resolve_tac ctxt (flat (map_filter (Option.map (#Supp_Map o #axioms) o leader params_of_bmv_monad) inners'))
1680- ]
1675+ SUBGOAL (fn (goal, _) =>
1676+ let
1677+ fun strip_all (Const (@{const_name Pure.all}, _) $ Abs (x, T, t)) = apfst (cons (x, T)) (strip_all t)
1678+ | strip_all t = ([], t)
1679+ val T = snd (snd (split_last (fst (strip_all goal))))
1680+ val thms = map (fn thm =>
1681+ let
1682+ val arg = Var (hd (Term.add_vars (Thm.prop_of thm) []));
1683+ val tyenv = Sign.typ_match (Proof_Context.theory_of ctxt)
1684+ (fastype_of arg, T) Vartab.empty;
1685+ val insts = map (fn (x, (s, T)) => ((x, s), Thm.ctyp_of ctxt T)) (Vartab.dest tyenv)
1686+ in instantiate_normalize (TVars.make insts, Vars.empty) thm end
1687+ ) (#Supp_Map (#axioms param));
1688+ in Local_Defs.unfold0_tac ctxt (@{thms UN_simps(10 )} @ thms) end
1689+ ),
1690+ EVERY' (map (fn thm => TRY o EqSubst.eqsubst_tac ctxt [0 ] [thm])
1691+ (flat (map_filter (Option.map (#Supp_Map o #axioms) o leader params_of_bmv_monad) inners'))
1692+ ),
1693+ K (Local_Defs.unfold0_tac ctxt @{thms image_UN[symmetric] image_Un[symmetric]}),
1694+ rtac ctxt refl
16811695 ]) Supps,
16821696 Supp_bd = map (fn _ => fn ctxt => REPEAT_DETERM (resolve_tac ctxt (
16831697 flat (map_filter (Option.map (#Supp_bd o #axioms) o leader params_of_bmv_monad) inners')
@@ -1696,9 +1710,10 @@ fun compose_bmv_monad qualify (outer : bmv_monad) (inners : (bmv_monad, typ) eit
16961710 etac ctxt @{thm UN_I} ORELSE' REPEAT_DETERM o FIRST' [
16971711 rtac ctxt @{thm UnI2} THEN' etac ctxt @{thm UN_I},
16981712 rtac ctxt @{thm UnI1} THEN' etac ctxt @{thm UN_I},
1713+ eresolve_tac ctxt @{thms UnI1 UnI2},
16991714 rtac ctxt @{thm UnI1}
17001715 ],
1701- assume_tac ctxt
1716+ TRY o assume_tac ctxt
17021717 ]
17031718 ]
17041719 ) inners)
@@ -1732,10 +1747,29 @@ fun compose_bmv_monad qualify (outer : bmv_monad) (inners : (bmv_monad, typ) eit
17321747 EqSubst.eqsubst_tac ctxt [0 ] (#Supp_Sb param),
17331748 REPEAT_DETERM o (assume_tac ctxt ORELSE' rtac ctxt @{thm SSupp_Inj_bound})
17341749 ],
1750+ SUBGOAL (fn (goal, _) =>
1751+ let
1752+ fun strip_all (Const (@{const_name Pure.all}, _) $ Abs (x, T, t)) = apfst (cons (x, T)) (strip_all t)
1753+ | strip_all t = ([], t)
1754+ val T = snd (snd (split_last (fst (strip_all goal))))
1755+ val thms = map (fn thm =>
1756+ let
1757+ val arg = Var (hd (Term.add_vars (Thm.prop_of thm) []));
1758+ val tyenv = Sign.typ_match (Proof_Context.theory_of ctxt)
1759+ (fastype_of arg, T) Vartab.empty;
1760+ val insts = map (fn (x, (s, T)) => ((x, s), Thm.ctyp_of ctxt T)) (Vartab.dest tyenv)
1761+ in instantiate_normalize (TVars.make insts, Vars.empty) thm end
1762+ ) (#Supp_Map (#axioms param));
1763+ in Local_Defs.unfold0_tac ctxt (@{thms UN_simps(10 )} @ thms) end
1764+ ),
1765+ REPEAT_DETERM o EVERY' [
1766+ EqSubst.eqsubst_tac ctxt [0 ] (flat (maps (map_filter (Option.map #Supp_Sb) o params_of_bmv_monad) inners')),
1767+ REPEAT_DETERM o (assume_tac ctxt ORELSE' rtac ctxt @{thm SSupp_Inj_bound})
1768+ ],
17351769 K (Local_Defs.unfold0_tac ctxt (
17361770 @{thms image_Un image_UN image_comp[unfolded comp_def] UN_empty2 Union_UN_swap
17371771 Un_empty_right Un_empty_left UN_Un Union_Un_distrib UN_UN_flatten UN_Un_distrib}
1738- @ #Supp_Map (#axioms param) @ # Vrs_Map param @ flat (#Supp_Injss facts)
1772+ @ #Vrs_Map param @ flat (#Supp_Injss facts)
17391773 )),
17401774 REPEAT_DETERM o EVERY' [
17411775 EqSubst.eqsubst_tac ctxt [0 ] (flat (maps (map_filter (Option.map #Supp_Sb) o params_of_bmv_monad) inners')),
@@ -1846,11 +1880,26 @@ fun compose_bmv_monad qualify (outer : bmv_monad) (inners : (bmv_monad, typ) eit
18461880 EqSubst.eqsubst_tac ctxt [0 ] (#Vrs_Sbs axioms @ #Supp_Sb param),
18471881 REPEAT_DETERM o (assume_tac ctxt ORELSE' rtac ctxt @{thm SSupp_Inj_bound})
18481882 ],
1883+ SUBGOAL (fn (goal, _) =>
1884+ let
1885+ fun strip_all (Const (@{const_name Pure.all}, _) $ Abs (x, T, t)) = apfst (cons (x, T)) (strip_all t)
1886+ | strip_all t = ([], t)
1887+ val T = snd (snd (split_last (fst (strip_all goal))))
1888+ val thms = map (fn thm =>
1889+ let
1890+ val arg = Var (hd (Term.add_vars (Thm.prop_of thm) []));
1891+ val tyenv = Sign.typ_match (Proof_Context.theory_of ctxt)
1892+ (fastype_of arg, T) Vartab.empty;
1893+ val insts = map (fn (x, (s, T)) => ((x, s), Thm.ctyp_of ctxt T)) (Vartab.dest tyenv)
1894+ in instantiate_normalize (TVars.make insts, Vars.empty) thm end
1895+ ) (#Supp_Map (#axioms param));
1896+ in Local_Defs.unfold0_tac ctxt (@{thms UN_simps(10 )} @ thms) end
1897+ ),
18491898 K (Local_Defs.unfold0_tac ctxt (
18501899 @{thms image_Un image_UN image_comp[unfolded comp_def] UN_empty2 Union_UN_swap Un_assoc[symmetric]
1851- Un_empty_right Un_empty_left UN_Un Union_Un_distrib UN_UN_flatten UN_Un_distrib}
1900+ Un_empty_right Un_empty_left UN_Un Union_Un_distrib UN_UN_flatten UN_Un_distrib id_bnf_apply }
18521901 @ #Vrs_Map param @ flat (#Vrs_Injss axioms)
1853- @ #Supp_Map (#axioms param) @ flat (maps (
1902+ @ flat (maps (
18541903 #Supp_Injss o leader facts_of_bmv_monad
18551904 ) (outer :: inners'))
18561905 )),
@@ -1860,7 +1909,7 @@ fun compose_bmv_monad qualify (outer : bmv_monad) (inners : (bmv_monad, typ) eit
18601909 ),
18611910 REPEAT_DETERM o (assume_tac ctxt ORELSE' rtac ctxt @{thm SSupp_Inj_bound})
18621911 ],
1863- K (Local_Defs.unfold0_tac ctxt @{thms image_Un Union_UN_swap image_UN UN_empty2 Un_empty_left Un_empty_right UN_UN_flatten UN_Un_distrib Un_assoc[symmetric]}),
1912+ K (Local_Defs.unfold0_tac ctxt @{thms image_single image_Un Union_UN_swap image_UN UN_empty2 Un_empty_left Un_empty_right UN_UN_flatten UN_Un_distrib Un_assoc[symmetric]}),
18641913 rtac ctxt refl ORELSE' EVERY' [
18651914 rtac ctxt @{thm set_eqI},
18661915 K (Local_Defs.unfold0_tac ctxt @{thms Un_iff}),
0 commit comments