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

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

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

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

NFAs continued, Closure Properties of Regular Languages

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

Homework 3 Solutions

Lecture 08: Feb. 08, 2019

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.

CMSC 330: Organization of Programming Languages

Minimal DFA. minimal DFA for L starting from any other

Non-deterministic Finite Automata

Convert the NFA into DFA

Non-deterministic Finite Automata

First Midterm Examination

Worked out examples Finite Automata

State Minimization for DFAs

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

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

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

Name Ima Sample ASU ID

Some Theory of Computation Exercises Week 1

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

Harvard University Computer Science 121 Midterm October 23, 2012

Finite Automata-cont d

NFAs continued, Closure Properties of Regular Languages

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

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

1 From NFA to regular expression

Let's start with an example:

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

DFA Minimization and Applications

Closure Properties of Regular Languages

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

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

Designing finite automata II

First Midterm Examination

Formal languages, automata, and theory of computation

Lexical Analysis Finite Automate

Java II Finite Automata I

Prefix-Free Subsets of Regular Languages and Descriptional Complexity

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.

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!)

GNFA GNFA GNFA GNFA GNFA

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

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

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

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

Formal Languages and Automata

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

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

CSC 311 Theory of Computation

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

Nondeterminism and Nodeterministic Automata

Deterministic Finite Automata

CS 330 Formal Methods and Models

Finite Automata Part Three

CISC 4090 Theory of Computation

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

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

input tape head moves current state

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

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

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

CS103 Handout 32 Fall 2016 November 11, 2016 Problem Set 7

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

SWEN 224 Formal Foundations of Programming WITH ANSWERS

Theory of Computation Regular Languages

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

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

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

Formal Language and Automata Theory (CS21004)

CS 330 Formal Methods and Models

Today s Topics Automata and Languages

Automata and Languages

Fundamentals of Computer Science

CHAPTER 1 Regular Languages. Contents

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

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

CSE396 Prelim I Answer Key Spring 2017

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

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:

Finite-State Automata: Recap

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

1 Nondeterministic Finite Automata

CSE : Exam 3-ANSWERS, Spring 2011 Time: 50 minutes

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

Chapter 2 Finite Automata

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

Closure Properties of Regular Languages

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

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

378 Relations Solutions for Chapter 16. Section 16.1 Exercises. 3. Let A = {0,1,2,3,4,5}. Write out the relation R that expresses on A.

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

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

Lecture 6 Regular Grammars

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

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

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

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

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

Transcription:

Midterm 1 Prctice CS 350 Fll 2018 gilry.org/clsses/fll2018/cs350/ 1

Midterm #1: Thursdy, Septemer 27! Bring less stuff, if possile. Keep ny gs under the tle. You my hve out: pencil, pen, nd/or erser. My hve wter. No pper. You ll e provided scrtch pper if you need it. You ll hve 75 minutes: the test is from 12:30 1:45p.!2

Tody: review prolems nd solutions!3

0) L is the lnguge L(). Digrm its NFA using the stndrd construction we ve seen:!4

0) L is the lnguge L(). Digrm its NFA using the stndrd construction we ve seen: q1 q2!5

1) L is the lnguge L(*). Digrm its NFA using the stndrd construction. (It s crucil to use the generl process nd not design n NFA d hoc!)!6

1) L is the lnguge L(*). Digrm its NFA using the stndrd construction. (It s crucil to use the generl process nd not design n NFA d hoc!) q1 q2 q4 q5 q6!7

2) L is the lnguge L( *). Digrm its NFA using the stndrd construction.!8

2) L is the lnguge L( *). Digrm its NFA using the stndrd construction. q1 q4 q6 q2 q5 q7 q8!9

So to rek this down, this prt is: q1 q4 q6 q2 q5 q7 q8!10

So to rek this down, this prt is: * q1 q4 q6 q2 q5 q7 q8!11

So to rek this down, this prt is: * q1 q4 q6 q2 q5 q7 q8!12

So to rek this down, this is: * q1 q4 q6 q2 q5 q7 q8!13

3) L is the lnguge L(0(1 10)). Digrm its NFA using the stndrd construction.!14

3) L is the lnguge L(0(1 10)). Digrm its NFA using the stndrd construction. 0 q1 1 q6 q2 q9 1 0 q4 q5 q7 q8!15

4) Find regex equivlent to: x q1 y y y x q2!16

4) Find regex equivlent to: x q1 yy y x!17

4) Find regex equivlent to: xy yy x!18

4) Find regex equivlent to: xy yy x* q 3!19

4) Find regex equivlent to: So vlid regex is: (xy yy)x*!20

5) Find regex equivlent to: x q1 y y y q2!21

5) Find regex equivlent to: x q1 yy y!22

5) Find regex equivlent to: yy x q1 y!23

5) Find regex equivlent to: yy y(yy)*x x q1 So vlid regex is: (yy)*x(y(yy)*x)*!24

