SlideShare ist ein Scribd-Unternehmen logo
1 von 7
Downloaden Sie, um offline zu lesen
Modeling Computation - 12                                                     CSC1001 Discrete Mathematics                1

 CHAPTER
                                                การคํานวณตามแบบจําลอง
   12                                             (Modeling Computation)

  1      Finite-State Machines
1. Finite-State Machines with Output
 Definition 1

 A finite-state machine M = (S,I,O, f, g, s0) consists of a finite set S of states, a finite input alphabet I, a finite
 output alphabet O, a transition function f that assigns to each state and input pair a new state, an output
 function g that assigns to each state and input pair an output, and an initial state s0.

Show the table of finite-state machine for a vending machine (State table)




Show the directed graph of finite-state machine for a vending machine (State diagram)




มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555)                                      เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
2       CSC1001 Discrete Mathematics                                                 12 - Modeling Computation


Example 1 (5 points) Construct the state diagram for the finite-state machine with the state table.




Example 2 (5 points) Construct the state diagram for the finite-state machine with the state table.




Example 3 (5 points) Construct the state diagram for the finite-state machine with the state table.




มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555)                                เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
Modeling Computation - 12                                                CSC1001 Discrete Mathematics            3
Example 4 (5 points) Construct the state table for the finite-state machine with the state diagram.




Example 5 (5 points) Construct the state table for the finite-state machine with the state diagram.




Example 6 (5 points) Construct the state table for the finite-state machine with the state diagram.




มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555)                                เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
4         CSC1001 Discrete Mathematics                                                     12 - Modeling Computation


2. Finite-State Machines with No Output
    Definition 2

    A finite-state automaton M = (S, I, f, s0, F) consists of a finite set S of states, a finite input alphabet I, a
    transition function f that assigns a next state to every pair of state and input (so that f : S × I S), an initial
    or start state s0, and a subset F of S consisting of final (or accepting states).

Example 7 (5 points) Construct the state diagram for the finite-state automaton M = (S, I, f, s0, F), where S =
{s0, s1, s2, s3}, I = {0, 1}, F = {s0, s3}, and the transition function f is given in Table.
                                              Answer




Example 8 (5 points) Construct deterministic finite-state automata that recognize each of these languages.
(This is the solutions of an example)
1) The set of bit strings that begin with two 0s




2) The set of bit strings that contain two consecutive 0s




3) The set of bit strings that do not contain two consecutive 0s




4) The set of bit strings that end with two 0s




มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555)                                      เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
Modeling Computation - 12                                                CSC1001 Discrete Mathematics            5
5) The set of bit strings that contain at least two 0s




Example 9 (5 points) Construct a deterministic finite-state automaton that recognizes the set of all bit strings
beginning with 01.




Example 10 (5 points) Construct a deterministic finite-state automaton that recognizes the set of all bit strings
that end with 10.




Example 11 (5 points) Construct a deterministic finite-state automaton that recognizes the set of all bit strings
that contain the string 101.




Example 12 (5 points) Construct a deterministic finite-state automaton that recognizes the set of all bit strings
that do not contain three consecutive 0s.




มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555)                                เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
6         CSC1001 Discrete Mathematics                                                12 - Modeling Computation


    2       Finite-State Machines
1. Regular Expressions
    Definition 1

    The regular expressions over a set I are defined recursively by:
     the symbol ∅ is a regular expression;
     the symbol λ is a regular expression;
     the symbol x is a regular expression whenever x ∈ I ;
     the symbols (AB), (A ∪ B), and A* are regular expressions whenever A and B are regular expressions.

Each regular expression represents a set specified by these rules:
       ∅ represents the empty set, that is, the set with no strings;
       λ represents the set {λ}, which is the set containing the empty string;
       x represents the set {x} containing the string with one symbol x;
       (AB) represents the concatenation of the sets represented by A and by B;
       (A ∪ B) represents the union of the sets represented by A and by B;
       A* represents the Kleene closure of the set represented by A.
