FINITE STATE AUTOMATA

Similar documents
Deterministic Finite Automata (DFAs)

Deterministic Finite Automata (DFAs)

Finite State Automata Design

Closure under the Regular Operations

Deterministic Finite Automata (DFAs)

Finite State Transducers

Part I: Definitions and Properties

Deterministic Finite Automata (DFAs)

Sri vidya college of engineering and technology

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Uses of finite automata

Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CS 154, Lecture 3: DFA NFA, Regular Expressions

CS 455/555: Finite automata

CHAPTER 1 Regular Languages. Contents

Equivalence of DFAs and NFAs

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

Closure under the Regular Operations

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

Chapter 3. Regular grammars

Introduction to Turing Machines. Reading: Chapters 8 & 9

Introduction to Automata

FS Properties and FSTs

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM)

Increasing the power of FSAs

Proving languages to be nonregular

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

CS 121, Section 2. Week of September 16, 2013

Computational Models - Lecture 3

Computational Models - Lecture 4

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA)

Finite-state Machines: Theory and Applications

Johns Hopkins Math Tournament Proof Round: Automata

Formal Definition of Computation. August 28, 2013

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

1 More finite deterministic automata

Pumping Lemma for CFLs

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

CS21 Decidability and Tractability

The Pumping Lemma and Closure Properties

TAFL 1 (ECS-403) Unit- II. 2.1 Regular Expression: The Operators of Regular Expressions: Building Regular Expressions

V Honors Theory of Computation

Automata Theory and Formal Grammars: Lecture 1

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

CSE 105 THEORY OF COMPUTATION

TURING MAHINES

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

What we have done so far

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

Nondeterministic finite automata

Theory of Computation (I) Yijia Chen Fudan University

Critical CS Questions

Theory of Computation (II) Yijia Chen Fudan University

Computational Models - Lecture 5 1

How do regular expressions work? CMSC 330: Organization of Programming Languages

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

Announcements. Problem Set 6 due next Monday, February 25, at 12:50PM. Midterm graded, will be returned at end of lecture.

arxiv: v2 [cs.fl] 29 Nov 2013

Computational Models: Class 3

Decidability (What, stuff is unsolvable?)

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application

Further discussion of Turing machines

Formal Models in NLP

Non-deterministic Finite Automata (NFAs)

Opleiding Informatica

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r

Theory of Computation 1 Sets and Regular Expressions

Finite Automata and Regular languages

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

CSE 105 THEORY OF COMPUTATION

Properties of Context-Free Languages. Closure Properties Decision Properties

Time Magazine (1984)

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Fooling Sets and. Lecture 5

UNIT-III REGULAR LANGUAGES

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Nondeterminism and Epsilon Transitions

TDDD65 Introduction to the Theory of Computation

Computational Theory

The Turing Machine. CSE 211 (Theory of Computation) The Turing Machine continued. Turing Machines

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Fundamentals of Computer Science

3515ICT: Theory of Computation. Regular languages

The tape of M. Figure 3: Simulation of a Turing machine with doubly infinite tape

Finite Automata. Finite Automata

NPDA, CFG equivalence

Turing machines Finite automaton no storage Pushdown automaton storage is a stack What if we give the automaton a more flexible storage?

CSE 20. Final Review. CSE 20: Final Review


CPS 220 Theory of Computation

UNIT II REGULAR LANGUAGES

Transcription:

FINITE STATE AUTOMATA

States An FSA has a finite set of states A system has a limited number of configurations Examples {On, Off}, {1,2,3,4,,k} {TV channels} States can be graphically represented as follows: On Off

Input An FSA is defined over an alphabet The symbols of the alphabet represent the input of the system Examples {switch_on, switch_off} {incoming==0, 0<incoming<=10, incoming>10}

Transitions among states When an input is received, the system changes its state The passage between states is performed through transitions A transition is graphically represented by arrows: On Off

Simple examples (flip-flop) On T T Off S On R S Off R

FSA FSAs are the simplest model of computation Many useful devices can be modeled using FSAs but they have some limitations

Formally An FSA is a triple <Q, A, δ>, where Q is a finite set of states A is the input alphabet δ is a transition function (that can be partial), given by δ: Q A Q Remark if the function is partial, then not all the transitions from all the possible states for all the possible elements of the alphabet are defined

Partial vs Total Transition Function switch_on switch_off switch_off On Off switch_on An FSA with a total transition function is called complete

Recognizing languages In order to be able to use FSAs for recognizing languages, it is important to identify: the initial conditions of the system the final admissible states Example: The light should be off at the beginning and at the end

Elements The elements of the model are States Transitions Input and also Initial state(s) Final state(s)

Graphical representation Initial state Off Final state Off

Formally An FSA is a tuple <Q, A, δ, q 0, F>, where Q is a finite set of states A is the input alphabet δ is a (partial) transition function, given by δ: Q A Q q 0 Q is called initial state F Q is the set of final states

Move sequence A move sequence starts from an initial state and is accepting if it reaches one of the final states switch_on On switch_off Off switch_off switch_on

Formally Move sequence: δ : Q A Q δ is inductively defined from δ δ (q,ε) = q δ (q,yi) = δ(δ (q,y), i) Initial state: q 0 Q Final (or accepting) states: F Q x (x L δ (q 0,x) F)

A practical example Recognizing Pascal identifiers <letter> <letter> q 0 q 1 <digit> q E <digit> <digit> <letter>

