CS 455/555: Finite automata

Similar documents
Finite Automata and Regular languages

Theory of Computation (I) Yijia Chen Fudan University

CS 154. Finite Automata, Nondeterminism, Regular Expressions

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Closure under the Regular Operations

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

Equivalence of DFAs and NFAs

Sri vidya college of engineering and technology

CS 455/555: Mathematical preliminaries

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,

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

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

Nondeterministic Finite Automata

COM364 Automata Theory Lecture Note 2 - Nondeterminism

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

Inf2A: Converting from NFAs to DFAs and Closure Properties

Lecture 4 Nondeterministic Finite Accepters

The Pumping Lemma and Closure Properties

CS243, Logic and Computation Nondeterministic finite automata

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

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

CS21 Decidability and Tractability

Non-deterministic Finite Automata (NFAs)

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

Lecture 3: Nondeterministic Finite Automata

CS 154, Lecture 3: DFA NFA, Regular Expressions

3515ICT: Theory of Computation. Regular languages

Intro to Theory of Computation

Unit 6. Non Regular Languages The Pumping Lemma. Reading: Sipser, chapter 1

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

Chapter Five: Nondeterministic Finite Automata

Finite Automata Part Two

Fooling Sets and. Lecture 5

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

Theory of Computation (II) Yijia Chen Fudan University

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

Finite Automata and Regular Languages

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

Before we show how languages can be proven not regular, first, how would we show a language is regular?

CS 208: Automata Theory and Logic

CHAPTER 1 Regular Languages. Contents

Computational Theory

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

Harvard CS 121 and CSCI E-207 Lecture 4: NFAs vs. DFAs, Closure Properties

Lecture 7 Properties of regular languages

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

UNIT-III REGULAR LANGUAGES

Theory of Languages and Automata

Uses of finite automata

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

CPS 220 Theory of Computation REGULAR LANGUAGES

Finite Automata and Languages

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

CSE 105 THEORY OF COMPUTATION

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSE 105 THEORY OF COMPUTATION

Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F)

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

Properties of Regular Languages. BBM Automata Theory and Formal Languages 1

Lecture 1: Finite State Automaton

Computer Sciences Department

CSE 105 Theory of Computation Professor Jeanne Ferrante

CPS 220 Theory of Computation

Formal Languages, Automata and Models of Computation

Regular Expressions. Definitions Equivalence to Finite Automata

Properties of Regular Languages (2015/10/15)

Computational Models - Lecture 3 1

Nondeterministic Finite Automata

CISC 4090 Theory of Computation

More Properties of Regular Languages

Lecture 17: Language Recognition

Finite Automata. BİL405 - Automata Theory and Formal Languages 1

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

CSE 105 THEORY OF COMPUTATION

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

Finite Automata and Regular Languages (part III)

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

What we have done so far

Deterministic Finite Automata (DFAs)

THEORY OF COMPUTATION

Automata and Languages

COMP4141 Theory of Computation

Finite Automata. Seungjin Choi

Closure under the Regular Operations

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

CSE 105 THEORY OF COMPUTATION

Regular Languages. Problem Characterize those Languages recognized by Finite Automata.

September 7, Formal Definition of a Nondeterministic Finite Automaton

CS 154 Introduction to Automata and Complexity Theory

Nondeterministic Finite Automata. Nondeterminism Subset Construction

CONCATENATION AND KLEENE STAR ON DETERMINISTIC FINITE AUTOMATA

Nondeterminism. September 7, Nondeterminism

DM17. Beregnelighed. Jacob Aae Mikkelsen

INF Introduction and Regular Languages. Daniel Lupp. 18th January University of Oslo. Department of Informatics. Universitetet i Oslo

Nondeterministic Finite Automata and Regular Expressions

Incorrect reasoning about RL. Equivalence of NFA, DFA. Epsilon Closure. Proving equivalence. One direction is easy:

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

Computational Models - Lecture 1 1

Transcription:

CS 455/555: Finite automata Stefan D. Bruda Winter 2019

AUTOMATA (FINITE OR NOT) Generally any automaton Has a finite-state control Scans the input one symbol at a time Takes an action based on the currently scanned symbol and the current state The action taken may yield a different current state May make use of some form of extra storage Input......... 1 2 3 4 Storage CS 455/555 (S. D. Bruda) Winter 2019 1 / 9

AUTOMATA (FINITE OR NOT) Generally any automaton Has a finite-state control Scans the input one symbol at a time Takes an action based on the currently scanned symbol and the current state The action taken may yield a different current state May make use of some form of extra storage Input......... 1 2 3 4 Storage A finite automaton scans the input from left to right only and uses no additional storage It cannot go back in the input It can only remember (using the finite state control) a finite amount of information about the already seen input CS 455/555 (S. D. Bruda) Winter 2019 1 / 9

