Some Theory of Computation Exercises Week 1

Similar documents
Homework 3 Solutions

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

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*

Worked out examples Finite Automata

Designing finite automata II

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

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

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

CISC 4090 Theory of Computation

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.

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

Lecture 08: Feb. 08, 2019

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

1 Nondeterministic Finite Automata

Finite-State Automata: Recap

CHAPTER 1 Regular Languages. Contents

Deterministic Finite Automata

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

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

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

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

CS 330 Formal Methods and Models

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

Finite Automata-cont d

Non-deterministic Finite Automata

Harvard University Computer Science 121 Midterm October 23, 2012

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

1 From NFA to regular expression

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

Chapter 2 Finite Automata

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

NFAs continued, Closure Properties of Regular Languages

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama

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

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

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

Let's start with an example:

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010

Non-Deterministic Finite Automata

Formal Language and Automata Theory (CS21004)

Theory of Computation Regular Languages

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

Convert the NFA into DFA

Minimal DFA. minimal DFA for L starting from any other

Chapter 1, Part 1. Regular Languages. CSC527, Chapter 1, Part 1 c 2012 Mitsunori Ogihara 1

Name Ima Sample ASU ID

Lecture 09: Myhill-Nerode Theorem

Formal languages, automata, and theory of computation

Non Deterministic Automata. Formal Languages and Automata - Yonsei CS 1

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

Languages & Automata

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

Non-deterministic Finite Automata

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

CS 330 Formal Methods and Models

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 Minimization for DFAs

Nondeterminism and Nodeterministic Automata

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

CMSC 330: Organization of Programming Languages

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

Chapter 4 Regular Grammar and Regular Sets. (Solutions / Hints)

Formal Languages and Automata

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

Fundamentals of Computer Science

Turing Machines Part One

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

CS375: Logic and Theory of Computing

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers

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

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa

NFAs continued, Closure Properties of Regular Languages

Java II Finite Automata I

In-depth introduction to main models, concepts of theory of computation:

CS375: Logic and Theory of Computing

Revision Sheet. (a) Give a regular expression for each of the following languages:

Thoery of Automata CS402

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings...

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science

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

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

CS 330 Formal Methods and Models

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

Section: Other Models of Turing Machines. Definition: Two automata are equivalent if they accept the same language.

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

input tape head moves current state

E 1 (n) = E 0 (n-1) E 0 (n) = E 0 (n-1)+e 0 (n-2) T(n -1)=2E 0 (n-2) + E 0 (n-3)

Midterm 1 Practice. CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

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.

1.4 Nonregular Languages

1.3 Regular Expressions

SWEN 224 Formal Foundations of Programming WITH ANSWERS

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

CSC 311 Theory of Computation

3 Regular expressions

FABER Formal Languages, Automata and Models of Computation

Deterministic Finite-State Automata

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

Transcription:

Some Theory of Computtion Exercises Week 1 Section 1 Deterministic Finite Automt Question 1.3 d d d d u q 1 q 2 q 3 q 4 q 5 d u u u u Question 1.4 Prt c - {w w hs even s nd one or two s} First we sk whether w hs n even numer of s, which requires two sttes one to signify tht n even numer of s hs een oserved thus fr, nd one to signify tht n odd numer hve een oserved thus fr: Next we must determine whether w contins precisely one or two s, which needs four sttes: initiliztion, single, two s nd the filure stte, These two devices must now e comined to crete recogniser for their intersection. Every pir of sttes will e represented y single stte in the new device, so we cn ly it out in 4 2 grid thus: 1

even s odd s 0 s 1 2 s >2s Notice tht the two sttes in the dotted rectngle cn e comined into single stte, s no sequence of chrcters will llow the device to escpe from the ox nd neither stte is n ccepting stte. Question 1.5 Prt h recognise {w w is ny string except, } As suggested in the question we cn first construct device which recognises the complement of this lnguge, nmely {, }, nd then negte its output to find the solution which we re looking for.,, To negte its output we convert ll the ccepting sttes into rejecting sttes nd vice-vers:,,,, Question 1.6 Prt i {w every odd position is 1} This is similr to the even/odd numer of s required in question 1.4 ove. Here we need gdget to keep trck of whether we re looking t n odd/even numered position, which will hed into n ttrcting filure stte if the position is odd nd is not 1. 2

