Why Study the Theory of Computation? Implementations come and go. Chapter 1.

Slides:



Advertisements
Similar presentations
CS3012 Formal Languages and Compilers Frank Guerin Room 227 Lectures Monday11:00MT3 Tuesday9:00105 St. Marys Tutorials Thursday13:00 Thursday 14:00definitely.
Advertisements

Formal Languages Languages: English, Spanish,... PASCAL, C,... Problem: How do we define a language? i.e. what sentences belong to a language? e.g.Large.
1 Turing Machines and Equivalent Models Section 13.2 The Church-Turing Thesis.
Properties of Regular Languages
COMP-421 Compiler Design Presented by Dr Ioanna Dionysiou.
YES-NO machines Finite State Automata as language recognizers.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata are like Turing Machines with a restriction: The working space of the tape is the space of the.
1 CSCI-2400 Models of Computation. 2 Computation CPU memory.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
CS 310 – Fall 2006 Pacific University CS310 Strings, String Operators, and Languages Sections: August 30, 2006.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
1 Languages and Finite Automata or how to talk to machines...
CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state.
Topics Automata Theory Grammars and Languages Complexities
Fall 2006Costas Busch - RPI1 Languages. Fall 2006Costas Busch - RPI2 Language: a set of strings String: a sequence of symbols from some alphabet Example:
Cs466(Prasad)L3RE1 Representation of Languages. cs466(Prasad)L3RE2 Need finite descriptions of infinite sets of strings (=> specify languages). Discover.
Fall 2004COMP 3351 Languages. Fall 2004COMP 3352 A language is a set of strings String: A sequence of letters/symbols Examples: “cat”, “dog”, “house”,
Computer Literacy Chapter 1. IBM 360 ~1970About 2 MB (1/500 GB) memory.
MA/CSSE 474 Theory of Computation Course Intro. Today's Agenda Student questions Overview of yesterday's proof –I placed online a "straight-line" writeup.
Lexical Analysis CSE 340 – Principles of Programming Languages Fall 2015 Adam Doupé Arizona State University
CMPS 3223 Theory of Computation Automata, Computability, & Complexity by Elaine Rich ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slides provided.
CS/IT 138 THEORY OF COMPUTATION Chapter 1 Introduction to the Theory of Computation.
CSC312 Automata Theory Lecture # 2 Languages.
CSC312 Automata Theory Lecture # 2 Languages.
Costas Busch - LSU1 Languages. Costas Busch - LSU2 Language: a set of strings String: a sequence of symbols from some alphabet Example: Strings: cat,
1 Chapter 1 Automata: the Methods & the Madness Angkor Wat, Cambodia.
Formal Methods in SE Theory of Automata Qasiar Javaid Assistant Professor Lecture # 06.
1 CSSE 350 Automata, Formal Languages, and Computability.
Two examples English-Words English-Sentences alphabet S ={a,b,c,d,…}
TM Design Universal TM MA/CSSE 474 Theory of Computation.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
MA/CSSE 474 Theory of Computation Functions, Closure, Decision Problems.
1 INFO 2950 Prof. Carla Gomes Module Modeling Computation: Language Recognition Rosen, Chapter 12.4.
1 Chapter 1 Introduction to the Theory of Computation.
Languages, Grammars, and Regular Expressions Chuck Cusack Based partly on Chapter 11 of “Discrete Mathematics and its Applications,” 5 th edition, by Kenneth.
Grammars CPSC 5135.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet:
1 Exercise: Prove that the set S = { π : π is a permutation of {1, 2, 3, …, n} for some integer n ≥ 1 } is countable.
MA/CSSE 474 Theory of Computation Regular Expressions Intro.
Languages and Strings Chapter 2. (1) Lexical analysis: Scan the program and break it up into variable names, numbers, etc. (2) Parsing: Create a tree.
Strings and Languages CS 130: Theory of Computation HMU textbook, Chapter 1 (Sec 1.5)
Overview of Previous Lesson(s) Over View  Symbol tables are data structures that are used by compilers to hold information about source-program constructs.
Properties of Regular Languages
CS 203: Introduction to Formal Languages and Automata
Languages and Strings Chapter 2.
Strings and Languages Denning, Section 2.7. Alphabet An alphabet V is a finite nonempty set of symbols. Each symbol is a non- divisible or atomic object.
1 Strings and Languages Lecture 2-3 Ref. Handout p12-17.
Set, Alphabets, Strings, and Languages. The regular languages. Clouser properties of regular sets. Finite State Automata. Types of Finite State Automata.
1 Let S = { π : π is a permutation of {1, 2, 3, …, n} for some integer n ≥ 1 }. (a) List the elements of S for n= 1, 2, and 3. (b) Prove that the set S.
MA/CSSE 474 Theory of Computation How many regular/non-regular languages are there? Closure properties of Regular Languages (if there is time) Pumping.
MA/CSSE 474 Theory of Computation Languages, prefixes, sets, cardinality, functions.
Week 14 - Friday.  What did we talk about last time?  Simplifying FSAs  Quotient automata.
MA/CSSE 474 Theory of Computation Decision Problems, Continued DFSMs.
Languages and Strings Chapter 2. (1) Lexical analysis: Scan the program and break it up into variable names, numbers, etc. (2) Parsing: Create a tree.
MA/CSSE 474 Theory of Computation Regular Expressions Intro.
MA/CSSE 474 Theory of Computation Course Intro More about strings and languages.
Languages.
Lexical Analysis CSE 340 – Principles of Programming Languages
Languages Prof. Busch - LSU.
Languages Costas Busch - LSU.
Properties of Regular Languages
Languages, prefixes, sets, cardinality, functions
CMPS 3223 Theory of Computation
Assume that p, q, and r are in
Languages, prefixes, sets, cardinality, functions
Chapter 1 Introduction to the Theory of Computation
CSC312 Automata Theory Lecture # 2 Languages.
Languages Fall 2018.
Presentation transcript:

Why Study the Theory of Computation? Implementations come and go. Chapter 1

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

Programming in the 1970’s (IBM 360) //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

Guruhood

It’s about the Problem! Is there any computational solution to the problem? –If not, is there a restricted but useful variation of the problem for which a solution exists? If a solution exists, can it be implemented using some fixed amount of memory? If a solution exists, how efficient is it? –More specifically, how do its time and space requirements grow as the size of the problem grows? Are there groups of problems that are equivalent in the sense that –if there is an efficient solution to one member of the group, there is an efficient solution to all the others?

Applications of the Theory FSMs for parity checkers, vending machines, communication protocols, and building security devices. Interactive games as nondeterministic FSMs. Programming languages, compilers, and context-free grammars. Natural languages are mostly context-free. Speech understanding systems use probabilistic FSMs. Computational biology: DNA and proteins are strings. The undecidability of a simple security model. Artificial intelligence: the undecidability of first-order logic.

Languages and Strings Chapter 2

A Framework for Analyzing Problems We need a single framework in which we can analyze a very diverse set of problems. The framework we will use is Language Recognition – Given some string s and some language L, is s in L? A language is a (possibly infinite) set of finite length strings over a finite alphabet.

Strings An alphabet  is a finite set of symbols or characters. A string is a finite sequence, possibly empty, of symbols drawn from some alphabet .  is the empty string.  * is the set of all possible strings over an alphabet . Alphabet nameAlphabet symbolsExample strings The English alphabet { a, b, c, …, z } , aabbcg, aaaaa The binary alphabet { 0, 1 } , 0, A star alphabet{ ,, , , ,  } ,,  A music alphabet { , , , , , , } , 

Functions on Strings Length: |s| is the number of symbols in s. |  | = 0 | | = 7 Counting: # c (s) is the number of times that c occurs in s. # a ( abbaaa ) = 4.

More Functions on Strings Concatenation: st is the concatenation of s and t. If x = good and y = bye, then xy = goodbye. Note that |xy| = |x| + |y|.  is the identity for concatenation of strings. So:  x (x  =  x = x). Concatenation is associative. So:  s, t, w ((st)w = s(tw)).

More Functions on Strings Replication: For each string w and each natural number i, the string w i is: w 0 =  w i+1 = w i w |w i | = _____ Examples: a 3 = aaa ( bye ) 2 = byebye a 0 b 3 = bbb

More Functions on Strings Reversal: For each string w, w R is defined as: if |w| = 0 then w R = w =  if |w|  1 then:  a   (  u   * (w = ua)). Then define w R = a u R.

Concatenation and 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

Concatenation and Reverse of Strings Proof: By induction on |x|: Base Case: |x| = 0: Then x = , and (wx) R = (w  ) R = (w) R =  w R =  R w R = x R w R. Induction Step:  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