DETERMINISTIC FINITE AUTOMATA A deterministic finite automaton is a tuple M = (K, Σ, δ, s, F) K finite set of states Σ input alphabet F K set of final states s K initial state δ : K Σ K transition function Configuration: c K Σ Yields in one step: (q, aw) M (q, w) iff a Σ and δ(q, a) = q M reflexive and transitive closure w is accepted by M iff q F : (s, w) M (q, ε) The language accepted by M: L(M) = {w Σ : q F : (s, w) M (q, ε)} CS 455/555 (S. D. Bruda) Winter 2019 2 / 9

NONDETERMINISTIC FINITE AUTOMATA A nondeterministic finite automaton is a tuple M = (K, Σ,, s, F ) K finite set of states Σ input alphabet F K set of final states s K initial state K (Σ {ε}) K transition relation Configuration: c K Σ Yields in one step: (q, aw) M (q, w) iff a Σ {ε} and (q, a, q ) M reflexive and transitive closure w is accepted by M iff q F : (s, w) M (q, ε) The language accepted by M: L(M) = {w Σ : q F : (s, w) M (q, ε)} CS 455/555 (S. D. Bruda) Winter 2019 3 / 9

DETERMINISM VERSUS NONDETERMINISM Languages accepted by finite automata? Of finite strings for sure Deterministic FA special case of nondeterministic FA In fact the two kind of finite automaton accept the same languages M = (K, Σ,, s, F) M = (K, Σ, δ, s, F ) such that L(M) = L(M ) K = 2 K Let E(q) be the closure of {q} under {(p, r) : (p, ε, r) } s = E(s) F = {Q K : Q F } δ (Q, a) = {E(p) : p K, (q, a, p) for some q Q} (proof on p. 71) DFA are more efficient, potentially difficult to understand, and often considerably larger (how much larger?) CS 455/555 (S. D. Bruda) Winter 2019 4 / 9

CLOSURE PROPERTIES M 1 = (K 1, Σ, 1, s 1, F 1 ) and M 2 = (K 2, Σ, 2, s 2, F 2 ). Can we construct M = (K, Σ,, s, F ) such that L(M) = L(M 1 ) L(M 2 ) (closure under union)? L(M) = L(M 1 )L(M 2 ) (closure under concatenation)? L(M) = L(M 1 ) (closure under Kleene star)? L(M) = L(M 1 ) (closure under complement)? L(M) = L(M 1 ) L(M 2 ) (closure under intersection)? CS 455/555 (S. D. Bruda) Winter 2019 5 / 9

CLOSURE PROPERTIES M 1 = (K 1, Σ, 1, s 1, F 1 ) and M 2 = (K 2, Σ, 2, s 2, F 2 ). Can we construct M = (K, Σ,, s, F ) such that L(M) = L(M 1 ) L(M 2 ) (closure under union)? K = K 1 K 2 F = F 1 F 2 = 1 2 {(s, ε, s 1 ), (s, ε, s 2 )} L(M) = L(M 1 )L(M 2 ) (closure under concatenation)? L(M) = L(M 1 ) (closure under Kleene star)? L(M) = L(M 1 ) (closure under complement)? L(M) = L(M 1 ) L(M 2 ) (closure under intersection)? CS 455/555 (S. D. Bruda) Winter 2019 5 / 9

CLOSURE PROPERTIES M 1 = (K 1, Σ, 1, s 1, F 1 ) and M 2 = (K 2, Σ, 2, s 2, F 2 ). Can we construct M = (K, Σ,, s, F ) such that L(M) = L(M 1 ) L(M 2 ) (closure under union)? K = K 1 K 2 F = F 1 F 2 = 1 2 {(s, ε, s 1 ), (s, ε, s 2 )} L(M) = L(M 1 )L(M 2 ) (closure under concatenation)? s = s 1 F = F 2 = 1 2 {(f, ε, s 2 ) : f F 1 } L(M) = L(M 1 ) (closure under Kleene star)? s = s 1 F = F 1 = 1 {(f, ε, s 1 ) : f F 1 } {(s 1, ε, f ) : f F 1 } L(M) = L(M 1 ) (closure under complement)? s = s 1 δ = δ 1 F 1 = K \ F L(M) = L(M 1 ) L(M 2 ) (closure under intersection)? CS 455/555 (S. D. Bruda) Winter 2019 5 / 9

CLOSURE PROPERTIES M 1 = (K 1, Σ, 1, s 1, F 1 ) and M 2 = (K 2, Σ, 2, s 2, F 2 ). Can we construct M = (K, Σ,, s, F ) such that L(M) = L(M 1 ) L(M 2 ) (closure under union)? K = K 1 K 2 F = F 1 F 2 = 1 2 {(s, ε, s 1 ), (s, ε, s 2 )} L(M) = L(M 1 )L(M 2 ) (closure under concatenation)? s = s 1 F = F 2 = 1 2 {(f, ε, s 2 ) : f F 1 } L(M) = L(M 1 ) (closure under Kleene star)? s = s 1 F = F 1 = 1 {(f, ε, s 1 ) : f F 1 } {(s 1, ε, f ) : f F 1 } L(M) = L(M 1 ) (closure under complement)? s = s 1 δ = δ 1 F 1 = K \ F L(M) = L(M 1 ) L(M 2 ) (closure under intersection)? L(M 1 ) L(M 2 ) = L(M 1 ) L(M 1 ) CS 455/555 (S. D. Bruda) Winter 2019 5 / 9

