CS 154 Formal Languages and Computability Assignment #2 Solutions

Similar documents
Closure under the Regular Operations

Nondeterministic Finite Automata

front pad rear pad door

Theory of Computation (I) Yijia Chen Fudan University

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

Lecture 1: Finite State Automaton

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

Nondeterministic Finite Automata. Nondeterminism Subset Construction

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

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

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

Lecture 2: Regular Expression

Chap. 1.2 NonDeterministic Finite Automata (NFA)

CSCI 2200 Foundations of Computer Science Spring 2018 Quiz 3 (May 2, 2018) SOLUTIONS

Deterministic Finite Automata (DFAs)

CMSC 330: Organization of Programming Languages

Chapter 6: NFA Applications

Computability Theory

Deterministic Finite Automata (DFAs)

CS375 Midterm Exam Solution Set (Fall 2017)

Chapter Five: Nondeterministic Finite Automata

CS 154, Lecture 3: DFA NFA, Regular Expressions

CSE 105 THEORY OF COMPUTATION

CS 322 D: Formal languages and automata theory

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

Extended transition function of a DFA

Sri vidya college of engineering and technology

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

Lecture 3: Nondeterministic Finite Automata

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

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

Fooling Sets and. Lecture 5

CpSc 421 Homework 1 Solutions

Deterministic Finite Automata (DFAs)

Lecture 4 Nondeterministic Finite Accepters

CS 455/555: Finite automata

Homework 1 Due September 20 M1 M2

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Nondeterminism and Epsilon Transitions

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

Lecture 3: Finite Automata. Finite Automata. Deterministic Finite Automata. Summary. Dr Kieran T. Herley

Harvard CS 121 and CSCI E-207 Lecture 6: Regular Languages and Countability

Computer Sciences Department

Regular Expressions. Definitions Equivalence to Finite Automata

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

Lecture 7 Properties of regular languages

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

Finite Automata. Dr. Neil T. Dantam. Fall CSCI-561, Colorado School of Mines. Dantam (Mines CSCI-561) Finite Automata Fall / 35

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

Please give details of your answer. A direct answer without explanation is not counted.

CS 154. Finite Automata, Nondeterminism, Regular Expressions

CSCE 551 Final Exam, April 28, 2016 Answer Key

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

Homework 5 - Solution

CS 208: Automata Theory and Logic

What we have done so far

Inf2A: Converting from NFAs to DFAs and Closure Properties

Theory of Languages and Automata

Homework 02 Solution updated

Computational Models - Lecture 1 1

Non-deterministic Finite Automata (NFAs)

Equivalence of DFAs and NFAs

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

TDDD65 Introduction to the Theory of Computation

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

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

Subset construction. We have defined for a DFA L(A) = {x Σ ˆδ(q 0, x) F } and for A NFA. For any NFA A we can build a DFA A D such that L(A) = L(A D )

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

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

Finite Automata. Seungjin Choi

Lexical Analysis. DFA Minimization & Equivalence to Regular Expressions

Computational Models Lecture 2 1

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

CSE 105 Homework 3 Due: Monday October 23, Instructions. should be on each page of the submission.

Constructions on Finite Automata

Nondeterministic Finite Automata

Finite Automata. Theorems - Unit I SUSAN ELIAS. Professor Department of Computer Science & Engineering Sri Venkateswara College of Engineering

Computational Models Lecture 2 1

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

(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},

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

CS21 Decidability and Tractability

Closure under the Regular Operations

Chapter 2: Finite Automata

CSE 105 THEORY OF COMPUTATION

Course 4 Finite Automata/Finite State Machines

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

Name: Student ID: Instructions:

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Intro to Theory of Computation

Finite Automata. Finite Automata

Chapter 6. Properties of Regular Languages

Finite-State Machines (Automata) lecture 12

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

Constructions on Finite Automata

Finite Automata. Wen-Guey Tzeng Computer Science Department National Chiao Tung University

Theory of Computation

Transcription:

CS 154 Formal Languages and Computability Assignment #2 Solutions Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak www.cs.sjsu.edu/~mak

Assignment #2: Question 1 o Use JFLAP to construct the transition graph for the DFA that accepts all strings (and only those strings) on the alphabet {a, b, c} that have an odd number of a s. 2

Assignment #2: Question 2 o Use JFLAP to construct the transition graph for the DFA that accepts all strings (and only those strings) on the alphabet {a, b, c} that have the symbols in alphabetical order. 3

Assignment #2: Question 3 o Describe in words the strings that the following DFA accepts and demonstrate your answer with some sample strings. n All strings that contain an even number of 0 s or an even number of 1 s. 4

Assignment #2: Question 4 o Describe in words the strings that the following DFA accepts and demonstrate your answer with some sample strings. n All strings that contain either two consecutive 0 s or two consecutive 1 s. 5

Assignment #2: Question 5 o Describe in words the strings that the following NFA accepts and demonstrate your answer with some sample strings. n All strings that contain all 1 s or end with a 0. 6

Assignment #2: Question 6 o NFA start state q 0 has λ-transitions to states q 1 and q 2, so label the DFA start state {q 0, q 1, q 2 }. 7