even Here s n odd/even detector, to which we just need to dd the fil stte odd We cn only fil y detecting 0 when the position is odd, so we get something like this: even 1, 0 1 1, 0 Adding tht we ccept if we don t fil odd 0 fil Question 1.33 - multiplying y 3 { ( ) ( ) ( ) ( )} Here Σ = 0 0, 0 1, 1 0, 1 nd we wnt to prove the regulrity of the set of strings from 1 Σ wherein the ottom row is three times the top row, so for exmple: ( 0 0 ( 0 1 1 1 In L Not in L ) ( ) 0 3 =0 0 0 3 1 ) 1 3=3 etc Tle 1. Some exmple strings 1 Since we re given tht regulrity of the reverse of lnguge implies the regulrity of the lnguge, we prove tht L is regulr y constructing DFA which recognises the reverse of L, in which the lest significnt it comes first. For the lnguge to e regulr it must e possile to perform the recognition using n mount of memory which doesn t increse with the length of the input (this is where we record our current stte), nd with ccess only to one symol of input t time. Multiplying y 3 definitely hs this property, s we cn work with 1 column t time nd the crry never exceeds 2. For exmple: C 1 0 1 1 0 0 C 0 1 1 1 1 0 (7) 0 0 1 1 1 (3) 0 0 0 1 1 (7 3) 1 0 1 0 1 3

Reding this from right to left: 1. 1 1=1 + no crry = 1 (output), nd 1 1=1 (new crry stte is 01) 2. 1 1=1 + crry (1) = 10, so output is 0 nd C 0 =1 1 1=1, so we re now crrying 2, C 1 = 1 (1 from ove nd 1 from this) 3. 1 1=1 + crry (2) = 11 (3), so output is 1 nd C 0 =1 1 1=1, so we re still crrying 2 4. 1 0=0 + crry (2) = 10 (2), so output is 0 nd C 0 =1 1 0=0 = 0 so C 1 = 0 5. 1 0=0 + crry (1) = 1, so output is 1 nd C 0 = 0 1 0=0 = 0 so C 1 = 0 So we need 3 sttes, one for no crry, one for single crry nd one for two crries, nd then for ny vlid trnsition the result it must e the lest significnt it of the sum of the input it nd the current crry. The current crry is then updted to e the most significnt it of the sum of input nd old crry + the input; tht gives us the following DFA. Any missing trnsitions led to n inescple filure stte which I hven t drwn in the interests of prsimony. ( ) 1 1 ( 1 0 ) ( ) 0 0 C = 0 C =1 C =2 ( ) 1 1 ( ) 0 1 ( ) 0 0 So for exmple in C = 2 when we see n input it of 1 we re dding 1 1 + 2 = 3 = 11 to the totl, so we expect to see n output it of 1 (the low it), nd crry of t lest 1 (the high it). We re lso dding 1 1 in the next column, so the crry must remin t 2. Similr rguments hold for ll the other vlid trnsitions. 4

Deterministic Finite Automt 1. Exercises in pges 83-84. Exercise 1.1. The strt stte of ech mchine is q 1.. The sets of ccept sttes of M 1 nd M 1 re respectively F={q 2 } nd F={q 1,q 4 }. c. M 1 goes through sttes q 1, q 2, q 3, q 1 nd q 1. M 2 goes through sttes q 1, q 1, q 1, q 2 nd q 4. d. M 1 does not ccept the string. M 1 does. e. M 1 does not ccept ε. M 2 does. Exercise 1.2. Forml description of M 1. Σ={,} Q={q 1,q 2,q 3 } F={q 2 } δ is given y q 1 q 2 q 1 q 2 q 3 q 3 q 3 q 2 q 1. Forml description of M 2. Σ={,} Q={q 1,q 2,q 3,q 4 } F={q 3,q 4 } δ is given y q 1 q 1 q 2 q 2 q 3 q 4 q 3 q 2 q 1 q 4 q 3 q 4

Exercise 1.3

Exercise 1.4. The forml definition of mchine M 1 ccepting the lnguge L(M 1 )={w w hs t lest three 's} is s follows: Σ={,} Q 1 ={s 0,s 1,s 2,s 3 } q 01 = s 0 F 1 ={s 3 } δ is given y s 0 s 1 s 0 s 1 s 2 s 1 s 2 s 3 s 2 s 3 s 3 s 3 The forml definition of mchine M 2 ccepting the lnguge L(M 2 )={w w hs t lest two 's} is s follows: Σ={,} Q 2 ={t 0,t 1,t 2 } q 02 = t 0 F 2 ={t 2 } δ is given y t 0 t 0 t 1 t 1 t 1 t 2 t 2 t 2 t 2

