ECS 20 Lecture 9 Fall Oct 2013 Phil Rogaway

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

1. Represent each of these relations on {1, 2, 3} with a matrix (with the elements of this set listed in increasing order).

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

Slides for Faculty Oxford University Press All rights reserved.

Functions and Sequences Rosen, Secs. 2.3, 2.4

1. Draw the state graphs for the finite automata which accept sets of strings composed of zeros and ones which:

Functions. How is this definition written in symbolic logic notation?

MATH 139 W12 Review 1 Checklist 1. Exam Checklist. 1. Introduction to Predicates and Quantified Statements (chapters ).

CHAPTER 3 FUZZY RELATION and COMPOSITION

Antisymmetric Relations. Definition A relation R on A is said to be antisymmetric

Introduction to Sets and Logic (MATH 1190)

CIT3130: Theory of Computation. Regular languages

EDAA40 At home exercises 1

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

1. Relations 2. Equivalence relations 3. Modular arithmetics. ! Think of relations as directed graphs! xry means there in an edge x!

MATH 22 MORE ABOUT FUNCTIONS. Lecture M: 10/14/2003. Form follows function. Louis Henri Sullivan

Functions. Def. Let A and B be sets. A function f from A to B is an assignment of exactly one element of B to each element of A.

Lexical Analysis. Introduction

(l) Represent each of the sets A, B and C using bit strings. Then, use bit string representation and bitwise logical operations to find

CS314: FORMAL LANGUAGES AND AUTOMATA THEORY L. NADA ALZABEN. Lecture 1: Introduction

CHAPTER 3 FUZZY RELATION and COMPOSITION

DVA337 HT17 - LECTURE 4. Languages and regular expressions

Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103. Chapter 2. Sets

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

CMPSCI 250: Introduction to Computation. Lecture #7: Quantifiers and Languages 6 February 2012

Logic and Discrete Mathematics. Section 2.5 Equivalence relations and partitions

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

A set with only one member is called a SINGLETON. A set with no members is called the EMPTY SET or 2 N

CSE 105 THEORY OF COMPUTATION

THREE LECTURES ON BASIC TOPOLOGY. 1. Basic notions.

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

14.1 Encoding for different models of computation

What Is A Relation? Example. is a relation from A to B.

Relational Database: The Relational Data Model; Operations on Database Relations

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

Functions 2/1/2017. Exercises. Exercises. Exercises. and the following mathematical appetizer is about. Functions. Functions

Computer Science 236 Fall Nov. 11, 2010

CHAPTER 8. Copyright Cengage Learning. All rights reserved.

1.3 Functions and Equivalence Relations 1.4 Languages

1. Lexical Analysis Phase

Comparing sizes of sets

2. Functions, sets, countability and uncountability. Let A, B be sets (often, in this module, subsets of R).

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

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

The Language of Sets and Functions

CS 341 Homework 1 Basic Techniques

r=1 The Binomial Theorem. 4 MA095/98G Revision


1KOd17RMoURxjn2 CSE 20 DISCRETE MATH Fall

2/18/14. Uses for Discrete Math in Computer Science. What is discrete? Why Study Discrete Math? Sets and Functions (Rosen, Sections 2.1,2.2, 2.

Let A(x) be x is an element of A, and B(x) be x is an element of B.

Semantics via Syntax. f (4) = if define f (x) =2 x + 55.

Binary Relations McGraw-Hill Education

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Languages and Compilers

Programming Lecture 3

Proof Techniques Alphabets, Strings, and Languages. Foundations of Computer Science Theory

Software development using B method. Julien Cervelle LACL - UPEC

Languages and Strings. Chapter 2

CSE 105 THEORY OF COMPUTATION

Formal languages and computation models

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

The Front End. The purpose of the front end is to deal with the input language. Perform a membership test: code source language?

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

Discrete Mathematics. Kruskal, order, sorting, induction

Compiler Construction LECTURE # 3

CS402 - Theory of Automata Glossary By

9.5 Equivalence Relations

Power Set of a set and Relations

9/19/12. Why Study Discrete Math? What is discrete? Sets (Rosen, Chapter 2) can be described by discrete math TOPICS

THEORY OF COMPUTATION

6.1 Evaluate Roots and Rational Exponents

Lexical Analysis. Prof. James L. Frankel Harvard University

Learn Smart and Grow with world

Name: Finite Automata

Caveat lector: This is the first edition of this lecture note. Please send bug reports and suggestions to

(Refer Slide Time: 0:19)

CSE 20 DISCRETE MATH. Winter

Solutions to Homework 10

Dr. D.M. Akbar Hussain

QUESTION BANK. Formal Languages and Automata Theory(10CS56)

CS 125 Section #10 Midterm 2 Review 11/5/14

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

Sets MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Sets Fall / 31

TOPIC PAGE NO. UNIT-I FINITE AUTOMATA

2. Sets. 2.1&2.2: Sets and Subsets. Combining Sets. c Dr Oksana Shatalov, Fall

Discrete mathematics , Fall Instructor: prof. János Pach

Chapter 4. Relations & Graphs. 4.1 Relations. Exercises For each of the relations specified below:

CS 441 Discrete Mathematics for CS Lecture 24. Relations IV. CS 441 Discrete mathematics for CS. Equivalence relation

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

1.5 Part - 2 Inverse Relations and Inverse Functions

3. Determine whether f is a function from the set of all bit strings to the set of integers if

Theory Bridge Exam Example Questions Version of June 6, 2008

CSC Discrete Math I, Spring Sets

Fundamental Mathematical Concepts Math 107A. Professor T. D. Hamilton

Standard Boolean Forms

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

AUBER (Models of Computation, Languages and Automata) EXERCISES

Ambiguous Grammars and Compactification

CISC 1400 Discrete Structures

Transcription:

ECS 20 Lecture 9 Fall 2013 24 Oct 2013 Phil Rogaway Today: o Sets of strings (languages) o Regular expressions Distinguished Lecture after class : Some Hash-Based Data Structures and Algorithms Everyone Should Know Prof. Michael Mitzenmacher, Harvard Sets of STRINGS (elements of formal language theory) Define and give examples: Alphabet a finite nonempty set (of characters ) Strings - a finite sequence of characters drawn from some alphabet. operation: concatenation, xy or x o y Language a set of strings, all of them over some alphabets extend concatenation to langauges Empty string () General set operations: union, intersection, complement; A* -- Kleene closure define it i 0 i A 0 = { } (why? For A i A j =A i+j ) * and concatenation BYTES = {0,1} 8 BYTES* ENGLISH-WORDS = {a, aah, aardvark, aardwolf, aba,, zymotic, zymurgy} PRIMES = SAT = The relationship between languages and decision questions. x M yes, xl no, xl Regular expression over : 1

1) a is a regular expression, for every a. Also, symbols and are regular expressions. 2) I fand are regular expressions, then so are (o ), (), (*) We routinely omit parenthesis, understanding it as a shorthand, with * binding most tightly, then concatenation, then union. Example: a number (0123456789) (0123456789)* A real number in decimal notation (0123456789)(0123456789)*. (0123456789)*. An even number in binary (01)0 Bit strings that start and top with the same bit (having at least one bit) 00* *** The complement of that set ** Exercise 1: write a regular expression for all strings over {0,1} that contain _some_ '111'. (0u1)* 111 (0u1)* Exercise 2: write a regular expression for all strings over {a,b} whose length is divisible by 3. (aub)(aub)(aub))* Exercise 3: write a regular expression for all strings over {a,b} whose length is NOT divisible by 3. (aub)(aub)(aub))*(aub) u (aub)(aub)(aub))*(aub)(aub) Exercise 4: write a regular expression for all strings over {0,1} that contain an even # of 0's and an even # of 1's. Kind of hard Exercise 5: write a regular expression for all strings over {0,1} that contain the same number of 0 s and 1 s. CAN T BE DONE. Why? Take ECS120! Relations 2

