irregular languages
play

Irregular Languages CSCI 3130 Formal Languages and Automata Theory - PowerPoint PPT Presentation

1/18 Irregular Languages CSCI 3130 Formal Languages and Automata Theory Siu On CHAN Chinese University of Hong Kong Fall 2015 Seems to require a DFA with infinitely many states 2/18 Non-regular languages Are there irregular languages?


  1. 1/18 Irregular Languages CSCI 3130 Formal Languages and Automata Theory Siu On CHAN Chinese University of Hong Kong Fall 2015

  2. Seems to require a “DFA” with infinitely many states 2/18 Non-regular languages Are there irregular languages? Candidate from last lecture: Why do we believe it is irregular? Afuer reading the first half, need to remember number of zeros so far 11, 0101, 001001, 00010001, … Infinitely many possibilities Let’s formally prove this intuition L = { 0 n 10 n 1 | n � 0 } (duplicate of language of 0 ∗ 1 = { 1 , 01 , 001 , 0001 , . . . } )

  3. 2/18 Non-regular languages Are there irregular languages? Candidate from last lecture: Why do we believe it is irregular? Afuer reading the first half, need to remember number of zeros so far 11, 0101, 001001, 00010001, … Infinitely many possibilities Let’s formally prove this intuition L = { 0 n 10 n 1 | n � 0 } (duplicate of language of 0 ∗ 1 = { 1 , 01 , 001 , 0001 , . . . } ) Seems to require a “DFA” with infinitely many states

  4. 3/18 Distinct states for 01 and 0001 1 0 0 1 0 q 1 0 0 1 0 q Claim If a deterministic automaton accepts L = { 0 n 10 n 1 | n � 0 } , the state q it reaches upon reading 01 must be different from the state q ′ it reaches upon reading 0001 ✓ q ′ (= q ′ ) ✗

  5. 4/18 Distinct states for 01 and 0001 If r is accepting state, it accepts 000101 01 0001 01 r q Reason: afuer going to q , if it reads 01 and reaches r … Why not? 0001 01 q reading 0001 Claim If a deterministic automaton accepts L = { 0 n 10 n 1 | n � 0 } , the state q it reaches upon reading 01 must be different from the state q ′ it reaches upon ✗ (= q ′ ) (= q ′ ) ✗ If r is not accepting, it rejects 0101 ✗

  6. 5/18 General case: distinguishable strings If r is accepting state, it accepts yz z y x r q Reason: y x q y x q If a deterministic automaton accepts L , if there are strings x and y such that xz ∈ L but yz / ∈ L , then the automaton must be in two different states upon reading x and y q ′ ✓ (= q ′ ) ✗ (= q ′ ) ✗ If r is not accepting, it rejects xz ✗

  7. 6/18 x x and y are distinguishable by L if for some string z , If x and y are distinguishable by L , any deterministic automaton accepting L must reach different states upon reading x and y q Distinguishable strings x y y q we have xz ∈ L and yz / ∈ L (or the other way round) q ′ ✓ (= q ′ ) ✗

  8. 7/18 automaton accepting L must have at least n states x n q n Requires many states x n Strings x 1 , . . . , x n are called pairwise distinguishable by L if every pair x i and x j are distinguishable by L , for any i � = j . If strings x 1 , . . . , x n are pairwise distinguishable by L , any deterministic q 1 q 1 x 1 x 1 x 2 x 2 q 3 q 2 x 3 q n − 1 ✓ ✗

  9. 8/18 Pigeonhole principle If you put 5 balls into 4 bins, then (at least) two balls end up in the same bin More generally then (at least) two balls end in the same bin If you put n balls into (at most) n − 1 bins,

  10. 9/18 Pigeonhole principle

  11. 10/18 Requires many states automaton accepting L must have at least n states Otherwise: q i x i x j x n If strings x 1 , . . . , x n are pairwise distinguishable by L , any deterministic q 1 x 1 q n − 1 If there are (at most) n − 1 states, by pigeonhole principle, two different strings x i and x j must end up at the same state, but: If x i and x j are distinguishable by L , any deterministic automaton accepting L must reach different states upon reading x i and x j ✗

  12. 0 i 1 i 1 11/18 0 n 10 n 1 is not regular Suffices find an infinitely sequence of strings that are pairwise Afuer reading the first half, need to remember number of zeros so far 11, 0101, 001001, 00010001, … Take z 0 i 1 L 0 j 10 i 1 L distinguishable by L = { 0 n 10 n 1 | n � 0 } 1 , 01 , 001 , 0001 , . . . are pairwise distinguishable by L ( i � = j ) Why are 0 i 1 and 0 j 1 distinguishable by L ?

  13. 11/18 0 n 10 n 1 is not regular Suffices find an infinitely sequence of strings that are pairwise Afuer reading the first half, need to remember number of zeros so far 11, 0101, 001001, 00010001, … distinguishable by L = { 0 n 10 n 1 | n � 0 } 1 , 01 , 001 , 0001 , . . . are pairwise distinguishable by L ( i � = j ) Why are 0 i 1 and 0 j 1 distinguishable by L ? Take z = 0 i 1 0 i 1 0 i 1 ∈ L 0 j 10 i 1 / ∈ L

  14. 12/18 Which of these are (ir)regular? L 1 = { x | x has the same number of 0s and 1s } L 2 = { 0 n 1 m | n > m � 0 } L 3 = { x | x has the same number of patterns 01 and 11 } L 4 = { x | x has the same number of patterns 01 and 10 } L 5 = { x | x has a different number of 0s and 1s }

  15. Why are 0 i and 0 j distinguishable by L ? 13/18 1 i i 0 j L i 0 i j Take z i are pairwise distinguishable by L 0 00 000 Need to remember number of 0s (or 1s) read so far Why does it require infinitely many states to accept? L L 1 = Same number of 0s and 1s

  16. 13/18 Why does it require infinitely many states to accept? Need to remember number of 0s (or 1s) read so far Take z 1 i 0 i i L 0 j i L L 1 = Same number of 0s and 1s ε, 0 , 00 , 000 , . . . are pairwise distinguishable by L 1 ( i � = j ) Why are 0 i and 0 j distinguishable by L 1 ?

  17. 13/18 Why does it require infinitely many states to accept? Need to remember number of 0s (or 1s) read so far L 1 = Same number of 0s and 1s ε, 0 , 00 , 000 , . . . are pairwise distinguishable by L 1 ( i � = j ) Why are 0 i and 0 j distinguishable by L 1 ? Take z = 1 i 0 i 1 i ∈ L 1 0 j 1 i / ∈ L 1

  18. Take z 14/18 1 i 0 i i L 0 j i L L 2 = { 0 n 1 m | n > m } Like L 1 , need to remember number of 0s read so far ε, 0 , 00 , 000 , . . . are pairwise distinguishable by L 2 ( i > j ) Why are 0 i and 0 j distinguishable by L 2 ?

  19. 14/18 L 2 = { 0 n 1 m | n > m } Like L 1 , need to remember number of 0s read so far ε, 0 , 00 , 000 , . . . are pairwise distinguishable by L 2 ( i > j ) Why are 0 i and 0 j distinguishable by L 2 ? Take z = 1 i − 1 0 i 1 i − 1 ∈ L 2 0 j 1 i − 1 / ∈ L 2

  20. 01 i 1 i 01 j 1 i Example: 010101111 15/18 Need to remember the number of 01s read so far Take z 1 i L L i L 3 = same number of 01s and 11s ε , 01, 0101, 010101, . . . are pairwise distinguishable by L 3 Why are ( 01 ) i and ( 01 ) j distinguishable by L 3 ? ( i > j )

  21. 15/18 Need to remember the number of 01s read so far L 3 = same number of 01s and 11s ε , 01, 0101, 010101, . . . are pairwise distinguishable by L 3 Why are ( 01 ) i and ( 01 ) j distinguishable by L 3 ? ( i > j ) Take z = 1 i ( 01 ) i 1 i ∈ L 3 ( 01 ) j 1 i / ∈ L 3 ( i = 3) Example: 010101111

  22. In fact, 01 j 10 i 16/18 L because there are as many 01 as 10 In fact, L is regular (see Week 2 tutorial) L 4 = same number of 01s and 10s ε , 01, 0101, 010101, . . . are pairwise distinguishable by L 4 Why are ( 01 ) i and ( 01 ) j distinguishable by L 4 ? ( i > j ) Take z = ( 10 ) i ( 01 ) i ( 10 ) i ∈ L 4 ( 10 ) j ( 10 ) i / ∈ L 4 ( i = 3) Example: 010101101010

  23. 16/18 L 4 = same number of 01s and 10s ε , 01, 0101, 010101, . . . are pairwise distinguishable by L 4 Why are ( 01 ) i and ( 01 ) j distinguishable by L 4 ? ( i > j ) Take z = ( 10 ) i ( 01 ) i ( 10 ) i ∈ L 4 ( 10 ) j ( 10 ) i / ∈ L 4 ( i = 3) Example: 010101101010 In fact, ( 01 ) j ( 10 ) i ∈ L 4 because there are as many 01 as 10 In fact, L 4 is regular (see Week 2 tutorial)

  24. 17/18 Yes If L were regular, then so is L L x x has the same number of 0s and 1s But we saw that L is irregular, therefore so is L L 5 = different number of 0s and 1s Is L 5 irregular?

  25. 17/18 Yes L 5 = different number of 0s and 1s Is L 5 irregular? If L 5 were regular, then so is L 5 = L 1 = { x | x has the same number of 0s and 1s } But we saw that L 1 is irregular, therefore so is L 5

  26. nested requires unbounded amount of memory 18/18 An exercise What does it mean? Language computational problem DFA machine with finite memory L is irregular checking whether (arbitrarily long) strings are properly L 6 = properly nested strings of parentheses Σ = { ( , ) } () , (()) , ()() are in L 6 ( , ) , )( are not Exercise: show that L 6 is irregular

  27. 18/18 An exercise What does it mean? nested requires unbounded amount of memory L 6 = properly nested strings of parentheses Σ = { ( , ) } () , (()) , ()() are in L 6 ( , ) , )( are not Exercise: show that L 6 is irregular Language = computational problem DFA = machine with finite memory L 6 is irregular ⇒ checking whether (arbitrarily long) strings are properly

Recommend


More recommend