Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.

Slides:



Advertisements
Similar presentations
and other words that come before nouns Created by Robert Eastland
Advertisements

Chapter Three: Closure Properties for Regular Languages
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
THE PUMPING LEMMA PROVING A LANGUAGE IS NOT REGULAR Dr. Cynthia Lee - UCSD - Spring 2011 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia.
CSCI 2670 Introduction to Theory of Computing September 13, 2005.
CSCI 2670 Introduction to Theory of Computing September 15, 2004.
CS21 Decidability and Tractability
Lecture 15UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 15.
Automata and Formal Languages Tim Sheard 1 Lecture 8 Pumping Lemma & Distinguishability Jim Hook Tim Sheard Portland State University.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (more on Section 1.4) David Martin This work is licensed under.
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse.
Costas Busch - RPI1 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
LING 438/538 Computational Linguistics Sandiway Fong Lecture 12: 10/5.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
1 Module 36 Non context-free languages –Examples and Intuition Pumping lemma for CFL’s –Pumping condition –No proof of pumping lemma –Applying pumping.
1 More Applications of the Pumping Lemma. 2 The Pumping Lemma: Given a infinite regular language there exists an integer for any string with length we.
Courtesy Costas Busch - RPI1 Non-regular languages.
1 CSCI 3130: Formal Languages and Automata Theory Tutorial 4 Hung Chun Ho Office: SHB 1026 Department of Computer Science & Engineering.
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
Prof. Busch - LSU1 Non-regular languages (Pumping Lemma)
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.4: Nonregular Languages) David Martin With some.
1 Non-regular languages. 2 Regular languages Non-regular languages.
according to conventional patterns.
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
Extra on Regular Languages and Non-Regular Languages
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
UNIT 2 GRAMMAR: ADJECTIVE ORDER The noun: The word that is receiving the adjectives. NOUN A purpose adjective describes what something is used for. These.
GROUP 陳美霖 ROSA 林格毅 ARTHUR 蔡穎璇 LESLIE 曹蔚晨 WADE 張致翔 ALLEN 李維哲 JOSÉ 張志宇 ERIC Types.
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
The Pumping Lemma for Context Free Grammars. Chomsky Normal Form Chomsky Normal Form (CNF) is a simple and useful form of a CFG Every rule of a CNF grammar.
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
NLP. Introduction to NLP Is language more than just a “bag of words”? Grammatical rules apply to categories and groups of words, not individual words.
Tutorial: Reduction from A TM Proofs Dr. Cynthia Lee CSE 105, UCSD Spring 2011 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee,
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
Rules, Movement, Ambiguity
CS 3240 – Chapter 4.  Closure Properties  Algorithms for Elementary Questions:  Is a given word, w, in L?  Is L empty, finite or infinite?  Are L.
Class Discussion Can you draw a DFA that accepts the language {a k b k | k = 0,1,2,…} over the alphabet  ={a,b}?
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Conversions & Pumping Lemma CPSC 388 Fall 2001 Ellen Walker Hiram College.
CSCI 2670 Introduction to Theory of Computing September 13.
CS 203: Introduction to Formal Languages and Automata
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
Computability Regular expressions. Languages defined by regular expresses = Regular languages (languages recognized by FSM). Applications. Pumping lemma.
CSCI 3130: Formal languages and automata theory Tutorial 3 Chin.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
1 Find as many examples as you can of w, x, y, z so that w is accepted by this DFA, w = x y z, y ≠ ε, | x y | ≤ 7, and x y n z is in L for all n ≥ 0.
Equivalence with FA * Any Regex can be converted to FA and vice versa, because: * Regex and FA are equivalent in their descriptive power ** Regular language.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Lecture 8UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 8.
Complexity and Computability Theory I Lecture #12 Instructor: Rina Zviel-Girshin Lea Epstein.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
CSE 105 theory of computation
Complexity and Computability Theory I
according to conventional patterns.
Non-regular languages
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
Elementary Questions about Regular Languages
Non-regular languages
CS21 Decidability and Tractability
CSCI 2670 Introduction to Theory of Computing
Presentation transcript:

Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Based on a work at Cynthia Lee, UCSDCreative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported Licensewww.peerinstruction4cs.org