Example of regular expression




Example 13 (11 points) Describe in words the strings in each of these regular sets.
1) 1*0
2) 1*00*
3) 111 ∪ 001
4) (1 ∪ 00)*
5) (00*1)*
6) (0 ∪ 1)(0 ∪ 1)*00
7) 001*
8) (01)*
9) 01 ∪ 001*
10) 0(11 ∪ 0)*
11) (101*)*

มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555)                              เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
Modeling Computation - 12                                               CSC1001 Discrete Mathematics             7
Example 14 (8 points) Determine whether 0101 belongs to each of these regular sets.
1) 01*0*
2) 0(11) * (01) *
3) 0(10)*1*
4) 0*10(0 ∪ 1)
5) (01)*(11)*
6) 0*(10 ∪ 11)*
7) 0*(10)*11
8) 01(01 ∪ 0)1*
Example 15 (8 points) Determine whether 1011 belongs to each of these regular sets.
1) 10*1*
2) 0*(10 ∪ 11)*
3) 1(01)*1*
4) 1*01(0 ∪ 1)
5) (10)*(11)*
6) 1(00)*(11)*
7) (10)*1011
8) (1 ∪ 00)(01 ∪ 0)1*
Example 16 (10 points) Express each of these sets using a regular expression.
1) The set consisting of the strings 0, 11, and 010
2) The set of strings of three 0s followed by two or more 0s
3) The set of strings of odd length
4) The set of strings that contain exactly one 1
5) The set of strings ending in 1 and not containing 000
6) The set containing all strings with zero, one, or two bits
7) The set of strings of two 0s, followed by zero or more 1s, and ending with a 0
8) The set of strings with every 1 followed by two 0s
9) The set of strings ending in 00 and not containing 11
10) The set of strings containing an even number of 1s




มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555)                                เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

PIPELINE INTERRUPTS
PIPELINE INTERRUPTSPIPELINE INTERRUPTS
PIPELINE INTERRUPTS
 
Chapter 13 - I/O Systems
Chapter 13 - I/O SystemsChapter 13 - I/O Systems
Chapter 13 - I/O Systems
 
Chapter 01 Basic Principles of Digital Systems
Chapter 01 Basic Principles of Digital SystemsChapter 01 Basic Principles of Digital Systems
Chapter 01 Basic Principles of Digital Systems
 
1.prallelism
1.prallelism1.prallelism
1.prallelism
 
Pipeline
PipelinePipeline
Pipeline
 
Computer Architecture - Program Execution
Computer Architecture - Program ExecutionComputer Architecture - Program Execution
Computer Architecture - Program Execution
 
Message Handling System
Message Handling SystemMessage Handling System
Message Handling System
 
Algorithm chapter 10
Algorithm chapter 10Algorithm chapter 10
Algorithm chapter 10
 
System calls
System callsSystem calls
System calls
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory
 
Automata theory
Automata theoryAutomata theory
Automata theory
 
1.2. introduction to automata theory
1.2. introduction to automata theory1.2. introduction to automata theory
1.2. introduction to automata theory
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expression
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
FInite Automata
FInite AutomataFInite Automata
FInite Automata
 
digital logic circuits, digital component
digital logic circuits, digital componentdigital logic circuits, digital component
digital logic circuits, digital component
 
Statistical Pattern recognition(1)
Statistical Pattern recognition(1)Statistical Pattern recognition(1)
Statistical Pattern recognition(1)
 
Ch 05
Ch 05Ch 05
Ch 05
 
Digital logic design part1
Digital logic design part1Digital logic design part1
Digital logic design part1
 
Instruction cycle
Instruction cycleInstruction cycle
Instruction cycle
 

Ähnlich wie Discrete-Chapter 12 Modeling Computation

General pipeline concepts
General pipeline conceptsGeneral pipeline concepts
General pipeline conceptsPrasenjit Dey
 
On the Principle of Optimality for Linear Stochastic Dynamic System
On the Principle of Optimality for Linear Stochastic Dynamic System On the Principle of Optimality for Linear Stochastic Dynamic System
On the Principle of Optimality for Linear Stochastic Dynamic System ijfcstjournal
 
Computation of Electromagnetic Fields Scattered from Dielectric Objects of Un...
Computation of Electromagnetic Fields Scattered from Dielectric Objects of Un...Computation of Electromagnetic Fields Scattered from Dielectric Objects of Un...
Computation of Electromagnetic Fields Scattered from Dielectric Objects of Un...Alexander Litvinenko
 
UNIT-II : SEQUENTIAL CIRCUIT DESIGN
UNIT-II  : SEQUENTIAL CIRCUIT DESIGN UNIT-II  : SEQUENTIAL CIRCUIT DESIGN
UNIT-II : SEQUENTIAL CIRCUIT DESIGN Dr.YNM
 
UNIT-II -DIGITAL SYSTEM DESIGN
UNIT-II -DIGITAL SYSTEM DESIGNUNIT-II -DIGITAL SYSTEM DESIGN
UNIT-II -DIGITAL SYSTEM DESIGNDr.YNM
 
A simple multi-stable chaotic jerk system with two saddle-foci equilibrium po...
A simple multi-stable chaotic jerk system with two saddle-foci equilibrium po...A simple multi-stable chaotic jerk system with two saddle-foci equilibrium po...
A simple multi-stable chaotic jerk system with two saddle-foci equilibrium po...IJECEIAES
 
Mathematical Statistics Assignment Help
Mathematical Statistics Assignment HelpMathematical Statistics Assignment Help
Mathematical Statistics Assignment HelpExcel Homework Help
 
Digital Signals and System (October – 2016) [Revised Syllabus | Question Paper]
Digital Signals and System (October  – 2016) [Revised Syllabus | Question Paper]Digital Signals and System (October  – 2016) [Revised Syllabus | Question Paper]
Digital Signals and System (October – 2016) [Revised Syllabus | Question Paper]Mumbai B.Sc.IT Study
 
Modern Control System (BE)
Modern Control System (BE)Modern Control System (BE)
Modern Control System (BE)PRABHAHARAN429
 
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...ieijjournal
 
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...ieijjournal
 
Automata
AutomataAutomata
AutomataGaditek
 
Automata
AutomataAutomata
AutomataGaditek
 

Ähnlich wie Discrete-Chapter 12 Modeling Computation (20)

QB104541.pdf
QB104541.pdfQB104541.pdf
QB104541.pdf
 
Discrete-Chapter 01 Sets
Discrete-Chapter 01 SetsDiscrete-Chapter 01 Sets
Discrete-Chapter 01 Sets
 
General pipeline concepts
General pipeline conceptsGeneral pipeline concepts
General pipeline concepts
 
On the Principle of Optimality for Linear Stochastic Dynamic System
On the Principle of Optimality for Linear Stochastic Dynamic System On the Principle of Optimality for Linear Stochastic Dynamic System
On the Principle of Optimality for Linear Stochastic Dynamic System
 
Computation of Electromagnetic Fields Scattered from Dielectric Objects of Un...
Computation of Electromagnetic Fields Scattered from Dielectric Objects of Un...Computation of Electromagnetic Fields Scattered from Dielectric Objects of Un...
Computation of Electromagnetic Fields Scattered from Dielectric Objects of Un...
 
UNIT-II : SEQUENTIAL CIRCUIT DESIGN
UNIT-II  : SEQUENTIAL CIRCUIT DESIGN UNIT-II  : SEQUENTIAL CIRCUIT DESIGN
UNIT-II : SEQUENTIAL CIRCUIT DESIGN
 
UNIT-II -DIGITAL SYSTEM DESIGN
UNIT-II -DIGITAL SYSTEM DESIGNUNIT-II -DIGITAL SYSTEM DESIGN
UNIT-II -DIGITAL SYSTEM DESIGN
 
