CS 3240: Languages and Computation - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

CS 3240: Languages and Computation

Description:

Convert B to a DFA C. Run TM M from previous on C,w If M accepts, accept. ... Convert R to a DFA C using algorithm discussed in class and in text ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 20
Provided by: ble87
Category:

less

Transcript and Presenter's Notes

Title: CS 3240: Languages and Computation


1
CS 3240 Languages and Computation
  • Decidable Languages

2
Decidability
  • A language is decidable if some Turing machine
    decides it
  • Not all languages are decidable
  • How to show a language is decidable?
  • Write a decider that decides it
  • Accepts w iff w is in the language
  • Must halt on all inputs

3
DFA Acceptance Problem
  • Consider the language ADFA ltB,wgt B is a DFA
    that accepts the string w
  • Theorem ADFA is a decidable language
  • Proof Consider the following TM, M
  • On input string ltB,wgt, where B is a DFA and w is
    an input to B
  • Simulate B on input w
  • If simulation ends in accept state, accept.
    Otherwise, reject.

4
NFA Acceptance Problem
  • Consider the language
  • ANFA ltB,wgt B is a NFA that accepts the
    string w
  • Theorem ANFA is a decidable language
  • Proof Consider the following TM, NOn input
    string ltB,wgt
  • Convert B to a DFA C
  • Run TM M from previous slide on ltC,wgt
  • If M accepts, accept. Otherwise, reject.

5
RE Acceptance Problem
  • Consider the language
  • AREX ltR,wgt R is an RE that generates the
    string w
  • Theorem AREX is a decidable language
  • Proof Consider the following TM, P
  • On input string ltR,wgt
  • Convert R to a DFA C using algorithm discussed in
    class and in text
  • Run TM M from earlier slide on ltC,wgt
  • If M accepts, accept. Otherwise, reject.

6
Emptiness Testing Problem
  • Consider the language
  • EDFA ltAgt A is a DFA and L(A) ?
  • Theorem EDFA is a decidable language
  • Proof Consider the following TM, T
  • On input string ltAgt, where A is a DFA
  • Mark the start state
  • Repeat until no new states get marked
  • Mark any state that has a transition coming into
    it from any state already marked
  • If no accept states are marked, accept.
    Otherwise, reject.

7
DFA Equivalence Problem
  • EQDFA ltA,Bgt A and B are DFAs and L(A)
    L(B)
  • Theorem EQDFA is a decidable language
  • Proof Consider the following language
  • (L(A) ? L(B)) ? (L(A) ? L(B))

8
DFA Equivalence Problem
  • (L(A) ? L(B)) ? (L(A) ? L(B))

9
DFA Equivalence Problem
  • EQDFA ltA,Bgt A and B are DFAs and L(A)
    L(B)
  • Theorem EQDFA is a decidable language
  • Proof idea Consider DFA C that accepts L(C)
    (L(A) ? L(B)) ? (L(A) ? L(B))
  • How do we know such a DFA exists?
  • If L(C) ?, then L(A) L(B)

10
TM That Decides EQDFA
  • On input string ltA,Bgt, where A and B are DFAs
  • Create DFA C such that
  • L(C) (L(A) ? L(B)) ? (L(A) ? L(B))
  • Submit C to Turing machine T that decides EDFA
  • If T accepts C, accept. Otherwise, reject.

11
Deciders and CFGs
  • Consider the following language
  • ACFG ltG,wgt G is a CFG that generates string
    w
  • Is ACFG decidable?
  • How can we get a TM to simulate a CFG?
  • Must be certain CFG tries a finite number of
    steps!
  • Solution Use Chomsky normal form

12
Chomsky Normal Form Review
  • All rules are of the form
  • A ?BC
  • A ?a
  • Where A, B, and C are any variables (B and C
    cannot be the start variable)
  • S ?eis the only erule, where S is the start
    variable

13
How Many Steps to Generate w?
  • If w 0
  • 1 step
  • If w n gt 0?
  • 2n 1 steps

14
TM Simulating ACFG
  • On input ltGgt, where G is a CFG
  • Convert G into Chomsky normal form
  • If w 0
  • If there is an S ? e rule, accept
  • Otherwise, reject
  • List all derivations with 2w-1 steps
  • If any generate w, accept
  • Otherwise, reject

15
Empty CFGs
  • Consider the following language
  • ECFG ltGgt G is a CFG and L(G) ?
  • Theorem ECFG is decidable
  • Can we use the TM in ACFG to prove this?
  • No. There are infinitely many possible strings
    in S
  • We need to check if there is any way to get from
    the start variable to some string of terminals

16
Work Backwards
  • On input ltGgt, where G is a CFG
  • Mark all terminals
  • Repeat until no new variables are marked
  • Mark any variable A if G has a rule A?U1U2Uk
    where U1, U2, , Uk are all marked
  • If S is marked, reject Otherwise, accept

17
What About EQCFG?
  • Recall for EQDFA, we considered
  • (L(A) ? L(B)) ? (L(A) ? L(B))
  • Will this work for CFGs?
  • No. CFGs are not closed under complementation or
    intersection
  • EQCFG is not a decidable language!
  • We will show this later

18
Decidability of CFLs
  • Theorem Every context-free language L is
    decidable
  • Can we make a TM that simulates a PDA?
  • No. May run into infinite loop.
  • Proof idea For each w, we need to decide
    whether or not w is in L. Let G be a CFG for L.
    This problem boils down to ACFG, which we showed
    is decidable.

19
Summary of Decidable Languages
Write a Comment
User Comments (0)
About PowerShow.com