Theory TA_Clousure_Const
section ‹(Multihole)Context closure of recognized tree languages›
theory TA_Clousure_Const
imports Tree_Automata_Derivation_Split
begin
subsection ‹Tree Automata closure constructions›
declare ta_union_def [simp]
subsubsection ‹Reflexive closure over a given signature›
definition "reflcl_rules ℱ q ≡ (λ (f, n). TA_rule f (replicate n q) q) |`| ℱ"
definition "refl_ta ℱ q = TA (reflcl_rules ℱ q) {||}"
definition gen_reflcl_automaton :: "('f × nat) fset ⇒ ('q, 'f) ta ⇒ 'q ⇒ ('q, 'f) ta" where
"gen_reflcl_automaton ℱ 𝒜 q = ta_union 𝒜 (refl_ta ℱ q)"
definition "reflcl_automaton ℱ 𝒜 = (let ℬ = fmap_states_ta Some 𝒜 in
gen_reflcl_automaton ℱ ℬ None)"
definition "reflcl_reg ℱ 𝒜 = Reg (finsert None (Some |`| fin 𝒜)) (reflcl_automaton ℱ (ta 𝒜))"
subsubsection ‹Multihole context closure over a given signature›
definition "refl_over_states_ta Q ℱ 𝒜 q = TA (reflcl_rules ℱ q) ((λ p. (p, q)) |`| (Q |∩| 𝒬 𝒜))"
definition gen_parallel_closure_automaton :: "'q fset ⇒ ('f × nat) fset ⇒ ('q, 'f) ta ⇒ 'q ⇒ ('q, 'f) ta" where
"gen_parallel_closure_automaton Q ℱ 𝒜 q = ta_union 𝒜 (refl_over_states_ta Q ℱ 𝒜 q)"
definition parallel_closure_reg where
"parallel_closure_reg ℱ 𝒜 = (let ℬ = fmap_states_reg Some 𝒜 in
Reg {|None|} (gen_parallel_closure_automaton (fin ℬ) ℱ (ta ℬ) None))"
subsubsection ‹Context closure of regular tree language›
definition "semantic_path_rules ℱ q⇩c q⇩i q⇩f ≡
|⋃| ((λ (f, n). fset_of_list (map (λ i. TA_rule f ((replicate n q⇩c)[i := q⇩i]) q⇩f) [0..< n])) |`| ℱ)"
definition "reflcl_over_single_ta Q ℱ q⇩c q⇩f ≡
TA (reflcl_rules ℱ q⇩c |∪| semantic_path_rules ℱ q⇩c q⇩f q⇩f) ((λ p. (p, q⇩f)) |`| Q)"
definition "gen_ctxt_closure_automaton Q ℱ 𝒜 q⇩c q⇩f = ta_union 𝒜 (reflcl_over_single_ta Q ℱ q⇩c q⇩f)"
definition "gen_ctxt_closure_reg ℱ 𝒜 q⇩c q⇩f =
Reg {|q⇩f|} (gen_ctxt_closure_automaton (fin 𝒜) ℱ (ta 𝒜) q⇩c q⇩f)"
definition "ctxt_closure_reg ℱ 𝒜 =
(let ℬ = fmap_states_reg Inl (reg_Restr_Q⇩f 𝒜) in
gen_ctxt_closure_reg ℱ ℬ (Inr False) (Inr True))"
subsubsection ‹Not empty context closure of regular tree language›