A simple multi-stable chaotic jerk system with two saddle-foci equilibrium po...
A simple multi-stable chaotic jerk system with two saddle-foci equilibrium po...A simple multi-stable chaotic jerk system with two saddle-foci equilibrium po...
A simple multi-stable chaotic jerk system with two saddle-foci equilibrium po...
 
4th Semester Electronic and Communication Engineering (2013-June) Question Pa...
4th Semester Electronic and Communication Engineering (2013-June) Question Pa...4th Semester Electronic and Communication Engineering (2013-June) Question Pa...
4th Semester Electronic and Communication Engineering (2013-June) Question Pa...
 
Seattle.Slides.7
Seattle.Slides.7Seattle.Slides.7
Seattle.Slides.7
 
Mathematical Statistics Assignment Help
Mathematical Statistics Assignment HelpMathematical Statistics Assignment Help
Mathematical Statistics Assignment Help
 
Assignment 2 solution acs
Assignment 2 solution acsAssignment 2 solution acs
Assignment 2 solution acs
 
Digital Signals and System (October – 2016) [Revised Syllabus | Question Paper]
Digital Signals and System (October  – 2016) [Revised Syllabus | Question Paper]Digital Signals and System (October  – 2016) [Revised Syllabus | Question Paper]
Digital Signals and System (October – 2016) [Revised Syllabus | Question Paper]
 
Modern Control System (BE)
Modern Control System (BE)Modern Control System (BE)
Modern Control System (BE)
 
exam1 unsolved
exam1 unsolvedexam1 unsolved
exam1 unsolved
 
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
 
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
FITTED OPERATOR FINITE DIFFERENCE METHOD FOR SINGULARLY PERTURBED PARABOLIC C...
 
Automata
AutomataAutomata
Automata
 
Automata
AutomataAutomata
Automata
 
10_rnn.pdf
10_rnn.pdf10_rnn.pdf
10_rnn.pdf
 

Mehr von Wongyos Keardsri

How to Study and Research in Computer-related Master Program
How to Study and Research in Computer-related Master ProgramHow to Study and Research in Computer-related Master Program
How to Study and Research in Computer-related Master ProgramWongyos Keardsri
 
The next generation intelligent transport systems: standards and applications
The next generation intelligent transport systems: standards and applicationsThe next generation intelligent transport systems: standards and applications
The next generation intelligent transport systems: standards and applicationsWongyos Keardsri
 
SysProg-Tutor 03 Unix Shell Script Programming
SysProg-Tutor 03 Unix Shell Script ProgrammingSysProg-Tutor 03 Unix Shell Script Programming
SysProg-Tutor 03 Unix Shell Script ProgrammingWongyos Keardsri
 
SysProg-Tutor 02 Introduction to Unix Operating System
SysProg-Tutor 02 Introduction to Unix Operating SystemSysProg-Tutor 02 Introduction to Unix Operating System
SysProg-Tutor 02 Introduction to Unix Operating SystemWongyos Keardsri
 
SysProg-Tutor 01 Introduction to C Programming Language
SysProg-Tutor 01 Introduction to C Programming LanguageSysProg-Tutor 01 Introduction to C Programming Language
SysProg-Tutor 01 Introduction to C Programming LanguageWongyos Keardsri
 
Discrete-Chapter 11 Graphs Part III
Discrete-Chapter 11 Graphs Part IIIDiscrete-Chapter 11 Graphs Part III
Discrete-Chapter 11 Graphs Part IIIWongyos Keardsri
 
Discrete-Chapter 11 Graphs Part II
Discrete-Chapter 11 Graphs Part IIDiscrete-Chapter 11 Graphs Part II
Discrete-Chapter 11 Graphs Part IIWongyos Keardsri
 
