TDDD14/TDDD85 Slides for Lecture 4, 2017 Slides originally for - - PowerPoint PPT Presentation

tddd14 tddd85 slides for lecture 4 2017 slides originally
SMART_READER_LITE
LIVE PREVIEW

TDDD14/TDDD85 Slides for Lecture 4, 2017 Slides originally for - - PowerPoint PPT Presentation

TDDD14/TDDD85 Slides for Lecture 4, 2017 Slides originally for TDDD65 by Gustav Nordh Some differences to Kozen: - Closure properties for regular languages uses -NFA construc- tions instead of DFA constructions. - Patterns are not used. -


slide-1
SLIDE 1

TDDD14/TDDD85 Slides for Lecture 4, 2017 Slides originally for TDDD65 by Gustav Nordh Some differences to Kozen:

  • Closure properties for regular languages uses ε-NFA construc-

tions instead of DFA constructions.

  • Patterns are not used.
  • Conversion of DFA to regular expression uses the GNFA method,

instead of Kozens method.

slide-2
SLIDE 2

Closure properties of regular languages

The natural numbers N = {0, 1, 2, 3, . . . } are closed under multiplication in the sense that for any natural numbers x and y, x · y is again a natural number The natural numbers are not closed under subtraction (3 − 5 = −2 which is not a natural number) Definition We say that a class of languages C is closed under an

  • peration op if applying op to any languages from C results in a

language in C

slide-3
SLIDE 3

Closure properties of regular languages

Understanding under which operations a class of languages C is closed is important!

slide-4
SLIDE 4

Closure properties of regular languages

Theorem The class of regular languages is closed under union (if L1 and L2 are regular languages, then so is L1 ∪ L2) Proof.

ε ε

slide-5
SLIDE 5

Closure properties of regular languages

Theorem The class of regular languages is closed under concatenation (if L1 and L2 are regular languages, then so is L1L2) Proof.

ε ε

slide-6
SLIDE 6

Closure properties of regular languages

Theorem The class of regular languages is closed under star (if L1 is a regular language, then so is L∗

1)

Proof.

ε ε ε

slide-7
SLIDE 7

Regular expressions

slide-8
SLIDE 8

Definition of regular expressions

Definition L(R) denotes the language described by the regular expression R. R is a regular expression if R is

1

a for a ∈ Σ, L(a) = {a}

2

ε, L(ε) = {ε}

3

∅, L(∅) = ∅

4

R1 + R2 where R1 and R2 are regular expressions, L(R1 + R2) = L(R1) ∪ L(R2)

5

R1R2 where R1 and R2 are regular expressions, L(R1R2) = L(R1)L(R2)

6

R∗

1 where R1 is a regular expression, L(R∗ 1) = L(R1)∗ ∗ has higher precedence than concatenation and +,

concatenation has higher precedence than +

slide-9
SLIDE 9

Examples of regular expressions

Example (0 + 1)∗0 binary strings ending with 0 (0 + 1)∗00(0 + 1)∗ binary strings with at least two consecutive 0’s (0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9)∗1234(0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9)∗

slide-10
SLIDE 10

Equivalence with finite automata

Theorem A language is regular if and only if some regular expression describes it

slide-11
SLIDE 11

Equivalence with finite automata

Lemma If a language is described by a regular expression then it is recognized by a NFA

slide-12
SLIDE 12

Equivalence with finite automata

Lemma If a language is described by a regular expression then it is recognized by a NFA Proof. R = a for a ∈ Σ, L(R) = {a}

a

R = ε, L(R) = {ε} R = ∅, L(R) = ∅

slide-13
SLIDE 13

Equivalence with finite automata

Lemma If a language is described by a regular expression then it is recognized by a NFA Proof. R = R1 + R2, L(R) = L(R1) ∪ L(R2)

ε ε

slide-14
SLIDE 14

Equivalence with finite automata

Lemma If a language is described by a regular expression then it is recognized by a NFA Proof. R = R1R2, L(R) = L(R1)L(R2)

ε ε

slide-15
SLIDE 15

Equivalence with finite automata

Lemma If a language is described by a regular expression then it is recognized by a NFA Proof. R = R∗

1, L(R) = L(R1)∗ ε ε ε

slide-16
SLIDE 16

Equivalence with finite automata: Example

Example (0 + 1)∗ to NFA 1

1

0 + 1

1 ε ε

(0 + 1)∗

1 ε ε ε ε ε

slide-17
SLIDE 17

Equivalence with finite automata

NFA DFA RegExp Subset Construction Closure Properties

slide-18
SLIDE 18

Equivalence with finite automata

NFA DFA RegExp Subset Construction Closure Properties GNFA Construction

