Theory of Computation (II) Yijia Chen Fudan University

Size: px
Start display at page:

Download "Theory of Computation (II) Yijia Chen Fudan University"

Transcription

1 Theory of Computation (II) Yijia Chen Fudan University

2 Review

3 A language L is a subset of strings over an alphabet Σ. Our goal is to identify those languages that can be recognized by one of the simplest computation models finite automata. We will also show that those languages can be formed by some simple syntactic manipulations regular expressions.

4 Finite automata Definition A (deterministic) finite automaton (DFA) is a 5-tuple ( Q, Σ, δ, q 0, F ), where 1. Q is a finite set called the states, 2. Σ is a finite set called the alphabet, 3. δ : Q Σ Q is the transition function, 4. q 0 Q is the start state, and 5. F Q is the set of accept states.

5 Formal definition of computation Let M = ( Q, Σ, δ, q 0, F ) be a finite automaton and let w = w 1w 2 w n be a string with w i Σ for all i [n]. Then M accepts w if a sequence of states r 0, r 1,..., r n in Q exists with: 1. r 0 = q 0, 2. δ(r i, w i+1 ) = r i+1 for i = 0,..., n 1, and 3. r n F. We say that M recognizes A if A = { w M accepts w }.

6 Regular languages Definition A language is called regular if some finite automaton recognizes it.

7 The regular operators Definition Let A and B be languages. We define the regular operations union, concatenation, and star as follows: Union: A B = { x x A or x B }. Concatenation: A B = { xy x A and y B }. Star: A = { x 1x 2... x k k 0 and each xi A }.

8 Closure under union Theorem The class of regular languages is closed under the union operation. In other words, if A 1 and A 2 are regular languages, so is A 1 A 2.

9 Proof (1) For i [2] let M i = ( Q i, Σ i, δ i, q i, F i ) recognize Ai. We can assume without loss of generality Σ 1 = Σ 2: Let a Σ 2 Σ 1. We add δ 1(r, a) = r trap, where r trap is a new state with δ 1(r trap, w) = r trap for every w.

10 Proof (2) We construct M = ( Q, Σ, δ, q 0, F ) to recognize A 1 A 2: 1. Q = Q 1 Q 2 = { (r 1, r } 2) r 1 Q 1 and r 2 Q Σ = Σ 1 = Σ For each (r 1, r 2) Q and a Σ we let δ ( (r 1, r 2), a ) = ( δ 1(r 1, a), δ 2(r 2, a) ). 4. q 0 = (q 1, q 2). 5. F = (F 1 Q 2) (Q 1 F 2) = { (r 1, r } 2) r 1 F 1 or r 2 F 2.

11 Closure under concatenation Theorem The class of regular languages is closed under the concatenation operation. In other words, if A 1 and A 2 are regular languages, so is A 1 A 2. We prove the above theorem by nondeterministic finite automata which have the same power as deterministic finite automata, are much easier to manipulate.

12 Nondeterminism Definition A nondeterministic finite automaton (NFA) is a 5-tuple ( Q, Σ, δ, q 0, F ), where 1. Q is a finite set of states, 2. Σ is a finite alphabet, 3. δ : Q Σ ε P(Q) is the transition function, where Σ ε = Σ {ε}, 4. q 0 Q is the start state, and 5. F Q is the set of accept states.

13 Formal definition of computation Let N = ( Q, Σ, δ, q 0, F ) be an NFA and let w = y 1y 2 y m be a string with y i Σ ε for all i [m]. Then N accepts w if a sequence of states r 0, r 1,..., r m in Q exists with: 1. r 0 = q 0, 2. r i+1 δ(r i, y i+1 ) for i = 0,..., m 1, and 3. r m F.

14 Equivalence of NFAs and DFAs Theorem Every NFA has an equivalent DFA, i.e., they recognize the same language.

15 Corollary A language is regular if and on if some nondeterministic finite automaton recognizes it.

16 Second proof of the closure under union For i [2] let N i = ( Q i, Σ i, δ i, q i, F i ) recognize Ai. We construct an N = ( Q, Σ, δ, q 0, F ) to recognize A 1 A 2: 1. Q = {q 0} Q 1 Q q 0 is the start state. 3. F = F 1 F For any q Q and any a Σ ε δ 1(q, a) q Q 1 δ 2(q, a) q Q 2 δ(q, a) = {q 1, q 2} q = q 0 and a = ε q = q 0 and a ε.

17 Closure under concatenation Theorem The class of regular languages is closed under the concatenation operation.

18 Proof For i [2] let N i = ( Q i, Σ i, δ i, q i, F i ) recognize Ai. We construct an N = ( Q, Σ, δ, q 1, F 2 ) to recognize A1 A 2: 1. Q = Q 1 Q The start state q 1 is the same as the start state of N The accept states F 2 are the same as the accept states of N For any q Q and any a Σ ε δ 1(q, a) q Q 1 F 1 δ 1(q, a) q F 1 and a ε δ(q, a) = δ 1(q, a) {q 2} q F 1 and a = ε δ 2(q, a) q Q 2.

