1 / 19

Lecture 3

Lecture 3. Topics Languages Language classes Closure properties. In class reading assignment. Read Section 1.5 (pages 27-30) and answer the following questions What is a language? What is L ? What is {aa,bb}{cc,dd}? What is {aa,bb} 2 ? What are the five shortest strings in {aa,bb} * ?

edan
Download Presentation

Lecture 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 3 • Topics • Languages • Language classes • Closure properties

  2. In class reading assignment • Read Section 1.5 (pages 27-30) and answer the following questions • What is a language? • What is L? • What is {aa,bb}{cc,dd}? • What is {aa,bb}2? • What are the five shortest strings in {aa,bb}*? • What are the five shortest strings in {aa,bb}+? • What does it mean if a language is infinite/finite? • Is there a difference between {} and {L}?

  3. Questions • What is the English Language? • What is the C++ Language?

  4. Describing a language L • List all elements in L • Doesn’t work for infinite languages • English language description of L • many different descriptions possible, though some are better than others • Formal mathematical description of L • Give a method for recognizing all strings in L • give a program for recognizing strings in L

  5. Example • Describing the language of “Legal Identifiers of C++” • English 1: Legal identifiers of C++ • English 2 (CSE 231 textbook): • “In C++, an identifier should begin with a letter, which may be followed by any number of letters, digits or underscores.” • Formal Definition: • Regular expression: A(A+D+_)* • A = {a, b, …, z, A, B, …, Z} • D = {0, 1, 2 , 3, 4, 5, 6, 7, 8, 9}

  6. Example Continued • Program to recognize language bool main( ) { char a; getc(cin, a); if (cin.eof( ) || (!alpha(a)) return false; getc(cin, a); while (!cin.eof( )) { if (!alpha(a) || !digit(a) !! (a != ‘_’)) return false; getc(cin,a); } return true; }

  7. Work on these examples • {anbm | m,n >= 0} • shortest 3 strings? • English language description? • C++ program? • {anbn | n >= 0} • shortest 3 strings? • English language description? • C++ program?

  8. Language classes • A language class is a set of languages • an element of a language class is a language which is a set of strings

  9. Example language classes • the set of finite languages • the set of languages with at most 3 strings • CARD-3 • the set of languages whose l.r.p.’s can be solved • How are the above language classes related?

  10. Closure Properties • A set is closed under an operation if applying the operation to elements of the set produces another element of the set • Example/Counterexample • set of integers and addition • set of integers and division

  11. 2 5 Integers and Addition 7 Integers

  12. Integers and Division .4 2 5 Integers

  13. Closure Properties for LC’s • We will be interested in closure properties of language classes. • The elements of a language class are languages which are sets themselves • Remember that we apply the set operations to the languages (elements of the language classes) rather than the language classes themselves • Example/Counterexample • Finite languages and set union operator • CARD-3 and set union operator

  14. {0,1,00} {0,1,11} Finite Sets and Set Union {0,1,00,11} Finite Sets

  15. {0,1,00} {0,1,11} CARD-3 and Set Union {0,1,00,11} CARD-3

  16. Finite Sets and Set Complement {l,00,01,10,11,000,...} {0,1} Finite Sets

  17. Infinite Number of Facts • A closure property can represent an infinite number of facts • Example: Finite languages closed under union • {} union {} is a finite language • {} union {l} is a finite language • {} union {0} is a finite language • ... • {l} union {} is a finite language • ...

  18. First-order logic • A way to formally write a closure property • For all L1, ...,Lk in LC, L1 op ... op Lk in LC • Only one expression is needed because of the for all quantifier • Number of languages k is determined by arity of the operation • complement is unary so only one language • union is binary so two languages

  19. Example F-O logic statements • For all L1,L2 in FINITE, L1 union L2 in FINITE • For all L1,L2 in LC3, L1 union L2 in LC3 • For all L in FINITE, Lc in FINITE • For all L in LC3, Lc in LC3

More Related