Automata and Formal Languages



Similar documents
C H A P T E R Regular Expressions regular expression

CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions

Reading 13 : Finite State Automata and Regular Expressions

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 4 Nancy Lynch

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

MACM 101 Discrete Mathematics I

Automata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi

CS 3719 (Theory of Computation and Algorithms) Lecture 4

Regular Languages and Finite Automata

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.

Fundamentele Informatica II

Automata and Computability. Solutions to Exercises

Regular Languages and Finite State Machines

CMPSCI 250: Introduction to Computation. Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013

Deterministic Finite Automata

THEORY of COMPUTATION

Introduction to Automata Theory. Reading: Chapter 1

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Regular Expressions and Automata using Haskell

Lecture 2: Regular Languages [Fa 14]

3515ICT Theory of Computation Turing Machines

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy

Automata on Infinite Words and Trees

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

Lecture 1. Basic Concepts of Set Theory, Functions and Relations

CAs and Turing Machines. The Basis for Universal Computation

Computability Theory

Turing Machines: An Introduction

INCIDENCE-BETWEENNESS GEOMETRY

We can express this in decimal notation (in contrast to the underline notation we have been using) as follows: b + 90c = c + 10b

Mathematical Induction. Lecture 10-11

6.080/6.089 GITCS Feb 12, Lecture 3

Compiler Construction

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

WOLLONGONG COLLEGE AUSTRALIA. Diploma in Information Technology

Finite Automata. Reading: Chapter 2

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

Finite Automata. Reading: Chapter 2

Informatique Fondamentale IMA S8

CHAPTER 5. Number Theory. 1. Integers and Division. Discussion

Lecture Note 1 Set and Probability Theory. MIT Spring 2006 Herman Bennett

CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move.

Computational Models Lecture 8, Spring 2009

ASSIGNMENT ONE SOLUTIONS MATH 4805 / COMP 4805 / MATH 5605

Notes on Complexity Theory Last updated: August, Lecture 1

The Halting Problem is Undecidable

Pushdown Automata. place the input head on the leftmost input symbol. while symbol read = b and pile contains discs advance head remove disc from pile

CS5236 Advanced Automata Theory

Overview of E0222: Automata and Computability

Continued Fractions and the Euclidean Algorithm

CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions

Introduction to Theory of Computation

T Reactive Systems: Introduction and Finite State Automata

Lecture 17 : Equivalence and Order Relations DRAFT

Turing Machines, Part I

INTRODUCTORY SET THEORY

Discrete Mathematics

Finite Automata and Regular Languages

How To Compare A Markov Algorithm To A Turing Machine

Basic Set Theory. 1. Motivation. Fido Sue. Fred Aristotle Bob. LX Semantics I September 11, 2008

3. Mathematical Induction

Omega Automata: Minimization and Learning 1

THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER

God created the integers and the rest is the work of man. (Leopold Kronecker, in an after-dinner speech at a conference, Berlin, 1886)

Properties of Stabilizing Computations

Genetic programming with regular expressions

Math Workshop October 2010 Fractions and Repeating Decimals

Regular Languages and Finite Automata

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

k, then n = p2α 1 1 pα k

Basic Concepts of Set Theory, Functions and Relations

CS 341: Foundations of Computer Science II elearning Section Syllabus, Spring 2015

Lecture 16 : Relations and Functions DRAFT

Cartesian Products and Relations

8 Divisibility and prime numbers

Basic Probability Concepts

Handout #1: Mathematical Reasoning

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

24 Uses of Turing Machines

Course Syllabus. MATH 1350-Mathematics for Teachers I. Revision Date: 8/15/2016

=

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

E3: PROBABILITY AND STATISTICS lecture notes

This chapter is all about cardinality of sets. At first this looks like a

Lecture I FINITE AUTOMATA

mod 10 = mod 10 = 49 mod 10 = 9.

Honors Class (Foundations of) Informatics. Tom Verhoeff. Department of Mathematics & Computer Science Software Engineering & Technology

Math/Stats 425 Introduction to Probability. 1. Uncertainty and the axioms of probability

Implementation of Recursively Enumerable Languages using Universal Turing Machine in JFLAP

Math 55: Discrete Mathematics

Answer Key for California State Standards: Algebra I

Lecture 13 - Basic Number Theory.

6.2 Permutations continued

So let us begin our quest to find the holy grail of real analysis.

A Little Set Theory (Never Hurt Anybody)

CS 103X: Discrete Structures Homework Assignment 3 Solutions

Cardinality. The set of all finite strings over the alphabet of lowercase letters is countable. The set of real numbers R is an uncountable set.

WRITING PROOFS. Christopher Heil Georgia Institute of Technology

Transcription:

Automata and Formal Languages Winter 2009-2010 Yacov Hel-Or 1

