293 lexing. Berghofer and Reiter \cite{BerghoferReiter09} formalise automata |
293 lexing. Berghofer and Reiter \cite{BerghoferReiter09} formalise automata |
294 working over bit strings in the context of Presburger arithmetic. The only |
294 working over bit strings in the context of Presburger arithmetic. The only |
295 larger formalisations of automata theory are carried out in Nuprl |
295 larger formalisations of automata theory are carried out in Nuprl |
296 \cite{Constable00} and in Coq \cite{Filliatre97}. |
296 \cite{Constable00} and in Coq \cite{Filliatre97}. |
297 |
297 |
298 Also one might consider automata theory as well-worn stock material where |
298 Also one might consider automata theory as a well-worn stock subject where |
299 everything is crystal clear. However, paper proofs about automata often |
299 everything is crystal clear. However, paper proofs about automata often |
300 involve subtle side-conditions which are easily overlooked, but which make |
300 involve subtle side-conditions which are easily overlooked, but which make |
301 formal reasoning rather painful. For example Kozen's proof of the |
301 formal reasoning rather painful. For example Kozen's proof of the |
302 Myhill-Nerode theorem requires that the automata do not have inaccessible |
302 Myhill-Nerode theorem requires that the automata do not have inaccessible |
303 states \cite{Kozen97}. Another subtle side-condition is completeness of |
303 states \cite{Kozen97}. Another subtle side-condition is completeness of |
304 automata: automata need to have total transition functions and at most one |
304 automata, that is automata need to have total transition functions and at most one |
305 `sink' state from which there is no connection to a final state (Brozowski |
305 `sink' state from which there is no connection to a final state (Brozowski |
306 mentions this side-condition in connection with state complexity |
306 mentions this side-condition in the context of state complexity |
307 \cite{Brozowski10}). Such side-conditions mean that if we define a regular |
307 of automata \cite{Brozowski10}). Such side-conditions mean that if we define a regular |
308 language as one for which there exists \emph{a} finite automaton that |
308 language as one for which there exists \emph{a} finite automaton that |
309 recognises all its strings (Def.~\ref{baddef}), then we need a lemma which |
309 recognises all its strings (see Def.~\ref{baddef}), then we need a lemma which |
310 ensures that another equivalent can be found satisfying the |
310 ensures that another equivalent can be found satisfying the |
311 side-condition. Unfortunately, such `little' and `obvious' lemmas make |
311 side-condition. Unfortunately, such `little' and `obvious' lemmas make |
312 formalisations of automata theory hair-pulling experiences. |
312 a formalisation of automata theory a hair-pulling experience. |
313 |
313 |
314 |
314 |
315 In this paper, we will not attempt to formalise automata theory in |
315 In this paper, we will not attempt to formalise automata theory in |
316 Isabelle/HOL nor will we attempt to formalise automata proofs from the |
316 Isabelle/HOL nor will we attempt to formalise automata proofs from the |
317 literature, but take a different approach to regular languages than is |
317 literature, but take a different approach to regular languages than is |
360 section {* Preliminaries *} |
360 section {* Preliminaries *} |
361 |
361 |
362 text {* |
362 text {* |
363 \noindent |
363 \noindent |
364 Strings in Isabelle/HOL are lists of characters with the \emph{empty string} |
364 Strings in Isabelle/HOL are lists of characters with the \emph{empty string} |
365 being represented by the empty list, written @{term "[]"}. \emph{Languages} |
365 being represented by the empty list, written @{term "[]"}. We assume there |
366 are sets of strings. The language containing all strings is written in |
366 are only finitely many different characters. \emph{Languages} are sets of |
367 Isabelle/HOL as @{term "UNIV::string set"}. The concatenation of two languages |
367 strings. The language containing all strings is written in Isabelle/HOL as |
368 is written @{term "A \<cdot> B"} and a language raised to the power @{text n} is written |
368 @{term "UNIV::string set"}. The concatenation of two languages is written |
|
369 @{term "A \<cdot> B"} and a language raised to the power @{text n} is written |
369 @{term "A \<up> n"}. They are defined as usual |
370 @{term "A \<up> n"}. They are defined as usual |
370 |
371 |
371 \begin{center} |
372 \begin{center} |
372 |
373 \begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
373 @{thm conc_def'[THEN eq_reflection, where A1="A" and B1="B"]} |
374 @{thm (lhs) conc_def'[THEN eq_reflection, where A1="A" and B1="B"]} |
374 \hspace{7mm} |
375 & @{text "\<equiv>"} & @{thm (rhs) conc_def'[THEN eq_reflection, where A1="A" and B1="B"]}\\ |
375 @{thm lang_pow.simps(1)[THEN eq_reflection, where A1="A"]} |
376 |
376 \hspace{7mm} |
377 @{thm (lhs) lang_pow.simps(1)[THEN eq_reflection, where A1="A"]} |
377 @{thm lang_pow.simps(2)[THEN eq_reflection, where A1="A" and n1="n"]} |
378 & @{text "\<equiv>"} & @{thm (rhs) lang_pow.simps(1)[THEN eq_reflection, where A1="A"]}\\ |
|
379 |
|
380 @{thm (lhs) lang_pow.simps(2)[THEN eq_reflection, where A1="A" and n1="n"]} |
|
381 & @{text "\<equiv>"} & @{thm (rhs) lang_pow.simps(2)[THEN eq_reflection, where A1="A" and n1="n"]} |
|
382 \end{tabular} |
378 \end{center} |
383 \end{center} |
379 |
384 |
380 \noindent |
385 \noindent |
381 where @{text "@"} is the list-append operation. The Kleene-star of a language @{text A} |
386 where @{text "@"} is the list-append operation. The Kleene-star of a language @{text A} |
382 is defined as the union over all powers, namely @{thm star_def}. In the paper |
387 is defined as the union over all powers, namely @{thm star_def}. In the paper |
451 Regular expressions are defined as the inductive datatype |
456 Regular expressions are defined as the inductive datatype |
452 |
457 |
453 \begin{center} |
458 \begin{center} |
454 \begin{tabular}{rcl} |
459 \begin{tabular}{rcl} |
455 @{text r} & @{text "::="} & @{term ZERO}\\ |
460 @{text r} & @{text "::="} & @{term ZERO}\\ |
456 & @{text"|"} & @{term ONE}\\ |
461 & @{text"|"} & @{term One}\\ |
457 & @{text"|"} & @{term "ATOM c"}\\ |
462 & @{text"|"} & @{term "Atom c"}\\ |
458 & @{text"|"} & @{term "TIMES r r"}\\ |
463 & @{text"|"} & @{term "Times r r"}\\ |
459 & @{text"|"} & @{term "PLUS r r"}\\ |
464 & @{text"|"} & @{term "Plus r r"}\\ |
460 & @{text"|"} & @{term "STAR r"} |
465 & @{text"|"} & @{term "Star r"} |
461 \end{tabular} |
466 \end{tabular} |
462 \end{center} |
467 \end{center} |
463 |
468 |
464 \noindent |
469 \noindent |
465 and the language matched by a regular expression is defined as |
470 and the language matched by a regular expression is defined as |
496 |
501 |
497 |
502 |
498 section {* The Myhill-Nerode Theorem, First Part *} |
503 section {* The Myhill-Nerode Theorem, First Part *} |
499 |
504 |
500 text {* |
505 text {* |
|
506 \noindent |
501 \footnote{Folklore: Henzinger (arden-DFA-regexp.pdf); Hofmann} |
507 \footnote{Folklore: Henzinger (arden-DFA-regexp.pdf); Hofmann} |
502 |
|
503 \noindent |
|
504 The key definition in the Myhill-Nerode theorem is the |
508 The key definition in the Myhill-Nerode theorem is the |
505 \emph{Myhill-Nerode relation}, which states that w.r.t.~a language two |
509 \emph{Myhill-Nerode relation}, which states that w.r.t.~a language two |
506 strings are related, provided there is no distinguishing extension in this |
510 strings are related, provided there is no distinguishing extension in this |
507 language. This can be defined as a tertiary relation. |
511 language. This can be defined as a tertiary relation. |
508 |
512 |
550 \noindent |
554 \noindent |
551 In our running example, @{text "X\<^isub>2"} is the only |
555 In our running example, @{text "X\<^isub>2"} is the only |
552 equivalence class in @{term "finals {[c]}"}. |
556 equivalence class in @{term "finals {[c]}"}. |
553 It is straightforward to show that in general |
557 It is straightforward to show that in general |
554 |
558 |
555 \begin{center} |
559 \begin{equation}\label{finalprops} |
556 @{thm lang_is_union_of_finals}\hspace{15mm} |
560 @{thm lang_is_union_of_finals}\hspace{15mm} |
557 @{thm finals_in_partitions} |
561 @{thm finals_in_partitions} |
558 \end{center} |
562 \end{equation} |
559 |
563 |
560 \noindent |
564 \noindent |
561 hold. |
565 hold. |
562 Therefore if we know that there exists a regular expression for every |
566 Therefore if we know that there exists a regular expression for every |
563 equivalence class in \mbox{@{term "finals A"}} (which by assumption must be |
567 equivalence class in \mbox{@{term "finals A"}} (which by assumption must be |
620 `terminal' states. We are forced to set up the equational system in our |
624 `terminal' states. We are forced to set up the equational system in our |
621 way, because the Myhill-Nerode relation determines the `direction' of the |
625 way, because the Myhill-Nerode relation determines the `direction' of the |
622 transitions---the successor `state' of an equivalence class @{text Y} can |
626 transitions---the successor `state' of an equivalence class @{text Y} can |
623 be reached by adding a character to the end of @{text Y}. This is also the |
627 be reached by adding a character to the end of @{text Y}. This is also the |
624 reason why we have to use our reverse version of Arden's Lemma.} |
628 reason why we have to use our reverse version of Arden's Lemma.} |
625 %In our initial equation system there can only be |
629 In our running example we have the initial equational system |
626 %finitely many terms of the form @{text "(Y\<^isub>i\<^isub>j, ATOM c\<^isub>i\<^isub>j)"} in a right-hand side |
630 |
627 %since by assumption there are only finitely many |
631 \begin{equation}\label{exmpcs} |
628 %equivalence classes and only finitely many characters. |
632 \mbox{\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
633 @{term "X\<^isub>1"} & @{text "="} & @{text "\<lambda>(ONE)"}\\ |
|
634 @{term "X\<^isub>2"} & @{text "="} & @{text "(X\<^isub>1, ATOM c)"}\\ |
|
635 @{term "X\<^isub>3"} & @{text "="} & @{text "(X\<^isub>1, ATOM d\<^isub>1) + \<dots> + (X\<^isub>1, ATOM d\<^isub>n)"}\\ |
|
636 & & \mbox{}\hspace{3mm}@{text "+ (X\<^isub>3, ATOM c\<^isub>1) + \<dots> + (X\<^isub>3, ATOM c\<^isub>m)"} |
|
637 \end{tabular}} |
|
638 \end{equation} |
|
639 |
|
640 \noindent |
|
641 where @{text "d\<^isub>1\<dots>d\<^isub>n"} is the sequence of all characters |
|
642 except @{text c}, and @{text "c\<^isub>1\<dots>c\<^isub>m"} is the sequence of all |
|
643 characters. In our initial equation systems there can only be finitely many |
|
644 terms of the form @{text "(Y\<^isub>i\<^isub>j, ATOM c\<^isub>i\<^isub>j)"}, |
|
645 since by assumption there are only finitely many equivalence classes and |
|
646 only finitely many characters. |
|
647 |
629 Overloading the function @{text \<calL>} for the two kinds of terms in the |
648 Overloading the function @{text \<calL>} for the two kinds of terms in the |
630 equational system, we have |
649 equational system, we have |
631 |
650 |
632 \begin{center} |
651 \begin{center} |
633 @{text "\<calL>(Y, r) \<equiv>"} % |
652 @{text "\<calL>(Y, r) \<equiv>"} % |
696 and substitutes @{text X} throughout the rest of the equational system |
715 and substitutes @{text X} throughout the rest of the equational system |
697 adjusting the remaining regular expressions appropriately. To define this adjustment |
716 adjusting the remaining regular expressions appropriately. To define this adjustment |
698 we define the \emph{append-operation} taking a term and a regular expression as argument |
717 we define the \emph{append-operation} taking a term and a regular expression as argument |
699 |
718 |
700 \begin{center} |
719 \begin{center} |
701 @{thm Append_rexp.simps(2)[where X="Y" and r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]}\hspace{10mm} |
720 \begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} |
702 @{thm Append_rexp.simps(1)[where r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]} |
721 @{thm (lhs) Append_rexp.simps(2)[where X="Y" and r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]} |
|
722 & @{text "\<equiv>"} & |
|
723 @{thm (rhs) Append_rexp.simps(2)[where X="Y" and r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]}\\ |
|
724 @{thm (lhs) Append_rexp.simps(1)[where r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]} |
|
725 & @{text "\<equiv>"} & |
|
726 @{thm (rhs) Append_rexp.simps(1)[where r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]} |
|
727 \end{tabular} |
703 \end{center} |
728 \end{center} |
704 |
729 |
705 \noindent |
730 \noindent |
706 We lift this operation to entire right-hand sides of equations, written as |
731 We lift this operation to entire right-hand sides of equations, written as |
707 @{thm (lhs) Append_rexp_rhs_def[where rexp="r"]}. With this we can define |
732 @{thm (lhs) Append_rexp_rhs_def[where rexp="r"]}. With this we can define |
709 % |
734 % |
710 \begin{equation}\label{arden_def} |
735 \begin{equation}\label{arden_def} |
711 \mbox{\begin{tabular}{rc@ {\hspace{2mm}}r@ {\hspace{1mm}}l} |
736 \mbox{\begin{tabular}{rc@ {\hspace{2mm}}r@ {\hspace{1mm}}l} |
712 @{thm (lhs) Arden_def} & @{text "\<equiv>"}~~\mbox{} & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "let"}}\\ |
737 @{thm (lhs) Arden_def} & @{text "\<equiv>"}~~\mbox{} & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "let"}}\\ |
713 & & @{text "rhs' ="} & @{term "rhs - {Trn X r | r. Trn X r \<in> rhs}"} \\ |
738 & & @{text "rhs' ="} & @{term "rhs - {Trn X r | r. Trn X r \<in> rhs}"} \\ |
714 & & @{text "r' ="} & @{term "STAR (\<Uplus> {r. Trn X r \<in> rhs})"}\\ |
739 & & @{text "r' ="} & @{term "Star (\<Uplus> {r. Trn X r \<in> rhs})"}\\ |
715 & & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "in"}~~@{term "append_rhs_rexp rhs' r'"}}\\ |
740 & & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "in"}~~@{term "Append_rexp_rhs rhs' r'"}}\\ |
716 \end{tabular}} |
741 \end{tabular}} |
717 \end{equation} |
742 \end{equation} |
718 |
743 |
719 \noindent |
744 \noindent |
720 In this definition, we first delete all terms of the form @{text "(X, r)"} from @{text rhs}; |
745 In this definition, we first delete all terms of the form @{text "(X, r)"} from @{text rhs}; |
721 then we calculate the combined regular expressions for all @{text r} coming |
746 then we calculate the combined regular expressions for all @{text r} coming |
722 from the deleted @{text "(X, r)"}, and take the @{const STAR} of it; |
747 from the deleted @{text "(X, r)"}, and take the @{const Star} of it; |
723 finally we append this regular expression to @{text rhs'}. It can be easily seen |
748 finally we append this regular expression to @{text rhs'}. It can be easily seen |
724 that this operation mimics Arden's Lemma on the level of equations. To ensure |
749 that this operation mimics Arden's Lemma on the level of equations. To ensure |
725 the non-emptiness condition of Arden's Lemma we say that a right-hand side is |
750 the non-emptiness condition of Arden's Lemma we say that a right-hand side is |
726 @{text ardenable} provided |
751 @{text ardenable} provided |
727 |
752 |
749 \begin{center} |
774 \begin{center} |
750 \begin{tabular}{rc@ {\hspace{2mm}}r@ {\hspace{1mm}}l} |
775 \begin{tabular}{rc@ {\hspace{2mm}}r@ {\hspace{1mm}}l} |
751 @{thm (lhs) Subst_def} & @{text "\<equiv>"}~~\mbox{} & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "let"}}\\ |
776 @{thm (lhs) Subst_def} & @{text "\<equiv>"}~~\mbox{} & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "let"}}\\ |
752 & & @{text "rhs' ="} & @{term "rhs - {Trn X r | r. Trn X r \<in> rhs}"} \\ |
777 & & @{text "rhs' ="} & @{term "rhs - {Trn X r | r. Trn X r \<in> rhs}"} \\ |
753 & & @{text "r' ="} & @{term "\<Uplus> {r. Trn X r \<in> rhs}"}\\ |
778 & & @{text "r' ="} & @{term "\<Uplus> {r. Trn X r \<in> rhs}"}\\ |
754 & & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "in"}~~@{term "rhs' \<union> append_rhs_rexp xrhs r'"}}\\ |
779 & & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "in"}~~@{term "rhs' \<union> Append_rexp_rhs xrhs r'"}}\\ |
755 \end{tabular} |
780 \end{tabular} |
756 \end{center} |
781 \end{center} |
757 |
782 |
758 \noindent |
783 \noindent |
759 We again delete first all occurrences of @{text "(X, r)"} in @{text rhs}; we then calculate |
784 We again delete first all occurrences of @{text "(X, r)"} in @{text rhs}; we then calculate |
898 and to show that @{term "Subst_all (ES - {(Y, yrhs)}) Y (Arden Y yrhs)"} |
923 and to show that @{term "Subst_all (ES - {(Y, yrhs)}) Y (Arden Y yrhs)"} |
899 preserves the invariant. |
924 preserves the invariant. |
900 We prove this as follows: |
925 We prove this as follows: |
901 |
926 |
902 \begin{center} |
927 \begin{center} |
903 @{text "\<forall> ES."} @{thm (prem 1) Subst_all_satisfies_invariant} implies |
928 \begin{tabular}{@ {}l@ {}} |
|
929 @{text "\<forall> ES."}\\ \mbox{}\hspace{5mm}@{thm (prem 1) Subst_all_satisfies_invariant} implies |
904 @{thm (concl) Subst_all_satisfies_invariant} |
930 @{thm (concl) Subst_all_satisfies_invariant} |
|
931 \end{tabular} |
905 \end{center} |
932 \end{center} |
906 |
933 |
907 \noindent |
934 \noindent |
908 Finiteness is straightforward, as the @{const Subst} and @{const Arden} operations |
935 Finiteness is straightforward, as the @{const Subst} and @{const Arden} operations |
909 keep the equational system finite. These operations also preserve soundness |
936 keep the equational system finite. These operations also preserve soundness |
1313 with @{term "y @ z \<in> A \<cdot> B"}. We again can complete the @{const TIMES}-case |
1340 with @{term "y @ z \<in> A \<cdot> B"}. We again can complete the @{const TIMES}-case |
1314 by setting @{text A} to @{term "lang r\<^isub>1"} and @{text B} to @{term "lang r\<^isub>2"}. |
1341 by setting @{text A} to @{term "lang r\<^isub>1"} and @{text B} to @{term "lang r\<^isub>2"}. |
1315 \end{proof} |
1342 \end{proof} |
1316 |
1343 |
1317 \noindent |
1344 \noindent |
1318 The case for @{const STAR} is similar to @{const TIMES}, but poses a few extra challenges. When |
1345 The case for @{const Star} is similar to @{const TIMES}, but poses a few extra challenges. When |
1319 we analyse the case that @{text "x @ z"} is an element in @{term "A\<star>"} and @{text x} is not the |
1346 we analyse the case that @{text "x @ z"} is an element in @{term "A\<star>"} and @{text x} is not the |
1320 empty string, we |
1347 empty string, we |
1321 have the following picture: |
1348 have the following picture: |
1322 % |
1349 % |
1323 \begin{center} |
1350 \begin{center} |
1380 % |
1407 % |
1381 \begin{center} |
1408 \begin{center} |
1382 @{thm tag_str_Star_def[where ?L1.0="A", THEN meta_eq_app]}\smallskip |
1409 @{thm tag_str_Star_def[where ?L1.0="A", THEN meta_eq_app]}\smallskip |
1383 \end{center} |
1410 \end{center} |
1384 |
1411 |
1385 \begin{proof}[@{const STAR}-Case] |
1412 \begin{proof}[@{const Star}-Case] |
1386 If @{term "finite (UNIV // \<approx>A)"} |
1413 If @{term "finite (UNIV // \<approx>A)"} |
1387 then @{term "finite (Pow (UNIV // \<approx>A))"} holds. The range of |
1414 then @{term "finite (Pow (UNIV // \<approx>A))"} holds. The range of |
1388 @{term "tag_str_STAR A"} is a subset of this set, and therefore finite. |
1415 @{term "tag_str_Star A"} is a subset of this set, and therefore finite. |
1389 Again we have to show injectivity of this tagging-function as |
1416 Again we have to show injectivity of this tagging-function as |
1390 % |
1417 % |
1391 \begin{center} |
1418 \begin{center} |
1392 @{term "\<forall>z. tag_str_STAR A x = tag_str_STAR A y \<and> x @ z \<in> A\<star> \<longrightarrow> y @ z \<in> A\<star>"} |
1419 @{term "\<forall>z. tag_str_Star A x = tag_str_Star A y \<and> x @ z \<in> A\<star> \<longrightarrow> y @ z \<in> A\<star>"} |
1393 \end{center} |
1420 \end{center} |
1394 % |
1421 % |
1395 \noindent |
1422 \noindent |
1396 We first need to consider the case that @{text x} is the empty string. |
1423 We first need to consider the case that @{text x} is the empty string. |
1397 From the assumption we can infer @{text y} is the empty string and |
1424 From the assumption we can infer @{text y} is the empty string and |
1448 \begin{equation}\label{mhders} |
1475 \begin{equation}\label{mhders} |
1449 @{term "x \<approx>A y"} \hspace{4mm}\text{if and only if}\hspace{4mm} @{term "Ders x A = Ders y A"} |
1476 @{term "x \<approx>A y"} \hspace{4mm}\text{if and only if}\hspace{4mm} @{term "Ders x A = Ders y A"} |
1450 \end{equation} |
1477 \end{equation} |
1451 |
1478 |
1452 \noindent |
1479 \noindent |
1453 It is realtively easy to establish the following identidies for left-quotients: |
1480 It is realtively easy to establish the following properties for left-quotients: |
1454 |
1481 |
1455 \begin{center} |
1482 \begin{center} |
1456 \begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{2mm}}l} |
1483 \begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{2mm}}l} |
1457 @{thm (lhs) Der_zero} & $=$ & @{thm (rhs) Der_zero}\\ |
1484 @{thm (lhs) Der_zero} & $=$ & @{thm (rhs) Der_zero}\\ |
1458 @{thm (lhs) Der_one} & $=$ & @{thm (rhs) Der_one}\\ |
1485 @{thm (lhs) Der_one} & $=$ & @{thm (rhs) Der_one}\\ |
1481 @{thm (lhs) der.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) der.simps(2)}\\ |
1508 @{thm (lhs) der.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) der.simps(2)}\\ |
1482 @{thm (lhs) der.simps(3)[where c'="d"]} & @{text "\<equiv>"} & @{thm (rhs) der.simps(3)[where c'="d"]}\\ |
1509 @{thm (lhs) der.simps(3)[where c'="d"]} & @{text "\<equiv>"} & @{thm (rhs) der.simps(3)[where c'="d"]}\\ |
1483 @{thm (lhs) der.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
1510 @{thm (lhs) der.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
1484 & @{text "\<equiv>"} & @{thm (rhs) der.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\ |
1511 & @{text "\<equiv>"} & @{thm (rhs) der.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\ |
1485 @{thm (lhs) der.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
1512 @{thm (lhs) der.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
1486 & @{text "\<equiv>"}\\ |
1513 & @{text "\<equiv>"} & @{text "if"}~@{term "nullable r\<^isub>1"}~@{text "then"}~% |
1487 \multicolumn{3}{@ {\hspace{5mm}}l@ {}}{@{thm (rhs) der.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}}\\ |
1514 @{term "Plus (Times (der c r\<^isub>1) r\<^isub>2) (der c r\<^isub>2)"}\\ |
|
1515 & & \phantom{@{text "if"}~@{term "nullable r\<^isub>1"}~}@{text "else"}~% |
|
1516 @{term "Times (der c r\<^isub>1) r\<^isub>2"}\\ |
1488 @{thm (lhs) der.simps(6)} & @{text "\<equiv>"} & @{thm (rhs) der.simps(6)}\smallskip\\ |
1517 @{thm (lhs) der.simps(6)} & @{text "\<equiv>"} & @{thm (rhs) der.simps(6)}\smallskip\\ |
1489 @{thm (lhs) ders.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) ders.simps(1)}\\ |
1518 @{thm (lhs) ders.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) ders.simps(1)}\\ |
1490 @{thm (lhs) ders.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) ders.simps(2)}\\ |
1519 @{thm (lhs) ders.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) ders.simps(2)}\\ |
1491 \end{tabular} |
1520 \end{tabular} |
1492 \end{center} |
1521 \end{center} |
1494 \noindent |
1523 \noindent |
1495 The function @{term "nullable r"} tests whether the regular expression |
1524 The function @{term "nullable r"} tests whether the regular expression |
1496 can recognise the empty string: |
1525 can recognise the empty string: |
1497 |
1526 |
1498 \begin{center} |
1527 \begin{center} |
1499 \begin{tabular}{cc} |
1528 \begin{tabular}{c@ {\hspace{10mm}}c} |
1500 \begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}} |
1529 \begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}} |
1501 @{thm (lhs) nullable.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) nullable.simps(1)}\\ |
1530 @{thm (lhs) nullable.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) nullable.simps(1)}\\ |
1502 @{thm (lhs) nullable.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) nullable.simps(2)}\\ |
1531 @{thm (lhs) nullable.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) nullable.simps(2)}\\ |
1503 @{thm (lhs) nullable.simps(3)} & @{text "\<equiv>"} & @{thm (rhs) nullable.simps(3)}\\ |
1532 @{thm (lhs) nullable.simps(3)} & @{text "\<equiv>"} & @{thm (rhs) nullable.simps(3)}\\ |
1504 \end{tabular} & |
1533 \end{tabular} & |
1566 @{thm (lhs) pder.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) pder.simps(2)}\\ |
1595 @{thm (lhs) pder.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) pder.simps(2)}\\ |
1567 @{thm (lhs) pder.simps(3)[where c'="d"]} & @{text "\<equiv>"} & @{thm (rhs) pder.simps(3)[where c'="d"]}\\ |
1596 @{thm (lhs) pder.simps(3)[where c'="d"]} & @{text "\<equiv>"} & @{thm (rhs) pder.simps(3)[where c'="d"]}\\ |
1568 @{thm (lhs) pder.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
1597 @{thm (lhs) pder.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
1569 & @{text "\<equiv>"} & @{thm (rhs) pder.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\ |
1598 & @{text "\<equiv>"} & @{thm (rhs) pder.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\ |
1570 @{thm (lhs) pder.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
1599 @{thm (lhs) pder.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
1571 & @{text "\<equiv>"}\\ |
1600 & @{text "\<equiv>"} & @{text "if"}~@{term "nullable r\<^isub>1"}~@{text "then"}~% |
1572 \multicolumn{3}{@ {\hspace{20mm}}l@ {}}{@{thm (rhs) pder.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}}\\ |
1601 @{term "(Times_set (pder c r\<^isub>1) r\<^isub>2) \<union> (pder c r\<^isub>2)"}\\ |
|
1602 & & \phantom{@{text "if"}~@{term "nullable r\<^isub>1"}~}@{text "else"}~% |
|
1603 @{term "Times_set (pder c r\<^isub>1) r\<^isub>2"}\\ |
1573 @{thm (lhs) pder.simps(6)} & @{text "\<equiv>"} & @{thm (rhs) pder.simps(6)}\smallskip\\ |
1604 @{thm (lhs) pder.simps(6)} & @{text "\<equiv>"} & @{thm (rhs) pder.simps(6)}\smallskip\\ |
1574 @{thm (lhs) pders.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) pders.simps(1)}\\ |
1605 @{thm (lhs) pders.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) pders.simps(1)}\\ |
1575 @{thm (lhs) pders.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) pders.simps(2)}\\ |
1606 @{thm (lhs) pders.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) pders.simps(2)}\\ |
1576 \end{tabular} |
1607 \end{tabular} |
1577 \end{center} |
1608 \end{center} |