Recursively enumerable (r.e.) languages - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

Recursively enumerable (r.e.) languages

Description:

Why then do we define and study RE? ... For all L1, L2 in RE, L1 intersect L2 in RE ... and last lines are usually obvious, and we can often work our way in. 11 ... – PowerPoint PPT presentation

Number of Views:137
Avg rating:3.0/5.0
Slides: 36
Provided by: erict9
Learn more at: http://www.cse.msu.edu
Category:

less

Transcript and Presenter's Notes

Title: Recursively enumerable (r.e.) languages


1
Lecture 8
  • Recursively enumerable (r.e.) languages
  • accommodates non-halting programs
  • Closure properties of r.e. languages
  • different than for recursive languages
  • generic element/template proof technique
  • Relationship between RE and REC
  • pseudoclosure property

2
Programs and Input Strings
  • Notation
  • P denotes a program
  • x denotes an input string for program P
  • 4 possible outcomes of running P on x
  • P halts and says yes P accepts string x
  • P halts and says no P rejects string x
  • P halts without saying yes or no P crashes on
    input x
  • We typically ignore this case as it can be
    combined with rejects
  • P never halts P loops on input x
  • L(P) the set of strings accepted by P

3
Illustration
S
Loops
4
REC and RE Language Classes
  • RE
  • A language L is recursively enumerable (r.e.) iff
    there exists some program P s.t. L L(P)
  • REC languages
  • A language L is recursive iff there exists some
    program P s.t L L(P) and P always halts
  • REC proper subset RE
  • Halting problem is r.e. but not recursive
  • Notation
  • RE, r.e. language, REC, recursive language

5
Why study RE?
  • A correct algorithm must halt on all inputs
  • We only consider recursive languages to be solved
    languages
  • Why then do we define and study RE?
  • One Answer RE is the natural class of
    problems/languages associated with any general
    computational model like C
  • That is, there is a 2-way mapping between
    programs and r.e. languages
  • Every program P accepts an r.e. language L and
    every r.e. language is accepted by some program P
  • There is no such 2-way mapping between recursive
    languages and programs
  • Some programs which do not halt do not map to any
    recursive language

6
Illustration of Mapping
2 key points
7
Languages
REC is a proper subset of RE RE is a proper
subset of the set of all languages.
8
RE Closed Under Set Intersection
  • First-order logic formulation?
  • For all L1, L2 in RE, L1 intersect L2 in RE
  • For all L1, L2 ((L1 in RE) and (L2 in RE) --gt
    ((L1 intersect L2) in RE)
  • What this really means
  • Let Li denote the ith r.e. language
  • L1 intersect L1 is in RE
  • L1 intersect L2 is in RE
  • ...
  • L2 intersect L1 is in RE
  • ...

9
Generic Element or Template Proofs
  • Since there are an infinite number of facts to
    prove, we cannot prove them all individually
  • Instead, we create a single proof that proves
    each fact simultaneously
  • I like to call these proofs generic element or
    template proofs

10
Basic Proof Ideas
  • Name your generic objects
  • In this case, we use L1 and L2
  • Only use facts which apply to any relevant
    objects
  • We will only use the fact that there must exist
    P1 and P2 which accept L1 and L2
  • Work from both ends of the proof
  • The first and last lines are usually obvious, and
    we can often work our way in

11
Set Intersection Example
  • Let L1 and L2 be arbitrary r.e. languages
  • There exist P1 and P2 s.t. L(P1)L1 and L(P2)L2
  • By definition of r.e. languages
  • Construct program P3 from P1 and P2 Subroutine
  • Note, we can assume very little about P1 and P2
  • Prove Program P3 accepts L1 intersection L2
  • There exists a program P which accepts L1
    intersection L2
  • L1 intersection L2 is an r.e. language

12
Constructing P3
  • What did we do in the REC setting?
  • Build P3 using P1 and P2 as subroutines
  • We just have to be careful now in how we use P1
    and P2

13
Constructing P3
  • Run P1 and P2 in parallel
  • One instruction of P1, then one instruction of
    P2, and so on
  • If both halt and say yes, halt and say yes
  • If both halt but both do not say yes, halt and
    say no
  • Note, if either never halts, P3 never halts

14
P3 Illustration
Yes/No/-
P1
Yes/No/-
P2
15
Proving P3 Is Correct
  • 2 steps to showing P3 accepts L1 intersection L2
  • For all x in L1 intersection L2, must show P3
  • accepts x
  • halts and says yes
  • For all x not in L1 intersection L2, must show P3
  • rejects x or
  • loops on x or
  • crashes on x

16
Part 1 of Correctness Proof
  • P3 accepts x in L1 intersection L2
  • Let x be an arbitrary string in L1 intersection
    L2
  • Note, this subproof is a generic element proof
  • P1 accepts x
  • L1 intersection L2 is a subset of L1
  • P1 accepts all strings in L1
  • P2 accepts x
  • P3 accepts x
  • We reach the AND gate because of the 2 previous
    facts
  • Since both P1 and P2 accept, AND evaluates to YES

17
Part 2 of Correctness Proof
  • P3 does not accept x not in L1 intersection L2
  • Let x be an arbitrary string not in L1
    intersection L2
  • By definition of intersection, this means x is
    not in L1 or L2
  • Case 1 x not in L1
  • 2 possibilities
  • P1 rejects (or crashes on) x
  • One input to AND gate is No
  • Output cannot be yes
  • P3 does not accept x
  • P1 loops on x
  • One input never reaches AND gate
  • No output
  • P3 loops on x
  • P3 does not accept x when x is not in L1
  • Case 2 x not in L2
  • Essentially identical analysis
  • P3 does not accept x not in L1 intersection L2

18
Set complement Example
  • Let L be an arbitrary r.e. language
  • There exists P s.t. L(P)L
  • By definition of r.e. languages
  • Construct program P from P Subroutine Theme
  • Note, we can assume very little about P
  • Prove Program P accepts L complement
  • There exists a program P which accepts L
    complement
  • L complement is an r.e. language

19
Constructing P
  • What did we do in recursive case?
  • Run P and then just complement answer at end
  • Accept -gt Reject
  • Reject -gt Accept
  • Does this work in this case?
  • No. Why not?
  • Accept-gtReject and Reject -gtAccept ok
  • Problem is we need to turn Loop-gtAccept
  • this requires solving the halting problem

20
What can we conclude?
  • Previous argument only shows that the approach
    used for REC does not work for RE
  • This does not prove that RE is not closed under
    set complement
  • Later, we will prove that RE is not closed under
    set complement

21
Other closure properties
  • Unary Operations
  • Language reversal
  • Kleene Closure
  • Binary operations
  • union
  • concatenation
  • Not closed
  • Set difference

22
Closure Property Applications
  • How can we use closure properties to prove a
    language LT is r.e. or recursive?
  • Unary operator op (e.g. complement)
  • 1) Find a known r.e. or recursive language L
  • 2) Show LT L op
  • Binary operator op (e.g. intersection)
  • 1) Find 2 known r.e or recursive languages L1 and
    L2
  • 2) Show LT L1 op L2