Discrete-Chapter 11 Graphs Part I
Discrete-Chapter 11 Graphs Part IDiscrete-Chapter 11 Graphs Part I
Discrete-Chapter 11 Graphs Part IWongyos Keardsri
 
Discrete-Chapter 09 Algorithms
Discrete-Chapter 09 AlgorithmsDiscrete-Chapter 09 Algorithms
Discrete-Chapter 09 AlgorithmsWongyos Keardsri
 
Discrete-Chapter 08 Relations
Discrete-Chapter 08 RelationsDiscrete-Chapter 08 Relations
Discrete-Chapter 08 RelationsWongyos Keardsri
 
Discrete-Chapter 07 Probability
Discrete-Chapter 07 ProbabilityDiscrete-Chapter 07 Probability
Discrete-Chapter 07 ProbabilityWongyos Keardsri
 
Discrete-Chapter 06 Counting
Discrete-Chapter 06 CountingDiscrete-Chapter 06 Counting
Discrete-Chapter 06 CountingWongyos Keardsri
 
Discrete-Chapter 05 Inference and Proofs
Discrete-Chapter 05 Inference and ProofsDiscrete-Chapter 05 Inference and Proofs
Discrete-Chapter 05 Inference and ProofsWongyos Keardsri
 
Discrete-Chapter 04 Logic Part II
Discrete-Chapter 04 Logic Part IIDiscrete-Chapter 04 Logic Part II
Discrete-Chapter 04 Logic Part IIWongyos Keardsri
 
Discrete-Chapter 04 Logic Part I
Discrete-Chapter 04 Logic Part IDiscrete-Chapter 04 Logic Part I
Discrete-Chapter 04 Logic Part IWongyos Keardsri
 
Discrete-Chapter 03 Matrices
Discrete-Chapter 03 MatricesDiscrete-Chapter 03 Matrices
Discrete-Chapter 03 MatricesWongyos Keardsri
 
Discrete-Chapter 02 Functions and Sequences
Discrete-Chapter 02 Functions and SequencesDiscrete-Chapter 02 Functions and Sequences
Discrete-Chapter 02 Functions and SequencesWongyos Keardsri
 
Java-Chapter 14 Creating Graphics with DWindow
Java-Chapter 14 Creating Graphics with DWindowJava-Chapter 14 Creating Graphics with DWindow
Java-Chapter 14 Creating Graphics with DWindowWongyos Keardsri
 

Mehr von Wongyos Keardsri (20)

How to Study and Research in Computer-related Master Program
How to Study and Research in Computer-related Master ProgramHow to Study and Research in Computer-related Master Program
How to Study and Research in Computer-related Master Program
 
The next generation intelligent transport systems: standards and applications
The next generation intelligent transport systems: standards and applicationsThe next generation intelligent transport systems: standards and applications
The next generation intelligent transport systems: standards and applications
 
IP address anonymization
IP address anonymizationIP address anonymization
IP address anonymization
 
SysProg-Tutor 03 Unix Shell Script Programming
SysProg-Tutor 03 Unix Shell Script ProgrammingSysProg-Tutor 03 Unix Shell Script Programming
SysProg-Tutor 03 Unix Shell Script Programming
 
SysProg-Tutor 02 Introduction to Unix Operating System
SysProg-Tutor 02 Introduction to Unix Operating SystemSysProg-Tutor 02 Introduction to Unix Operating System
SysProg-Tutor 02 Introduction to Unix Operating System
 
SysProg-Tutor 01 Introduction to C Programming Language
SysProg-Tutor 01 Introduction to C Programming LanguageSysProg-Tutor 01 Introduction to C Programming Language
SysProg-Tutor 01 Introduction to C Programming Language
 
Discrete-Chapter 11 Graphs Part III
Discrete-Chapter 11 Graphs Part IIIDiscrete-Chapter 11 Graphs Part III
Discrete-Chapter 11 Graphs Part III
 
Discrete-Chapter 11 Graphs Part II
Discrete-Chapter 11 Graphs Part IIDiscrete-Chapter 11 Graphs Part II
Discrete-Chapter 11 Graphs Part II
 
Discrete-Chapter 11 Graphs Part I
Discrete-Chapter 11 Graphs Part IDiscrete-Chapter 11 Graphs Part I
Discrete-Chapter 11 Graphs Part I
 
Discrete-Chapter 10 Trees
Discrete-Chapter 10 TreesDiscrete-Chapter 10 Trees
Discrete-Chapter 10 Trees
 
Discrete-Chapter 09 Algorithms
Discrete-Chapter 09 AlgorithmsDiscrete-Chapter 09 Algorithms
Discrete-Chapter 09 Algorithms
 
Discrete-Chapter 08 Relations
Discrete-Chapter 08 RelationsDiscrete-Chapter 08 Relations
Discrete-Chapter 08 Relations
 
Discrete-Chapter 07 Probability
Discrete-Chapter 07 ProbabilityDiscrete-Chapter 07 Probability
Discrete-Chapter 07 Probability
 
Discrete-Chapter 06 Counting
Discrete-Chapter 06 CountingDiscrete-Chapter 06 Counting
Discrete-Chapter 06 Counting
 
Discrete-Chapter 05 Inference and Proofs
Discrete-Chapter 05 Inference and ProofsDiscrete-Chapter 05 Inference and Proofs
Discrete-Chapter 05 Inference and Proofs
 
Discrete-Chapter 04 Logic Part II
Discrete-Chapter 04 Logic Part IIDiscrete-Chapter 04 Logic Part II
Discrete-Chapter 04 Logic Part II
 
Discrete-Chapter 04 Logic Part I
Discrete-Chapter 04 Logic Part IDiscrete-Chapter 04 Logic Part I
Discrete-Chapter 04 Logic Part I
 
Discrete-Chapter 03 Matrices
Discrete-Chapter 03 MatricesDiscrete-Chapter 03 Matrices
Discrete-Chapter 03 Matrices
 
Discrete-Chapter 02 Functions and Sequences
Discrete-Chapter 02 Functions and SequencesDiscrete-Chapter 02 Functions and Sequences
Discrete-Chapter 02 Functions and Sequences
 
Java-Chapter 14 Creating Graphics with DWindow
Java-Chapter 14 Creating Graphics with DWindowJava-Chapter 14 Creating Graphics with DWindow
Java-Chapter 14 Creating Graphics with DWindow
 

