Finite-state machines (FSMs)

Similar documents
Finite Automata. Finite Automata

Automata Theory (2A) Young Won Lim 5/31/18

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,


Introduction to Computers & Programming

Computer Sciences Department

CSE 311 Lecture 23: Finite State Machines. Emina Torlak and Kevin Zatloukal

UNIT-I. Strings, Alphabets, Language and Operations

Nondeterministic Finite Automata

Part I: Definitions and Properties

CMP 309: Automata Theory, Computability and Formal Languages. Adapted from the work of Andrej Bogdanov

Finite-State Machines (Automata) lecture 12

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Author: Vivek Kulkarni ( )

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Decision, Computation and Language

Deterministic Finite Automata (DFAs)

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

Deterministic Finite Automata (DFAs)

Deterministic Finite Automata (DFAs)

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

Theory of Finite Automata

Uses of finite automata

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata.

Announcements. Problem Set Four due Thursday at 7:00PM (right before the midterm).

Formal Methods Engineering Nasreen Iqbal De Montfort University

Finite State Machines 2

Finite Automata. Seungjin Choi

Course 4 Finite Automata/Finite State Machines

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

CSCI 2670 Introduction to Theory of Computing

Theory of Computation

Chapter Two: Finite Automata

Finite State Machines Transducers Markov Models Hidden Markov Models Büchi Automata

Chapter 5. Finite Automata

Chapter Five: Nondeterministic Finite Automata

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

Finite State Machine (1A) Young Won Lim 6/9/18

Regular Expressions and Finite-State Automata. L545 Spring 2008

Computability and Complexity

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

Finite Automata. BİL405 - Automata Theory and Formal Languages 1

Models for representing sequential circuits

ECS 120 Lesson 15 Turing Machines, Pt. 1

Sequential logic and design

Closure under the Regular Operations

EECS 144/244: Fundamental Algorithms for System Modeling, Analysis, and Optimization

Theory of Computation

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

Formal Definition of a Finite Automaton. August 26, 2013

Automata: a short introduction

Lecture 23 : Nondeterministic Finite Automata DRAFT Connection between Regular Expressions and Finite Automata

CSCI 2200 Foundations of Computer Science Spring 2018 Quiz 3 (May 2, 2018) SOLUTIONS

Automata and Languages

Sri vidya college of engineering and technology

Embedded systems specification and design

Discrete Mathematics. CS204: Spring, Jong C. Park Computer Science Department KAIST

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

Introduction to Formal Languages, Automata and Computability p.1/51

Deterministic Finite Automaton (DFA)

Language Stability and Stabilizability of Discrete Event Dynamical Systems 1

Computational Models #1

Introduction to Theoretical Computer Science. Motivation. Automata = abstract computing devices

Automata Theory for Presburger Arithmetic Logic

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

Inf2A: Converting from NFAs to DFAs and Closure Properties

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

Nondeterminism. September 7, Nondeterminism

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

Automata and Languages

Computational Models: Class 1

Deterministic Finite Automata (DFAs)

Further discussion of Turing machines

Critical CS Questions

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Formal Definition of Computation. August 28, 2013

Finite Automata Part One

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Theory of Computation (I) Yijia Chen Fudan University

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

CPS 220 Theory of Computation Pushdown Automata (PDA)

Lecture 1: Finite State Automaton

FINITE STATE MACHINES (AUTOMATA)

or 0101 Machine

Student#: CISC-462 Exam, December XY, 2017 Page 1 of 12

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

Finite Automata Part One

Lecture 10: Synchronous Sequential Circuits Design

Introduction to Formal Languages, Automata and Computability p.1/42

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

Nondeterminism and Epsilon Transitions

Finite Automata and Languages

CMSC 330: Organization of Programming Languages

Some useful tasks involving language. Finite-State Machines and Regular Languages. More useful tasks involving language. Regular expressions

CSC173 Workshop: 13 Sept. Notes

Finite State Machine. By : Ali Mustafa

Finite Automata. Dr. Neil T. Dantam. Fall CSCI-561, Colorado School of Mines. Dantam (Mines CSCI-561) Finite Automata Fall / 35

Chapter 2: Finite Automata

Transcription:

Finite-state machines (FSMs) Dr. C. Constantinides Department of Computer Science and Software Engineering Concordia University Montreal, Canada January 10, 2017 1/19

Finite-state machines (FSMs) and state diagrams A finite-state machine (FSM), or state machine, or automaton (plural: automata), or finite-state automaton is a mathematical structure used to provide an abstract description of the behavior of a system. An FSM can model computational problems such as program design, and sequential logic circuits. 2/19

Example: An FSM to determine an even number of 1 s in a binary string Consider the finite-state machine that is used to determine whether or not a binary string contains an even number of 1 s. The machine responds to inputs. Each step in a computation is called a state. In its initial state, the machine reads the first symbol of an input string, followed by the next symbol etc. until there are no more input symbols. After each reading, the machine performs a transition to some state and possibly produces some output. 3/19

Example: An FSM to determine an even number of 1 s in a binary string /cont. The response of the machine to a given sequence of inputs is completely predictable. We say that the machine is deterministic. There is a finite number of states that the machine can attain. At any given moment the machine is in exactly one of these states. As each state depends on the previous state and the inputs, we say that the machine maintains a memory of past inputs. After having read the entire input string, the machine stops. 4/19

