Finite Automata a b A simplest computational model

Slides:



Advertisements
Similar presentations
4b Lexical analysis Finite Automata
Advertisements

CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Finite Automata.
Cpt S 317: Spring 2009 Reading: Chapter 2
CS5371 Theory of Computation
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
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.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 1 Regular Languages Contents Finite Automata (FA or DFA) definitions, examples,
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Nondeterminism.
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.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
Topics Automata Theory Grammars and Languages Complexities
Introduction to Finite Automata Adapted from the slides of Stanford CS154.
1.Defs. a)Finite Automaton: A Finite Automaton ( FA ) has finite set of ‘states’ ( Q={q 0, q 1, q 2, ….. ) and its ‘control’ moves from state to state.
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
Costas Busch - LSU1 Non-Deterministic Finite Automata.
1 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
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.
Rosen 5th ed., ch. 11 Ref: Wikipedia
NFA ε - NFA - DFA equivalence. What is an NFA An NFA is an automaton that its states might have none, one or more outgoing arrows under a specific symbol.
CS311: Computational Theory
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
Theory of Languages and Automata
Theory of Computation - Lecture 3 Regular Languages What is a computer? Complicated, we need idealized computer for managing mathematical theories... Hence:
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Modeling Computation: Finite State Machines without Output
Lecture Notes 
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.
Lecture #4 Thinking of designing an abstract machine acts as finite automata. Advanced Computation Theory.
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
1 Chapter 2 Finite Automata (part a) Hokkaido, Japan.
Theory of Computation Automata Theory Dr. Ayman Srour.
Nondeterminism Subset Construction ε -Transitions.
  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.
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.
Introduction to Automata Theory Theory of Computation Lecture 3 Tasneem Ghnaimat.
CIS Automata and Formal Languages – Pei Wang
Finite State Machines Dr K R Bond 2009
Languages.
Lexical analysis Finite Automata
Non Deterministic Automata
Recognizer for a Language
Jaya Krishna, M.Tech, Assistant Professor
Hierarchy of languages
Non-Deterministic Finite Automata
Non-Deterministic Finite Automata
CSE322 Definition and description of finite Automata
Non Deterministic Automata
Introduction to Finite Automata
Finite Automata.
4b Lexical analysis Finite Automata
Deterministic Finite Automaton (DFA)
4b Lexical analysis Finite Automata
CSCI 2670 Introduction to Theory of Computing
Chapter 1 Regular Language
Finite-State Machines with No Output
CSCI 2670 Introduction to Theory of Computing
AUTOMATA THEORY.
CHAPTER 1 Regular Languages
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
Presentation transcript:

Finite Automata a b A simplest computational model State control input Schematic of a finite automaton A simplest computational model Models computers with very small amount of memory various electromechanical devices (dish washers, digital watches, calculators …) Example: automatic door controller i.e., entries, exits in supermarkets Two states: open, closed 4 possible inputs (from two sensors) State transition table rear front front both rear neither State diagram front rear both Input signal rear both neither neither front rear both front open closed closed open closed closed closed State open closed open open open neither

Formal Definition of DFAs A deterministic finite automaton (DFA) is specified by a 5-tuple , where is a finite set of states, is a finite alphabet, is the transition function, is the initial state, is the set of final states. A DFA is usually represented by a directed labeled graph (so called transition diagram) nodes = states, arc from q to p is labeled by the set of input symbols a such that no arc if no such a, start state indicated by word ‘start’ and an arrow, accepting states get double circles. For DFA we have If the FA is in state q and input a is received, then FA goes to state p. 1 q2 q0 q1 1 0, 1

Example: Clamping Logic We may think of an accepting state as representing a ``1'' output and non-accepting states as representing ``0'' out. A ``clamping'' circuit waits for a 1 input, and forever after makes a 1 output. However, to avoid clamping on spurious noise, we'll design a FA that waits for two 1's in a row, and ``clamps'' only then. In general, we may think of a state as representing a summary of the history of what has been seen on the input so far. The states we need are: 1. State q0, the start state, says that the most recent input (if there was one) was not a 1, and we have never seen two 1's in a row. 2. State q1 says we have never seen 11, but the previous input was 1. 3. State q2 is the only accepting state; it says that we have at some time seen 11. Thus, A = ({q0, q1, q2}, {0,1}, , q0, {q2}), where is given by: Start state OR Accepting state Transition table Transition Diagram

Extension of to Paths; The Language of a DFA Intuitively, a FA accepts a string if there is a path in the transition diagram that: 1. Begins at the start state, 2. Ends at an accepting state, and 3. Has sequence of labels Formally, we extend transition function to , where w can be any string of input symbols: Basis: (i.e., on no input, the FA doesn't go anywhere). Induction: where w is a string, and a is a single symbol (i.e., see where the FA goes on w, then look for the transition on the last symbol from that state). Important fact with a straightforward, inductive proof: really represents paths. That is, if , and for all i = 0,1,…, n-1 then Acceptance of Strings: A FA A = accepts string w if Language of a FA: FA A accepts the language

Nondeterministic Finite Automata (NFA) Allow (deterministic) FA to have a choice of 0 or more next states for each state­input pair. Important tool for designing string processors, e.g., grep, lexical analyzers. But ``imaginary,'' in the sense that it has to be implemented deterministically. Example: In this somewhat contrived example, we shall design an NFA to accept strings over alphabet {1,2,3} such that the last symbol appears previously, without any intervening higher symbol, e.g., …11, …21112, …312123. Trick: use start state to mean ``I guess I haven't seen the symbol that matches the ending symbol yet. Three other states represent a guess that the matching symbol has been seen, and remembers what that symbol is.

Formal NFA N = , where all is as DFA, but: is a set of states, rather than a single state. Extension to Basis: Induction: Let: Then Language of an NFA: An NFA accepts w if any path from the start state to an accepting state is labeled w. Formally:

Subset Construction For every NFA there is an equivalent (accepts the same language) DFA. But the DFA can have exponentially many states. Let be an NFA. The equivalent DFA constructed by the subset construction is where: 1. i.e., is the set of all subsets of . is the set of sets S in such that Key theorem (induction on |w|, proof in book): Consequence: L(D) = L(N ).

Example: Subset Construction Subset construction from previous NFA An important practical trick, used in lexical analyzers and other text­processors is to ignore the (often many) states that are not accessible from the start state (i.e., no path leads there). For the NFA example above, of the 32 possible subsets, only 15 are accessible. Computing transitions ``on demand'' gives the following