Technische Universität München Winter term 2009/10 I7 Prof. J. Esparza / J. Křetínský / M. Luttenberger 11. Februar Solution

Similar documents
CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

Minimal DFA. minimal DFA for L starting from any other

= state, a = reading and q j

Nondeterministic Automata vs Deterministic Automata

CS 573 Automata Theory and Formal Languages

Lecture 08: Feb. 08, 2019

Regular languages refresher

NON-DETERMINISTIC FSA

Formal Languages and Automata

Regular expressions, Finite Automata, transition graphs are all the same!!

Nondeterministic Finite Automata

Myhill-Nerode Theorem

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

Lecture 09: Myhill-Nerode Theorem

Finite State Automata and Determinisation

More on automata. Michael George. March 24 April 7, 2014

State Minimization for DFAs

Theory of Computation Regular Languages

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER MACHINES AND THEIR LANGUAGES ANSWERS

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

Coalgebra, Lecture 15: Equations for Deterministic Automata

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

Convert the NFA into DFA

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

Fundamentals of Computer Science

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30

CMSC 330: Organization of Programming Languages

DFA minimisation using the Myhill-Nerode theorem

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Bisimulation, Games & Hennessy Milner logic

Discrete Structures, Test 2 Monday, March 28, 2016 SOLUTIONS, VERSION α

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

Homework 3 Solutions

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model?

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

Worked out examples Finite Automata

Chapter 2 Finite Automata

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Prefix-Free Regular-Expression Matching

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Finite Automata-cont d

System Validation (IN4387) November 2, 2012, 14:00-17:00

2.4 Theoretical Foundations

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

Designing finite automata II

KENDRIYA VIDYALAYA IIT KANPUR HOME ASSIGNMENTS FOR SUMMER VACATIONS CLASS - XII MATHEMATICS (Relations and Functions & Binary Operations)

Solutions for HW9. Bipartite: put the red vertices in V 1 and the black in V 2. Not bipartite!

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

Non-deterministic Finite Automata

1 Nondeterministic Finite Automata

Math 4310 Solutions to homework 1 Due 9/1/16

Harvard University Computer Science 121 Midterm October 23, 2012

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

State Complexity of Union and Intersection of Binary Suffix-Free Languages

Tutorial Automata and formal Languages

Descriptional Complexity of Non-Unary Self-Verifying Symmetric Difference Automata

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

Non-deterministic Finite Automata

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages

p-adic Egyptian Fractions

CISC 4090 Theory of Computation

1.4 Nonregular Languages

1 From NFA to regular expression

Finite-State Automata: Recap

CHAPTER 1 Regular Languages. Contents

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

Hybrid Systems Modeling, Analysis and Control

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

Homework Solution - Set 5 Due: Friday 10/03/08

CS241 Week 6 Tutorial Solutions

Algorithms & Data Structures Homework 8 HS 18 Exercise Class (Room & TA): Submitted by: Peer Feedback by: Points:

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

Formal languages, automata, and theory of computation

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.

Parse trees, ambiguity, and Chomsky normal form

Introduction to Olympiad Inequalities

Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem 2/16/15

1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides.

Project 6: Minigoals Towards Simplifying and Rewriting Expressions

Nondeterminism and Nodeterministic Automata

Some Theory of Computation Exercises Week 1

Java II Finite Automata I

Tutorial Worksheet. 1. Find all solutions to the linear system by following the given steps. x + 2y + 3z = 2 2x + 3y + z = 4.

CS 330 Formal Methods and Models

GNFA GNFA GNFA GNFA GNFA

Running an NFA & the subset algorithm (NFA->DFA) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

Exercises Chapter 1. Exercise 1.1. Let Σ be an alphabet. Prove wv = w + v for all strings w and v.

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions

Farey Fractions. Rickard Fernström. U.U.D.M. Project Report 2017:24. Department of Mathematics Uppsala University

Compression of Palindromes and Regularity.

CONTROLLABILITY and observability are the central

Chapter 3. Vector Spaces. 3.1 Images and Image Arithmetic

Transcription:

Tehnishe Universität Münhen Winter term 29/ I7 Prof. J. Esprz / J. Křetínský / M. Luttenerger. Ferur 2 Solution Automt nd Forml Lnguges Homework 2 Due 5..29. Exerise 2. Let A e the following finite utomton: strt, () Trnsform the utomton A into n equivlent regulr expression, then trnsform this expression into n NFA (with ε-trnsitions), remove the ε-trnsitions, determinize the utomton nd then minimize it using the lgorithms from the leture. Chek tht the resulting utomton is isomorphi to the originl one. () Use JFLAP (http://www.jflp.org/) to perform the sme trnsformtions. Is there ny differene? () Let us denote Σ = {, }. Then L(A) = Σ \ Σ Σ. Prove tht A is miniml y proving tht no equivlene reltion on Σ of index t most 2 n stisfy x y w(xw L(A) yw L(A)) (nd thus onluding y Nerode theorem); omputing the index of L(A) (nd if it is 3 then onluding y Myhill-Nerode theorem); performing the Bisim lgorithm for minimiztion (nd heking the result is isomorphi to the originl utomton). Exerise 2.2 For n N let msf(n) e the lnguge of ll words over {, } whih represent n w.r.t. to the most signifint it first representtion where n ritrry numer of leding zeros is llowed. For exmple: msf(3) = L( ) nd msf() = L( ). Similrly, let lsf(n) denote the lnguge of ll lest signifint it first representtions of n with n ritrry numer of following zeros, e.g.: lsf(6) = L( ) nd lsf() = L( ). () Construt nd ompre the miniml DFAs representing ll even nturl numers n N w.r.t. the unry enoding (i.e., n n ), the msf enoding, nd the lsf enoding. () Consider the following FA A over the lphet {,,, }: strt

W.r.t. the msf enoding, we my interpret ny word w {,,, } s pir of nturl numers (X(w), Y (w)) N N. Exmple : (Underlined letters orrespond to Y (w).) w = () k () k ( k, k ) (3, ) = (X(w), Y (w)) Find onstnts, Z suh tht X(w) + Y (w) = for ll w L(A). () Construt the miniml DFA representing the lnguge {w {, } msf (w) is divisile y 3}. Solution: () Unry enoding: MSBF enoding: strt strt LSBF enoding:, strt, () We lel the sttes s follows: strt 2 We show y indution on the length of word w Σ tht for δ(, w) = q we hve 3Y (w) X(w) = q. Oviously, this will then imply tht 3Y (w) X(w) = for ll w L(A). Let l denote the length of word w (w.r.t. the lphet {,,, }). l = : We hve w = ε nd oth δ(, ε) = nd X(w) = = Y (w). l l + : We my write w s u with, {, }. Note tht we then hve X(w) = 2X(u) + nd Y (w) = 2Y (w) +. Assume tht δ(, w) =: q is defined, otherwise there is nothing to show. Then lso δ(, u) =: q is defined. By indution hypothesis we hve 3Y (u) X(u) = q. Assume q = q = : Then =, = hs to hold, i.e., X(w) = 2X(u) nd Y (w) = 2Y (u). Hene, 3Y (w) X(w) = 3 2Y (u) 2X(u) = 2(3Y (u) X(u)) = 2 q = 2 = = q.

Assume q = q =. Then =, =, nd X(w) = 2X(u) + nd Y (w) = 2Y (u) + susequently follow, leding to: 3Y (w) X(w) = 3 (2Y (u) + ) (2X(u) + ) = 2(3Y (u) X(u)) + 2 = 2 q + 2 = 2 ( ) + 2 = = q. Similrly, the remining ses follow. One n even show tht A epts extly those words w with 3Y (w) X(w) =. For this, let w = u e word suh tht δ(, u) is defined, ut δ(, w) is undefined, i.e., is the rejeting stte. Assume δ(, u) =. Then either = or =. We only onsider the se =, s the se = is quite similr. Then y our preeding result we hve 3Y (u) X(u) =, whih leds to 3Y (w) X(w) = 3(2Y (u) + ) 2X(u) = 3. Assume we dd letter xy to w. In order to lulte 3Y (wxy) X(wxy) we doule the vlue 3Y (w) X(w) nd then dd numer from {,, 2, 3}. Hene, 5 = 2(3Y (w) X(w)) 3Y (wxy) X(wxy) 2(3Y (w) X(w)) + 3 = 9, i.e., no mtter how we extend w y some word u {,,, }, we never will e le to otin 3Y (wu) X(wu). Similrly, one shows for the other ses of δ(, u) tht ll words leding to the rejeting stte nnot stisfy the liner eqution 3y x =. () The ide is tht the stte rehed fter reding the word u orresponds to the reminder of the numer represented y u when dividing y 3. We therefore tke s sttes {,, 2} with the initil stte nd define This yields the utomton: δ(q, ) = 2q + (mod 3). strt 2 Oviously, this utomton hs to e miniml s two different sttes enode two different reminder lsses. Note tht we lso otin this utomton from the one of () y forgetting (projeting) the y-omponent. Exerise 2.3 In the leture you hve seen the definition of the Myhill-Nerode reltion L for given lnguge L Σ : For two words x, y Σ we write x L y iff xv L yv L holds for ll v Σ. () Determine the equivlene lsses of L w.r.t. the following lnguges over Σ = {, }: L := L(( + ) ), L 2 := L(() ), L 3 := {w {, } the numer of ourrenes of nd in w is the sme }. L 4 := { n n n n }. () In the definition of L we ompre two given words y ppending ll possile words. Insted of ppending, we my lso prepend. Consider therefore the inry reltion L on Σ defined y For two words x, y Σ we write x L y iff ux L uy L holds for ll u Σ. Determine the equivlene lsses of L nd L2. Show tht L is regulr iff L hs only finitely mny equivlene lsses. Is the numer of equivlene lsses of L equl to the one of L? () Finlly, we my ompre two words x, y lso y ppending nd prepending ritrry words, i.e., define the reltion L s follows:

For two words x, y Σ we write x L y iff uxv L uzv L holds for ll u, v Σ. For x Σ let [x] L denote the equivlene lss of x w.r.t. L, i.e., [x] L = {t Σ x L y}. We write Σ / L for the set of equivlene lsses. How does L relte to L, resp. L? Determine the equivlene lsses of L2. Show tht the following multiplition on Σ / L is well-defined, ssoitive nd hs [ε] L s its neutrl element: Remrk : Σ / L is lled the syntti monoid of L. [w] L [w ] L := [ww ] L. Solution: () Reminder : For L Σ, the reltion L on Σ ws defined y x L y iff z Σ : xz L yz L. Let A = (Q, Σ, δ, q I, F ) e DFA. Set P (q) = {x Σ δ(q I, x) = q} for q Q. Oviously, for x, y P (q) we hve for ny word v Σ tht δ(q initil, xv) = δ(δ(q initil, x), v) = δ(q, v) = δ(δ(q initil, y), v) = δ(q initil, yv). s the utomton is deterministi, i.e., x, y P (q) x L y. Hene, the prtition {P (q) q Q} is refinement of Σ / L. So, if A is lso miniml, then we even hve x, y P (q) x L y. Hene, for lulting the equvilene lsses of regulr lnguge L it suffies to onstrut miniml DFA for L nd otin from it the lnguges P (q). L : q strt q q 3, q 2 P (q ) = L(( + ) ), P (q ) = L(( + ) ), P (q 2 ) = L(( + ) ) nd P (q 3 ) = L(( + ) ( + )). L 2 : q strt q q 2 P (q ) = L(() ), P (q ) = L(() )) nd P (q 2 ) = L(() ( + )). L 3 :,

