Lecture 1 09/08/2017

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

CS Automata, Computability and Formal Languages

Theory of Computation

1 Alphabets and Languages

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

The Three Hour Tour Through Automata Theory

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

Recap from Last Time

Automata: a short introduction

CS 455/555: Mathematical preliminaries

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CSCI 340: Computational Models. Regular Expressions. Department of Computer Science

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

CS 133 : Automata Theory and Computability

Computational Theory

Automata Theory and Formal Grammars: Lecture 1

How do regular expressions work? CMSC 330: Organization of Programming Languages

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

Languages. A language is a set of strings. String: A sequence of letters. Examples: cat, dog, house, Defined over an alphabet:

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

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

Finite Automata and Regular Languages

Theory of Computation

Closure under the Regular Operations

Theory of computation: initial remarks (Chapter 11)

CPSC 421: Tutorial #1

Author: Vivek Kulkarni ( )

FLAC Context-Free Grammars

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

UNIT-I. Strings, Alphabets, Language and Operations

Formal Languages. We ll use the English language as a running example.

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

1. (a) Explain the procedure to convert Context Free Grammar to Push Down Automata.

CS 455/555: Finite automata

Theory of Computation (Classroom Practice Booklet Solutions)

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

A Universal Turing Machine

CMSC 330: Organization of Programming Languages

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

Theory of Computation - Module 4

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

MA/CSSE 474 Theory of Computation

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

Theory of Computation Turing Machine and Pushdown Automata

Homework 4. Chapter 7. CS A Term 2009: Foundations of Computer Science. By Li Feng, Shweta Srivastava, and Carolina Ruiz

Understanding Computation

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

Theory of Computer Science

Regular Expressions and Finite-State Automata. L545 Spring 2008

CPS 220 Theory of Computation REGULAR LANGUAGES

COSE212: Programming Languages. Lecture 1 Inductive Definitions (1)

Theoretical Computer Science

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

6.8 The Post Correspondence Problem

Theory of Computation 1 Sets and Regular Expressions

CS6902 Theory of Computation and Algorithms

Closure under the Regular Operations

Section 1 (closed-book) Total points 30

What is this course about?

Mathematical Preliminaries. Sipser pages 1-28

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.


CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

Theory of Computation

Text Search and Closure Properties

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Regular Languages. Problem Characterize those Languages recognized by Finite Automata.

CS243, Logic and Computation Nondeterministic finite automata

COSE212: Programming Languages. Lecture 1 Inductive Definitions (1)

Text Search and Closure Properties

Chapter 3. Regular grammars

Formal Languages. We ll use the English language as a running example.

Theory of computation: initial remarks (Chapter 11)

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

CSE 311: Foundations of Computing. Lecture 26: More on Limits of FSMs, Cardinality

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

CpSc 421 Homework 1 Solutions

TAFL 1 (ECS-403) Unit- II. 2.1 Regular Expression: The Operators of Regular Expressions: Building Regular Expressions

Chapter 4. Regular Expressions. 4.1 Some Definitions

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

CSE 105 THEORY OF COMPUTATION

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Problem Session 5 (CFGs) Talk about the building blocks of CFGs: S 0S 1S ε - everything. S 0S0 1S1 A - waw R. S 0S0 0S1 1S0 1S1 A - xay, where x = y.

Announcements. Problem Set 6 due next Monday, February 25, at 12:50PM. Midterm graded, will be returned at end of lecture.

CSE 105 THEORY OF COMPUTATION

CS375 Midterm Exam Solution Set (Fall 2017)

REGular and Context-Free Grammars

Sri vidya college of engineering and technology

Nondeterministic Finite Automata and Regular Expressions

INSTITUTE OF AERONAUTICAL ENGINEERING

Chapter 1. Formal Definition and View. Lecture Formal Pushdown Automata on the 28th April 2009

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2017

CSE 105 THEORY OF COMPUTATION

Transcription:

15CS54 Automata Theory & Computability By Harivinod N Asst. Professor, Dept of CSE, VCET Puttur 1 Lecture 1 09/08/2017 3 1

