# Lets Recapitulate 1 Regular Languages DFAs NFAs Regular

• Slides: 53

Let’s Recapitulate 1

Regular Languages DFAs NFAs Regular Grammars Regular Expressions 2

A standard representation of a regular language : A DFA that accepts A NFA that accepts A regular expression that generates A regular grammar that generates 3

When we say: “We are given a Regular Language “ We mean: Language in a standard representation 4

Elementary Questions about Regular Languages 5

Question: Given regular language how can we check if a string ? 6

Question: Answer: Given regular language how can we check if a string ? Take the DFA that accepts and check if is accepted 7

Question: Answer: Given regular language how can we check if is empty, finite, infinite ? Take the DFA that accepts Then check the DFA 8

If there is a walk from the start state to a final state then: is not empty Otherwise empty If the walk contains a cycle then: is infinite Otherwise finite 9

Question: Given regular languages how can we check if and ? 10

Question: Given regular languages how can we check if and ? Answer: take And find if 11

Question: Given language how can we check if is not a regular language ? 12

Question: Given language how can we check if is not a regular language ? Answer: The answer is not obvious We need the Pumping Lemma 13

The Pigeonhole Principle 14

4 pigeons 3 pigeonholes 15

A pigeonhole must have two pigeons 16

pigeons. . . pigeonholes. . . 17

The Pigeonhole Principle pigeons pigeonholes There is a pigeonhole with at least 2 pigeons . . . 18

The Pigeonhole Principle and DFAs 19

DFA with states 20

In walks of strings: no state is repeated 21

In walks of strings: a state is repeated 22

If the walk of string has length Then a state is repeated 23

The pigeonhole principle: If in a walk: Then: transitions states A state is repeated 24

In other words: transitions are pigeons states are pigeonholes 25

In general: A string has length A state must be repeated in the walk . . . number of states . . . 26

The Pumping Lemma 27

Take an infinite regular language DFA that accepts states 28

Take string with There is a walk with label : . . 29

If string number of states has length Then, from the pigeonhole principle: A state is repeated in the walk . . . 30

Write . . . 31

Observations : number of states length . . . 32

Observation: The string . . . is accepted . . . 33

Observation: The string is accepted . . . 34

Observation: The string is accepted . . . 35

In General: The string is accepted . . . 36

In other words, we described: The Pumping Lemma 37

The Pumping Lemma: 1. Given a infinite regular language 2. There exists an integer 3. For any string with length 4. We can write 5. With and 6. Such that: string 38

Applications of the Pumping Lemma 39

Claim: The language is not regular Proof: Use the Pumping Lemma 40

Proof: Assume for contradiction that is a regular language Since is infinite we can apply the Pumping Lemma 41

Let be the integer in the Pumping Lemma Pick a string such that: length Example: pick 42

Write From the Pumping Lemma it must be that length Therefore: 43

From the Pumping Lemma: Thus: 44

Therefore: Our assumption that is a regular language cannot be true CONCLUSION: is not a regular language 46

Claim: The language is not regular Proof: Use the Pumping Lemma 47

Proof: Assume for contradiction that is a regular language Since is infinite we can apply the Pumping Lemma 48

Let be the integer in the Pumping Lemma Pick a string such that: length Example: pick 49

Write From the Pumping Lemma it must be that length Therefore: 50

From the Pumping Lemma: Thus: 51