The forml definition of mchine M ccepting the lnguge L(M)={w w hs t lest three 's nd t lest two 's} is s follows: Σ={,} Q=Q 1 Q 2 q 0 = (s 0,t 0 ) F =F 1 xf 2 ={(s 3,t 2 )} δ is given y (s 0,t 0 ) (s 1,t 0 ) (s 0,t 1 ) (s 0,t 1 ) (s 1,t 1 ) (s 0,t 2 ) (s 0,t 2 ) (s 1,t 2 ) (s 0,t 2 ) (s 1,t 0 ) (s 2,t 0 ) (s 1,t 1 ) (s 1,t 1 ) (s 2,t 1 ) (s 1,t 2 ) (s 1,t 2 ) (s 2,t 2 ) (s 1,t 2 ) (s 2,t 0 ) (s 3,t 0 ) (s 2,t 1 ) (s 2,t 1 ) (s 3,t 1 ) (s 2,t 2 ) (s 2,t 2 ) (s 3,t 2 ) (s 2,t 2 ) (s 3,t 0 ) (s 3,t 0 ) (s 3,t 1 ) (s 3,t 1 ) (s 3,t 1 ) (s 3,t 2 ) (s 3,t 2 ) (s 3,t 2 ) (s 3,t 2 )

. The forml definition of mchine M 1 ccepting the lnguge L(M 1 )={w w hs exctly two 's} is s follows: Σ={,} Q 1 ={s 0,s 1,s 2,s 3 } q 01 = s 0 F 1 ={s 2 } δ is given y s 0 s 1 s 0 s 1 s 2 s 1 s 2 s 3 s 2 s 3 s 3 s 3 The forml definition of mchine M 2 ccepting the lnguge L(M 2 )={w w hs t lest two 's} is s follows: Σ={,} Q 2 ={t 0,t 1,t 2 } q 02 = t 0 F 2 ={t 2 } δ is given y t 0 t 0 t 1 t 1 t 1 t 2 t 2 t 2 t 2

The forml definition of mchine M ccepting the lnguge L(M 2 )={w w hs t exctly two 's nd t lest two 's} is s follows: Σ={,} Q=Q 1 Q 2 q 0 = (s 0,t 0 ) F =F 1 xf 2 ={(s 2,t 2 )} δ is given y (s 0,t 0 ) (s 1,t 0 ) (s 0,t 1 ) (s 0,t 1 ) (s 1,t 1 ) (s 0,t 2 ) (s 0,t 2 ) (s 1,t 2 ) (s 0,t 2 ) (s 1,t 0 ) (s 2,t 0 ) (s 1,t 1 ) (s 1,t 1 ) (s 2,t 1 ) (s 1,t 2 ) (s 1,t 2 ) (s 2,t 2 ) (s 1,t 2 ) (s 2,t 0 ) (s 3,t 0 ) (s 2,t 1 ) (s 2,t 1 ) (s 3,t 1 ) (s 2,t 2 ) (s 2,t 2 ) (s 3,t 2 ) (s 2,t 2 ) (s 3,t 0 ) (s 3,t 0 ) (s 3,t 1 ) (s 3,t 1 ) (s 3,t 1 ) (s 3,t 2 ) (s 3,t 2 ) (s 3,t 2 ) (s 3,t 2 )

c. The forml definition of mchine M 1 ccepting the lnguge L(M 1 )={w w hs n even numer of 's} is s follows: Σ={,} Q 1 ={s 0,s 1,s 2 } q 01 = s 0 F 1 ={s 2 } δ is given y s 0 s 1 s 0 s 1 s 2 s 1 s 2 s 1 s 2 The forml definition of mchine M 2 ccepting the lnguge L(M 2 )={w w hs one or two 's} is s follows: Σ={,} Q 2 ={t 0,t 1,t 2,t 3 } q 02 = t 0 F 2 ={t 1,t 2 } δ is given y t 0 t 0 t 1 t 1 t 1 t 2 t 2 t 2 t 3 t 3 t 3 t 3