What this course is all about This course is about mathematical models of computation We ll study different machine models (finite automata, pushdown automata, Turing machine) and characterize what they can compute 2

Why should I care? To understand the limits of computations Some problems require more resources to compute and others cannot be computed at all. To learn some programming tools Automata show up in many different settings: compilers, text editors, hardware design, communication protocols, program proofing, To learn to think in a formal way about computing 3

Computability and Complexity Are there any problems that can not be solved by a (very powerful) computer? What makes some problems computationally hard and other easy? Can we partition the problems into classes such that problems in one class share the same computational properties? Complete answers: next semester. Introduction, basic tools, models, intuition: this semester. 4

This Course: Formal computational models The basic computational model : Finite State Automata Additional models: Pushdown automaton Turing machine Formal languages Regular languages Context free languages 5

Administration Course Home page: http://www1.idc.ac.il/toky/automata Lecture notes will appear at the course web-page the day before the lecture (the latest). Proofs, examples, technical details will usually be presented on the board. No recitations, part of lecture time will be dedicated to solving problems. Grade calculation: Exam 70%, HW 30% Exam: Must pass the exam (60) in order to have the HW component. 6

Administration (cont.) HW: Will be given every week. Submission: Wednesdays before your lecture. Appeals: No more than two weeks after return. Grader + TA: Ilit Raz (raz.ilit@post.idc.ac.il) Newsgroup: news://news.idc.ac.il/automata Book: Sipser (see web-page for details). 7

Unit 1 Introduction Mathematical Background Reading: Sipser, chapter 1 8

Today Set theory (review?) Logic, proofs (review?) Words and their operations: Languages and their operations: w i * 1 w2, w, w, w L i * 1 L2, L, L, L 9

Set Theory A Set is a group of objects. The objects are called elements. קבוצה, איבר Notation: 1. By listing the elements. Examples: {3,5,7}, {Alice, Bob, {1,2} } (for finite sets only) 2. By providing a rule. Examples: {x x is an odd integer between 2 and 8} ; {x name of a student in the Automata class} A name of a set is usually a capital letter of the English alphabet (A, B, C) or a capital letter with an index (X 1, X 2, X 3 ) 10

The Empty Set A set with no elements is called an empty set. Notation or { } Example: S - a set of all odd numbers that can be divided by two without any remainder. S is an empty set. הקבוצה הריקה S = {x N x is odd and x mod 2=0}= 11

Membership in a set s S, means that an element s is a member of the set S איבר בקבוצה b S, means that an element b is not a member of the set S Examples: 7 {21,7,30} and 8 {21,7,30} Let N be the set of natural numbers. 2 N and 3.2 N 12

Subsets Given two sets A and B we say that A is a subset of B, if each element of A is also an element of B. The notation: A B תת קבוצה מוכל Formally: A B x A x B Example: A set of natural numbers N is a subset of a set of all real numbers R. N R 13

Proper Subset Given two sets A and B we say that A is a proper subset of B if each element of A is also an element of B and there exists at least one element in B that does not belong to A. תת קבוצה ממש The notation: A B Example: {1,3} {1, 2, 3, 8} מוכל ממש 14

Some Facts Each set is a subset of itself: A A The empty set is a subset of every set: A 15

More on Sets Two groups of elements that have the same elements but in different order form the same set. Example: If A = { 1,2,3,4}, B = { 2,1,4,3} then A = B Repetitions in a set are irrelevant Example: {1,2,3,4,2} = {1,2,3,4} 16

More on Sets The cardinality of a set is the number of elements in the set. Notation: A עצמת הקבוצה Example: Let A = { 1,2,4,8,16}, then A =5 A set can be: Finite A={Even integers smaller than 100} Infinite A={Even integers dividing 7 with no reminder} 17

union intersection complement difference Operations on sets A visual model, called Venn diagram can be used. A 18

Venn Diagram Start-t End-z Start-j terrific theory topaz jazz 19

A binary operation The notation : A B Formally: Union A B = { x x A or x B } אחוד A B 20

A binary operation The notation: A B Formally: Intersection חיתוך A B = { x x A and x B } A B 21

Complement An unary operation The notation : ~A Formally: ~A = { x x A} משלים A 22

Set Difference An binary operation The notation : A-B חיסור Formally: A-B = { x x A and x B} Example: A = { 1,2,3 }, B={3,4,5}, A-B={1,2} A B 23

Power Set The power set is the set of all subsets of a given set. Notation: P(S) or 2 S is a power set of S Note, that sets may appear as elements of other sets. Example: S = { 1,2 } P(S) = 2 S = {,{1},{2},{1,2}} קבוצת החזקה The cardinality of a power set is: 2 S (why?) 24

