This action might not be possible to undo. Are you sure you want to continue?

Ivan Stojmenovic Ivan@site.uottawa.ca www.site.uottawa.ca/~ivan I. Theory of Automata II. Theory of Formal Languages III. Theory of Turing Machines

Zaguia/Stojmenovic

1

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 Introduction to Computer Theory, Daniel Cohen, Wiley, 2nd edition. Course notes will be available on the web page of the course: www.site.uottawa.ca\~ivan\csi3104

MANUEL:

Zaguia/Stojmenovic

2

CSI 3104 /Winter 2007: Introduction to Formal Languages

**Approximate Course Outline:
**

1. 2. 3. 4. 5. 6. 7. January 5, Introduction, Languages, Recursive Definitions, (Chapters 1, 2, 3) January 12, Regular Expressions (Ch. 4), Finite Automata (Ch. 5) Transition Graphs (Ch. 6) January 19, Kleene's Theorem (Chapter 7) January 26, Nondeterministic Finite Automata (Ch. 7), Finite Automata with Output (Ch. 8) , February 2, MIDTERM February 9, Regular Languages (Ch. 9) Non-regular Languages (Ch. 10), Decidability (Ch. 11) 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 318-327) 10. March 16, Non-Context-Free Languages, Context-Free Languages, (Chapters 16, 17) 11. March 23, Decidability, Parsing, Turing Machines, (Chapters 18 pages 402-410 and 415-423 , 19) 12. March 30, Recursively Enumerable Languages, (Chapter 23) April 6, Easter Break

Zaguia/Stojmenovic

3

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/Stojmenovic

4

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/Stojmenovic 5 .

Markov. Pitts Neural nets (similar but with different limitations) Chomsky mathematical models for the description of languages Zaguia/Stojmenovic 6 . Post.Introduction Cantor (1845-1918) theory of sets Hilbert (1862-1943) methodology for finding proofs GÖdel (1906-1978) Incompleteness theorem Church. Turing Which statements have proofs? building blocks of mathematical algorithms Turing (1912-1954) Universal machine and its limitations McCulloch. Kleene. von Neumann.

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

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

.e. sufficiently powerful to do anything ? Which languages require more complicated machines? Zaguia/Stojmenovic 9 .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.

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

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

product Kleene star. Post machine. product. II. complement Yes I. product. membership Not much Examples of Applications Text editors.Introduction p. Kleene star Zaguia/Stojmenovic Yes 12 . Contextfree grammar Type 0 grammar No Union. emptiness. Pushdown automaton Language Closed Under Union. Formal Languages Nondeterminism= Determinism III. III. intersection. Automata Language Defined by Regular expression II. Turing Machines What Can Be Decided? Equivalence. Kleene star Union. membership Emptiness. verification Parsing.434: I. transition graph Pushdown automaton Turing machine. compilers Computers Corresponding Accepting Machine Finite automaton. sequential circuits. finiteness. finiteness.

denoted 7 letter characters an element of an alphabet 7 word a finite sequence of letters from the alphabet 7 7 .Languages Definitions alphabet a finite set of symbols.the set of all words on 7 0 (empty string) a word without letters language a set of words formed from the alphabet 7 (a subset of 7*) Zaguia/Stojmenovic 13 .

