Finite State Machines Part I

Slides:



Advertisements
Similar presentations
Finite-State Machines with No Output Ying Lu
Advertisements

Counters. In class excercise How to implement a “counter”, which will count as 0,3,1,4,5,7,0,3,1,…… Q2Q1Q0D2D1D
YES-NO machines Finite State Automata as language recognizers.
Chapter Two: Finite Automata
CS5371 Theory of Computation
14-Jun-15 State Machines. 2 What is a state machine? A state machine is a different way of thinking about computation A state machine has some number.
CS 310 – Fall 2006 Pacific University CS310 Finite Automata Sections: September 1, 2006.
25-Jun-15 State Machines. 2 What is a state machine? A state machine is a different way of thinking about computation A state machine has some number.
Turing Machines CS 105: Introduction to Computer Science.
Rosen 5th ed., ch. 11 Ref: Wikipedia
CPSC 388 – Compiler Design and Construction Scanners – Finite State Automata.
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.
Lecture 03: Theory of Automata:08 Finite Automata.
CMPS 3223 Theory of Computation
Lecture 23: Finite State Machines with no Outputs Acceptors & Recognizers.
Lecture 07: Formal Methods in SE Finite Automata Lecture # 07 Qaisar Javaid Assistant Professor.
Automata, Computability, & Complexity by Elaine Rich ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slides provided by author Slides edited for.
Lecture 1 Computation and Languages CS311 Fall 2012.
Computabilty Computability Finite State Machine. Regular Languages. Homework: Finish Craps. Next Week: On your own: videos +
Counters. In class excercise How to implement a “counter”, which will count as 0,3,1,4,5,7,0,3,1,…… Q2Q1Q0D2D1D
13-Nov-1513-Nov-1513-Nov-15 State Machines. What is a state machine? A state machine is a different way of thinking about computation A state machine.
Copyright © Curt Hill Finite State Machines The Simplest and Least Capable Automaton.
CS1Q Computer Systems Lecture 11 Simon Gay. Lecture 11CS1Q Computer Systems - Simon Gay 2 The D FlipFlop The RS flipflop stores one bit of information.
Formal Definition of Computation Let M = (Q, ∑, δ, q 0, F) be a finite automaton and let w = w 1 w w n be a string where each wi is a member of the.
Computing Machinery Chapter 4: Finite State Machines.
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.
Language Translation Part 2: Finite State Machines.
Lecture 22: Finite State Machines with Output. Moore Machine - A Moore machine is a 6-tuple (Q, , , , q 0,  ) where, (1) Q is a finite set of states.
Akram Salah ISSR Basic Concepts Languages Grammar Automata (Automaton)
Mealy Machines Finite State Machines with Outputs given on the transitions.
MA/CSSE 474 Theory of Computation Regular Expressions Intro.
  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.
Department of Software & Media Technology
Lecture Three: Finite Automata Finite Automata, Lecture 3, slide 1 Amjad Ali.
Finite Automata.
Nondeterminism The Chinese University of Hong Kong Fall 2011
CS314 – Section 5 Recitation 2
CS 461 – Nov. 2 Sets Prepare for ATM finite vs. infinite Infinite sets
AS Computer Studies Finite State Machines 1.
Finite automate.
Turing Machines Finite State Machines.
Finite-State Machines (FSMs)
Compilers Welcome to a journey to CS419 Lecture5: Lexical Analysis:
CSE 105 theory of computation
Error Correcting Code.
Finite-State Machines (FSMs)
Deterministic Finite Automata
What Are They? Who Needs ‘em? An Example: Scoring in Tennis
Deterministic Finite Automata
Undecidable Problems (unsolvable problems)
Some slides by Elsa L Gunter, NJIT, and by Costas Busch
Chapter Two: Finite Automata
Theory of Computation Turing Machines.
What Are They? Who Needs ‘em? An Example: Scoring in Tennis
Finite State Machines.
4b Lexical analysis Finite Automata
State Machines 6-Apr-196-Apr-19.
Counters.
Recap lecture 19 NFA corresponding to Closure of FA, Examples, Memory required to recognize a language, Example, Distinguishing one string from another,
State Machines 8-May-19.
EGR 2131 Unit 12 Synchronous Sequential Circuits
State Machines 16-May-19.
Finite Automaton with output
CSE 105 theory of computation
Lecture 5 Scanning.
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.
Nondeterminism The Chinese University of Hong Kong Fall 2010
CSE 105 theory of computation
Presentation transcript:

Finite State Machines Part I State Based Computing

State-based Reasoning The state of a computation is all the internal information needed to take the next step in the computation 0 NEWx -> S 1 previous state next state external input data literal next step (action)

Picobot == state machine each oval represents a different robot state Semantic action ***x/ move S x***/move N N*** state pattern -> move new state start here state 0 state 1 0 x*** -> N 0 0 N*** -> X 1 1 ***x -> S 1 1 ***S -> X 0 the "go North" state the "go South" state ***S transitions move from state to state

All computation can be considered a deliberate sequence of state-changes 0110110101011010010001 0110110101000000001110 bits before bits after

A model of computation: FSM FSM or Finite State Machine Example: 1 s0 s1 1 start state transitions accepting states Don't give the answer of what each state means yet… two slides away! “input funnel” “where to go” double circled labeled by input ! How it runs: 100101 input sequence read left-to-right

Parts of a Finite State Machine (FSM) 1. Must have a finite number of states, i.e., can't be an infinite number. Drawn as circles with label. 2. Must have one starting state designated by 3. Have a non empty subset of the states called final or accepting states designated by double circles. 4. Have transitions of how to change from one state to another state. Drawn as arrows labeled with the input character read. 5. Rule of acceptance: If on reading the last input character the FSM is in a final state, the FSM accepts, otherwise rejects. s0 s1 0,1 s0 s1 FSM accepts all binary strings with at least one 1. 1

0010111 FSM: Finite state machine State 1 State 0 transition on 0 Oh, how I wish we could discuss regex! State 0 – Even number of 1s seen so far State 1 – Odd 1s This accepts sequences of any string with an odd number of 1s another input sequence 0010111 What does each state MEAN ? What does this FSM do overall? always left-to-right

How to Program a FSM? "Count the words in a file" example FSMs great for design of character processing problems Translation to Python program mechanical!

How to Program a FSM? state = 'WS' # start state for FSM words = 0 # action done at start of FSM for line in file1: for ch in line: # FSM-For each character read, depending on character read #and current state, change to new state and do any actions. if state == 'WS': if isWhitespace(ch): state = 'WS' else: state = 'WORD' words += 1 # action elif state == 'WORD': print('Should not be here! Must be programming error!') # End of FSM