equal
deleted
inserted
replaced
19 finite_N: "finite (UNIV::N set)" |
19 finite_N: "finite (UNIV::N set)" |
20 and finite_in_P: "\<And> n tns. (n,tns) \<in> P \<longrightarrow> finite tns" |
20 and finite_in_P: "\<And> n tns. (n,tns) \<in> P \<longrightarrow> finite tns" |
21 and used: "\<And> n. \<exists> tns. (n,tns) \<in> P" |
21 and used: "\<And> n. \<exists> tns. (n,tns) \<in> P" |
22 |
22 |
23 |
23 |
24 subsection{* Tree basics: frontier, interior, etc. *} |
24 subsection{* Tree Basics: frontier, interior, etc. *} |
25 |
25 |
26 |
26 |
27 (* Frontier *) |
27 (* Frontier *) |
28 |
28 |
29 inductive inFr :: "N set \<Rightarrow> dtree \<Rightarrow> T \<Rightarrow> bool" where |
29 inductive inFr :: "N set \<Rightarrow> dtree \<Rightarrow> T \<Rightarrow> bool" where |
307 unfolding Itr_def apply safe |
307 unfolding Itr_def apply safe |
308 apply (metis (lifting, mono_tags) inItr_subtr) |
308 apply (metis (lifting, mono_tags) inItr_subtr) |
309 by (metis inItr.Base subtr_inItr subtr_rootL_in) |
309 by (metis inItr.Base subtr_inItr subtr_rootL_in) |
310 |
310 |
311 |
311 |
312 subsection{* The immediate subtree function *} |
312 subsection{* The Immediate Subtree Function *} |
313 |
313 |
314 (* production of: *) |
314 (* production of: *) |
315 abbreviation "prodOf tr \<equiv> (id \<oplus> root) ` (cont tr)" |
315 abbreviation "prodOf tr \<equiv> (id \<oplus> root) ` (cont tr)" |
316 (* subtree of: *) |
316 (* subtree of: *) |
317 definition "subtrOf tr n \<equiv> SOME tr'. Inr tr' \<in> cont tr \<and> root tr' = n" |
317 definition "subtrOf tr n \<equiv> SOME tr'. Inr tr' \<in> cont tr \<and> root tr' = n" |
341 assumes "Inr tr' \<in> cont tr" |
341 assumes "Inr tr' \<in> cont tr" |
342 shows "Inr (root tr') \<in> prodOf tr" |
342 shows "Inr (root tr') \<in> prodOf tr" |
343 by (metis (lifting) assms image_iff sum_map.simps(2)) |
343 by (metis (lifting) assms image_iff sum_map.simps(2)) |
344 |
344 |
345 |
345 |
346 subsection{* Well-formed derivation trees *} |
346 subsection{* Well-Formed Derivation Trees *} |
347 |
347 |
348 hide_const wf |
348 hide_const wf |
349 |
349 |
350 coinductive wf where |
350 coinductive wf where |
351 dtree: "\<lbrakk>(root tr, (id \<oplus> root) ` (cont tr)) \<in> P; inj_on root (Inr -` cont tr); |
351 dtree: "\<lbrakk>(root tr, (id \<oplus> root) ` (cont tr)) \<in> P; inj_on root (Inr -` cont tr); |
446 qed |
446 qed |
447 thus ?thesis using assms by auto |
447 thus ?thesis using assms by auto |
448 qed |
448 qed |
449 |
449 |
450 |
450 |
451 subsection{* Default trees *} |
451 subsection{* Default Trees *} |
452 |
452 |
453 (* Pick a left-hand side of a production for each nonterminal *) |
453 (* Pick a left-hand side of a production for each nonterminal *) |
454 definition S where "S n \<equiv> SOME tns. (n,tns) \<in> P" |
454 definition S where "S n \<equiv> SOME tns. (n,tns) \<in> P" |
455 |
455 |
456 lemma S_P: "(n, S n) \<in> P" |
456 lemma S_P: "(n, S n) \<in> P" |
486 } |
486 } |
487 thus ?thesis by auto |
487 thus ?thesis by auto |
488 qed |
488 qed |
489 |
489 |
490 |
490 |
491 subsection{* Hereditary substitution *} |
491 subsection{* Hereditary Substitution *} |
492 |
492 |
493 (* Auxiliary concept: The root-ommiting frontier: *) |
493 (* Auxiliary concept: The root-ommiting frontier: *) |
494 definition "inFrr ns tr t \<equiv> \<exists> tr'. Inr tr' \<in> cont tr \<and> inFr ns tr' t" |
494 definition "inFrr ns tr t \<equiv> \<exists> tr'. Inr tr' \<in> cont tr \<and> inFr ns tr' t" |
495 definition "Frr ns tr \<equiv> {t. \<exists> tr'. Inr tr' \<in> cont tr \<and> t \<in> Fr ns tr'}" |
495 definition "Frr ns tr \<equiv> {t. \<exists> tr'. Inr tr' \<in> cont tr \<and> t \<in> Fr ns tr'}" |
496 |
496 |
677 using inFr_self_hsubst[OF assms] unfolding Frr Fr_def by auto |
677 using inFr_self_hsubst[OF assms] unfolding Frr Fr_def by auto |
678 |
678 |
679 end (* context *) |
679 end (* context *) |
680 |
680 |
681 |
681 |
682 subsection{* Regular trees *} |
682 subsection{* Regular Trees *} |
683 |
683 |
684 hide_const regular |
684 hide_const regular |
685 |
685 |
686 definition "reg f tr \<equiv> \<forall> tr'. subtr UNIV tr' tr \<longrightarrow> tr' = f (root tr')" |
686 definition "reg f tr \<equiv> \<forall> tr'. subtr UNIV tr' tr \<longrightarrow> tr' = f (root tr')" |
687 definition "regular tr \<equiv> \<exists> f. reg f tr" |
687 definition "regular tr \<equiv> \<exists> f. reg f tr" |
769 qed |
769 qed |
770 |
770 |
771 |
771 |
772 |
772 |
773 |
773 |
774 subsection {* Paths in a regular tree *} |
774 subsection {* Paths in a Regular Tree *} |
775 |
775 |
776 inductive path :: "(N \<Rightarrow> dtree) \<Rightarrow> N list \<Rightarrow> bool" for f where |
776 inductive path :: "(N \<Rightarrow> dtree) \<Rightarrow> N list \<Rightarrow> bool" for f where |
777 Base: "path f [n]" |
777 Base: "path f [n]" |
778 | |
778 | |
779 Ind: "\<lbrakk>path f (n1 # nl); Inr (f n1) \<in> cont (f n)\<rbrakk> |
779 Ind: "\<lbrakk>path f (n1 # nl); Inr (f n1) \<in> cont (f n)\<rbrakk> |
913 apply (metis (no_types) inFr_subtr r reg_subtr_path) |
913 apply (metis (no_types) inFr_subtr r reg_subtr_path) |
914 by (metis f inFr.Base path_subtr subtr_inFr subtr_mono subtr_rootL_in) |
914 by (metis f inFr.Base path_subtr subtr_inFr subtr_mono subtr_rootL_in) |
915 |
915 |
916 |
916 |
917 |
917 |
918 subsection{* The regular cut of a tree *} |
918 subsection{* The Regular Cut of a Tree *} |
919 |
919 |
920 context fixes tr0 :: dtree |
920 context fixes tr0 :: dtree |
921 begin |
921 begin |
922 |
922 |
923 (* Picking a subtree of a certain root: *) |
923 (* Picking a subtree of a certain root: *) |
1080 by (metis (lifting) root_H inItr.Base reg_def reg_root subtr_rootR_in) |
1080 by (metis (lifting) root_H inItr.Base reg_def reg_root subtr_rootR_in) |
1081 |
1081 |
1082 end (* context *) |
1082 end (* context *) |
1083 |
1083 |
1084 |
1084 |
1085 subsection{* Recursive description of the regular tree frontiers *} |
1085 subsection{* Recursive Description of the Regular Tree Frontiers *} |
1086 |
1086 |
1087 lemma regular_inFr: |
1087 lemma regular_inFr: |
1088 assumes r: "regular tr" and In: "root tr \<in> ns" |
1088 assumes r: "regular tr" and In: "root tr \<in> ns" |
1089 and t: "inFr ns tr t" |
1089 and t: "inFr ns tr t" |
1090 shows "t \<in> Inl -` (cont tr) \<or> |
1090 shows "t \<in> Inl -` (cont tr) \<or> |
1129 apply (simp, metis (full_types) mem_Collect_eq) |
1129 apply (simp, metis (full_types) mem_Collect_eq) |
1130 apply simp |
1130 apply simp |
1131 by (simp, metis (lifting) inFr_Ind_minus insert_Diff) |
1131 by (simp, metis (lifting) inFr_Ind_minus insert_Diff) |
1132 |
1132 |
1133 |
1133 |
1134 subsection{* The generated languages *} |
1134 subsection{* The Generated Languages *} |
1135 |
1135 |
1136 (* The (possibly inifinite tree) generated language *) |
1136 (* The (possibly inifinite tree) generated language *) |
1137 definition "L ns n \<equiv> {Fr ns tr | tr. wf tr \<and> root tr = n}" |
1137 definition "L ns n \<equiv> {Fr ns tr | tr. wf tr \<and> root tr = n}" |
1138 |
1138 |
1139 (* The regular-tree generated language *) |
1139 (* The regular-tree generated language *) |