About grammar Formal Languages and Automata a little consideration

Based on the review
  • The system is divided into four Chomsky grammar, 0,1,2,3 type.
  • G generated by the grammar language referred to as L (G)
  • A string in L (G), will be composed of a terminator, and is derived from the start symbol S
  • Type 0 grammar: unrestricted grammar
  • Type 1 grammar, also known as context-sensitive grammar.Here Insert Picture Description
  • Type 2 grammar, also known as context-free grammar.Here Insert Picture Description
  • Type 3 grammar, also known as regular grammar.Here Insert Picture Description
  • A → ε free type 2, type 3 are type 1, type 1, type 2, type 3 0 type belong.
  • Type 1, A → ε form is not allowed.

Think

So how do you take advantage of these four types of set up simple language grammar is something worth considering.

First, a look at the example:
Here Insert Picture Description
Analysis: First, understand the need to prove that two sets are equal bi-proof. L is a collection of language generated by the formula, while the right hand side is the general form of a collection generated sentence.

  1. There are two entry points S-> aSBC; S-> aBC; to get connected to the right n characters, it is clear into n times.
  2. Can try two, such as S-> aBC respectively; substituting itself for integration available -S-> A n- (the BC) n- .
  3. To obtain a power of n, and may be the right approach. Behind us consider (BC) the n- deal with the problem.
  4. A the n- (BC) the n- , in the formula provided will certainly go first aB-> ab, because only it can bring a use, others are not.
  5. For about to give A n-. 1- aB (the BC) n-. 1- C, can be obtained substituting the A n- B (the BC) n-. 1- C, it is clear that we get B, then the equation just bB-> bb play action, to give successively dismantling A n- B n- C n-
  6. Like the process C, into bC-> bc, then substituting cC-> cc can be obtained A n- B n- C n- , i.e. comprising L syndrome in L (G).

Similarly, re-license L (G) -> L relationship.
Starting at S to obtain the string containing only a, B, C by ① and ②, and the same number of these 3-letter string. And b and c can only be used in exchange for B and C, the same string number L (G) in the A, b, c of. And a symbol always appears to the left of the other, in order to be replaced with a B b only immediately to the right of a or b, c can be replaced only when C immediately to the right of b or c, b will thus in a, on the right, and on the right of b will give evidence L (G) -> CL.

  1. Right linear structure grammar, language recognition = {A L with 3N +. 1 | n-> = 0}. So Here Insert Picture Descriptionthis is the basic definition, but if a multiple of 3 and more than 1, indicating an increase of three characters each time, or only one at the beginning, either to add a can at the end of last, the whole increments are three characters so it is S->aaaS|aor
    Here Insert Picture Description
  2. Context-free grammar structure, capable of producing L = {wl w belongs to a {,} b * and w b is a number in the double}.
    Then the number of construction of a double b, indicating that each increase all the time I added in the form of an increase of at least 1, you add 2,
    then the formula is a simple S-> aabS, S-> aab, it is like this almost, but to consider all combinations, then the order is a question worth considering, S-> aab, S-> aba , S-> arrangement baa are there, so in any of the three location insertion new position are possible
    S-> the ASAB | AASB | AABS | Saab,
    S-> Saba | ASBA | ABSA | ABAS,
    S-> Sbaa | BSAA | BASA | Baas,
    like this write a little tedious, so we can use dynamic programming idea is to increase
    Here Insert Picture Description
    then we take advantage of this, a dynamic resolution, namely S-> SaSaSbS | SaSbSaS | SbSaSaS can meet the above requirements.
  3. In a further example, to write a string beginning at the end of the formula 01
    it is determined that start with 1, to give S-> 1A, 1 can then be back with 0 or 1, i.e., A-> 0A | 1A | 0, and also completed 1 with the aim of ending, so, when do these problems step by step to learn the characteristics of the dismantling is very important. Some may not be the only solution.

For a typical exercises last job inside
to find the right linear grammars, can be constructed and a string having an odd number odd number b thereof.
Analysis: the time to do this problem, we will consider how to ensure that it must be an odd number? According to conventional thinking, in an increase on the basis of each when they are two or twice increased to increase the operating elements of the same type, then we will be able to ensure that the result is an odd number.
So first determine the beginning of either a character or is b, then
Here Insert Picture Description
so it is the result of the whole
Here Insert Picture Description
schematic
Here Insert Picture Description

Published 222 original articles · won praise 48 · views 20000 +

Guess you like

Origin blog.csdn.net/qq_44116998/article/details/104657745