Modeling Computation: Finite State Machines without Output

Slides:



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

Finite State Machines Finite state machines with output
4b Lexical analysis Finite Automata
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
YES-NO machines Finite State Automata as language recognizers.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
Chapter Section Section Summary Set of Strings Finite-State Automata Language Recognition by Finite-State Machines Designing Finite-State.
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
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.
1 Finite Automata. 2 Finite Automaton Input “Accept” or “Reject” String Finite Automaton Output.
1 Languages and Finite Automata or how to talk to machines...
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.
Topics Automata Theory Grammars and Languages Complexities
Nondeterminism (Deterministic) FA required for every state q and every symbol  of the alphabet to have exactly one arrow out of q labeled . What happens.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
Rosen 5th ed., ch. 11 Ref: Wikipedia
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
1 INFO 2950 Prof. Carla Gomes Module Modeling Computation: Language Recognition Rosen, Chapter 12.4.
1 For each language, give a regular expression that generates the language and a DFA that accepts it. L 1 = { w  {0, 1}* : has both 00 and 11 as substrings}
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2006.
1 Course Overview PART I: overview material 1Introduction 2Language processors (tombstone diagrams, bootstrapping) 3Architecture of a compiler PART II:
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.
Copyright © Curt Hill Finite State Automata Again This Time No Output.
CS 3813: Introduction to Formal Languages and Automata Chapter 2 Deterministic finite automata These class notes are based on material from our textbook,
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
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.
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
R. Johnsonbaugh Discrete Mathematics 5 th edition, 2001 Chapter 10 Automata, Grammars and Languages.
1.2 Three Basic Concepts Languages start variables Grammars Let us see a grammar for English. Typically, we are told “a sentence can Consist.
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.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
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.
Finite Automata A simple model of computation. 2 Finite Automata2 Outline Deterministic finite automata (DFA) –How a DFA works.
1 Section 11.2 Finite Automata Can a machine(i.e., algorithm) recognize a regular language? Yes! Deterministic Finite Automata A deterministic finite automaton.
Set, Alphabets, Strings, and Languages. The regular languages. Clouser properties of regular sets. Finite State Automata. Types of Finite State Automata.
Finite-State Machines (FSM) Chuck Cusack Based partly on Chapter 11 of “Discrete Mathematics and its Applications,” 5 th edition, by Kenneth Rosen.
Fall 2004COMP 3351 Finite Automata. Fall 2004COMP 3352 Finite Automaton Input String Output String Finite Automaton.
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
Languages.
Lexical analysis Finite Automata
Non Deterministic Automata
Recognizer for a Language
Jaya Krishna, M.Tech, Assistant Professor
Equivalence, DFA, NDFA Sequential Machine Theory Prof. K. J. Hintz
Chapter 2 FINITE AUTOMATA.
Language Recognition (12.4)
CSE322 Finite Automata Lecture #2.
Some slides by Elsa L Gunter, NJIT, and by Costas Busch
THEORY OF COMPUTATION Lecture One: Automata Theory Automata Theory.
Deterministic Finite Automata And Regular Languages Prof. Busch - LSU.
Non-Deterministic Finite Automata
Non-Deterministic Finite Automata
Nondeterministic Finite Automata
Non Deterministic Automata
Finite Automata.
4b Lexical analysis Finite Automata
4b Lexical analysis Finite Automata
Language Recognition (12.4)
Chapter 1 Regular Language
Finite-State Machines with No Output
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:

Modeling Computation: Finite State Machines without Output INFO 2950 Prof. Carla Gomes gomes@cs.cornell.edu Module Modeling Computation: Finite State Machines without Output Rosen, Chapter 12.2 and 12.3

Finite-State Machines with No Output

Definition: Concatenation of A and B A and B are subsets of V*, where V is a vocabulary The concatenation of A and B is AB={xy: x string in A and y string in B} Example: A={0, 11} and B={1, 10, 110} AB={01,010,0110,111,1110,11110} What is BA? A0={λ} An+1=AnA for n=0,1,2,…

Definition: Concatenation of A and B Example: A={1,00} An ? n=1, 2, 3,… A0 A0={λ} A1=A0A1={λ} A ? A1=A0A1={λ} A={1,00} A2=A1A ={1,00} {1,00} A2=A1A ={1,00} {1,00} = {11,100,001,0000} A3=A2A ={11,100,001,0000}{1,00} A3=A2A ={11,100,001,0000}{1,00} = {111,1100,1001,10000,001111,00100,00001,000000}

Kleene Closure Let A be any subset of V*. Kleene closure of A, denoted by A*, is The set consisting of concatenations of arbitrarily many strings from A If B={0,1}, B*=V*.

Kleene Closure What are the Kleen closures of the set A={0}; B={0,1}, and C={11}? A*={,0,00,000,…} ={0n |n=0,1,2,…} If B={0,1}, B*=V*. (The set of all strings over the alphabet V) C*={,11,1111,111111,…} ={(11)n |n=0,1,2,…} ={12n |n=0,1,2,…}

Finite State Automata Representations As with finite-state machines, finite-state automata have the following common representations A state table is used to represent a finite-state automaton by giving the values of the function f. Just like for finite-state machines, except the second half of the columns are omitted, since there is no output. A state diagram is a directed graph representation of a finite-state automaton. Final states are usually denoted by double-circles. Values separated by commas denote several possible inputs, not inputs and outputs as with finite state machines.

Finite State Automata A finite state automation over an alphabet is illustrated by a state diagram: a directed graph edges are labeled with elements of alphabet, some nodes (or states), marked as final of “accepting”. one node marked as start state

