# HG changeset patch # User urbanc # Date 1297227018 0 # Node ID 6457e668dee57b65f66614090d8c57df3180525b # Parent a3e0056c228bd8cb9b14704246f1b83085a0d989 tuned comments and names in Myhill_1 diff -r a3e0056c228b -r 6457e668dee5 Myhill_1.thy --- a/Myhill_1.thy Wed Feb 09 03:52:28 2011 +0000 +++ b/Myhill_1.thy Wed Feb 09 04:50:18 2011 +0000 @@ -1,33 +1,12 @@ theory Myhill_1 - imports Main +imports Main Folds begin -(* -text {* - \begin{figure} - \centering - \scalebox{0.95}{ - \begin{tikzpicture}[->,>=latex,shorten >=1pt,auto,node distance=1.2cm, semithick] - \node[state,initial] (n1) {$1$}; - \node[state,accepting] (n2) [right = 10em of n1] {$2$}; - - \path (n1) edge [bend left] node {$0$} (n2) - (n1) edge [loop above] node{$1$} (n1) - (n2) edge [loop above] node{$0$} (n2) - (n2) edge [bend left] node {$1$} (n1) - ; - \end{tikzpicture}} - \caption{An example automaton (or partition)}\label{fig:example_automata} - \end{figure} -*} - -*) - - section {* Preliminary definitions *} types lang = "string set" + text {* Sequential composition of two languages *} definition @@ -151,10 +130,7 @@ assumes a: "x \ A\" "x \ []" shows "\a b. x = a @ b \ a \ [] \ a \ A \ b \ A\" using a -apply(induct rule: star_induct) -apply(simp) -apply(blast) -done +by (induct rule: star_induct) (blast)+ lemma shows seq_Union_left: "B ;; (\n. A \ n) = (\n. B ;; (A \ n))" @@ -167,12 +143,11 @@ lemma seq_star_comm: shows "A ;; A\ = A\ ;; A" -unfolding Star_def -unfolding seq_Union_left -unfolding seq_pow_comm -unfolding seq_Union_right +unfolding Star_def seq_Union_left +unfolding seq_pow_comm seq_Union_right by simp + text {* Two lemmas about the length of strings in @{text "A \ n"} *} lemma pow_length: @@ -209,12 +184,13 @@ qed -section {* A slightly modified version of Arden's lemma *} + +section {* A modified version of Arden's lemma *} text {* A helper lemma for Arden *} -lemma ardens_helper: +lemma arden_helper: assumes eq: "X = X ;; A \ B" shows "X = X ;; (A \ Suc n) \ (\m\{0..n}. B ;; (A \ m))" proof (induct n) @@ -232,7 +208,7 @@ finally show "X = X ;; (A \ Suc (Suc n)) \ (\m\{0..Suc n}. B ;; (A \ m))" . qed -theorem ardens_revised: +theorem arden: assumes nemp: "[] \ A" shows "X = X ;; A \ B \ X = B ;; A\" proof @@ -251,10 +227,9 @@ next assume eq: "X = X ;; A \ B" { fix n::nat - have "B ;; (A \ n) \ X" using ardens_helper[OF eq, of "n"] by auto } + have "B ;; (A \ n) \ X" using arden_helper[OF eq, of "n"] by auto } then have "B ;; A\ \ X" - unfolding Seq_def Star_def UNION_def - by auto + unfolding Seq_def Star_def UNION_def by auto moreover { fix s::string obtain k where "k = length s" by auto @@ -262,14 +237,13 @@ using seq_pow_length[OF nemp] by blast assume "s \ X" then have "s \ X ;; (A \ Suc k) \ (\m\{0..k}. B ;; (A \ m))" - using ardens_helper[OF eq, of "k"] by auto + using arden_helper[OF eq, of "k"] by auto then have "s \ (\m\{0..k}. B ;; (A \ m))" using not_in by auto moreover have "(\m\{0..k}. B ;; (A \ m)) \ (\n. B ;; (A \ n))" by auto ultimately have "s \ B ;; A\" - unfolding seq_Union_left Star_def - by auto } + unfolding seq_Union_left Star_def by auto } then have "X \ B ;; A\" by auto ultimately show "X = B ;; A\" by simp @@ -288,14 +262,12 @@ text {* - The following @{text "L"} is an overloaded operator, where @{text "L(x)"} evaluates to - the language represented by the syntactic object @{text "x"}. + The function @{text L} is overloaded, with the idea that @{text "L x"} + evaluates to the language represented by the object @{text x}. *} consts L:: "'a \ lang" -text {* The @{text "L (rexp)"} for regular expressions. *} - overloading L_rexp \ "L:: rexp \ lang" begin fun @@ -309,22 +281,7 @@ | "L_rexp (STAR r) = (L_rexp r)\" end - -section {* Folds for Sets *} - -text {* - To obtain equational system out of finite set of equivalence classes, a fold operation - on finite sets @{text "folds"} is defined. The use of @{text "SOME"} makes @{text "folds"} - more robust than the @{text "fold"} in the Isabelle library. The expression @{text "folds f"} - makes sense when @{text "f"} is not @{text "associative"} and @{text "commutitive"}, - while @{text "fold f"} does not. -*} - - -definition - folds :: "('a \ 'b \ 'b) \ 'b \ 'a set \ 'b" -where - "folds f z S \ SOME x. fold_graph f z S x" +text {* ALT-combination of a set or regulare expressions *} abbreviation Setalt ("\_" [1000] 999) @@ -332,9 +289,7 @@ "\A == folds ALT NULL A" text {* - The following lemma ensures that the arbitrary choice made by the - @{text "SOME"} in @{text "folds"} does not affect the @{text "L"}-value - of the resultant regular expression. + For finite sets, @{term Setalt} is preserved under @{term L}. *} lemma folds_alt_simp [simp]: @@ -349,23 +304,26 @@ done + +section {* Direction @{text "finite partition \ regular language"} *} + + text {* Just a technical lemma for collections and pairs *} lemma Pair_Collect[simp]: shows "(x, y) \ {(x, y). P x y} \ P x y" by simp -text {* - @{text "\A"} is an equivalence class defined by language @{text "A"}. -*} +text {* Myhill-Nerode relation *} + definition str_eq_rel :: "lang \ (string \ string) set" ("\_" [100] 100) where "\A \ {(x, y). (\z. x @ z \ A \ y @ z \ A)}" text {* - Among the equivalence clases of @{text "\A"}, the set @{text "finals A"} singles out - those which contains the strings from @{text "A"}. + Among the equivalence clases of @{text "\A"}, the set @{text "finals A"} + singles out those which contains the strings from @{text A}. *} definition @@ -373,10 +331,6 @@ where "finals A \ {\A `` {x} | x . x \ A}" -text {* - The following lemma establishes the relationshipt between - @{text "finals A"} and @{text "A"}. -*} lemma lang_is_union_of_finals: shows "A = \ finals A" @@ -394,64 +348,22 @@ unfolding quotient_def by auto -section {* Direction @{text "finite partition \ regular language"}*} -text {* - The relationship between equivalent classes can be described by an - equational system. For example, in equational system \eqref{example_eqns}, - $X_0, X_1$ are equivalent classes. The first equation says every string in - $X_0$ is obtained either by appending one $b$ to a string in $X_0$ or by - appending one $a$ to a string in $X_1$ or just be an empty string - (represented by the regular expression $\lambda$). Similary, the second - equation tells how the strings inside $X_1$ are composed. - - \begin{equation}\label{example_eqns} - \begin{aligned} - X_0 & = X_0 b + X_1 a + \lambda \\ - X_1 & = X_0 a + X_1 b - \end{aligned} - \end{equation} - - \noindent - The summands on the right hand side is represented by the following data - type @{text "rhs_item"}, mnemonic for 'right hand side item'. Generally, - there are two kinds of right hand side items, one kind corresponds to pure - regular expressions, like the $\lambda$ in \eqref{example_eqns}, the other - kind corresponds to transitions from one one equivalent class to another, - like the $X_0 b, X_1 a$ etc. - -*} +section {* Equational systems *} datatype rhs_item = - Lam "rexp" (* Lambda *) + Lam "rexp" (* Lambda-marker *) | Trn "lang" "rexp" (* Transition *) -text {* - In this formalization, pure regular expressions like $\lambda$ is - repsented by @{text "Lam(EMPTY)"}, while transitions like $X_0 a$ is - represented by @{term "Trn X\<^isub>0 (CHAR a)"}. -*} - -text {* - Every right-hand side item @{text "itm"} defines a language given - by @{text "L(itm)"}, defined as: -*} - -overloading L_rhs_e \ "L:: rhs_item \ lang" +overloading L_rhs_item \ "L:: rhs_item \ lang" begin - fun L_rhs_e:: "rhs_item \ lang" + fun L_rhs_item:: "rhs_item \ lang" where - "L_rhs_e (Lam r) = L r" - | "L_rhs_e (Trn X r) = X ;; L r" + "L_rhs_item (Lam r) = L r" + | "L_rhs_item (Trn X r) = X ;; L r" end -text {* - The right hand side of every equation is represented by a set of - items. The string set defined by such a set @{text "itms"} is given - by @{text "L(itms)"}, defined as: -*} - overloading L_rhs \ "L:: rhs_item set \ lang" begin fun L_rhs:: "rhs_item set \ lang" @@ -459,18 +371,18 @@ "L_rhs rhs = \ (L ` rhs)" end -text {* - Given a set of equivalence classes @{text "CS"} and one equivalence class @{text "X"} among - @{text "CS"}, the term @{text "init_rhs CS X"} is used to extract the right hand side of - the equation describing the formation of @{text "X"}. The definition of @{text "init_rhs"} - is: -*} +definition + "trns_of rhs X \ {Trn X r | r. Trn X r \ rhs}" + +text {* Transitions between equivalence classes *} definition transition :: "lang \ rexp \ lang \ bool" ("_ \_\_" [100,100,100] 100) where "Y \r\ X \ Y ;; (L r) \ X" +text {* Initial equational system *} + definition "init_rhs CS X \ if ([] \ X) then @@ -478,89 +390,54 @@ else {Trn Y (CHAR c)| Y c. Y \ CS \ Y \(CHAR c)\ X}" -text {* - In the definition of @{text "init_rhs"}, the term - @{text "{Trn Y (CHAR c)| Y c. Y \ CS \ Y ;; {[c]} \ X}"} appearing on both branches - describes the formation of strings in @{text "X"} out of transitions, while - the term @{text "{Lam(EMPTY)}"} describes the empty string which is intrinsically contained in - @{text "X"} rather than by transition. This @{text "{Lam(EMPTY)}"} corresponds to - the $\lambda$ in \eqref{example_eqns}. - - With the help of @{text "init_rhs"}, the equitional system descrbing the formation of every - equivalent class inside @{text "CS"} is given by the following @{text "eqs(CS)"}. -*} - - -definition "eqs CS \ {(X, init_rhs CS X) | X. X \ CS}" +definition + "eqs CS \ {(X, init_rhs CS X) | X. X \ CS}" -(************ arden's lemma variation ********************) - -text {* - The following @{text "trns_of rhs X"} returns all @{text "X"}-items in @{text "rhs"}. -*} - -definition - "trns_of rhs X \ {Trn X r | r. Trn X r \ rhs}" +section {* Arden Operation on equations *} text {* - The following @{text "attach_rexp rexp' itm"} attach - the regular expression @{text "rexp'"} to - the right of right hand side item @{text "itm"}. + The function @{text "attach_rexp r item"} SEQ-composes @{text r} to the + right of every rhs-item. *} fun attach_rexp :: "rexp \ rhs_item \ rhs_item" where - "attach_rexp rexp' (Lam rexp) = Lam (SEQ rexp rexp')" -| "attach_rexp rexp' (Trn X rexp) = Trn X (SEQ rexp rexp')" + "attach_rexp r (Lam rexp) = Lam (SEQ rexp r)" +| "attach_rexp r (Trn X rexp) = Trn X (SEQ rexp r)" -text {* - The following @{text "append_rhs_rexp rhs rexp"} attaches - @{text "rexp"} to every item in @{text "rhs"}. -*} definition "append_rhs_rexp rhs rexp \ (attach_rexp rexp) ` rhs" -text {* - With the help of the two functions immediately above, Ardens' - transformation on right hand side @{text "rhs"} is implemented - by the following function @{text "arden_variate X rhs"}. - After this transformation, the recursive occurence of @{text "X"} - in @{text "rhs"} will be eliminated, while the string set defined - by @{text "rhs"} is kept unchanged. +definition + "arden_op X rhs \ + append_rhs_rexp (rhs - trns_of rhs X) (STAR (\ {r. Trn X r \ rhs}))" + + +section {* Substitution Operation on equations *} + +text {* + Suppose and equation @{text "X = xrhs"}, @{text "subst_op"} substitutes + all occurences of @{text "X"} in @{text "rhs"} by @{text "xrhs"}. *} definition - "arden_variate X rhs \ - append_rhs_rexp (rhs - trns_of rhs X) (STAR (\ {r. Trn X r \ rhs}))" - - -(*********** substitution of ES *************) - -text {* - Suppose the equation defining @{text "X"} is $X = xrhs$, - the purpose of @{text "rhs_subst"} is to substitute all occurences of @{text "X"} in - @{text "rhs"} by @{text "xrhs"}. - A litte thought may reveal that the final result - should be: first append $(a_1 | a_2 | \ldots | a_n)$ to every item of @{text "xrhs"} and then - union the result with all non-@{text "X"}-items of @{text "rhs"}. - *} - -definition - "rhs_subst rhs X xrhs \ + "subst_op rhs X xrhs \ (rhs - (trns_of rhs X)) \ (append_rhs_rexp xrhs (\ {r. Trn X r \ rhs}))" text {* - Suppose the equation defining @{text "X"} is $X = xrhs$, the follwing - @{text "eqs_subst ES X xrhs"} substitute @{text "xrhs"} into every equation - of the equational system @{text "ES"}. - *} + @{text "eqs_subst ES X xrhs"} substitutes @{text xrhs} into every + equation of the equational system @{text ES}. +*} definition - "eqs_subst ES X xrhs \ {(Y, rhs_subst yrhs X xrhs) | Y yrhs. (Y, yrhs) \ ES}" + "subst_op_all ES X xrhs \ {(Y, subst_op yrhs X xrhs) | Y yrhs. (Y, yrhs) \ ES}" + + +section {* Well-founded iteration *} text {* The computation of regular expressions for equivalence classes is accomplished @@ -601,33 +478,36 @@ Every definition starting next till @{text "Inv"} stipulates a property to be satisfied by @{text "ES"}. *} -text {* - Every variable is defined at most onece in @{text "ES"}. - *} + +section {* Invariants *} + +text {* Every variable is defined at most onece in @{text ES}. *} definition "distinct_equas ES \ - \ X rhs rhs'. (X, rhs) \ ES \ (X, rhs') \ ES \ rhs = rhs'" + \ X rhs rhs'. (X, rhs) \ ES \ (X, rhs') \ ES \ rhs = rhs'" text {* - Every equation in @{text "ES"} (represented by @{text "(X, rhs)"}) is valid, i.e. @{text "(X = L rhs)"}. - *} + Every equation in @{text ES} (represented by @{text "(X, rhs)"}) + is valid, i.e. @{text "(X = L rhs)"}. +*} + definition "valid_eqns ES \ \ X rhs. (X, rhs) \ ES \ (X = L rhs)" text {* - The following @{text "rhs_nonempty rhs"} requires regular expressions occuring in transitional - items of @{text "rhs"} does not contain empty string. This is necessary for - the application of Arden's transformation to @{text "rhs"}. - *} + @{text "rhs_nonempty rhs"} requires regular expressions occuring in + transitional items of @{text "rhs"} do not contain empty string. This is + necessary for the application of Arden's transformation to @{text "rhs"}. +*} definition "rhs_nonempty rhs \ (\ Y r. Trn Y r \ rhs \ [] \ L r)" text {* - The following @{text "ardenable ES"} requires that Arden's transformation is applicable - to every equation of equational system @{text "ES"}. - *} + The following @{text "ardenable ES"} requires that Arden's transformation + is applicable to every equation of equational system @{text "ES"}. +*} definition "ardenable ES \ \ X rhs. (X, rhs) \ ES \ rhs_nonempty rhs" @@ -636,40 +516,41 @@ definition "non_empty ES \ \ X rhs. (X, rhs) \ ES \ X \ {}" -text {* - The following @{text "finite_rhs ES"} requires every equation in @{text "rhs"} be finite. - *} +text {* + @{text "finite_rhs ES"} requires every equation in @{text "rhs"} + be finite. +*} definition "finite_rhs ES \ \ X rhs. (X, rhs) \ ES \ finite rhs" text {* - The following @{text "classes_of rhs"} returns all variables (or equivalent classes) + @{text "classes_of rhs"} returns all variables (or equivalent classes) occuring in @{text "rhs"}. *} + definition "classes_of rhs \ {X. \ r. Trn X r \ rhs}" text {* - The following @{text "lefts_of ES"} returns all variables - defined by equational system @{text "ES"}. - *} + @{text "lefts_of ES"} returns all variables defined by an + equational system @{text "ES"}. +*} definition "lefts_of ES \ {Y | Y yrhs. (Y, yrhs) \ ES}" text {* - The following @{text "self_contained ES"} requires that every - variable occuring on the right hand side of equations is already defined by some - equation in @{text "ES"}. - *} + The following @{text "self_contained ES"} requires that every variable occuring + on the right hand side of equations is already defined by some equation in @{text "ES"}. +*} definition "self_contained ES \ \ (X, xrhs) \ ES. classes_of xrhs \ lefts_of ES" text {* - The invariant @{text "Inv(ES)"} is a conjunction of all the previously defined constaints. + The invariant @{text "invariant(ES)"} is a conjunction of all the previously defined constaints. *} definition - "Inv ES \ valid_eqns ES \ finite ES \ distinct_equas ES \ ardenable ES \ + "invariant ES \ valid_eqns ES \ finite ES \ distinct_equas ES \ ardenable ES \ non_empty ES \ finite_rhs ES \ self_contained ES" subsection {* The proof of this direction *} @@ -771,8 +652,8 @@ subsubsection {* Intialization *} text {* - The following several lemmas until @{text "init_ES_satisfy_Inv"} shows that - the initial equational system satisfies invariant @{text "Inv"}. + The following several lemmas until @{text "init_ES_satisfy_invariant"} shows that + the initial equational system satisfies invariant @{text "invariant"}. *} lemma defined_by_str: @@ -855,9 +736,9 @@ thus ?thesis by (simp add:init_rhs_def transition_def) qed -lemma init_ES_satisfy_Inv: +lemma init_ES_satisfy_invariant: assumes finite_CS: "finite (UNIV // (\Lang))" - shows "Inv (eqs (UNIV // (\Lang)))" + shows "invariant (eqs (UNIV // (\Lang)))" proof - have "finite (eqs (UNIV // (\Lang)))" using finite_CS by (simp add:eqs_def) @@ -874,7 +755,7 @@ by (auto simp:finite_rhs_def eqs_def) moreover have "self_contained (eqs (UNIV // (\Lang)))" by (auto simp:self_contained_def eqs_def init_rhs_def classes_of_def lefts_of_def) - ultimately show ?thesis by (simp add:Inv_def) + ultimately show ?thesis by (simp add:invariant_def) qed subsubsection {* @@ -883,15 +764,15 @@ text {* From this point until @{text "iteration_step"}, it is proved - that there exists iteration steps which keep @{text "Inv(ES)"} while + that there exists iteration steps which keep @{text "invariant(ES)"} while decreasing the size of @{text "ES"}. *} -lemma arden_variate_keeps_eq: +lemma arden_op_keeps_eq: assumes l_eq_r: "X = L rhs" and not_empty: "[] \ L (\{r. Trn X r \ rhs})" and finite: "finite rhs" - shows "X = L (arden_variate X rhs)" + shows "X = L (arden_op X rhs)" proof - def A \ "L (\{r. Trn X r \ rhs})" def b \ "rhs - trns_of rhs X" @@ -905,13 +786,13 @@ by (simp only: lang_of_rexp_of finite B_def A_def) finally show ?thesis using l_eq_r not_empty - apply(rule_tac ardens_revised[THEN iffD1]) + apply(rule_tac arden[THEN iffD1]) apply(simp add: A_def) apply(simp) done qed - moreover have "L (arden_variate X rhs) = (B ;; A\)" - by (simp only:arden_variate_def L_rhs_union_distrib lang_of_append_rhs + moreover have "L (arden_op X rhs) = (B ;; A\)" + by (simp only:arden_op_def L_rhs_union_distrib lang_of_append_rhs B_def A_def b_def L_rexp.simps seq_union_distrib_left) ultimately show ?thesis by simp qed @@ -920,9 +801,9 @@ "finite rhs \ finite (append_rhs_rexp rhs r)" by (auto simp:append_rhs_rexp_def) -lemma arden_variate_keeps_finite: - "finite rhs \ finite (arden_variate X rhs)" -by (auto simp:arden_variate_def append_keeps_finite) +lemma arden_op_keeps_finite: + "finite rhs \ finite (arden_op X rhs)" +by (auto simp:arden_op_def append_keeps_finite) lemma append_keeps_nonempty: "rhs_nonempty rhs \ rhs_nonempty (append_rhs_rexp rhs r)" @@ -937,23 +818,23 @@ "\rhs_nonempty rhs; rhs_nonempty rhs'\ \ rhs_nonempty (rhs \ rhs')" by (auto simp:rhs_nonempty_def) -lemma arden_variate_keeps_nonempty: - "rhs_nonempty rhs \ rhs_nonempty (arden_variate X rhs)" -by (simp only:arden_variate_def append_keeps_nonempty nonempty_set_sub) +lemma arden_op_keeps_nonempty: + "rhs_nonempty rhs \ rhs_nonempty (arden_op X rhs)" +by (simp only:arden_op_def append_keeps_nonempty nonempty_set_sub) -lemma rhs_subst_keeps_nonempty: - "\rhs_nonempty rhs; rhs_nonempty xrhs\ \ rhs_nonempty (rhs_subst rhs X xrhs)" -by (simp only:rhs_subst_def append_keeps_nonempty nonempty_set_union nonempty_set_sub) +lemma subst_op_keeps_nonempty: + "\rhs_nonempty rhs; rhs_nonempty xrhs\ \ rhs_nonempty (subst_op rhs X xrhs)" +by (simp only:subst_op_def append_keeps_nonempty nonempty_set_union nonempty_set_sub) -lemma rhs_subst_keeps_eq: +lemma subst_op_keeps_eq: assumes substor: "X = L xrhs" and finite: "finite rhs" - shows "L (rhs_subst rhs X xrhs) = L rhs" (is "?Left = ?Right") + shows "L (subst_op rhs X xrhs) = L rhs" (is "?Left = ?Right") proof- def A \ "L (rhs - trns_of rhs X)" have "?Left = A \ L (append_rhs_rexp xrhs (\{r. Trn X r \ rhs}))" - unfolding rhs_subst_def + unfolding subst_op_def unfolding L_rhs_union_distrib[symmetric] by (simp add: A_def) moreover have "?Right = A \ L ({Trn X r | r. Trn X r \ rhs})" @@ -970,29 +851,29 @@ ultimately show ?thesis by simp qed -lemma rhs_subst_keeps_finite_rhs: - "\finite rhs; finite yrhs\ \ finite (rhs_subst rhs Y yrhs)" -by (auto simp:rhs_subst_def append_keeps_finite) +lemma subst_op_keeps_finite_rhs: + "\finite rhs; finite yrhs\ \ finite (subst_op rhs Y yrhs)" +by (auto simp:subst_op_def append_keeps_finite) -lemma eqs_subst_keeps_finite: +lemma subst_op_all_keeps_finite: assumes finite:"finite (ES:: (string set \ rhs_item set) set)" - shows "finite (eqs_subst ES Y yrhs)" + shows "finite (subst_op_all ES Y yrhs)" proof - - have "finite {(Ya, rhs_subst yrhsa Y yrhs) |Ya yrhsa. (Ya, yrhsa) \ ES}" + have "finite {(Ya, subst_op yrhsa Y yrhs) |Ya yrhsa. (Ya, yrhsa) \ ES}" (is "finite ?A") proof- def eqns' \ "{((Ya::string set), yrhsa)| Ya yrhsa. (Ya, yrhsa) \ ES}" - def h \ "\ ((Ya::string set), yrhsa). (Ya, rhs_subst yrhsa Y yrhs)" + def h \ "\ ((Ya::string set), yrhsa). (Ya, subst_op yrhsa Y yrhs)" have "finite (h ` eqns')" using finite h_def eqns'_def by auto moreover have "?A = h ` eqns'" by (auto simp:h_def eqns'_def) ultimately show ?thesis by auto qed - thus ?thesis by (simp add:eqs_subst_def) + thus ?thesis by (simp add:subst_op_all_def) qed -lemma eqs_subst_keeps_finite_rhs: - "\finite_rhs ES; finite yrhs\ \ finite_rhs (eqs_subst ES Y yrhs)" -by (auto intro:rhs_subst_keeps_finite_rhs simp add:eqs_subst_def finite_rhs_def) +lemma subst_op_all_keeps_finite_rhs: + "\finite_rhs ES; finite yrhs\ \ finite_rhs (subst_op_all ES Y yrhs)" +by (auto intro:subst_op_keeps_finite_rhs simp add:subst_op_all_def finite_rhs_def) lemma append_rhs_keeps_cls: "classes_of (append_rhs_rexp rhs r) = classes_of rhs" @@ -1000,131 +881,131 @@ apply (case_tac xa, auto simp:image_def) by (rule_tac x = "SEQ ra r" in exI, rule_tac x = "Trn x ra" in bexI, simp+) -lemma arden_variate_removes_cl: - "classes_of (arden_variate Y yrhs) = classes_of yrhs - {Y}" -apply (simp add:arden_variate_def append_rhs_keeps_cls trns_of_def) +lemma arden_op_removes_cl: + "classes_of (arden_op Y yrhs) = classes_of yrhs - {Y}" +apply (simp add:arden_op_def append_rhs_keeps_cls trns_of_def) by (auto simp:classes_of_def) lemma lefts_of_keeps_cls: - "lefts_of (eqs_subst ES Y yrhs) = lefts_of ES" -by (auto simp:lefts_of_def eqs_subst_def) + "lefts_of (subst_op_all ES Y yrhs) = lefts_of ES" +by (auto simp:lefts_of_def subst_op_all_def) -lemma rhs_subst_updates_cls: +lemma subst_op_updates_cls: "X \ classes_of xrhs \ - classes_of (rhs_subst rhs X xrhs) = classes_of rhs \ classes_of xrhs - {X}" -apply (simp only:rhs_subst_def append_rhs_keeps_cls + classes_of (subst_op rhs X xrhs) = classes_of rhs \ classes_of xrhs - {X}" +apply (simp only:subst_op_def append_rhs_keeps_cls classes_of_union_distrib[THEN sym]) by (auto simp:classes_of_def trns_of_def) -lemma eqs_subst_keeps_self_contained: +lemma subst_op_all_keeps_self_contained: fixes Y assumes sc: "self_contained (ES \ {(Y, yrhs)})" (is "self_contained ?A") - shows "self_contained (eqs_subst ES Y (arden_variate Y yrhs))" + shows "self_contained (subst_op_all ES Y (arden_op Y yrhs))" (is "self_contained ?B") proof- { fix X xrhs' assume "(X, xrhs') \ ?B" then obtain xrhs - where xrhs_xrhs': "xrhs' = rhs_subst xrhs Y (arden_variate Y yrhs)" - and X_in: "(X, xrhs) \ ES" by (simp add:eqs_subst_def, blast) + where xrhs_xrhs': "xrhs' = subst_op xrhs Y (arden_op Y yrhs)" + and X_in: "(X, xrhs) \ ES" by (simp add:subst_op_all_def, blast) have "classes_of xrhs' \ lefts_of ?B" proof- - have "lefts_of ?B = lefts_of ES" by (auto simp add:lefts_of_def eqs_subst_def) + have "lefts_of ?B = lefts_of ES" by (auto simp add:lefts_of_def subst_op_all_def) moreover have "classes_of xrhs' \ lefts_of ES" proof- have "classes_of xrhs' \ - classes_of xrhs \ classes_of (arden_variate Y yrhs) - {Y}" + classes_of xrhs \ classes_of (arden_op Y yrhs) - {Y}" proof- - have "Y \ classes_of (arden_variate Y yrhs)" - using arden_variate_removes_cl by simp - thus ?thesis using xrhs_xrhs' by (auto simp:rhs_subst_updates_cls) + have "Y \ classes_of (arden_op Y yrhs)" + using arden_op_removes_cl by simp + thus ?thesis using xrhs_xrhs' by (auto simp:subst_op_updates_cls) qed moreover have "classes_of xrhs \ lefts_of ES \ {Y}" using X_in sc apply (simp only:self_contained_def lefts_of_union_distrib[THEN sym]) by (drule_tac x = "(X, xrhs)" in bspec, auto simp:lefts_of_def) - moreover have "classes_of (arden_variate Y yrhs) \ lefts_of ES \ {Y}" + moreover have "classes_of (arden_op Y yrhs) \ lefts_of ES \ {Y}" using sc - by (auto simp add:arden_variate_removes_cl self_contained_def lefts_of_def) + by (auto simp add:arden_op_removes_cl self_contained_def lefts_of_def) ultimately show ?thesis by auto qed ultimately show ?thesis by simp qed - } thus ?thesis by (auto simp only:eqs_subst_def self_contained_def) + } thus ?thesis by (auto simp only:subst_op_all_def self_contained_def) qed -lemma eqs_subst_satisfy_Inv: - assumes Inv_ES: "Inv (ES \ {(Y, yrhs)})" - shows "Inv (eqs_subst ES Y (arden_variate Y yrhs))" +lemma subst_op_all_satisfy_invariant: + assumes invariant_ES: "invariant (ES \ {(Y, yrhs)})" + shows "invariant (subst_op_all ES Y (arden_op Y yrhs))" proof - have finite_yrhs: "finite yrhs" - using Inv_ES by (auto simp:Inv_def finite_rhs_def) + using invariant_ES by (auto simp:invariant_def finite_rhs_def) have nonempty_yrhs: "rhs_nonempty yrhs" - using Inv_ES by (auto simp:Inv_def ardenable_def) + using invariant_ES by (auto simp:invariant_def ardenable_def) have Y_eq_yrhs: "Y = L yrhs" - using Inv_ES by (simp only:Inv_def valid_eqns_def, blast) - have "distinct_equas (eqs_subst ES Y (arden_variate Y yrhs))" - using Inv_ES - by (auto simp:distinct_equas_def eqs_subst_def Inv_def) - moreover have "finite (eqs_subst ES Y (arden_variate Y yrhs))" - using Inv_ES by (simp add:Inv_def eqs_subst_keeps_finite) - moreover have "finite_rhs (eqs_subst ES Y (arden_variate Y yrhs))" + using invariant_ES by (simp only:invariant_def valid_eqns_def, blast) + have "distinct_equas (subst_op_all ES Y (arden_op Y yrhs))" + using invariant_ES + by (auto simp:distinct_equas_def subst_op_all_def invariant_def) + moreover have "finite (subst_op_all ES Y (arden_op Y yrhs))" + using invariant_ES by (simp add:invariant_def subst_op_all_keeps_finite) + moreover have "finite_rhs (subst_op_all ES Y (arden_op Y yrhs))" proof- - have "finite_rhs ES" using Inv_ES - by (simp add:Inv_def finite_rhs_def) - moreover have "finite (arden_variate Y yrhs)" + have "finite_rhs ES" using invariant_ES + by (simp add:invariant_def finite_rhs_def) + moreover have "finite (arden_op Y yrhs)" proof - - have "finite yrhs" using Inv_ES - by (auto simp:Inv_def finite_rhs_def) - thus ?thesis using arden_variate_keeps_finite by simp + have "finite yrhs" using invariant_ES + by (auto simp:invariant_def finite_rhs_def) + thus ?thesis using arden_op_keeps_finite by simp qed ultimately show ?thesis - by (simp add:eqs_subst_keeps_finite_rhs) + by (simp add:subst_op_all_keeps_finite_rhs) qed - moreover have "ardenable (eqs_subst ES Y (arden_variate Y yrhs))" + moreover have "ardenable (subst_op_all ES Y (arden_op Y yrhs))" proof - { fix X rhs assume "(X, rhs) \ ES" - hence "rhs_nonempty rhs" using prems Inv_ES - by (simp add:Inv_def ardenable_def) + hence "rhs_nonempty rhs" using prems invariant_ES + by (simp add:invariant_def ardenable_def) with nonempty_yrhs - have "rhs_nonempty (rhs_subst rhs Y (arden_variate Y yrhs))" + have "rhs_nonempty (subst_op rhs Y (arden_op Y yrhs))" by (simp add:nonempty_yrhs - rhs_subst_keeps_nonempty arden_variate_keeps_nonempty) - } thus ?thesis by (auto simp add:ardenable_def eqs_subst_def) + subst_op_keeps_nonempty arden_op_keeps_nonempty) + } thus ?thesis by (auto simp add:ardenable_def subst_op_all_def) qed - moreover have "valid_eqns (eqs_subst ES Y (arden_variate Y yrhs))" + moreover have "valid_eqns (subst_op_all ES Y (arden_op Y yrhs))" proof- - have "Y = L (arden_variate Y yrhs)" - using Y_eq_yrhs Inv_ES finite_yrhs nonempty_yrhs - by (rule_tac arden_variate_keeps_eq, (simp add:rexp_of_empty)+) - thus ?thesis using Inv_ES + have "Y = L (arden_op Y yrhs)" + using Y_eq_yrhs invariant_ES finite_yrhs nonempty_yrhs + by (rule_tac arden_op_keeps_eq, (simp add:rexp_of_empty)+) + thus ?thesis using invariant_ES by (clarsimp simp add:valid_eqns_def - eqs_subst_def rhs_subst_keeps_eq Inv_def finite_rhs_def + subst_op_all_def subst_op_keeps_eq invariant_def finite_rhs_def simp del:L_rhs.simps) qed moreover have - non_empty_subst: "non_empty (eqs_subst ES Y (arden_variate Y yrhs))" - using Inv_ES by (auto simp:Inv_def non_empty_def eqs_subst_def) + non_empty_subst: "non_empty (subst_op_all ES Y (arden_op Y yrhs))" + using invariant_ES by (auto simp:invariant_def non_empty_def subst_op_all_def) moreover - have self_subst: "self_contained (eqs_subst ES Y (arden_variate Y yrhs))" - using Inv_ES eqs_subst_keeps_self_contained by (simp add:Inv_def) - ultimately show ?thesis using Inv_ES by (simp add:Inv_def) + have self_subst: "self_contained (subst_op_all ES Y (arden_op Y yrhs))" + using invariant_ES subst_op_all_keeps_self_contained by (simp add:invariant_def) + ultimately show ?thesis using invariant_ES by (simp add:invariant_def) qed -lemma eqs_subst_card_le: +lemma subst_op_all_card_le: assumes finite: "finite (ES::(string set \ rhs_item set) set)" - shows "card (eqs_subst ES Y yrhs) <= card ES" + shows "card (subst_op_all ES Y yrhs) <= card ES" proof- - def f \ "\ x. ((fst x)::string set, rhs_subst (snd x) Y yrhs)" - have "eqs_subst ES Y yrhs = f ` ES" - apply (auto simp:eqs_subst_def f_def image_def) + def f \ "\ x. ((fst x)::string set, subst_op (snd x) Y yrhs)" + have "subst_op_all ES Y yrhs = f ` ES" + apply (auto simp:subst_op_all_def f_def image_def) by (rule_tac x = "(Ya, yrhsa)" in bexI, simp+) thus ?thesis using finite by (auto intro:card_image_le) qed -lemma eqs_subst_cls_remains: - "(X, xrhs) \ ES \ \ xrhs'. (X, xrhs') \ (eqs_subst ES Y yrhs)" -by (auto simp:eqs_subst_def) +lemma subst_op_all_cls_remains: + "(X, xrhs) \ ES \ \ xrhs'. (X, xrhs') \ (subst_op_all ES Y yrhs)" +by (auto simp:subst_op_all_def) lemma card_noteq_1_has_more: assumes card:"card S \ 1" @@ -1143,31 +1024,31 @@ qed lemma iteration_step: - assumes Inv_ES: "Inv ES" + assumes invariant_ES: "invariant ES" and X_in_ES: "(X, xrhs) \ ES" and not_T: "card ES \ 1" - shows "\ ES'. (Inv ES' \ (\ xrhs'.(X, xrhs') \ ES')) \ + shows "\ ES'. (invariant ES' \ (\ xrhs'.(X, xrhs') \ ES')) \ (card ES', card ES) \ less_than" (is "\ ES'. ?P ES'") proof - - have finite_ES: "finite ES" using Inv_ES by (simp add:Inv_def) + have finite_ES: "finite ES" using invariant_ES by (simp add:invariant_def) then obtain Y yrhs where Y_in_ES: "(Y, yrhs) \ ES" and not_eq: "(X, xrhs) \ (Y, yrhs)" using not_T X_in_ES by (drule_tac card_noteq_1_has_more, auto) def ES' == "ES - {(Y, yrhs)}" - let ?ES'' = "eqs_subst ES' Y (arden_variate Y yrhs)" + let ?ES'' = "subst_op_all ES' Y (arden_op Y yrhs)" have "?P ?ES''" proof - - have "Inv ?ES''" using Y_in_ES Inv_ES - by (rule_tac eqs_subst_satisfy_Inv, simp add:ES'_def insert_absorb) + have "invariant ?ES''" using Y_in_ES invariant_ES + by (rule_tac subst_op_all_satisfy_invariant, simp add:ES'_def insert_absorb) moreover have "\xrhs'. (X, xrhs') \ ?ES''" using not_eq X_in_ES - by (rule_tac ES = ES' in eqs_subst_cls_remains, auto simp add:ES'_def) + by (rule_tac ES = ES' in subst_op_all_cls_remains, auto simp add:ES'_def) moreover have "(card ?ES'', card ES) \ less_than" proof - have "finite ES'" using finite_ES ES'_def by auto moreover have "card ES' < card ES" using finite_ES Y_in_ES by (auto simp:ES'_def card_gt_0_iff intro:diff_Suc_less) ultimately show ?thesis - by (auto dest:eqs_subst_card_le elim:le_less_trans) + by (auto dest:subst_op_all_card_le elim:le_less_trans) qed ultimately show ?thesis by simp qed @@ -1184,10 +1065,10 @@ *} lemma iteration_conc: - assumes history: "Inv ES" + assumes history: "invariant ES" and X_in_ES: "\ xrhs. (X, xrhs) \ ES" shows - "\ ES'. (Inv ES' \ (\ xrhs'. (X, xrhs') \ ES')) \ card ES' = 1" + "\ ES'. (invariant ES' \ (\ xrhs'. (X, xrhs') \ ES')) \ card ES' = 1" (is "\ ES'. ?P ES'") proof (cases "card ES = 1") case True @@ -1201,28 +1082,28 @@ lemma last_cl_exists_rexp: assumes ES_single: "ES = {(X, xrhs)}" - and Inv_ES: "Inv ES" + and invariant_ES: "invariant ES" shows "\ (r::rexp). L r = X" (is "\ r. ?P r") proof- - def A \ "arden_variate X xrhs" + def A \ "arden_op X xrhs" have "?P (\{r. Lam r \ A})" proof - have "L (\{r. Lam r \ A}) = L ({Lam r | r. Lam r \ A})" proof(rule rexp_of_lam_eq_lam_set) show "finite A" unfolding A_def - using Inv_ES ES_single - by (rule_tac arden_variate_keeps_finite) - (auto simp add: Inv_def finite_rhs_def) + using invariant_ES ES_single + by (rule_tac arden_op_keeps_finite) + (auto simp add: invariant_def finite_rhs_def) qed also have "\ = L A" proof- have "{Lam r | r. Lam r \ A} = A" proof- - have "classes_of A = {}" using Inv_ES ES_single + have "classes_of A = {}" using invariant_ES ES_single unfolding A_def - by (simp add:arden_variate_removes_cl - self_contained_def Inv_def lefts_of_def) + by (simp add:arden_op_removes_cl + self_contained_def invariant_def lefts_of_def) thus ?thesis unfolding A_def by (auto simp only: classes_of_def, case_tac x, auto) @@ -1231,15 +1112,15 @@ qed also have "\ = X" unfolding A_def - proof(rule arden_variate_keeps_eq [THEN sym]) - show "X = L xrhs" using Inv_ES ES_single - by (auto simp only:Inv_def valid_eqns_def) + proof(rule arden_op_keeps_eq [THEN sym]) + show "X = L xrhs" using invariant_ES ES_single + by (auto simp only:invariant_def valid_eqns_def) next - from Inv_ES ES_single show "[] \ L (\{r. Trn X r \ xrhs})" - by(simp add:Inv_def ardenable_def rexp_of_empty finite_rhs_def) + from invariant_ES ES_single show "[] \ L (\{r. Trn X r \ xrhs})" + by(simp add:invariant_def ardenable_def rexp_of_empty finite_rhs_def) next - from Inv_ES ES_single show "finite xrhs" - by (simp add:Inv_def finite_rhs_def) + from invariant_ES ES_single show "finite xrhs" + by (simp add:invariant_def finite_rhs_def) qed finally show ?thesis by simp qed @@ -1253,14 +1134,14 @@ proof - from X_in_CS have "\ xrhs. (X, xrhs) \ (eqs (UNIV // (\Lang)))" by (auto simp:eqs_def init_rhs_def) - then obtain ES xrhs where Inv_ES: "Inv ES" + then obtain ES xrhs where invariant_ES: "invariant ES" and X_in_ES: "(X, xrhs) \ ES" and card_ES: "card ES = 1" - using finite_CS X_in_CS init_ES_satisfy_Inv iteration_conc + using finite_CS X_in_CS init_ES_satisfy_invariant iteration_conc by blast hence ES_single_equa: "ES = {(X, xrhs)}" - by (auto simp:Inv_def dest!:card_Suc_Diff1 simp:card_eq_0_iff) - thus ?thesis using Inv_ES + by (auto simp:invariant_def dest!:card_Suc_Diff1 simp:card_eq_0_iff) + thus ?thesis using invariant_ES by (rule last_cl_exists_rexp) qed diff -r a3e0056c228b -r 6457e668dee5 Paper/Paper.thy --- a/Paper/Paper.thy Wed Feb 09 03:52:28 2011 +0000 +++ b/Paper/Paper.thy Wed Feb 09 04:50:18 2011 +0000 @@ -238,24 +238,24 @@ version of Arden's lemma. \begin{lemma}[Reverse Arden's Lemma]\label{arden}\mbox{}\\ - If @{thm (prem 1) ardens_revised} then - @{thm (lhs) ardens_revised} has the unique solution - @{thm (rhs) ardens_revised}. + If @{thm (prem 1) arden} then + @{thm (lhs) arden} has the unique solution + @{thm (rhs) arden}. \end{lemma} \begin{proof} - For the right-to-left direction we assume @{thm (rhs) ardens_revised} and show - that @{thm (lhs) ardens_revised} holds. From Prop.~\ref{langprops}@{text "(i)"} + For the right-to-left direction we assume @{thm (rhs) arden} and show + that @{thm (lhs) arden} holds. From Prop.~\ref{langprops}@{text "(i)"} we have @{term "A\ = {[]} \ A ;; A\"}, which is equal to @{term "A\ = {[]} \ A\ ;; A"}. Adding @{text B} to both sides gives @{term "B ;; A\ = B ;; ({[]} \ A\ ;; A)"}, whose right-hand side is equal to @{term "(B ;; A\) ;; A \ B"}. This completes this direction. - For the other direction we assume @{thm (lhs) ardens_revised}. By a simple induction + For the other direction we assume @{thm (lhs) arden}. By a simple induction on @{text n}, we can establish the property \begin{center} - @{text "(*)"}\hspace{5mm} @{thm (concl) ardens_helper} + @{text "(*)"}\hspace{5mm} @{thm (concl) arden_helper} \end{center} \noindent @@ -263,7 +263,7 @@ all @{text n}. From this we can infer @{term "B ;; A\ \ X"} using the definition of @{text "\"}. For the inclusion in the other direction we assume a string @{text s} - with length @{text k} is element in @{text X}. Since @{thm (prem 1) ardens_revised} + with length @{text k} is element in @{text X}. Since @{thm (prem 1) arden} we know by Prop.~\ref{langprops}@{text "(ii)"} that @{term "s \ X ;; (A \ Suc k)"} since its length is only @{text k} (the strings in @{term "X ;; (A \ Suc k)"} are all longer). @@ -392,8 +392,8 @@ equational system as follows \begin{center} - @{thm L_rhs_e.simps(2)[where X="Y" and r="r", THEN eq_reflection]}\hspace{10mm} - @{thm L_rhs_e.simps(1)[where r="r", THEN eq_reflection]} + @{thm L_rhs_item.simps(2)[where X="Y" and r="r", THEN eq_reflection]}\hspace{10mm} + @{thm L_rhs_item.simps(1)[where r="r", THEN eq_reflection]} \end{center} \noindent