theory AGTT imports GTT GTT_Transitive_Closure Pair_Automaton begin definition AGTT_union where "AGTT_union π’β©1 π’β©2 β‘ (ta_union (fst π’β©1) (fst π’β©2), ta_union (snd π’β©1) (snd π’β©2))" abbreviation AGTT_union' where "AGTT_union' π’β©1 π’β©2 β‘ AGTT_union (fmap_states_gtt Inl π’β©1) (fmap_states_gtt Inr π’β©2)" lemma disj_gtt_states_disj_fst_ta_states: assumes dist_st: "gtt_states π’β©1 |β©| gtt_states π’β©2 = {||}" shows "π¬ (fst π’β©1) |β©| π¬ (fst π’β©2) = {||}" using assms unfolding gtt_states_def by auto lemma disj_gtt_states_disj_snd_ta_states: assumes dist_st: "gtt_states π’β©1 |β©| gtt_states π’β©2 = {||}" shows "π¬ (snd π’β©1) |β©| π¬ (snd π’β©2) = {||}" using assms unfolding gtt_states_def by auto lemma ta_der_not_contains_undefined_state: assumes "q |β| π¬ T" and "ground t" shows "q |β| ta_der T t" using ground_ta_der_states[OF assms(2)] assms(1) by blast lemma AGTT_union_sound1: assumes dist_st: "gtt_states π’β©1 |β©| gtt_states π’β©2 = {||}" shows "agtt_lang (AGTT_union π’β©1 π’β©2) β agtt_lang π’β©1 βͺ agtt_lang π’β©2" proof - let ?TA_A = "ta_union (fst π’β©1) (fst π’β©2)" let ?TA_B = "ta_union (snd π’β©1) (snd π’β©2)" {fix s t assume ass: "(s, t) β agtt_lang (AGTT_union π’β©1 π’β©2)" then obtain q where ls: "q |β| ta_der ?TA_A (term_of_gterm s)" and rs: "q |β| ta_der ?TA_B (term_of_gterm t)" by (auto simp add: AGTT_union_def agtt_lang_def gta_der_def) then have "(s, t) β agtt_lang π’β©1 β¨ (s, t) β agtt_lang π’β©2" proof (cases "q |β| gtt_states π’β©1") case True then have "q |β| gtt_states π’β©2" using dist_st by blast then have nt_fst_st: "q |β| π¬ (fst π’β©2)" and nt_snd_state: "q |β| π¬ (snd π’β©2)" by (auto simp add: gtt_states_def) from True show ?thesis using ls rs using ta_der_not_contains_undefined_state[OF nt_fst_st] using ta_der_not_contains_undefined_state[OF nt_snd_state] unfolding gtt_states_def agtt_lang_def gta_der_def using ta_union_der_disj_states[OF disj_gtt_states_disj_fst_ta_states[OF dist_st]] using ta_union_der_disj_states[OF disj_gtt_states_disj_snd_ta_states[OF dist_st]] using ground_term_of_gterm by blast next case False then have "q |β| gtt_states π’β©1" by (metis IntI dist_st emptyE) then have nt_fst_st: "q |β| π¬ (fst π’β©1)" and nt_snd_state: "q |β| π¬ (snd π’β©1)" by (auto simp add: gtt_states_def) from False show ?thesis using ls rs using ta_der_not_contains_undefined_state[OF nt_fst_st] using ta_der_not_contains_undefined_state[OF nt_snd_state] unfolding gtt_states_def agtt_lang_def gta_der_def using ta_union_der_disj_states[OF disj_gtt_states_disj_fst_ta_states[OF dist_st]] using ta_union_der_disj_states[OF disj_gtt_states_disj_snd_ta_states[OF dist_st]] using ground_term_of_gterm by blast qed} then show ?thesis by auto qed lemma AGTT_union_sound2: shows "agtt_lang π’β©1 β agtt_lang (AGTT_union π’β©1 π’β©2)" "agtt_lang π’β©2 β agtt_lang (AGTT_union π’β©1 π’β©2)" unfolding agtt_lang_def gta_der_def AGTT_union_def by auto (meson fin_mono ta_der_mono' ta_union_ta_subset)+ lemma AGTT_union_sound: assumes dist_st: "gtt_states π’β©1 |β©| gtt_states π’β©2 = {||}" shows "agtt_lang (AGTT_union π’β©1 π’β©2) = agtt_lang π’β©1 βͺ agtt_lang π’β©2" using AGTT_union_sound1[OF assms] AGTT_union_sound2 by blast lemma AGTT_union'_sound: fixes π’β©1 :: "('q, 'f) gtt" and π’β©2 :: "('q, 'f) gtt" shows "agtt_lang (AGTT_union' π’β©1 π’β©2) = agtt_lang π’β©1 βͺ agtt_lang π’β©2" proof - have map: "agtt_lang (AGTT_union' π’β©1 π’β©2) = agtt_lang (fmap_states_gtt CInl π’β©1) βͺ agtt_lang (fmap_states_gtt CInr π’β©2)" by (intro AGTT_union_sound) (auto simp add: agtt_lang_fmap_states_gtt) then show ?thesis by (simp add: agtt_lang_fmap_states_gtt finj_CInl_CInr) qed subsection βΉAnchord gtt compositonβΊ definition AGTT_comp :: "('q, 'f) gtt β ('q, 'f) gtt β ('q, 'f) gtt" where "AGTT_comp π’β©1 π’β©2 = (let (π, β¬) = (fst π’β©1, snd π’β©2) in (TA (rules π) (eps π |βͺ| (Ξβ©Ξ΅ (snd π’β©1) (fst π’β©2) |β©| (gtt_interface π’β©1 |Γ| gtt_interface π’β©2))), TA (rules β¬) (eps β¬)))" abbreviation AGTT_comp' where "AGTT_comp' π’β©1 π’β©2 β‘ AGTT_comp (fmap_states_gtt Inl π’β©1) (fmap_states_gtt Inr π’β©2)" lemma AGTT_comp_sound: assumes "gtt_states π’β©1 |β©| gtt_states π’β©2 = {||}" shows "agtt_lang (AGTT_comp π’β©1 π’β©2) = agtt_lang π’β©1 O agtt_lang π’β©2" proof - let ?Qβ©1 = "fId_on (gtt_interface π’β©1)" let ?Qβ©2 = "fId_on (gtt_interface π’β©2)" have lan: "agtt_lang π’β©1 = pair_at_lang π’β©1 ?Qβ©1" "agtt_lang π’β©2 = pair_at_lang π’β©2 ?Qβ©2" using pair_at_agtt[of π’β©1] pair_at_agtt[of π’β©2] by auto have "agtt_lang π’β©1 O agtt_lang π’β©2 = pair_at_lang (fst π’β©1, snd π’β©2) (Ξ_eps_pair π’β©1 ?Qβ©1 π’β©2 ?Qβ©2)" using pair_comp_sound1 pair_comp_sound2 by (auto simp add: lan pair_comp_sound1 pair_comp_sound2 relcomp.simps) moreover have "AGTT_comp π’β©1 π’β©2 = pair_at_to_agtt (fst π’β©1, snd π’β©2) (Ξ_eps_pair π’β©1 ?Qβ©1 π’β©2 ?Qβ©2)" by (auto simp: AGTT_comp_def pair_at_to_agtt_def gtt_interface_def Ξβ©Ξ΅_def' Ξ_eps_pair_def) ultimately show ?thesis using pair_at_agtt_conv[of "Ξ_eps_pair π’β©1 ?Qβ©1 π’β©2 ?Qβ©2" "(fst π’β©1, snd π’β©2)"] using assms by (auto simp: Ξ_eps_pair_def gtt_states_def gtt_interface_def) qed lemma AGTT_comp'_sound: "agtt_lang (AGTT_comp' π’β©1 π’β©2) = agtt_lang π’β©1 O agtt_lang π’β©2" using AGTT_comp_sound[of "fmap_states_gtt (Inl :: 'b β 'b + 'c) π’β©1" "fmap_states_gtt (Inr :: 'c β 'b + 'c) π’β©2"] by (auto simp add: agtt_lang_fmap_states_gtt disjoint_iff_not_equal agtt_lang_Inl_Inr_states_agtt) subsection βΉAnchord gtt transitivityβΊ definition AGTT_trancl :: "('q, 'f) gtt β ('q + 'q, 'f) gtt" where "AGTT_trancl π’ = (let π = fmap_states_ta Inl (fst π’) in (TA (rules π) (eps π |βͺ| map_prod CInl CInr |`| (Ξ_Atrans_gtt π’ (fId_on (gtt_interface π’)))), TA (map_ta_rule CInr id |`| (rules (snd π’))) (map_both CInr |`| (eps (snd π’)))))" lemma AGTT_trancl_sound: shows "agtt_lang (AGTT_trancl π’) = (agtt_lang π’)β§+" proof - let ?P = "map_prod (fmap_states_ta CInl) (fmap_states_ta CInr) π’" let ?Q = "fId_on (gtt_interface π’)" let ?Q' = "map_prod CInl CInr |`| ?Q" have inv: "finj_on CInl (π¬ (fst π’))" "finj_on CInr (π¬ (snd π’))" "?Q |β| π¬ (fst π’) |Γ| π¬ (snd π’)" by (auto simp: gtt_interface_def finj_CInl_CInr) have *: "fst |`| map_prod CInl CInr |`| Ξ_Atrans_gtt π’ (fId_on (gtt_interface π’)) |β| CInl |`| π¬ (fst π’)" using fsubsetD[OF Ξ_Atrans_states_stable[OF inv(3)]] by (auto simp add: gtt_interface_def) from pair_at_lang_fun_states[OF inv] have "agtt_lang π’ = pair_at_lang ?P ?Q'" using pair_at_agtt[of π’] by auto moreover then have "(agtt_lang π’)β§+ = pair_at_lang ?P (Ξ_Atrans_gtt ?P ?Q')" by (simp add: pair_trancl_sound) moreover have "AGTT_trancl π’ = pair_at_to_agtt ?P (Ξ_Atrans_gtt ?P ?Q')" using Ξ_Atrans_states_stable[OF inv(3)] Ξ_Atrans_map_prod[OF inv, symmetric] using fId_on_frelcomp_id[OF *] by (auto simp: AGTT_trancl_def pair_at_to_agtt_def gtt_interface_def Let_def fmap_states_ta_def) (metis fmap_prod_fimageI fmap_states fmap_states_ta_def) moreover have "gtt_interface (map_prod (fmap_states_ta CInl) (fmap_states_ta CInr) π’) = {||}" by (auto simp: gtt_interface_def) ultimately show ?thesis using pair_at_agtt_conv[of "Ξ_Atrans_gtt ?P ?Q'" ?P] Ξ_Atrans_states_stable[OF inv(3)] unfolding Ξ_Atrans_map_prod[OF inv, symmetric] by (simp add: fimage_mono gtt_interface_def map_prod_ftimes) qed end