Representation Application and Examples

Slides:



Advertisements
Similar presentations
4b Lexical analysis Finite Automata
Advertisements

Theory Of Automata By Dr. MM Alam
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
Finite Automata with Output
CS5371 Theory of Computation
Cohen, Chapter 61 Introduction to Computational Theory Chapter 6.
1 Finite Automata. 2 Finite Automaton Input “Accept” or “Reject” String Finite Automaton Output.
Aho-Corasick String Matching An Efficient String Matching.
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.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
Finite Automata Chapter 5. Formal Language Definitions Why need formal definitions of language –Define a precise, unambiguous and uniform interpretation.
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.
Basic Concepts of Algebra
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
1 Quiz Friday 8-29 Lectures: introduction and methods of proof Text: pp 1-26.
Lecture 03: Theory of Automata:08 Finite Automata.
Pushdown Automata (PDAs)
Lecture 07: Formal Methods in SE Finite Automata Lecture # 07 Qaisar Javaid Assistant Professor.
Lecture 05: Theory of Automata:08 Kleene’s Theorem and NFA.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
Introduction to Finite Automata
Regular Grammars Chapter 7. Regular Grammars A regular grammar G is a quadruple (V, , R, S), where: ● V is the rule alphabet, which contains nonterminals.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
CS 203: Introduction to Formal Languages and Automata
1 Decision Properties of Regular Languages General Discussion of “Properties” The Pumping Lemma Minimizing DFA.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
Lecture 04: Theory of Automata:08 Transition Graphs.
Lecture Notes 
Deterministic Finite Automata
Language Translation Part 2: Finite State Machines.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
1 Chapter Pushdown Automata. 2 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations.
Chapter 2-II Scanning Sung-Dong Kim Dept. of Computer Engineering, Hansung University.
Lecture 09: Theory of Automata:2014 Asif NawazUIIT, PMAS-Arid Agriclture University Rawalpindi. Kleene’s Theorem and NFA.
L ECTURE 3 T HEORY OF AUTOMATA. E QUIVALENT R EGULAR E XPRESSIONS Definition Two regular expressions are said to be equivalent if they generate the same.
Lecture 14: Theory of Automata:2014 Finite Automata with Output.
  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.
General Discussion of “Properties” The Pumping Lemma Membership, Emptiness, Etc.
Topic 3: Automata Theory 1. OutlineOutline Finite state machine, Regular expressions, DFA, NDFA, and their equivalence, Grammars and Chomsky hierarchy.
Finite Automata.
Kleene’s Theorem and NFA
Transition Graphs.
Finite State Machines Dr K R Bond 2009
CSE 105 theory of computation
Table-driven parsing Parsing performed by a finite state machine.
Copyright © Cengage Learning. All rights reserved.
Chapter 7 PUSHDOWN AUTOMATA.
What Are They? Who Needs ‘em? An Example: Scoring in Tennis
Jaya Krishna, M.Tech, Assistant Professor
Chapter 2 FINITE AUTOMATA.
Finite Automata Motivation An Example.
Finite Automata Motivation Examples.
THEORY OF COMPUTATION Lecture One: Automata Theory Automata Theory.
What Are They? Who Needs ‘em? An Example: Scoring in Tennis
NFAs and Transition Graphs
Finite Automata.
4b Lexical analysis Finite Automata
CSE 105 theory of computation
4b Lexical analysis Finite Automata
NFAs and Transition Graphs
CSE 105 theory of computation
OPERATOR GRAMMAR No Ɛ-transition. No two adjacent non-terminals. Eg.
CSE 105 theory of computation
Presentation transcript:

Representation Application and Examples Finite Automata 1 Representation Application and Examples

What are FA? Finite automata are finite collections of states with transition rules that take you from one state to another.

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

FA model of on-off switch push on Start

Protocol for Sending Data Ready Sending data in done timeout Start

FA Recognizing Strings Ending in “ing” Get next character in any state except the finish state Where we go depends on which character empty Saw i i Not i Saw ing g Not i or g Saw in n Not i or n Start Double circle denotes “finish” or “accepting” state String recognized may not be the entire input

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

