Paper/Paper.thy
changeset 170 b1258b7d2789
parent 166 7743d2ad71d1
child 334 d47c2143ab8a
equal deleted inserted replaced
169:b794db0b79db 170:b1258b7d2789
    13   "EClass x R \<equiv> R `` {x}"
    13   "EClass x R \<equiv> R `` {x}"
    14 
    14 
    15 abbreviation
    15 abbreviation
    16   "Append_rexp2 r_itm r == Append_rexp r r_itm"
    16   "Append_rexp2 r_itm r == Append_rexp r r_itm"
    17 
    17 
       
    18 abbreviation
       
    19   "pow" (infixl "\<up>" 100)
       
    20 where
       
    21   "A \<up> n \<equiv> A ^^ n"
       
    22 
       
    23 
       
    24 abbreviation "NULL \<equiv> Zero"
       
    25 abbreviation "EMPTY \<equiv> One"
       
    26 abbreviation "CHAR \<equiv> Atom"
       
    27 abbreviation "ALT \<equiv> Plus"
       
    28 abbreviation "SEQ \<equiv> Times"
       
    29 abbreviation "STAR \<equiv> Star"
       
    30 
       
    31 
       
    32 ML {* @{term "op ^^"} *}
       
    33 
    18 notation (latex output)
    34 notation (latex output)
    19   str_eq_rel ("\<approx>\<^bsub>_\<^esub>") and
    35   str_eq_rel ("\<approx>\<^bsub>_\<^esub>") and
    20   str_eq ("_ \<approx>\<^bsub>_\<^esub> _") and
    36   str_eq ("_ \<approx>\<^bsub>_\<^esub> _") and
    21   Seq (infixr "\<cdot>" 100) and
    37   conc (infixr "\<cdot>" 100) and
    22   Star ("_\<^bsup>\<star>\<^esup>") and
    38   star ("_\<^bsup>\<star>\<^esup>") and
    23   pow ("_\<^bsup>_\<^esup>" [100, 100] 100) and
    39   pow ("_\<^bsup>_\<^esup>" [100, 100] 100) and
    24   Suc ("_+1" [100] 100) and
    40   Suc ("_+1" [100] 100) and
    25   quotient ("_ \<^raw:\ensuremath{\!\sslash\!}> _" [90, 90] 90) and
    41   quotient ("_ \<^raw:\ensuremath{\!\sslash\!}> _" [90, 90] 90) and
    26   REL ("\<approx>") and
    42   REL ("\<approx>") and
    27   UPLUS ("_ \<^raw:\ensuremath{\uplus}> _" [90, 90] 90) and
    43   UPLUS ("_ \<^raw:\ensuremath{\uplus}> _" [90, 90] 90) and
    28   L_rexp ("\<^raw:\ensuremath{\cal{L}}>'(_')" [0] 101) and
    44   lang ("\<^raw:\ensuremath{\cal{L}}>'(_')" [0] 101) and
    29   Lam ("\<lambda>'(_')" [100] 100) and 
    45   Lam ("\<lambda>'(_')" [100] 100) and 
    30   Trn ("'(_, _')" [100, 100] 100) and 
    46   Trn ("'(_, _')" [100, 100] 100) and 
    31   EClass ("\<lbrakk>_\<rbrakk>\<^bsub>_\<^esub>" [100, 100] 100) and
    47   EClass ("\<lbrakk>_\<rbrakk>\<^bsub>_\<^esub>" [100, 100] 100) and
    32   transition ("_ \<^raw:\ensuremath{\stackrel{\text{>_\<^raw:}}{\Longmapsto}}> _" [100, 100, 100] 100) and
    48   transition ("_ \<^raw:\ensuremath{\stackrel{\text{>_\<^raw:}}{\Longmapsto}}> _" [100, 100, 100] 100) and
    33   Setalt ("\<^raw:\ensuremath{\bigplus}>_" [1000] 999) and
    49   Setalt ("\<^raw:\ensuremath{\bigplus}>_" [1000] 999) and
    34   Append_rexp2 ("_ \<^raw:\ensuremath{\triangleleft}> _" [100, 100] 100) and
    50   Append_rexp2 ("_ \<^raw:\ensuremath{\triangleleft}> _" [100, 100] 100) and
    35   Append_rexp_rhs ("_ \<^raw:\ensuremath{\triangleleft}> _" [100, 100] 50) and
    51   Append_rexp_rhs ("_ \<^raw:\ensuremath{\triangleleft}> _" [100, 100] 50) and
    36   
    52   
    37   uminus ("\<^raw:\ensuremath{\overline{>_\<^raw:}}>" [100] 100) and
    53   uminus ("\<^raw:\ensuremath{\overline{>_\<^raw:}}>" [100] 100) and
    38   tag_str_ALT ("tag\<^isub>A\<^isub>L\<^isub>T _ _" [100, 100] 100) and
    54   tag_str_Plus ("tag\<^isub>A\<^isub>L\<^isub>T _ _" [100, 100] 100) and
    39   tag_str_ALT ("tag\<^isub>A\<^isub>L\<^isub>T _ _ _" [100, 100, 100] 100) and
    55   tag_str_Plus ("tag\<^isub>A\<^isub>L\<^isub>T _ _ _" [100, 100, 100] 100) and
    40   tag_str_SEQ ("tag\<^isub>S\<^isub>E\<^isub>Q _ _" [100, 100] 100) and
    56   tag_str_Times ("tag\<^isub>S\<^isub>E\<^isub>Q _ _" [100, 100] 100) and
    41   tag_str_SEQ ("tag\<^isub>S\<^isub>E\<^isub>Q _ _ _" [100, 100, 100] 100) and
    57   tag_str_Times ("tag\<^isub>S\<^isub>E\<^isub>Q _ _ _" [100, 100, 100] 100) and
    42   tag_str_STAR ("tag\<^isub>S\<^isub>T\<^isub>A\<^isub>R _" [100] 100) and
    58   tag_str_Star ("tag\<^isub>S\<^isub>T\<^isub>A\<^isub>R _" [100] 100) and
    43   tag_str_STAR ("tag\<^isub>S\<^isub>T\<^isub>A\<^isub>R _ _" [100, 100] 100)
    59   tag_str_Star ("tag\<^isub>S\<^isub>T\<^isub>A\<^isub>R _ _" [100, 100] 100)
    44 
    60 
    45 lemma meta_eq_app:
    61 lemma meta_eq_app:
    46   shows "f \<equiv> \<lambda>x. g x \<Longrightarrow> f x \<equiv> g x"
    62   shows "f \<equiv> \<lambda>x. g x \<Longrightarrow> f x \<equiv> g x"
    47   by auto
    63   by auto
    48 
    64 
       
    65 lemma conc_def':
       
    66   "A \<cdot> B = {s\<^isub>1 @ s\<^isub>2 | s\<^isub>1 s\<^isub>2. s\<^isub>1 \<in> A \<and> s\<^isub>2 \<in> B}"
       
    67 unfolding conc_def by simp
       
    68 
    49 (* THEOREMS *)
    69 (* THEOREMS *)
       
    70 
       
    71 lemma conc_Union_left: 
       
    72   shows "B \<cdot> (\<Union>n. A \<up> n) = (\<Union>n. B \<cdot> (A \<up> n))"
       
    73 unfolding conc_def by auto
       
    74 
    50 notation (Rule output)
    75 notation (Rule output)
    51   "==>"  ("\<^raw:\mbox{}\inferrule{\mbox{>_\<^raw:}}>\<^raw:{\mbox{>_\<^raw:}}>")
    76   "==>"  ("\<^raw:\mbox{}\inferrule{\mbox{>_\<^raw:}}>\<^raw:{\mbox{>_\<^raw:}}>")
    52 
    77 
    53 syntax (Rule output)
    78 syntax (Rule output)
    54   "_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop"
    79   "_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop"
   275   Isabelle/HOL as @{term "UNIV::string set"}. The concatenation of two languages 
   300   Isabelle/HOL as @{term "UNIV::string set"}. The concatenation of two languages 
   276   is written @{term "A \<cdot> B"} and a language raised to the power @{text n} is written 
   301   is written @{term "A \<cdot> B"} and a language raised to the power @{text n} is written 
   277   @{term "A \<up> n"}. They are defined as usual
   302   @{term "A \<up> n"}. They are defined as usual
   278 
   303 
   279   \begin{center}
   304   \begin{center}
   280   @{thm Seq_def[THEN eq_reflection, where A1="A" and B1="B"]}
   305   @{thm conc_def'[THEN eq_reflection, where A1="A" and B1="B"]}
   281   \hspace{7mm}
   306   \hspace{7mm}
   282   @{thm pow.simps(1)[THEN eq_reflection, where A1="A"]}
   307   @{thm lang_pow.simps(1)[THEN eq_reflection, where A1="A"]}
   283   \hspace{7mm}
   308   \hspace{7mm}
   284   @{thm pow.simps(2)[THEN eq_reflection, where A1="A" and n1="n"]}
   309   @{thm lang_pow.simps(2)[THEN eq_reflection, where A1="A" and n1="n"]}
   285   \end{center}
   310   \end{center}
   286 
   311 
   287   \noindent
   312   \noindent
   288   where @{text "@"} is the list-append operation. The Kleene-star of a language @{text A}
   313   where @{text "@"} is the list-append operation. The Kleene-star of a language @{text A}
   289   is defined as the union over all powers, namely @{thm Star_def}. In the paper
   314   is defined as the union over all powers, namely @{thm star_def}. In the paper
   290   we will make use of the following properties of these constructions.
   315   we will make use of the following properties of these constructions.
   291   
   316   
   292   \begin{proposition}\label{langprops}\mbox{}\\
   317   \begin{proposition}\label{langprops}\mbox{}\\
   293   \begin{tabular}{@ {}ll}
   318   \begin{tabular}{@ {}ll}
   294   (i)   & @{thm star_cases}     \\ 
   319   (i)   & @{thm star_cases}     \\ 
   295   (ii)  & @{thm[mode=IfThen] pow_length}\\
   320   (ii)  & @{thm[mode=IfThen] pow_length}\\
   296   (iii) & @{thm seq_Union_left} \\ 
   321   (iii) & @{thm conc_Union_left} \\ 
   297   \end{tabular}
   322   \end{tabular}
   298   \end{proposition}
   323   \end{proposition}
   299 
   324 
   300   \noindent
   325   \noindent
   301   In @{text "(ii)"} we use the notation @{term "length s"} for the length of a
   326   In @{text "(ii)"} we use the notation @{term "length s"} for the length of a
   370   and the language matched by a regular expression is defined as
   395   and the language matched by a regular expression is defined as
   371 
   396 
   372   \begin{center}
   397   \begin{center}
   373   \begin{tabular}{c@ {\hspace{10mm}}c}
   398   \begin{tabular}{c@ {\hspace{10mm}}c}
   374   \begin{tabular}{rcl}
   399   \begin{tabular}{rcl}
   375   @{thm (lhs) L_rexp.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) L_rexp.simps(1)}\\
   400   @{thm (lhs) lang.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(1)}\\
   376   @{thm (lhs) L_rexp.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) L_rexp.simps(2)}\\
   401   @{thm (lhs) lang.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(2)}\\
   377   @{thm (lhs) L_rexp.simps(3)[where c="c"]} & @{text "\<equiv>"} & @{thm (rhs) L_rexp.simps(3)[where c="c"]}\\
   402   @{thm (lhs) lang.simps(3)[where a="c"]} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(3)[where a="c"]}\\
   378   \end{tabular}
   403   \end{tabular}
   379   &
   404   &
   380   \begin{tabular}{rcl}
   405   \begin{tabular}{rcl}
   381   @{thm (lhs) L_rexp.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} & @{text "\<equiv>"} &
   406   @{thm (lhs) lang.simps(4)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]} & @{text "\<equiv>"} &
   382        @{thm (rhs) L_rexp.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\
   407        @{thm (rhs) lang.simps(4)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]}\\
   383   @{thm (lhs) L_rexp.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} & @{text "\<equiv>"} &
   408   @{thm (lhs) lang.simps(5)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]} & @{text "\<equiv>"} &
   384        @{thm (rhs) L_rexp.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\
   409        @{thm (rhs) lang.simps(5)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]}\\
   385   @{thm (lhs) L_rexp.simps(6)[where r="r"]} & @{text "\<equiv>"} &
   410   @{thm (lhs) lang.simps(6)[where r="r"]} & @{text "\<equiv>"} &
   386       @{thm (rhs) L_rexp.simps(6)[where r="r"]}\\
   411       @{thm (rhs) lang.simps(6)[where r="r"]}\\
   387   \end{tabular}
   412   \end{tabular}
   388   \end{tabular}
   413   \end{tabular}
   389   \end{center}
   414   \end{center}
   390 
   415 
   391   Given a finite set of regular expressions @{text rs}, we will make use of the operation of generating 
   416   Given a finite set of regular expressions @{text rs}, we will make use of the operation of generating 
   526   Overloading the function @{text \<calL>} for the two kinds of terms in the
   551   Overloading the function @{text \<calL>} for the two kinds of terms in the
   527   equational system, we have
   552   equational system, we have
   528   
   553   
   529   \begin{center}
   554   \begin{center}
   530   @{text "\<calL>(Y, r) \<equiv>"} %
   555   @{text "\<calL>(Y, r) \<equiv>"} %
   531   @{thm (rhs) L_trm.simps(2)[where X="Y" and r="r", THEN eq_reflection]}\hspace{10mm}
   556   @{thm (rhs) lang_trm.simps(2)[where X="Y" and r="r", THEN eq_reflection]}\hspace{10mm}
   532   @{thm L_trm.simps(1)[where r="r", THEN eq_reflection]}
   557   @{thm lang_trm.simps(1)[where r="r", THEN eq_reflection]}
   533   \end{center}
   558   \end{center}
   534 
   559 
   535   \noindent
   560   \noindent
   536   and we can prove for @{text "X\<^isub>2\<^isub>.\<^isub>.\<^isub>n"} that the following equations
   561   and we can prove for @{text "X\<^isub>2\<^isub>.\<^isub>.\<^isub>n"} that the following equations
   537   %
   562   %
   566   & & @{text "then"}~@{term "{Trn Y (CHAR c) | Y c. Y \<in> CS \<and> Y \<Turnstile>c\<Rightarrow> X} \<union> {Lam EMPTY}"}\\
   591   & & @{text "then"}~@{term "{Trn Y (CHAR c) | Y c. Y \<in> CS \<and> Y \<Turnstile>c\<Rightarrow> X} \<union> {Lam EMPTY}"}\\
   567   & & @{text "else"}~@{term "{Trn Y (CHAR c)| Y c. Y \<in> CS \<and> Y \<Turnstile>c\<Rightarrow> X}"}\\
   592   & & @{text "else"}~@{term "{Trn Y (CHAR c)| Y c. Y \<in> CS \<and> Y \<Turnstile>c\<Rightarrow> X}"}\\
   568   @{thm (lhs) Init_def}     & @{text "\<equiv>"} & @{thm (rhs) Init_def}
   593   @{thm (lhs) Init_def}     & @{text "\<equiv>"} & @{thm (rhs) Init_def}
   569   \end{tabular}}
   594   \end{tabular}}
   570   \end{equation}
   595   \end{equation}
   571 
   596 *}(*<*)
   572   
   597 
   573 
   598 lemma test:
       
   599   assumes X_in_eqs: "(X, rhs) \<in> Init (UNIV // \<approx>A)"
       
   600   shows "X = \<Union> (lang_trm `  rhs)"
       
   601 using assms l_eq_r_in_eqs by (simp)
       
   602 
       
   603 (*>*)text {*
   574   \noindent
   604   \noindent
   575   Because we use sets of terms 
   605   Because we use sets of terms 
   576   for representing the right-hand sides of equations, we can 
   606   for representing the right-hand sides of equations, we can 
   577   prove \eqref{inv1} and \eqref{inv2} more concisely as
   607   prove \eqref{inv1} and \eqref{inv2} more concisely as
   578   %
   608   %
   924   The cases for @{const NULL}, @{const EMPTY} and @{const CHAR} are routine, because 
   954   The cases for @{const NULL}, @{const EMPTY} and @{const CHAR} are routine, because 
   925   we can easily establish that
   955   we can easily establish that
   926 
   956 
   927   \begin{center}
   957   \begin{center}
   928   \begin{tabular}{l}
   958   \begin{tabular}{l}
   929   @{thm quot_null_eq}\\
   959   @{thm quot_zero_eq}\\
   930   @{thm quot_empty_subset}\\
   960   @{thm quot_one_subset}\\
   931   @{thm quot_char_subset}
   961   @{thm quot_atom_subset}
   932   \end{tabular}
   962   \end{tabular}
   933   \end{center}
   963   \end{center}
   934 
   964 
   935   \noindent
   965   \noindent
   936   hold, which shows that @{term "UNIV // \<approx>(L r)"} must be finite.\qed
   966   hold, which shows that @{term "UNIV // \<approx>(L r)"} must be finite.\qed
  1019 
  1049 
  1020   \begin{proof}[@{const "ALT"}-Case] 
  1050   \begin{proof}[@{const "ALT"}-Case] 
  1021   We take as tagging-function 
  1051   We take as tagging-function 
  1022   %
  1052   %
  1023   \begin{center}
  1053   \begin{center}
  1024   @{thm tag_str_ALT_def[where A="A" and B="B", THEN meta_eq_app]}
  1054   @{thm tag_str_Plus_def[where A="A" and B="B", THEN meta_eq_app]}
  1025   \end{center}
  1055   \end{center}
  1026 
  1056 
  1027   \noindent
  1057   \noindent
  1028   where @{text "A"} and @{text "B"} are some arbitrary languages.
  1058   where @{text "A"} and @{text "B"} are some arbitrary languages.
  1029   We can show in general, if @{term "finite (UNIV // \<approx>A)"} and @{term "finite (UNIV // \<approx>B)"}
  1059   We can show in general, if @{term "finite (UNIV // \<approx>A)"} and @{term "finite (UNIV // \<approx>B)"}
  1152   or @{text x} and a prefix of @{text "z"} is in @{text A} and the rest in @{text B} (second picture).
  1182   or @{text x} and a prefix of @{text "z"} is in @{text A} and the rest in @{text B} (second picture).
  1153   In both cases we have to show that @{term "y @ z \<in> A \<cdot> B"}. For this we use the 
  1183   In both cases we have to show that @{term "y @ z \<in> A \<cdot> B"}. For this we use the 
  1154   following tagging-function
  1184   following tagging-function
  1155   %
  1185   %
  1156   \begin{center}
  1186   \begin{center}
  1157   @{thm tag_str_SEQ_def[where ?L1.0="A" and ?L2.0="B", THEN meta_eq_app]}
  1187   @{thm tag_str_Times_def[where ?L1.0="A" and ?L2.0="B", THEN meta_eq_app]}
  1158   \end{center}
  1188   \end{center}
  1159 
  1189 
  1160   \noindent
  1190   \noindent
  1161   with the idea that in the first split we have to make sure that @{text "(x - x') @ z"}
  1191   with the idea that in the first split we have to make sure that @{text "(x - x') @ z"}
  1162   is in the language @{text B}.
  1192   is in the language @{text B}.
  1266 
  1296 
  1267   In order to show that @{term "x @ z \<in> A\<star>"} implies @{term "y @ z \<in> A\<star>"}, we use
  1297   In order to show that @{term "x @ z \<in> A\<star>"} implies @{term "y @ z \<in> A\<star>"}, we use
  1268   the following tagging-function:
  1298   the following tagging-function:
  1269   %
  1299   %
  1270   \begin{center}
  1300   \begin{center}
  1271   @{thm tag_str_STAR_def[where ?L1.0="A", THEN meta_eq_app]}\smallskip
  1301   @{thm tag_str_Star_def[where ?L1.0="A", THEN meta_eq_app]}\smallskip
  1272   \end{center}
  1302   \end{center}
  1273 
  1303 
  1274   \begin{proof}[@{const STAR}-Case]
  1304   \begin{proof}[@{const STAR}-Case]
  1275   If @{term "finite (UNIV // \<approx>A)"} 
  1305   If @{term "finite (UNIV // \<approx>A)"} 
  1276   then @{term "finite (Pow (UNIV // \<approx>A))"} holds. The range of
  1306   then @{term "finite (Pow (UNIV // \<approx>A))"} holds. The range of