Example: An FSM to determine an even number of 1 s in a binary string /cont. The behavior of the FSM can be graphically represented by a state diagram: a directed graph, where the set of nodes, denoted as circles, defines the set of states (including initial and final states, where the latter is denoted as a double circle), and the set of edges defines the set of transitions. The arrow without a source node points to the initial state, S 1. 0 0 1 S 1 S 2 1 5/19

Example: An FSM to determine an even number of 1 s in a binary string /cont. Let the input string to the machine be 011. First, the machine will read 0 and it will perform a transition back to S 1. The machine will then read 1 and it will perform a transition to state S 2. Next the machine will read 1 and it will perform a transition to S 1. We see that upon having read the entire binary string, the machine is at the final state. We say that this particular input has been accepted by the FSM. 0 0 1 S 1 S 2 1 6/19

Example: An FSM to determine an even number of 1 s in a binary string /cont. The machine can also be represented by a state-transition table (or state table). The table shows what state (or states in the case of a nondeterministic finite automaton) an FSM will move to, based on the current state and other inputs. The machine begins at state s 1. If the first symbol is a 0, then the machine stays in state s 1, otherwise if the first symbol is a 1 then the next state of the machine is s 2. Current state 0 1 s 1 s 1 s 2 s 2 s 2 s 1 7/19

Example: An FSM to determine an even number of 1 s in a binary string /cont. For the input 011, we can perform an analysis of the state transition table and produce the following: Time t 0 t 1 t 2 Input 0 1 1 State s 1 s 2 s 1 8/19

Formal definition of finite-state machines Formally, a finite state machine is defined as a 5-tuple (read: quintuple ) as follows: (Q,q 0,F,Σ,δ) where 1. Q is a finite, non-empty set of states. 2. q 0 Q is the initial state (or start state). 3. F Q is a set of final states. 4. Σ is a finite, non-empty set of symbols, called the input alphabet. 5. δ is a state transition function: δ : Q Σ q Q. This function defines a deterministic finite state machine as opposed to a nondeterministic finite state machine whose state transition function returns a set of states. 9/19

Classification The following are subdivisions of finite state machines: Acceptors (also: recognizers, or sequence detectors) process all input and then produce a binary output (Yes/No) based on whether or not the input is accepted, i.e. if the current state is an accepting state. Transducers generate output based on a given input and/or a state using actions. In the Moore machine, the output depends solely on the state, whereas in the Mealy machine, the output depends on both input and state. An FSM can model the behavior of any type of entity in terms of its life-cycle and this behavior is captured by a traversal of the state diagram. 10/19

Example: An acceptor for strings ending in ab Consider a machine that can accept any binary string that ends in ab, such as ab, bab, baab, bbbaab, etc. What does it mean to execute an acceptor FSM over an input alphabet Σ? Given an FSM and a string w Power(Σ), the FSM accepts each one of the letters of w as input (from left to right) following a path starting from the start state. 11/19

Example: An acceptor for strings ending in ab /cont. Each letter causes a state transition from the start state to the next and so forth. If this path eventually ends in the final state, then we say that the FSM accepts w. Otherwise we say that the FSM rejects w. The language of an FSM is the set of all strings that it accepts. 12/19

Example: An acceptor for strings ending in ab /cont. A state transition table for the FSM of this example is shown below. Current state a b q 0 q 1 q 2 q 1 q 1 q 0 q 2 q 1 q 2 13/19

Example: An acceptor for strings ending in ab /cont. In this example, it just so happens that this is also the final state. Each bit input causes a transition either to the same state or to another state. For example, for the input string ab, we start at state q 0 and read the first bit, a, which will cause a transition to state q 1. While at state q 1 the FSM will then read b and perform a transition to state q 0. As the input string has been read and the FSM is currently at its final state, we say that the input string ab has been accepted by the FSM. 14/19

Example: An acceptor for strings ending in ab /cont. Consider an input string abb. From the initial state q 0 the FSM will read a and perform a transition to state q 1. While at state q 1 it will read b and perform a transition to state q 0. While at state q 0 it will then read b which is the final symbol in the input string and perform a transition to state q 2. As the input string has been read and the FSM is currently not at its final state, we say that the input string abb has been rejected by the FSM. 15/19

Example: An acceptor for strings ending in ab /cont. The state diagram of the FSM that can accept any binary string that ends in ab is shown below: b q 2 b a a q 0 q 1 b a 16/19

Example: An acceptor for strings ending in aab Suppose we need to build a deterministic FSM to recognize strings that end in aab such as aab, aaaab, babaab, bbabaab, aababaab, etc. 17/19

Example: An acceptor for strings ending in aab /cont. The state-transition table is shown below: Current state a b q 0 q 1 q 0 q 1 q 2 q 0 q 2 q 2 q 3 q 3 q 1 q 0 18/19

Example: An acceptor for strings ending in aab /cont. The state diagram of the FSM to recognize strings that end in aab is shown below: b a a a b q 0 q 1 q 2 q 3 b a b 19/19