SlideShare une entreprise Scribd logo
1  sur  7
Télécharger pour lire hors ligne
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)                                เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี

Contenu connexe

Tendances

Lesson 21: Antiderivatives (slides)
Lesson 21: Antiderivatives (slides)Lesson 21: Antiderivatives (slides)
Lesson 21: Antiderivatives (slides)Matthew Leingang
 
Examinable Question and answer system programming
Examinable Question and answer system programmingExaminable Question and answer system programming
Examinable Question and answer system programmingMakerere university
 
Relations digraphs
Relations  digraphsRelations  digraphs
Relations digraphsIIUM
 
RISC and CISC Processors
RISC and CISC ProcessorsRISC and CISC Processors
RISC and CISC ProcessorsAdeel Rasheed
 
Bellman Ford's Algorithm
Bellman Ford's AlgorithmBellman Ford's Algorithm
Bellman Ford's AlgorithmTanmay Baranwal
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Eelco Visser
 
EET107_Chapter 3_SLD(part2.1)-edit1.ppt
EET107_Chapter 3_SLD(part2.1)-edit1.pptEET107_Chapter 3_SLD(part2.1)-edit1.ppt
EET107_Chapter 3_SLD(part2.1)-edit1.pptBeautyKumar1
 
Automata theory -- NFA and DFA construction
Automata theory -- NFA and DFA  constructionAutomata theory -- NFA and DFA  construction
Automata theory -- NFA and DFA constructionAkila Krishnamoorthy
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086Akhila Rahul
 
Relation in Discrete Mathematics
Relation in Discrete Mathematics Relation in Discrete Mathematics
Relation in Discrete Mathematics NANDINI SHARMA
 
Basic computer organization and design
Basic computer organization and designBasic computer organization and design
Basic computer organization and designmahesh kumar prajapat
 
Part I:Introduction to assembly language
Part I:Introduction to assembly languagePart I:Introduction to assembly language
Part I:Introduction to assembly languageAhmed M. Abed
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFAMaulik Togadiya
 
Assembly Language and microprocessor
Assembly Language and microprocessorAssembly Language and microprocessor
Assembly Language and microprocessorKhaled Sany
 
Indefinite and Definite Integrals Using the Substitution Method
Indefinite and Definite Integrals Using the Substitution MethodIndefinite and Definite Integrals Using the Substitution Method
Indefinite and Definite Integrals Using the Substitution MethodScott Bailey
 
Ordinary differential equation
Ordinary differential equationOrdinary differential equation
Ordinary differential equationJUGAL BORAH
 
memory reference instruction
memory reference instructionmemory reference instruction
memory reference instructionDeepikaT13
 
Propositional logic
Propositional logicPropositional logic
Propositional logicMamta Pandey
 

Tendances (20)

Lesson 21: Antiderivatives (slides)
Lesson 21: Antiderivatives (slides)Lesson 21: Antiderivatives (slides)
Lesson 21: Antiderivatives (slides)
 
Examinable Question and answer system programming
Examinable Question and answer system programmingExaminable Question and answer system programming
Examinable Question and answer system programming
 
Relations digraphs
Relations  digraphsRelations  digraphs
Relations digraphs
 
M ary-tree
M ary-treeM ary-tree
M ary-tree
 
RISC and CISC Processors
RISC and CISC ProcessorsRISC and CISC Processors
RISC and CISC Processors
 
Bellman Ford's Algorithm
Bellman Ford's AlgorithmBellman Ford's Algorithm
Bellman Ford's Algorithm
 
Algoritmos
AlgoritmosAlgoritmos
Algoritmos
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?
 
EET107_Chapter 3_SLD(part2.1)-edit1.ppt
EET107_Chapter 3_SLD(part2.1)-edit1.pptEET107_Chapter 3_SLD(part2.1)-edit1.ppt
EET107_Chapter 3_SLD(part2.1)-edit1.ppt
 
Automata theory -- NFA and DFA construction
Automata theory -- NFA and DFA  constructionAutomata theory -- NFA and DFA  construction
Automata theory -- NFA and DFA construction
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Relation in Discrete Mathematics
Relation in Discrete Mathematics Relation in Discrete Mathematics
Relation in Discrete Mathematics
 
Basic computer organization and design
Basic computer organization and designBasic computer organization and design
Basic computer organization and design
 
Part I:Introduction to assembly language
Part I:Introduction to assembly languagePart I:Introduction to assembly language
Part I:Introduction to assembly language
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
 
Assembly Language and microprocessor
Assembly Language and microprocessorAssembly Language and microprocessor
Assembly Language and microprocessor
 
Indefinite and Definite Integrals Using the Substitution Method
Indefinite and Definite Integrals Using the Substitution MethodIndefinite and Definite Integrals Using the Substitution Method
Indefinite and Definite Integrals Using the Substitution Method
 
Ordinary differential equation
Ordinary differential equationOrdinary differential equation
Ordinary differential equation
 
memory reference instruction
memory reference instructionmemory reference instruction
memory reference instruction
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
 

Similaire à 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
 

Similaire à 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
 

Plus de 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
 

Plus de 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) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี