Languages - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Languages

Description:

Read Section 1.5 (pages 27-30) and answer the following questions. What is a language? ... Example F-O logic statements. For all L1,L2 in FINITE, L1 union L2 in FINITE ... – PowerPoint PPT presentation

Number of Views:16
Avg rating:3.0/5.0
Slides: 20
Provided by: Eri770
Learn more at: http://www.cse.msu.edu
Category:

less

Transcript and Presenter's Notes

Title: Languages


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,bbcc,dd?
  • What is aa,bb2?
  • 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
  • Doesnt 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(AD_)
  • 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 gt 0
  • shortest 3 strings?
  • English language description?
  • C program?
  • anbn n gt 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
Integers and Addition
7
Integers
12
Integers and Division
.4
2
5
Integers
13
Closure Properties for LCs
  • 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
Finite Sets and Set Union
0,1,00,11
Finite Sets
15
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
Write a Comment
User Comments (0)
About PowerShow.com