• Home
  • Queen's University
  • Software Specifications
  • Formal Languages and Regular Expressions

Formal Languages and Regular Expressions

(20 CISC 223 002 (Winter 22 Assignment #2: Formal Languages Specification Points) Student Name/ID :. Solutions are due before 2 PM on Thursday February 10, 2022. · The assignments are graded according to the correctness, preciseness and legibility of the solutions. All handwritten parts included as figures in the .tex file should be clear and legible. This assignment is marked out of 20 possible marks. . Please submit your solutions as PDF on onQ before the deadline. · The assignment must be based on individual work. Copying solutions from other stu- dents is a violation of academic integrity. See the course onQ site for more information. 1. (4 marks) Using the method described in Section 9.1 (and in class) convert the following regular expression into a state diagram: (01*+ 10)*1* Note that the closure operation has highest precedence (see page 164 in the text). Thus the expression 01* denotes exactly one 0 followed by any number of 1's. Your answer should indicate how you got your results: · As intermediate steps write down the state diagrams that you construct for subex- pressions of the given regular expression, and for each intermediate step clearly indicate which subexpression it corresponds to. . Please do not simplify/modify the state diagrams. Simplifications/modifications of the state diagrams are considered as errors when marking (independently of whether or not the state diagram remains equivalent). Please note: The question is marked based on how well you follow the steps of the algorithm of section 9.11. 2. (3 marks) Using the method described in Section 9.2 (and in class), convert the state diagram given in Figure 1 into an equivalent regular expression. Here 2 = {a, b, c, d}. Your answer should include the intermediate step(s) used in the construction. 1An NFA produced by some other method is considered incorrect independently of whether or not it may define the same language. 1 a d E C F C b b a G d Figure 1: State-transition diagram for Question 2. 3. Are the following languages A and B over the alphabet > = {a, b, c, d} regular or non-regular? · For a language that is regular, give a regular expression that defines it. · For a nonregular language, using the pumping lemma prove that it is not regular. (a) (2 marks) A = {c3j ?2k a3m+3 bk | j ? 0, k ? 0 and m ? 0} (b) (2 marks) B = {a2jbk | j ? k?0} . {br+3c25+3 | r? 0 and s ? 0} Above "." stands for language concatenation. Note: The language B is expressed as concatenation of two components. If one (or both) of the components is non-regular, this does not imply anything about the non- regularity of the concatenation. If trying to show that the language B is non-regular, we have to apply the pumping lemma to the entire language B (and not to the individual components of the concatenation). Similarly, if trying to show that B is regular, we should