105
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2006

CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University

  • Upload
    uriel

  • View
    45

  • Download
    0

Embed Size (px)

DESCRIPTION

CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2006. Content Languages, Alphabets and Strings Strings & String Operations Languages & Language Operations Regular Expressions Finite Automata, FA Deterministic Finite Automata, DFA. - PowerPoint PPT Presentation

Citation preview

Page 1: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

1

CD5560

FABER

Formal Languages, Automata and Models of Computation

Lecture 2

Mälardalen University2006

Page 2: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

2

Content

Languages, Alphabets and Strings

Strings & String Operations

Languages & Language Operations

Regular Expressions

Finite Automata, FA

Deterministic Finite Automata, DFA

Page 3: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

3

Languages, Alphabets and

Strings

Page 4: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

4

defined over an alphabet:

Languages

zcba ,,,,

A language is a set of strings

A String is a sequence of letters

An alphabet is a set of symbols

Page 5: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

5

Alphabets and Strings

We will use small alphabets:

abbaw

bbbaaav

abu

baaabbbaaba

baba

abba

ab

aStrings

ba,

Page 6: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

6

Operations on Strings

Page 7: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

7

String Operations

m

n

bbbv

aaaw

21

21

y bbbaaax abba

mn bbbaaawv 2121

Concatenation (sammanfogning)

xy abbabbbaaa

Page 8: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

8

12aaaw nR

naaaw 21 ababaaabbb

Reverse (reversering)

bbbaaababa

Example:

Longest odd length palindrome in a natural language:

saippuakauppias

(Finnish: soap sailsman)

Page 9: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

9

String Length

naaaw 21

1

2

4

a

aa

abba

nw Length:

Examples:

Page 10: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

10

Recursive Definition of Length

For any letter:

For any string :

Example:

1a

1wwawa

41111

11111

1

aab

abbabba

Page 11: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

11

Length of Concatenation

vuuv

853

8

vuuv

aababaabuv

5,

3,

vabaabv

uaabuExample:

Page 12: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

12

Proof of Concatenation Length

Claim:

Proof: By induction on the length

Induction basis:

From definition of length:

vuuv

v

1v

vuuuv 1

Page 13: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

13

Inductive hypothesis:

vuuv

nv

1nv

vuuv

Inductive step: we will prove

for

for

Page 14: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

14

Inductive Step

Write , where

From definition of length:

From inductive hypothesis:

Thus:

wav 1, anw

1

1

wwa

uwuwauv

wuuw

vuwauwuuv 1

END OF PROOF

Page 15: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

15

Empty String

A string with no letters: (Also denoted as )

Observations:

}{{}

0

abbaabbaabba

www

Page 16: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

16

Substring (delsträng)

Substring of string:

a subsequence of consecutive characters

String Substring

bbab

b

abba

ab

abbab

abbab

abbab

abbab

Page 17: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

17

Prefix and Suffix

Suffixesabbab

abbab

abba

abb

ab

a

b

ab

bab

bbab

abbab uvw

prefix

suffix

Prefixes

Page 18: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

18

Repetition

Example:

Definition:

n

n www... w

abbaabbaabba 2

0w

0abba

}

(String repeated n times)w

Page 19: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

19

The * (Kleene star) Operation

the set of all possible strings from alphabet

*

,,,,,,,,,*

,

aabaaabbbaabaaba

ba