19 Closure under star Theorem The class of regular languages is closed under the star operation.

20 Proof Let N 1 = ( Q 1, Σ, δ 1, q 1, F 1 ) recognize Ai. We construct an N = ( Q, Σ, δ, q 0, F ) to recognize A 1 : 1. Q = {q 0} Q The start state q 0 is the new start state. 3. F = {q 0} F For any q Q and any a Σ ε δ 1(q, a) q Q 1 F 1 δ 1(q, a) q F 1 and a ε δ(q, a) = δ 1(q, a) {q 1} q F 1 and a = ε {q 1} q = q 0 and a = ε q = q 0 and a ε.

21 Regular expression and the associated languages regular expression R language L(R) a {a} ε {ε} (R 1 R 2) L(R 1) L(R 2) (R 1 R 2) L(R 1) L(R 2) (R1 ) L(R 1)

22 Equivalence with finite automata Theorem A language is regular if and only if some regular expression describes it.

23 The languages defined by regular expressions are regular 1. R = a: Let N = ( {q 1, q 2}, Σ, δ, q 1, {q 2} ), where δ(q 1, a) = {q 2} and δ(r, b) = for all r q 1 or b a. 2. R = ε: Let N = ( {q 1}, Σ, δ, q 1, {q 1} ), where δ(r, b) = for all r and b. 3. R = : Let N = ( {q 1}, Σ, δ, q 1, ), where δ(r, b) = for all r and b. 4. R = R 1 R 2: L(R) = L(R 1) L(R 2). 5. R = R 1 R 2: L(R) = L(R 1) L(R 2). 6. R = R 1 : L(R) = L(R 1).

24 To prove the other direction we need to further generalize NFA to generalized nondeterministic finite automata, which might be viewed as a mixture of automata and regular expressions.

25 Generalized nondeterministic finite automata Definition A GNFA is a 5-tuple ( Q, Σ, δ, q start, q accept ), where 1. Q is a finite set of states, 2. Σ is a finite alphabet, 3. δ : ( Q {q accept} ) ( Q {q start} ) R is the transition function, where R is the set of regular expressions, 4. q start is the start state, and 5. q accept is the accept state.

26 Formal definition of computation A GNFA accepts a string w Σ if w = w 1w 2... w k, where each w i Σ and a sequence of states q 0, q 1,..., q k exists such that 1. q 0 = q start is the start state, 2. q k = q accept is the accept state, and 3. for each i [k], we have w i L(R i ), where R i = δ(q i 1, q i ).

27 Regular languages can be defined by regular expressions Let M be the DFA for language A. We convert M to a GNFA G by adding a new start state and a new accept state and additional transition arrows as necessary. 1. The start state has transition arrows going to every other state but no arrows coming in from any other state. 2. There is only a single accept state, and it has arrows coming in from every other state but no arrows going to any other state. Furthermore, the accept state is not the same as the start state. 3. Except for the start and accept states, one arrow goes from every state to every other state and also from each state to itself. Then we use a procedure convert on G to return an equivalent regular expression.

28 convert(g): 1. Let k be the number of states of G. 2. If k = 2, then return the regular expression R labelling the arrow from q start to q accept. 3. If k > 2, we select any state q rip Q {q start, q accept} and let G = ( Q, Σ, δ, q start, q accept ) be the GNFA, where Q = Q { q rip }, and for any q i Q { q accept } and qj Q { q start }, let δ (q i, q j ) = (R 1)(R 2) (R 3) (R 4), for R 1 = δ(q i, q rip), R 2 = δ(q rip, q rip), R 3 = δ(q rip, q j ), and R 4 = δ(q i, q j ). 4. Compute convert(g ) and return this value.

29 Languages need counting C = { w {0, 1} w has an equal number of 0s and 1s }. D = { w {0, 1} w has an equal number of occurrences of 01 and 10 as substrings }. Lemma D is regular.

30 The pumping lemma for regular languages Lemma If A is a regular language, then there is a number p (i.e., the pumping length) where if s is any string in A of length at least p, then s may be divided into three pieces, s = xyz, satisfying the following conditions: 1. for each i 0, we have xy i z A, 2. y > 0, and 3. xy p. Any string xyz in A can be pumped along y.

31 Proof Let M = ( Q, Σ, δ, q 1, F ) be a DFA recognizing A and p := Q. Let s = s 1s 2 s n be a string in A with n p. Let r 1,..., r n+1 be the sequence of states that M enters while processing s, i.e., for i [n]. r i+1 = δ(r i, s i ) Among the first p + 1 states in the sequence, two must be the same, say r j and r l with j < l p + 1. We define x = s 1 s j 1, y = s j s l 1, and z = s l s n.

32 Example (I) Example The language { 0 n 1 n n 0 } is not regular. Proof. Choose p be the pumping length and consider s = 0 p 1 p. By the Pumping Lemma, s = xyz with xy i z { 0 n 1 n n 0 } for all i y 00, then xyyz has more 0s than 1s, a contradiction. 2. y 11, then xyyz has more 1s than 0s, again a contradiction. 3. y consists of both 0s and 1s, then xyyz have 0 and 1 interleaved.

