Finite State Machines 2

Similar documents
COM364 Automata Theory Lecture Note 2 - Nondeterminism

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

Finite Automata. Mahesh Viswanathan

Fooling Sets and. Lecture 5

CSE 105 THEORY OF COMPUTATION

Equivalence of Regular Expressions and FSMs

Finite-State Machines (Automata) lecture 12

Embedded systems specification and design

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

CSC236 Week 11. Larry Zhang

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Nondeterministic finite automata

Finite-state machines (FSMs)

Finite Automata. Finite Automata

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

Inf2A: Converting from NFAs to DFAs and Closure Properties

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

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

Author: Vivek Kulkarni ( )

Deterministic Finite Automata

1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u,

September 7, Formal Definition of a Nondeterministic Finite Automaton

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

CS 154, Lecture 3: DFA NFA, Regular Expressions

Nondeterminism. September 7, Nondeterminism

Nondeterministic Finite Automata

NFA and regex. the Boolean algebra of languages. regular expressions. Informatics 1 School of Informatics, University of Edinburgh

Theory of Computation

CS21 Decidability and Tractability

Deterministic Finite Automata

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

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

Lecture 3: Nondeterministic Finite Automata

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

Lecture 4: More on Regexps, Non-Regular Languages

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

(Refer Slide Time: 0:21)

Turing machines and linear bounded automata

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

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Further discussion of Turing machines

Announcements. Problem Set 6 due next Monday, February 25, at 12:50PM. Midterm graded, will be returned at end of lecture.

Automata: a short introduction

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

Languages, regular languages, finite automata

Automata Theory CS S-12 Turing Machine Modifications

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

Chapter 3: Polynomial and Rational Functions

CSCC63 Worksheet Turing Machines

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM)

Turing machines and linear bounded automata

Chapter Two: Finite Automata

Computability and Complexity

Turing machines COMS Ashley Montanaro 21 March Department of Computer Science, University of Bristol Bristol, UK

CSE 105 THEORY OF COMPUTATION

Constructions on Finite Automata

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

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

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

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

Proving languages to be nonregular

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

Theory of Computation

Finite Automata. Seungjin Choi

How do regular expressions work? CMSC 330: Organization of Programming Languages

Automata-based Verification - III

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

BASIC STRUCTURE OF MACHINES


CS4026 Formal Models of Computation

Equivalence of TMs and Multitape TMs. Theorem 3.13 and Corollary 3.15 By: Joseph Lauman

Formal Definition of Computation. August 28, 2013

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

Lecture Notes: The Halting Problem; Reductions

Uses of finite automata

Chapter Five: Nondeterministic Finite Automata

CSE 311: Foundations of Computing. Lecture 25: Pattern Matching, DFA NFA Regex Languages vs Representations

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

Deterministic Finite Automata (DFAs)

Turing Machine Variants

Introduction to Computers & Programming

Theory of Computation Lecture 1. Dr. Nahla Belal

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

CS 154 Introduction to Automata and Complexity Theory

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

UNIT-I. Strings, Alphabets, Language and Operations

Takeaway Notes: Finite State Automata

Deterministic Finite Automata (DFAs)

Nondeterministic Finite Automata

CS21 Decidability and Tractability

CSE 105 THEORY OF COMPUTATION

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

CSCI 2670 Introduction to Theory of Computing

Deterministic Finite Automata (DFAs)

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

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

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

Transcription:

Finite State Machines 2 Joseph Spring School of Computer Science 1COM0044 Foundations of Computation 1

Discussion Points In the last lecture we looked at: 1. Abstract Machines 2. Finite State Machines Informal 1. Components of an FSM 2. State Transition Diagrams 3. A Simple FSM 4. FSM s and Loops 5. FSM s and Multiple Transitions 6. FSM s and Traps / Multiple Loops 2

Recall We are interested in the interaction between languages and machines The machines we work with are abstract machines they eist as abstract models of real world machines. So we are involved in modelling and the modelling process The machines we eplore (finite state machines) are sometimes referred to as finite state automata 3

Informal FSM s: We saw that: There is a special relationship between any FSM and the largest language that it recognises. Any given FSM will recognise a particular language (and any languages which are subsets of this of course). We noted that as language acceptors If two machines recognise the same language, then there is no difference between them they were considered equivalent. They have the same behaviour (even though they may look different). 4

For eample: a 2 c 1 c 3 5 b 4 c Machine 1: A Simple FSM This accepts the language L 1 = {acc, bcc} 5

And: a, b 1 2 c 3 c 4 Machine 4: A FSM with Multiple Transitions between States This accepts the language L 4 = {acc, bcc} As Language Acceptors Machines 1 & 4 are equivalent 6

