Finite Automata Motivation An Example.

Slides:



Advertisements
Similar presentations
Regular Expressions and DFAs COP 3402 (Summer 2014)
Advertisements

1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
Representation Application and Examples
Graphs Graphs are the most general data structures we will study in this course. A graph is a more general version of connected nodes than the tree. Both.
Introduction to Computability Theory
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.
CSE115/ENGR160 Discrete Mathematics 03/03/11 Ming-Hsuan Yang UC Merced 1.
1 Finite Automata. 2 Finite Automaton Input “Accept” or “Reject” String Finite Automaton Output.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 1 Regular Languages Contents Finite Automata (FA or DFA) definitions, examples,
1 Foundations of Software Design Lecture 23: Finite Automata and Context-Free Grammars Marti Hearst Fall 2002.
1 Intro to Finite Automata Chapter 2 introduces the concept of a Finite Automata (or FA). An FA has several properties: It is theoretical. It allows computer.
Finite Automata Motivation An Example.
CS 503 Spring semester 2015 WPI Most of the slides below are due to Jeffrey Ullman (one of our textbok’s authors). They are slides from a course he gave.
Introduction to Finite Automata Adapted from the slides of Stanford CS154.
Regular Expressions and Automata Chapter 2. Regular Expressions Standard notation for characterizing text sequences Used in all kinds of text processing.
Finite State Machines Data Structures and Algorithms for Information Processing 1.
What Are They? Who Needs ‘em? An Example: Scoring in Tennis Finite Automata 11.
1 Introduction to Parsing Lecture 5. 2 Outline Regular languages revisited Parser overview Context-free grammars (CFG’s) Derivations.
Functions Definition & purpose Notation Functions on binary / returning binary values Finite automaton model We haven’t completely left the world of counting.
Lecture 03: Theory of Automata:08 Finite Automata.
Week 5 - Wednesday.  What did we talk about last time?  Exam 1!  And before that?  Review!  And before that?  if and switch statements.
Lecture 07: Formal Methods in SE Finite Automata Lecture # 07 Qaisar Javaid Assistant Professor.
Theory of Computation - Lecture 3 Regular Languages What is a computer? Complicated, we need idealized computer for managing mathematical theories... Hence:
Lecture 1 Computation and Languages CS311 Fall 2012.
1 Computability Five lectures. Slides available from my web page There is some formality, but it is gentle,
1 © 2014 B. Wilkinson Modification date: Dec Sequential Logic Circuits Previously, we described the basic building blocks of sequential circuits,
TRANSITION DIAGRAM BASED LEXICAL ANALYZER and FINITE AUTOMATA Class date : 12 August, 2013 Prepared by : Karimgailiu R Panmei Roll no. : 11CS10020 GROUP.
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.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
Copyright © Curt Hill Finite State Machines The Simplest and Least Capable Automaton.
SM2220 – Class 06 Finite Automata. SM2220 – Class 06 Topic in theoretical computing. A subset of computation machines. Closely related to formal language.
Chapter 3 Regular Expressions, Nondeterminism, and Kleene’s Theorem Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction.
CSC3315 (Spring 2009)1 CSC 3315 Lexical and Syntax Analysis Hamid Harroud School of Science and Engineering, Akhawayn University
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Sahar Mosleh California State University San MarcosPage 1 Finite State Machine.
Lecture 04: Theory of Automata:08 Transition Graphs.
Deterministic Finite Automata
Overview of Previous Lesson(s) Over View  A token is a pair consisting of a token name and an optional attribute value.  A pattern is a description.
Data Link Layer. Data link layer The communication between two machines that can directly communicate with each other. Basic property – If bit A is sent.
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture 1 Ahmed Ezzat.
LECTURE 5 Scanning. SYNTAX ANALYSIS We know from our previous lectures that the process of verifying the syntax of the program is performed in two stages:
Introduction to Exceptions in Java CS201, SW Development Methods.
Lecture #4 Thinking of designing an abstract machine acts as finite automata. Advanced Computation Theory.
Theory of Computation Automata Theory Dr. Ayman Srour.
General Discussion of “Properties” The Pumping Lemma Membership, Emptiness, Etc.
Department of Software & Media Technology
CSE15 Discrete Mathematics 03/06/17
Chapter 4 Introduction to Set Theory
Finite Automata.
CSE 105 theory of computation
Finite State Machines Dr K R Bond 2009
Table-driven parsing Parsing performed by a finite state machine.
Copyright © Cengage Learning. All rights reserved.
CSc 453 Lexical Analysis (Scanning)
Finite Automata a b A simplest computational model
What Are They? Who Needs ‘em? An Example: Scoring in Tennis
Chapter 2 FINITE AUTOMATA.
Finite Automata Motivation Examples.
Theory of Computation Languages.
What Are They? Who Needs ‘em? An Example: Scoring in Tennis
Finite Automata.
Guest Lecture by David Johnston
State Machines 6-Apr-196-Apr-19.
ECE 352 Digital System Fundamentals
Finite Automata with Output
State Machines 8-May-19.
State Machines 16-May-19.
Lecture 5 Scanning.
Turing Machines Everything is an Integer
CSc 453 Lexical Analysis (Scanning)
Presentation transcript:

