Presentation is loading. Please wait.

Presentation is loading. Please wait.

Theory of Languages and Automata By: Mojtaba Khezrian.

Similar presentations


Presentation on theme: "Theory of Languages and Automata By: Mojtaba Khezrian."— Presentation transcript:

1 Theory of Languages and Automata By: Mojtaba Khezrian

2 Theory of Languages and Automata By Dr. Khezrian 2 Review Alphabetic ……. {0,1} String ….. x=‘101010’ Length of String ….. |x| Language Union Intersection Concat

3 Theory of Languages and Automata By Dr. Khezrian 3 Review

4 Theory of Languages and Automata By Dr. Khezrian 4 Grammar G =(V,T,P,S) V= nonFinal symbol T= Alphabetic P= Rules S= Starting symbol

5 Theory of Languages and Automata By Dr. Khezrian 5 Language of Grammar

6 Theory of Languages and Automata By Dr. Khezrian 6 Language of Grammar

7 Theory of Languages and Automata By Dr. Khezrian 7 Language of Grammar

8 Theory of Languages and Automata By Dr. Khezrian 8 Language of Grammar

9 Theory of Languages and Automata By Dr. Khezrian 9 How to Write Grammar? First split the language to small parts then write the grammar of them. Finally join all of them.

10 Theory of Languages and Automata By Dr. Khezrian 10 How to Write Grammar? 1: Split like: A A A …. A A is the symbol of even length

11 Theory of Languages and Automata By Dr. Khezrian 11 How to Write Grammar? 2: Split like: X A A is the symbol of even length X is the symbol of aa or ab or bb or ba

12 Theory of Languages and Automata By Dr. Khezrian 12 How to Write Grammar? 3: Split like: A B A,B is the symbol of even length

13 Theory of Languages and Automata By Dr. Khezrian 13 How to Write Grammar? 4: Split like: A X A is the symbol of even length X is the symbol of aa or ab or bb or ba

14 Theory of Languages and Automata By Dr. Khezrian 14 How to Write Grammar? Split like: X A A is the symbol of even length X is the symbol of a or b

15 Theory of Languages and Automata By Dr. Khezrian 15 How to Write Grammar? 1: Split like: b…a and a…b

16 Theory of Languages and Automata By Dr. Khezrian 16 How to Write Grammar? 2: Split like: b…a… and a…b…

17 Theory of Languages and Automata By Dr. Khezrian 17 How to Write Grammar? 3: Split like: AB

18 Theory of Languages and Automata By Dr. Khezrian 18 How to Write Grammar? 3: Split it to two languages: L1 and L2 L1: n,m are even L2: n,m are odd

19 Theory of Languages and Automata By Dr. Khezrian 19 How to Write Grammar?

20 Theory of Languages and Automata By Dr. Khezrian 20 Type of Grammar Type-3 Grammar (Regular Grammar) Type-2 Grammar (Context free Grammar) Type-1 Grammar (Context Sensitive Grammar) Type-0 Grammar

21 Theory of Languages and Automata By Dr. Khezrian 21 Type-3 Grammar (Regular Grammar) If it would be right-linear: Or left-linear:

22 Theory of Languages and Automata By Dr. Khezrian 22 Type-3 Grammar (Regular Grammar)

23 Theory of Languages and Automata By Dr. Khezrian 23 Type-2 Grammar (Context Free Grammar)

24 Theory of Languages and Automata By Dr. Khezrian 24 Type-1 Grammar (Context Sensetive Grammar)

25 Theory of Languages and Automata By Dr. Khezrian 25 Type-1 Grammar (Context Sensitive Grammar)

26 Theory of Languages and Automata By Dr. Khezrian 26 Type-0 Grammar

27 Theory of Languages and Automata By Dr. Khezrian 27 Type-0 Grammar

28 Theory of Languages and Automata By Dr. Khezrian 28 Type of Language Type-3 Language (Regular Language) Type-2 Language (Context Free Language) Type-1 Language (Context Sensitive Language) Type-0 Language

29 Theory of Languages and Automata By Dr. Khezrian 29 Type of Language Type-3 If there is a type-3 grammar for it Type-2 If there is a type-2 grammar and no type-3 grammar for it Type-1 If there is a type-1 grammar and no type-3 and type-2 grammar for it Type-0 If there is a type-0 grammar and no type-3 and type-2 and type-1 grammar for it

30 Theory of Languages and Automata By Dr. Khezrian 30 Type of Language

31 Theory of Languages and Automata By Dr. Khezrian 31 Type of Automata Automata for type-3 language (Finite Automata) Automata for type-2 language (Push-down Automata) Automata for type-1 language (Linear Bounded Automata) Automata for type-0 language (Turing Machine)