NON-REGULAR LANGUAGES On beyond Regular!

Next we’ll be talking about non- Regular Languages All part of becoming intimately familiar with the boundaries that define these language classes Closure properties are one way of doing exploring transformations that keep us in the boundaries of the class of Regular Languages Now we’re bursting through the boundary! It’s an exciting day!!

Next we’ll be talking about non- Regular Languages All part of becoming intimately familiar with the boundaries that define these language classes Closure properties are one way of doing exploring transformations that keep us in the boundaries of the class of Regular Languages Now we’re bursting through the boundary! It’s an exciting day!!

Next we’ll be talking about non- Regular Languages All part of becoming intimately familiar with the boundaries that define these language classes Closure properties are one way of doing exploring transformations that keep us in the boundaries of the class of Regular Languages Now we’re bursting through the boundary! It’s an exciting day!!

PIGEONHOLE PRINCIPLE For the birds

What is the longest string this DFA can accept without visiting any state more than once? a)1 b)3 c)4 d)5 e)None of the above

What is the longest string this DFA can accept without visiting any state more than once? a)1 b)2 c)3 d)4 e)None of the above

Generalizing: Given a string s in L, and a DFA M that recognizes L: – If |s| > |Q|, then when M processes s, it must visit one (or more) state(s) more than once For a second, let’s just consider one state being twice visited – Let y be the substring of s that is read between the first and second times the twice-visited state is visited – It must be the case that t could appear repeatedly in s: s = [first part of s]y[last part of s], then also possible in this DFA: [first part of s]yy[last part of s] [first part of s]yyyyyyyyyyy[last part of s] – WHY?? (Discuss in your groups)

THE PUMPING LEMMA PROVING A LANGUAGE IS NOT REGULAR On beyond Regular!

The Pumping Lemma: A One-Act Play Your Script “I’m giving you a language L.” “Uh…sure…let’s just say it’s Regular.” “Excellent. I’m giving you this string s that I made using your p. It is in L and |s| >= p. I think you’ll really like it.” “Hm. I followed your directions for xyz, but when I [copy y N times or delete y], the new string is NOT is L! What happened to your 100% Warranty??!” Pumping Lemma’s Script “Is L Regular? In this shop I only work on Regular Languages.” “Good. For the Regular language L that you’ve given me, I pick this nice pumping length I call p.” “Great string, thanks. I’ve cut s up into parts xyz for you. I won’t tell you what they are exactly, but I will say this: |y| > 0 and |xy| <= p. Also, I make you this 100% Lifetime Warranty: you can remove y, or copy it as many times as you like, and the new string will still be in L, I promise!” “Well, then L wasn’t a Regular Language. Since you lied, the Warranty was void. Thanks for playing.”

How to use the Pumping Lemma Script to write a Pumping Lemma Proof (1) Let’s look at the parts of your script: – Picking language L: Done—given to you in the homework/exam problem – Start the proof: Proof by contradiction: Assume L is regular – Picking s: Here you need to get creative Try several things, remember: – s must be in L – |s| must be >= p (often do this by making some pattern repeat p times, e.g., s = “0 p 1 p ” is clearly of length >= p)

The Pumping Lemma: A One-Act Play Your Script “I’m giving you a language L.” “Uh…sure…let’s just say it’s Regular.” “Excellent. I’m giving you this string s that I made using your p. It is in L and |s| >= p. I think you’ll really like it.” “Hm. I followed your directions for xyz, but when I [copy y N times or delete y], the new string is NOT is L! What happened to your 100% Warranty??!” Pumping Lemma’s Script “Is L Regular? In this shop I only work on Regular Languages.” “Thanks. For the language L that you’ve given me, I pick this nice pumping length I call p.” “Great string, thanks. I’ve cut s up into parts xyz for you. I won’t tell you what they are exactly, but I will say this: |y| > 0 and |xy| <= p. Also, I make you this 100% Lifetime Warranty: you can remove y, or copy it as many times as you like, and the new string will still be in L, I promise!” “Well, then L wasn’t a Regular Language. Since you lied, the Warranty was void. Thanks for playing.”

How to use the Pumping Lemma Script to write a Pumping Lemma Proof (2) Let’s look at the parts of your script: – Picking i (the number of times to copy part y): For many problems, two main ways to go: i = big: (say, 3 or p), or i = 0 (delete y) Try both and see if either “breaks” s (makes a string not in L) If several tries don’t work, you may need to design a different s – End the proof: Once you find an i/s pair that “breaks” the warranty, this is a contradiction, and so the assumption is false, and L is not Regular. QED.

Pumping Lemma Practice Thm. L = {O n 1 m O n | m,n >= 0} is not regular. Proof (by contradiction): Assume (towards contradiction) that L is regular. Then the pumping lemma applies to L. Let p be the pumping length. Choose s to be the string _________. The pumping lemma guarantees s can be divided into parts xyz s.t. for any i>=0, xy i z is in L, and that |y|>0 and |xy|<=p. But if we let i = ____, we get the string XXXX, which is not in L, a contradiction. Therefore the assumption is false, and L is not regular. Q.E.D. a)s = , i = 5 b)s = 0 p 10 p, i=0 c)s = (010) p, i=5 d)None or more than one of the above e)I don’t understand this at all

Pumping Lemma Practice Thm. L = {O n 1 n | n >= 0} is not regular. Proof (by contradiction): Assume (towards contradiction) that L is regular. Then the pumping lemma applies to L. Let p be the pumping length. Choose s to be the string _________. The pumping lemma guarantees s can be divided into parts xyz s.t. for any i>=0, xy i z is in L, and that |y|>0 and |xy|<=p. But if we let i = ____, we get the string XXXX, which is not in L, a contradiction. Therefore the assumption is false, and L is not regular. Q.E.D. a)s = , i = 0 b)s = , i=6 c)s = 0 p 1 p, i=1 d)s = 0 i 1 i, i=5 e)None or more than one of the above

Pumping Lemma Practice Thm. L = {ww r | w r is the reverse of w} is not regular. Proof (by contradiction): Assume (towards contradiction) that L is regular. Then the pumping lemma applies to L. Let p be the pumping length. Choose s to be the string _________. The pumping lemma guarantees s can be divided into parts xyz s.t. for any i>=0, xy i z is in L, and that |y|>0 and |xy|<=p. But if we let i = ____, we get the string XXXX, which is not in L, a contradiction. Therefore the assumption is false, and L is not regular. Q.E.D. a)s = , i=6 b)s = 0 p 0 p, i=2 c)s = 0 p 110 p, i = 2 d)None or more than one of the above

REAL-WORLD APPLICATIONS Why???

Markov Chains Used to Recognize Many Forms of “Semi-Structured Text” XML file, database file = highly structured text – Each field is clearly labeled according to a strict schematic – Easy to write programs to parse and process these—they are designed for the strict, rigid world of computer programs Resumes, invitations, contact information (e.g. business card or contact information in an signature block) = semi-structured text – Have a wide variety of formats – A fixed model like an RE would have a very hard time with these formats – But they still have many elements in common, and prevailing norms for formatting Need a slightly more flexible model

Markov Chains Markov Chains are Finite Automata (like DFAs and NFAs) where the transitions are probabilistic Extensive use in real-world artificial intelligence applications – Ex: tasks having to do with semi-structured text documents

MODELING GRAMMATICAL UNDERSTANDING Grammar intuition

Vote your first gut instinct! Which is the correct order? a)a small Canadian thin lady b)a Canadian small thin lady c)a small thin Canadian lady d)a thin small Canadian lady Credits: Quiz questions taken from:

Vote your first gut instinct! Which is the correct order? a)a carving steel new knife b)a new steel carving knife c)a steel new carving knife d)a new carving steel knife Credits: Quiz questions taken from:

