Harbin Institute of Technology Headquarters 2022 Formal Language and Automata Final Exam Questions

Under normal circumstances, seniors can only take one test per subject. I hope that the juniors can pass on the same legacy in the future.
Note: I can only remember the general meaning of the test paper , but cannot remember the specific description, so it is for reference only.

A classmate has posted the teacher’s original English test questions . If you have the original English test questions, why should I use this recall version? 233. Link: https://blog.csdn.net/weixin_44705388/article/details/126386915 . The article published by this student follows the CC 4.0 BY-SA agreement, which allows the original work to be modified and shared, so I have incorporated the content into this recall question for your reference . At the same time, this article also follows the CC 4.0 BY-SA license.

On Sunday, May 8, 2022, from 13:00 to 15:00 in the afternoon, I experienced the formal language and automata exam. The recall version of the test questions is now presented as follows for your reference.

Let’s talk about the test experience first: the questions are a little more difficult than those in 2019 and 2020. The reason for the difficulty is that some points that I “thought” may not be covered or may be rarely examined. You still have to listen carefully to the teacher during class, the teacher will be very careful . It clearly states which areas are often tested, which areas will be tested, and which areas are not. (Anything that is not clearly stated not to be tested may be tested, but don’t worry, it actually doesn’t have much content.) And what answering standards should be followed for different questions.

The PDF version will be uploaded to Github in the near future: HITSZ-OpenCS project, so stay tuned~

2022.05.19 Update: The results are out. If you have any questions, you can ask the teacher. The teacher will explain clearly to you the points that will be deducted, so that you can be convinced. What I wrote during the exam is difficult to reproduce exactly now, so I won’t provide the answers :). I personally think that some of the more tricky points will be placed at the end of the article.

1. Please design a DFA for the following language: L = { w ∈ { 0 , 1 } ∗ ∣ w contains both 00 and 11 } L=\left\{ w\in \left\{ 0,1 \right\} ^*|w\text{includes both}00\text{ and }11 \right\}L={ w{ 0,1}w contains both 00 and 11 }

[10points] Design a DFA for L = { w ∈ { 0 , 1 } ∗ ∣ w L=\left\{w \in\{0,1\}^* \mid w\right. L={ w{ 0,1}w contains both 00 and 11 as substrings } \} }.

2. Please design an NFA for the following language: L = { w ∈ { 0 , 1 } ∗ ∣ w The substrings 01 and 10 appear equally often} L=\left\{ w\in \left\{ 0,1 \ right\} ^*|w\text{neutron string}01\text{, }10\text{equal number of occurrences} \right\}L={ w{ 0,1}∣wThe substrings 01 and 10 appear equally often }

[10points] Design an NFA for L = { w ∈ { 0 , 1 } ∗ ∣ w L=\left\{w \in\{0,1\}^* \mid w\right. L={ w{ 0,1}w contains an cqual number of occurrences of the substrings 01 and 10 } \} }.

3. Please design regular expressions for the following languages:
(1) L = { w ∈ { a , b } ∗ ∣ w neutron string aa appears at least twice} L=\left\{ w\in \left\{ a ,b \right\} ^*|w\text{neutron string}aa\text{appears at least twice} \right\}L={ w{ a,b}w neutron string aa appears at least twice } (My hands were shaking and I typed the wrong question here before. Thanks to my classmates for helping to point out the error!)

(2) L = { w ∈ { a , b } ∣ ∣ w does not end with aa or bb} L=\left\{ w\in \left\{ a,b \right\} ^*|w\text{ Does not end with }aa\text{ or }bb\text{} \right\}L={ w{ a,b}w does not end with aa or bb }

[10points] Design regular expressions for languages over Σ = { a , b } \Sigma=\{a, b\} S={ a,b} :
(1) All strings having at least two occurrences of the substring a a a a aa.
(2) All strings that do not end with substrings a a a a aa or b b b b bb.

4. Please use the pump lemma to prove that L is not regular: L = { w ∈ { 0 , 1 } ∗ ∣ w The substrings 00 and 11 appear equally often} L=\left\{ w\in \left\{ 0 ,1 \right\} ^*|w\text{neutron string}00\text{and}11\text{the number of occurrences are equal} \right\}L={ w{ 0,1}The substrings 00 and 11 appear equally often in w }

[10points] Prove that the language L L L is not regular with pumping lemma L = { w ∈ { 0 , 1 } ∗ ∣ w L=\left\{w \in\{0,1\}^* \mid w\right. L={ w{ 0,1}w has the same number of substrings 00 and 11 } \} }.

5. Please select from any regular language L ⊆ Σ ∗ L\subseteq \Sigma ^*LSStarting from the DFA of ∗ , we construct the DFA of h(L) using formal symbolic language. whereh : Σ → Σ ∗ , ∀ a ∈ Σ , h ( a ) = aah:\Sigma \rightarrow \Sigma ^*,\forall a\in \Sigma ,h\left( a \right) =aah:SS,aS ,h(a)=aa