The forml definition of mchine M ccepting the lnguge L(M)={w w hs n even numer of 's nd one or two 's} is s follows: Σ={,} Q=Q 1 Q 2 q 0 = (s 0,t 0 ) F =F 1 xf 2 ={(s 2,t 1 ),(s 2,t 2 )} δ is given y (s 0,t 0 ) (s 1,t 0 ) (s 0,t 1 ) (s 0,t 1 ) (s 1,t 1 ) (s 0,t 2 ) (s 0,t 2 ) (s 1,t 2 ) (s 0,t 3 ) (s 0,t 3 ) (s 1,t 3 ) (s 0,t 3 ) (s 1,t 0 ) (s 2,t 0 ) (s 1,t 1 ) (s 1,t 1 ) (s 2,t 1 ) (s 1,t 2 ) (s 1,t 2 ) (s 2,t 2 ) (s 1,t 3 ) (s 1,t 3 ) (s 2,t 3 ) (s 1,t 3 ) (s 2,t 0 ) (s 1,t 0 ) (s 2,t 1 ) (s 2,t 1 ) (s 1,t 1 ) (s 2,t 2 ) (s 2,t 2 ) (s 1,t 2 ) (s 2,t 3 ) (s 2,t 3 ) (s 1,t 3 ) (s 2,t 3 )

