Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Module 17 Closure Properties of Language class LFSA –Remember ideas used in solvable languages unit –Set complement –Set intersection, union, difference,

Similar presentations


Presentation on theme: "1 Module 17 Closure Properties of Language class LFSA –Remember ideas used in solvable languages unit –Set complement –Set intersection, union, difference,"— Presentation transcript:

1 1 Module 17 Closure Properties of Language class LFSA –Remember ideas used in solvable languages unit –Set complement –Set intersection, union, difference, symmetric difference

2 2 LFSA is closed under set complement If L is in LFSA, then L c is in LFSA Proof –Let L be an arbitrary language in LFSA –Let M be the FSA such that L(M) = L M exists by definition of L in LFSA –Construct FSA M’ from M –Argue L(M’) = L c –There exists an FSA M’ such that L(M’) = L c –L c is in LFSA

3 3 Visualization Let L be an arbitrary language in LFSA Let M be the FSA such that L(M) = L M exists by definition of L in LFSA Construct FSA M’ from M Argue L(M’) = L c L c is in LFSA LcLc L LFSA FSA’s M M’

4 4 Construct FSA M’ from M What did we do when we proved that REC, the set of solvable languages, is closed under set complement? Construct program P’ from program P Can we translate this to the FSA setting?

5 5 Construct FSA M’ from M M = (Q, , q 0, A,  ) M’ = (Q’,  ’, q’, A’,  ’) –M’ should say yes when M says no –M’ should say no when M says yes –How? Q’ = Q  ’ =  q’ = q 0  ’ =  A’ = Q-A

6 6 Example 1 2 3 a a a b b b FSA M 1 2 3 a a a b b b FSA M’ Q’ = Q  ’ =  q’ = q 0  ’ =  A’ = Q-A

7 7 Construction is an algorithm * Set Complement Construction –Algorithm Specification Input: FSA M Output: FSA M’ such that L(M’) = L(M) c –Comments This algorithm can be in any computational model. –It does not have to be (and typically is not) an FSA These set closure constructions are useful. –More on this later Construction Algorithm FSA M FSA M’

8 8 Specification of the algorithm Your algorithm must give a complete specification of M’ in terms of M –Example: Let input FSA M = (Q, , q 0, A,  ) Output FSA M’ = (Q’,  ’, q’, A’,  ’) where –Q’ = Q –  ’ =  –q’ = q 0 –  ’ =  –A’ = Q-A When I ask for such a construction algorithm specification, this type of answer is what I am looking for. Further algorithmic details on how such an algorithm would work are unnecessary. Construction Algorithm FSA M FSA M’

9 9 LFSA closed under Set Intersection Operation (also set union, set difference, and symmetric difference)

10 10 LFSA closed under set intersection operation * Let L 1 and L 2 be arbitrary languages in LFSA Let M 1 and M 2 be FSA’s s.t. L(M 1 ) = L 1, L(M 2 ) = L 2 –M 1 and M 2 exist by definition of L 1 and L 2 in LFSA Construct FSA M 3 from FSA’s M 1 and M 2 Argue L(M 3 ) = L 1 intersect L 2 There exists FSA M 3 s.t. L(M 3 ) = L 1 intersect L 2 L 1 intersect L 2 is in LFSA

11 11 Visualization Let L 1 and L 2 be arbitrary languages in LFSA Let M 1 and M 2 be FSA’s s.t. L(M 1 ) = L 1, L(M 2 ) = L 2 M 1 and M 2 exist by definition of L 1 and L 2 in LFSA Construct FSA M 3 from FSA’s M 1 and M 2 Argue L(M 3 ) = L 1 intersect L 2 There exists FSA M 3 s.t. L(M 3 ) = L 1 intersect L 2 L 1 intersect L 2 is in LFSA L 1 intersect L 2 L1L1 L2L2 LFSA M3M3 M1M1 M2M2 FSA’s

12 12 Algorithm Specification Input –Two FSA’s M 1 and M 2 Output –FSA M 3 such that L(M 3 ) = L(M 1 ) intersection L(M 2 ) FSA M 1 FSA M 2 FSA M 3 Alg

13 13 Use Old Ideas Key concept: Try ideas from previous closure property proofs Example –How did the algorithm that was used to prove that REC is closed under set intersection work? –If we adapt this approach, what should M 3 do with respect to M 1, M 2, and the input string? FSA M 1 FSA M 2 FSA M 3 Alg

