Copyright © 2014 - Curt Hill Finite State Automata Again This Time No Output.

Slides:



Advertisements
Similar presentations
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Advertisements

Finite-State Machines with No Output Ying Lu
Finite State Machines Finite state machines with output
CSC 361NFA vs. DFA1. CSC 361NFA vs. DFA2 NFAs vs. DFAs NFAs can be constructed from DFAs using transitions: Called NFA- Suppose M 1 accepts L 1, M 2 accepts.
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
January 7, 2015CS21 Lecture 21 CS21 Decidability and Tractability Lecture 2 January 7, 2015.
Chapter Section Section Summary Set of Strings Finite-State Automata Language Recognition by Finite-State Machines Designing Finite-State.
Equivalence, DFA, NDFA Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 2 Updated and modified by.
Finite Automata Finite-state machine with no output. FA consists of States, Transitions between states FA is a 5-tuple Example! A string x is recognized.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
Fall 2005 CSE 467/567 1 Formal languages regular expressions regular languages finite state machines.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
PZ02B Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ02B - Regular grammars Programming Language Design.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { ‘{‘, ‘}’ } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite language,
Rosen 5th ed., ch. 11 Ref: Wikipedia
Language Recognizer Connecting Type 3 languages and Finite State Automata Copyright © – Curt Hill.
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.
Finite-State Machines with No Output
CMPS 3223 Theory of Computation
PZ02B Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ02B - Regular grammars Programming Language Design.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2006.
Copyright © Curt Hill Languages and Grammars This is not English Class. But there is a resemblance.
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.
Regular Grammars Chapter 7 1. Regular Grammars A regular grammar G is a quadruple (V, , R, S), where: ● V is the rule alphabet, which contains nonterminals.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
Regular Expressions and Languages A regular expression is a notation to represent languages, i.e. a set of strings, where the set is either finite or contains.
Regular Expressions Chapter 6 1. Regular Languages Regular Language Regular Expression Finite State Machine L Accepts 2.
Copyright © Curt Hill Finite State Machines The Simplest and Least Capable Automaton.
Overview of Previous Lesson(s) Over View  Symbol tables are data structures that are used by compilers to hold information about source-program constructs.
CS 3813: Introduction to Formal Languages and Automata Chapter 2 Deterministic finite automata These class notes are based on material from our textbook,
Brian Mitchell - Drexel University MCS680-FCS 1 Patterns, Automata & Regular Expressions int MSTWeight(int graph[][], int size)
Regular Expressions Chapter 6. Regular Languages Regular Language Regular Expression Finite State Machine L Accepts.
Chapter 3 Regular Expressions, Nondeterminism, and Kleene’s Theorem Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction.
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Finite State Machines 1.Finite state machines with output 2.Finite state machines with no output 3.DFA 4.NDFA.
Modeling Computation: Finite State Machines without Output
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2007.
Mathematical Foundations of Computer Science Chapter 3: Regular Languages and Regular Grammars.
using Deterministic Finite Automata & Nondeterministic Finite Automata
1 Language Recognition (11.4) Longin Jan Latecki Temple University Based on slides by Costas Busch from the courseCostas Busch
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Conversions Regular Expression to FA FA to Regular Expression.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2006.
Deterministic Finite Automata Nondeterministic Finite Automata.
Non Deterministic Automata
Regular grammars Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
FORMAL LANGUAGES AND AUTOMATA THEORY
Chapter 2 Finite Automata
Jaya Krishna, M.Tech, Assistant Professor
Equivalence, DFA, NDFA Sequential Machine Theory Prof. K. J. Hintz
Language Recognition (12.4)
REGULAR LANGUAGES AND REGULAR GRAMMARS
Hierarchy of languages
Some slides by Elsa L Gunter, NJIT, and by Costas Busch
Chapter 7 Regular Grammars
Non Deterministic Automata
Chapter Five: Nondeterministic Finite Automata
Language Recognition (12.4)
Regular grammars Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Chapter 1 Regular Language
Finite-State Machines with No Output
NFAs and Transition Graphs
Regular grammars Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
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.
Presentation transcript:

Copyright © Curt Hill Finite State Automata Again This Time No Output

Copyright © Curt Hill Recall… We last considered FSA Each has An input alphabet A finite number of states State transition function Output function Initial node They are often represented as –Graphs with nodes and arcs –State charts Now we are considering FSA without output

What is new? Now our FSMs do not produce output, so we do not need the Output function What we add instead is the requirement of a final node To be legal input we must start at an initial state and end at a final state Thus their output is based on final state –Legal or illegal Copyright © Curt Hill

Why? FSA with output are usually used to model a simple machine and display intermediate results –These intermediate results may be all we are interested in The no output FSA are usually language recognizers –Does the input string conform to some predefined rule or not Copyright © Curt Hill

Definition An output-less finite state machine is 5 tuple M=(S,I,f,s 0, F) S is a set of states I is the set of inputs f is the transition function s 0 is the initial state, s 0  S F is the set of final states, F  S Copyright © Curt Hill

Error States There are two possible errors that can occur with these If the state does not allow for this particular input this puts the machine in an error state –The book does not allow this one yet If the machine does not end in a designated final state this is also an error –There may be multiple final states Copyright © Curt Hill