Text Books 5 Why Study the Theory of Computation? Implementations come and go. 8 2

IBM 7090 Programming in the 1950 s ENTRY SXA 4,RETURN LDQ X FMP A FAD B XCA FMP X FAD C STO RESULT RETURN TRA 0 A BSS 1 B BSS 1 C BSS 1 X BSS 1 TEMP BSS 1 STORE BSS 1 END Ax 2 + Bx +C 9 Programming in the 1970 s IBM 360 JCL (Job Control Language) //MYJOB JOB (COMPRESS), 'VOLKER BANDKE',CLASS=P,COND=(0,NE) //BACKUP EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=* //SYSUT1 DD DISP=SHR,DSN=MY.IMPORTNT.PDS //SYSUT2 DD DISP=(,CATLG), DSN=MY.IMPORTNT.PDS.BACKUP, // UNIT=3350,VOL=SER=DISK01, // DCB=MY.IMPORTNT.PDS, SPACE=(CYL,(10,10,20)) //COMPRESS EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=* //MYPDS DD DISP=OLD,DSN=*.BACKUP.SYSUT1 //SYSIN DD * COPY INDD=MYPDS,OUTDD=MYPDS //DELETE2 EXEC PGM=IEFBR14 //BACKPDS DD DISP=(OLD,DELETE,DELETE), DSN=MY.IMPORTNT.PDS.BACKUP 10 3

Guruhood IBM s APL Language Returns 1 if the largest value in a 3 element vector is greater than the sum of the other 2 and Returns 0 otherwise APL was very powerful for processing arrays & vectors 11 Why study this? Science of Computing Mathematical Properties (problems & algorithms) having nothing to do with current technology or languages E.G. Alan Turing Provides Abstract Structures Defines Provable Limits Like Big Oh 12 4

Alan Turing (1912-1954) He was an Olympic-level runner He got bad grades and frustrated his teachers The father of modern computer science. He also dabbled in physics, biology, chemistry and neurology 13 Pilot ACE, 1950, is one of Britain s earliest stored program computers and the oldest complete general purpose electronic computer. It was based on plans for a larger computer (the ACE) designed by the mathematician Alan Turing between 1945 and 1947 14 5

Goals Study Principles of Problems themselves Does a solution exist? If not, is there a restricted variation? Can solution be implemented in fixed memory? Is Solution efficient? Growth of time & memory with problem size? Are there equivalent groups of problems? 15 Applications of the Theory Programming languages, compilers, & context-free grammars. UTA FSMs (finite state machines) for parity checkers, vending machines, communication protocols, & building security devices. Interactive games as nondeterministic FSMs. Natural languages are mostly context-free. Speech understanding systems use probabilistic FSMs. Computational Biology: DNA & proteins are strings. The undecidability of a simple security model. Artificial Intelligence: the undecidability of first-order logic. 16 6

Languages and Strings This is one of MOST important chapters. It includes the TERMINOLOGY required to be successful in this course. KNOW this chapter & ALL DEFINITIONS!! 17 A Framework for Analyzing Problems We need a single framework in which we can analyze a very diverse set of problems. The framework is Language Recognition *A language is a (possibly infinite) set of finite length strings over a finite alphabet. NOTE: Pay particular attention to use of finite & infinite in all definitions! 22 7

