Presentation is loading. Please wait.

Presentation is loading. Please wait.

More on showing L non-regular

Similar presentations


Presentation on theme: "More on showing L non-regular"— Presentation transcript:

1 More on showing L non-regular
MA/CSSE 474 Theory of Computation More on showing L non-regular (Using Closure) Decision Problems Slides 8-10 were hidden for I unhid for , should probably hide again for

2 This one has so many levels …
Your Questions? This one has so many levels … Previous class days' material Reading Assignments 8 problems Anything else

3 L = {aibj: i, j  0 and i  j} Try to use the Pumping Theorem by letting w = akbk+k!. Then y = ap for some nonzero p. Let q = (k!/p) + 1 (i.e., pump in (k!/p) times). Note that (k!/p) must be an integer because p < k. The number of a’s in the new string is k + (k!/p)p = k + k!. So the new string is ak+k!bk+k!, which has equal numbers of a’s and b’s and so is not in L. This slide is animated.

4 L = {aibj: i, j  0 and i  j} An easier way:
If L is regular then so is L. Is L regular? L = AnBn  {strings with a and b out of order} If L is regular, then so is L = L  a*b* = ___________

5 L = {aibjck: i, j, k ≥ 0 and (if i = 1 then j = k)}
Every string in L of length at least 1 is pumpable. But is L regular?

6 L = {aibjck: i, j, k ≥ 0 and (if i = 1 then j = k)}
Every string in L of length at least 1 is pumpable. Rewrite the final condition as: (i  1) or (j = k)

7 L = {aibjck: i, j, k ≥ 0 and (i  1 or j = k)}
Every string in L of length at least 1 is pumpable: If w has i = 0: if j  0, let y be b; otherwise, let y be c. Let q=0 or q>1. In each case i will still be 0 and thus not equal to 1, so the resulting string is in L. If i = 1: let y be a. Let q=0 or q>1. Then i will no longer equal 1, so the resulting string is in L. If i = 2: let y be aa. Let q=0 or q>1. Then i cannot equal 1, so the resulting string is in L. If i > 2: let y = a. Let q=0 or q>1. Then i cannot equal 1, so the resulting string is in L.

8 L = {aibjck: i, j, k ≥ 0 and (i  1 or j = k)}
But the closure theorems help. Suppose we guarantee that i = 1. If L is regular, then so is: L = L  ab*c*. L = {abjck : j, k ≥ 0 and j = k} We can easily use the Pumping Theorem to show that L is not regular:

9 L = {aibjck: i, j, k ≥ 0 and (i  1 or j = k)} An Alternative
If L is regular, then so is LR: LR = {ckbjai : i, j, k ≥ 0 and (i  1 or j = k)} Use Pumping to show that LR is not regular:

10 Functions from one Language to Another
Let firstchars(L) = {w : yL ( y = cx, c  L, x  L*, and w  c*)} Is the set of regular languages closed under firstchars? L firstchars(L) a*b* ca*cb*

11 Functions from one Language to Another
Let chop(L) = {w : xL ( x = x1cx2, x1  L*, x2  L*, c  L, |x1| = |x2|, and w = x1x2)} Is the set of regular languages closed under chop? L chop(L) a*b* a*db* Chop(a*db*) = AnBn and also strings of the form aidbj where i+j is an odd number The intersection of this with A*B* is not regular, so it is not regular.

12 Functions from One Language to Another
Let maxstring(L) = {w: w  L, z * (z    wz  L)} Is the set of regular languages closed under maxstring? L maxstring(L) a*b* ab*a a*b*a

13 The rest of Session 16's slides
(previous session) They are there as examples in case they are helpful for you as you do HW8 Next session we may or may not do some of these examples in class. Most of them are discussed in detail in the textbook.

14 Summary of algorithms we have so far
The next few slides are here for reference. I do not expect to spend class time on them. You should know how to do all of them, but during class exercises and homework you may simply "call" any of them as part of your decision procedures. ● Operate on FSMs without altering the language that is accepted: ● ndfsmtodfsm(M: NDFSM) ● minDFSM (M:DFSM) ● buildFSMcanonicalform(M:FSM)

15 Summary of Algorithms ● Compute functions of languages defined as FSMs: ● Given FSMs M1 and M2, construct a FSM M3 such that L(M3) = L(M2)  L(M1). ● Given FSMs M1 and M2, construct a new FSM M3 such that L(M3) = L(M2) L(M1). ● Given FSM M, construct an FSM M* such that L(M*) = (L(M))*. ● Given a DFSM M, construct an FSM M* such that L(M*) = L(M). ● Given two FSMs M1 and M2, construct an FSM M3 such that L(M3) = L(M2)  L(M1). L(M3) = L(M2) - L(M1). ● Given an FSM M, construct an FSM M* such that L(M*) = (L(M))R. ● Given an FSM M, construct an FSM M* that accepts letsub(L(M)).

16 Algorithms, Continued ● Converting between FSMs and regular expressions: ● Given a regular expression , construct an FSM M such that: L() = L(M) ● Given an FSM M, construct a regular expression  ● Algorithms that implement operations on languages defined by regular expressions: any operation that can be performed on languages defined by FSMs can be implemented by converting all regular expressions to equivalent FSMs and then executing the appropriate FSM algorithm.

17 Algorithms, Continued ● Converting between FSMs and regular grammars:
● Given a regular grammar G, construct an FSM M such that: L(G) = L(M) ● Given an FSM M, construct a regular grammar G L(G) = L(M). We have not yet discussed regular grammars. They are in the reading assignment for tomorrow. This is here for completeness.

18 Decision Procedures A decision procedure is an algorithm whose result is a Boolean value (in this course's context, sometimes we will write "yes" or "no" instead of "true" or "false"). It must: ● Halt, no matter what (correctly typed) input it is given. ● Always give the correct answer Usually a decision procedure has one or more parameters Zero-parameter decision procedures are not very interesting!

19 Answering Specific Questions
Given two regular expressions 1 and 2, is: (L(1)  L(2)) – {}  ? 1. From 1, construct an FSM M1 such that L(1) = L(M1). 2. From 2, construct an FSM M2 such that L(2) = L(M2). 3. Construct M such that L(M ) = L(M1)  L(M2). 4. Construct M such that L(M) = {}. 5. Construct M such that L(M ) = L(M ) - L(M). 6. If L(M ) is empty return False; else return True. (in tomorrow's exercises, you'll write an algorithm for step 6) For practice later: Given two regular expressions 1 and 2, are there at least 3 strings that are generated by both of them?

20 Decision Procedure Practice
Find a group of three students. Work together to write decision procedures for as many of the problems on the following slide as you can do in the allotted time.

21 Decision Procedures for Regular Languages
● Given a FSM M and a string w, does M accept w? ● Given a regular expression  and a string w, does  generate w? ● Given a FSM M, is L(M) empty? ● Given a FSM M, does L(M) = M*? ● Given a FSM M, is L(M) finite? ● Given a FSM M, is L(M) infinite? ● Given two FSMs M1 and M2, are they equivalent? ● Given an DFSM M, is M minimal?


Download ppt "More on showing L non-regular"

Similar presentations


Ads by Google