33 Example (II) Example The language { w w has an equal number of 0s and 1s } is not regular. Proof. Choose p be the pumping length and consider s = 0 p 1 p. By the Pumping Lemma, s = xyz with xy p and xy i z { w w has an equal number of 0s and 1s } for all i 0. Thus xy 00 and the contradiction follows easily.

34 Context-Free Languages

35 An example The grammar: A 0A1 A B B # A derivation: A 0A1 00A11 000A #111.

36 A second example (1) sentence noun-phrase verb-phrase noun-phrase cmplx-noun cmplx-noun prep-phrase verb-phrase cmplx-verb cmplx-verb prep-phrase prep-phrase prep cmplx-noun cmplx-noun article noun cmplx-verb verb verb noun-phrase article a the noun boy girl flower verb touches likes sees prep with

37 A second example (2) sentence noun-phrase verb-phrase cmplx-noun verb-phrase article noun verb-phrase a noun verb-phrase a boy verb-phrase a boy cmplx-verb a boy verb a boy sees.

38 Context-free grammars Definition A context-free grammar (CFL) is a 4-tuple (V, Σ, R, S), where 1. V is a finite set called the variables, 2. Σ is a finite set, disjoint from V, called the terminals. 3. R is a finite set of rules, with each rule being a variable and a string of variables and terminals, and 4. S V is the start variable.

39 Derivations Let u, v, w be strings of variables and terminals, and A w is a rule of the grammar. We say that uav yields uwv, written uav uwv. Say that u derives v, written u v, if u = v or if a sequence u 1, u 2,..., u k exists for k 0 and u u 1 u 2... u k v. The language of the grammar is { w Σ S w }, which is a context-free language (CFL).

40 Examples 1. The language { 0 n 1 n n 0 } has a grammar: S 1 0S 11 ε. 2. The language { 1 n 0 n n 0 } has a grammar: S 2 1S 20 ε. 3. The language { 0 n 1 n n 0 } { 1 n 0 n n 0 } has a grammar: S S 1 S 2 S 1 0S 11 ε S 2 1S 20 ε.

41 expr expr + expr expr expr ( expr ) a. The string a+a a have two different derivations: 1. expr expr expr expr + expr expr a+a a. 2. expr expr + expr expr + expr expr a+a a.

42 Leftmost derivations A derivation of a string w in a grammar G is a leftmost derivation if at every step the leftmost remaining variable is the one replaced.

43 Ambiguity Definition A string w is derived ambiguously is context free grammar G if it has two or more different leftmost derivations. Grammar G is ambiguous if it generates some string ambiguously. {a} has two different grammars S 1 S 2 a; S 2 a and S a. The first is ambiguous, while the second is not. { a i b j c k i = j or j = k } is inherently ambiguous, i.e., its every grammar is ambiguous.

44 Chomsky normal form Definition A context-free grammar is in Chomsky normal form if every rule is of the form A BC A a where a is any terminal and A, B, and C are any variables except that B and C may be not the start variable. In addition, we permit the rule S ε, where S is the star variable. Theorem Any context-free language is generated by a context-free grammar in Chomsky normal form.

45 Proof of the theorem 1. Add a new start variable S 0 with the rule S 0 S, where S is the original start variable. 2. Remove every A ε, where A S. Then for each occurrence of A on the right-hand side of a rule, we add a new rule with that occurrence deleted. For R A, we add R ε unless we had previously removed R ε. 3. Remove every A B. Then whenever a rule B u appears, where u is a string of variables and terminals, we add the rule A u unless this was previously removed. 4. Replace each rule A u 1u 2 u k with k 3 and each u i is a variable or terminal with the rules A u 1A 1, A 1 u 2A 2, A 2 u 2A 3,..., and A k 2 u k 1 u k. The A i s are new variables. We replace any terminal u i with the new variable U i and add U i u i.

Theory of Computation (I) Yijia Chen Fudan University

Theory of Computation (I) Yijia Chen Fudan University Theory of Computation (I) Yijia Chen Fudan University Instructor Yijia Chen Homepage: http://basics.sjtu.edu.cn/~chen Email: yijiachen@fudan.edu.cn Textbook Introduction to the Theory of Computation Michael

More information

Finite Automata and Regular languages

Finite Automata and Regular languages Finite Automata and Regular languages Huan Long Shanghai Jiao Tong University Acknowledgements Part of the slides comes from a similar course in Fudan University given by Prof. Yijia Chen. http://basics.sjtu.edu.cn/

More information

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 10 : Context-Free Grammars

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 10 : Context-Free Grammars COMP-330 Theory of Computation Fall 2017 -- Prof. Claude Crépeau Lec. 10 : Context-Free Grammars COMP 330 Fall 2017: Lectures Schedule 1-2. Introduction 1.5. Some basic mathematics 2-3. Deterministic finite