Sequences and Tuples A sequence of objects is a list of objects in some order. The notation : (7,21,57, ) Unlike sets, the order and repetitions in the sequence do matter, thus (7,21,57) (7,57,21) and (7,21,57,57) (7,21,57) A sequence with k elements is a k-tuple Example: (7,21,57) is a 3-tuple. סדרית ק-איה 25

Cartesian product A binary operation The Cartesian product (or cross product) is a set of all pairs (2-tuple) where the first element of the pair is in A and the second element of the pair is in B. The notation: A B A Cartesian product of a set with itself: A A A (k times)=a k Example: מכפלה חיצונית A = {2,3}, B = {b,c}, A B ={ (2,b), (2,c), (3,b), (3,c) } 26

Summary: sets,{ } a A A A B A B A B ~A A-B 2 A (a,b,..) empty set membership cardinality subset union intersection complement set difference power set a sequence (k-tuple) AxB cartesian product 27

Letters and Alphabet Any finite set of letters (symbols) is called an alphabet. Notation: alphabet- ; Letter (symbol)- אותיות Examples: 1 2 3 = { 0,1 }, 1 =0 ; 2 =1; = { a,b,c,d,e, }, 1 =a ; 2 =b ; 3 =c ; = { 0,1,x,y,z} אלפבית, 28

Strings (and words) A string (word) over some alphabet is a finite sequence of letters from the alphabet. Example: = {0, 1}, w = 101 מחרוזת, מילה, סדרית The length of a word, w, denoted w, is the number of letters in it. Example: w 1 = abracadabra; w 1 = 11 w 2 = 001011 ; w 2 = 6 29

More on Strings An empty word is a string without letters. The notation of an empty word is = 0 המילה הריקה The number of occurrences of some letter in word w is denoted by # (W) Example: Let w=aaba, then # a (w)=3, # b (w)=1, # c (w)=0 30

Operations on Strings reverse sub-string prefix suffix concatenation 31

Reversing strings A reverse string is a string in which all letters are written in the opposite order Notation: w R Examples: w = 10, w R = 01 s = abcb, s R = bcba היפוך A palindrome: a string w such that w=w R. Examples: aba, 010010, 32

Sub-strings A sub-string is a subsequence of consecutive letters from a string תת מחרוזת Example: Let w = 101. All sub-strings of w are: B(w) = {, 1, 0, 10, 01, 101 }. Note: 11 B(w) 33

Prefixes A prefix is a sub-string which starts from the first letter of the word (or an empty word). A proper prefix of a string is a prefix that is not equal to the complete word. רישא, רישא ממש Example: Let w = acdb. The prefixes of w are {, a,ac,acd,acdb}. acdb is not a proper prefix. 34

Suffixes A suffix is a substring ending with the last letter of the word or an empty word. A proper suffix of the string is a suffix that is not the whole word. Example: Let w = acdb. The suffixes of w are {,b, db,cdb,acdb}. acdb is not a proper suffix Note: The prefixes of w are the reversed suffixes of w R. סיפא, סיפא ממש 35

Concatenation A binary operation (over two words) The concatenation of two words x and y places them one after the other such that the first word is a prefix and a second one is a suffix. Notation: concatenation of two words x and y: xy שרשור Example: Let x= 01, y=012, z=10 Then xy=01012, yx=01201, xyz=0101210 36

Concatenation (Cont.) The result of concatenating a word with an empty word is the string itself. For example, let w=ab, then w = w = w = ab Concatenating an empty word to itself results in an empty word: = = 37

Languages A language is a set of words (strings). A language can be finite or infinite. Notation: L (or with an index: L i ) The language of all words over some alphabet Σ is denoted Σ * (sigma star). שפה An empty language A language with zero words. השפה הריקה 38

Examples Infinite languages: L 1 = The language of all natural numbers over the decimal alphabet. L 2 = The language of all even length words over the binary alphabet. L 3 = The language of all strings over the binary alphabet that ends with 0. Finite languages: L 4 = {abc, bc} L 5 = The Language of natural numbers smaller than 5. L 6 = {words over Σ={0,1} whose binary value is as an odd number smaller than 325} 39

Operations over languages reverse concatenation iteration positive closure Kleene closure 40

Reverse Languages The reverse language L R is the language with all reversed words in it. Formally: L R ={ w w R L} שפה הפוכה Examples: L = {abc, bc}; L R = {cba, cb} L={0,00,0010}; L R = {0,00,0100} L= all binary words ={0,1}* ; L R = L (why?) 41

Concatenation A concatenation of two languages is a language in which each word is a concatenation of two words - one from the first language and a second from the second language. Formally: A B={w=ab a A and b B} Examples: L 1 = {ab, cd }; L 2 = {00, 1} ; L 3 ={0,10,110} L 1 L 2 = { ab00, ab1, cd00, cd1 } L 3 L 2 = { 000, 01, 1000, 101, 11000, 1101} שרשור שפות Note: the order is important (A B is different from B A ) 42