Relations on Strings aaa is a substring of aaabbbaaa aaaaaa is not a substring of aaabbbaaa aaa is a proper substring of aaabbbaaa Every string is a substring of itself.  is a substring of every string.

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.

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.

Defining a Language A language is a (finite or infinite) set of strings over a finite alphabet . Examples: Let  = { a, b } Some languages over  : , {  }, { a, b }, { , a, aa, aaa, aaaa, aaaaa } The language  * contains an infinite number of strings, including: , a, b, ab, ababaa.

Example Language Definitions L = {x  { a, b }* : all a ’s precede all b ’s} , a, aa, aabbb, and bb are in L. aba, ba, and abc are not in L. What about: , a, aa, and bb ?

Example Language Definitions L = {x :  y  { a, b }* : x = y a } Simple English description:

The Perils of Using English L = {x#y: x, y  { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }* and, when x and y are viewed as the decimal representations of natural numbers, square(x) = y}. Examples: 3#9, 12#144 3#8, 12, 12#12#12 #

More Example Language Definitions L = {} =  L = {  }

English L = {w: w is a sentence in English}. Examples: Kerry hit the ball. Colorless green ideas sleep furiously. The window needs fixed. Ball the Stacy hit blue.

A Halting Problem Language L = {w: w is a C program that halts on all inputs}. Well specified. Can we decide what strings it contains?

Prefixes What are the following languages: L = {w  { a, b }*: no prefix of w contains b } L = {w  { a, b }*: no prefix of w starts with b } L = {w  { a, b }*: every prefix of w starts with b }

Using Replication in a Language Definition L = { a n : n  0}

Languages Are Sets Computational definition: Generator (enumerator) Recognizer

Enumeration Enumeration: Arbitrary order More useful: lexicographic order Shortest first Within a length, dictionary order The lexicographic enumeration of: {w  { a, b }* : |w| is even} :

How Large is a Language? The smallest language over any  is , with cardinality 0. The largest is  *. How big is it?

How Large is a Language? Theorem: If    then  * is countably infinite. Proof: The elements of  * can be lexicographically enumerated by the following procedure: Enumerate all strings of length 0, then length 1, then length 2, and so forth. Within the strings of a given length, enumerate them in dictionary order. This enumeration is infinite since there is no longest string in  *. Since there exists an infinite enumeration of  *, it is countably infinite.

How Large is a Language? So the smallest language has cardinality 0. The largest is countably infinite. So every language is either finite or countably infinite.

How Many Languages Are There? Theorem: If    then the set of languages over  is uncountably infinite. Proof: The set of languages defined on  is P (  *).  * is countably infinite. If S is a countably infinite set, P (S) is uncountably infinite. So P (  *) is uncountably infinite.

Functions on Languages Set operations Union Intersection Complement Language operations Concatenation Kleene star

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 1 = a * L 2 = b * L 1 L 2 =

Concatenation of Languages {  } is the identity for concatenation: L{  } = {  }L = L  is a zero for concatenation: L  =  L = 

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}

Kleene Star L* = {  }  {w   * :  k  1 (  w 1, w 2, … w k  L (w = w 1 w 2 … w k ))} Example: L = { dog, cat, fish } L* = { , dog, cat, fish, dogdog, dogcat, fishcatfish, fishdogdogfishcat, …}

The + Operator L + = L L* L + = L* - {  } iff   L L + is the closure of L under concatenation.

Concatenation and Reverse of Languages Theorem: (L 1 L 2 ) R = L 2 R L 1 R. Proof:  x (  y ((xy) R = y R x R )) Theorem 2.1 (L 1 L 2 ) R = {(xy) R : x  L 1 and y  L 2 }Definition of concatenation of languages = {y R x R : x  L 1 and y  L 2 }Lines 1 and 2 = L 2 R L 1 R Definition of concatenation of languages

What About Meaning? A n B n = { a n b n : n  0}. Do these strings mean anything?

Semantic Interpretation Functions A semantic interpretation function assigns meanings to the strings of a language. English: I brogelled the yourtish. The semantic interpretation function for English is mostly compositional. He’s all thumbs.

Semantic Interpretation Functions For formal languages: Programming languages Network protocol languages Database query languages HTML BNF For other kinds of “natural” languages: DNA