[10points] Let h : Σ → Σ ∗ h: \Sigma \rightarrow \Sigma^* h:SS be a homomorphism: ∀ a ∈ Σ , h ( a ) = a a \forall a \in \Sigma, h(a)=a a aS ,h(a)=aa. Please give a formal construction of the DFA for h ( L ) h(L) h(L) from the DFA that accepts the regular language L L L over Σ \Sigma S. _

6. Please construct a grammar for the following language: { w ∈ { 0 , 1 } ∗ ∣ w has two blocks ( block ) 0 , each block has an equal number of 0 } \left\{ w\in \left\{ 0,1 \right\} ^*|w\text{There are two blocks}\left( block \right) 0\text{, the number of each block}0\text{ is equal} \right\}{ w{ 0,1}w has two pieces(block)0 , the number of 0s in each block is equal }
[Note: The original question was "just" two blocks, but the teacher deleted just in the exam]

[10points] Design a context-free grammar for the language
L = { x ∈ { 0 , 1 } ∗ ∣ x L=\left\{x \in\{0,1\}^* \mid x\right. L={ x{ 0,1}x has just two nonempty blocks of 0s of the same length } \} }.

7. Please construct a deterministic PDA for the following language: { w = anb 2 n + 1 ∣ n ⩾ 1 } \left\{ w=a^nb^{2n+1}|n\geqslant 1 \right\}{ w=anb2n + 1n _1}

[10points] Design a deterministic PDA for L = { a n b 2 n + 1 ∣ n ≥ 1 } L=\left\{a^n b^{2n+1} \mid n \geq1\right\} L={ anb2n + 1 _n1}.

8. Given the CFG:
S → ASA ∣ A ∣ ε A → 00 ∣ ε S\rightarrow ASA|A|\varepsilon \\A\rightarrow 00|\varepsilonSASAAεA00∣ε

(1) Eliminate empty productions
(2) Eliminate unit productions
(3) Convert to Chomsky grammar

[10points] Begin with the grammar:
S → A S A ∣ A ∣ ε A → 00 ∣ ε \begin{aligned} & S \rightarrow A S A|A| \varepsilon \\ & A \rightarrow00\mid \varepsilon \end{aligned} SASAAεA00e
(1) Eliminate any ε \varepsilon ε-productions.
(2) Eliminate any unit productions in the resulting grammar.
(3) Put the resulting grammar into Chomsky Normal Form.

9. There is a question from PDA->CFG. I can’t remember the specific question. It is in the book. The teacher will also give examples. It is just a formula. Once you know the method, it will be fine.

[10points] Consider a PDA P P P with start state q q q, start symbol Z Z Z in the stack and the following transition rules. Please convert P P P to an equivalent CFG.
(1) δ ( q , 0 , Z ) = { ( q , X ) } \delta(q,0, Z)=\{(q, X)\} d ( q ,0,Z)={(q,X)}
(2) δ ( q , 0 , X ) = { ( q , X X ) } \delta(q,0, X)=\{(q, X X)\} d ( q ,0,X)={(q,XX)}
(3) δ ( q , 1 , X ) = { ( r , X ) } \delta(q,1, X)=\{(r, X)\} d ( q ,1,X)={(r,X )}
(4)δ ( r , 0 , X ) = { ( r , ε ) } \delta(r,0, X)=\{(r, \varepsilon)\}d ( r ,0,X)={(r,e )}

10. Please design a Turing machine for the following language: { aibjck ∣ k = i × j , k > 0 } \left\{ a^ib^jc^k|k=i\times j,k>0 \right\}{ aibjckk=i×j,k>0}

[10points] Design a Turing machine for L = { a i b j c k ∣ k = i × j L=\left\{a^i b^j c^k \mid k=i \times j\right. L={ aibjckk=i×j and k > 0 } \left.k>0\right\} k>0}.

Postscript is for reference only. If you have any questions, please ask the teacher. We cannot guarantee that the following is absolutely correct.

  1. For all design questions, remember to check the empty string, one character, and two characters after drawing.
  2. For question 2, it is best to show that what you are drawing is NFA, that is, it has empty transfer. Different teachers have different requirements. Some allow drawing DFA, and some do not. Everything must be done according to the teacher's requirements. The teacher will emphasize it in class. If it doesn't work, you can ask the teacher after class.
  3. Question 3 is the first question, remember to consider the situation aaa
  4. Question 5, be sure to use mathematical language to completely give the designed DFA (Q, Σ, δ, q 0, F) (Q,\Sigma,\delta,q_{0},F)(Q,S ,d ,q0,F ) can
  5. Question 6: The so-called two pieces of 0 can only be called two pieces if there is a 1 in between, such as "000100"
  6. Question 7: DPDA must be designed. If any one of them does not comply with the rules of DPDA, then it will be a pill.
  7. The first question of question 8 is that S needs to be derived from S. Many students fall into this problem.
  8. For question 9, remember to write down the process. It is best to simplify the symbols.
  9. Question 10, note that k > 0 k>0k>0 condition restriction, do not accept empty string

Guess you like

Origin blog.csdn.net/weixin_52027058/article/details/124738005