CLOSURE UNDER INTERSECTION (CONSTRUCTIVE) M 1 = (K 1, Σ, s 1, δ 1, F 1 ), M 2 = (K 2, Σ, s 2, δ 2, F 2 ) M = (K, Σ, s, δ, F ) such that L(M 1 ) L(M 2 ) = L(M) M must somehow run M 1 and M 2 in parallel to determine whether both accept the input It follows that at any given time we have to keep track of the current states of both M 1 and M 2. We thus put K = K 1 K 2 At the beginning of the computation both M 1 and M 2 are in their respective initial states, so s = (s 1, s 2 ) Similarly, in order for the input to be accepted, both M 1 and M 2 must be in one of their respective final states, so F = F 1 F 2 Finally, δ should allow M to perform simultaneously exactly one transition of M 1 and exactly one transition of M 2 : δ((q 1, q 2 ), a) = (q 1, q 2 ) iff δ 1 (q 1, a) = q 1 and δ 2(q 2, a) = q 2 CS 455/555 (S. D. Bruda) Winter 2019 6 / 9

LANGUAGES ACCEPTED BY FINITE AUTOMATA Theorem: Finite automata accept exactly all the languages in REG CS 455/555 (S. D. Bruda) Winter 2019 7 / 9

LANGUAGES ACCEPTED BY FINITE AUTOMATA Theorem: Finite automata accept exactly all the languages in REG : REG = closure of {{a} : a Σ} under union, concatenation, and Kleene star Clearly FA accept {a}, and are closed under the above operations So FA accept all REG (closure is minimal) CS 455/555 (S. D. Bruda) Winter 2019 7 / 9

LANGUAGES ACCEPTED BY FINITE AUTOMATA Theorem: Finite automata accept exactly all the languages in REG : REG = closure of {{a} : a Σ} under union, concatenation, and Kleene star Clearly FA accept {a}, and are closed under the above operations So FA accept all REG (closure is minimal) : Let M = ({q 1, q 2,..., q n}, Σ,, q 1, F) Let i, j, k be the path from q i to q j of rank k (i.e., q α in the path implies α k) Let R(i, j, k) be the set of strings in Σ along all the paths i, j, k Obviously, L(M) = {R(1, j, n) : q j F} We prove that all R(i, j, k) are regular CS 455/555 (S. D. Bruda) Winter 2019 7 / 9

LANGUAGES ACCEPTED BY FINITE AUTOMATA Theorem: Finite automata accept exactly all the languages in REG : REG = closure of {{a} : a Σ} under union, concatenation, and Kleene star Clearly FA accept {a}, and are closed under the above operations So FA accept all REG (closure is minimal) : Let M = ({q 1, q 2,..., q n}, Σ,, q 1, F) Let i, j, k be the path from q i to q j of rank k (i.e., q α in the path implies α k) Let R(i, j, k) be the set of strings in Σ along all the paths i, j, k Obviously, L(M) = {R(1, j, n) : q j F} We prove that all R(i, j, k) are regular by induction over k basis: All the i, j, 0 are transitions of M only, so R(i, j, k) are clearly regular inductive hypothesis: all the R(i, j, k 1) are regular R(i, j, k) = R(i, j, k 1) R(i, k, k 1)R(k, k, k 1) R(k, j, k 1) then R(i, j, k) are regular given the closure of regular expressions under union, concatenation, and Kleene star CS 455/555 (S. D. Bruda) Winter 2019 7 / 9

ALGORITHMS FOR REGULAR LANGUAGES nondeterministic to deterministic FA exponential time nondeterministic FA to regular expression exponential time O( K ) computations of R(i, j, k), but R(i, j, k) doubles each time Whether two FA or regular expressions accept/generate the same language polynomial time for DFA likely exponential time for NFA, regular expressions Decide whether w L(M): O( w ) if M is deterministic O( K 2 w ) if M is nondeterministic Typical application of regular languages: pattern matching L x = {w Σ : x is a substring of w} CS 455/555 (S. D. Bruda) Winter 2019 8 / 9

REGULAR AND NON-REGULAR LANGUAGES Regular languages can be described by regular expressions, finite automata (deterministic or not), and any combination of union, concatenation, intersection, complement, Kleene star of the above Languages that are not regular can be found using a pumping theorem: Theorem (Pumping regular languages) Let L be a regular language. Then there exists n 1 such that any w L with w n can be written as w = xyz with y ε xy n xy i z L for all i 0 Trivial proof using the pigeonhole principle Typical examples of non-regular languages: {a n b n : n 0}, {a p : p is prime}, {a n b n c m : n, m 0} CS 455/555 (S. D. Bruda) Winter 2019 9 / 9