cse-217: theory of computation - github pages · 2020. 11. 20. · example - 2 sipser, 1.1, p-43...

41
CSE-217: Theory of Computation REGULAR LANGUAGES Md Jakaria Lecturer Department of Computer Science and Engineering Military Institute of Science and Technology July 18, 2019 Md Jakaria MIST Theory of Computation July 18, 2019 1 / 40

Upload: others

Post on 19-Feb-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

  • CSE-217: Theory of ComputationREGULAR LANGUAGES

    Md Jakaria

    LecturerDepartment of Computer Science and Engineering

    Military Institute of Science and Technology

    July 18, 2019

    Md Jakaria MIST Theory of Computation July 18, 2019 1 / 40

  • DESIGNING FINITE AUTOMATA

    Design is a creative process!

    Md Jakaria MIST Theory of Computation July 18, 2019 2 / 40

  • DESIGNING FINITE AUTOMATA

    Put yourself in the place ofthe machine you are trying to

    design.

    Figure out what you need toremember about the string.

    Md Jakaria MIST Theory of Computation July 18, 2019 3 / 40

  • DESIGNING FINITE AUTOMATA

    Put yourself in the place ofthe machine you are trying to

    design.

    Figure out what you need toremember about the string.

    Md Jakaria MIST Theory of Computation July 18, 2019 3 / 40

  • Example - 1Sipser, 1.1, p-41

    Example 1

    1 Suppose that the alphabet is {0,1} and that thelanguage consists of all strings with an odd numberof 1s.

    2 You want to construct a finite automaton E1 torecognize this language.

    Md Jakaria MIST Theory of Computation July 18, 2019 4 / 40

  • Example - 1Sipser, 1.1, p-42

    Md Jakaria MIST Theory of Computation July 18, 2019 5 / 40

  • Example - 1Sipser, 1.1, p-42

    Md Jakaria MIST Theory of Computation July 18, 2019 6 / 40

  • Example - 1Sipser, 1.1, p-43

    Md Jakaria MIST Theory of Computation July 18, 2019 7 / 40

  • Example - 2Sipser, 1.1, p-43

    Example 2

    1 Design a finite automaton E2 to recognize the regularlanguage of all strings that contain the string 001 as asubstring.

    2 For example, 0010, 1001, 001, and 11111110011111are all in the language, but 11 and 0000 are not.

    Md Jakaria MIST Theory of Computation July 18, 2019 8 / 40

  • Example - 2Sipser, 1.1, p-44

    Md Jakaria MIST Theory of Computation July 18, 2019 9 / 40

  • Example - 3Sipser, 1.1, p-43

    Example 3

    1 Let us formally specify a DFA that accepts all andonly the strings of 0’s and 1’s that have the sequence01 somewhere in the string.

    Md Jakaria MIST Theory of Computation July 18, 2019 10 / 40

  • Example - 3Ullman, 2.1, Fig-2.4

    Md Jakaria MIST Theory of Computation July 18, 2019 11 / 40

  • Example - 3Sipser, 1.1, p-43

    We can write this language L as:{w | w is of the form x01y for some strings x and y consistingof 0’s and 1’s only.}

    Another equivalent description, using parameters x and y tothe left of the vertical bar, is:{x01y | x and y are any strings of 0’s and 1’s}

    Md Jakaria MIST Theory of Computation July 18, 2019 12 / 40

  • Example - 4Sipser, 1.1, p-43

    Example 4

    1 Design a DFA to accept the language L = {w | w hasboth an even number of 0’s and an even number of1’s}

    Md Jakaria MIST Theory of Computation July 18, 2019 13 / 40

  • Example - 4Ullman, 2.1, Fig-2.6

    Md Jakaria MIST Theory of Computation July 18, 2019 14 / 40

  • Example - 4Ullman, 2.1, Fig-2.6

    Md Jakaria MIST Theory of Computation July 18, 2019 15 / 40

  • Example - 5Lewis and Papadimitriou, Example 2.1.2

    Example 5

    1 Design a deterministic finite automaton M thataccepts the languageL(M) = { w ∈ {a,b}* : w does not contain threeconsecutive b’s}

    Md Jakaria MIST Theory of Computation July 18, 2019 16 / 40

  • Example - 5Ullman, 2.1, Fig-2.6

    Md Jakaria MIST Theory of Computation July 18, 2019 17 / 40

  • Example - 6Lewis and Papadimitriou, Example 2.1.2

    Example 6

    1 Design a DFA that accepts binary numbers that aredivisible by three.

    Md Jakaria MIST Theory of Computation July 18, 2019 18 / 40

  • Example - 6Ullman, 2.1, Fig-2.6

    Md Jakaria MIST Theory of Computation July 18, 2019 19 / 40

  • Example - 7

    Example 7

    1 Draw a DFA for the language accepting stringsstarting with ‘ab’ over input alphabets Σ = {a,b}

    Md Jakaria MIST Theory of Computation July 18, 2019 20 / 40

  • Example - 7Ullman, 2.1, Fig-2.6

    Md Jakaria MIST Theory of Computation July 18, 2019 21 / 40

  • Example - 8

    Example 8

    1 Construct a DFA that accepts a language L over inputalphabetsΣ = {a,b} such that L is the set of allstrings starting with ‘aa’ or ‘bb’.

    Md Jakaria MIST Theory of Computation July 18, 2019 22 / 40

  • Example - 8

    Md Jakaria MIST Theory of Computation July 18, 2019 23 / 40

  • Example - 9

    Example 9

    1 Design FA with Σ = {0, 1} accepts the set of all stringswith three consecutive 0’s.

    Md Jakaria MIST Theory of Computation July 18, 2019 24 / 40

  • Example - 9

    Md Jakaria MIST Theory of Computation July 18, 2019 25 / 40

  • Example - 10

    Example 10

    1 Design a FA with Σ = {0, 1} accepts the strings withan even number of 0’s followed by single 1.

    Md Jakaria MIST Theory of Computation July 18, 2019 26 / 40

  • Example - 10

    Md Jakaria MIST Theory of Computation July 18, 2019 27 / 40

  • Example - 11

    Example 11

    1 Design a DFA over w ∈ {a,b}* such that number of a= 2 and there is no restriction over length of b.

    Md Jakaria MIST Theory of Computation July 18, 2019 28 / 40

  • Example -11

    Md Jakaria MIST Theory of Computation July 18, 2019 29 / 40

  • Example - 12

    Example 12

    1 Design a DFA over w ∈ {a,b}* such that number of ais less or equals to 2 and there is no restriction overlength of b.

    Md Jakaria MIST Theory of Computation July 18, 2019 30 / 40

  • Example -12

    Md Jakaria MIST Theory of Computation July 18, 2019 31 / 40

  • Example - 13

    Example 13

    1 Design a DFA over w ∈ {a,b}* such that number of ais greater or equals to 2 and there is no restrictionover length of b.

    Md Jakaria MIST Theory of Computation July 18, 2019 32 / 40

  • Example -13

    Md Jakaria MIST Theory of Computation July 18, 2019 33 / 40

  • Example - 14

    Example 14

    1 Design a DFA over w ∈ {a,b}* in which set of allstrings can be accepted which start with a.

    Md Jakaria MIST Theory of Computation July 18, 2019 34 / 40

  • Example -14

    Md Jakaria MIST Theory of Computation July 18, 2019 35 / 40

  • Example - 15

    Example 15

    1 Design a DFA over w ∈ {a,b}* in which every ’a’should followed by ’bb’

    Md Jakaria MIST Theory of Computation July 18, 2019 36 / 40

  • Example -15

    Md Jakaria MIST Theory of Computation July 18, 2019 37 / 40

  • Example - 16

    Example 16

    1 Design a DFA such that:L = {anbm | n,m ≥ 1} Given: Input alphabet, Σ={a, b}Language L = {ab, aab, aaab, abbb, aabb, abbbb, ...}

    Md Jakaria MIST Theory of Computation July 18, 2019 38 / 40

  • Example -16

    Md Jakaria MIST Theory of Computation July 18, 2019 39 / 40

  • Ar Parina Boddo Hoyran Lage

    Md Jakaria MIST Theory of Computation July 18, 2019 40 / 40