Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "1 Lecture 3 Topics –Languages –Language classes –Closure properties."— Presentation transcript:

1 1 Lecture 3 Topics –Languages –Language classes –Closure properties

2 2 In class reading assignment Read Section 1.5 (pages 27-30) and answer the following questions –What is a language? –What is  ? –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 {  }?

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

4 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 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 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 7 Work on these examples {a n b m | m,n >= 0} –shortest 3 strings? –English language description? –C++ program? {a n b n | n >= 0} –shortest 3 strings? –English language description? –C++ program?

8 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 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 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 11 Integers and Addition Integers 2 5 7

12 12 Integers and Division Integers 2 5.4

13 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 14 Finite Sets and Set Union Finite Sets {0,1,00} {0,1,11} {0,1,00,11}

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

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

17 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 {0} is a finite language –... –{ } union {} is a finite language –...

18 18 First-order logic A way to formally write a closure property –For all L 1,...,L k in LC, L 1 op... op L k 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 19 Example F-O logic statements For all L 1,L 2 in FINITE, L 1 union L 2 in FINITE For all L 1,L 2 in LC3, L 1 union L 2 in LC3 For all L in FINITE, L c in FINITE For all L in LC3, L c in LC3


Download ppt "1 Lecture 3 Topics –Languages –Language classes –Closure properties."

Similar presentations


Ads by Google