Alphabet - Σ An alphabet is a non-empty, finite set of characters/symbols Use Σ to denote an alphabet Examples Σ = { a, b } Σ = { 0, 1, 2 } Σ = { a, b, c, z, A, B, Z } Σ = { #, $, *, @, & } 23 Strings A string is a finite sequence, possibly empty, of characters drawn from some alphabet Σ. ε is the empty string Σ* is the set of all possible strings over an alphabet Σ. 24 8

Example Alphabets & Strings Alphabet name Alphabet symbols Example strings The lower case English alphabet {a, b, c,, z} ε, aabbcg, aaaaa The binary alphabet {0, 1} ε, 0, 001100,11 A star alphabet {,,,,, } ε,, A music alphabet {w, h, q, e, x, r, } ε, q w, w wr 25 Functions on Strings Length: s is the length of string s s is the number of characters in string s. ε = 0 1001101 = 7 # c (s) is defined as the number of times that c occurs in s. # a (abbaaa) = 4. 27 9

More Functions on Strings Concatenation: the concatenation of 2 strings s and t is the string formed by appending t to s; written as s t or more commonly, st Example: If x = good and y = bye, then xy = goodbye and yx = byegood Note that xy = x + y -- Is it always?? ε is the identity for concatenation of strings. So, x (x ε = ε x = x) Concatenation is associative. So, s, t, w ((st)w = s(tw)) 28 More Functions on Strings Replication: For each string w and each natural number k, the string w k is: w 0 = ε w k+1 = w k w Examples: a 3 = aaa (bye) 2 = byebye a 0 b 3 = bbb b 2 y 2 e 2 =?? Natural Numbers {0,1,2, } 29 10

More Functions on Strings Reverse: For each string w, w R is defined as: if w = 0 then w R = w = ε if w = 1 then w R = w OR if w > 1 then: a Σ ( u Σ* (w = ua)) So define w R = a u R if w > 1 then: a Σ & u Σ* w= ua So define w R = a u R Proof is by simple induction 30 Concatenation & Reverse of Strings Theorem: If w and x are strings, then (w x) R = x R w R. Example: (nametag) R = (tag) R (name) R = gateman In this course, will not use this too much! Not responsible for inductive proof on next slide. 31 11

Concatenation & Reverse of Strings Proof: By induction on x : x = 0: Then x = ε, and (wx) R = (w ε) R = (w) R = ε w R = ε R w R = x R w R. n 0 ((( x = n) ((w x) R = x R w R )) (( x = n + 1) ((w x) R = x R w R ))): Consider any string x, where x = n + 1. Then x = u a for some character a and u = n. So: (w x) R = (w (u a)) R rewrite x as ua = ((w u) a) R associativity of concatenation = a (w u) R definition of reversal = a (u R w R ) induction hypothesis = (a u R ) w R associativity of concatenation = (ua) R w R definition of reversal = x R w R rewrite ua as x 32 Relations on Strings - Substrings o Substring: string s is a substring of string t if s occurs contiguously in t o Every string is a substring of itself oε is a substring of every string o Proper Substring: s is a proper substring of t iff s t o Suppose t = aabbcc. o Substrings: ε, a, aa, ab, bbcc, b, c, aabbcc o Proper substrings? o Others? 33 12

The Prefix Relations s is a prefix of t iff x Σ* (t = sx). s is a proper prefix of t iff s is a prefix of t and s t. Examples: The prefixes of abba are: ε, a, ab, abb, abba. The proper prefixes of abba are: ε, a, ab, abb. Every string is a prefix of itself. ε is a prefix of every string. 34 The Suffix Relations s is a suffix of t iff x Σ* (t = xs). s is a proper suffix of t iff s is a suffix of t and s t. Examples: The suffixes of abba are: ε, a, ba, bba, abba. The proper suffixes of abba are: ε, a, ba, bba. Every string is a suffix of itself. ε is a suffix of every string. 35 13

Defining a Language A language is a (finite or infinite) set of strings over a (finite) alphabet Σ. Examples: Let Σ = {a, b} Some languages over Σ: = { } // the empty language, no strings {ε} // language contains only the empty string {a, b} {ε, a, aa, aaa, aaaa, aaaaa} 36 Defining a Language Two ways to define a language via a Machine = Automaton Also Known As Computer Program Recognizer which decides whether or not a candidate string is in the language and returns True if it is and False if it isn't Generator which enumerates (lists) the elements of the language Which do we want? Why? 37 14

Suppose we care about the order in which the elements of L are generated generator is preferred If there exists n total order D of the elements of L, then we can use D to define on L a total order called lexicographic order (written < L.): Shorter strings precede longer ones: x ( y (( x < y ) (x < L y))) and Of strings that are the same length sort them in dictionary order using D. Let L= {w ϵ {a, b}*; all a's precede all b's}. The lexicographic enumeration of Lis: ε, a. b. aa. ab. bb. aaa. aab. abb. bbb. aaaa, aaab. aabb. abbb. bbbb. aaaaa... 38 Σ* Σ* is defined as the set of all possible strings that can be formed from the alphabet Σ* Σ* is a language Σ* contains an infinite number of strings Σ* is countably infinite 39 15

Let Σ = {a, b} Σ* Example Σ* = {ε, a, b,aa,ab,ba,bb,aaa,aab, } Later, we will spend some more time studying Σ*. 40 Defining Languages Remember we are defining a set Set Notation: L = { w Σ* description of w} L = { w {a,b,c}* description of w} description of w can take many forms but must be precise Notation can vary, but must precisely define 42 16

Example Language Definitions L = {x {a, b}* all a s precede all b s} aab,aaabb, and aabbb are in L. aba, ba, and abc are not in L. What about ε, a, aa, and bb? L = {x : y {a, b}* x = ya} Give an English description. 43 Example Language Definitions Let Σ = {a, b} L = { w Σ* : w < 5} L = { w Σ* w begins with b} L = { w Σ* # b (w) = 2} L = { w Σ* each a is followed by exactly 2 b s} L = { w Σ* w does not begin with a} 44 17

More Examples Home work What strings are in the following languages? 1. L = {w {a, b}*: no prefix of w contains b} 2. L = {w {a, b}*: no prefix of w starts with a} 3. L = {w {a, b}*: every prefix of w starts with a} 4. L = {a n : n 0} 5. L = {ba 2n : n 0} 6. L = {b n a n : n 0} 45 Enumeration Enumeration: to list all strings in a language (set) Arbitrary order More useful: lexicographic order Shortest first Within a length, dictionary order Define linear order of arbitrary symbols 48 18

Lexicographic Enumeration {w {a, b}* : w is even} {ε, aa, ab, bb, aaaa, aaab, } What string is next? How many strings of length 4? How many strings of length 6? 49 Cardinality of a Language Cardinality of a Language: the number of strings in the language L Smallest language over any Σ is, with cardinality 0. The largest is Σ*. Is this true? How big is it? Can a language be uncountable? 50 19

Functions on Languages Set (Language) functions Have the traditional meaning Union Intersection Complement Difference Language functions Concatenation Kleene star 53 Traditional functions - example 54 20

Concatenation of Languages If L 1 and L 2 are languages over Σ: L 1 L 2 = {w : s L 1 & t L 2 w = st } Examples: L 1 = {cat, dog} L 2 = {apple, pear} L 1 L 2 ={catapple, catpear, dogapple, dogpear} L 2 L 1 ={applecat,appledog,pearcat,peardog} 55 Concatenation of Languages {ε} is the identity for concatenation: L{ε} = {ε}l = L is a zero for concatenation: L = L = 56 21

Concatenating Languages Defined Using Variables The scope of any variable used in an expression that invokes replication will be taken to be the entire expression. L 1 = {a n : n 0} L 2 = {b n : n 0} L 1 L 2 = {a n b m : n, m 0} L 1 L 2 {a n b n : n 0} 57 Kleene Star * L* - language consisting of 0 or more concatenations of strings from L L* = {ε} {w Σ* : w = w 1 w 2 w k, k 1 & w 1, w 2, w k L} Examples: L = {dog, cat, fish} L* = {ε, dog, cat, fish, dogdog, dogcat, dogfish,fishcatfish,fishdogdogfishcat, } ~~~~~~~~~~~~ L 1 = a* L 2 = b* What is a*? b*? L 1 L 2 = L 2 L 1 = L 1 L 1 = 58 22

The + Operator L + = language consisting of 1 or more concatenations of strings from L L + = L L* L + = L* - {ε} iff ε L 59 Closure A set S is closed under the operation @ if for every element x & y in S, x@y is also an element of S Examples 60 23

Exercises 67 68 24

69 25