Automata Theory and Formal Grammars: Lecture 1

Similar documents
Mathematical Preliminaries. Sipser pages 1-28

Foundations of Mathematics MATH 220 FALL 2017 Lecture Notes

Propositional Logic, Predicates, and Equivalence

Discrete Mathematics. W. Ethan Duckworth. Fall 2017, Loyola University Maryland

Background for Discrete Mathematics

Packet #2: Set Theory & Predicate Calculus. Applied Discrete Mathematics

Introduction to Automata

Lecture Notes 1 Basic Concepts of Mathematics MATH 352

Chapter 1 : The language of mathematics.

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

n Empty Set:, or { }, subset of all sets n Cardinality: V = {a, e, i, o, u}, so V = 5 n Subset: A B, all elements in A are in B

CA320 - Computability & Complexity

Seminaar Abstrakte Wiskunde Seminar in Abstract Mathematics Lecture notes in progress (27 March 2010)

Week Some Warm-up Questions

Automata Theory for Presburger Arithmetic Logic

Foundations of Mathematics

COMP1002 exam study sheet

Introduction to Proofs

Today s Topics. Methods of proof Relationships to logical equivalences. Important definitions Relationships to sets, relations Special functions

Mathematical Reasoning & Proofs

Logic, Sets, and Proofs

CSE 1400 Applied Discrete Mathematics Definitions

Lecture Notes on DISCRETE MATHEMATICS. Eusebius Doedel

Theory of Computation

Theory of Computation

Chapter Summary. Sets The Language of Sets Set Operations Set Identities Functions Types of Functions Operations on Functions Computability

3. Only sequences that were formed by using finitely many applications of rules 1 and 2, are propositional formulas.

Notes for Math 290 using Introduction to Mathematical Proofs by Charles E. Roberts, Jr.

Final Exam Review. 2. Let A = {, { }}. What is the cardinality of A? Is

Mathematics Review for Business PhD Students Lecture Notes

Chapter 0 Introduction. Fourth Academic Year/ Elective Course Electrical Engineering Department College of Engineering University of Salahaddin

CS 455/555: Mathematical preliminaries

LECTURE NOTES DISCRETE MATHEMATICS. Eusebius Doedel

CS Automata, Computability and Formal Languages

INF210 Datamaskinteori (Models of Computation)

18.S097 Introduction to Proofs IAP 2015 Lecture Notes 1 (1/5/2015)

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

HANDOUT AND SET THEORY. Ariyadi Wijaya

Notation Index. gcd(a, b) (greatest common divisor) NT-16

Theorem. For every positive integer n, the sum of the positive integers from 1 to n is n(n+1)

CSCE 222 Discrete Structures for Computing. Review for Exam 1. Dr. Hyunyoung Lee !!!

Review CHAPTER. 2.1 Definitions in Chapter Sample Exam Questions. 2.1 Set; Element; Member; Universal Set Partition. 2.

Mathematics Review for Business PhD Students

Sri vidya college of engineering and technology

Computational Models - Lecture 3

Harvard CS121 and CSCI E-121 Lecture 2: Mathematical Preliminaries

A Semester Course in Basic Abstract Algebra

MATH 363: Discrete Mathematics

UNIT-III REGULAR LANGUAGES

