1 / 10

Homework 3

Homework 3. NFA and Regular Expressions. NFA design. Give NFAs (which may use empty transitions) for each of the following languages with the specified number of states: 1.1 The language {0} with two states 1.2 The language 0* with one state

tarak
Télécharger la présentation

Homework 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Homework 3 NFA and Regular Expressions

  2. NFA design • Give NFAs (which may use empty transitions) for each of the following languages with the specified number of states: 1.1 The language {0} with two states 1.2 The language 0* with one state 1.3 The language {w| w ends with 00} with three states 1.4 The language 0*1*0+ with three states 1.5 The language 1*(001+)* with three states

  3. 2. NFA to DFA 2. For both NFAs given below, • give their state-transition tables and • find their equivalent DFAs. M1: M2:

  4. 3. NFA-e to DFA 3. Let N3 be an NFA allowing empty transition as shown in the table: 3.1 If N3=(Q,S,d,S,F) then Q= _______________ S= _______________ • d = _______________ • S = _______________ • F = ________________ 3.2 Draw a state transition diagram for N3. 3.3 Find all strings which have length  2 and are accepted by N3. 3.4 Find the empty-transition closure(EC) of {p},{q},{r} and {p,q}, respectively. 3.5 Find a DFA M3 equivalent to N3. Remember to name each state of M3 with the corresponding state subset of N2 and M2 should not contain useless state..

  5. 4. Reqular expressios to NFA • Regular expressions to NFA conversions: 4.1 Find an NFA N41 with no more than 4 states for the language L= { an | n 0 } U {bn a | n  1} 4.2 Find an NFA N42 with no more than 3 states accepting the language represented by the regular expression: (ab + abc)* 4.3 Find an NFA N43 with no more than 5 states accepting the language which represented by the regular expression: aba(b*) + ab(a*). Note that you can use empty transition in you NFA.

  6. 5. For each of the following automata, derive a regular expression equivalent to it. Note you should give the whole process instead of just a regular expression as your answer. 5. FA to regular expressions 5.2 5.1

  7. 6. Closure properties of NFA 6. Given the NFA M : 6.1 Find a NFA M1 such that L(M1) = { xyz | x,z{a,b}* and yL(M)}. 6.2 Find a NFA M2 such that L(M2) = { xy | x {a,b}* and yL(M)}. 6.3 Find a NFA M3 such that L(M3) = { yz | yL(M) and z{a,b}* }. Give your answers using state transition diagram.

  8. 7 Regular languages are closed under the shuffling operation • If x = x1 x2 … xm and y = y1 y2 … yn are two strings of length m and n, respectively. Then a shuffling of x and y is an order-preserving permutation of x1 x2 … xm and y1 y2 … yn , i.e., a string z = z1 z2 … zm+n of length m+ns.t. there are positions 1 s1<s2<…<smm+n, 1 t1<t2<…<tnm+n , with { s1,…, sm, t1,…, tn} = {1,…,m+n} and x = xs1 xs2 … x sm and y = yt1 yt2…ytn. For two strings x and y, let (x || y) denotes the set of all shufflings of x and y. For example, if x = a and y = 01, then x||y = { a01, 0a1, 01a}. And if x = ab and y = 01, then x || y = {a} (b || 01) U {0} ( ab || 1) = {a}{b01,0b1,01b} U {0}{1ab, a1b, ab1} = {ab01,a0b1, a01b, 01ab, 0a1b.0ab1}. We can extend the definition of || to languages by the equation: A || B =def U x A and y  B (x || y )

  9. 7.1 What is the set baba || 01 ? 7.2 give an inductive (or recursive) definition of (x||y). 7.3 if A= {aa, bbb }, then what is A || A ? It can be shown that regular languages are closed under ||, i.e., if A and B are regular languages, then so is A || B. The intuition is that, given two FA M1, M2 accepting A and B, respectively, consider a new machine M3 with M1 and M2 as consulting machines such that for each input symbol a, M3 uses either M1 or M2 non-deterministically to consume the symbol and the other machine remain unchanged of state. Finally M3 accepts if both submachine stay at their final state when the input string is used up. Accordingly, if M1 = (Q1, S, d1, S1, F1) and M2 = (Q2, S, d2, S2, F2), we have M3 = (Q3, S, d3, S3, F3) where Q3 = Q1XQ2, S3 = S1xS2, F3 = F1XF2 and d3 = { ( (p,s), a, (q,s)) | (p,a,q) d1 and s  Q2 } U { ( (p,s), a, (p,t)) | p  Q1 and (s,a,t)  d2 } .

  10. Regular languages are closed under || operation 4. Given the following two DFAs : • Construction a NFAs M3 such that • L(M3) = L(M1) || L(M2). Use state transition table for your answer.

More Related