d. The forml definition of mchine M 1 ccepting the lnguge L(M 1 )={w w hs n even numer of 's} is s follows: Σ={,} Q 1 ={s 0,s 1,s 2 } q 01 = s 0 F 1 ={s 2 } δ is given y s 0 s 1 s 0 s 1 s 2 s 1 s 2 s 1 s 2 The forml definition of mchine M 2 ccepting the lnguge L(M 2 )={w in w ech is followed y t lest one } is s follows: Σ={,} Q 2 ={t 0,t 1,t 2,t 3 } q 02 = t 0 F 2 ={t 0,t 2 } δ is given y t 0 t 1 t 0 t 1 t 3 t 2 t 2 t 1 t 2 t 3 t 3 t 3

The forml definition of mchine M ccepting the lnguge L(M)={w w hs n even numer of 's nd ech is followed y t lest one } is s follows: Σ={,} Q=Q 1 Q 2 q 0 = (s 0,t 0 ) F =F 1 xf 2 ={(s 0,t 0 ),(s 0,t 2 )} δ is given y (s 0,t 0 ) (s 1,t 1 ) (s 0,t 0 ) (s 0,t 1 ) (s 1,t 3 ) (s 0,t 2 ) (s 0,t 2 ) (s 1,t 1 ) (s 0,t 2 ) (s 0,t 3 ) (s 1,t 3 ) (s 0,t 3 ) (s 1,t 0 ) (s 2,t 1 ) (s 1,t 0 ) (s 1,t 1 ) (s 2,t 3 ) (s 1,t 2 ) (s 1,t 2 ) (s 2,t 1 ) (s 1,t 2 ) (s 1,t 3 ) (s 2,t 3 ) (s 1,t 3 ) (s 2,t 0 ) (s 1,t 1 ) (s 2,t 0 ) (s 2,t 1 ) (s 1,t 3 ) (s 2,t 2 ) (s 2,t 2 ) (s 1,t 1 ) (s 2,t 2 ) (s 2,t 3 ) (s 1,t 3 ) (s 2,t 3 ) 2. Not included in this solution sheet.

. The forml definition of mchine M 1 ccepting the lnguge L(M 1 )={w w hs n odd numer of 's} is s follows: Σ={,} Q 1 ={s 0,s 1,s 2 } q 01 = s 0 F 1 ={s 1 } δ is given y s 0 s 1 s 0 s 1 s 2 s 1 s 2 s 1 s 2 The forml definition of mchine M 2 ccepting the lnguge L(M 2 )={w w ends with } is s follows: Σ={,} Q 2 ={t 0,t 1 } q 02 = t 0 F 2 ={t 1 } δ is given y t 0 t 0 t 1 t 1 t 0 t 1

The forml definition of mchine M ccepting the lnguge L(M)={w w hs n odd numer of 's nd ends with } is s follows: Σ={,} Q=Q 1 Q 2 q 0 = (s 0,t 0 ) F =F 1 xf 2 ={(s 1,t 1 )} δ is given y (s 0,t 0 ) (s 1,t 0 ) (s 0,t 1 ) (s 0,t 1 ) (s 1,t 0 ) (s 0,t 1 ) (s 1,t 0 ) (s 2,t 0 ) (s 1,t 1 ) (s 1,t 1 ) (s 2,t 0 ) (s 1,t 1 ) (s 2,t 0 ) (s 1,t 0 ) (s 2,t 1 ) (s 2,t 1 ) (s 1,t 0 ) (s 2,t 1 ). The forml definition of mchine M 1 ccepting the lnguge L(M 1 )={w w hs n even length} is s follows: Σ={,} Q 1 ={s 0,s 1 } q 01 = s 0 F 1 ={s 0 } δ is given y s 0 s 1 s 1 s 1 s 0 s 0

The forml definition of mchine M 2 ccepting the lnguge L(M 2 )={w w hs n odd numer of 's} is s follows: Σ={,} Q 2 ={t 0,t 1,t 2 } q 02 = t 0 F 2 ={t 1 } δ is given y t 0 t 1 t 0 t 1 t 2 t 1 t 2 t 1 t 2 The forml definition of mchine M ccepting the lnguge L(M)={w w hs n even length nd n odd numer of 's} is s follows: Σ={,} Q=Q 1 Q 2 q 0 = (s 0,t 0 ) F =F 1 xf 2 ={(s 0,t 1 )} δ is given y (s 0,t 0 ) (s 1,t 1 ) (s 1,t 0 ) (s 0,t 1 ) (s 1,t 2 ) (s 1,t 1 ) (s 0,t 2 ) (s 1,t 1 ) (s 1,t 2 ) (s 1,t 0 ) (s 0,t 1 ) (s 0,t 0 ) (s 1,t 1 ) (s 0,t 2 ) (s 0,t 1 ) (s 1,t 2 ) (s 0,t 1 ) (s 0,t 2 )

Exercise 1.5. The forml definition of mchine M 1 ccepting the lnguge L(M 1 )={w w contins the sustring } is s follows: Σ={,} Q 1 ={s 0,s 1,s 2 } q 01 = s 0 F 1 ={s 2 } δ is given y s 0 s 1 s 0 s 1 s 1 s 2 s 2 s 2 s 2 A mchine M 2 ccepting the lnguge L(M 2 )={w w does not contin the sustring } is defined y the sme lphet, the sme sttes, the sme trnsition function, the sme strt stte nd set of ccept sttes F 2 =Q- F 1 ={s 0,s 1 }.. The forml definition of mchine M 1 ccepting the lnguge L(M 1 )={w w contins the sustring } is s follows: Σ={,} Q 1 ={s 0,s 1,s 2,s 3,s 4 } q 01 = s 0 F 1 ={s 4 } δ is given y s 0 s 0 s 1 s 1 s 2 s 1 s 2 s 0 s 3 s 3 s 4 s 1 s 4 s 4 s 4

A mchine M 2 ccepting the lnguge L(M 2 )={w w does not contin the sustring } is defined y the sme sttes, the sme trnsition function, the sme strt stte nd set of ccept sttes F 2 =Q-F 1 ={s 0,s 1,s 2,s 3 }. c. The forml definition of mchine M 1 ccepting the lnguge L(M 1 )={w w contins either the sustring or } is s follows: Σ={,} Q 1 ={s 0,s 1,s 2,s 3 } q 01 = s 0 F 1 ={s 3 } δ is given y s 0 s 1 s 2 s 1 s 1 s 3 s 2 s 3 s 2 s 3 s 3 s 3 A mchine M 2 ccepting the lnguge L(M 2 )={w w contins neither the sustring or } is defined y the sme lphet, the sme sttes, the sme trnsition function, the sme strt stte nd set of ccept sttes F 2 =Q- F 1 ={s 0,s 1,s 2 }.

d. The forml definition of mchine M 1 ccepting the lnguge L(M 1 )={w w is ny string in **} is s follows: Σ={,} Q 1 ={s 0,s 1,s 2,s 3,s 4 } q 01 = s 0 F 1 ={s 0,s 1,s 2,s 3 } δ is given y s 0 s 1 s 2 s 1 s 1 s 3 s 2 s 4 s 2 s 3 s 4 s 3 s 4 s 4 s 4 A mchine M 2 ccepting the lnguge L(M 2 )={w w is ny string not in **} is defined y the sme lphet, the sme sttes, the sme trnsition function, the sme strt stte nd set of ccept sttes F 2 =Q-F 1 ={s 4 }.

e. The forml definition of mchine M 1 ccepting the lnguge L(M 1 )={w w is ny string in (+)*} is s follows: Σ={,} Q 1 ={s 0,s 1,s 2,s 3 } q 01 = s 0 F 1 ={s 0,s 3 } δ is given y s 0 s 2 s 1 s 1 s 1 s 1 s 2 s 1 s 3 s 3 s 2 s 3 A mchine M 1 ccepting the lnguge L(M 1 )={w w is ny string not in (+)*} is defined y the sme lphet, the sme sttes, the sme trnsition function, the sme strt stte nd set of ccept sttes F 2 =Q-F 1 ={s 1,s 2 }. f. The forml definition of mchine M 1 ccepting the lnguge L(M 1 )={w w is ny string in *U*} is s follows: Σ={,} Q 1 ={s 0,s 1,s 2,s 3 } q 01 = s 0 F 1 ={s 0,s 1,s 2 } δ is given y s 0 s 1 s 2 s 1 s 1 s 3 s 2 s 3 s 2 s 3 s 3 s 3

A mchine M 2 ccepting the lnguge L(M 2 )={w w is ny string not in *U*} defined y the sme lphet, the sme sttes, the sme trnsition function, the sme strt stte nd set of ccept sttes F 2 =Q-F 1 ={s 3 }. g. The forml definition of mchine M 1 ccepting the lnguge L(M 1 )={w w is ny string tht contins exctly two 's} is s follows: Σ={,} Q 1 ={s 0,s 1,s 2,s 3 } q 01 = s 0 F 1 ={s 2 } δ is given y s 0 s 1 s 0 s 1 s 2 s 1 s 2 s 3 s 2 s 3 s 3 s 3 A mchine mchine M 2 ccepting the lnguge L(M 2 )={w w is ny string tht doesn't contin exctly two 's} defined y the sme lphet, the sme sttes, the sme trnsition function, the sme strt stte nd set of ccept sttes F 2 =Q-F 1 ={s 0,s 1,s 3 }.

h. The forml definition of mchine M 1 ccepting the lnguge L(M 1 )={w w is ny string or } is s follows: Σ={,} Q 1 ={s 0,s 1,s 2 } q 01 = s 0 F 1 ={s 1 } δ is given y s 0 s 1 s 1 s 1 s 2 s 2 s 2 s 2 s 2 A mchine M 2 ccepting the lnguge L(M 2 )={w w is ny string except nd } is defined y the sme lphet, the sme sttes, the sme trnsition function, the sme strt stte nd set of ccept sttes F 2 =Q-F 1 ={s 0,s 2 }. Exercise 1.6 ) {w w egins with 1 nd ends with zero}.

) {w w contins t lest three 1s} c) {w w contins the sustring 0101} d) {w w hs length t lest three nd its third symol is 0}

e) {w w strts with 0 nd hs odd length, or strts with 1 nd hs even length} f) {w w doesn't contin the sustring 110}

g) {w the length of w is t most 5} h) {w w is ny string except 11 nd 111} i) {w every odd position of w is 1}