32 Theory of Languages and Automata By Dr. Khezrian 32 Type of Automata

33 Theory of Languages and Automata By Dr. Khezrian 33 Finite Machine

34 Theory of Languages and Automata By Dr. Khezrian 34 Finite Machine Accept: If at the end of string, machine is stated in one of final states. Reject: If at the end of string, machine is stated in one of non-final states or before end of string it’ll be stoped.

35 Theory of Languages and Automata By Dr. Khezrian 35 Finite Machine

36 Theory of Languages and Automata By Dr. Khezrian 36 Finite Machine

37 Theory of Languages and Automata By Dr. Khezrian 37 Example

38 Theory of Languages and Automata By Dr. Khezrian 38 Language of a Finite machine If A is the set of all strings that machine M accepts, we say that A is the language of machine M and write: L(M) = A.  M recognizes A  M accepts A.

39 Theory of Languages and Automata By Dr. Khezrian 39 Finite Machine

40 Theory of Languages and Automata By Dr. Khezrian 40 Finite Machine

41 Theory of Languages and Automata By Dr. Khezrian 41 Finite Machine

42 Theory of Languages and Automata By Dr. Khezrian 42 Example L(M1) = {w | w contains at least one 1 and even number of 0s follow the last 1}

43 Theory of Languages and Automata By Dr. Khezrian 43 Example L(M4) = {w | w accepts all strings that start and end with a or with b}

44 Theory of Languages and Automata By Dr. Khezrian 44 Example L(M5) = {w | keeps a running count of the sum of the numerical input symbols it reads, modulo 3}

45 Theory of Languages and Automata By Dr. Khezrian 45 Designing Finite Automata Put yourself in the place of the machine and then see how you would go about performing the machine’s task. Design a finite automaton to recognize the regular language of all strings that contain the string 001 as a substring.

46 Theory of Languages and Automata By Dr. Khezrian 46 Designing Finite Automata

47 Theory of Languages and Automata By Dr. Khezrian 47 Example

48 Theory of Languages and Automata By Dr. Khezrian 48 Example

49 Theory of Languages and Automata By Dr. Khezrian 49 Type of Finite Automata Deterministic Finite Automata (DFA) Nondeterministic Finite Automata (NDFA)

50 Theory of Languages and Automata By Dr. Khezrian 50 Deterministic Finite Automata (DFA)

51 Theory of Languages and Automata By Dr. Khezrian 51 Nondeterministic Finite Automata (NDFA)

52 Theory of Languages and Automata By Dr. Khezrian 52 Differences between DFA & NFA First, very state of a DFA always has exactly one exiting transition arrow for each symbol in the alphabet. In an NFA a state may have zero, one, or more exiting arrows for each alphabet symbol.

53 Theory of Languages and Automata By Dr. Khezrian 53 Differences between DFA & NFA Second, in a DFA, labels on the transition arrows are symbols from the alphabet. An NFA may have arrows labeled with members of the alphabet or. Zero, one, or many arrows may exit from each state with the label.

54 Theory of Languages and Automata By Dr. Khezrian 54 Differences between DFA & NFA

55 Theory of Languages and Automata By Dr. Khezrian 55 Example Consider the computation of N1 on input 010110.

56 Theory of Languages and Automata By Dr. Khezrian 56 Example (Cont.)

57 Theory of Languages and Automata By Dr. Khezrian 57 Example

58 Theory of Languages and Automata By Dr. Khezrian 58 Example NFA to DFA

59 Theory of Languages and Automata By Dr. Khezrian 59 Example NFA to DFA

60 Theory of Languages and Automata By Dr. Khezrian 60 Example NFA with to DFA

61 Theory of Languages and Automata By Dr. Khezrian 61 Pumping Lemma

62 Theory of Languages and Automata By Dr. Khezrian 62 Pumping Lemma

63 Theory of Languages and Automata By Dr. Khezrian 63 Pumping Lemma

64 Theory of Languages and Automata By Dr. Khezrian 64 Pumping Lemma

65 Theory of Languages and Automata By Dr. Khezrian 65 Pumping Lemma

66 Theory of Languages and Automata By Dr. Khezrian 66 Pumping Lemma

67 Theory of Languages and Automata By Dr. Khezrian 67 Pumping Lemma

68 Theory of Languages and Automata By Dr. Khezrian 68 Pumping Lemma

69 Theory of Languages and Automata By Dr. Khezrian 69 The Regular Operations Let A and B be languages. We define the regular operations union, concatenation, and star as follows:

70 Theory of Languages and Automata By Dr. Khezrian 70 Union Operations Let NFA1 recognize N1 and NFA2 recognize N2. Construct NFA3 to recognize N1 U N2.