Informal FSM s: We also noted that: We can think of the machine as recognising a string from the language OR we can think of the strings a programs that control the machine. If we assume that we can see what states we are in the machines respond to the program by eecuting the strings (provided we give valid strings!!). 7

Discussion Points In this lecture we consider: 1. Informal FSM s 1. Equivalent FSM s 2. FSM s and Computation 2. Formal FSM s 1. Definitions 8

1.1 Equivalent FSM s Consider the formal language L 6 = {ca, cb} One machine that we could use is: c a, b 1 2 3 Machine 6 9

1.1 Equivalent FSM s Another machine that we could use for L 6 = {ca, cb} Machine 6a c 1 2 b a 4 3 10

1.1 An Alternative View As language acceptors Machines 6 and 6a are equivalent However there is another way of viewing the machines which makes more eplicit their potential for computation they embody some notion of memory which creates a distinction between machines 6 and 6a Machine 6 remembers less than machine 6a 11

1.1 An Alternative View To see this consider As a language acceptor all that we require is some indication (lets say a light) to tell us that the machine has stopped in a final accepting state Light on string accepted as part of language Light off string NOT accepted as part of language However If we are also interested in which string was presented ca or cb then machine 6 cannot distinguish between which of a or b affected the transition from state 2 to state 3 Machine 6a on the other hand could have a light on each of states 3 and 4 and could thus indicate which string was accepted. In this sense Machine 6a is able to remember more than machine 6 12

1.1 An Alternative View The machines Are finite Can only remember a finite number of things The number being determined by the design of the machine Can recognise infinite languages Via loops Loops do not track of the number of times that they have been used Machine 3 for eample accepts abc, abcabc, but does not distinguish between which string has been used 13

1.1 An Alternative View L 3 = {abc, abcabc, abcabcabc, } a 2 b 1 a 3 b 4 c Machine 3: An FSM with Larger Loops 14

1.2 FSM s & Computation The above observation gives us an insight into how we could use FSM s for direct computation 1 0 2 3 15

1.2 FSM s & Computation We note State 1 is obtained using strings,,,, 1, 5, 9, 13,17, 21, 25, State 2 is obtained using strings,,,, 2, 6, 10, 14,18, 22, 26, State 3 is obtained using strings,,,, 3, 7, 11, 15,19, 23, 27, State 4 is obtained using strings,,,, 4, 8, 12, 16,20, 24, 28, This machine can be used to find remainders when dividing positive integers by 4 16

1.2 FSM s & Computation 1 0 2 3 A Simple Remainder Calculating Machine 17

1.2 FSM s & Computation What about this machine? n n n n S 0 1 0 2 0 3 0 4 1 4 3 4 1 2 1 3 2 3 2 4 18

1.2 FSM s & Computation What about this machine? n n n n S 0 1 0 2 0 3 0 4 1 4 3 4 1 2 1 3 2 3 A More General Remainder Calculating Machine 2 4 19

1.2 FSM s & Computation Let Strings of the form nnn denote a number (divisor) Strings of the form denote another number (dividend) Then We may interpret nnn as 5 divided by 3 Giving a remainder 2 which provided we label our states as in the previous machine is given by the previous machine Note that we have had to denote the states very carefully: we could not simply label all of our remainder-2 states with a 2, or we would have interfered with the machines memory as to what number was being divided by. 20

1.2 FSM s & Computation Note The previous eample illustrates the point that we need to be very careful regarding the representations we use for, for eample numbers 21

2.1 Formal FSM s - Definition The formal definition of a deterministic Finite State Automaton is given in terms of five components: 1. Q is a finite set of states. 2. T is a finite input alphabet. 3. t is a partial function: Q T Q. This function is called the transition function because it defines what state the FSM moves to from a given state when a given symbol from the input alphabet is received. 4. q 0 ε Q is a designated start state. 5. F Q is a set of final accepting states. Any number of states in Q can be designated as final accepting states. 22

2.1 Formal FSM s - Definition For Machine 1 we have: Q = {1, 2, 3, 4, 5} T = {a, b, c} t = {(1,a) 2, (1,b) 4, (2,c) 3, (3,c) 5, (4,c) 3} q 0 = 1 F = {5} What of machines 2 and 5 and? 23

2.1 Formal FSM s - Definition a 2 c 1 c 3 5 b 4 c Machine 1: A Simple FSM This accepts the language L 1 = {acc, bcc} 24

2.2 Transition Functions in Tabulated Form We can equally well draw the transition functions in tabulated form: Current State M1 transition 1 2 3 4 a 2 b 4 c 3 5 3 25

Summary In this lecture we consider: 1. Informal FSM s 1. Equivalent FSM s 2. FSM s and Computation 2. Formal FSM s 1. Definitions 2. Transition Functions in Tabulated Form 26