More information

Computational Models - Lecture 3

Computational Models - Lecture 3 Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Computational Models - Lecture 3 Equivalence of regular expressions and regular languages (lukewarm leftover

More information

What we have done so far

What we have done so far What we have done so far DFAs and regular languages NFAs and their equivalence to DFAs Regular expressions. Regular expressions capture exactly regular languages: Construct a NFA from a regular expression.

More information

Theory of Languages and Automata

Theory of Languages and Automata Theory of Languages and Automata Chapter 1- Regular Languages & Finite State Automaton Sharif University of Technology Finite State Automaton We begin with the simplest model of Computation, called finite

More information

CISC4090: Theory of Computation

CISC4090: Theory of Computation CISC4090: Theory of Computation Chapter 2 Context-Free Languages Courtesy of Prof. Arthur G. Werschulz Fordham University Department of Computer and Information Sciences Spring, 2014 Overview In Chapter

More information

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

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1) CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1) Definition 1 (Alphabet) A alphabet is a finite set of objects called symbols. Definition 2 (String)

More information

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

September 11, Second Part of Regular Expressions Equivalence with Finite Aut Second Part of Regular Expressions Equivalence with Finite Automata September 11, 2013 Lemma 1.60 If a language is regular then it is specified by a regular expression Proof idea: For a given regular language

More information

Computational Models - Lecture 4