Finite Automata Motivation An Example

Informal Explanation Finite automata are finite collections of states with transition rules that take you from one state to another. Original application was sequential switching circuits, where the “state” was the settings of internal bits. Today, several kinds of software can be modeled by FA.

Representing FA Simplest representation is often a graph. Nodes = states. Arcs indicate state transitions. Labels on arcs tell what causes the transition.

Example: Recognizing Strings Ending in “ing” Saw ing g i Not i or g Saw i i Not i Saw in n i Not i or n nothing Start

Automata to Code In C/C++, make a piece of code for each state. This code: Reads the next input. Decides on the next state. Jumps to the beginning of the code for that state.

Example: Automata to Code 2: /* i seen */ c = getNextInput(); if (c == ’n’) goto 3; else if (c == ’i’) goto 2; else goto 1; 3: /* ”in” seen */ . . .

Automata to Code – Thoughts How would you do this in Java, which has no goto? You don’t really write code like this. Rather, a code generator takes a “regular expression” describing the pattern(s) you are looking for. Example: .*ing works in grep.

Example: Protocol for Sending Data timeout data in Ready Sending Start ack

Extended Example Thanks to Jay Misra for this example. On a distant planet, there are three species, a, b, and c. Any two different species can mate. If they do: The participants die. Two children of the third species are born.

Strange Planet – (2) Observation: the number of individuals never changes. The planet fails if at some point all individuals are of the same species. Then, no more breeding can take place. State = sequence of three integers – the numbers of individuals of species a, b, and c.

Strange Planet – Questions In a given state, must the planet eventually fail? In a given state, is it possible for the planet to fail, if the wrong breeding choices are made?

Questions – (2) These questions mirror real ones about protocols. “Can the planet fail?” is like asking whether a protocol can enter some undesired or error state. “Must the planet fail” is like asking whether a protocol is guaranteed to terminate. Here, “failure” is really the good condition of termination.

Strange Planet – Transitions An a-event occurs when individuals of species b and c breed and are replaced by two a’s. Analogously: b-events and c-events. Represent these by symbols a, b, and c, respectively.

Strange Planet with 2 Individuals 200 020 002 a b c 011 101 110 Notice: all states are “must-fail” states.

Strange Planet with 3 Individuals 111 a c b 300 030 003 a a 210 102 021 201 120 012 c b b c Notice: four states are “must-fail” states. The others are “can’t-fail” states. State 111 has several transitions.

Strange Planet with 4 Individuals 400 022 130 103 211 a c b 040 202 013 310 121 b a c 004 220 301 031 112 c b a Notice: states 400, etc. are must-fail states. All other states are “might-fail” states.

Taking Advantage of Symmetry The ability to fail depends only on the set of numbers of the three species, not on which species has which number. Let’s represent states by the list of counts, sorted by largest-first. Only one transition symbol, x.

The Cases 2, 3, 4 x 211 400 110 111 x x x x 200 300 310 x 210 220 x Notice: for the case n = 4, there is nondeterminism : different transitions are possible from 211 on the same input.

5 Individuals 500 410 221 320 311 Notice: 500 is a must-fail state; all others are might-fail states.

6 Individuals 600 510 222 420 321 411 330 Notice: 600 is a must-fail state; 510, 420, and 321 are can’t-fail states; 411, 330, and 222 are “might-fail” states.

7 Individuals 700 322 610 331 520 421 511 430 Notice: 700 is a must-fail state; All others are might-fail states.

Questions for Thought Without symmetry, how many states are there with n individuals? What if we use symmetry? For n individuals, how do you tell whether a state is “must-fail,” “might-fail,” or “can’t-fail”?