c.Languages Two examples English-Words alphabet 7 ={a. } English-Sentences 7 =words in dictionary + space + punctuation marks letter word language letter word all the words in the dictionary word sentence all English sentences Zaguia/Stojmenovic 14 .d.b.

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

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

} ={x | n=0. } Zaguia/Stojmenovic 17 . xx. 2. 5. xxxx. xxxx. 3. xxx.Languages Example L1: 7 ={x} n L1={x. } We denote x0 = 0 L2 = {w in 7: w has an odd number of characters} = {x. xx. 3. xxxxx. } or L1={x | n=1. xxx. 3. } n 7 = {0x. xxx. 1. 2. } = {xn | n=1.

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

aa. bbb. bab.Languages reverse reverse(xxx)=xxx reverse(157)=751 reverse(acb)=bca Example: PALINDROME 7={a. bb. b. } Zaguia/Stojmenovic 19 . b} PALINDROME:={0 and w in 7| reverse(w) = w} = {0a. aaa. aba.

Languages Concatenation of two words two words written down side by side. u=xx v=xxx uv=xxxxx u = abb v=aa uv=abbaa u = u1u2 um v=v1v2 vn uv= u1u2 um v1v2 vn factor one of the words in a concatenation Property: length(uv) = length(u) + length(v) Zaguia/Stojmenovic 20 . A new word is formed.

1} L1 = {u in 7: the number of zeros in u is even} L2 = {u in 7: u starts with a 0 and all the remaining characters are 1 s} L1L2 = {u in 7: the number of zeros in u is odd} Zaguia/Stojmenovic 21 . L1L2. is the set of all words which are a concatenation of a word in L1 with a word in L2 .Languages Concatenation of two languagesThe concatenation of two languages L1 and L2. L1L2 = {uv: u is in L1 and v is in L2} Example: 7={0.

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

. L* ={u in 7: u= u1u2 um . u2.Languages closure or Kleene star of a set of words (a language) It is a generalization of 7 to a more general set of words. um are in L} Zaguia/Stojmenovic 23 . including the empty string 0. Let 7 be an alphabet and let L be a set of words on 7. L* is the language formed by concatenating words from L. where u1.

aba. a. ab. aab. aaaa. } factors) abaaababa L* (ab|a|a|ab|ab|a L* = {0 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/Stojmenovic 24 . aa. aaa.Languages Examples: L = {a. ab} L* = {0.

always produces an infinite language unless L is empty or L={0}. xxx} xxxxxxx L* xx|xxx|xx xxx|xx|xx xx|xx|xxx L* = {0 and all sequences of more than one x} = {xn : x 1} If L = J then L* = {0} The Kleene closure L*.Languages L = {xx. of a language L. Zaguia/Stojmenovic 25 .

Languages Example: S = {a. ab} T = {a. bb} S* = T* although S T ab|a|a|ab|ab|a a|b|a|a|a|b|a|b|a Zaguia/Stojmenovic 26 . b. b.

0.Languages Definition: L+. aabbb. 0} S+ = {aa. aaaa. } S = {aa. xxx. L* = L+. } ( a0 = a) Zaguia/Stojmenovic 27 . xx. Otherwise L* = L+ .{0a Examples: 7 = {x} 7 = {x. 7 L+ = language with all concatenations that contain at least (L* without 0) 1 word from L 1 letter from 7 If 0 is a member of L. bbb. bbb.

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

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

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

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

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

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

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

Recursive Definitions Theorem: 5x3-8x+7 is in POLYNOMIAL Rule 1: Rule 2: Rule 3: Rule 3: Rule 3: Rule 1: Rule 3: Rule 3: Rule 1: Rule 3: 5 POLYNOMIAL x POLYNOMIAL 5x POLYNOMIAL 5xx = 5x2 POLYNOMIAL 5x2x = 5x3 POLYNOMIAL 8 POLYNOMIAL 8x POLYNOMIAL 5x3 8x POLYNOMIAL 7 POLYNOMIAL 5x3 8x + 7 POLYNOMIAL Is this derivation unique? Zaguia/Stojmenovic 35 .

then xw is in 7+ Rule 1: 0 7* Rule 2: If w is in 7*.Recursive Definitions OTHER EXAMPLES 7+. 7={x} S-ODD. 7={x} . then xw is in 7* Rule 1: x S-ODD Rule 2: If w is in S-ODD then xxw is in S-ODD Zaguia/Stojmenovic 36 7*. 7={x} Rule 1: x 7+ Rule 2: If w is in 7+.

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

8.+. (x) x (as long as x does not already start with a sign) Zaguia/Stojmenovic 38 .1. the following words are also in AE: 1.7. 2. .5.6. Rule 2: If x is in AE.(.4./.)} Rule 1: All numbers are in AE.Recursive Definitions AE (Arithmetic Expressions) 7 = {0.9.*.2.3.

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

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

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

9} 0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 0 (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 If d=9 then (v) = wm(d) (v) = (w)0 Zaguia/Stojmenovic 42 .Recursive Definitions Function successor D = {0. 2. 1. d m(d) :NpN .

Sign up to vote on this title

UsefulNot useful- Theory of Automata - Solved Assignments - Semester Spring 2010
- COS2601 - WikiStudent, Unisa
- Automata Questions
- Theory of Automata by Cohen
- 2 - Recursive Definition
- Assignment 2Sou
- -Chapter 3-Danial I. A Cohen-Computer Theory
- Solution Manual
- Chapter 5-Computer Theory BY Danial I. A Cohen
- Chapter 5 - Finite Automata
- Chomsky_hierarchy
- QXI
- idaacs2011-clanek
- Recursively Enumerable Languages
- FL_sp
- Chomsky Hier Achy
- QIV.pdf
- class8
- QVIII
- Tcs in Concise
- Mood and Modality
- Theory of it
- Mildly Context-Sensitive Languages
- Top School in Delhi NCR
- Named Entity Recognition System for Hindi Language
- Slips of the Hands Texas CUP
- Nlp-Automata in Nlp
- Kay - Programming and Programming Languages
- ijnlc020306
- Psych Midterm P3
- Chapter1-2-3