Discrete Mathematics -- Chapter 6: Languages: Finite Ch t 6 L Fi - - PowerPoint PPT Presentation

discrete mathematics
SMART_READER_LITE
LIVE PREVIEW

Discrete Mathematics -- Chapter 6: Languages: Finite Ch t 6 L Fi - - PowerPoint PPT Presentation

Discrete Mathematics -- Chapter 6: Languages: Finite Ch t 6 L Fi it State Machine Hung-Yu Kao ( ) Department of Computer Science and Information Engineering, N National Cheng Kung University l Ch K U Outline 6.1 Language:


slide-1
SLIDE 1

Discrete Mathematics

Ch t 6 L Fi it

  • - Chapter 6: Languages: Finite

State Machine

Hung-Yu Kao (高宏宇) Department of Computer Science and Information Engineering, N l Ch K U National Cheng Kung University

slide-2
SLIDE 2

Outline

6.1 Language: The Set Theory of Strings 6 2 Finite State Machines: A First Encounter 6.2 Finite State Machines: A First Encounter 6.3 Finite State Machines: A Second Encounter

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

2

slide-3
SLIDE 3

Language: The Set Theory of Strings

  • A finite state machine (FSM), which is an abstract model, has a

finite number of internal states where the machine remembers t i i f ti h it i i ti l t t certain information when it is in a particular state.

  • Strings: Sequence of symbols (characters) play a key role in the

processing of information by a computer. processing of information by a computer.

  • ∑ denote a nonempty finite set of symbols, collectively called an
  • alphabet. E.g., ∑ = {0, 1}, ∑ = {a, b, c, d, e}.
  • Definition 6.1: If ∑ is an alphabet and , we define the powers
  • f ∑ recursively as follows:

+

∈Z n

and

  • f

ion juxtaposit the denotes where }, , | { 2) 1)

1 1

y x xy y x xy

n n

∑ ∈ ∑ ∈ = ∑ ∑ = ∑

+ Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

3

j p }, , | { ) y y y y

slide-4
SLIDE 4

Language: The Set Theory of Strings

E 6 1 L t ∑

l h b t

Ex 6.1 : Let ∑ an alphabet.