[Kleene is pronounced "clay-knee“]

Page 20: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

20

The + Operation

: the set of all possible strings from

alphabet except

,ba

,,,,,,,,,* aabaaabbbaabaaba

*

,,,,,,,, aabaaabbbaabaaba

Page 21: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

21

Example

* , oj, fy, usch, ojoj, fyfy,uschusch, ojfy, ojusch

*

, fyoj , usch

oj, fy, usch, ojoj, fyfy,uschusch, ojfy, ojusch

Page 22: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

22

Operations on Languages

Page 23: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

23

Language

A language is any subset of

Example:

Languages:

*

,,,,,,,,*

,

aaabbbaabaaba

ba

},,,,,{

,,

aaaaaaabaababaabba

aabaaa

Page 24: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

24

Example

An infinite language }0:{ nbaL nn

Labb

aaaaabbbbb

aabb

ab

L

Page 25: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

25

Operations on Languages

The usual set operations

aaaaaabbbaaaaaba

ababbbaaaaaba

aaaabbabaabbbaaaaaba

,,,,

}{,,,

},,,{,,,

,,,,,,, aaabbabaabbaa ,,,,,,,,,* aabaaabbbaabaaba

LL *Complement:

Page 26: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

26

Reverse

}:{ LwwL RR

ababbaabababaaabab R ,,,,

}0:{

}0:{

nabL

nbaLnnR

nn

Examples:

Definition:

Page 27: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

27

Concatenation

Definition: 2121 ,: LyLxxyLL

baaabababaaabbaaaab

aabbaaba

,,,,,

,,,

Example

Page 28: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

28

Repeat

Definition:

Special case:

n

n LLLL

bbbbbababbaaabbabaaabaaa

babababa

,,,,,,,

,,,, 3

0

0

,, aaabbaa

L

Page 29: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

29

Example

}0:{ nbaL nn

}0,:{2 mnbabaL mmnn

2Laabbaaabbb

Page 30: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

30

Star-Closure (Kleene *)

Definition:

Example:

210* LLLL

,,,,

,,,,

,,

,

*,

abbbbabbaaabbaaa

bbbbbbaabbaa

bbabba

Page 31: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

31

Positive Closure

Definition

*L 21

LLL

,,,,

,,,,

,,

,

abbbbabbaaabbaaa

bbbbbbaabbaa

bba

bba

Page 32: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

32

Regular Expressions

Page 33: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

33

Regular Expressions: Recursive Definition

1

1

21

21

*

r

r

rr

rr

are Regular Expressions

,,Primitive regular expressions:

2rGiven regular expressions and 1r

Page 34: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

34

Examples

)(* ccbaA regular expression:

baNot a regular expression:

Page 35: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

35

Zero or more.

a* means "zero or more a's."

To say "zero or more ab's," that is,

{, ab, abab, ababab, ...}, you need to say (ab)*.

ab* denotes {a, ab, abb, abbb, abbbb, ...}.

cba ,,Building Regular Expressions

Page 36: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

36

One or more.

Since a* means "zero or more a's", you can use aa* (or equivalently, a*a) to mean "one or more a's.“

Similarly, to describe "one or more ab's," that is,

{ab, abab, ababab, ...}, you can use ab(ab)*.

cba ,,Building Regular Expressions

Page 37: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

37

Any string at all.

To describe any string at all (with = {a, b, c}), you can use (a+b+c)*.

Any nonempty string.

This can be written as any character from followed by any string at all: (a+b+c)(a+b+c)*.

cba ,,

Building Regular Expressions

Page 38: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

38

Any string not containing....

To describe any string at all that doesn't contain an a (with = {a, b, c}), you can use (b+c)*.

Any string containing exactly one...

To describe any string that contains exactly one a, put "any string not containing an a," on either side of the a, like this: (b+c)*a(b+c)*.

cba ,,Building Regular Expressions

Page 39: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

39

Languages of Regular Expressions

,...,,,,,*)( bcaabcaabcacbaL

Example

rL rlanguage of regular expression

Page 40: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

40

Definition

For primitive regular expressions:

aaL

L

L

Page 41: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

41

Definition (continued)

For regular expressions and

1r 2r

2121 rLrLrrL

2121 rLrLrrL

** 11 rLrL

11 rLrL

Page 42: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

42

Example *aba

*abaL *aLbaL

*aLbaL

*aLbLaL

*aba

,...,,,, aaaaaaba

,...,,,...,,, baababaaaaaa

Regular expression:

Page 43: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

43

Example

Regular expression

bbabar *

,...,,,,, bbbbaabbaabbarL

Page 44: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

44

Example

Regular expression

bbbaar **

}0,:{ 22 mnbbarL mn

Page 45: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

45

Example

Regular expression

*)10(00*)10( r

)(rL { all strings with at least

two consecutive 0 }

1,0

Page 46: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

46

Example

Regular expression

(consists of repeating 1’s and 01’s).

)0(*)011(1 r

)(rL = { all strings without

two consecutive 0 }

1,0

Page 47: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

47

Example

L = { all strings without

two consecutive 0 }

)0(*1)0(**)011*1(2 r

(In order not to get 00 in a string, after each 0 there must be an 1, which means that strings of the form 1....101....1are repeated. That is the first parenthesis. To take into account strings that end with 0, and those consisting of 1’s solely, the rest of the expression is added.)

Equivalent solution:

Page 48: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

48

Equivalent Regular Expressions

Regular expressions and

1r 2r

)()( 21 rLrL are equivalent if

Definition:

Page 49: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

49

Example L = { all strings without

two consecutive 0 }

)0(*1)0(**)011*1(2 r

LrLrL )()( 21 1r 2randare equivalent

regular expressions.

)0(*)011(1 r

Page 50: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

50

Finite Automata

FA

Page 51: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

51

There is no formal definition for "automaton". Instead, there are various kinds of automata, each with it's own formal definition.

• has some form of input

• has some form of output

• has internal states,

• may or may not have some form of storage

• is hard-wired rather than programmable

Generally, an automaton

Page 52: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

52

Finite Automaton

Input

String

Output

String

Finite

Automaton

Page 53: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

53

Finite Accepter

Input

“Accept”

or

“Reject”

String

Finite

Automaton

Output

Page 54: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

54

Nodes = States Edges = Transitions

An edge with several symbols is a short-hand for several edges:

FA as Directed Graph

1qa

0q

1qba,0q1q

a

0qb

Page 55: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

55

Deterministic Finite AutomataDFA

Page 56: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

56

• Deterministic there is no element of choice• Finite only a finite number of states and arcs • Acceptors produce only a yes/no answer

DFA

Page 57: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

57

Transition Graph

initial

state

final

state

“accept”statetransition

abba -Finite Acceptor

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

},{ baAlphabet =

Page 58: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

58

Initial Configuration

Input Stringa b b a

1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

0q

Page 59: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

59

Reading the Input

a b b a

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

Page 60: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

60

a b b a

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

Page 61: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

61

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b b a

ba,

Page 62: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

62

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b b a

ba,

Page 63: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

63

0q 1q 2q 3q 4qa b b a

Output: “accept”

5q

a a bb

ba,

a b b a

ba,

Page 64: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

64

Rejection

1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b a

ba,

0q

Page 65: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

65

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b a

ba,

Page 66: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

66

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b a

ba,

Page 67: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

67

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b a

ba,

Page 68: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

68

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

Output:

“reject”

a b a

ba,

Page 69: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

69

Another Example

a

b ba,

ba,

0q 1q 2q

a ba

Page 70: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

70

a

b ba,

ba,

0q 1q 2q

a ba

Page 71: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

71

a

b ba,

ba,

0q 1q 2q

a ba

Page 72: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

72

a

b ba,

ba,

0q 1q 2q

a ba

Page 73: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

73

a

b ba,

ba,

0q 1q 2q

a ba

Output: “accept”

Page 74: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

74

Rejection

a

b ba,

ba,

0q 1q 2q

ab b

Page 75: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

75

a

b ba,

ba,

0q 1q 2q

ab b

Page 76: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

76

a

b ba,

ba,

0q 1q 2q

ab b

Page 77: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

77

a

b ba,

ba,

0q 1q 2q

ab b

Page 78: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

78

a

b ba,

ba,

0q 1q 2q

ab b

Output: “reject”

Page 79: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

79

Formal definitions

Deterministic Finite Accepter (DFA)

FqQM ,,,, 0

Q

0q

F

: set of states

: input alphabet

: transition function

: initial state

: set of final states

Page 80: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

80

Input Aplhabet

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

ba,

Page 81: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

81

Set of States

Q

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

543210 ,,,,, qqqqqqQ

ba,

Page 82: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

82

Initial State

0q

1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

0q

Page 83: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

83

Set of Final States

F

0q 1q 2q 3qa b b a

5q

a a bb

ba,

4qF

ba,

4q

Page 84: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

84

Transition Function

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

QQ :

ba,

Page 85: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

85

10 , qaq

2q 3q 4qa b b a

5q

a a bb

ba,

ba,

0q 1q

Page 86: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

86

50 , qbq

1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

0q

Page 87: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

87

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

32 , qbq

Page 88: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

88

Transition Function

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

a b0q

2q

5q

1q 5q

5q5q

3q

4q

1q 5q 2q

5q 3q

4q5q

5q 5q

Page 89: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

89

Extended Transition Function

*

QQ *:*

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

Page 90: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

90

20 ,* qabq

3q 4qa b b a

5q

a a bb

ba,

ba,

0q 1q 2q

Page 91: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

91

40 ,* qabbaq

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

Page 92: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

92

50 ,* qabbbaaq

1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

0q

Page 93: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

93

50 ,* qabbbaaq

1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

0q

Observation: There is a walk from to

with label

0q 5qabbbaa

Page 94: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

94

Recursive Definition

)),,(*(,*

,*

awqwaq

qq

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

Page 95: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

95

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

21

0

0

0

0

,

,,

,,,*

),,(*

,*

qbq

baq

baq

baq

abq

Page 96: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

96

Languages Accepted by DFAs

Take DFA

Definition:

The language contains

all input strings accepted by

= { strings that drive to a final state}

M

MLM

ML M

Page 97: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

97

Example

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

abbaML M

accept

},{ baAlphabet =

Page 98: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

98

Another Example

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

abbaabML ,, M

acceptacceptaccept

},{ baAlphabet =

Page 99: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

99

Formally

For a DFA

Language accepted by :

FqQM ,,,, 0

M

FwqwML ,*:* 0

alphabet transition

function

initial

state

final

states

Page 100: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

100

Observation

Language accepted by

FwqwML ,*:* 0

M

FwqwML ,*:* 0

MLanguage rejected by

Page 101: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

101

More Examples

a

b ba,

ba,

0q 1q 2q

}0:{ nbaML n

accept trap state},{ baAlphabet =

Page 102: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

102

ML = { all strings with prefix }ab

a b

ba,

0q 1q 2q

accept

ba,3q

ab

},{ baAlphabet =

Page 103: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

103

ML = { all strings without substring }001

0 00 001

1

0

1

10

0 1,0

}1,0{Alphabet =

Page 104: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

104

Regular Languages

All regular languages form a language family

LM MLL

A language is regular if there is

a DFA such that

Page 105: CD5560 FABER Formal Languages, Automata  and Models of Computation Lecture 2 Mälardalen University

105

Example

*,: bawawaL

a

b

ba,

a

b

ba

0q 2q 3q

4q

is regular

The language

},{ baAlphabet =