Computational Models - Lecture 4 Computational Models - Lecture 4 Regular languages: The Myhill-Nerode Theorem Context-free Grammars Chomsky Normal Form Pumping Lemma for context free languages Non context-free languages: Examples Push

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY REVIEW for MIDTERM 1 THURSDAY Feb 6 Midterm 1 will cover everything we have seen so far The PROBLEMS will be from Sipser, Chapters 1, 2, 3 It will be

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY THE PUMPING LEMMA FOR REGULAR LANGUAGES and REGULAR EXPRESSIONS TUESDAY Jan 21 WHICH OF THESE ARE REGULAR? B = {0 n 1 n n 0} C = { w w has equal number

More information

TDDD65 Introduction to the Theory of Computation

TDDD65 Introduction to the Theory of Computation TDDD65 Introduction to the Theory of Computation Lecture 2 Gustav Nordh, IDA gustav.nordh@liu.se 2012-08-31 Outline - Lecture 2 Closure properties of regular languages Regular expressions Equivalence of

More information

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10 Regular Languages Andreas Karwath & Malte Helmert 1 Overview Deterministic finite automata Regular languages Nondeterministic finite automata Closure operations Regular expressions Nonregular languages

More information

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministic Finite Automata Not A DFA Does not have exactly one transition from every state on every symbol: Two transitions from q 0 on a No transition from q 1 (on either a or b) Though not a DFA,

More information

Outline. CS21 Decidability and Tractability. Machine view of FA. Machine view of FA. Machine view of FA. Machine view of FA.

Outline. CS21 Decidability and Tractability. Machine view of FA. Machine view of FA. Machine view of FA. Machine view of FA. Outline CS21 Decidability and Tractability Lecture 5 January 16, 219 and Languages equivalence of NPDAs and CFGs non context-free languages January 16, 219 CS21 Lecture 5 1 January 16, 219 CS21 Lecture

More information

Closure under the Regular Operations

Closure under the Regular Operations September 7, 2013 Application of NFA Now we use the NFA to show that collection of regular languages is closed under regular operations union, concatenation, and star Earlier we have shown this closure

More information

CS 154. Finite Automata, Nondeterminism, Regular Expressions

CS 154. Finite Automata, Nondeterminism, Regular Expressions CS 54 Finite Automata, Nondeterminism, Regular Expressions Read string left to right The DFA accepts a string if the process ends in a double circle A DFA is a 5-tuple M = (Q, Σ, δ, q, F) Q is the set

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 5-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY NON-DETERMINISM and REGULAR OPERATIONS THURSDAY JAN 6 UNION THEOREM The union of two regular languages is also a regular language Regular Languages Are

More information

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

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is Abstraction of Problems Data: abstracted as a word in a given alphabet. Σ: alphabet, a finite, non-empty set of symbols. Σ : all the words of finite length built up using Σ: Conditions: abstracted as a

More information

CS 154, Lecture 3: DFA NFA, Regular Expressions

CS 154, Lecture 3: DFA NFA, Regular Expressions CS 154, Lecture 3: DFA NFA, Regular Expressions Homework 1 is coming out Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and

More information

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

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages CS 154 Finite Automata vs Regular Expressions, Non-Regular Languages Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and guessing

More information

Computer Sciences Department

Computer Sciences Department 1 Reference Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER 3 objectives Finite automaton Infinite automaton Formal definition State diagram Regular and Non-regular

More information

CPS 220 Theory of Computation

CPS 220 Theory of Computation CPS 22 Theory of Computation Review - Regular Languages RL - a simple class of languages that can be represented in two ways: 1 Machine description: Finite Automata are machines with a finite number of

More information

COM364 Automata Theory Lecture Note 2 - Nondeterminism

COM364 Automata Theory Lecture Note 2 - Nondeterminism COM364 Automata Theory Lecture Note 2 - Nondeterminism Kurtuluş Küllü March 2018 The FA we saw until now were deterministic FA (DFA) in the sense that for each state and input symbol there was exactly

More information

CS 455/555: Finite automata

CS 455/555: Finite automata 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

More information

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

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application Examples of Regular Expressions 1. 0 10, L(0 10 ) = {w w contains exactly a single 1} 2. Σ 1Σ, L(Σ 1Σ ) = {w w contains at least one 1} 3. Σ 001Σ, L(Σ 001Σ ) = {w w contains the string 001 as a substring}

More information

Computational Models - Lecture 4 1

Computational Models - Lecture 4 1 Computational Models - Lecture 4 1 Handout Mode Iftach Haitner. Tel Aviv University. November 21, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.

More information

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

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata CISC 4090: Theory of Computation Chapter Regular Languages Xiaolan Zhang, adapted from slides by Prof. Werschulz Section.: Finite Automata Fordham University Department of Computer and Information Sciences

More information

CPSC 421: Tutorial #1

CPSC 421: Tutorial #1 CPSC 421: Tutorial #1 October 14, 2016 Set Theory. 1. Let A be an arbitrary set, and let B = {x A : x / x}. That is, B contains all sets in A that do not contain themselves: For all y, ( ) y B if and only

More information

Theory of Computation (IV) Yijia Chen Fudan University

Theory of Computation (IV) Yijia Chen Fudan University Theory of Computation (IV) Yijia Chen Fudan University Review language regular context-free machine DFA/ NFA PDA syntax regular expression context-free grammar Pushdown automata Definition A pushdown automaton

More information

Introduction to Theory of Computing

Introduction to Theory of Computing CSCI 2670, Fall 2012 Introduction to Theory of Computing Department of Computer Science University of Georgia Athens, GA 30602 Instructor: Liming Cai www.cs.uga.edu/ cai 0 Lecture Note 3 Context-Free Languages

More information

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

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism, CS 54, Lecture 2: Finite Automata, Closure Properties Nondeterminism, Why so Many Models? Streaming Algorithms 0 42 Deterministic Finite Automata Anatomy of Deterministic Finite Automata transition: for

More information

Applied Computer Science II Chapter 1 : Regular Languages

Applied Computer Science II Chapter 1 : Regular Languages Applied Computer Science II Chapter 1 : Regular Languages Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany Overview Deterministic finite automata Regular languages

More information

September 7, Formal Definition of a Nondeterministic Finite Automaton

September 7, Formal Definition of a Nondeterministic Finite Automaton Formal Definition of a Nondeterministic Finite Automaton September 7, 2014 A comment first The formal definition of an NFA is similar to that of a DFA. Both have states, an alphabet, transition function,

More information

UNIT-III REGULAR LANGUAGES

UNIT-III REGULAR LANGUAGES Syllabus R9 Regulation REGULAR EXPRESSIONS UNIT-III REGULAR LANGUAGES Regular expressions are useful for representing certain sets of strings in an algebraic fashion. In arithmetic we can use the operations

More information

Context Free Languages (CFL) Language Recognizer A device that accepts valid strings. The FA are formalized types of language recognizer.

Context Free Languages (CFL) Language Recognizer A device that accepts valid strings. The FA are formalized types of language recognizer. Context Free Languages (CFL) Language Recognizer A device that accepts valid strings. The FA are formalized types of language recognizer. Language Generator: Context free grammars are language generators,

More information

Computational Models - Lecture 4 1

Computational Models - Lecture 4 1 Computational Models - Lecture 4 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. April 3/8, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

CS21 Decidability and Tractability

CS21 Decidability and Tractability CS21 Decidability and Tractability Lecture 2 January 5, 2018 January 5, 2018 CS21 Lecture 2 1 Outline Finite Automata Nondeterministic Finite Automata Closure under regular operations NFA, FA equivalence

More information

The View Over The Horizon

The View Over The Horizon The View Over The Horizon enumerable decidable context free regular Context-Free Grammars An example of a context free grammar, G 1 : A 0A1 A B B # Terminology: Each line is a substitution rule or production.

More information

Intro to Theory of Computation

Intro to Theory of Computation Intro to Theory of Computation 1/19/2016 LECTURE 3 Last time: DFAs and NFAs Operations on languages Today: Nondeterminism Equivalence of NFAs and DFAs Closure properties of regular languages Sofya Raskhodnikova

More information

Chapter Five: Nondeterministic Finite Automata

Chapter Five: Nondeterministic Finite Automata Chapter Five: Nondeterministic Finite Automata From DFA to NFA A DFA has exactly one transition from every state on every symbol in the alphabet. By relaxing this requirement we get a related but more

More information

Outline. CS21 Decidability and Tractability. Regular expressions and FA. Regular expressions and FA. Regular expressions and FA

Outline. CS21 Decidability and Tractability. Regular expressions and FA. Regular expressions and FA. Regular expressions and FA Outline CS21 Decidability and Tractability Lecture 4 January 14, 2019 FA and Regular Exressions Non-regular languages: Puming Lemma Pushdown Automata Context-Free Grammars and Languages January 14, 2019

More information

Lecture 17: Language Recognition

Lecture 17: Language Recognition Lecture 17: Language Recognition Finite State Automata Deterministic and Non-Deterministic Finite Automata Regular Expressions Push-Down Automata Turing Machines Modeling Computation When attempting to

More information

Theory of Computation (IX) Yijia Chen Fudan University

Theory of Computation (IX) Yijia Chen Fudan University Theory of Computation (IX) Yijia Chen Fudan University Review The Definition of Algorithm Polynomials and their roots A polynomial is a sum of terms, where each term is a product of certain variables and

More information

Lecture 3: Nondeterministic Finite Automata

Lecture 3: Nondeterministic Finite Automata Lecture 3: Nondeterministic Finite Automata September 5, 206 CS 00 Theory of Computation As a recap of last lecture, recall that a deterministic finite automaton (DFA) consists of (Q, Σ, δ, q 0, F ) where

More information

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

Incorrect reasoning about RL. Equivalence of NFA, DFA. Epsilon Closure. Proving equivalence. One direction is easy: Incorrect reasoning about RL Since L 1 = {w w=a n, n N}, L 2 = {w w = b n, n N} are regular, therefore L 1 L 2 = {w w=a n b n, n N} is regular If L 1 is a regular language, then L 2 = {w R w L 1 } is regular,

More information

Computational Theory

Computational Theory Computational Theory Finite Automata and Regular Languages Curtis Larsen Dixie State University Computing and Design Fall 2018 Adapted from notes by Russ Ross Adapted from notes by Harry Lewis Curtis Larsen

More information

CS21 Decidability and Tractability

CS21 Decidability and Tractability CS21 Decidability and Tractability Lecture 3 January 9, 2017 January 9, 2017 CS21 Lecture 3 1 Outline NFA, FA equivalence Regular Expressions FA and Regular Expressions January 9, 2017 CS21 Lecture 3 2

More information

Context Free Grammars

Context Free Grammars Automata and Formal Languages Context Free Grammars Sipser pages 101-111 Lecture 11 Tim Sheard 1 Formal Languages 1. Context free languages provide a convenient notation for recursive description of languages.

More information

10. The GNFA method is used to show that

10. The GNFA method is used to show that CSE 355 Midterm Examination 27 February 27 Last Name Sample ASU ID First Name(s) Ima Exam # Sample Regrading of Midterms If you believe that your grade has not been recorded correctly, return the entire

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation CISC 4090 Theory of Computation Context-Free Languages and Push Down Automata Professor Daniel Leeds dleeds@fordham.edu JMH 332 Languages: Regular and Beyond Regular: a b c b d e a Not-regular: c n bd

More information

Lecture 4: More on Regexps, Non-Regular Languages

Lecture 4: More on Regexps, Non-Regular Languages 6.045 Lecture 4: More on Regexps, Non-Regular Languages 6.045 Announcements: - Pset 1 is on piazza (as of last night) - If you don t have piazza access but are registered for 6.045, send email to TAs with

More information

Automata: a short introduction

Automata: a short introduction ILIAS, University of Luxembourg Discrete Mathematics II May 2012 What is a computer? Real computers are complicated; We abstract up to an essential model of computation; We begin with the simplest possible

More information

Pushdown Automata. Notes on Automata and Theory of Computation. Chia-Ping Chen

Pushdown Automata. Notes on Automata and Theory of Computation. Chia-Ping Chen Pushdown Automata Notes on Automata and Theory of Computation Chia-Ping Chen Department of Computer Science and Engineering National Sun Yat-Sen University Kaohsiung, Taiwan ROC Pushdown Automata p. 1

More information

Inf2A: Converting from NFAs to DFAs and Closure Properties

Inf2A: Converting from NFAs to DFAs and Closure Properties 1/43 Inf2A: Converting from NFAs to DFAs and Stuart Anderson School of Informatics University of Edinburgh October 13, 2009 Starter Questions 2/43 1 Can you devise a way of testing for any FSM M whether

More information

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

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r Syllabus R9 Regulation UNIT-II NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: In the automata theory, a nondeterministic finite automaton (NFA) or nondeterministic finite state machine is a finite

More information

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

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS Automata Theory Lecture on Discussion Course of CS2 This Lecture is about Mathematical Models of Computation. Why Should I Care? - Ways of thinking. - Theory can drive practice. - Don t be an Instrumentalist.

More information

Computational Models Lecture 2 1

Computational Models Lecture 2 1 Computational Models Lecture 2 1 Handout Mode Iftach Haitner. Tel Aviv University. October 30, 2017 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.

More information

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

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova. Introduction to the Theory of Computation Automata 1VO + 1PS Lecturer: Dr. Ana Sokolova http://cs.uni-salzburg.at/~anas/ Setup and Dates Lectures and Instructions 23.10. 3.11. 17.11. 24.11. 1.12. 11.12.

More information

Computational Models Lecture 2 1

Computational Models Lecture 2 1 Computational Models Lecture 2 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. March 16/18, 2015 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3},

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3}, Code No: 07A50501 R07 Set No. 2 III B.Tech I Semester Examinations,MAY 2011 FORMAL LANGUAGES AND AUTOMATA THEORY Computer Science And Engineering Time: 3 hours Max Marks: 80 Answer any FIVE Questions All