i b l h i ld } { } 11 , 10 , 01 , 00 { }, 1 , { e.g., }, , | { 2, If

3 3 2 2

dd b d b y x xy n ∑ ∑ = ∑ = ∑ ∑ ∈ ∑ ∈ = ∑ =

Definition 6 2: For an alphabet ∑ we define ∑0 ={ } where

λ

. etc , , , e.g., strings, symbol

  • three

5 contain would }, , , , , {

3 3

cdd acb aaa e d c b a ∑ = ∑

λ

Definition 6.2: For an alphabet ∑ we define ∑

{ }, where denotes the empty string, i.e., the string consisting of no symbols taken from ∑. λ

since } { ) 1 ( λ λ ∑ ∉ ∑ ⊄

λ

| | 1 | } { | because } { ) 2 ( since } { ) 1 ( φ λ φ λ λ λ = ≠ = ≠ ∑ ∉ ∑ ⊄

Definition 6.3: If ∑ is an alphabet, then

U U

∗ ∈ ∞ = +

∑ ∑ ∑ = ∑ = ∑

+

1

) 1 (

n n n n n Z

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

4

U∞

= ∗

∑ = ∑ ) 2 (

n n

slide-5
SLIDE 5

Language: The Set Theory of Strings

Ex 6.2 : Let ∑ = {0,1} the set ∑* consists of all finite strings of 0’s

and 1’s together with the empty string. (how about ∑+?)

If ∑ = {ß 0 1

9 + / } where ß denotes the blank (space) Here in

If ∑ = {ß,0,1,…,9,+,-,/,}, where ß denotes the blank (space). Here in

∑* we find familiar arithmetic expression such as (7+5)/(2-3).

Definition 6.4:

, , , If

2 1 2 2 1 1 2 1

y y y w x x x w w w

n m

⋅ ⋅ ⋅ = ⋅ ⋅ ⋅ = ∑ ∈

+

. all for and if ) ( equal are and say then we , , , , , , , , and

2 1 2 1 2 1 2 1

i y x n m w w w w y y y x x x

i i n m

= = = ∑ ∈ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

5

slide-6
SLIDE 6

Language: The Set Theory of Strings

Definition 6.5:

. 1 for where , Let

2 1

≤ ≤ ∑ ∈ ∑ ∈ ⋅ ⋅ ⋅ =

+

n i x x x x w

i n

0. || || and ||, || by donated , is

  • f

length The = λ w n w

Definition 6.6:

, , , , Let

2 1 2 1

⋅ ⋅ ⋅ = ⋅ ⋅ ⋅ = ∑ ∈

+

y y y y x x x x y x

n m

. : and

  • f

ion concatenat The . , , , , , , , and

2 1 2 1 2 1 2 1

⋅ ⋅ ⋅ ⋅ ⋅ ⋅ = ∑ ∈ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ y y y x x x xy y x y y y x x x

n m n m

. : and

  • f

ion concatenat The . , : and

  • f

ion concatenat The λ λλ λ λ λ λ λ = = = x x x x x

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

6

slide-7
SLIDE 7

Language: The Set Theory of Strings

Definition 6.7:

, , , by

  • f

powers the define we ,

2 1

xx x x x x x x = = = ∑ ∈

λ

Definition 6.8:

. where , , , ,

1 2 3

N n xx x xx x

n n

∈ ⋅ ⋅ ⋅ = ⋅ ⋅ ⋅ =

+

ffi h i i f ffi ll d i Si il l prefix. proper a be to is then , if and ,

  • f

prefix a called is then , and , If λ λ ≠ = ∑ ∈

x y w x xy w y x

Definition 6.9:

. n suffix whe proper a is it ,

  • f

suffix a called i Similarly, λ ≠ x w s y f b i ll d i h d If ∑∗ . substring proper a call we , from different is and

  • f
  • ne

least at When .

  • f

substring a called is then , and , , If y z x w y xyz w z y x λ = ∑ ∈

∗ Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

7

slide-8
SLIDE 8

Language: The Set Theory of Strings

Definition 6.10:

l t th ll hi h b t th i l d Thi .

  • ver

language a called is

  • f

subset any , alphabet given a For φ ∑ ∑ ∑

  • Ex 6.9 :

i h ∑ h l h b f 26 l 10 di i d h i l b l d i

. language empty the call which we , subset the includes This φ

  • With ∑ the alphabet of 26 letters, 10 digits, and the special symbols used in a

given implementation of C++, the collection of executable programs for that implementation constitutes a language.

  • In the same situation, each executable program could be considered a

language, as could a particular set of such programs.

Since languages are sets, we can form the union, intersection, and

symmetric difference of two languages.

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

8

slide-9
SLIDE 9

Language: The Set Theory of Strings

Definition 6.11:

, and

  • f

ion concatenat the , , languages any alphabet an For B A B A ∑ ⊆ ∑

. } , | { is , denoted B b A a ab AB ∈ ∈

Ex 6.10 :

}. , { }, , , { languages finite the be , let and }, , , { Let y B z xy x A B A z y x = = = ∑ λ | || | 2 3 6 5 | | 2) | | 6 5 | | 1) } , , , , , { and } , , , , { Then B A AB BA AB yz yxy yx z xy x BA zy xyy z xy x AB ≠ = ≠ = = = | || | 2 3 6 5 | | 2) B A AB = ⋅ = ≠ =

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

9

slide-10
SLIDE 10

Language: The Set Theory of Strings

Theorem 6.1:

C B A ∑ ⊆ ∑ ) ( ) ( b) } { } { ) . , , let , alphabet an For

*

λ λ CA BA A C B AC AB C B A CA BA A C B AC AB C B A BC A C AB A A A ∩ ⊆ ∩ ∩ ⊆ ∩ ∪ = ∪ ∪ = ∪ = = = ) ( f) ) ( e) ) ( d) ) ( c) ) ( ) ( b) } { } { a) λ λ x CA BA A C B AC AB C B A ∑ ∈ ∩ ⊆ ∩ ∩ ⊆ ∩ , For (f) ) ( f) ) ( e)

*

: Proof CA BA A z C y yz x A z B y yz x A z C B y yz x A C B x ∈ ∈ = ∈ ∈ = ⇒ ∈ ∩ ∈ = ⇒ ∩ ∈ d ) and for ( and ) and for ( and where ) ( CA BA A C B CA BA x CA x BA x ∩ ⊆ ∩ ∴ ∩ ∈ ⇒ ∈ ∈ ⇒ ) ( and

A C B CA BA yy y A xy y C y xx x B ) ( } , { }, , { }, , , { ∉ = = =

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

10

CA BA A C B ∩ ⊆ ∩ ∴ ) (

A C B xyy CA BA xyy ) ( , ∩ ∉ ∩ ∈

slide-11
SLIDE 11

Language: The Set Theory of Strings

Definition 6.12:

: follows as languages

  • ther

construct can we language given a For

*

∑ ⊆ A .

  • f

closure positive the , b) } , { , and , }, { a)

1 1

λ = ∈ ∈ = ∈ = =

∈ + + +

+

A A A A b A ab|a A n A A A

n n n n

U

Z

Z 1994)

  • 1909

Kleene, Cole Stephen logician American the

  • f

honor (in A.

  • f

closure Kleene the called is * A language The }. { c)

*

λ ∪ =

+

A A

Ex 6.11 :

; } { (2) }; { (1) then } { and } { If ∈ = = = = ∑ N n x A A x A z y x

n n

λ }. | { (4) and }; 1 | { (3) ; }, { (2) }; { (1) then }, { and }, , , { If

*

≥ = ≥ = ∈ = = = = ∑

+

n x A n x A N n x A A x A z y x

n n

λ

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

11

slide-12
SLIDE 12

Language: The Set Theory of Strings

Lemma 6.1:

*

then , If . , languages with alphabet, an be Let ⊆ ⊆ ∑ ⊆ ∑

n n

B A B A B A

1 1

, for truth the Assuming ) ii ( 1, (i) ⊆ ⇒ ⊆ = = ⊆ = =

k k

B A B A k n B B A A n : Proof

1 1 1 1

, ), hypothesis induction ( . , , i.e. , If ) iii (

+

∈ ∈ ∴ ⊆ ⇒ ⊆ ∈ ∈ ∈ =

k k k k k k k k

B x B x B A B A A x A x A x x x Q

1 1 1 1 + + +

⊆ ⇒ = ∈ = ⇒

k k k k k

B A B BB x x x

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

12

slide-13
SLIDE 13

Language: The Set Theory of Strings

Theorem 6.2:

b) a) , , languages and alphabet an For

* * *

A B A AB A B A ⊆ ⊆ ∑ ⊆ ∑ ) ( ) ( ) ( f) e) d) c) b) a)

* * * * * * * * * * *

A A A A A A A A A AA B A B A B A B A A B A AB A = = = = = = ⊆ ⇒ ⊆ ⊆ ⇒ ⊆ ⊆ ⊆

+ + + + +

] ) ( ) [( (g) ) ( ) ( ) ( g)

* * * * * * * * * * *

B A B A B A B A B A ∪ = ∪ = ∪ = ∪ : Proof (d)] [by ) ( ) ( ) ( ) ( , (i) ] ) ( ) [( (g)

* * * * * * * *

B A B A B A B A B B A A B A B A ∪ ⊆ ∪ ⇒ ∪ ⊆ ∪ ⇒ ⊆ ⊆ ∪ = ∪ (f)] d (d) [b ) ( ) ) ( ( ) ( ) ( ) ( (d)] [by ) ( , , (ii)

* * * * * * * * * * * *

B A B A B A B A B A B A B A B A B A ∪ ⊆ ∪ ⇒ ∪ ⊆ ⇒ ∪ ⊆

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

13

(f)] and (d) [by ) ( ) ) ( ( ) ( B A B A B A ∪ = ∪ ⊆ ∪ ⇒

slide-14
SLIDE 14

Language: The Set Theory of Strings

Ex 6.14 :

where languages he consider t {0 1} alphabet an For

*

A ∑ ⊆ = ∑ : follows as y recursivel language this define can We etc. 0111, 10, 01, 0, e.g., 0, symbol the

  • f
  • ccurrence
  • ne

exactly contains in each word where , languages he consider t {0,1} alphabet an For A A A ∑ ⊆ = ∑ words the in include want to we process recursive For the 2) that us tells step base Our 1) y g g , , , , A A ∈ . for 1, and 1 A x x x ∈

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

14

slide-15
SLIDE 15

Language: The Set Theory of Strings

Definition (palindrome):

d t d i f l Th . in consider , alphabet an Given

* 2 1

x x x x

R n

∑ ⋅ ⋅ ⋅ = ∑ 1) : follows as y recursivel string a

  • f

reversal the define can We . denoted is

  • f

reversal The

1 1

x x x x x

R n n R

= ⋅ ⋅ ⋅ =

λ λ . ) ( ) ( define we here,

  • and

where can write then we , if , For 2) 1)

1

z y zy x y z zy x x n

R R R n n

= = ∑ ∈ ∑ ∈ = ∑ ∈ ∈

+

N λ λ

  • Ex 6 16 : Prove that

) (

* R R R

x x x x x x ⇒ ∑ ∈

  • Ex 6.16 : Prove that

|| || 1 || || 1 || | | (iii) , || | | (ii) || || (i) induction al mathematic By

1 1

k k k x x = = : Proof

. ) ( ,

1 2 2 1 2 1

x x x x x x = ⇒ ∑ ∈

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

15

. ) ( ) ( ) ( ) ( , || || , 1 || || , , 1 || | | (iii)

1 2 1 2 1 2 2 1 2 1 2 1 1 1 1 1 R R R R R R R R R

x x zy x z y x z x y x zy x x k y z zy x k x = = = = = = = = + =

slide-16
SLIDE 16

6.2 Finite State Machines: A First Encounter

  • Example: A vending machine dispenses two flavors of chewing gum:

peppermint (P) and spearmint (S).

  • The cost of either flavor is 20c. The machine accepts nickels; dimes, and

p quarters and returns the necessary change.

  • Mary Jo inserts two nickels and a dime, and press the white button (W) for a

package of peppermint-flavored chewing gum. p g p pp g g

t0 t1 t2 t3 t4 State (1) s0 (4) s1 (5c) (7) s2 (10c) (10) s3 (20c) (13) s0 Input (2) 5c (5) 5c (8) 10c (11) W Output (3) Nothing (6) Nothing (9) Nothing (12) P Output (3) Nothing (6) Nothing (9) Nothing (12) P

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

16

slide-17
SLIDE 17

Finite State Machines: A First Encounter

D fi iti 6 13

Definition 6.13

; for states internal

  • f

set the where ), , , , , ( tuple

  • five

is machine state finite A M S w v O I S M = = ; for alphabet

  • utput

the ; for alphabet input the ; for states internal

  • f

set the M O M I M S = = =

v w 0 1 0 1

; function

  • utput

the is : ; function state next the is : O I S w S I S v → × → ×

s0 s0 s1 0 0 s1 s2 s1 0 0 s s s 1

  • Ex 6.17

where ), , , , , ( machine state finite he Consider t w v O I S M =

s2 s0 s1 0 1

. table state by the given are , and 0,1}, { }, , , { ), , , , , (

2 1

w v O I s s s S = = =

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

17

slide-18
SLIDE 18

Finite State Machines: A First Encounter

  • Another representation for finite state machine
  • State diagram

Wh t i th t t t i f th i t t i 1100101101?

  • What is the output string for the input string 1100101101?
  • Input (output) string is an element of I* (O*), the Kleene closure of

I (O).

State s0 v(s0 , 1)= s1 v(s1 , 0)= s2 v(s2 , 1)= s1 v(s1 , 0)= s2 Input 1 1 Output w(s0 1)= 0 w(s1 1)= 0 w(s2 1)= 1 w(s1 0)= 0 Output w(s0 , 1) 0 w(s1 , 1) 0 w(s2 , 1) 1 w(s1 , 0) 0

0,0 1,0

v w 1 1

s0 s1 s2

Start 1,0 0,0

0 1 0 1 s0 s0 s1 0 0 s1 s2 s1 0 0

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

18

1,1 0,0

s2 s0 s1 0 1

slide-19
SLIDE 19

Finite State Machines: A First Encounter

E t i

h t t t t ti F S I ∗

  • Extensions:

s x s v x x s v v x x s v s x s v = = = =

3 2 2 2 1 1 2 1 1 2 1 1

) , ( ) ), , ( ( ) , ( ) , (

have we , state any at starting , For

1 2 1

S s I x x x

k

∈ ∈ ⋅ ⋅ ⋅

s x s v x x x s v v v x x x s v

s x s v s

= = =

= 4 3 3 3 ) , ( 2 1 1 3 2 1 1

) , ( ) ), , ) , ( ( ( ) , (

3 2 2 2

4 43 4 42 1 4 3 4 2 1 y x s w S s x s v x x x s v

k k k k

= ∈ = = ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅

+1 2 1 1

) ( ) , ( ) , ( y y y x s w x s w x s w x x x s w y y x s w x s w x x s v w x s w x x s w y x s w = = = = = =

3 2 1 3 3 2 2 1 1 3 2 1 1 2 1 2 2 1 1 2 1 1 1 1 2 1 1 1 1 1

) , ( ) , ( ) , ( ) , ( ) , ( ) , ( ) ), , ( ( ) , ( ) , ( ) , ( S s s s v O y y y x s w x s w x s w x x x s w

k k k k

∈ ∈ ⋅ ⋅ ⋅ = ⋅ ⋅ ⋅ = ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅

∗ 2 1 2 2 1 1 2 1 1

all for ) ( Also ) , ( ) , ( ) , ( ) , ( λ

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

19

S s s s v ∈ =

1 1 1

all for ) , ( Also, λ

slide-20
SLIDE 20

Finite State Machines: A First Encounter

E 6 19 A

i l bi dd i fi it t t hi th t

  • Ex 6.19 : A serial binary adder is a finite state machine that we can

use to obtain x + y.

  • E.g.,

01101 , 00111

1 2 3 4 5 1 2 3 4 5

= = = = y y y y y y x x x x x x

g ,

01101 , 00111

1 2 3 4 5 1 2 3 4 5

y y y y y y x x x x x x

Serial binary

1 2 3 4 5

x x x x x x =

1 2 3 4 5

z z z z z z =

adder

1 2 3 4 5 1 2 3 4 5

y y y y y y =

1 2 3 4 5

z z z z z z

1 1 1

+1 +1 +1 +1

x = 0 0 1 1 1 + y = 0 1 1 0 1 z = 1 0 1 0 0

third addition first addition

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

20

slide-21
SLIDE 21

Finite State Machines: A First Encounter

Th i l bi dd i d l d b fi it t t hi M (S I O

  • The serial binary adder is modeled by a finite state machine M = (S, I, O,

v, w). S = {s0, s1}, where si indicates a carry of i; I = {00, 01, 10, 11}; O = {0, 1}; and v, w are given in the following state table.

v w 00 01 10 11 00 01 10 11 s0 s0 s0 s0 s1 0 1 1 0 s1 s0 s1 s1 s1 1 0 0 1

+1 00, 0 01, 1 10, 1 11 0 01, 0 10, 0 11, 1 +1

s0 s1

Start 11, 0 00, 1

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

21

slide-22
SLIDE 22

6.3 Finite State Machines: A Second Encounter

S dditi l hi l t t th d i f t

Some additional machines relevant to the design of computer

hardware, e.g., sequence recognizer.

  • Ex 6 20 : Construct a machine that recognizes each occurrence of
  • Ex 6.20 : Construct a machine that recognizes each occurrence of

the sequence 111.

  • Input: 1110101111, output: 0010000011

{0, 1}*{111}

0, 0 1, 1

s0 s1 s2

Start 1, 0 1, 0 0, 0 0, 0

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

22

equivalent

slide-23
SLIDE 23

Finite State Machines: A Second Encounter

E 6 21 C

t t hi th t t l i th

  • Ex 6.21 : Construct a machine that not only recognizes the
  • ccurrence of 111, but also recognizes those occurrences that end

in a position that is a multiple of three. p p

  • Input: 1110111, output: 0010000, not 0010001
  • Input: 111100111, output: 001000001

Start 1, 0 1, 1 0, 0 1, 0

s0 s1 s2

Start 0 0 0, 0 0, 0 0, 0 1, 0

s3 s4

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

23

0, 0 1, 0

slide-24
SLIDE 24

Finite State Machines: A Second Encounter

E 6 22 C

t t hi th t t l i ( ) th

  • Ex 6.22: Construct a machine that not only recognizes (a) the
  • ccurrence of 0101, (b) those occurrences that end in a position

that is a multiple of four. p

  • Input: 01010100101, output: (a) 00010100001 (b)00010000000

Start 1, 1 0, 0 0, 0 1, 0

s0 s1 s2

1, 0 0, 0

s3

0, 0

s0 s1 s2

1, 0 0, 0

s3

0, 0 1, 0

s4

0, 0

s

1, 0

s

0, 0 1, 0 0, 0 1, 0 Start 0, 0 1, 1

4

0, 0 1 0

s5 s6

1, 0

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

24

1, 0

slide-25
SLIDE 25

Finite State Machines: A Second Encounter

  • Ex 6.23 : Can we construct a finite state machine that recognizes

precisely those strings in the language A = {01, 0011, 000111,…} =

? } | 1 {

+

Z i

i i

  • Apply the pigeonhole principle

? } | 1 {

+

∈Z i

i i

State s0 s1 s2 … si si+1 … sj sj+1 … sn sn+1 … s2n s2n+1 Input 1 1 1 Output 1 1 1 Output 1 1 1 State s0 s1 s2 si sj+1 sn sn+1 s2n s2n+1

1 2

i j 1

n n 1

2n 2n 1

Input 1 1 1 Output 1 1 1

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

25

slide-26
SLIDE 26

Finite State Machines: A Second Encounter

  • Proof

. 1 | | let , in strings recognize can } , , , , { n S A w v O I S M ≥ = = i i i l i h l b | | , , , states 1 by s 0' 1 process will language in the 1 Consider

1 1 1

S s s s n n M A

n n n

⋅ ⋅ ⋅ + + ⇒

+ +

1 ) ( ) 1 ( h 1 i tables) the (see columns remove can We states two exists principle, pigeonhole by , | |

1 ) ( ) 1 (

i j M i j s s n S

n i j n j i

− ∴ = =

+ − − +

Q contradict recognize cannot fact, In 1 ) ( ) 1 ( where , 1 recognizes

1 ) ( ) 1 (

x M A x n i j n x M

n i j n

∴ ⇒ ∉ + < − − + = ⇒

+ +

. in strings g recognizin machine state finite a construct cannot We contradict A ∴ ∴

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

26

slide-27
SLIDE 27

Finite State Machines: A Second Encounter

O it d l hi

One-unit delay machine

  • Ex 6.24 : If x = x1x2…xm, then w(s0, x) = 0x1x2…xm-1.

0, 0 0, 0

Output 0 when receive input s0 s1

Start 0, 1 1, 0

Output 0 when eceive input s2

1, 0

Output 1 when receive input

1, 1

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

27

slide-28
SLIDE 28

Finite State Machines: A Second Encounter

T it d l hi

Two-unit delay machine

  • Ex 6.25 : If x = x1x2…xm, then w(s0, x) = 00x1x2…xm-2.

0, 0

s3

0, 0

s1 s3

0, 0 0, 1 1, 0

s0 s1

Start 0, 0 1, 0

s4

0, 1

s0 s1

Start 0, 0 1, 0

s4

0, 0 1, 1 1, 0

s2 s5

1 0 0, 0 1, 0

s2 s5

1, 0 0, 0 1, 0 0, 1 1, 0

s6

1, 0

s6

1 1 1, 0

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

28

1, 1

slide-29
SLIDE 29

Finite State Machines: A

M1

Second Encounter

D fi iti 6 14

  • Definition 6.14

w v O I S M machine state finite a is } , , , , { =

j i j i i j j i

s s s s s x s v s s s reachable s S s s Fig.) in the , , from reachable is (e.g., ) , (

  • r

if from is , , a) } , , , , {

2 1 3

= = ∈ s I x s x s v s s x I x s x s v transient s Fig.) in the (e.g., all for ) , ( if sink a is c) Fig.) in the (e.g., implies for ) , ( if is b)

3 * 2 *

∈ = = ∈ = λ

(出去回不來)

I S I S

M w v O I S M w w S I S v v I I S S

  • f

submachine a is } , , , , { , | , : | if , , d)

