M - Programs in Mathematics and Computer Science

advertisement
Spring 2016
CISG 5115
Theory of Computation
Chapter 4
Decidability
Donghyun (David) Kim
Department of Mathematics and Computer Science
North Carolina Central University
Some slides are in courtesy of Prof. Verma at Univ. of Houston, Max Alekseyev at Univ. of South Carolina
1
Turing Machine: Languages
• Recall that a collection of strings that a TM M “accepts”
is called the language of M or language “recognized”
by M, denoted L(M).
• Definition
• A language is Turing-recognizable (or recursively
enumerable) if it is recognized by some Turing machine.
2
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Turing Machine: Languages –
cont’
• A TM M on an input that is not in L(M) can either reject
or loop. We distinguish TMs that never loop and call
them “deciders”. A decider M decides the language
that it recognizes.
• Definition
• A language is decidable (or recursive) if it is decided by
some Turing machine.
• It is easy to see that the complement of a decidable
language is also decidable.
3
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Decidable Problems concerning
Regular Language (RL)
• Acceptance problem for DFAs of testing whether a
particular deterministic finite automation accepts a
given string can be expressed as a language,
• ADFA = { <B, w> | B is a DFA that accepts input string w}.
• The problem of testing whether a DFA B accepts an
input w is the same as the problem of testing whether
<B, w> is a member of the language ADFA.
4
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Decidable Problems concerning
Regular Language (RL) – cont’
• ADFA = { <B, w> | B is a DFA that accepts string w}
• Theorem: ADFA is decidable.
• Proof: we need to present a TM that decides ADFA. Idea is
to “execute” given B on the given input w within our TM.
• Check that the input represents a valid DFA B (a list of five
components Q, ,  , q0 , F ) and a valid string w over the
alphabet of B (i.e.,  ).
• Perform a simulation (after constructing  )
• When M finishes processing the last symbol of w, M accepts
the input if B is in an accepting state; M rejects the input if B
is a non-accepting state.
5
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Decidable Problems concerning
Regular Language (RL) – cont’
• ANFA = { <B, w> | B is a NFA that accepts string w}
• AREX = { <B, w> | B is a regular expression that accepts
string w}
• Theorem: ANFA and AREX are decidable
• Proof: Idea is to construct a TM that first converts a given
NFA (or regular expression) into an equivalent DFA (or
NFA to DFA), and then executes this DFA as done in the
previous slide
6
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Decidable Problems concerning
Regular Language (RL) – cont’
7
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Decidable Problems concerning
Regular Language (RL) – cont’
L(B)
L( A)
( L( A)  L( B))  ( L( B)  L( A))
8
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Decidable Problems concerning
Context-free Languages (CFL)
9
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Decidable Problems concerning
Context-free Languages (CFL) – cont’
10
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Relationship among languages
11
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Decidable vs. Undecidable
Languages
12
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Decidable vs. Undecidable
Languages
13
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Halting Problem
• ATM is recognizable
• For a given pair <M, w>, we need simply to simulate M on
the input w, and accept or reject depending on whether
M accepts or rejects.
• Note that M may loop in which case our simulation will
loop as well, making it just a recognizer not a decider.
14
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Halting Problem – cont’
• If we were able to determine whether M would ever
stop on a given input w, a TM for ATM could reject given
<M, w> as soon as it determined that M would loop on
w. In this case it would be a decider for ATM (which
accepts if M accepts; and rejects if M rejects or loops).
• Therefore, the crucial point is determination of
whether M would ever stop on a given input w, giving
the name “Halting Problem” to ATM. In these new
terms, our goal is to prove that the halting problem is
undecidable.
Spring 2016 CISG 5115
Donghyun (David) Kim
15
Department of Mathematics and Physics
North Carolina Central University
Sets and Their Cardinalities
• It is easy to tell whether two given finite sets (such as
{5, 7, 23} and {a, b, c} have the same size - just count up
their elements and compare the counts.
• But is there a way to compare sizes of two infinite sets?
Obviously, counting elements won't help as it would
never end. But can we determine that two sets have
equal sizes without counting their elements?
16
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Sets and Their Cardinalities –
cont’
• The idea is to set up a mapping between the elements
of two sets such that each element of one set is
mapped to an element of the other, and vice versa.
• This idea works equally well for finite and infinite sets.
For example, we can map elements of the two sets
above as follows: 5 ↔ a, 7 ↔ b, and 23 ↔ c; implying
that these sets are the same size.
17
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
One-to-one, onto, correspondence
• Let A, B be two sets and f: A→B be a function from A to B.
• f is called one-to-one (injective) if it maps different elements
of A to different elements of B.
• f is called onto (surjective) if for every elements b ∈ B, there
exists a ∈ A such that f(a) = b.
• f is called one-to-one correspondence (bijective) if it is one-toone and onto.
• Two set are of the same size if there exists a
correspondence between them.
Spring 2016 CISG 5115
Donghyun (David) Kim
18
Department of Mathematics and Physics
North Carolina Central University
One-to-one, onto, correspondence
– cont’
• The set E = {2, 4, 6, …} of even positive integers and the set
N = {1, 2, 3, …} of natural numbers are the same size.
• Define a function f : E→N such that f (n) = 2n for every n ∈ N .
It is
• one-to-one since for 𝑛 ≠ 𝑚 we have 2𝑛 ≠ 2𝑚. It is onto
since for k ∈ E, k/2 is a natural number and f (k/2) = k. Hence,
f is a correspondence between E and N , implying that they
are the same size
• A set is called countable if either it is finite or has the same
19
size as N.
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Some Properties
1. the union of a finite number of finite sets is finite,
2. the union of a finite or infinite number of countable sets
is countable,
3. the power set of a finite set is finite,
4. the power set of an infinite set is uncountable.
• The last property is proved by an important technique
called diagonalization.
• For the proof of countability of the (positive) rationals
Q and uncountability of the reals R, see pp.175-178 of
the textbook.
20
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Coutability of Languages and
TMs
*
*  {w | w  *  | w | k}
k 0
21
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Halting Problem is Undecidable
• Show ATM = {<M, w> | M is a TM and M accepts w} is NOT
decidable.
• Assume that ATM is decidable and let H be a decider for it (i.e.,
H(<M, w>) accepts if M accepts w; and rejects otherwise).
• Define a new TM D which on input <M> runs H on input <M,
<M>> and outputs opposite to what H outputs.
• D(<M>): if D accepts <M> then (by the definition of D) H
rejects <M, <M>> implying (by the definition of H) that M
does not accept <M>
• D(<D>):
• if D accepts <D> then H rejects <D, <D>> implying that D
does not accept <D>
• if D rejects <D> then H accepts <D, <D>> implying that D
accepts <D>
• Contradiction!
Spring 2016 CISG 5115
Donghyun (David) Kim
22
Department of Mathematics and Physics
North Carolina Central University
Turing-Unrecognizable languages
• The complement of a language is the language
consisting of all strings that are not in the language.
• Theorem
• A language is decidable iff it is Turing-recognizable and
co-Turing-recognizable (i.e., its complement is Turingrecognizable).
• Corollary
• ATM is not Turing-recognizable. Otherwise, ATM is Turingdecidable, which is not true.
23
Spring 2016 CISG 5115
Donghyun (David) Kim
Department of Mathematics and Physics
North Carolina Central University
Download