More information

Introduction to Languages and Computation

Introduction to Languages and Computation Introduction to Languages and Computation George Voutsadakis 1 1 Mathematics and Computer Science Lake Superior State University LSSU Math 400 George Voutsadakis (LSSU) Languages and Computation July 2014

More information

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

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova. Introduction to the Theory of Computation Automata 1VO + 1PS Lecturer: Dr. Ana Sokolova http://cs.uni-salzburg.at/~anas/ Setup and Dates Lectures Tuesday 10:45 pm - 12:15 pm Instructions Tuesday 12:30

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation 9/2/28 Stereotypical computer CISC 49 Theory of Computation Finite state machines & Regular languages Professor Daniel Leeds dleeds@fordham.edu JMH 332 Central processing unit (CPU) performs all the instructions

More information

Computability and Complexity

Computability and Complexity Computability and Complexity Rewriting Systems and Chomsky Grammars CAS 705 Ryszard Janicki Department of Computing and Software McMaster University Hamilton, Ontario, Canada janicki@mcmaster.ca Ryszard

More information

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

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties Recall a closure property is a statement

More information

CS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF)

CS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF) CS5371 Theory of Computation Lecture 7: Automata Theory V (CFG, CFL, CNF) Announcement Homework 2 will be given soon (before Tue) Due date: Oct 31 (Tue), before class Midterm: Nov 3, (Fri), first hour

