Zaguia/Stojmenovic1 CSI 3104 /Winter 2007: Introduction to Formal Languages Ivan Stojmenovic I. Theory of.

Slides:



Advertisements
Similar presentations
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Advertisements

Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
YES-NO machines Finite State Automata as language recognizers.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture5: Context Free Languages Prof. Amos Israeli.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
Normal forms for Context-Free Grammars
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
Introduction to CS Theory Lecture 1 – Introduction Piotr Faliszewski
Chapter 2 Languages.
Week 14 - Friday.  What did we talk about last time?  Exam 3 post mortem  Finite state automata  Equivalence with regular expressions.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
::ICS 804:: Theory of Computation - Ibrahim Otieno SCI/ICT Building Rm. G15.
CS490 Presentation: Automata & Language Theory Thong Lam Ran Shi.
CS/IT 138 THEORY OF COMPUTATION Chapter 1 Introduction to the Theory of Computation.
DECIDABILITY OF PRESBURGER ARITHMETIC USING FINITE AUTOMATA Presented by : Shubha Jain Reference : Paper by Alexandre Boudet and Hubert Comon.
CSC312 Automata Theory Lecture # 2 Languages.
L ECTURE 1 T HEORY OF A UTOMATA. P RAGMATICS  Pre-Requisites  No Pre-Requisite  Text book  Introduction to Computer Theory by Daniel I.A. Cohen 
Formal Methods in SE Theory of Automata Qasiar Javaid Assistant Professor Lecture # 06.
Introduction to Theory of Automata
Two examples English-Words English-Sentences alphabet S ={a,b,c,d,…}
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
1 Language Definitions Lecture # 2. Defining Languages The languages can be defined in different ways, such as Descriptive definition, Recursive definition,
1 INFO 2950 Prof. Carla Gomes Module Modeling Computation: Language Recognition Rosen, Chapter 12.4.
1 Chapter 1 Introduction to the Theory of Computation.
Grammars CPSC 5135.
CS 3813: Introduction to Formal Languages and Automata
1 Computability Five lectures. Slides available from my web page There is some formality, but it is gentle,
Introduction to Language Theory
Module 2 How to design Computer Language Huma Ayub Software Construction Lecture 8.
Lecture # 5 Pumping Lemma & Grammar
Recursive Definitions & Regular Expressions (RE)
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
Saeid Pashzadeh Jan 2009 Theory of Computation 1.
CSC312 Automata Theory Lecture # 1 Introduction.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
CS 203: Introduction to Formal Languages and Automata
Recursive Definations Regular Expressions Ch # 4 by Cohen
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
Lecture # Book Introduction to Theory of Computation by Anil Maheshwari Michiel Smid, 2014 “Introduction to computer theory” by Daniel I.A. Cohen.
Theory of computation Introduction theory of computation: It comprises the fundamental mathematical properties of computer hardware, software,
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Finite-State Machines Fundamental Data Structures and Algorithms Peter Lee March 11, 2003.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
Lecture 6: Context-Free Languages
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
Lecture 02: Theory of Automata:2014 Asif Nawaz Theory of Automata.
Set, Alphabets, Strings, and Languages. The regular languages. Clouser properties of regular sets. Finite State Automata. Types of Finite State Automata.
Theory of Languages and Automata By: Mojtaba Khezrian.
CS 154 Formal Languages and Computability May 12 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
The Church-Turing Thesis Chapter Are We Done? FSM  PDA  Turing machine Is this the end of the line? There are still problems we cannot solve:
Week 14 - Friday.  What did we talk about last time?  Simplifying FSAs  Quotient automata.
Lecture 01: Theory of Automata:2013 Asif Nawaz Theory of Automata.
Lecture 17: Theory of Automata:2014 Context Free Grammars.
Theory of Computation. Introduction to The Course Lectures: Room ( Sun. & Tue.: 8 am – 9:30 am) Instructor: Dr. Ayman Srour (Ph.D. in Computer Science).
Theory of Computation Lecture #
Lecture 1 Theory of Automata
CIS Automata and Formal Languages – Pei Wang
Theory of Computation Theory of computation is mainly concerned with the study of how problems can be solved using algorithms.  Therefore, we can infer.
Chapter 1 Introduction to the Theory of Computation
CSC312 Automata Theory Lecture # 2 Languages.
Presentation transcript:

Zaguia/Stojmenovic1 CSI 3104 /Winter 2007: Introduction to Formal Languages Ivan Stojmenovic I. Theory of Automata II. Theory of Formal Languages III. Theory of Turing Machines

Zaguia/Stojmenovic2 CSI 3104 /Winter 2007: Introduction to Formal Languages CSI 3104 Introduction to Formal Languages (3 hours of lecture per week, 3 credits) Regular languages, finite automata, transition graphs, Kleene's theorem. Finite automata with output. Context-free languages, derivation trees, normal form grammars, pumping lemma, pushdown automata, determinism. Decidability. Recursively enumerable languages, Turing machines, the halting problem. Prerequisites: MAT1361, MAT2343 or MAT2143. PROFESSOR: Ivan Stojmenovic LECTURES: Fridays, 14:30-17:30, LMX 405 MANUEL: Introduction to Computer Theory, Daniel Cohen, Wiley, 2 nd edition. Course notes will be available on the web page of the course:

Zaguia/Stojmenovic3 CSI 3104 /Winter 2007: Introduction to Formal Languages Approximate Course Outline: 1. January 5, Introduction, Languages, Recursive Definitions, (Chapters 1, 2, 3) 2. January 12, Regular Expressions (Ch. 4), Finite Automata (Ch. 5) Transition Graphs (Ch. 6) 3. January 19, Kleene's Theorem (Chapter 7) 4. January 26, Nondeterministic Finite Automata (Ch. 7), Finite Automata with Output (Ch. 8), 5. February 2, MIDTERM 6. February 9, Regular Languages (Ch. 9) Non-regular Languages (Ch. 10), Decidability (Ch. 11) 7. February 16, Context-Free Grammars (Ch. 12), Grammatical Format (=CNF, Ch. 13) February 23, Study Break 8. March 2, Pushdown Automata (Chapter 14) 9. March 9, Context-Free Grammars = Pushdown Automata, Chapter 15 (pages ) 10. March 16, Non-Context-Free Languages, Context-Free Languages, (Chapters 16, 17) 11. March 23, Decidability, Parsing, Turing Machines, (Chapters 18 “pages and ”, 19) 12. March 30, Recursively Enumerable Languages, (Chapter 23) April 6, Easter Break

Zaguia/Stojmenovic4 Introduction to Formal Languages Evaluation A= 4 assignments, 20% (late assignments not accepted; deadlines lectures 3, 4, 10 and 12) M= Midterm, 30% (in class, closed book) F= Final Exam, 50% IF.3M+.5F >= 40 THEN FM=.2A+.3M+.5F ELSE FM= 1.25(.3M+.5F)

Zaguia/Stojmenovic5 Introduction Two basic questions: What is a computer good for? What can & can’t a computer compute? Why? Want precise answers: Formulate unambiguous questions & proofs, using formal models of computers/computation. Using precise, mathematical writing

Zaguia/Stojmenovic6 Introduction Cantor ( ) theory of sets Hilbert ( ) methodology for finding proofs GÖdel ( ) Incompleteness theorem Church, Kleene, Post, Markov, von Neumann, Turing Which statements have proofs? building blocks of mathematical algorithms Turing ( ) Universal machine and its limitations McCulloch, Pitts Neural nets (similar but with different limitations) Chomsky mathematical models for the description of languages

Zaguia/Stojmenovic7 Introduction Theory of computers Study of mathematical models Abstract Simplify Codify (relate in a meaningful way to the physical world) Computability

Zaguia/Stojmenovic8 Introduction Language: Some set of strings of symbols, of interest. E.g., all valid English words. Machine: A formal description of a “computer”. Based on states & transitions between states. Computes some output from input. Grammar: Rules for deriving & parsing strings in some language.

Zaguia/Stojmenovic9 Introduction We will be interested in relations such as… Which machines recognize which languages? Does extending a class of machines with more features also extend the class of languages about to be described? What machines are universal? I.e., sufficiently powerful to do “anything”? Which languages require more complicated machines?

Zaguia/Stojmenovic10 Introduction We will be interested in properties such as… Decidability= What questions can be answered? Computability= What languages can be computed?

Zaguia/Stojmenovic11 Introduction Many computation models exist. Can’t cover them all. Will concentrate on 3 groups of models: Each proven pragmatically useful. Presented in order of increasing power. 1. Regular languages & Finite automata 2. Context-free languages & Push-down automata 3. Recursively-enumerable languages & Turing machines

Zaguia/Stojmenovic12 Introduction Language Defined by Corresponding Accepting Machine Nondeter- minism= Determinism Language Closed Under What Can Be Decided? Examples of Applications Regular expression Finite automaton, transition graph Yes Union,product Kleene star, intersection, complement Equivalence, emptiness, finiteness, membership Text editors, sequential circuits, verification Context- free grammar Pushdown automaton NoUnion, product, Kleene star Emptiness, finiteness, membership Parsing, compilers Type 0 grammar Turing machine, Post machine, Pushdown automaton YesUnion, product, Kleene star Not muchComputers I. III. II. p.434: I. Automata II. Formal Languages III. Turing Machines

Zaguia/Stojmenovic13 Languages Definitions alphabet – a finite set of symbols, denoted  letter – “characters” an element of an alphabet  word – a finite sequence of letters from the alphabet     - the set of all words on   (empty string) – a word without letters language – a set of words formed from the alphabet  (a subset of  * )

Zaguia/Stojmenovic14 Languages English-WordsEnglish-Sentences alphabet  ={a,b,c,d,…}  =words in dictionary + space + punctuation marks letter word sentence languageall the words in the dictionary all English sentences Two examples

Zaguia/Stojmenovic15 Languages It is very difficult to define the complete English language with a finite number of rules. We cannot too simply list all acceptable sentences. Grammatical rules are not enough: « I ate two Mondays »

Zaguia/Stojmenovic16 Languages In general, the interesting languages have the following properties: Well defined « without ambiguity ». Using a formula, a property or a finite set of rules, We should be able to recognize in a finite time, whether any given word is in the language.

Zaguia/Stojmenovic17 Languages Example L 1 :  ={x} L 1 ={x, xx, xxx, xxxx,…} or L 1 ={x n | n=1, 2, 3,…}   = {  x, xx, xxx, xxxx,…} ={x n | n=0, 1, 2, 3,…} We denote x 0 =  L 2 = {w in   : w has an odd number of characters} = {x, xxx, xxxxx, … } = {x n | n=1, 3, 5, … }

Zaguia/Stojmenovic18 Languages Operations on Words: length – number of letters in a word length(xxxxx) = 5 length(1025)=4 length(  )=0  = {0, 1} L1 = set of all words in   starting with 1 and with length at most three = {1, 10, 11, 101, 100, 110, 111}

Zaguia/Stojmenovic19 Languages reverse reverse(xxx)=xxx reverse(157)=751 reverse(acb)=bca Example: PALINDROME   ={a, b}  PALINDROME:={  and w in   | reverse(w) = w}  = {  a, b, aa, bb, aaa, aba, bbb, bab, … }

Zaguia/Stojmenovic20 Languages Concatenation of two words – two words written down side by side. A new word is formed. u=xx v=xxx uv=xxxxx u = abbv=aauv=abbaa u = u 1 u 2 …u m v=v 1 v 2 … v n uv= u 1 u 2 …u m v 1 v 2 … v n factor – one of the words in a concatenation Property: length(uv) = length(u) + length(v)

Zaguia/Stojmenovic21 Languages Concatenation of two languages- The concatenation of two languages L 1 and L 2, L 1 L 2, is the set of all words which are a concatenation of a word in L 1 with a word in L 2. L 1 L 2 = {uv: u is in L 1 and v is in L 2 } Example:  ={0, 1} L 1 = {u in   : the number of zeros in u is even} L 2 = {u in   : u starts with a 0 and all the remaining characters are 1’s} L 1 L 2 = {u in   : the number of zeros in u is odd}