14 14 1 Run M 1 and M 2 Simultaneously 0 2 0 0 0 0 1 1 1 1 M1M1 A B 0 10,1 M2M2,A 0,A1,A2,A,B 0,B1,B2,B M3M3 What happens when M 1 and M 2 run on input string 11010? FSA M 1 FSA M 2 FSA M 3 Alg

15 15 Construction * Input –FSA M 1 = (Q 1,  , q 1,  , A 1 ) –FSA M 2 = (Q 2,  , q 2,  , A 2 ) Output –FSA M 3 = (Q 3,  , q 3,  , A 3 ) –What is Q 3 ? Q 3 = Q 1 X Q 2 where X is cartesian product In this case, Q 3 = {(,A), (,B), (0,A), (0,B), (1,A), (1,B), (2,A), (2,B)} –What is  3 ?  3 =  1 =  2 In this case,  3 = {0,1} 1 0 2 0 0 0 0 1 1 1 1 M1M1 A B 0 10,1 M2M2

16 16 Construction * Input –FSA M 1 = (Q 1,  , q 1,  , A 1 ) –FSA M 2 = (Q 2,  , q 2,  , A 2 ) Output –FSA M 3 = (Q 3,  , q 3,  , A 3 ) –What is q 3 ? q 3 = (q 1, q 2 ) In this case, q 3 = (,A) –What is A 3 ? A 3 = {(p, q) | p in A 1 and q in A 2 } In this case, A 3 = {(0,B)} 1 0 2 0 0 0 0 1 1 1 1 M1M1 A B 0 10,1 M2M2

17 17 Construction Input –FSA M 1 = (Q 1,  , q 1,  , A 1 ) –FSA M 2 = (Q 2,  , q 2,  , A 2 ) Output –FSA M 3 = (Q 3,  , q 3,  , A 3 ) –What is  3 ? For all p in Q 1, q in Q 2, a in ,  3 ((p,q),a) = (  1 (p,a),  2 (q,a)) In this case, –  3 ((0,A),0) = (  1 (0,0),  2 (A,0)) – = (0,B) –  3 ((0,A),1) = (  1 (0,1),  2 (A,1)) – = (1,A) 1 0 2 0 0 0 0 1 1 1 1 M1M1 A B 0 10,1 M2M2

18 18 Example Summary 1 0 2 0 0 01 1 1 M1M1 A B 0 10,1 M2M2,A 0,A1,A2,A,B 0,B 1,B2,B M3M3 01 0 1 0 1 0 1 0 1 0 1 0 1

19 19 Observation Input –FSA M 1 = (Q 1,  , q 1,  , A 1 ) –FSA M 2 = (Q 2,  , q 2,  , A 2 ) Output –FSA M 3 = (Q 3,  , q 3,  , A 3 ) –What is A 3 ? A 3 = {(p, q) | p in A 1 and q in A 2 } What if operation were different? –Set union, set difference, symmetric difference

20 20 Observation continued * Input –FSA M 1 = (Q 1,  , q 1,  , A 1 ) –FSA M 2 = (Q 2,  , q 2,  , A 2 ) Output –FSA M 3 = (Q 3,  , q 3,  , A 3 ) –What is A 3 ? Set intersection: A 3 = {(p, q) | p in A 1 and q in A 2 } Set union: A 3 = {(p, q) | p in A 1 or q in A 2 } Set difference: A 3 = {(p, q) | p in A 1 and q not in A 2 } Symmetric difference: A 3 = {(p, q) | (p in A 1 and q not in A 2 ) or (p not in A 1 and q in A 2 ) }

21 21 Observation conclusion LFSA is closed under –set intersection –set union –set difference –symmetric difference The constructions used to prove these closure properties are essentially identical

22 22 Comments * You should be able to execute this algorithm –Convert two FSA’s into a third FSA with the correct properties. You should understand the idea behind this algorithm –The third FSA essentially runs both input FSA’s simultaneously on any input string –How we set A 3 depending on the specific set operation You should understand how this algorithm can be used to simplify design of FSA’s You should be able to construct new algorithms for new closure property proofs

23 23 Comparison * L 1 intersect L 2 L1L1 L2L2 LFSA M3M3 M1M1 M2M2 FSA’s LFSA REC FSA’s C++ Programs L L M P


Download ppt "1 Module 17 Closure Properties of Language class LFSA –Remember ideas used in solvable languages unit –Set complement –Set intersection, union, difference,"

Similar presentations


Ads by Google