Dr. Eng. Farag Elnagahy Office Phone: 67967 King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.

Slides:



Advertisements
Similar presentations
Modeling Computation Chapter 13.
Advertisements

Finite-State Machines with No Output Ying Lu
Finite State Machines Finite state machines with output
4b Lexical analysis Finite Automata
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
YES-NO machines Finite State Automata as language recognizers.
COGN1001: Introduction to Cognitive Science Topics in Computer Science Formal Languages and Models of Computation Qiang HUO Department of Computer.
Chapter Section Section Summary Set of Strings Finite-State Automata Language Recognition by Finite-State Machines Designing Finite-State.
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
CS5371 Theory of Computation
Finite Automata Finite-state machine with no output. FA consists of States, Transitions between states FA is a 5-tuple Example! A string x is recognized.
Fall 2006Costas Busch - RPI1 Deterministic Finite Automata And Regular Languages.
1.Defs. a)Finite Automaton: A Finite Automaton ( FA ) has finite set of ‘states’ ( Q={q 0, q 1, q 2, ….. ) and its ‘control’ moves from state to state.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Great Theoretical Ideas in Computer Science.
CSE 311: Foundations of Computing Fall 2014 Lecture 23: State Minimization, NFAs.
Rosen 5th ed., ch. 11 Ref: Wikipedia
Regular Expressions (RE) Empty set Φ A RE denotes the empty set Empty string λ A RE denotes the set {λ} Symbol a A RE denotes the set {a} Alternation M.
Finite-State Machines with No Output Longin Jan Latecki Temple University Based on Slides by Elsa L Gunter, NJIT, and by Costas Busch Costas Busch.
Finite-State Machines with No Output
NFA ε - NFA - DFA equivalence. What is an NFA An NFA is an automaton that its states might have none, one or more outgoing arrows under a specific symbol.
::ICS 804:: Theory of Computation - Ibrahim Otieno SCI/ICT Building Rm. G15.
Finite-State Machines with Output
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
Lecture 23: Finite State Machines with no Outputs Acceptors & Recognizers.
1 Chapter 3 Scanning – Theory and Practice. 2 Overview Formal notations for specifying the precise structure of tokens are necessary –Quoted string in.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
1 Course Overview PART I: overview material 1Introduction 2Language processors (tombstone diagrams, bootstrapping) 3Architecture of a compiler PART II:
Copyright © Curt Hill Finite State Automata Again This Time No Output.
Overview of Previous Lesson(s) Over View  Symbol tables are data structures that are used by compilers to hold information about source-program constructs.
September1999 CMSC 203 / 0201 Fall 2002 Week #15 – 2/4/6 December 2002 Prof. Marie desJardins.
Finite State Machines 1.Finite state machines with output 2.Finite state machines with no output 3.DFA 4.NDFA.
Modeling Computation: Finite State Machines without Output
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
R. Johnsonbaugh Discrete Mathematics 5 th edition, 2001 Chapter 10 Automata, Grammars and Languages.
Lecture # 15. Mealy machine A Mealy machine consists of the following 1. A finite set of states q 0, q 1, q 2, … where q 0 is the initial state. 2. An.
1 Languages: Finite State Machines Chapter 6 problemsstrings (languages) machines answers.
using Deterministic Finite Automata & Nondeterministic Finite Automata
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
BİL711 Natural Language Processing1 Regular Expressions & FSAs Any regular expression can be realized as a finite state automaton (FSA) There are two kinds.
Conceptual Foundations © 2008 Pearson Education Australia Lecture slides for this course are based on teaching materials provided/referred by: (1) Statistics.
Pushdown Automata Hopcroft, Motawi, Ullman, Chap 6.
1 Section 11.2 Finite Automata Can a machine(i.e., algorithm) recognize a regular language? Yes! Deterministic Finite Automata A deterministic finite automaton.
Deterministic Finite Automata Nondeterministic Finite Automata.
Lecture #5 Advanced Computation Theory Finite Automata.
  An alphabet is any finite set of symbols.  Examples: ASCII, Unicode, {0,1} ( binary alphabet ), {a,b,c}. Alphabets.
Theory of Computation Automata Theory Dr. Ayman Srour.
Finite-State Machines (FSM) Chuck Cusack Based partly on Chapter 11 of “Discrete Mathematics and its Applications,” 5 th edition, by Kenneth Rosen.
Deterministic Finite-State Machine (or Deterministic Finite Automaton) A DFA is a 5-tuple, (S, Σ, T, s, A), consisting of: S: a finite set of states Σ:
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
Finite Automata.
Finite State Machines Dr K R Bond 2009
Lexical analysis Finite Automata
Non Deterministic Automata
Finite Automata & Regular Languages
REGULAR LANGUAGES AND REGULAR GRAMMARS
Some slides by Elsa L Gunter, NJIT, and by Costas Busch
Finite Automata.
4b Lexical analysis Finite Automata
Chapter Five: Nondeterministic Finite Automata
Deterministic Finite Automaton (DFA)
4b Lexical analysis Finite Automata
Chapter 1 Regular Language
Finite-State Machines with No Output
Non Deterministic Automata
What is it? The term "Automata" is derived from the Greek word "αὐτόματα" which means "self-acting". An automaton (Automata in plural) is an abstract self-propelled.
Presentation transcript:

Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222 Discrete Structures I Modeling Computation Finite-State Machines

2 Finite-State Machines (FSM) finite-state machine is one type of structures that used in models of computation. We will study two types of finite-state machines  finite-state machine with output  finite-state machine with no output (has final state) FSM is Used to model many kinds of machines FSM is Used to model many kinds of machines oVending machines oDelay machines oBinary adders oLanguage recognizer oSpell checking oRecognizing speech, etc.

3 Finite-State Machines with Outputs A finite-state machine with output M = ( S, I, O, f, g, s 0 ) M = ( S, I, O, f, g, s 0 ) 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 sate and input pair a new state  An output function g that assigns to each sate and input pair an output  An initial state s 0

4 The following state table describes a finite-state machine with S={s 0,s 1,s 2,s 3 }, I={0,1} and O={0,1} the values of the transition function f are displayed in the first two columns, and the values of the output function g are displayed in the last two columns. State diagram State table Finite-State Machines with Outputs

5 Construct the state table for the finite-state machine with the following state diagram.

6 Finite-State Machines with Outputs Find the output string generated by the following finite-state machine if the input string is The obtained output is as shown in the table.

7 Finite-State Machines with Outputs Unit-Delay Machine Unit-Delay Machine produces as output the input string delayed by a specific amount of time. Input: x 1 x 2 x 3 ……..x n output: 0x 1 x 2 x 3 ……..x n-1 Previous input is 1 Previous input is 0

8 Finite-State Machines with Outputs Construct a finite-state machine that adds two integers using their binary expansion. Input 1 : (x n…….. x 1 x 0 ) 2 Input 2 : (y n…….. y 1 y 0 ) 2 For simplicity assumed that x n =y n =0 A finite-state machine for addition Previous carry is 1 Previous carry is 0

9 Finite-State Machines with Outputs Construct a finite-state machine that gives a 1 as its current output bit if and only if the last three bits received are all 1s.

10 Exercises pp

11 Finite-State Machines with no Outputs  Finite-state machine with no output is called finite- state automaton (plural is automata)  This machine does not produce output, but it has a set for final states. The final states are indicated in state diagrams by using double circles. The final states are indicated in state diagrams by using double circles.

12 Finite-State Machines with no Outputs A finite-state automaton M = ( S, I, f, s 0, 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: SxI  S)  An initial state (start state) s 0 and  A subset F of S consisting of final states (accepting states)

13 Finite-State Machines with no Outputs Construct the state diagram for the finite-state automaton M = ( S, I, f, s 0, F ) where S={s 0,s 1,s 2,s 3 }, I={0,1},F={s 0,s 3 }, and the transition function f is given in the following table.

14 Finite-State Machines with no Outputs Set of strings Suppose that A and B are subsets of V*, where V is a vocabulary. The concatenation of A and B, denoted by AB, is the set of all strings of the form xy, where x is a string in A and y is a string in B. V* is the set of all words over v. Example A={0,11} and B={1,10,110} find AB and BA. AB={01,010,0110,111,1110,11110}BA={10,111,100,1011,1100,11011}

15 Finite-State Machines with no Outputs The empty string or null string ( ), is the string containing no symbol. is different from  (empty set) is different from  (empty set) A n n=0,1,2,….. concatenation AAAAAAAAA A 0 ={ } A n+1 = A n A Example A={1,00} find A n for n=0,1,and 3. A 0 ={ } A 1 = A 0 A= { }A= {1,00} A 2 =A 1 A={11,100,001,0000} A 3 = A 2 A={111,1100,1001,10000,0011,00100,00001, }

16 Finite-State Machines with no Outputs Language recognition by finite-state machines  A string x is said to be recognized or accepted by the machine M = ( S, I, f, s 0, F ) if it takes the initial state s 0 to a final state,that is, f(s 0,x) is a state in F.  The Language recognized or accepted by the machine M, denoted by L(M), is the set of all strings that are recognized by M.  Two finite-state automata are called equivalent if they recognize the same language.

17 Finite-State Machines with no Outputs Language recognition by finite-state machines Determine the languages recognized by the finite-state automata M 1, and M 2 in the following figure. L(M 1 )={1 n |n=0,1,2,…} Concatenations M2M2M2M2 M1M1M1M1 L(M 2 )={1,01}

18 Examp1: Construct a deterministic finite-state automaton that recognizes the set of all bit strings such that the first bit is 0 and all remaining bits are 1’s. Finite-State Machines with no Outputs

19 Examp2: Construct a deterministic finite-state automaton that recognizes the set of all bit strings that contain exactly one 0. Finite-State Machines with no Outputs

20 Examp3: Determine the set of bit strings recognized by the following deterministic finite-state automaton. If the bit string ends in 0, you end in state s 2. If the bit string ends in 1, you end in state s 1. Therefore, this automaton recognizes all bit strings that end in 0. Finite-State Machines with no Outputs

21 Examp4: Determine the set of bit strings recognized by the following deterministic finite-state automaton. If the bit string has two consecutive 0’s or two consecutive 1’s, you end in state s 3. If the bit string has no two consecutive 0’s or two consecutive 1’s, you end in either state s 1 or s 2. Therefore, this automaton recognizes all bit strings that alternate 0’s and 1’s. Finite-State Machines with no Outputs

22 Examp5: Determine the set of bit strings recognized by the following deterministic finite-state automaton. The string must end in 01 in order to be recognized by this automaton. If the string ends in 11, the string ends in state s 0. If the string ends in 0, the string ends in state s 1. Finite-State Machines with no Outputs

23 Finite-State Machines with no Outputs Types of finite-state automata Deterministic For each pair of state and input value there is a unique next state given by transition function. Nondeterministic For each pair of state and input value there may be several possible next states given by transition function.

24 Find the state diagram for the nondeterministic finite- state automaton with the following state table. Finite-State Machines with no Outputs

25 Finite-State Machines with no Outputs Find the state diagram for the nondeterministic finite- state automaton with the following state table.

26 Exercises pp