Download presentation

Presentation is loading. Please wait.

1
**Finite-State Machines with No Output Ying Lu**

Based on Slides by Elsa L Gunter, NJIT, Costas Busch, and Longin Jan Latecki, Temple University

2
Kleene closure A and B are two sets of strings. The concatenation of A and B is AB={xy: x string in A and y string in B} Example: A={0, 11} and B={1, 10, 110} AB={01,010,0110,111,1110,11110} A0={λ}, where λ represents the empty string An+1=AnA for n=0,1,2,…

3
**Let A be any set of strings formed of characters in V.**

Kleene closure of A, denoted by A*, is Examples: If C={11}, then C*={12n: n=0,1,2,…} If B={0,1}, then B*={all binary strings}.

4
**Finite State Automata A FSA is similar to a compiler in that:**

A compiler recognizes legal programs in some (source) language. A finite-state machine recognizes legal strings in some language. Example: Pascal Identifiers sequences of one or more letters or digits, starting with a letter: letter | digit letter S A

5
**Finite Automaton Input String Output “Accept” or Finite “Reject”**

6
Finite State Automata A finite state automaton over an alphabet is illustrated by a state diagram: a directed graph edges are labeled with elements of alphabet, some nodes (or states), marked as final one node marked as start state

7
Transition Graph initial state accepting state transition state

8
**Initial Configuration**

Input String

9
Reading the Input

13
Input finished accept

14
Rejection

18
Input finished reject

19
Another Rejection

20
reject

21
Another Example

25
Input finished accept

26
Rejection Example

30
Input finished reject

31
Finite State Automata A finite state automaton M=(S,Σ,δ,s0,F) consists of a finite set S of states, a finite input alphabet Σ, a state transition function δ: S x Σ S, an initial state s0, F subset of S that represent the final states.

32
**Finite Automata Transition**

Is read ‘In state s1 on input “a” go to state s2’ At the end of input If in accepting state => accept Otherwise => reject If no transition possible (got stuck) => reject FSA = Finite State Automata

33
Input Alphabet

34
Set of States

35
Initial State

36
**Set of Accepting States**

37
Transition Function

41
Transition Function

42
**Language accepted by FSA**

The language accepted by a FSA is the set of strings accepted by the FSA. in the language of the FSM shown below: x, tmp2, XyZzy, position27. not in the language of the FSM shown below: 123, a?, 13apples. letter | digit letter S A

43
Example accept

44
Example accept accept accept

45
Example trap state accept

46
**Extended Transition Function**

50
**Observation: if there is a walk from to**

with label then

51
**Example: There is a walk from to**

with label

52
Recursive Definition

53
**Language Accepted by FSAs**

For a FSA Language accepted by :

54
Observation Language rejected by :

55
Example = { all strings with prefix } accept

56
Example = { all strings without substring }

57
Example

58
Deterministic FSAs If a FSA has for every state exactly one edge for each letter in alphabet then FSA is deterministic In general a FSA is non-deterministic. Deterministic FSA special kind of non-deterministic FSA

59
Example FSA Deterministic FSA Regular expression: (0 1)* 1 1

60
Example DFSA Regular expression: (0 1)* 1 Accepts string 1

61
**Example DFSA Regular expression: (0 1)* 1 Accepts string 0 1 1 0 1 1**

1

62
**Example DFSA Regular expression: (0 1)* 1 Accepts string 0 1 1 0 1 1**

1

63
**Example DFSA Regular expression: (0 1)* 1 Accepts string 0 1 1 0 1 1**

1

64
**Example DFSA Regular expression: (0 1)* 1 Accepts string 0 1 1 0 1 1**

1

65
**Example DFSA Regular expression: (0 1)* 1 Accepts string 0 1 1 0 1 1**

1

66
**Example DFSA Regular expression: (0 1)* 1 Accepts string 0 1 1 0 1 1**

1

67
Example NFSA Regular expression: (0 1)* 1 Non-deterministic FSA 1 1

68
**Example NFSA Regular expression: (0 1)* 1 Accepts string 0 1 1 0 1**

1 1

69
**Example NFSA Regular expression: (0 1)* 1 Accepts string 0 1 1 0 1**

1 1

70
**Example NFSA Regular expression: (0 1)* 1 Accepts string 0 1 1 0 1**

1 1

71
**Example NFSA Regular expression: (0 1)* 1 Accepts string 0 1 1 0 1**

Guess Regular expression: (0 1)* 1 Accepts string 1 1

72
**Example NFSA Regular expression: (0 1)* 1 Accepts string 0 1 1 0 1**

Backtrack Regular expression: (0 1)* 1 Accepts string 1 1

73
**Example NFSA Regular expression: (0 1)* 1 Accepts string 0 1 1 0 1**

Guess again Regular expression: (0 1)* 1 Accepts string 1 1

74
**Example NFSA Regular expression: (0 1)* 1 Accepts string 0 1 1 0 1**

Guess Regular expression: (0 1)* 1 Accepts string 1 1

75
**Example NFSA Regular expression: (0 1)* 1 Accepts string 0 1 1 0 1**

Backtrack Regular expression: (0 1)* 1 Accepts string 1 1

76
**Example NFSA Regular expression: (0 1)* 1 Accepts string 0 1 1 0 1**

Guess again Regular expression: (0 1)* 1 Accepts string 1 1

77
**Example NFSA Regular expression: (0 1)* 1 Accepts string 0 1 1 0 1**

1 1

78
**Example NFSA Regular expression: (0 1)* 1 Accepts string 0 1 1 0 1**

Guess (Hurray!!) Regular expression: (0 1)* 1 Accepts string 1 1

79
**If a language L is recognized by**

a nondeterministic FSA, then L is recognized by a deterministic FSA NFSA FSA

80
**How to Implement an FSA A table-driven approach: table: Table[j][k]**

one row for each state in the machine, and one column for each possible character. Table[j][k] which state to go to from state j on character k, an empty entry corresponds to the machine getting stuck.

81
**The table-driven program for a Deterministic FSA**

state = S // S is the start state repeat { k = next character from the input if (k == EOF) // the end of input if state is a final state then accept else reject state = T[state,k] if state = empty then reject // got stuck }

82
In-Class Exercise Construct a finite-state automaton that recognizes the set of bit strings consisting of a 0 followed by a string with an odd number of 1s.

83
Appendix

84
**Regular Expressions Regular expressions describe regular languages**

Example: describes the language

85
**Recursive Definition Primitive regular expressions:**

Given regular expressions and Are regular expressions

86
Examples A regular expression: Not a regular expression:

87
**Languages of Regular Expressions**

: language of regular expression Example

88
Definition For primitive regular expressions:

89
**Definition (continued)**

For regular expressions and

90
Example Regular expression:

91
Example Regular expression

92
Example Regular expression

93
**Example Regular expression = { all strings with at least**

two consecutive 0 }

94
Example Regular expression = { all strings without two consecutive 0 }

95
**Equivalent Regular Expressions**

Definition: Regular expressions and are equivalent if

96
**Example = { all strings without two consecutive 0 } and are equivalent**

regular expr.

97
Example: Lexing Regular expressions good for describing lexemes (words) in a programming language Identifier = (a b … z A B … Z) (a b … z A B … Z 0 1 … 9 _ ‘ )* Digit = (0 1 … 9)

98
**Implementing Regular Expressions**

Regular expressions, regular grammars reasonable way to generates strings in language Not so good for recognizing when a string is in language Regular expressions: which option to choose, how many repetitions to make Answer: finite state automata

Similar presentations

OK

Chapter 5 Finite Automata. 2 5.1 Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.

Chapter 5 Finite Automata. 2 5.1 Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on indian textile industries in usa Ppt on model view controller definition Ppt on profit planning in banks Ppt on chronic renal failure Ppt on validity and reliability Seminar ppt on brain machine interface Ppt on linear equations in two variables class 9 Ppt on magnetohydrodynamic power generation Ppt on credit default swaps history Ppt on synthesis and degradation of purines and pyrimidines are what