More information

Closure under the Regular Operations

Closure under the Regular Operations Closure under the Regular Operations Application of NFA Now we use the NFA to show that collection of regular languages is closed under regular operations union, concatenation, and star Earlier we have

More information

Final exam study sheet for CS3719 Turing machines and decidability.

Final exam study sheet for CS3719 Turing machines and decidability. Final exam study sheet for CS3719 Turing machines and decidability. A Turing machine is a finite automaton with an infinite memory (tape). Formally, a Turing machine is a 6-tuple M = (Q, Σ, Γ, δ, q 0,

More information

Non-deterministic Finite Automata (NFAs)

Non-deterministic Finite Automata (NFAs) Algorithms & Models of Computation CS/ECE 374, Fall 27 Non-deterministic Finite Automata (NFAs) Part I NFA Introduction Lecture 4 Thursday, September 7, 27 Sariel Har-Peled (UIUC) CS374 Fall 27 / 39 Sariel

More information

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministic Finite Automata Lecture 6 Section 2.2 Robb T. Koether Hampden-Sydney College Mon, Sep 5, 2016 Robb T. Koether (Hampden-Sydney College) Nondeterministic Finite Automata Mon, Sep 5, 2016

More information

CPS 220 Theory of Computation REGULAR LANGUAGES

CPS 220 Theory of Computation REGULAR LANGUAGES CPS 22 Theory of Computation REGULAR LANGUAGES Introduction Model (def) a miniature representation of a thing; sometimes a facsimile Iraq village mockup for the Marines Scientific modelling - the process

More information

DM17. Beregnelighed. Jacob Aae Mikkelsen

DM17. Beregnelighed. Jacob Aae Mikkelsen DM17 Beregnelighed Jacob Aae Mikkelsen January 12, 2007 CONTENTS Contents 1 Introduction 2 1.1 Operations with languages...................... 2 2 Finite Automata 3 2.1 Regular expressions/languages....................

More information

Chapter 3. Regular grammars

Chapter 3. Regular grammars Chapter 3 Regular grammars 59 3.1 Introduction Other view of the concept of language: not the formalization of the notion of effective procedure, but set of words satisfying a given set of rules Origin

More information

Formal Languages, Automata and Models of Computation

Formal Languages, Automata and Models of Computation CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2011 1 Content - More Properties of Regular Languages (RL)

More information

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I Internal Examination 2017-18 B.Tech III Year VI Semester Sub: Theory of Computation (6CS3A) Time: 1 Hour 30 min. Max Marks: 40 Note: Attempt all three

More information

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

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont ) CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont ) Sungjin Im University of California, Merced 2-3-214 Example II A ɛ B ɛ D F C E Example II A ɛ B ɛ D F C E NFA accepting

More information

Theory of Computation (VI) Yijia Chen Fudan University

Theory of Computation (VI) Yijia Chen Fudan University Theory of Computation (VI) Yijia Chen Fudan University Review Forced handles Definition A handle h of a valid string v = xhy is a forced handle if h is the unique handle in every valid string xhŷ where