Vote your first gut instinct! Which is the correct order? a)a beautiful blue sailing boat b)a blue beautiful sailing boat c)a sailing beautiful blue boat d)a blue sailing beautiful boat Credits: Quiz questions taken from:

Adjective Categories and Ordering Opinion: silly, beautiful, horrible, difficult Size: large, tiny, enormous, little Age: ancient, new, young, old Shape: square, round, flat, rectangular Color: blue, pink, reddish, grey Origin: French, lunar, American, eastern, Greek Material: wooden, metal, cotton, paper Purpose: sleeping (as in "sleeping bag"), roasting (as in "roasting tin") When using more than one adjective, must be placed in this order Credits:

Did you know you knew that?? Could you have written down those rules? – Then how did you apply them? – Did anyone ever explicitly teach you how to correctly structure multi-adjective clauses using that list? Our subconscious collection of language rules is fantastically complex, detailed, rich Linguists, Psychologists and Anthropologists have long been amazed and puzzled by the human capacity for acquiring language Context-free grammars are one way that scholars have tried to model how language, and our brain’s models of language, might be structured – Key concept: representing and generating infinite complexity, with just a few simple rules (not unlike fractals)

CONTEXT-FREE GRAMMARS CFG S Back to your [English/Spanish/French/…] class

From Last Year’s Midterm S -> NP VP NP -> CN | CN PP VP -> CV | CV PP PP -> P CN CN -> A N CV -> V | V NP A -> a | the N -> boy | girl | flower V -> touches | likes | sees P -> with S = Sentence NP = Noun-Phrase VP = Verb-Phrase PP = Prep-Phrase CN = Complex-Noun CV = Complex-Verb A = Article N = Noun V = Verb P = Preposition

Parse Tree “The girl touches the boy with the flower.” (a) (b) S -> NP VP NP -> CN | CN PP VP -> CV | CV PP PP -> P CN CN -> A N CV -> V | V NP A -> a | the N -> boy | girl | flower V -> touches | likes | sees P -> with

Parse Tree 2 “The girl touches the boy with the flower.” (a) (b) S -> NP VP NP -> CN | CN PP VP -> CV | CV PP PP -> P CN CN -> A N CV -> V | V NP A -> a | the N -> boy | girl | flower V -> touches | likes | sees P -> with

Ambiguity

Modifying a Grammar S -> NP VP NP -> CN | CN PP VP -> CV | CV PP PP -> P CN CN -> A N CV -> V | V NP A -> a | the N -> boy | girl | flower V -> touches | likes | sees P -> with What if we want to add support for conjunctions? – Words such as "and" "or" "but" and "yet" Connect two thoughts (clauses) into one sentence Each clause could stand on its own as a complete sentence: – The midterm is coming up soon and I hope I will be ready. – This homework problem is hard but I know I can do it!

Adding Support for Conjunctions (A) S -> JP J JP | NP VP JP -> NP VP NP -> CN | CN PP VP -> CV | CV PP PP -> P CN CN -> A N CV -> V | V NP A -> a | the N -> boy | girl | flower V -> touches | likes | sees P -> with J -> but | and | yet (B) S -> NP VP J NP VP | NP VP NP -> CN | CN PP VP -> CV | CV PP PP -> P CN CN -> A N CV -> V | V NP A -> a | the N -> boy | girl | flower V -> touches | likes | sees P -> with J -> but | and | yet (C) S -> S J S | NP VP NP -> CN | CN PP VP -> CV | CV PP PP -> P CN CN -> A N CV -> V | V NP A -> a | the N -> boy | girl | flower V -> touches | likes | sees P -> with J -> but | and | yet

Adding Support for Plural Noun Objects “The girl touches the boy and the flower” S -> NP VP NP -> CN | CN PP VP -> CV | CV PP PP -> P CN CN -> A N CV -> V | V NP | V PN PN -> CN and PN | CN and CN A -> a | the N -> boy | girl | flower V -> touches | likes | sees P -> with