6) Find DFA nd regex tht represents the intersection of L(( )*) nd L(( )*)!25

6) Find DFA nd regex tht represents the intersection of L(( )*) nd L(( )*) Hint: L(( )*) L(( )*) q2 q1 q1!26

Ech stte is in Q0xQ1 nd only (,) ccepts ecuse oth nd ccept:,,q1 q1 L(( )*) q1,q2 q1,,q2 q2 So: L(( )*) L(( )*) q1 L(( )*) = L(()*) Mkes sense!!27

7) Digrm DFA tht represents strings either not in L(( )*) or not in L(( )*)!28

So, y De Morgn s lws, L 0 L 1 = (L 0 L 1 ), we wnt the complement of this sme DFA:,,q1 q1,,q2!29

So, we dd n explicit ded stte: q1 q2, ded!30

nd invert the set of ccept sttes F, with respect to the overll set of sttes Q (Q-F) q1 q2, live!31

8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: But first, reminder!!32

The ε-closure of set of sttes is the set of sttes which re rechle without consuming ny chrcters/strings. (Another fixpoint itertion.) closure δ : P(Q) P(Q) closure δ (qs) = ext N δ (qs) where ext N 1 (qs) = ext δ N δ (qs) ext δ (qs) = qs {q q qs (q,, q ) δ}!33

The move of set of sttes nd chrcter s, is the set of sttes which re rechle from ny input stte, vi single trnsition on the chrcter s. move δ : P(Q) Σ P(Q) move δ (qs, s) = {q q qs (q, s, q ) δ}!34

The suset lgorithm Input: NFA (Q, Σ, δq,, FQ) Output: DFA (D, Σ, δd, d0, FD) Let d0 = ε-closureδ({}) mrked = {} D = {d0} δd = {} While d D such tht d mrked: mrked = mrked {d} For ech s Σ: Let dmv = moveδ(d,s) Let dmv+ε = ε-closureδ(dmv) If dmv+ε D: D = D {dmv+ε} δd = δd {(d,s,dmv+ε)} FD = { d D q d. q FQ}!35

8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm:!36

8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA q1 q2 q4!37

8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA Strt t ε-closure({}) d0 = {,q1,q2} q1 q2 q4 d0 DFA!38

8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA q1 Strt t ε-closure({}) d0 = {,q1,q2} d1 = ε-clo(moveδ(d0,)) = {,,q1,q2} q2 q4 d0 d1 DFA!39

8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA q1 Strt t ε-closure({}) d0 = {,q1,q2} d1 = {,,q1,q2} d2 = ε-clo(moveδ(d0,)) = {q4} q2 q4 d0 d1 d2 DFA!40

8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA q1 Strt t ε-closure({}) d0 = {,q1,q2} d1 = {,,q1,q2} d2 = {q4} d1 = ε-clo(moveδ(d1,)) q2 q4 d0 d1 d2 DFA!41

8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA q1 Strt t ε-closure({}) d0 = {,q1,q2} d1 = {,,q1,q2} d2 = {q4} d2 = ε-clo(moveδ(d1,)) q2 q4 d0 d1 d2 DFA!42

8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA q1 Strt t ε-closure({}) d0 = {,q1,q2} d1 = {,,q1,q2} d2 = {q4} = ε-clo(moveδ(d2,)) Ø q2 q4 d0 d1 d2 DFA!43

8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA q1 Strt t ε-closure({}) d0 = {,q1,q2} d1 = {,,q1,q2} d2 = {q4} = ε-clo(moveδ(d2,)) Ø q2 q4 d0 d1 d2 DFA!44

8) Turn the stndrd-construction NFA for L(*) into DFA vi the suset lgorithm: NFA q1 Strt t ε-closure({}) d0 = {,q1,q2} d1 = {,,q1,q2} d2 = {q4} q2 q4 d0 d1 d2 DFA!45

9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm:!46

9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm: q6 q1 q2 q7 q8 q4 q5 q9 q10!47

9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm: q6 q1 q2 q7 q8 q4 q5 q9 q10 d0!48

9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm: q6 q1 q2 q7 q8 q4 q5 q9 q10 d0 d1!49

9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm: q6 q1 q2 q7 q8 q4 q5 d2 q9 q10 d0 d1!50

9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm: q6 q1 q2 q7 q8 q4 q5 d2 q9 q10 d0 d1 d3!51

9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm: q6 q1 q2 q7 q8 q4 q5 d2 q9 q10 d0 d1 d4 d3!52

9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm: q6 q1 q2 q7 q8 q4 q5 d0 d1 d2 d4 q9 q10 d3!53

9) Turn the stndrd-construction NFA for L(( )*) into DFA vi the suset lgorithm: q6 q1 q2 q7 q8 q4 q5 d0 d1 d2 d4 q9 q10 d3!54

Other prolems we should work out? Any prolems from the prctice exm?!55