Dealing with Input Strings Let x=x1x2…xnÎI * (That is, x is a string over I) Then we can extend the transition function f to all state-input string pairs (rather than simply state-input pairs) in the obvious way Assume the machine is in state S0, Compute f(S0, x1) = Si2 Next compute f(Si2, x2) = Si3 Continue until you get f(Sin, xn) = Sin+1 We define f(S0, x) = Sin+1 From now on, we will speak of the transition function f being applied to input strings, not just single inputs.

Finite (State) Automata A FA is similar to a compiler in that: A compiler recognizes legal programs in some (source) language. A finite-state machine recognizes legal strings in some language. Example: Pascal Identifiers sequences of one or more letters or digits, starting with a letter: letter | digit letter S A

Finite Automaton Input String Output “Accept” or Finite “Reject”

Transition Graph initial state accepting state transition state

Initial Configuration Input String

Reading the Input

Input finished accept

Rejection

Input finished reject

Another Rejection

reject

Another Example

Input finished accept

Rejection Example

Input finished reject

Finite-State Automata Definition: A finite-state automaton is a 5-tuple M=(S, I, f, S0, F) where S is a finite set of states I is a finite input alphabet f:S´I®S is a transition function from each state-input pair to a state S0 is the initial state FÍS is a set of final states Note: automaton is the singular of automata.

’ Finite Automata If end of input If in accepting state => accept Otherwise => reject If no transition possible (got stuck) => reject

Language Recognition Definition: A finite-state automaton accepts (or recognizes) a string x if f(S0, x)ÎF. That is, the finite state automaton ends up in a final state. Definition: The language accepted (or recognized) by a finite-state automaton M, denoted by L(M), is the set of all strings recognized by M. Definition: Two finite-state automata are equivalent if they recognize the same language.

Example accept

Example accept accept accept

Example trap state accept

What is the Language? Example: What language is recognized by the following finite-state automaton? Input 0 or 1 Solution: Since the only final state is the start state, and only an input of 1 will leave the machine in the start state, it is easy to see that L(M)={1n: n=0,1,2,…}

L(M)={binary strings beginning with 0 and ending with 1} What is the Language? Example: What language is recognized by the following finite-state automaton? Solution: Notice that Any input that does not start with 0 cannot go to a final state The final state can only be arrived at if the last input is a 1 Any string can occur in between the first 0 and last 1. Thus, we can see that L(M)={binary strings beginning with 0 and ending with 1}

FSM Examples Example: What language is recognized by the following finite-state automaton? 1 1 S0 S1 Accepts strings over alphabet {0,1} that end in 1

FSM Examples Example: What language is recognized by the following finite-state automaton? 5 S2 4 S1 S0 a b Accepts strings over alphabet {a,b} that begin and end with same symbol

FSM Examples Example: What language is recognized by the following finite-state automaton? Accepts strings over {0,1,2} such that sum of digits is a multiple of 3 S1 Start 2 1 S0 S2 1 2 2 1

FSM Examples Even Odd 1 Accepts strings over {0,1} 1 Accepts strings over {0,1} that have an odd number of ones

FSM Examples '001' 1 '0' '00' 0,1 Accepts strings over {0,1} that contain the substring 001

Examples Not possible Perhaps surprisingly, this is possible Design a FSM to recognize strings with an equal number of ones and zeros. Not possible Design a FSM to recognize strings with an equal number of substrings "01" and "10". Perhaps surprisingly, this is possible

FSM Examples 1 1 1 1 1 Accepts strings with an equal number 1 1 Accepts strings with an equal number of substrings "01" and "10" 1 1 1

Non-deterministic Finite Automaton (NDFA) a non-deterministic finite state machine or non-deterministic finite automaton (NDFA) is a finite state machine where for each pair of state and input symbol it assigns a set of states i.e., from a pair of state and input symbol there are possibly two or more transitions to a next state. Every NDFA can be converted to a DFA

Nondeterministic Finite-State Automata Definition: A Nondeterministic fnite-state automaton is a 5-tuple M=(S, I, f, S0, F) where S is a finite set of states I is a finite input alphabet f:S´I® P(S) is a transition function from each state-input pair to a set of states S0 is the initial state FÍS is a set of final states

S2 S3 S1 S0 S4 Start 1 0,1 State F 1 S0 S0,S2 S1 S3 S4 S2

What does it mean for a nondeterministic FSA (NFSA) Start 1 0,1 What does it mean for a nondeterministic FSA (NFSA) to recognize a string? T he NDFSA recognizes or accepts a string x if there is a final state in the set of all states that can be obtained from S0, using x.

What language does it accept? 0n 11 |n≥0 S2 S3 S1 S0 S4 Start 1 0,1 0n |n≥0 0n 01 |n≥0

Equivalence of DFSM and NFSM Theorem: For each non-deterministic finite state machine N, we can construct a deterministic finite state machine D such that N and D accept the same language. [proof omitted] Every deterministic finite state machine can be regarded as a non–deterministic finite state machine that just doesn’t use the extra non–deterministic capabilities.

Start 1 0,1 start 1 0,1 0n |n≥0 0n 01 |n≥0 0n 11 |n≥0 State F 1 S0 Start 1 0,1 State F 1 S0 S0,S2 S1 S3 S4 S2 {S0} {S0,S2} {S1,S4} {S3,S4} {S4} {S3} {S1} Ø start 1 0,1 0n |n≥0 0n 01 |n≥0 0n 11 |n≥0