# Lecture 03

## Establishing regularity

$$L=\{w_1, w_2, ...,w_n: n\geq 2, w_{n-1} = 1\}$$

Proposition: $$L$$ is regular Proof: Aside:

• $$Q=\{q_{00}, q_{01}, q_{10}, q_{11}\}$$
• $$\Sigma=\{0,1\}$$
• $$\delta=...$$
• $$q_0=q_{00}$$
• $$F=\{q_{10}, q_{11}\}$$

First, $$M$$ does not accept $$\epsilon$$ because $$q_{00}\not\in\epsilon$$.

The only states that can be reached with one transition are $$q_{00}, q_{01}$$, neither of which is in $$F$$, so $$M$$ correctly does not accept them.

Let $$W=w_1,...,w_n$$, $$n\geq 2$$ where $$n_{n-1}=1$$. For any state $$q\in Q$$, $$\delta(q,1)\in\{q_{00}, q_{01}\}$$, so the state $$r_{n-1}$$ reached after reading $$n-1$$ symbols is $$q_{01}$$ or $$q_{11}$$. For any $$\sigma\in\{0,1\}$$ $$\delta(q_{01}, \sigma)\in\{q_{10}, q_{11}\}$$ and $$\delta(q_{11}, \sigma)\in\{q_{10}, q_{11}\}$$. In all these cases, we end up in a state in $$F$$ and $$M$$ correctly accepts.

When $$W=w_1,...,w_n$$, $$n\geq 2$$ where $$n_{n-1}=0$$, (similar argument shows that $$M$$ never accepts).

## Regular Expressions

Theorem If $$L$$ is a language over $$\Sigma$$ that satisfies

• $$L=\emptyset$$
• $$L=\{\epsilon\}$$
• $$L=\{\sigma\}$$ for $$\sigma\in\Sigma$$
• $$L=L_1\cup L_2$$ for some regular languages $$L_1$$, $$L_2$$.
• $$L=L_1L_2=\{w_1w_2: w_1\in L_1, w_2\in L_2\}$$ for regular $$L_1$$, $$L_2$$
• $$L=L_1^*=\{w_1,...,w_n: n\geq 0, w_1,...,w_n\in L_1\}$$ for regular $$L_1$$

then $$L$$ is regular

Proof: Definition: A string $$R$$ over $$\Sigma\cup\{\bar\epsilon,|,*,(,)\}$$ is regular expression if

• $$R=\epsilon$$
• $$R=\bar\epsilon$$
• $$R=\sigma$$ for any $$\sigma\in\Sigma$$
• $$R=R_1|R_2$$ for any regular expression $$R_1$$, $$R_2$$
• $$R=R_1R_2$$ for any regular expression $$R_1$$, $$R_2$$
• $$R=R_1^*$$ for any regular expression $$R_1$$
• $$R=(R_1)$$ for any regular expression $$R_1$$

Definition $$L(R)$$ is the language represented by regular expression $$R$$

• exercise Define "representation of languages by regular expressions"

exercise Define a regular expression that represents the language

1. All strings that end with $$1$$
• $$(0|1)*1$$
2. All strings that with even number of $$1$$s
• $$0*(0*10*1)*$$
3. All string with even number of $$0$$s and even number of $$1$$s

## Kleene's Theorem

Theorem The language $$L$$ is regular if and only if it can be represented by a regular expression.

#### Proof Sketch

1. RE $$\rightarrow$$ NFA, we already saw (Thompson's algorithm 1968).
2. DFA $$\rightarrow$$ RE (via generalized NFAs)
2. Replace $$a,b$$ transition
3. Remove states of $$M$$ one at a time