Zaguia/Stojmenovic22 Languages closure of an alphabet , Kleene star *  Given an alphabet  the closure of  (or Kleene star), denoted  *, is the language containing all words made up of finite sequences of letters from , including the empty string . Examples:  = {x}  * = { , x, xx, xxx, …}  = {0, 1}  * = { , 0, 1, 00, 01, 10, 11, 000, 001, …}  = {a, b, c}  * = ?

Zaguia/Stojmenovic23 closure or Kleene star of a set of words (a language)  It is a generalization of   to a more general set of words.  Let  be an alphabet and let L be a set of words on .  L* is the language formed by concatenating words from L, including the empty string .  L* ={u in   : u= u 1 u 2 …u m, where u 1, u 2, …, u m are in L} Languages

Zaguia/Stojmenovic24 Languages Examples: L = {a, ab} L* = { , a, aa, ab, aaa, aab, aba, aaaa, …} abaaababa  L* (ab|a|a|ab|ab|a factors) L* = {  plus all sequences of a’s and b’s except those that start with b and those that contain a double b} Is the factoring always unique?

Zaguia/Stojmenovic25 Languages L = {xx, xxx} xxxxxxx  L* xx|xx|xxx xx|xxx|xx xxx|xx|xx L* = {  and all sequences of more than one x} = {x n : x≠1} If L =  then L * = {  } The Kleene closure L*, of a language L, always produces an infinite language unless L is empty or L={  }.

Zaguia/Stojmenovic26 Languages Example: S = {a, b, ab} T = {a, b, bb} S* = T* although S ≠ T ab|a|a|ab|ab|a a|b|a|a|a|b|a|b|aa|b|a|a|a|b|a|b|a