FINITE STATE TRANSDUCERS

Automata as language translators Input tape Control device (finite state) Output tape A finite state transducer is an FSA that works on two tapes. it is a kind of ``translating machine''.

The idea y = τ(x) x: input string y: output τ: function from L 1 to L 2 Examples: τ 1 the occurrences of 1 are doubled (1 --> 11) τ 2 a is swapped with b (a <---> b): but also Compression of files Compiling from high level languages into object languages Translation from English to Italian

Informally Transitions with output q i/w q Example: τ halves the number of 0 s and doubles the number of 1 s 1/11 0/ε 1/11 q 0 q 1 0/0

Formally A finite state transducer (FST) is a tuple T = <Q, I, δ, q 0, F, O, η> <Q, I, δ, q 0, F>: just like acceptors O: output alphabet η : Q I O * Remark: the condition for acceptance remains the same as in acceptors The translation is performed only on accepted strings

Translating a string As we did for δ, we define η* inductively η * (q,ε) = ε η (q,y.i) = η (q,y).η(δ (q,y), i) Remark η*: Q I * O * x (τ(x) = η (q 0,x) iff δ (q 0,x) F)

PUMPING LEMMA

Cycles There is a cycle: q1 ----aabab---> q1 b a b q0 q1 q2 q9 b b a a q5 a q4 q3 b q8 a b q6 q7 If one goes through the cycle once, then one can also go through it 2,3,, n times

More formally If x L and x Q, then there exists a q Q and a w I + such that: x = ywz δ (q,w) = q Therefore the following also holds: n 0 yw n z L This is the Pumping Lemma (one can pump w)

Consequences of pumping lemma L =? L =? x L y L y < Q : Just remove all cycles from the FSA accepting x Check by a similar argument whether x L Q <= x < 2 Q Note that in general knowing how to answer the question x L? for a generic x, does not entail knowing how to answer the other questions It works for FSAs, but

Impact in practice Are we interested in a programming language consisting of 0 correct programs? Are we interested in a programming language in which one can only write a finite number of programs?...

A negative consequence of pumping lemma Is the language L = {a n b n n > 0} recognized by some FSA? Let us suppose it is. Then: Consider x = a m b m, m > Q and let us apply P.L. Possible cases: x = ywz, w = a k, k > 0 ====> a m + r k b m L, r : NO x = ywz, w = b k, k > 0 ====> same x = ywz, w = a k b s, k, s > 0 ====> a m-k a k b s a k b s b m-s L: NO

Intuitively In order to count an arbitrary n we need an infinite memory! Rigorously speaking, every computer is an FSA, but it is the wrong abstraction: intractable number of states! (same thing as studying every single molecule in the flight of an airplane) Importance of an abstract notion of infinity From the toy example {a n b n } to more concrete cases: Checking well-balancing of brackets (typically used in programming languages) cannot be done with finite memory We therefore need more powerful models

OPERATIONS ON FSA

Closure in math A set S is closed w.r.t. an operation OP if, when operation OP is applied to elements of S, the result is still an element of S Examples: Natural numbers are closed w.r.t. sum (but not subtraction) Integers are closed w.r.t. sum, subtraction, multiplication (but not division) Rationals Reals

Closure for languages L = {L i }: family of languages L is closed w.r.t. operation OP if and only if, for every L 1, L 2 L, L 1 OP L 2 L. R: regular languages (recognized by FSAs) R is closed w.r.t. set-theoretic operations, concatenation, *,

Intersection A The parallel run of A and B can be simulated by coupling them b a a q 0 q 1 q 2 q 9 B p 0 b a a p 1 p 2 p 9 p a a <A,B> q b 0 0 q 1 p 1 q 2 p 2 q 9 p 9

Example A 1 : a A 2 : a q 0 q 1 p 0 a a q 0 p 0 q 1 p 0 a 33

Formally Given A 1 = <Q 1, I, δ 1, q 01, F 1 > A 2 = <Q 2, I, δ 2, q 02, F 2 > < A 1, A 2 > = <Q 1 Q 2,I,δ,<q 01,q 02 >,F 1 F 2 > δ(<q 1,q 2 >, i) = <δ 1 (q 1, i), δ 2 (q 2,i)> One can show (by simple induction) that L(< A 1,A 2 >) = L(A 1 ) L( A 2 ) Can we do the same for union?

Union The union is built analogously Given A 1 = <Q 1, I, δ 1, q 01, F 1 > A 2 = <Q 2, I, δ 2, q 02, F 2 > <A1, A2>= <Q 1 xq 2,I,δ,<q 01,q 02 >,F 1 xq 2 UQ 1 xf 2 > δ(<q 1,q 2 >, i) = <δ 1 (q 1, i), δ 2 (q 2,i)>

Complement (1) Basic idea F c = Q-F 0 0 1 q 0 q 1 1 but in general the transition function is partial!

Complement (2) Before swapping final and non final states it is necessary to complete the FSA 0 0 1 q 0 q 1 0 0 1 q 0 q 1 0 0 1 q 0 q 1 q E 0,1 1 0,1 q E 1

Union again Another possibility is to use complement and De Morgan s laws: A B = ( A B)

Philosophy of complement If I scan the entire input string, then it suffices to swap yes and no (F with Q-F) If I cannot reach the end of the string, then swapping F with Q-F does not work In the case of FSAs there is an easy workaround (completing the FSA) In general we cannot consider the negative answer to a question as equivalent to the positive answer to the opposite question!