MC 306 Theory of Computation Tuesday, 92303 - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

MC 306 Theory of Computation Tuesday, 92303

Description:

MC 306 Theory of Computation Tuesday, 92303 – PowerPoint PPT presentation

Number of Views:29
Avg rating:3.0/5.0
Slides: 12
Provided by: skid
Category:

less

Transcript and Presenter's Notes

Title: MC 306 Theory of Computation Tuesday, 92303


1
MC 306 Theory of ComputationTuesday, 9/23/03
  • Last time
  • Converting NFAs to DFAs
  • Todays Class
  • FA closure under language operations
  • Assignments due
  • HW 2 due Wednesday at noon
  • Reading 2.4
  • Exercises p. 60, parts a and b of 2.14-2.16
  • New Hand-in problems (not due yet) p. 60, part c
    of 2.14-2.16, also 2.16h

2
Regular Languages
  • Call a language L over ? regular, if it is the
    language L(M) accepted by some DFA M. We know
  • Theorem 1. L is regular if and only if it is the
    language L(M) for some NFA M.
  • Theorem 2. The set of regular languages is closed
    under the operation of union.
  • Closed under an operation means that if I
    perform that operation on members of the set (of
    regular languages), I get another member of the
    set, i.e., another regular language

3
Closure under language operations
  • Theorem 3. The set of regular languages is closed
    under the all the following operations. In other
    words if L1 and L2 are regular, then so is
  • Union L1 ? L2 (already proved)
  • Intersection L1 ? L2 (homework assignment)
  • Complement L1c ? \ L1 --- proof?
  • Difference L1 \ L2 --- proof?
  • Concatenation L1L2 --- proof?
  • Kleene star L1 --- proof?

4
Regular Expressions
  • Let ? be an alphabet. A regular expression is a
    shorthand way to represent some languages over ?.
  • Example ? 0, 1
  • (0 ? 1) 0 denotes the language consisting of
    strings formed by concatenating either symbol 0
    or 1 with any number of 0s
  • L((0 ? 1) 0 ) 0, 00, 000, ? 1, 10,
    100, 1000,
  • Note Some texts use instead of ? (0 1) 0
  • Also, some texts use a dot for concatenation (0
    1) 0

5
Exercises
  • 1) List some the elements in the language L(r),
    where r is the following regular expression (ab
    ? aba)
  • 2) Find regular expressions for each of the
    following languages
  • Strings containing exactly two as
  • Strings not containing exactly two as
  • Strings in which each a is preceded by a b

6
Inductive Definition of Regular Expressions
  • Base case ?, e, ?, and each symbol x ? ? are
    regular expressions
  • Inductive case If r1 and r2 are both regular
    expressions, then so is
  • (r1 ? r2)
  • (r1r2)
  • r1
  • Hence a regular expression is a string over the
    alphabet ? ? ?, e, ?, , , (, )
  • Not every string over this alphabet is regular
  • ) ( a)))

7
Inductive definition of language of a regular
expression
  • If r is a regular expression, we define L(r) as
    follows
  • L(?) ?, L(?) ?, L(x) x for x ? ?
  • If r1 and r2 are both regular expressions, then
  • L(r1 ? r2) L(r1) ? L(r2)
  • L(r1r2) L(r1)L(r2)
  • L(r1) (L(r1))

8
Regular expressions versus regular languages
  • We defined a regular language to be one that is
    accepted by some DFA (or NFA).
  • We will prove that a language is regular by this
    definition if and only if it corresponds to some
    regular expression. Thus,
  • 1) Given a DFA or NFA, there is some regular
    expression to describe the language it accepts
  • 2) Given a regular expression, we can construct a
    DFA or NFA to accept the language it represents

9
Application Lexical-analyzers and
lexical-analyzer generators
  • Lexical analyzer
  • Input Character string comprising a computer
    program in some language
  • Output A string of symbols representing tokens
    elements of that language
  • Ex in C
  • Input if (x 3) y 2
  • Output (sort of) if-token, expression-token,
    variable-name-token, assignment-token,
    numeric-constant token, statement-separator-token.

10
Lexical-analyzer generators
  • Input A list of tokens in a programming
    language, described as regular expressions
  • Output A lexical analyzer for that language
  • Technique Builds an NFA recognizing the language
    tokens, then converts to DFA.

11
Regular Expressions Applications and Limitations
  • Regular expressions have many applications
  • Specification of syntax in programming languages
  • Design of lexical analyzers for compilers
  • Representation of patterns to match in search
    engines
  • Provide an abstract way to talk about programming
    problems (language correpsonds to inputs that
    produce output yes in a yes/no programming
    problem)
  • Limitations
  • There are lots of reasonable languages that are
    not regular hence lots of programming problems
    that cant be solved using power of a DFA or NFA
Write a Comment
User Comments (0)
About PowerShow.com