(Change of topics. But do define some relations on strings, regular languages, and DFAs to tie the two topics together.) DEF: A and B sets. Then a *relation* R is subset of A B. R A B Variant notation: x R y for (x,y) R May use a symbol like ~ or < for a relations x ~ y if (x,y) ~ Relations in arithmetic, where A and B are both natural numbers: = < <= > >= divides what about succ, +, * NO: function symbols, not relations In set theory: what about NO: constant symbol Relations are useful for things other than numbers and sets and the like: S = all UCD students for F13 C = all UCD classes for F13 P = all UCD professors for F13 E: enrolled relation S x C s E c (ie, (s,c)\in E) - x is taking class y T: teaches relation C x P c T p (ie, (c,p)\in T) - professor p is teaching class c this term You can *compose* relations what _should_ E o T mean, do you think E o T S P S C C P -> S P s EoT p if there exists c in C such that s E c and c T p -- student s is taking some course that p is teaching -- p is s's teacher this term What I've just given is the general definition R X x Y S Y x Z then R o S X x Z is {(x,z): y in Y xry and ysz} What _should_ R -1 should be? formalize 3

if R X Y is a relation that R -1 is the relation on Y X where (y,x) R -1 iff x R y. More examples: Often X = Y is the *same* set Relations on natural numbers, real numbers, strings, etc. X = set of strings x y "is a substring of y" and are regular expressions. ~ if L() = L() T/F: (0u1)^*(0u1)^* ~ (00 u 01 u 10 u 11)^* TRUE e ~ e* TRUE 0(0u1)0 ~ 1(0u1)1 FALSE Relations, continued. We say that R is Let R be a relation on A A Reflexive: if x R x for all x Symmetric: if x R y y R x for all x,y Transitive: if x R y and y R z x R z for all x, y, z If R has all three properties, R is said to be an equivalence relation Reflexive Symmetric Transitive comments = on Integers Yes Yes Yes (or anything else) <=, integers Yes No Yes antisymmetric, sets Yes No Yes antisymmetric x E y if x and y are regular expressions and Yes Yes Yes blocks are the regular L(x) = L(y) languages x S y if x is a substring Yes No Yes of y x R y where x and y are strings and M is a some DFA and you go to the Yes Yes Yes same state on processing 4

x and y x y if 3 x-y Yes Yes Yes Carefully prove this one and write out its blocks. Define when n m We only got to here and then I jumped ahead to defining functions. We ll take up equivalence classes and quotients next time, as well as properties of functions, like injectivity and surjectivity. ------------ 4. Functions ------------ Definition: A function f is a relation on A x B such that there is one and only one pair a R b for every in A. We write b=f(a) to mean that (a,b) in f. (Just one way to do it: we could have defined functions as the primitive and used the function to define the relation, putting in a pair (a,f(a)) for every a in A.) - We call A the domain of f, Dom(f). - We call B the *codomain* (or *target*) of f. Note that this does not mean the set {b: f(a)=b for some a in A}! That is a different (and important) st called the *Range* (or *image*) of f. Denote it f(a). Example 1: Domain={1,2,3} f(a) = a^2. Dom(f) = {1,2,3} f(a) = {1,4,9} co-domain: unclear, might be \N, might be \R,... Example 2: Domain = students in this class b(x) = birthdays, encoded as {1,..,12} x {1..31}. b(phil) = (7,31) b(ellen) = (4,1) Example 3: f: \R -> \R defined by f(x) = x^2 is it a function? Represent it as a graph Two functions f and g are equal, f=g, if their domains and ranges are equal and f(x) = g(x) for all x in Dom(f) Function composition 5

f o g f: A -> B, g: B -> C the (g o f) : A -> C is defined by (g o f)(x) = g(f(x)) Kind of "backwards" notation, but fairly tradition. Some algebrists will reverse it, (x) (f o g) "function operates on the left" Some computer scientists like to denote functions by "lambda expressions" To say that f is the function that maps x to x^2 we write f = lambda x. x^2 Here x is just a formal variable; lambda x. x^2 = lambda y. y^2 The domain is not explicitly Functions don't have to be defined on numbers, of course x = maps \Sigma^* -> \N hd(x) = the first character of the string x, x\ne emptystring tl(x) = all but the first character of x (define how when x=\emptystring)? dim(a) = the dimensions of the matrix A, regarded as a pair of natural numbers 6