More information

Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular OctoberExpressions

Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular OctoberExpressions Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular Expressions Orit Moskovich Gal Rotem Tel Aviv University October 28, 2015 Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular

More information

1.3 Regular Expressions

1.3 Regular Expressions 51 1.3 Regular Expressions These have an important role in descriing patterns in searching for strings in many applications (e.g. awk, grep, Perl,...) All regular expressions of alphaet are 1.Øand are

More information

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET Regular Languages and FA A language is a set of strings over a finite alphabet Σ. All languages are finite or countably infinite. The set of all languages

More information

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever.  ETH Zürich (D-ITET) September, Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu ETH Zürich (D-ITET) September, 24 2015 Last week was all about Deterministic Finite Automaton We saw three main

More information

Nondeterministic Finite Automata. Nondeterminism Subset Construction

Nondeterministic Finite Automata. Nondeterminism Subset Construction Nondeterministic Finite Automata Nondeterminism Subset Construction 1 Nondeterminism A nondeterministic finite automaton has the ability to be in several states at once. Transitions from a state on an

More information

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

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010 University of Virginia - cs3102: Theory of Computation Spring 2010 PS2 - Comments Average: 77.4 (full credit for each question is 100 points) Distribution (of 54 submissions): 90, 12; 80 89, 11; 70-79,

More information

Equivalence of DFAs and NFAs

Equivalence of DFAs and NFAs CS 172: Computability and Complexity Equivalence of DFAs and NFAs It s a tie! DFA NFA Sanjit A. Seshia EECS, UC Berkeley Acknowledgments: L.von Ahn, L. Blum, M. Blum What we ll do today Prove that DFAs

More information

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam ECS 120: Theory of Computation Handout MT UC Davis Phillip Rogaway February 16, 2012 Midterm Exam Instructions: The exam has six pages, including this cover page, printed out two-sided (no more wasted

More information

Name: Student ID: Instructions:

Name: Student ID: Instructions: Instructions: Name: CSE 322 Autumn 2001: Midterm Exam (closed book, closed notes except for 1-page summary) Total: 100 points, 5 questions, 20 points each. Time: 50 minutes 1. Write your name and student

More information

Critical CS Questions

Critical CS Questions Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Critical CS Questions What is a computer? And What is a Computation? real computers too complex for any

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION FORMAL LANGUAGES, AUTOMATA AND COMPUTATION IDENTIFYING NONREGULAR LANGUAGES PUMPING LEMMA Carnegie Mellon University in Qatar (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011

More information

Uses of finite automata

Uses of finite automata Chapter 2 :Finite Automata 2.1 Finite Automata Automata are computational devices to solve language recognition problems. Language recognition problem is to determine whether a word belongs to a language.

More information

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

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2 5-25 Great Theoretical Ideas in Computer Science Lecture 4: Deterministic Finite Automaton (DFA), Part 2 January 26th, 27 Formal definition: DFA A deterministic finite automaton (DFA) M =(Q,,,q,F) M is

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation CISC 4090 Theory of Computation Context-Free Languages and Push Down Automata Professor Daniel Leeds dleeds@fordham.edu JMH 332 Languages: Regular and Beyond Regular: Captured by Regular Operations a b

More information

Foundations of Informatics: a Bridging Course

Foundations of Informatics: a Bridging Course Foundations of Informatics: a Bridging Course Week 3: Formal Languages and Semantics Thomas Noll Lehrstuhl für Informatik 2 RWTH Aachen University noll@cs.rwth-aachen.de http://www.b-it-center.de/wob/en/view/class211_id948.html

More information

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

Unit 6. Non Regular Languages The Pumping Lemma. Reading: Sipser, chapter 1 Unit 6 Non Regular Languages The Pumping Lemma Reading: Sipser, chapter 1 1 Are all languages regular? No! Most of the languages are not regular! Why? A finite automaton has limited memory. How can we

More information

CS5371 Theory of Computation. Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)

CS5371 Theory of Computation. Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression) CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression) Objectives Prove the Pumping Lemma, and use it to show that there are non-regular languages

More information

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever.  ETH Zürich (D-ITET) September, Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu ETH Zürich (D-ITET) September, 28 2017 Part 2 out of 5 Last week was all about Deterministic Finite Automaton

More information

The Pumping Lemma and Closure Properties

The Pumping Lemma and Closure Properties The Pumping Lemma and Closure Properties Mridul Aanjaneya Stanford University July 5, 2012 Mridul Aanjaneya Automata Theory 1/ 27 Tentative Schedule HW #1: Out (07/03), Due (07/11) HW #2: Out (07/10),

More information

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

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa CS:4330 Theory of Computation Spring 2018 Regular Languages Finite Automata and Regular Expressions Haniel Barbosa Readings for this lecture Chapter 1 of [Sipser 1996], 3rd edition. Sections 1.1 and 1.3.

More information

Computational Models - Lecture 3 1

Computational Models - Lecture 3 1 Computational Models - Lecture 3 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. March 13/18, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information