Concatenation v.s Cartesian Product Do not confuse concatenation of languages with Cartesian Product of sets. For example, let A = {0,00} then A A = { 00, 000, 0000 } with A A =3, A A = { (0,0), (0,00), (00,0), (00,00) } with A A =4 What is the cardinality of AxA v.s. A A? 43

Concatenation with special languages Concatenation with an empty language the result is an empty language. L = L = Concatenation with a language that includes only an empty word the result is the language itself. L { } = { } L = L 44

Iterations K-th iteration concatenation of the language with itself k times : L L L L (k times) Notation: L K Definition: L 0 = { } (for each L!) Examples: Let L 1 ={,00, 1} ; L 2 ={01, 1} L 12 = {,00, 1, 0000, 001, 100, 11} L 2 2 = {0101, 011, 101, 11} L 2 3 = {010101, 01011, 01101, 0111, 10101, 1011, 1101, 111} 45

Kleene (star) closure A Kleene closure is the union of all possible iterations of L: L i 0 L i { L 0 L 1 L 2...} סגור של קלין Notation: L * Examples: 1. Let L={a}, then L * = {, a, aa, aaa, aaaa. } 2. Let L={0,1} then L * ={all binary words} Note: for all L, L * 46

Positive closures A positive closure is a union of all positive iterations of L, not including the zero iteration: Notation: L + Examples: L i 1 L { L...} 1. Let L={a}, then L + = { a, aa, aaa, aaaa. } i 2.Let L={0,1} then L + ={all binary words of length > 0} 1 L 2 סגור חיובי 47

Problems concerning formal languages Is a given word a member of the language? Is the language infinite? Does the sequence of operations (steps) create (derive) a given word? Given a word and a sequence of basic steps does the result belongs to a given language? Given a grammar (a set of rules) what language does it create? 48

Practice Problems 1. Prove that L + = L * if and only if L 2. Prove that for any three languages (L 1 L 2 ) L 3 = L 1 L 3 L 2 L 3 3. For a given word w, define L 1 = {prefixes of w}; L 2 ={suffixes of w R } Prove that L 1 =L R 2 Answers: In class. 49

Types of Proofs Four main types: direct proof (syllogism) proof by construction proof by contradiction proof by induction 50

Direct proof axioms + theorems + rules of deduction theorems All students at IDC are nice. Danny is a student at IDC. Danny is nice. modus ponens: a b, a b a b, ~b ~a 51

Proof by Construction prove by building a solution (algorithm, automaton) Example: Claim: There exists a set with 4 elements. Proof: Here is such a set: A = {01, 001, 1, 1100} 52

Proof by Contradiction The idea: assume the opposite of the theorem derive a contradiction Example: Claim: There is an infinite number of integers. Proof: Assume the opposite, therefore, there is some largest integer. Denote it N. But N+1 is also an integer, and it is bigger than N A contradiction. 53

Another Example If there are more girls than boys and every girl is dating a boy, there must be a boy that s cheating Proof: Assume no boy is cheating, that is, each boy dates at most one girl, therefore, the total number of dating girls is at most the number of boys. Since every girl is dating a boy, the total number of girls is less or equal the number of boys. Contradicting the fact that there are more girls than boys. Note: This is called THE PIGEONHOLE PRINCIPLE: If you put 6 pigeons in 5 holes then at least one hole will have more than one pigeon. 54

Proof by Induction Induction has many appearances: Formal Arguments Loop Invariants Recursion Algorithm Design 55

Review: Induction Suppose S(k) is true for fixed constant k (often k=0) S(n) S(n+1) for all n >= k Then S(n) is true for all n >= k 56

Proof By Induction Claim:S(n) is true for all n >= k Base: Show S(n) is true for n = k Inductive hypothesis: Assume S(n) is true for an arbitrary n Step: Show that S(n+1) is true 57

Induction Example: Geometric Closed Form S(n)=a 0 + a 1 + + a n Prove S(n)= (a n+1-1)/(a-1) for all a 1 Proof: Base: S(0)=a 0 = (a 0+1-1)/(a - 1)=1 Inductive hypothesis: Assume S(n)= (a n+1-1)/(a - 1) Step (show true for n+1): S(n+1)=a 0 + a 1 + + a n+1 = S(n) + a n+1 = (a n+1-1)/(a - 1) + a n+1 = (a n+1+1-1)/(a - 1) 58

Induction Another variation: Basis: show S(0), S(1) Hypothesis: assume S(n) and S(n+1) are true Step: show S(n+2) follows Another variation: Basis: show S(k) Hypothesis: assume S(n) Step: show S(n-1) follows 59

E N D 60