q q 2 strt q q 3 q 4 It s left to the reder to determine the equivlene lsses from the DFA. L 4 : Although L 4 is ontext-sensitive, ut neither ontext-free nor regulr, the sme ide s for the preeding lnguges n e used, leit one hs to onsider n utomton with infinite numer of sttes (the rejeting stte isn t shown here): strt One esily heks tht ny two sttes re inequivlent. We otin the equivlene lsses: { k } for k, { k l } for k > l, { k+l k+l l l } for k, nd the omplement of the union of these. () For w Σ let w R e its reverse, i.e., the word we otin when reding w from right to left, e.g., () R =. For L Σ we then set L R := {w R w L}. It is well-known tht L is regulr if nd only if L R is regulr (exerise!). Consider the definition of L now: x L y iff u Σ ux L uy L iff u Σ (ux) R L R (uy) R L R iff u Σ x R u R L R y R u R L R iff v Σ x R v L R y R v L R iff v Σ x R v L R y R v L R iff x R L R y R. The ruil point here is tht u R is ny possile word s we onsider ll u Σ whih llows us to reple u R nd u y v. This mens tht we n otin the equivlene lsses of L from those of L R y simply reversing the memers of the equivlene lsses, nd we lredy know how to otin the equivlene lsses of L R (see ()). In oth ses, L nd L 2, L R i = L i, so we hve lredy otined the sought equivlene lsses in ().