71 Theory of Languages and Automata By Dr. Khezrian 71 Concatenation Operations

72 Theory of Languages and Automata By Dr. Khezrian 72 Union Operations We represent another NFA to recognize A*.

73 Theory of Languages and Automata By Dr. Khezrian 73 Regular Expression

74 Theory of Languages and Automata By Dr. Khezrian 74 Regular Expression Language

75 Theory of Languages and Automata By Dr. Khezrian 75 Example

76 Theory of Languages and Automata By Dr. Khezrian 76 Regular Language Cycle NDFA DFA NDFA-λ R RG

77 Theory of Languages and Automata By Dr. Khezrian 77 Regular Language Cycle NDFA DFA NDFA-λ R RG

78 Theory of Languages and Automata By Dr. Khezrian 78 Building an NFA from the Regular Expression

79 Theory of Languages and Automata By Dr. Khezrian 79 Building an NFA from the Regular Expression

80 Theory of Languages and Automata By Dr. Khezrian 80 Regular Language Cycle NDFA DFA NDFA-λ R RG

81 Theory of Languages and Automata By Dr. Khezrian 81 Building Grammar from the NFA G =(V,T,P,S)

82 Theory of Languages and Automata By Dr. Khezrian 82 Building Grammar from the NFA

83 Theory of Languages and Automata By Dr. Khezrian 83 Building Grammar from the NFA

84 Theory of Languages and Automata By Dr. Khezrian 84 Building Grammar from the NFA

85 Theory of Languages and Automata By Dr. Khezrian 85 Building Grammar from the NFA

86 Theory of Languages and Automata By Dr. Khezrian 86 Building Grammar from the NFA

87 Theory of Languages and Automata By Dr. Khezrian 87 Building Grammar from the NFA

88 Theory of Languages and Automata By Dr. Khezrian 88 Regular Language Cycle NDFA DFA NDFA-λ R RG

89 Theory of Languages and Automata By Dr. Khezrian 89 Building NFA from the Grammar G =(V,T,P,S)

90 Theory of Languages and Automata By Dr. Khezrian 90 Building NFA from the Grammar

91 Theory of Languages and Automata By Dr. Khezrian 91 Regular Language Cycle NDFA DFA NDFA-λ R RG

92 Theory of Languages and Automata By Dr. Khezrian 92 Building Grammar from the Regular expression

93 Theory of Languages and Automata By Dr. Khezrian 93 Building Grammar from the Regular expression

94 Theory of Languages and Automata By Dr. Khezrian 94 Building Grammar from the Regular expression

95 Theory of Languages and Automata By Dr. Khezrian 95 Building Grammar from the Regular expression

96 Theory of Languages and Automata By Dr. Khezrian 96 Regular Language Cycle NDFA DFA NDFA-λ R RG

97 Theory of Languages and Automata By Dr. Khezrian 97 Building Regular expression from the Grammar

98 Theory of Languages and Automata By Dr. Khezrian 98 Regular Language Cycle NDFA DFA NDFA-λ R RG

99 Theory of Languages and Automata By Dr. Khezrian 99 Regular Language Cycle NDFA DFA NDFA-λ R RG

100 Theory of Languages and Automata By Dr. Khezrian 100 Regular Language Cycle NDFA DFA NDFA-λ R RG

101 Theory of Languages and Automata By Dr. Khezrian 101 GNFA Formal Definition A generalized nondeterministic finite automaton is a 5-tuple, a 5-tuple (Q,Σ,δ,qstart, qaccept), where 1.Q is a finite set called states, 2.Σ is a the input alphabet, 3.δ : (−*+) ×(Q−*+ is the transition function, 4.qstart is the start state, and 5.qaccept is the accept state.

102 Theory of Languages and Automata By Dr. Khezrian 102 Assumptions For convenience we require that GNFAs always have a special form that meets the following conditions: 1.The start state has transition arrows going to every other state but no arrows coming in from any other state. 2.There is only a single accept state, and it has arrows coming in from every other state but no arrows going to any other state. Furthermore, the accept state is not the same as the start state. 3.Except for the start and accept states, one arrow goes from every state to every other state and also from each state to itself.

103 Theory of Languages and Automata By Dr. Khezrian 103 How to Eliminate a State?

104 Theory of Languages and Automata By Dr. Khezrian 104 Example

105 Theory of Languages and Automata By Dr. Khezrian 105 Example

106 Theory of Languages and Automata By Dr. Khezrian 106 Example (Cont.)


Download ppt "Theory of Languages and Automata By: Mojtaba Khezrian."

Similar presentations


Ads by Google