23
Closure Property Applications
  • How can we use closure properties to prove a
    language LT is not r.e. or recursive?
  • Unary operator op (e.g. complement)
  • 1) Find a known not r.e. or non-recursive
    language L
  • 2) Show LT op L
  • Binary operator op (e.g. intersection)
  • 1) Find a known r.e. or recursive language L1
  • 2) Find a known not r.e. or non-recursive
    language L2
  • 2) Show L2 L1 op LT

24
Example
  • Looping Problem
  • Input
  • Program P
  • Input x for program P
  • Yes/No Question
  • Does P loop on x?
  • Looping Problem is undecidable
  • Looping Problem complement H

25
Closure Property Applications
  • Proving a new closure property
  • Theorem Nonrecursive languages are closed under
    set complement
  • Let L be an arbitrary nonrecursive language
  • If Lc is recursive, then L is recursive
  • (Lc)c L
  • Recursive languages closed under complement
  • However, we are assuming that L is not recursive
  • Therefore, we can conclude that Lc is not
    recursive
  • Thus, nonrecursive languages are closed under
    complement

26
Pseudo Closure Property
  • Lemma If L and Lc are r.e., then L is recursive.
  • First-order logic?
  • For all L in RE, (Lc in RE) --gt (L in REC)
  • For all L, ((L in RE) and (Lc in RE)) --gt (L in
    REC)
  • Question What about Lc?
  • Also recursive because REC closed under set
    complement

27
High Level Proof
  • Let L be an arbitrary language where L and Lc are
    both r.e.
  • Let P1 and P2 be the programs which accept L and
    Lc, respectively
  • Construct program P3 from P1 and P2 Subroutine
    theme
  • Argue P3 decides L
  • L is recursive

28
Constructing P3
  • Problem
  • Both P1 and P2 may loop on some input strings,
    and we need P3 to halt on all input strings
  • Key Observation
  • On all input strings, one of P1 and P2 is
    guaranteed to halt. Why?
  • Nature of complement operation

29
Illustration
S
30
Construction and Proof
  • P3s Operation
  • Run P1 and P2 in parallel on the input string x
    until one accepts x
  • Guranteed to occur given previous argument
  • Also, only one program will accept any string x
  • IF P1 is the accepting machine THEN yes ELSE no

31
P3 Illustration
Yes
P1
Yes
P2
32
Question
  • What if P2 rejects the input?
  • Our description of P3 doesnt describe what we
    should do in this case.
  • If P2 rejects the input, then the input must be
    in L
  • This means P1 will eventually accept the input.
  • This means P3 will eventually accept the input.

33
RE and REC
S
RE
34
RE and REC
S
RE
Are there any languages L in RE - REC?
35
Summary
  • Programs and Input Strings
  • RE and REC
  • Why we care about RE
  • Details on their relationship
  • Closure Properties
  • Generic Element or Template Proofs
  • Some operations NOT closed for RE
  • Applications
Write a Comment
User Comments (0)
About PowerShow.com