slide-19
SLIDE 19

Equivalence with finite automata

Lemma If a language is recognized by a DFA then it is described by a regular expression Idea: Use a generalized NFA (GNFA) where the transition arrows can be labeled by regular expressions

q1 q2 ab∗ ab + ba (aa)∗ a∗

slide-20
SLIDE 20

Equivalence with finite automata

Lemma If a language is recognized by a DFA then it is described by a regular expression Idea: Use a generalized NFA (GNFA) where the transition arrows can be labeled by regular expressions Given a DFA Add a new start state with an ε transition to the old start state Add a new accept state with ε transitions from all old accept states Replace transitions of the form a, b, c by a + b + c

slide-21
SLIDE 21

Equivalence with finite automata

Lemma If a language is recognized by a DFA then it is described by a regular expression Add a new start state with an ε transition to the old start state Add a new accept state with ε transitions from all old accept states Replace transitions of the form a, b, c by a + b + c

q1 q2 1 1

slide-22
SLIDE 22

Equivalence with finite automata

Lemma If a language is recognized by a DFA then it is described by a regular expression Add a new start state with an ε transition to the old start state Add a new accept state with ε transitions from all old accept states Replace transitions of the form a, b, c by a + b + c

q1 q2 qs qF 1 ε ε 1

slide-23
SLIDE 23

Equivalence with finite automata

Lemma If a language is recognized by a DFA then it is described by a regular expression Add a new start state with an ε transition to the old start state Add a new accept state with ε transitions from all old accept states Replace transitions of the form a, b, c by a + b + c Eliminate a state different from the start and accept state (reducing the number of states by 1)

slide-24
SLIDE 24

Equivalence with finite automata

Lemma If a language is recognized by a DFA then it is described by a regular expression Eliminate a state different from the start and accept state (reducing the number of states by 1)

qe q2 q1 R3 R4 R1 R2

slide-25
SLIDE 25

Equivalence with finite automata

Lemma If a language is recognized by a DFA then it is described by a regular expression Eliminate a state different from the start and accept state (reducing the number of states by 1)

qe q2 q1 R3 R4 R1 R2 q2 q1 R1R∗

2R3 + R4

slide-26
SLIDE 26

Equivalence with finite automata

Lemma If a language is recognized by a DFA then it is described by a regular expression Eliminate a state different from the start and accept state (reducing the number of states by 1)

q1 q2 qs qF 1 ε ε 1

slide-27
SLIDE 27

Equivalence with finite automata

Lemma If a language is recognized by a DFA then it is described by a regular expression Eliminate q2

q1 q2 qs qF 1 ε ε 1

slide-28
SLIDE 28

Equivalence with finite automata

Lemma If a language is recognized by a DFA then it is described by a regular expression Eliminate q2

q1 q2 qs qF 1 ε ε 1

Using the rule R1R∗

2R3 + R4 the new transition from q1 to qF is

labeled 11∗ε + ∅

slide-29
SLIDE 29

Equivalence with finite automata

Lemma If a language is recognized by a DFA then it is described by a regular expression Eliminate q2

q1 q2 qs qF 1 ε ε 1

Using the rule R1R∗

2R3 + R4 the new transition from q1 to qF is

labeled 11∗ε + ∅ Using the rule R1R∗

2R3 + R4 the new transition from q1 to q1 is

labeled 11∗0 + 0

slide-30
SLIDE 30

Equivalence with finite automata

Lemma If a language is recognized by a DFA then it is described by a regular expression Eliminate q2

q1 q2 qs qF 1 ε ε 1

q1 qs qF 11∗ε + ∅ ε 11∗0 + 0

slide-31
SLIDE 31

Equivalence with finite automata

Lemma If a language is recognized by a DFA then it is described by a regular expression Eliminate q1

q1 qs qF 11∗ε + ∅ ε 11∗0 + 0

slide-32
SLIDE 32

Equivalence with finite automata

Lemma If a language is recognized by a DFA then it is described by a regular expression Eliminate q1

q1 qs qF 11∗ε + ∅ ε 11∗0 + 0

Using the rule R1R∗

2R3 + R4 the new transition from qs to qF is

labeled ε(11∗0 + 0)∗(11∗ε + ∅) + ∅

slide-33
SLIDE 33

Equivalence with finite automata

Lemma If a language is recognized by a DFA then it is described by a regular expression Eliminate q1

q1 qs qF 11∗ε + ∅ ε 11∗0 + 0 qs qF ε(11∗0 + 0)∗(11∗ε + ∅) + ∅

slide-34
SLIDE 34

Equivalence with finite automata

NFA DFA RegExp Subset Construction Closure Properties GNFA Construction