Строительный блокнот  Automata methods and madness 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 [ 55 ] 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175

-f Minimizing Deterministic Finite. Automata: We can partition tlie states of any DFA into groups of mutually indistinguishable states. Members of two different gioups are always distinguishable. If we replac:e each group by a single state, we get an equivalent DF.A that has as few states as any DFA for the sam<? language.

4.6 References for Chapter 4

Except for the obvious closure properties of regular expressions - union, concatenation, and star - that were shown by Kleene [6], almost all results about closure properties of the regular languages mimic similar results about context-free languages (the class of languages we study in the next chapters). Thus, the ]mmping lemma for regular languages is a simplification of a corresponding result for context-free languages by Bar-Hillel, Perles, and Shamir [1]. The same paper indirectly gives us several of the other closure properties shown here. Howwer, the closure- under inverse homomorphism is fiom [2].

The quotient operation introduced in Exercise 4.2.2 is from [3]. In fact, that papcT talks about a more general operation where in place of a single sjinbol a is any regular language. The series of operations of the partial removal type, starting with Exercise 4,2.8 on the first halves of strings in a regular language, began with [8]. Seiferas and McNaughton [9] worked out the general case of when a removal operation preserves regular languages.

The original decision algorithms, such as emptiness, finiteness, and membership f(jr regidar languages, are from [7]. Algorithms for mimnuzing the. states of a DFA appear there; and in [-5], The most efficient algorithm for finding the minimum-state DFA is in [4j.

1. Y. Bar-Hillel, M, Perles, and E. Shamir, On formal properties of simple phras(vstnicture grammars, Z. Phonelik. Sprachwiss. Kom?nunikations-forsdi. 14 (1961), pp, 143 172.

2, S. Ginsburg and G. Rose, Operations which preserve definabifity in languages. ,/, ACM 1И:2 (1963), pp. 175-195.

3, S, Ginsburg and E. H, Spanier, Quotients of context-free hmguages, J. ACM 10:4 (1963), pp. 487-492.

4, J, E, Hopcroft, An nlogri algorithm for minimizing the .states in a finite automaton, in Z. Kohavi (ed,) The Theory of Machines and Computa-tinnS; -Aicademic Press, New York, pp, 189-196,

5. D, A. Huffman, The synthesis of sequential switching circuits, ,7. Franklin Inst. 257:3-4 (1954), pp. 161 190 and 275-303.

6. S. C. Kleene, Representation of events in nerve nets and finite automata, in C- E. Shannon and J. McCarthy, Automata Studies, Princeton Univ, Press, 1956, pp. 3-42.



4.6. REFERENCES FOR CHAPTER 4 167

7. E. F. Moore, Gedanken experiments on sequtential machines, in C. E. Shannon and J. McCarthy, Automata Studies, Princeton Univ. Pre, 1956, pp. 129-153.

8. R. E. Stearns and J. Hartmanis, Regularity-preserving moddications of regidar exprsions, Information and Control 6:1 (1963), pp. 55-69.

9. J. I. Seiferas and R. McNaughton, Regularity-preserving modifications, Thearetieal Computer Science 2:2 (1976), pp. 147-154.



Chapter 5

Context-Free Grammars and Languages

We now turn onr attention away from the r(;gular languages to a larger class of languages, called the context-free languages. These languages have a natural, recursive notation, called context-free grammars. Context-free grammars have played a central role in comjiiler technology since the 1960s; tiiey turned the implementation of parsers (functions that discover the structure of a program) from a time-consuming, ad-hoc implementation task into a. routine job that can be done in an afternoon. More recently, the context-free grammar has been used to describe document formats, via the so-called document-type definition (DTD) that is used in the XML (extensible markup language) cornmimity for information exchange on the Web,

In this chapter, we introduce the context-free grammar notation, and shf)w how grammars define languages. Wo discuss the parse tree, a picture of the structure that a grammar places on the strings of its language. The parse tree is tlu! product of a. parser fijr a progranuning language and is the way that the structure of programs is normally captuK-d.

There is an automaton-like notation, called the pushdown automaton, that also describes all and only the context-free languages; we intrcjduce the pushdown automaton in Chapter 6, While less imptjrtant than finite automata, we shall find the pushdown automaton, especially its equivalence to context-free grammars as a language-defining mechanism, to be quite useful when we explore the closure and decision properties of the context-free languages in Chapter 7,

5.1 Context-Free Grammars

We shall begin by introducing the context-free grammar notation informally. After seeing some of the important capabilities of these grammars, we offer formal definitions. We show how to define a grfinniiar formally, and introduce;



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 [ 55 ] 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175