Zaguia/Stojmenovic27 Languages Definition: L+,   L+ = language with all concatenations that contain at least  1 word from L 1 letter from   (L* without  )  If  is a member of L, L* = L+. Otherwise L* = L+ - {  Examples:  = {x}  = {x, xx, xxx, …} S  = {aa, bbb,  } S+ = {aa, bbb, , aaaa, aabbb, …} ( a  = a)

Zaguia/Stojmenovic28 Languages Theorem 1: For any set of words S, we have S*=S**. Definitions: equality of sets S = T: S  T et T  S subsets S  T: for all x in S, x is also in T Example: S = {a,b} aaba, baaa, aaba  S* aaba|baaa|aaba  S** a|a|b|a|b|a|a|a|a|a|b|a  S*

Zaguia/Stojmenovic29 Languages Proof of Theorem 1: S*=S** : S**  S* Every word in S** is made up of factors from S* (definition of Kleene star). Every word in S* is made up of factors from S. Therefore, every word in S** is also a word in S*. Thus S**  S*. S*  S** For any set A, we can show that A  A*. Let w be a word in A. Then w is certainly in A*. If S* = A, we can conclude S*  S**. By definition of equality of sets, we have S* = S**.

Zaguia/Stojmenovic30 Recursive Definitions RECURSIVE DEFINITIONS A new method to define languages: 3 steps: 1. Specify the basic words (base case). 2. Rules for constructing new words from ones already known (recursive case). 3. Declare that no word except those constructed by following rules 1 and 2 are in the language. The same method could be used to define sets in general.

Zaguia/Stojmenovic31 Recursive Definitions Example EVEN is the set of all whole numbers divisible by 2. EVEN = {2n | n = 1, 2, 3, 4, …} EVEN is defined by the rules: 1. 2 is in EVEN. 2. If x is in EVEN, x+2 is in EVEN. 3. The only elements in EVEN are the ones that are constructed by following rules 1 and 2.

Zaguia/Stojmenovic32 Recursive Definitions Prove: 12 is in EVEN Divisible by 2? Yes, 12/2 = = 2n? Yes, n = 6. Rules of the recursive definition? Rule 1: 2  EVEN Rule 2: x=2, 2+2 = 4  EVEN Rule 2: x=4, 4+2 = 6  EVEN Rule 2: x=6, 6+2 = 8  EVEN Rule 2: x=8, 8+2 = 10  EVEN Rule 2: x=10, 10+2 = 12  EVEN

Zaguia/Stojmenovic33 Recursive Definitions Another equivalent recursive definition for the set EVEN  2 is in EVEN.  If x and y are in EVEN, x+y is in EVEN. Using the alternative definition Rule 1: 2  EVEN Rule 2: x=2, y=2, 2+2 = 4  EVEN Rule 2: x=4, y= = 8  EVEN Rule 2: x=4, y=8, 4+8 = 12  EVEN

Zaguia/Stojmenovic34 Recursive Definitions Example: Recursive definition of the set POLYNOMIAL  All numbers are in POLYNOMIAL.  The variable x is in POLYNOMIAL.  If p and q are in POLYNOMIAL, p+q, p – q, (p), and pq are also in POLYNOMIAL.  The only elements in POLYNOMIAL are the ones that are constructed by following rules 1, 2, and 3.

Zaguia/Stojmenovic35 Recursive Definitions Theorem: 5x 3 -8x+7 is in POLYNOMIAL Rule 1: 5  POLYNOMIAL Rule 2: x  POLYNOMIAL Rule 3: 5x  POLYNOMIAL Rule 3: 5xx = 5x 2  POLYNOMIAL Rule 3: 5x 2 x = 5x 3  POLYNOMIAL Rule 1: 8  POLYNOMIAL Rule 3: 8x  POLYNOMIAL Rule 3: 5x 3 – 8x  POLYNOMIAL Rule 1: 7  POLYNOMIAL Rule 3: 5x 3 – 8x + 7  POLYNOMIAL Is this derivation unique?

Zaguia/Stojmenovic36 Recursive Definitions OTHER EXAMPLES  +,  ={x} Rule 1: x   + Rule 2: If w is in  +, then xw is in  +  *,  ={x} Rule 1:    * Rule 2: If w is in  *, then xw is in  * S-ODD,  ={x} Rule 1: x  S-ODD Rule 2: If w is in S-ODD then xxw is in S-ODD

Zaguia/Stojmenovic37 Recursive Definitions Kleene closure S* of a language S Rule 1:  is in S*. All words in S are in S*. Rule 2: If x and y are in S*, their concatenation xy is also in S*. POSITIVE Rule 1: 1,2,3,4,5,6,7,8,9 are in POSITIVE Rule 2: If w is in POSITIVE, w0, w1, w2, w3, w4, w5, w6, w7, w8, w9 are also words in POSITIVE

Zaguia/Stojmenovic38 Recursive Definitions AE (Arithmetic Expressions)  = {0,1,2,3,4,5,6,7,8,9,+, –,*,/,(,)} Rule 1: All numbers are in AE. Rule 2: If x is in AE, the following words are also in AE: 1. (x) 2. – x (as long as x does not already start with a – sign)

Zaguia/Stojmenovic39 Recursive Definitions Rule 3: If x and y are in AE, the following words are also in AE: 1. x + y (as long as y does not already start with a – sign) 2. x – y (same condition) 3. x * y 4. x / y 5. x ** y

Zaguia/Stojmenovic40 Recursive Definitions Theorem 1: There is no word in AE that begins or ends with the symbol /. Proof: 1. No number contains the symbol /. So / is not introduced by rule Suppose that x does not begin or end with /. Neither (x) nor – x begin or end with /. (Rule 2) 3. Suppose that x and y do not begin or end with /. Then there is no expression introduced by rule 3 that begins or ends with /. All words in AE are constructed by applying the rules 1,2,3. Thus, no word in AE begins or ends with \.

Zaguia/Stojmenovic41 Recursive Definitions FORMULAS (of propositional logic) Rule 1: All Latin letters are in FORMULAS. Rule 2: If p is in FORMULAS, (p) et  p are also in FORMULAS. Rule 3: If p and q are in FORMULAS, p  q is in FORMULAS. The factorial function Rule 1: 0! = 1 Rule 2: n! = n(n-1)!

Zaguia/Stojmenovic42 Recursive Definitions Function successor σ : N  N D = {0, 1, 2, …, 9} d m(d) (i) If v is in D then If v  9 then σ (v) = m(v) If v= 9 then σ (v) = 10 (ii) If v = wd where d is in D then If d  9 then σ (v) = wm(d) If d=9 then σ (v) = σ (w)0