Assignment #2: Question 6, cont d o NFA: δ(q 0, 0) = ϕ and δ(q 1, 0) = ϕ and δ(q 2, 0) = {q 2, q 3 }, so DFA δ({q 0, q 1, q 2 }, 0) = {q 2, q 3 }. Perform the union. o NFA: δ(q 0, 1) = {q 0 } and δ(q 1, 1) = ϕ and δ(q 2, 1) = {q 2 }, so DFA δ({q 0, q 1, q 2 }, 1) = {q 0, q 2 }. 8

Assignment #2: Question 6, cont d o NFA: δ(q 0, 0) = ϕ and δ(q 2, 0) = {q 2, q 3 }, so DFA δ({q 0, q 2 }, 0) = {q 2, q 3 }. o NFA: δ(q 0, 1) = {q 0 } and δ(q 2, 1) = {q 2 }, so DFA δ({q 0, q 2 }, 1) = {q 0, q 2 }. 9

Assignment #2: Question 6, cont d o NFA: δ(q 2, 0) = {q 2, q 3 } and δ(q 3, 0) = ϕ, so DFA δ({q 2, q 3 }, 0) = {q 2, q 3 }. o NFA: δ(q 2, 1) = {q 2 } and δ(q 3, 1) = ϕ, so DFA δ({q 2, q 3 }, 1) = {q 2 }. 10

Assignment #2: Question 6, cont d o NFA: δ(q 2, 0) = {q 2, q 3 } so DFA δ({q 2 }, 0) = {q 2, q 3 }. o NFA: δ(q 2, 1) = {q 2 } so DFA δ({q 2 }, 1) = {q 2 }. 11

Assignment #2: Question 6, cont d o Since NFA q 0 and q 3 are final states, DFA {q 0, q 1, q 2 }, {q 0, q 2 }, and {q 2, q 3 } must be final states. 12

Assignment #2: Question 7 o Construct the NFA where Σ = {0, 1}, q 0 is the starting state, and q 2 is the final state. 0 1 q 0 q 0, q 1 q 2 q 1 q 2 q 1 q 2 q 1 q 2 13

Assignment #2: Question 8 o NFA: start state q 0, so DFA start state {q 0 } 14

Assignment #2: Question 8, cont d o NFA: δ(q 0, 0) = {q 0, q 1 }, so DFA δ({q 0 }, 0) = {q 0, q 1 } o NFA: δ(q 0, 1) = {q 2 }, so DFA δ({q 0 }, 1) = {q 2 } 15

Assignment #2: Question 8, cont d o NDA: δ(q 2, 0) = {q 1 }, so DFA δ({q 2 }, 0) = {q 1 } o NDA: δ(q 2, 1) = {q 2 }, so DFA δ({q 2 }, 1) = {q 2 } 16

Assignment #2: Question 8, cont d o NDA: δ(q 1, 0) = {q 2 }, so DFA δ({q 1 }, 0) = {q 2 } o NDA: δ(q 1, 1) = {q 1 }, so DFA δ({q 1 }, 1) = {q 1 } 17

Assignment #2: Question 8, cont d o NFA: δ(q 0, 0) = {q 0, q 1 } and δ(q 1, 0) = {q 2 }, so DFA δ({q 0, q 1 }, 0) = {q 0, q 1, q 2 } o NFA: δ(q 0, 1) = {q 2 } and δ(q 1, 1) = {q 1 }, so DFA δ({q 0, q 1 }, 1) = {q 1, q 2 } 18

Assignment #2: Question 8, cont d o NDA: δ(q 1, 0) = {q 2 } and δ(q 2, 0) = {q 1 }, so DFA δ({q 1, q 2 }, 0) = {q 1, q 2 } o NDA: δ(q 1, 1) = {q 1 } and δ(q 2, 1) = {q 2 }, so DFA δ({q 1, q 2 }, 1) = {q 1, q 2 } 19

Assignment #2: Question 8, cont d o NDA: δ(q 0, 0) = {q 0, q 1 } and δ(q 1, 0) = {q 2 } and δ(q 2, 0) = {q 1 }, so DFA δ({q 0, q 1, q 2 }, 0) = {q 0, q 1, q 2 } o NDA: δ(q 0, 1) = {q 2 } and δ(q 1, 1) = {q 1 } and δ(q 2, 1) = {q 2 }, so DFA δ({q 0, q 1, q 2 }, 1) = {q 1, q 2 } 20

Assignment #2: Question 8, cont d o NDA final state q 2, so DFA final states {q 2 }, {q 1, q 2 }, and {q 0, q 1, q 2 } 21

o Assignment #2: Question 9 Construct the DFA where Σ = {a, b}, q 0 is the starting state, and q 2 is the final state. a b q 0 q 2 q 2 q 1 q 2 q 2 q 2 q 3 q 3 q 3 q 3 q 1 22

Assignment #2: Question 10 o State q 2 is final: 0 1 3 2 o From states q 0 and q 1, all strings lead to final state q 2 : o 0 1 3 2 No further partitioning is possible. 23

Assignment #2: Question 10, cont d o Original: δ(q 0, w) = δ(q 1, w) = q 2 for all w in Σ Minimized: δ*({q 0, q 1 }, w) = {q 2 } o Original: δ(q 3, b) = q 1 Minimized: δ({q 3 }, b) = {q 0, q 1 } 24