Discrete-Chapter 12 Modeling Computation

  • 1. Modeling Computation - 12 CSC1001 Discrete Mathematics 1 CHAPTER การคํานวณตามแบบจําลอง 12 (Modeling Computation) 1 Finite-State Machines 1. Finite-State Machines with Output Definition 1 A finite-state machine M = (S,I,O, f, g, s0) consists of a finite set S of states, a finite input alphabet I, a finite output alphabet O, a transition function f that assigns to each state and input pair a new state, an output function g that assigns to each state and input pair an output, and an initial state s0. Show the table of finite-state machine for a vending machine (State table) Show the directed graph of finite-state machine for a vending machine (State diagram) มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
  • 2. 2 CSC1001 Discrete Mathematics 12 - Modeling Computation Example 1 (5 points) Construct the state diagram for the finite-state machine with the state table. Example 2 (5 points) Construct the state diagram for the finite-state machine with the state table. Example 3 (5 points) Construct the state diagram for the finite-state machine with the state table. มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
  • 3. Modeling Computation - 12 CSC1001 Discrete Mathematics 3 Example 4 (5 points) Construct the state table for the finite-state machine with the state diagram. Example 5 (5 points) Construct the state table for the finite-state machine with the state diagram. Example 6 (5 points) Construct the state table for the finite-state machine with the state diagram. มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
  • 4. 4 CSC1001 Discrete Mathematics 12 - Modeling Computation 2. Finite-State Machines with No Output Definition 2 A finite-state automaton M = (S, I, f, s0, F) consists of a finite set S of states, a finite input alphabet I, a transition function f that assigns a next state to every pair of state and input (so that f : S × I S), an initial or start state s0, and a subset F of S consisting of final (or accepting states). Example 7 (5 points) Construct the state diagram for the finite-state automaton M = (S, I, f, s0, F), where S = {s0, s1, s2, s3}, I = {0, 1}, F = {s0, s3}, and the transition function f is given in Table. Answer Example 8 (5 points) Construct deterministic finite-state automata that recognize each of these languages. (This is the solutions of an example) 1) The set of bit strings that begin with two 0s 2) The set of bit strings that contain two consecutive 0s 3) The set of bit strings that do not contain two consecutive 0s 4) The set of bit strings that end with two 0s มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
  • 5. Modeling Computation - 12 CSC1001 Discrete Mathematics 5 5) The set of bit strings that contain at least two 0s Example 9 (5 points) Construct a deterministic finite-state automaton that recognizes the set of all bit strings beginning with 01. Example 10 (5 points) Construct a deterministic finite-state automaton that recognizes the set of all bit strings that end with 10. Example 11 (5 points) Construct a deterministic finite-state automaton that recognizes the set of all bit strings that contain the string 101. Example 12 (5 points) Construct a deterministic finite-state automaton that recognizes the set of all bit strings that do not contain three consecutive 0s. มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
  • 6. 6 CSC1001 Discrete Mathematics 12 - Modeling Computation 2 Finite-State Machines 1. Regular Expressions Definition 1 The regular expressions over a set I are defined recursively by: the symbol ∅ is a regular expression; the symbol λ is a regular expression; the symbol x is a regular expression whenever x ∈ I ; the symbols (AB), (A ∪ B), and A* are regular expressions whenever A and B are regular expressions. Each regular expression represents a set specified by these rules: ∅ represents the empty set, that is, the set with no strings; λ represents the set {λ}, which is the set containing the empty string; x represents the set {x} containing the string with one symbol x; (AB) represents the concatenation of the sets represented by A and by B; (A ∪ B) represents the union of the sets represented by A and by B; A* represents the Kleene closure of the set represented by A. Example of regular expression Example 13 (11 points) Describe in words the strings in each of these regular sets. 1) 1*0 2) 1*00* 3) 111 ∪ 001 4) (1 ∪ 00)* 5) (00*1)* 6) (0 ∪ 1)(0 ∪ 1)*00 7) 001* 8) (01)* 9) 01 ∪ 001* 10) 0(11 ∪ 0)* 11) (101*)* มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
  • 7. Modeling Computation - 12 CSC1001 Discrete Mathematics 7 Example 14 (8 points) Determine whether 0101 belongs to each of these regular sets. 1) 01*0* 2) 0(11) * (01) * 3) 0(10)*1* 4) 0*10(0 ∪ 1) 5) (01)*(11)* 6) 0*(10 ∪ 11)* 7) 0*(10)*11 8) 01(01 ∪ 0)1* Example 15 (8 points) Determine whether 1011 belongs to each of these regular sets. 1) 10*1* 2) 0*(10 ∪ 11)* 3) 1(01)*1* 4) 1*01(0 ∪ 1) 5) (10)*(11)* 6) 1(00)*(11)* 7) (10)*1011 8) (1 ∪ 00)(01 ∪ 0)1* Example 16 (10 points) Express each of these sets using a regular expression. 1) The set consisting of the strings 0, 11, and 010 2) The set of strings of three 0s followed by two or more 0s 3) The set of strings of odd length 4) The set of strings that contain exactly one 1 5) The set of strings ending in 1 and not containing 000 6) The set containing all strings with zero, one, or two bits 7) The set of strings of two 0s, followed by zero or more 1s, and ending with a 0 8) The set of strings with every 1 followed by two 0s 9) The set of strings ending in 00 and not containing 11 10) The set of strings containing an even number of 1s มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี