CSE 105 THEORY OF COMPUTATION

Similar documents
CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

ECS 120 Lesson 7 Regular Expressions, Pt. 1

Computer Sciences Department

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

Regular Languages and Regular Expressions

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

G52LAC Languages and Computation Lecture 6

CS 301. Lecture 05 Applications of Regular Languages. Stephen Checkoway. January 31, 2018

Chapter Seven: Regular Expressions

CIT3130: Theory of Computation. Regular languages

CSE 105 THEORY OF COMPUTATION

1 Finite Representations of Languages

(Refer Slide Time: 0:19)

DVA337 HT17 - LECTURE 4. Languages and regular expressions

6 NFA and Regular Expressions

Finite Automata Part Three

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

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

CS/ECE 374 Fall Homework 1. Due Tuesday, September 6, 2016 at 8pm

Lexical Analysis. Chapter 2

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

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

CS 181 B&C EXAM #1 NAME. You have 90 minutes to complete this exam. You may assume without proof any statement proved in class.

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

CS103 Handout 35 Spring 2017 May 19, 2017 Problem Set 7

Regular Expressions. Regular Expressions. Regular Languages. Specifying Languages. Regular Expressions. Kleene Star Operation

(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

Lecture 2 Finite Automata

Ambiguous Grammars and Compactification

Lexical Analysis. Lecture 3-4

MIT Specifying Languages with Regular Expressions and Context-Free Grammars. Martin Rinard Massachusetts Institute of Technology

MIT Specifying Languages with Regular Expressions and Context-Free Grammars

Computer Science Department Carlos III University of Madrid Leganés (Spain) David Griol Barres

CS402 - Theory of Automata Glossary By

Lexical Analysis. Lecture 2-4

CMSC 350: COMPILER DESIGN

Homework 1 Due Tuesday, January 30, 2018 at 8pm

Lecture 5: Regular Expression and Finite Automata

CSE 105 THEORY OF COMPUTATION

Answer All Questions. All Questions Carry Equal Marks. Time: 20 Min. Marks: 10.

Regular Expressions. Agenda for Today. Grammar for a Tiny Language. Programming Language Specifications

CS 403 Compiler Construction Lecture 3 Lexical Analysis [Based on Chapter 1, 2, 3 of Aho2]

CSE 413 Programming Languages & Implementation. Hal Perkins Winter 2019 Grammars, Scanners & Regular Expressions

CSE 20 DISCRETE MATH WINTER

David Griol Barres Computer Science Department Carlos III University of Madrid Leganés (Spain)

MITOCW watch?v=4dj1oguwtem

CS402 - Theory of Automata FAQs By

CS3102 Theory of Computation Problem Set 2, Spring 2011 Department of Computer Science, University of Virginia

PS3 - Comments. Describe precisely the language accepted by this nondeterministic PDA.

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

Implementation of Lexical Analysis

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

Material from Recitation 1

ECE 468/573 Midterm 1 September 30, 2015

Decidable Problems. We examine the problems for which there is an algorithm.

CMPSCI 250: Introduction to Computation. Lecture #28: Regular Expressions and Languages David Mix Barrington 2 April 2014

Lexical Analysis. Implementation: Finite Automata

Languages and Automata

CSEP 501 Compilers. Languages, Automata, Regular Expressions & Scanners Hal Perkins Winter /8/ Hal Perkins & UW CSE B-1

COMP Logic for Computer Scientists. Lecture 25

CSE 20 DISCRETE MATH. Fall

CSE 413 Programming Languages & Implementation. Hal Perkins Autumn 2012 Grammars, Scanners & Regular Expressions

Theory of Programming Languages COMP360

Decision, Computation and Language

Lexical Analysis. Note by Baris Aktemur: Our slides are adapted from Cooper and Torczon s slides that they prepared for COMP 412 at Rice.

Chapter 3: Lexing and Parsing

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

Slides for Faculty Oxford University Press All rights reserved.

CS308 Compiler Principles Lexical Analyzer Li Jiang

Front End: Lexical Analysis. The Structure of a Compiler

Zhizheng Zhang. Southeast University

Midterm I - Solution CS164, Spring 2014

CT32 COMPUTER NETWORKS DEC 2015

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

Regular Expressions. A Language for Specifying Languages. Thursday, September 20, 2007 Reading: Stoughton 3.1

Actually talking about Turing machines this time

CSc 453 Lexical Analysis (Scanning)

Regular Languages (14 points) Solution: Problem 1 (6 points) Minimize the following automaton M. Show that the resulting DFA is minimal.

Theory of Computation

Implementation of Lexical Analysis

Neha 1, Abhishek Sharma 2 1 M.Tech, 2 Assistant Professor. Department of Cse, Shri Balwant College of Engineering &Technology, Dcrust University

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

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

2010: Compilers REVIEW: REGULAR EXPRESSIONS HOW TO USE REGULAR EXPRESSIONS

Context-Free Grammars

Formal Languages and Automata

CMPE 4003 Formal Languages & Automata Theory Project Due May 15, 2010.

UNIT -2 LEXICAL ANALYSIS

Lecture 3: Lexical Analysis

Source of Slides: Introduction to Automata Theory, Languages, and Computation By John E. Hopcroft, Rajeev Motwani and Jeffrey D.

Implementation of Lexical Analysis

Finite Automata Part Three

CSE 20 DISCRETE MATH. Winter

CS6160 Theory of Computation Problem Set 2 Department of Computer Science, University of Virginia

Final Course Review. Reading: Chapters 1-9

Automating Construction of Lexers

Lecture 1. 1 Notation

Figure 2.1: Role of Lexical Analyzer

Transcription:

CSE 105 THEORY OF COMPUTATION Spring 2017 http://cseweb.ucsd.edu/classes/sp17/cse105-ab/

Today's learning goals Sipser Ch 1.2, 1.3 Decide whether or not a string is described by a given regular expression Design a regular expression to describe a given language Convert between regular expressions and automata Reminder: Exam 1 is Tuesday April 25 in class

Inductive application of closure Sipser 1.52 p. 64 R is a regular expression over Σ if Watch out for overloaded symbols! Σ is shorthand for (0 U 1) if Σ = {0,1}, Parentheses may be omitted, R + means RR *, R k means R concatenated with itself k times

Syntax à Languages The language described by a regular expression, L(R): L ( (0 U 1)U1 ) = { } L ( ) = { } L ( ) = { }

L(R) Which of the following strings is not in the language described by A. 00 B. 01 C. 1101 ( ( (00) * (11) ) U 01 ) * D. E. I don't know

L(R) Let L be the language over {a,b} described by the regular expression ((a U Ø) b * ) * Which of the following is not true about L? A. Some strings in L have equal numbers of a's and b's B. L contains the string aaaaaa C. a's never follow b's in any string in L D. L can also be represented by the regular expression (ab * ) * E. More than one of the above.

Regular expressions in practice Compilers: first phase of compiling transforms Strings to Tokens keywords, operators, identifiers, literals One regular expression for each token type Other software tools: grep, Perl, Python, Java, Ruby,

"Regular = regular" Sipser Theorem 1.54 p. 66 Theorem: A language is regular if and only if some regular expression describes it. Lemma 1.55: If a language is described by a regular expression, then it is regular. Lemma 1.60: If a language is regular, then it is described by some regular expression

L(R) to NFA (to DFA) Lemma 1.55, page 67 Idea: basic regular expressions are easy to implement as DFA, for inductive step of definition, use closure under regular operations. E.g.: build NFA recognizing the language described by (00 U 11) *

DFA to regular expression Lemma 1.60, page 69 Idea: use intermediate model GNFA whose labels are regular expressions DFA GNFA: start state à all, single accept, one arrow from all to all GNFA with fewer states 2 state GNFA E.g.: build regular expression describing language recognized by Regular expression

All roads lead to regular sets? Are there any languages over {0,1} that are not regular? A. Yes: a language that is recognized by an NFA but not any DFA. B. Yes: there is some infinite language of strings over {0,1} that is not described by any regular expression. C. No: all languages over {0,1} are regular because that's what it means to be a language. D. No: for each set of strings over {0,1}, some DFA recognizes that set. E. I don't know.

Counting Fact: a countable union of countable sets is countable. Fact: {0,1} * is countably infinite. X * is countably infinite when X is finite. Fact: the set of subsets of a countably infinite sets is uncountable. Fact: there are countably many DFA with Σ={0,1} Fact: there are countably many regular languages over {0,1}

Counting Fact: a countable union of countable sets is countable. Fact: {0,1} * is countably infinite. X * is countably infinite when X is finite. Uncountably many languages over {0,1} Fact: the set of subsets of a countably infinite sets is uncountable. Fact: there are countably many DFA with Σ={0,1} Countably many regular languages Fact: there are countably over many {0,1} regular languages over {0,1}

Proving nonregularity How can we prove that a set is non-regular? A. Try to design a DFA that recognizes it and, if the first few attempts don't work, conclude there is none that does. B. Prove that it's a strict subset of some regular set. C. Prove that it's the union of two regular sets. D. Prove that its complement is not regular. E. I don't know.

Where we stand There exist non-regular sets. If we know that some sets are not regular, we can conclude others are also not regular judiciously reasoning using closure properties of class of regular languages. No example of a specific regular set... yet.

Bounds on DFA in DFA, memory = states Automata can only "remember" finitely far in the past finitely much information If a computation path visits the same state more than once, the machine can't tell the difference between the first time and future times it visited that state.