Chapter Summary. Sets (2.1) Set Operations (2.2) Functions (2.3) Sequences and Summations (2.4) Cardinality of Sets (2.5) Matrices (2.

COMP9020 Lecture 3 Session 2, 2014 Sets, Functions, and Sequences. Revision: 1.3

Informal Statement Calculus

With Question/Answer Animations. Chapter 2

Sets are one of the basic building blocks for the types of objects considered in discrete mathematics.

2.1 Sets. Definition 1 A set is an unordered collection of objects. Important sets: N, Z, Z +, Q, R.

FABER Formal Languages, Automata. Lecture 2. Mälardalen University

FOUNDATIONS & PROOF LECTURE NOTES by Dr Lynne Walling

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

MATH 13 FINAL EXAM SOLUTIONS

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages

Tribhuvan University Institute of Science and Technology Micro Syllabus

LECTURE NOTES DISCRETE MATHEMATICS. Eusebius Doedel

Packet #1: Logic & Proofs. Applied Discrete Mathematics

Problem 1: Suppose A, B, C and D are finite sets such that A B = C D and C = D. Prove or disprove: A = B.

BASIC MATHEMATICAL TECHNIQUES

Review 3. Andreas Klappenecker

Topics in Logic and Proofs

Foundations Revision Notes

What Is a Language? Grammars, Languages, and Machines. Strings: the Building Blocks of Languages

1. Consider the conditional E = p q r. Use de Morgan s laws to write simplified versions of the following : The negation of E : 5 points

Sets McGraw-Hill Education

CSCE 222 Discrete Structures for Computing. Review for the Final. Hyunyoung Lee

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

Logic Overview, I. and T T T T F F F T F F F F

HOW TO CREATE A PROOF. Writing proofs is typically not a straightforward, algorithmic process such as calculating

Introduction. Foundations of Computing Science. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

Tecniche di Verifica. Introduction to Propositional Logic

(Refer Slide Time: 0:21)

586 Index. vertex, 369 disjoint, 236 pairwise, 272, 395 disjoint sets, 236 disjunction, 33, 36 distributive laws

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

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Preliminaries to the Theory of Computation

Chapter 1. Sets and Numbers

Computational Models: Class 3

What we have done so far

Discrete Mathematics: Lectures 6 and 7 Sets, Relations, Functions and Counting Instructor: Arijit Bishnu Date: August 4 and 6, 2009

Chapter 1. Introduction

In English, there are at least three different types of entities: letters, words, sentences.

Math 10850, fall 2017, University of Notre Dame

Languages, regular languages, finite automata

Economics 204 Summer/Fall 2017 Lecture 1 Monday July 17, 2017

Computational Models - Lecture 4 1

This is logically equivalent to the conjunction of the positive assertion Minimal Arithmetic and Representability

Foundations of Mathematics

COMP 182 Algorithmic Thinking. Proofs. Luay Nakhleh Computer Science Rice University

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

Exercises 1 - Solutions

Solutions to Homework Set 1

CHAPTER 0: BACKGROUND (SPRING 2009 DRAFT)

Theory of Languages and Automata

Transcription:

Automata Theory and Formal Grammars: Lecture 1 Sets, Languages, Logic Automata Theory and Formal Grammars: Lecture 1 p.1/72

Sets, Languages, Logic Today Course Overview Administrivia Sets Theory (Review?) Logic, Proofs (Review?) Words, and operations on them: w 1 w 2, w i, w, w + Languages, and operations on them: L 1 L 2, L i, L, L + Automata Theory and Formal Grammars: Lecture 1 p.2/72

What This Course Is About Mathematical theory of computation! We ll study different machine models (finite automata, pushdown automata)...... with a view toward characterizing what they can compute. Automata Theory and Formal Grammars: Lecture 1 p.3/72

Why Study This Topic? To understand the limits of computation. Some things require more resources to compute, and others cannot be computed at all. To study these issues we need mathematical notions of resource and compute. To learn some programming tools. Automata show up in many different settings: compilers, text editors, communications protocols, hardware design,... First compilers took several person-years; now written by a single student in one semester, thanks to theory of parsing. To learn about program analysis. Microsoft is shipping two model-checking tools. PREfix discovered 2000 bugs in XP (fixed in SP2). To learn to think analytically about computing. Automata Theory and Formal Grammars: Lecture 1 p.4/72

Why Study This Topic? This course focuses on machines and logics. Analysis technique: model checking (SE431). CSC535 focuses on languages and types. Analysis technique: type checking (CSC535). Both approaches are very useful. For example, in Computer Security (SE547). Automata Theory and Formal Grammars: Lecture 1 p.5/72

Course Homepage: Administrivia http://www.depaul.edu/ jriely/csc444fall2003/ Syllabus: http://www.depaul.edu/ jriely/csc444fall2003/syllabus.html Automata Theory and Formal Grammars: Lecture 1 p.6/72

Set Theory: Sets, Functions, Relations Automata Theory and Formal Grammars: Lecture 1 p.7/72

Sets Sets are collections of objects. { }, {42}, {alice, bob} N = {0, 1, 2,...} Z = {..., 2, 1, 0, 1, 2,...} R = the set of real numbers includings Z, 2, π, etc { x N x 5 } Sets are unordered and insensitive to repetition. {42, 27} = {27, 42} {42, 42} = {42} Automata Theory and Formal Grammars: Lecture 1 p.8/72

What Do the Following Mean?, {} empty set a A A B A B A B A A B i I A i i I A i membership subset union intersection complement set difference = A B indexed union indexed intersection 2 A power set (set of all subsets) A B Cartesian product = { a, b a A, b B } A size (cardinality, or number of elements) Automata Theory and Formal Grammars: Lecture 1 p.9/72

Examples Let A = {m, n} and B = {x, y, z} What is A? B? What is A B? A B? What is 2 A? 2 A? What is 2 B? 2 B? Automata Theory and Formal Grammars: Lecture 1 p.10/72

Examples Let A = {m, n} and B = {x, y, z} What is A? B? 2, 3 What is A B? A B? What is 2 A? 2 A? What is 2 B? 2 B? Automata Theory and Formal Grammars: Lecture 1 p.10/72

Examples Let A = {m, n} and B = {x, y, z} What is A? B? 2, 3 What is A B? A B? { m, x, m, y, m, z, n, x, n, y, n, z }, 2 3 = 6 What is 2 A? 2 A? What is 2 B? 2 B? Automata Theory and Formal Grammars: Lecture 1 p.10/72

Examples Let A = {m, n} and B = {x, y, z} What is A? B? 2, 3 What is A B? A B? { m, x, m, y, m, z, n, x, n, y, n, z }, 2 3 = 6 What is 2 A? 2 A? {, {m}, {n}, {m, n}}, 2 2 = 4 What is 2 B? 2 B? Automata Theory and Formal Grammars: Lecture 1 p.10/72

Examples Let A = {m, n} and B = {x, y, z} What is A? B? 2, 3 What is A B? A B? { m, x, m, y, m, z, n, x, n, y, n, z }, 2 3 = 6 What is 2 A? 2 A? {, {m}, {n}, {m, n}}, 2 2 = 4 What is 2 B? 2 B? {, {x}, {y}, {z}, {x, y}, {x, z}, {y, z}, {x, y, z}}, 2 3 = 8 Automata Theory and Formal Grammars: Lecture 1 p.10/72

Equality on Sets Let A and B be sets. When does A = B? When they contain the same elements. When A B and B A. Some Set Equalities A = A A = A B = A B (De Morgan) A (B C) = (A B) (A C) (Distributivity) Automata Theory and Formal Grammars: Lecture 1 p.11/72

Cardinality Cardinality is easy with finite sets. {1, 2, 3} = {a, b, c} What about infinite ones? To answer this we need to understand functions. Automata Theory and Formal Grammars: Lecture 1 p.12/72

Binary Relations... relate elements of a set to other elements in the set. Definition R A A. Let A be a set. Then R is a binary relation over A if Notation We usually write a 1 R a 2, rather than a 1, a 2 R. Examples { 0, 1, 1, 2 } is a binary relation over N. { n, n n N } is a binary relation over N. Automata Theory and Formal Grammars: Lecture 1 p.13/72

Equivalence Relations When is R A A an equivalence relation? R must be reflexive a 1 R a 1 holds for any a 1 A. symmetric a 1 R a 2 implies a 2 R a 1 for any a 1, a 2 A. transitive a 1 R a 2 and a 2 R a 3 implies a 1 R a 3 for all a 1, a 2, a 3 A. As an example, consider = 3 N N defined by i = 3 j if and only if i modulo 3 = j modulo 3 For example 0 = 3 3 = 3 6 3 1 = 3 4 = 3 7 Automata Theory and Formal Grammars: Lecture 1 p.14/72

Equivalence Classes Let R be an equivalence relation R A A. Let a A. Then we write [a] R for the set of elements equivalent to a under R. Note that [a] R A. What is [1] =3? [a] R = { a a R a } Automata Theory and Formal Grammars: Lecture 1 p.15/72

Equivalence Classes Let R be an equivalence relation R A A. Let a A. Then we write [a] R for the set of elements equivalent to a under R. Note that [a] R A. What is [1] =3? {1, 4, 7, 10,...} [a] R = { a a R a } Automata Theory and Formal Grammars: Lecture 1 p.15/72

Functions When is R A B a function (ie, a total function)? Automata Theory and Formal Grammars: Lecture 1 p.16/72

Functions When is R A B a function (ie, a total function)? R must be deterministic If a R b 1 and a R b 2 then b 1 = b 2. total For every a A, there exists b B such that a R b holds. Automata Theory and Formal Grammars: Lecture 1 p.16/72

Functions When is R A B a function (ie, a total function)? R must be deterministic If a R b 1 and a R b 2 then b 1 = b 2. total For every a A, there exists b B such that a R b holds. Equivalently... For every a A, require { b a R b } = 1. If we require only determinism, we define partial functions. Automata Theory and Formal Grammars: Lecture 1 p.16/72

Functions When is R A B a function (ie, a total function)? R must be deterministic If a R b 1 and a R b 2 then b 1 = b 2. total For every a A, there exists b B such that a R b holds. Equivalently... For every a A, require { b a R b } = 1. If we require only determinism, we define partial functions. Functions map elements from one set to elements from another. f : A B A : domain of f B : codomain of f f(a) : result of applying f to a A f(a) B. Automata Theory and Formal Grammars: Lecture 1 p.16/72

Relational Inverse R 1 B A is the inverse of R A B. Definition b R 1 a if and only if a R b. Is the inverse of a function always a function? Automata Theory and Formal Grammars: Lecture 1 p.17/72

Bijections When Is f : A B...... injective (or one-to-one)?... surjective (onto)?... bijective? Automata Theory and Formal Grammars: Lecture 1 p.18/72

Bijections When Is f : A B...... injective (or one-to-one)? When f(a 1 ) = f(a 2 ) implies a 1 = a 2 for any a 1, a 2 A.... surjective (onto)?... bijective? Automata Theory and Formal Grammars: Lecture 1 p.18/72

Bijections When Is f : A B...... injective (or one-to-one)? When f(a 1 ) = f(a 2 ) implies a 1 = a 2 for any a 1, a 2 A. When f 1 is deterministic... surjective (onto)?... bijective? Automata Theory and Formal Grammars: Lecture 1 p.18/72

Bijections When Is f : A B...... injective (or one-to-one)? When f(a 1 ) = f(a 2 ) implies a 1 = a 2 for any a 1, a 2 A. When f 1 is deterministic... surjective (onto)? When for any b B there is an a A with f(a) = b.... bijective? Automata Theory and Formal Grammars: Lecture 1 p.18/72

Bijections When Is f : A B...... injective (or one-to-one)? When f(a 1 ) = f(a 2 ) implies a 1 = a 2 for any a 1, a 2 A. When f 1 is deterministic... surjective (onto)? When for any b B there is an a A with f(a) = b. When f 1 is total... bijective? Automata Theory and Formal Grammars: Lecture 1 p.18/72

Bijections When Is f : A B...... injective (or one-to-one)? When f(a 1 ) = f(a 2 ) implies a 1 = a 2 for any a 1, a 2 A. When f 1 is deterministic... surjective (onto)? When for any b B there is an a A with f(a) = b. When f 1 is total... bijective? When it is injective and surjective. Automata Theory and Formal Grammars: Lecture 1 p.18/72

Bijections When Is f : A B...... injective (or one-to-one)? When f(a 1 ) = f(a 2 ) implies a 1 = a 2 for any a 1, a 2 A. When f 1 is deterministic... surjective (onto)? When for any b B there is an a A with f(a) = b. When f 1 is total... bijective? When it is injective and surjective. When f 1 is a function Automata Theory and Formal Grammars: Lecture 1 p.18/72

Which f : N N Is Injective/Surjective? f(x) = x + 1 f(x) = x 2 f(x) = x Automata Theory and Formal Grammars: Lecture 1 p.19/72

Which f : N N Is Injective/Surjective? f(x) = x + 1 f(x) = x 2 f(x) = x injective, not surjective surjective, not injective bijective What if instead f : Z Z? f(x) = x + 1 f(x) = x 2 f(x) = x Automata Theory and Formal Grammars: Lecture 1 p.19/72

Which f : N N Is Injective/Surjective? f(x) = x + 1 f(x) = x 2 f(x) = x injective, not surjective surjective, not injective bijective What if instead f : Z Z? f(x) = x + 1 f(x) = x 2 f(x) = x bijective surjective, not injective neither injective nor surjective Automata Theory and Formal Grammars: Lecture 1 p.19/72

More On Functions Let f : A B If S A then how is f(s) defined? What is f(a) called? If g : B C then how is g f defined? If f is a bijection, what is (f 1 ) 1? If f is a bijection, what is f f 1 (b)? Automata Theory and Formal Grammars: Lecture 1 p.20/72

More On Functions Let f : A B If S A then how is f(s) defined? f(s) = { f(a) a S }. We have lifted f from A B to 2 A 2 B. What is f(a) called? If g : B C then how is g f defined? If f is a bijection, what is (f 1 ) 1? If f is a bijection, what is f f 1 (b)? Automata Theory and Formal Grammars: Lecture 1 p.20/72

More On Functions Let f : A B If S A then how is f(s) defined? f(s) = { f(a) a S }. We have lifted f from A B to 2 A 2 B. What is f(a) called? The range of f. If g : B C then how is g f defined? If f is a bijection, what is (f 1 ) 1? If f is a bijection, what is f f 1 (b)? Automata Theory and Formal Grammars: Lecture 1 p.20/72

More On Functions Let f : A B If S A then how is f(s) defined? f(s) = { f(a) a S }. We have lifted f from A B to 2 A 2 B. What is f(a) called? The range of f. If g : B C then how is g f defined? g f : A C is defined as g f(a) = g(f(a)). If f is a bijection, what is (f 1 ) 1? If f is a bijection, what is f f 1 (b)? Automata Theory and Formal Grammars: Lecture 1 p.20/72

More On Functions Let f : A B If S A then how is f(s) defined? f(s) = { f(a) a S }. We have lifted f from A B to 2 A 2 B. What is f(a) called? The range of f. If g : B C then how is g f defined? g f : A C is defined as g f(a) = g(f(a)). If f is a bijection, what is (f 1 ) 1? f If f is a bijection, what is f f 1 (b)? Automata Theory and Formal Grammars: Lecture 1 p.20/72

More On Functions Let f : A B If S A then how is f(s) defined? f(s) = { f(a) a S }. We have lifted f from A B to 2 A 2 B. What is f(a) called? The range of f. If g : B C then how is g f defined? g f : A C is defined as g f(a) = g(f(a)). If f is a bijection, what is (f 1 ) 1? f If f is a bijection, what is f f 1 (b)? b Automata Theory and Formal Grammars: Lecture 1 p.20/72

Cardinality Revisited Definition Two infinite sets have the same cardinality if there exists a bijection between them. Recall the naturals (N), integers (Z) and reals (R). Theorem N = Z N = N N N 2 N 2 N = R How would you prove these statements? Automata Theory and Formal Grammars: Lecture 1 p.21/72

Languages Automata Theory and Formal Grammars: Lecture 1 p.22/72

Languages and Computation What are computers? Symbol pushers They take in sequences of symbols...... and produce sequences of symbols. Mathematically, languages are sets of sequences of symbols ( words ) taken from some alphabet. Computers are language processors. We ll study different classes of languages with a view toward characterizing how much computing power is needed to process them. But first, we need precise definitions of alphabet, word and language. Automata Theory and Formal Grammars: Lecture 1 p.23/72

Alphabets An alphabet is a finite, nonempty set of symbols. Examples {a, b,..., z} {a, b,..., z, ä, ö, ü, ß} {0,1} ASCII Alphabets are usually denoted by Σ. Automata Theory and Formal Grammars: Lecture 1 p.24/72

Words A word (or string) or over an alphabet is a finite sequence of symbols from the alphabet. Examples sour süß 010101110 Automata Theory and Formal Grammars: Lecture 1 p.25/72

More Formally: Alphabets and Words Definition (Alphabet) symbols. An alphabet is a finite, non-empty set of Definition (Σ ) Let Σ be an alphabet. The set Σ of words (or strings) over Σ is defined recursively as follows. ε Σ If a Σ and w Σ then a w Σ Automata Theory and Formal Grammars: Lecture 1 p.26/72

What? ε is a special symbol representing the empty string (i.e. a string with no symbols). You can also think of it as the end-of-word marker. a w represents a word consisting of the letter a followed by the word w. Examples ε {0, 1} 0 ε {0, 1} 0 1 1 0 ε {0, 1} Notation Instances of, trailing ε s are usually omitted: 0, 0110 written rather than 0 ε, 0 1 1 0 ε. Automata Theory and Formal Grammars: Lecture 1 p.27/72

Fibonacci Example The i th Fibonacci number f(i) f(0) = 0 f(1) = 1 f(i) = f(i 1) + f(i 2), for i 2 0, 1, 1, 2, 3, 5, 8, 13, 21,... Automata Theory and Formal Grammars: Lecture 1 p.28/72

Reversal Example The reversal of a string w, denoted w R, is: if w = 0 then w R = w = ε if w = n + 1, for n 0, then w = ua for some a Σ and w R = au R Less formally, the reversal of a string is the string spelled backward. Automata Theory and Formal Grammars: Lecture 1 p.29/72

Exponentiation Definition For each string w and each natural number i, the string w i is defined as: w 0 = ε w i+1 = w i w for each i 0 Example Let w = he w 1 = he w 2 = hehe w 4 = hehehehe Automata Theory and Formal Grammars: Lecture 1 p.30/72

Recursive Definitions for Functions Recursion A method of defining something in terms of itself. Both fibonacci and reverse are defined in terms of themselves. Why is this OK? Because: There are base cases (n = 0, 1; w = 0). Applications of f in body are to smaller arguments. Automata Theory and Formal Grammars: Lecture 1 p.31/72

Sets Can Also Be Defined Recursively Recursive set definitions consist of rules explaining how to build up elements in the set from elements already in the set. Example 1 A A set A can be defined as follows. If a A then a + 3 A What are elements in A? Automata Theory and Formal Grammars: Lecture 1 p.32/72

Sets Can Also Be Defined Recursively Recursive set definitions consist of rules explaining how to build up elements in the set from elements already in the set. Example 1 A A set A can be defined as follows. If a A then a + 3 A What are elements in A? A = {1, 4, 7,...} = [1] =3 Automata Theory and Formal Grammars: Lecture 1 p.32/72

Elements of Recursively Defined Sets The previous definition specifies that A = i=0 A i, where A 0 = A i+1 = {1} { a + 3 a A i } E.g. A 0 = A 1 = {1} = {1} A 2 = {1} {4} = {1, 4} A 3 = {1} {4, 7} = {1, 4, 7} A 4 = Automata Theory and Formal Grammars: Lecture 1 p.33/72

More Generally Recursive set definitions consist of rules of following forms: c A for some constant c If a A and p(a) then f(a) A for some predicate p and function f Then A = i=0 A i, where A 0 = A i+1 = { c c A is a rule } {f(a) If a A and p(a) then f(a) A is a rule a A i p(a)} E.g. In previous example: p(a) is true f(a) = a + 3 Automata Theory and Formal Grammars: Lecture 1 p.34/72

More Formally: Alphabets and Words Definition (Σ ) Let Σ be an alphabet. The set Σ of words (or strings) over Σ is defined recursively as follows. ε Σ If a Σ and w Σ then a w Σ (Σ ) = i=0 (Σ ) i, where (Σ ) 0 = (Σ ) i+1 = ε { a w a Σ and w (Σ ) i } Convention: we write 0, 10 rather than 0 ε, 1 0 ε. Automata Theory and Formal Grammars: Lecture 1 p.35/72

An example (Σ ) = i=0 (Σ ) i, where (Σ ) 0 = (Σ ) i+1 = ε { a w a Σ and w (Σ ) i } For example, let Σ = {0, 1} (Σ ) 0 = (Σ ) 1 = {ε} = {ε} (Σ ) 2 = {ε} {0, 1} = {ε, 0, 1} (Σ ) 3 = {ε} {0, 1, 00, 01, 10, 11} = {ε, 0, 1, 00, 01, 10, 11} (Σ ) 4 = {0, 1} = {ε, 0, 1, 00, 01, 10, 11,...} Automata Theory and Formal Grammars: Lecture 1 p.36/72

Generally... Σ = i=0 (Σ ) i, where (Σ ) 0 = (Σ ) 1 = {ε} (Σ ) 2 = {ε} { a ε a Σ } = {ε} { a a Σ } (Σ ) 3 = {ε} { a w a Σ w (Σ ) 2 } = {ε} { a ε a Σ } { a 1 a 2 ε a 1, a 2 Σ } = {ε} { a a Σ } { a 1 a 2 a 1, a 2 Σ }. Note. (Σ ) i consists of all words containing up to i 1 symbols from Σ. Automata Theory and Formal Grammars: Lecture 1 p.37/72

Operations on Words: Length Definition Let Σ be an alphabet. Then the length function : Σ N is defined inductively as follows. 0 if w = ε w = 1 + w if w = a w E.g. abb = a b b ε = 1 + b b ε = 1 + 1 + b ε = 1 + 1 + 1 + ε = 1 + 1 + 1 + 0 = 3 Automata Theory and Formal Grammars: Lecture 1 p.38/72

Operations on Words: Concatenation Definition Let Σ be an alphabet. Then the concatenation operation C : Σ Σ Σ is defined inductively as follows. w 2 if w 1 = ε C(w 1, w 2 ) = a (C(w 1, w 2 )) if w 1 = a w 1 E.g. C(01, 10) = C(0 1 ε, 10) = 0 C(1 ε, 10) = 0 1 C(ε, 10) = 0 1 10 = 0110 Notation C(w 1, w 2 ) usually written as w 1 w 2 or w 1 w 2. Automata Theory and Formal Grammars: Lecture 1 p.39/72

Substrings v is a substring of a string w if there are strings x and y s.t. w = xvy if w = uv for some string u then v is a suffix of w if w = uv for some string v then u is a prefix of w Degenerate cases: ε is a substring of any string Any string is a substring of itself ε is a prefix and suffix of any string Any string is a prefix and suffix of itself Automata Theory and Formal Grammars: Lecture 1 p.40/72

Operations on Words: Exponentiation Definition Let Σ be an alphabet. Then the exponentiation operation : Σ N Σ is defined inductively as follows. w i ε if i = 0 = w (w i 1 ) otherwise E.g. (ab) 2 = ab (ab) 1 = ab ab (ab) 0 = ab ab ε = abab Automata Theory and Formal Grammars: Lecture 1 p.41/72

Properties of Operators on Words ε w = w w ε = w w 1 (w 2 w 3 ) = (w 1 w 2 ) w 3 w 1 w 2 = w 1 + w 2 w 1 = w w i+j = w i w j Automata Theory and Formal Grammars: Lecture 1 p.42/72

Languages Automata Theory and Formal Grammars: Lecture 1 p.43/72

Languages... are just sets of words, i.e. subsets of Σ! Definition Let Σ be an alphabet. Then a language over Σ is a subset of Σ. Question What is 2 Σ? Automata Theory and Formal Grammars: Lecture 1 p.44/72

Languages... are just sets of words, i.e. subsets of Σ! Definition Let Σ be an alphabet. Then a language over Σ is a subset of Σ. Question What is 2 Σ? Answer over Σ! The set of all subsets of Σ, i.e. the set of all languages Automata Theory and Formal Grammars: Lecture 1 p.44/72

Operations on Languages The usual set operations may be applied to languages:,, etc. One can also lift operations on words to languages. Definition languages. Let Σ be an alphabet, and let L, L 1, L 2 Σ be Concatenation: L 1 L 2 = { w 1 w 2 w 1 L 1 w 2 L 2 }. Exponentiation: Let i N. Then L i is defined recursively as follows. L i {ε} if i = 0 = L L i 1 otherwise Automata Theory and Formal Grammars: Lecture 1 p.45/72

Examples of Language Operations {ab, aa} {bb, a} = {ab bb, ab a, aa bb, aa a} = {abbb, aba, aabb, aaa} {01, 1} 2 = {01, 1} {01, 1} 1 = {01, 1} {01, 1} {01, 1} 0 = {01, 1} {01, 1} {ε} = {0101, 011, 101, 11} Automata Theory and Formal Grammars: Lecture 1 p.46/72

Operations on Languages: Kleene Closure Kleene closure (pronounced clean-y ) is another important operation on languages. Definition Let Σ be an alphabet, and let L Σ be a language. Then the Kleene closure, L, of L is defined recursively as follows. 1. ε L. 2. If w L and w L then w w L E.g. {01} = {ε, 01, 0101, 010101,...} What is? Automata Theory and Formal Grammars: Lecture 1 p.47/72

What is L Mathematically? Since L is defined recursively, we know that L = i=0 (L ) i, where: (L ) 0 = (L ) 1 = {ε} (L ) 2 = {ε} { w ε w L } = {ε} L (L ) 3 = {ε} { w w w L w (L ) 2 } = {ε} L (L L). Note. (L ) i consists of words obtained by gluing together up to i 1 copies of words from L. Automata Theory and Formal Grammars: Lecture 1 p.48/72

A Variation on L Definition Let L Σ. Then L + is defined inductively as follows. L L +. If v L and w L + then v w L +. Difference between L, L + : ε is not guaranteed to be an element of L +! Automata Theory and Formal Grammars: Lecture 1 p.49/72

Properties of L 1 L 2, L i, L, L + L = L {ε} = L L 1 (L 2 L 3 ) = (L 1 L 2 ) L 3 L 1 (L 2 L 3 ) = (L 1 L 2 ) (L 1 L 3 ) L 1 = L L i+j = L i L j L = L i L + = i=0 i=1 L i L + = L L Automata Theory and Formal Grammars: Lecture 1 p.50/72

Logic Automata Theory and Formal Grammars: Lecture 1 p.51/72

Logic...... is the study of propositions and proofs. Propositions: Statements that are either true or false. Proof: A rigorous argument that a proposition is true. Propositions are built up...... from (nonlogical/domain-specific) predicates and atomic propositions... E.g. x is prime, f is differentiable... using logical constructors. Automata Theory and Formal Grammars: Lecture 1 p.52/72

What Do the Following Logical Constructors Mean? conjunction ( and ) disjunction ( or ) negation ( not ) implication ( if... then, implies ) bi-implication ( if and only if ) universal quantifier ( for all ) existential quantifier ( there exists ) Examples (Propositions) 1. f : R R. f is differentiable f is continuous 2. x N. x is prime ( y N. y x y is prime ). Automata Theory and Formal Grammars: Lecture 1 p.53/72

Formulas and Instantiations Definition A formula is a proposition containing propositional and predicate variables. E.g. (p q), x : N. P (x) Definition A substitution is a function R mapping propositional variables to propositions and predicate variables to predicates. E.g. R where R(p) = 1 > 0, R(q) = 1 < 0, and R(P ) = x > x + 1 Definition An instantiation of a formula f by substitution R (notation: f[r]) is a proposition obtained by replacing each variable p in f with R(p). E.g. ( (p q))[r] = ( 1 > 0 1 < 0 ) ( x : N. P (x))[r] = x : N. x + 1 > x Automata Theory and Formal Grammars: Lecture 1 p.54/72

Logical Implications, Logical Equivalences, and Tautologies Definition Let f, g be formulas. f logically implies g (notation: f = g) if for every substitution R such that f[r] is true, g[r] is also true. f and g are logically equivalent (notation: f g) if for every substitution R, f[r] and g[r] are either both true or both false. f is a tautology if for every substitution R, f[r] is true (equivalently, f true). Intuitively, f = g and f g reflect truths that hold independently of any domain-specific information. Automata Theory and Formal Grammars: Lecture 1 p.55/72

Examples of Implications, Equivalences and Tautologies p q = p q Disjunctive weakening (I) p = p q Disjunctive weakening (II) p p Double negation p q ( p) q Material implication (p q) ( p) ( q) DeMorgan s Laws p q ( q) ( p) Contrapositive x. P (x) x. P (x) DeMorgan s Laws p ( p) true Law of Excluded Middle Automata Theory and Formal Grammars: Lecture 1 p.56/72

Propositions, Natural Language, and Mathematics In this course we will devote a lot of attention to proofs of assertions about different models of computation. These statements are usually given in English, e.g. A language L is regular if and only if it can be recognized by some FA M. In order to prove statements like these it is extremely useful to know the logical structure of the statement: that is, to convert it into a proposition! E.g. L. L is a language ( L is regular M. M is a FA M recognizes L ) Automata Theory and Formal Grammars: Lecture 1 p.57/72

Translating Natural Langauge into Logic Phrase Logical construct... not...... and...... or... if... then...,... implies...,... only if...... if and only if...,... is logically equivalent to...... all...,... any...... exists...,... some... Automata Theory and Formal Grammars: Lecture 1 p.58/72

Proofs Proofs are rigorous arguments for the truth of propositions. They come in one of two forms. Direct proofs: Use templates or recipes based on the logical form of the proposition. Indirect proofs: Involve the direct proof of a proposition that logically implies the one we are interested in. Automata Theory and Formal Grammars: Lecture 1 p.59/72

Direct Proofs Logical Form Proof recipe p Assume p and then derive a contradiction. p q Prove p; then prove q. p q Prove either p or q. p q Assume p and then prove q. p q Prove p q; then prove q p. x. P (x) Fix a generic x and then prove P (x). x. P (x) Present a specific value a and prove P (a). Automata Theory and Formal Grammars: Lecture 1 p.60/72

Sample Direct Proof A theorem is a statement to be proved. Theorem A language L is regular if and only if it is recognized by some FA M. Logical Form L. L is a language ( L is regular M. M is a FA M recognizes L ) Proof Fix a generic L ( ) and assume that L is a language ( ); we must prove that L is regular if and only if it is recognized by some FA M. So assume that L is regular; we must now show that some FA M exists such that M recognizes L (first part of )... Now assume that some FA M exists such that M recognizes L; we must show that L is regular (second part of )... This is not a complete proof; we need to know the definitions to continue. But notice that the logical form gets us started! Automata Theory and Formal Grammars: Lecture 1 p.61/72

Indirect Proofs... rely on proof of a statement that logically implies the one we are interested in. Examples To prove... It suffices to prove... Terminology p p Proof by contradiction p q ( q) ( p) Proof by contrapositive Automata Theory and Formal Grammars: Lecture 1 p.62/72

Mathematical Induction...... is an indirect proof technique for statements having logical form k N. P (k). Induction proofs have two parts. Base case: Prove P (0). Induction step: Prove k N. (P (k) P (k + 1)). The P (k) is often called the induction hypothesis. Note that an induction proof is actually a proof of the following: P (0) ( k N. P (k) P (k + 1)) Why does this logically imply k N. P (k)? Automata Theory and Formal Grammars: Lecture 1 p.63/72

Sample Induction Proof Theorem For any natural number k, k i=0 2i = 2 k+1 1 Logical Form k N. P (k), where P (k) is k i=0 2i = 2 k+1 1 Proof The proof proceeds by induction. Base case: We must prove P (0), i.e. 0 i=0 2i = 2 1 1. But 0 i=0 2i = 2 0 = 1 = 2 1 = 2 1 1. Induction step: We must prove k N. P (k) P (k + 1). So fix a generic k N and assume (induction hypothesis) that P (k) holds, i.e. that k i=0 2i = 2 k+1 1 is true. We must prove P (k + 1), i.e. that k+1 i=0 2i = 2 k+2 1. The proof proceeds as follows. Automata Theory and Formal Grammars: Lecture 1 p.64/72

Proof (cont.) k+1 i=0 2i = ( k i=0 2i ) + 2 k+1 Definition of = 2 k+1 1 + 2 k+1 Induction hypothesis = (2 2 k+1 ) 1 Arithmetic = 2 k+2 1 Exponentiation Automata Theory and Formal Grammars: Lecture 1 p.65/72

Strong Induction (Skip) Also used to prove statements of form n N.P (n) Like regular induction but with stronger induction hypothesis and no explicit base case. Notation [i..j) = {i, i + 1,..., j 1}. Strong induction argument consists of proof of following n N. ( k [0..n). P (k)) P (n) k [0..n). P (k) is usually called the induction hypothesis. Proof usually requires a case analysis on values n can take. Automata Theory and Formal Grammars: Lecture 1 p.66/72

Example Strong Induction Proof (Skip) Theorem f(n) = Consider f : N N given as follows. 1 if n = 0, 1 f(n 1) + f(n 2) otherwise Prove that f(n) ( 5 3 )n all n N. Logical Form n N. P (n), where P (n) is f(n) ( 5 3 )n. Proof Proceeds by strong induction. So fix n N and assume (induction hypothesis) k [0..n).P (k); we must prove P (n). We now do a case analysis on n. Automata Theory and Formal Grammars: Lecture 1 p.67/72

Example Strong Induction Proof (cont.) (Skip) n = 0: We must show P (0), i.e. f(0) ( 5 3 )0. But f(0) = 1 = ( 5 3 )0. n = 1: We must show P (1), i.e. f(1) ( 5 3 )1. This follows because f(1) = 1 < 5 3 = ( 5 3 )1. n 2: In this case we argue as follows. f(n) = f(n 1) + f(n 2) Definition of f ( 5 3 )n 1 + ( 5 3 )n 2 Induction hypothesis (twice) = ( 5 3 )n 2 ( 5 3 + 1) Factoring = ( 5 3 )n 2 ( 8 3 ) Algebra < ( 5 3 )n 2 ( 5 3 )2 8 3 = 24 9 < 25 9 = ( 5 3 )2 = ( 5 3 )n Exponents Automata Theory and Formal Grammars: Lecture 1 p.68/72

Proving Properties of Recursively Defined Sets Suppose A is a recursively defined set; how do we prove a statement of form: Use induction! Recall that A = i=0 A i. a A. P (a) a A. P (a) is logically equivalent to k N. ( a A k. P (a)). The latter statement has the correct form for an induction proof! Automata Theory and Formal Grammars: Lecture 1 p.69/72

Example Proof about Recursively Defined Set Theorem Let A N be the set defined as follows. 1. 0 A 2. If a A then a + 3 A. Prove that any a A is divisible by 3. Logical form a A. P (a), where P (a) is a is divisible by 3. Proof Proceeds by induction. The statement to be proved has form k N. Q(k), where Q(k) is a A k. P (a). Base case: k = 0. We must prove Q(0), i.e. a A 0. P (a), i.e. for every a A 0, a is divisible by 3. This follows immediately since A 0 =. Automata Theory and Formal Grammars: Lecture 1 p.70/72

Sample Proof (cont.) Induction step: We must prove that k N. (Q(k) Q(k + 1)). So fix k N and assume Q(k), i.e. a A k. P (a) (induction hypothesis). We must show Q(k + 1) = a A k+1. P (a), i.e. we must show that every a A k+1 is divisible by 3 under the assumption that every a A k is divisible by 3. So fix a generic a A k+1. Based on the definition of A a is added into A k+1 in one of two ways. a = 0. In this case a is certainly divisible by 0, since 0 = 0 3. a = b + 3 for some b A k. By the induction hypothesis b is divisible by 0, i.e. b = 3 c some c N. But then a = b + 3 = 3 (c + 1), and thus a is divisible by 3. Automata Theory and Formal Grammars: Lecture 1 p.71/72

Notes on Proof In the induction proof the base case was trivial; this will always be the case when using induction to prove properties of recursive sets! So it can be omitted. The induction step amounts to showing that the constants have the right property and that each application of a rule preserves the property. Automata Theory and Formal Grammars: Lecture 1 p.72/72