1 1 1 1 1 1 1 1 1 1 1

1 1 1 1

= = → × = ⊆ ⊆

× × i j j i

s s S s s from reachable is , , any for if connected Strongly e) ∈

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

29

slide-30
SLIDE 30

Finite State Machines: A Second Encounter

D fi iti 6 15

Definition 6.15

if to from ) ( a called is states. distinct two be , let , machine state finite a For s s sequence transition transfer I x s s M

j i

+

|| | | || || ) , ( with b) ) , ( a) if to from ) ( a called is x y s y s v I y s x s v s s sequence transition transfer I x

j i j i j i

≥ ⇒ = ∈ = ∈

+

v w

  • Ex 6.26 : Find a transfer sequence

from s0 to s2 in the state table.

|| | | || || ) ( ) y y y

j i

0 1 0 1 s0 s1 s6 s1 s5 s0 0 1 0 1 2

  • x = 0000

s2 s3 s4 s1 s2 s4 s0 s2 s1 0 1 0 1 0 1 1 1 s5 s6 s3 s5 s3 s6 1 1 1 1

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

30

slide-31
SLIDE 31

Practice (6.3-3)

Construct a state diagram for a finite state

machine with I=O={0, 1} that recognizes all strings in the language {0, 1}*{00}U{0, 1}*{11}

s1

0, 0

0, 1

s1 s0

Start 1, 0 1, 0 0, 0

s0

Start

s2

1, 1

s2

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

31

slide-32
SLIDE 32

Practice (Sppl.-5)

Let M be the finite state machine in the following figure. For

states Si, Sj , where , let Oij denote the set of all nonempty

  • utput strings that M can produce as it goes from state Si, to

state Sj, e.g., O20 ={0}{1, 00}*. Find O02 ,O22, O11, and O10. O00 = {1, 00}*-{λ} O02 = {1, 00}*{0} O22 = {0}{1, 00}*{0}

22

{ }{ , } { } O11 = Φ O10 = {1}{1, 00}*U{10} {1, 00}*

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

32

slide-33
SLIDE 33

Exercises (2009)

6.1: 2, 12, 20 6.2: 4, 8

,

6.3: 4, 7(c), 8 Supplementary: 6 Supplementary: 6

Discrete Mathematics Discrete Mathematics – – CH6 CH6 2009 Spring 2009 Spring

33