Midterm I review. Reading: Chapters 1-4

Similar documents
Final Course Review. Reading: Chapters 1-9

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

6 NFA and Regular Expressions

Last lecture CMSC330. This lecture. Finite Automata: States. Finite Automata. Implementing Regular Expressions. Languages. Regular expressions

Converting a DFA to a Regular Expression JP

Lexical Analysis. Prof. James L. Frankel Harvard University

Decision, Computation and Language

Finite automata. We have looked at using Lex to build a scanner on the basis of regular expressions.

CS 432 Fall Mike Lam, Professor. Finite Automata Conversions and Lexing

1. (10 points) Draw the state diagram of the DFA that recognizes the language over Σ = {0, 1}

To illustrate what is intended the following are three write ups by students. Diagonalization

NFAs and Myhill-Nerode. CS154 Chris Pollett Feb. 22, 2006.

CSE450. Translation of Programming Languages. Lecture 20: Automata and Regular Expressions

CSE 105 THEORY OF COMPUTATION

Lexical Analysis. Implementation: Finite Automata

Regular Languages. MACM 300 Formal Languages and Automata. Formal Languages: Recap. Regular Languages

I have read and understand all of the instructions below, and I will obey the Academic Honor Code.

CS402 Theory of Automata Solved Subjective From Midterm Papers. MIDTERM SPRING 2012 CS402 Theory of Automata

(Refer Slide Time: 0:19)

Finite Automata. Dr. Nadeem Akhtar. Assistant Professor Department of Computer Science & IT The Islamia University of Bahawalpur

Theory of Computation

lec3:nondeterministic finite state automata

Chapter Seven: Regular Expressions

CIT3130: Theory of Computation. Regular languages

CS5371 Theory of Computation. Lecture 8: Automata Theory VI (PDA, PDA = CFG)

Formal Languages and Compilers Lecture IV: Regular Languages and Finite. Finite Automata

Languages and Automata

Regular Languages and Regular Expressions

CMPSCI 250: Introduction to Computation. Lecture 20: Deterministic and Nondeterministic Finite Automata David Mix Barrington 16 April 2013

HKN CS 374 Midterm 1 Review. Tim Klem Noah Mathes Mahir Morshed

Definition 2.8: A CFG is in Chomsky normal form if every rule. only appear on the left-hand side, we allow the rule S ǫ.

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

Ambiguous Grammars and Compactification

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

CSE450. Translation of Programming Languages. Automata, Simple Language Design Principles

Chapter Seven: Regular Expressions. Formal Language, chapter 7, slide 1

Lecture 2 Finite Automata

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Lexical Analysis. Dragon Book Chapter 3 Formal Languages Regular Expressions Finite Automata Theory Lexical Analysis using Automata

Implementation of Lexical Analysis. Lecture 4

Finite Automata Part Three

Lexical Analysis. Chapter 2

Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np

Languages and Compilers

Lexical Analysis. Lecture 2-4

Finite Automata Part Three

CS154 Midterm Examination. May 4, 2010, 2:15-3:30PM

CS103 Handout 14 Winter February 8, 2013 Problem Set 5

Automata & languages. A primer on the Theory of Computation. The imitation game (2014) Benedict Cumberbatch Alan Turing ( ) Laurent Vanbever

14.1 Encoding for different models of computation

AXIOMS FOR THE INTEGERS

CMSC330 Fall 2014 Midterm 1 Solution

T.E. (Computer Engineering) (Semester I) Examination, 2013 THEORY OF COMPUTATION (2008 Course)

Theory of Programming Languages COMP360

1. [5 points each] True or False. If the question is currently open, write O or Open.

(a) R=01[((10)*+111)*+0]*1 (b) ((01+10)*00)*. [8+8] 4. (a) Find the left most and right most derivations for the word abba in the grammar

2. Lexical Analysis! Prof. O. Nierstrasz!

CSE 431S Scanning. Washington University Spring 2013

Announcements! P1 part 1 due next Tuesday P1 part 2 due next Friday

[Lexical Analysis] Bikash Balami

Actually talking about Turing machines this time

Midterm Exam. CSCI 3136: Principles of Programming Languages. February 20, Group 2

Computer Sciences Department

CS Lecture 2. The Front End. Lecture 2 Lexical Analysis

Lexical Analysis. Lecture 3-4

Implementation of Lexical Analysis

Formal Languages. Formal Languages

R10 SET a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA?

CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5

Compiler Construction I

Sets 1. The things in a set are called the elements of it. If x is an element of the set S, we say

Lecture 3: Lexical Analysis

LECTURE NOTES THEORY OF COMPUTATION

Regular Expression Constrained Sequence Alignment

CT32 COMPUTER NETWORKS DEC 2015

CSE 105 THEORY OF COMPUTATION

Languages and Finite Automata

CS2 Language Processing note 3

Introduction to Lexical Analysis

Decision Properties of RLs & Automaton Minimization

LECTURE NOTES THEORY OF COMPUTATION

Theory of Computation, Homework 3 Sample Solution

Module 6 Lexical Phase - RE to DFA

Closure Properties of CFLs; Introducing TMs. CS154 Chris Pollett Apr 9, 2007.

Implementation of Lexical Analysis

Implementation of Lexical Analysis

DVA337 HT17 - LECTURE 4. Languages and regular expressions

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

Final Exam 1, CS154. April 21, 2010

Learn Smart and Grow with world

Theory of Languages and Automata

Compilers CS S-01 Compiler Basics & Lexical Analysis

CMSC330 Fall 2014 Midterm 1 Grading

UNIT -2 LEXICAL ANALYSIS

Formal Languages and Compilers Lecture VI: Lexical Analysis

LING/C SC/PSYC 438/538. Lecture 18 Sandiway Fong

Limits of Computation p.1/?? Limits of Computation p.2/??

TOPIC PAGE NO. UNIT-I FINITE AUTOMATA

ECS 120 Lesson 16 Turing Machines, Pt. 2

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

Transcription:

Midterm I review Reading: Chapters 1-4 1

Test Details In class, Wednesday, Feb. 25, 2015 3:10pm-4pm Comprehensive Closed book, closed notes 2

Syllabus Formal proofs Finite Automata NFA, DFA, -NFA Regular expressions Regular language properties Pumping lemma for regular languages Note: closure properties and minimization of DFAs not included 3

Finite Automata Deterministic Finite Automata (DFA) The machine can exist in only one state at any given time Non-deterministic Finite Automata (NFA) The machine can exist in multiple states at the same time -NFA is an NFA that allows -transitions What are their differences? 4

Deterministic Finite Automata A DFA is defined by the 5-tuple: {Q,, q 0,F, δ } Two ways to define: State-diagram (preferred) State-transition table DFA construction checklist: Associate states with their meanings Capture all possible combinations/input scenarios break into cases & subcases wherever possible Are outgoing transitions defined for every symbol from every state? Are final/accepting states marked? Possibly, dead/error-states will have to be included depending on the design. 5

Non-deterministic Finite Automata A NFA is defined by the 5-tuple: {Q,, q 0,F, δ } Two ways to represent: State-diagram (preferred) State-transition table NFA construction checklist: Has at least one nondeterministic transition Capture only valid input transitions Can ignore invalid input symbol transitions (paths will die implicitly) Outgoing transitions defined only for valid symbols from every state Are final/accepting states marked? 6

NFA to DFA conversion Checklist for NFA to DFA conversion Two approaches: Enumerate all possible subsets, or Use lazy construction strategy (to save time) Introduce subset states only as needed In your solutions, use the lazy construction procedure by default unless specified otherwise. Any subset containing an accepting state is also accepting in the DFA Have you made a special entry for Φ, the empty subset? This will correspond to the dead/error state 7

-NFA to DFA conversion Checklist for -NFA to DFA conversion First take ECLOSE(start state) New start state = ECLOSE(start state) Remember: ECLOSE(q) include q Then convert to DFA: Use lazy construction strategy for introducing subset states only as needed (same as NFA to DFA), but Only difference : take ECLOSE after transitions and also include those states in the subset corresponding to your destination state. E.g., if q_i goes to {q_j, q_k}, then your subset must be: ECLOSE(q_j) U ECLOSE(q_k) Again, check for a special entry for Φ if needed 8

Regular Expressions A way to express accepting patterns Operators for Reg. Exp. (E), L(E+F), L(EF), L(E * ).. Reg. Language Reg. Exp. (checklist): Capture all cases of valid input strings Express each case by a reg. exp. Combine all of them using the + operator Pay attention to operator precedence Try to reuse previously built regular expressions wherever possible 9

Regular Expressions DFA to Regular expression Enumerate all paths from start to every final state Generate regular expression for each segment, and concatenate Combine the reg. exp. for all each path using the + operator Reg. Expression to -NFA conversion Inside-to-outside construction Start making states for every atomic unit of RE Combine using: concatenation, + and * operators as appropriate For connecting adjacent parts, use -transitions Remember to note down final states 10

Regular Expressions Algebraic laws Commutative Associative Distributive Identity Annihiliator Idempotent Involving Kleene closures (* operator) 11

English description of lang. Finite automata english description Regular expression english description English description should be similar to how we have been describing languages in class E.g., languages of strings over {a,b} that end in b; or Languages of binary strings that have 0 in its even position, etc. Thumbrule: the simpler the description is, the better. However, make sure that the description should accurately capture the language. 12

Pumping Lemma Purpose: Regular or not? Verification technique Steps/Checklist for Pumping Lemma (in order): 1) Let N pumping lemma constant 2) Choose a template string w in L, such that w N. (Note: the string you choose should depend on N. And the choice of your w will affect the rest of the proof. So select w judiciously. Generally, a simple choice of w would be a good starting point. But if that doesn t work, then go for others.) 3) Now w should satisfy P/L, and therefore, all three conditions of the lemma. Specifically, using conditions xy N and y, try to conclude something about the property of the xy part and y part separately. 4) Next, use one of these two below strategies to arrive at the conclusion of xy k z L (for some value of k): Pump down (k=0) Pump up (k >= 2) Note: arriving at a contradiction using either pumping up OR down is sufficient. No need to show both. 13

Working out pumping lemma based proofs as a 2-player game: Steps (think of this 2-party game): Good guy (us) Builds w using N (without assuming any particular value of N) Tries to break the third condition of P/L without assuming any particular {x,y,z} split this is done by first pumping down (k=0) if that does not work, then try pumping up (k 2) Bad guy (someone else) Claims L is regular => Knows N and has the freedom to choose any value of N 1 Comes up with {x,y,z} combination, s.t. w=xyz (again, has the freedom to choose any xyz split, but meeting the two conditions of P/L: i.e., xy N and y ) 14

GOOD LUCK! 15