j) Not included in this solution sheet. k) {empty,0} l) Not included in this solution sheet. m) The empty string. n) Any string except the empty string.

2. For ech of the following regulr expressions, drw DFA recognizing the corresponding lnguge. ) (0 U 1)*110* ) (11 U 10)* c) (1 U 110)*0

3. Not included in this solution sheet. 4.

Nondeterministic Finite Automt Exercise 1.11 Given NFA M 1 =(Q 1, Σ 1, S 01, F 1, δ 1 ) construct NFA M 2 =(Q 2, Σ 2, S 02, F 2, δ 2 ) s follows (given tht F 1 ={f 1, f 2, f 3,..., f n }). Q 2 =Q 1 Σ 2 =Σ 1 S 02 = S 01 F 2 ={f k }, 1 k n δ 2 =δ 1 plus the mppings δ(f, ε)={f k }, for every f F 1 nd f F 2. Exercise 1.14 ) Given NFA M 1 =(Q 1, Σ 1, S 01, F 1, δ 1 ) if the ccept sttes re swpped the result is new NFA M 2 =(Q 2, Σ 2, S 02, F 2, δ 2 ) with the following definitions: Q 2 =Q 1 Σ 2 =Σ 1 S 02 = S 01 F 2 =Q 1 -F 1 δ 2 =δ 1 The fct tht the set of ccept sttes of M 2 (F 2 ) is the complement of F 1 it gurntees tht M 2 ccepts only those words tht re not ccepted y M 1, i.e., the complement lnguge of M 1. ) The following NFA recognises the lnguge L={w w is }.

The following mchine ws constructed y swpping the ccept sttes of the previous ut it doesn't ccept the lnguge L={w w is not }.