Exercise Recall the FSM from previous presentation that we saw –I will show again on next slide Lets assume that the initial and terminal state is s0 Find three strings that this automaton accepts What is shortest string it may accept? What is the longest string it may accept? Copyright © Curt Hill

Exercise Copyright © Curt Hill s0 s1 s2 a b b a a b s0 s1 s2 ba s0 s1 s2

Which are not legal? Copyright © Curt Hill s0 s1 s2 a b b a a b s0 s1 s2 ba s0 s1 s2 aaabb bbaa abaab bababba abababa bbbbabab

Strings These FSA are language recognizers –That is, given an input string they pronounce it legal or illegal based on the state on which they stopped I* is the set of all strings, whose characters are composed solely from the input alphabet, I The language they accept is a subset of the set of all possible strings, I* Copyright © Curt Hill

Definitions Suppose we have two sets of strings A,B both of which are subsets of I* The concatenation of A and B is AB –This is the set of every element of A concatenated with each element of B –Something like a Cartesian product but we end up with strings rather than ordered pairs Copyright © Curt Hill

Example Suppose that A = {0, 1} and B={a,b,c} AB = {0a, 0b, 0c, 1a, 1b, 1c} BA = {a0, a1, b0, b1, c0, c1} AA = {00,01,10,11} BB = {aa, ab, ac, ba, bb, bc, ca, cb, cc} Copyright © Curt Hill

Kleene Closure Copyright © Curt Hill

Example Suppose that A={0,1}, B={a,b,c} A* = {0,1,00,01,10,11,000,001,…} –This is the set of all bit strings B* = {a,b,c,aa,ab,ac,ba,bb,bc,…} –This is the set of all strings composed of the three letters abc If C = {ab} what is C*? Copyright © Curt Hill

Language Recognition Each FSM with starting and final states recognizes a language –A type 3 grammar to be exact If the machine ends on a final state the string is correct –If not the string is not in the language If this machine is denoted by M then the language is denoted by L(M) Copyright © Curt Hill

Example Suppose that S 0 is the start state and S 1 and S 3 are final states What language does this accept? What productions? Copyright © Curt Hill S0S0 S1S1 0 S2S S3S3 0,1

Other Way Can we construct a DFM that recognizes all bit strings where there are not two successive ones? Copyright © Curt Hill

Result What we want is a DFM with node that is obtained with a one but only accepts zeros from there Start is S 0 and final is S 1 and S 2 Copyright © Curt Hill S0S0 S1S1 1 S2S S3S3 0,1 1 0

Determinism All the FSMs we have looked at are deterministic –For each pair of state and input there is a unique new state The alternative is a non- deterministic finite state automaton –For any state-input pair there may be zero or more states A NDFA accepts a string if any choice of transitions accepts the string Copyright © Curt Hill

Example State S 0 is the start state and S 1 is the final state –S 0 has no two 1 transitions –S 1 has no transitions –S 2 has two 1 transitions –S 3 has no 1 transition Copyright © Curt Hill S0S0 S1S1 0,1 S2S S3S3 1 0

Commentary The understanding problem is the states that have multiple transitions or no transitions A NDFA can be viewed in several ways: –If any of the alternatives work the machine accepts the language –Multiple alternatives are pursued concurrently –Failed alternatives do not matter as long as one works Copyright © Curt Hill

NDFA Non-Deterministic Finite Automata are useful in variety of theoretical contexts Often easier to define a NDFA for a language Many proofs are easier with NDFA Closures are also easier to compute Copyright © Curt Hill

Example Suppose that S 0 is the start state and S 1 is the final state What language does this accept? What productions? What errors are possible Copyright © Curt Hill S0S0 S1S1 1 S2S2 0 0,1

Equivalence Although NDFA have more flexibility than DFA the two have equivalent strength in regards to language recognition In particular for any NDFA and equivalent DFA may be constructed How is this done? –It is called the Powerset or subset construction Copyright © Curt Hill

Construction Suppose we have a NDFA, N Converting it to a DFA, D, will have several characteristics The worst case is that if the N has n nodes then D will have 2 n nodes Each node in D will be labeled by a subset of the nodes from N Copyright © Curt Hill

Building the States Add {s 0 } to S D – this is the start node While there are still states to be defined –Choose s in S D –For each a in the alphabet determine the set of states that are reachable from q on input a If there is no state in S D representing the above add it Define a new state corresponding to this Define f D as any state in S D that corresponds to a subset containing any final state in N Copyright © Curt Hill

Easy Example There are two states that have incomplete specification, S 0 and S 1 All we need to do is generate an error state that captures Copyright © Curt Hill S0S0 S1S1 1 S2S2 0 0,1

Easy Example Copyright © Curt Hill S0S0 S1S1 1 S2S2 0 0,1 S0S0 S1S1 1 S2S2 0 Becomes: S err 0 1 0,1 Does not matter if we have 1 or 2 error states

Harder Copyright © Curt Hill S0S0 S1S1 0,1 S2S No missing transitions, but two 1’s coming from S 0 State S 0 is start, S 1 is final

Harder Copyright © Curt Hill S0S0 S1S1 0,1 S2S S0S0 S1S1 0 S2S2 1 1 S3S3 S err 0,1 S3S Six states and three final states. S 1 and S 3 could have been merged

Exercises 13.3 –1, 5, 9, 13, 17, 21, 45 Copyright © Curt Hill