Code for state “saw i” 2: /* i seen */ c = getNextInput(); if (c == ’n’) goto 3; else if (c == ’i’) goto 2; else goto 1; 3: /* ”in” seen */ . . .

E-commerce example E-commerce requires protocols to prevent fraud Protocols can be modeled by finite automata Example: protocol to ensure that e-money is transferred from customer to merchant on shipped purchases

E-commerce 2 pay cancel cancel 2 1 3 4 start redeem transfer bank customer Pay does not change state of customer. Free to cancel order Bank can go down either cancel path or path that leads to e-money transfer following a redeem request from e-store

E-commerce 3 Store preferred path a->b->c->f->g redeem start b c f e g pay ship transfer store Store preferred path a->b->c->f->g Alternate paths allow ship before transfer complete

This representation is not complete pay cancel a redeem start b c f e g pay ship transfer cancel 2 1 3 4 start redeem transfer All parts must have a defined response to every input even if the response is no change of state.

Each loop labeled by actions that do not change states R start b c f e g P S T C P,C P,C,R,S,T C 2 1 3 4 start R T P,S P,C,R,S P=pay C=cancel R=redeem S=ship T=transfer

Customer is in a “free” state start b c f e g P S T C P,C P,C,S,R,T C 2 1 3 4 start R T P,S P,C,R,S No interactions between store and bank can change customer’s state

Analysis of Store-Bank interactions reveals paths to failure of e-protocols Analysis requires “product” FA with all possible combinations of (store, bank) states and paths that connect them. Will discuss construction of product FAs later in course

Store-Bank product FA Paths exist to state (c,2) that has no exit. Customer cancelled and store shipped before transfer of payment from bank.

Analysis of protocol using FA start b c f e g P S T C P,C P,C,S,R,T C 2 1 3 4 start R T P,S P,C,R,S If customer state is C, then interactions between store and bank can lead to failure

Store-Bank product automaton 3 start b c f e g P S T C P,C Product automaton reveals problem with the protocol. State (c,2) is accessible from (a,1) but only loops back. C 2 1 3 4 start R T P,S P,C,R,S State (c,2) is case where store has shipped before redeeming payment from bank and customer has canceled

Far out 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?

Relationship to Computers These questions mirror real ones about protocols. Planet “failure” is like protocol “termination” We want protocols to terminate “Must the planet fail” is like asking whether a protocol, in its current state, is guaranteed to terminate.

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 002 020 110 101 011 a c b all states are “must-fail” all possible events lead to states where have all same species analogous to “termination” states automata

“Meta-states” are populations of different size 200 020 002 a b c 011 101 110 This analysis of a “meta-state” consist of “exhaustive enumeration”. List all possible species distributions. For each distribution, list all possible transitions.

Strange Planet with 3 Individuals “must-fail” state 111 a c b 300 030 003 a a 210 102 021 201 120 012 c b b c “can’t-fail” states are parts of cycles.

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 “might-fail” states appear Some breeding choices lead to termination Others lead to a cycle

Taking Advantage of Symmetry In exhaustive enumeration of meta-states, we see repeated patterns. Nodes and edges have different labels but topology is same. 200 002 020 110 101 011 a c b

Taking Advantage of Symmetry 2 Outcome (termination) is the same regardless of which species is extinct and which 2 have a single individual. 200 002 020 110 101 011 a c b

Taking Advantage of Symmetry 3 Develop a “prototype” that illustrates states and transitions allowed for populations of various size List species-specific populations in decreasing order Replace specific type of transition (a, b, c) with x prototype 200 002 020 110 101 011 a c b 110 200 x

Prototypes for 2, 3, 4 x 110 200 x 211 400 111 x x x 300 310 x 210 220 x The “might-fail” state of prototype 4 is a nondeterminism. Different transitions are possible from 211 on the same input.

Prototype for meta-state 5 Drop the unnecessary edge label “x” Prototype has standard form of a directed graph Basic graph algorithms can find cycles 410 500 320 311 221 1 must-fail state; 1 can’t fail cycle; 1 might fail state

Strange planet example illustrates 3 types of states you could find in finite automata: must terminate, might terminate and can’t terminate Methods of analysis to find those states: exhaustive enumeration and graph theory