It lso immeditely follows tht L is finite iff L is regulr, s L = L R nd we know tht (i) L is regulr iff L R is regulr, nd (ii) L R is regulr iff L R is finite. Finlly, we show tht in generl L nd L do not need to hve the sme numer of lsses: Let L Σ onsist of those words whose third letter is n. It is esy to see tht miniml DFA for L onsists of 4 + sttes; four sttes re required to ount how mny letters hve lredy een red, while the fifth stte is the rejeting stte. On the other hnd, L R onsists of ll words whose third lst letter is n. A orresponding miniml DFA hs to rememer the lst seen within window of three letters, leding to the equivlene lsses [ε], [], [], [], [], [], [], []: strt ε () Oviously, x L y implies oth x L y nd x L y. But in generl, L hs more equivlene lsses thn L or L. Consider for exmple L : We hve oth ε L nd ε L, ut ε L s ε L, ut () L. (See lso exerise 3.2.) In the se of L 2 one esily heks x L2 y iff x L2 y It remins to show tht the defined multiplition on Σ / L is independent of the representtive tken from the equivlene lss. Choose x, y, x, y Σ s.t. x L x nd y L y. We hve to show tht xy L x y : x L x implies xy L x y. (Set v = yv in the definition with v Σ ). y L y implies x y L x y. (Set u = u x in the definition with u Σ.) As L is equivlene reltion, it is trnsitive, nd we otin xy L x y. Exerise 2.4 Let Σ e n lphet. The set S Σ of str-free expression over Σ is indutively defined: S := Σ {ε, } S k+ := {(φ + ψ), (φ ψ), φ, (φ ψ) φ, ψ S k } S k S Σ := k N Sk. The lnguge L(ρ) represented y str-free expression ρ S Σ is defined s expeted: if ρ = L(φ) L(ψ) if ρ = (φ + ψ) L(ρ) := {ρ} if ρ Σ {ε} L(φ) L(ψ) if ρ = (φ ψ) Σ \ L(φ) if ρ = φ L(φ) L(ψ) if ρ = (φ ψ). To void prentheses, we ssume tht ontention hs the highest priority, followed y intersetion, then ddition. Some exmples: L( ) = Σ \ L( ) = Σ, L( ( + )) = {}. () Show tht for every str-free expression φ S Σ it holds tht L(φ) is regulr lnguges over Σ. () Give str-free expression for the regulr lnguge L(() ) for Σ = {, }. Remrk : There is no str-free expression for the lnguge L(() )!

Solution: () We lim tht Note tht L( ) = Σ = L(( + ) ). So we my write: L( ( + ) )! = L(()() ). L( + ) = L(( + ) ) \ L(( + ) ( + )( + ) ). This follows from strightforwrd indution on the term struture using tht regulr lnguges re losed under union, intersetion nd omplement. L(( + ) ) \ L(( + ) ( + )( + ) ) L(()() ): Consider w = () k for some k. Clerly, w L(( + ) ). Further, neither nor pper s suwords in w, so w L(Σ ( + )Σ ). L(( + ) ) \ L(( + ) ( + )( + ) ) L(()() ): Choose some w L(( + ) ) \ L(( + ) ( + )( + ) ). (Note tht this lnguge is not empty s it ontins the word.) Oviously, w ε. One now shows y indution on the length of w, tht the letters nd hve to lternte in w nd tht w hs to e of even length (s it strts with n, ut ends with ). So, w L(()() ). It follows tht L(() ) = L(ε + ( + ) ).