You are on page 1of 7

CSC4510 AUTOMATA

2.2 Accepting the Union, Intersection,
or Difference of Two Languages
2 3 Distinguishing One String from
2.3
Another

Accepting the Union, Intersection, or Difference of Two Languages

 Suppose that L1 and L2 are languages over 
 Given an FA that accepts L
Given an FA that accepts L1 and another that
and another that
accepts L2, we can construct one that accepts
L1∪L2 .
 The same approach works for L
Th
h
k f L1∩L2 and L
d L1–L
L2 .
 If x*, then knowing whether xL1 and whether
xL2 is enough to determine whether x
g
 L1∪L2.
2

2

1

or Difference of Two Languages  Theorem: Suppose M1 = (Q1. q . 2 A = {(p. • Given two machines. A1.  Q = Q1  Q2  q0 = (q1. . ) be defined as follows: Accepting the Union. 2)) are FAs accepting L p g 1 and L2. = {(p q) | p  A1 and q and q  A2}. . Intersection. q2. 3 4 2 . q) | p  A1 or q  A2}. q) | p 2. M accepts L1∪L2. A = {(p. and draw the necessary transitions. q1. q). Let M = (Q... Intersection.Accepting the Union. ) = (1(p. if : 1. )) Then. 3. q0. M accepts L1–L2. . q) | p  A1 and q ∉ A2}. or Difference of Two Languages Construct an FA Accepting L1∪L2 / L1∩L2 / L1–L2. q2)  ((p. 2(q. A2. M } M accepts L accepts L1∩L2.. A. A = {(p. ). create the Cartesian product of Given two machines create the Cartesian product of the state sets. 1) and M2 = (Q (Q2.

Intersection. or Difference of Two Languages  The FA below accepts L1∩L2. if possible. Intersection.b BQ AP AR 5 CR 6 3 . pp p p g  The FA below accepts L1∪L2. and designate the appropriate accepting states. Accepting the Union. or Difference of Two Languages  Simplify the resulting FA.Accepting the Union. a.

) | g } Construct an FA that accepts L1∪L2.s a.b b 8 4 . or Difference of Two Languages L1={x(a.r b b b 1. Intersection.b)* | x contains the substring bba} .s a 7 2.p b 3.Accepting the Union.q b 1.q 3p 3. a a a 2. Intersection. or Difference of Two Languages Accepting the Union.p a 3r 3.p p b a b 1.b)* | x contains the substring ab} L2={x { ((a.r a a 3.

Accepting the Union.  aba and ab lead to different states. Intersection.  Could the FA be constructed with fewer than 3 states??  Are 3 states enough? 9 10 5 .  aba and aabbabbabaaaba lead to the same state. or Difference of Two Languages Distinguishing One String from Another The FA after combining all the accepting states.

x) ≠ *(q0. and yzL  A string z having this property is said to distinguish x and y with respect to L.)  Definition:  If L If L is a language over the alphabet . or L‐distinguishable. or xzL and yzL. q0. ) is an FA accepting L* accepting L  If x and y are two strings in * that are L‐distinguishable.  Equivalently.Distinguishing One String from Another (cont’d. and x is a language over the alphabet  and x and y and y are strings in *. x and y are L‐distinguishable if L/x ≠ L/y. then Q must contain at least n states. . where L/x = {z* | xzL}  Theorem: Suppose M = (Q. y)  For every n ≥ 2. 11 12 6 . A. if there is a string z* such that either xzL and yzL. then *(q0. if there is a set of n pairwise L‐distinguishable strings in *. then x and y are distinguishable with respect to L.) Distinguishing One String from Another (cont’d.

because aabL. create state u. if the next symbol is a it’s the start of a new occurrence.) Distinguishing One String from Another (cont’d.Distinguishing One String from Another (cont’d. because aabbL but not a prefix of any other string in L.)  Consruct an FA to accept L = {aa.  Let (u. aab}*{b}.  If the input starts with aa we need to leave state p because a and aa are L‐ di ti distinguishable.b) be r.  States t and u can be thought of as representing the end of an occurrence of aa or aab. i h bl t t t t  (t. so go back to p. 13 14 7 . create a new state t. the same as for an initial b. b) must be accepting.