151
1 Computability Decidability

Computability Decidability

  • Upload
    cael

  • View
    63

  • Download
    1

Embed Size (px)

DESCRIPTION

Computability Decidability. Unsolvable problems. Computer scientists usually deal with problems which are solvable. We are supposed to find an algorithm to solve a particular problem. Why do we need to know about problems which are unsolvable ? - PowerPoint PPT Presentation

Citation preview

Page 1: Computability Decidability

1

ComputabilityDecidability

Page 2: Computability Decidability

2

Unsolvable problems

Computer scientists usually deal with problems which are solvable.

We are supposed to find an algorithm to solve a particular problem.

Why do we need to know about problems which are unsolvable ?we will not waste time in finding an non-existed algorithm.we will realize that the problem needs to be simplified or altered

before we can find an algorithmic solution.unsolvable problems can stimulate our imagination and help us

gain an important perspective on computation.

Page 3: Computability Decidability

3

Decidable Languages

We have seen in the last chapter an undecidable problem, the 10th problem of Hilbert.

Now we will show some other problems and consider whether they are decidable by algorithm or not.

Page 4: Computability Decidability

4

Decidable Problems Concerning Regular Languages

Acceptance problem

Whether a finite automata accepts a string ?

ADFA = {<B,w>| B is a DFA that accepts input string w}

Whether a nondeterministic finite automata accepts

a string ?

ANFA = {<B,w>| B is a NFA that accepts input string w}

Whether a regular expression generates a given string.

AREX = {<R,w>| R is a regular expression that generates string w}

Page 5: Computability Decidability

5

Decidable Problems concerning Regular Lang.

Empty Language problemWhether a language of a finite automata is empty ?

EDFA = {<A>| A is a DFA and L(A) = }

Equivalence problemWhether two finite automata are equivalent ?

EQDFA = {<A,B>| A and B are DFAs and L(A) = L(B)}

Page 6: Computability Decidability

6

Theorem 1

ADFA is a decidable language

ADFA = {<B,w>| B is a DFA that accepts input string w}

Show that the problem of testing whether a given finite automata accepts a given string is decidable

Proof idea: Present a TM M that decides ADFA.

Page 7: Computability Decidability

7

Proof

M = “on input <B,w>, where B is a DFA and w is a string:Simulate B on input w.If the simulation ends in an accept state, accept. If it ends in a

non-accepting state, reject.”

Notes: input of M is an encoded string <B,w>B can be represented reasonably as a list of its five components,

Q, , , q0 and F.before M starts its computation, M first checks on whether it

properly represents a DFA B and a string w. If not, M rejects.

Page 8: Computability Decidability

8

Proof:

wInput Tape

B

Machine M

accept

rejectM keeps track of B’s current state and B’s current position in the input w by writing this information down on its tape.

Page 9: Computability Decidability

9

Theorem 2

ANFA is a decidable language

ANFA = {<B,w>| B is a NFA that accepts input string w}

Proof idea: Present a TM N that decides ANFA.N has M as a subroutine.Because M is designed to work with DFAs, N first converts

the NFA B it receives as input to a DFA before passing it to M.

Page 10: Computability Decidability

10

Proof

N = “on input <B,w>, where B is a NFA and w is a string:Convert NFA B to an equivalent DFA C

Run TM M from Theorem 1 on input <C,w>.

If M accepts, accept; otherwise reject.”

Page 11: Computability Decidability

11

Proof:

wInput Tape

C

Machine N

accept

reject

Machine M

Page 12: Computability Decidability

12

Theorem 3

AREX is a decidable language

AREX = {<R,w>| R is a regular expression that generates string w}

Proof idea: Present a TM P that decides AREX.

Page 13: Computability Decidability

13

Proof

P = “on input <R,w>, where R is a regular expression and w is a string:Convert regular expression R to an equivalent DFA A.

Run TM M on input <A,w>.

If M accepts, accept; if M rejects , reject.”

Page 14: Computability Decidability

14

Theorem 4

EDFA is a decidable language

EDFA = {<A>| A is a DFA and L(A) = }

Show that the problem of testing whether a given finite automata accepts any strings at all is decidable.

Proof idea: A DFA accepts some string if and only if reaching an accept state

from the start state by traveling alone the arrows of the DFA is possible.

Present a TM T that uses a marking algorithm.

Page 15: Computability Decidability

15

ProofT = “on input <A>, where A is a DFA:

Mark the start state of A.

Repeat until no new states get marked:

Mark any state that has a transition coming into it from any state that is already marked.

If no accept state is marked, accept; otherwise reject.”

A is empty

Page 16: Computability Decidability

16

Theorem 5

EQDFA is a decidable language

EQDFA = {<A,B>| A and B are DFAs and L(A) = L(B)}

Show that the problem of testing whether 2 DFAs recognize the same language is decidable.

Proof idea: Construct a new DFA C from A and B, where C accepts only

those strings that are accepted by either A or B but not by both.If A and B recognize the same language, C will accept nothing.Test whether L(C) is empty by the theorem 4.4

Page 17: Computability Decidability

17

L(C)

L(C) = (L(A) L(B)) (L(A) L(B))

L(A) L(B)

Symmetric difference of L(A) and L(B)

C is also a DFA as the class of regular language is closed undercomplementation, union and intersection

Page 18: Computability Decidability

18

Proof

F = “on input <A,B>, where A and B are DFAs:Construct DFA C as described.

Run TM T from Theorem 4 on input <C>

If T accepts, accept. If T rejects, reject.”

Page 19: Computability Decidability

19

Proof

Machine F

Machine T

C

accept

reject

accept

reject

Page 20: Computability Decidability

20

Decidable Problems concerning to Context-Free Language

Acceptance problem

Whether a CFG accepts a string ?

ACFG = {<G,w>| G is a CFG that accepts input string w}

Emptiness problem

Whether a CFG generates any strings at all ?

ECFG = {<G>| G is a CFG and L(G) = }

Equivalent problem

Whether two CFGs generate the same language ?

EQCFG = {<G,H>| G and H are CFGs and L(G) = L(H)}

Page 21: Computability Decidability

21

Theorem 6

ACFG is a decidable language

ACFG = {<G,w>| G is a CFG that generates string w}

Proof idea: Naïve idea :

Go through every derivations to determine whether any is a derivation of w.

But this algorithm will not halt if w is not a member of G.

Better approach:We need to ensure that the algorithm tries only finitely many

derivations, so use CNF form.

any derivation of w has 2n-1 steps, where n is the length of w.

Page 22: Computability Decidability

22

Proof

S = “on input <G,w>, where G is a CFG and w is a string:Convert G to an equivalent grammar in Chomsky

Normal Form.

List all derivations with 2n-1 steps, where n is the length of w.

If any of these derivations generate w, accept; if not, reject.”

Page 23: Computability Decidability

23

CFLs and PDAs

As we can convert back and forth between CFLs and PDAs.

Hence, everything we say about the decidability of problems concerning CFLs applies well to PDAs.

Page 24: Computability Decidability

24

Theorem 7

ECFG is a decidable language

ECFG = {<G>| G is a CFG and L(G) = }

Proof idea: Naïve idea : to determine whether L(G) =

try going through all possible w’s, one by one.But there are infinitely many w’s to try, so this algorithm could end

up running forever.

Better approach:We need to test whether the start variable can generate a string of

terminals.Determine for each variable whether that variable is capable of

generating a string of terminals, the algorithm keeps track of this information by placing a mark on that variable.

Page 25: Computability Decidability

25

ProofR = “on input <G>, where G is a CFG :

Mark all terminal symbols in G.

Repeat until no new variables get marked

Mark any variable A where G has a rule AU1 U2… Uk and each symbol U1 , …, Uk

has already been marked.

If the start symbol is not marked, accept; otherwise

reject. ”

G is empty

Page 26: Computability Decidability

26

EQCFG

Consider the problem of testing whether 2 CFGs generate the same language.

ECFG = {<G,w>| G is a CFG that generates string w}

Proof idea: Naïve idea :

use the same method as theorem 4.5But CFL is not closed under complementation or

intersections.

In fact, ECFG is not decidable. We’ll prove it in the next chapter.

Page 27: Computability Decidability

27

Theorem 8

“Every context-free language is decidable.”We show that every CFL is decidable.Proof idea:

Naïve (bad) idea : try to convert a PDA for A directly to a TM.the PDA for A may be nondeterministic, so we get an NTM

which we can convert into a deterministic TM.however, PDA can have some branches go on forever, reading

and writing the stack without coming to a halt. therefore our TM will not be a decider.

Better approach:We prove this theorem with the TM S in Theorem 6 to decide

ACFG.

Page 28: Computability Decidability

28

Proof

Let G be a CFG for A and design a TM MG that decides A.

We build a copy of G into MG.

It works as follow.

MG = “on input w:

Run TM S on input <G,w>

If this machine accepts, accept; if it rejects, reject.”

Page 29: Computability Decidability

29

Proof

Machine MG

Machine S

accept

reject

accept

reject

1. Convert G to CNF form.

2. List all derivations with 2n-1 steps, where n is the length of w.

3. If any of these derivations generate w, accept; if not, reject.

Page 30: Computability Decidability

30

Relationship among classes of Language

Turing-recognizable

DecidableContext-freeRegular

Page 31: Computability Decidability

31

Non Recursively Enumerator language

We want to find a language that is not Recursively Enumerable

This language is not accepted by any Turing MachineIt can’t be implemented on (contemporary) computer.Example:

Verify that the program we wrote performs as specified (that it is correct).

Halting problem : Testing whether a TM accepts a given input string (ATM)

Page 32: Computability Decidability

32

Theorem 9

ATM = {<M,w>| M is a TM and M accepts w}.

ATM is undecidable.

Proof: observe that ATM is Turing-recognizable.

We try to find a TM (U) that recognizes ATM.

Page 33: Computability Decidability

33

Halting Problem

U = “On input <M,w>, where M is a TM and w is a string:Simulate M on input w.

If M ever enters its accept state, accept; if M ever enters its reject state, reject.”

Note: U loops on input <M,w> if M loops on w, that’s why U doesn’t decide ATM.

Page 34: Computability Decidability

34

Universal Turing Machineproposed by Turing.

a machine is called universal if it is capable to simulate any other Turing machine from the description of that machine.

played an important early role in stimulating the development of stored-program computers.

Page 35: Computability Decidability

35

The Diagonalization method

discovered by Georg Cantor in 1873.is the proof of the undecidability of the halting

problem.using countable and uncountable set to prove.Idea is : we want to prove that

set of Turing-recognizable language is uncountablewhile set of Turing machine is countable.

Page 36: Computability Decidability

36

Cantor’s problemConcerned with the problem of measuring the sizes

of infinite sets.

If we have 2 infinite sets, how can we tell whether one is larger than the other or whether they are of the same size ?

Naïve: try to count the elements of the infinite set, we will never finish!

Page 37: Computability Decidability

37

Cantor’s problem

Better approach:

Observe that 2 finite sets are of the same size if the elements of the one set can be paired with the element of the other set.

We can extend this idea to infinite sets.

Page 38: Computability Decidability

38

Definition: Correspondence

Consider 2 sets, A and B, and a function f from A to B.

Say that f is one-to-one if it never maps 2 different elements to the same place that is, f(a) f(b) whenever a b.

Say that A and B are the same size if there is a one-to-one, onto function f: AB.

one-to-one and onto is called CorrespondenceCorrespondence

Page 39: Computability Decidability

39

Example

Let N be the set of Natural numbers {1,2,3,…}

be the set of even natural numbers {2,4,6,…}

Using cantor’s method, we can see that N and have the same size.

n f(n)

1 2

2 4

3 6... ...

Page 40: Computability Decidability

40

Definition : Countable

A set A is countable if either it is finite or it has the same size as N.

Page 41: Computability Decidability

41

ExampleLet

N be the set of Natural numbers {1,2,3,…} Q be the set of positive rational numbers

Q = {m/n |m,n N }

Q seems the be bigger than N but actually they have the same size.

Using cantor’s method, we list all the elements of Q and then pair each element with the element of N.

We have to ensure that every member of Q appears only once on the list.

Page 42: Computability Decidability

42

Correspondence of N and Q

11

12

13

14

15

21

22

23

24

25

31

32

33

34

35

41

42

43

44

45

51

52

.

.

.

. . .

Page 43: Computability Decidability

43

Trick

We pair the first element of Q on the list with the number 1 from N.

the second element of Q on the list with the number 2 from N.

After seeing the corresponding of N and Q, we can see that as each curve Q has finite number of elements which can be mapped with elements of N, thus both sets have same size.

Page 44: Computability Decidability

44

Theorem 4.14R is uncountable

R is the set of real number.

Proof by the diagonalization method.

Page 45: Computability Decidability

45

Proof

by contradiction : suppose that a correspondence f existed between N and R. means that we must pair all the members of N with all the members of R.

show that f fails to work as it should.

How to show ? finding an x in R that is not paired with anything in N.

Page 46: Computability Decidability

46

ProofFinding x by constructing it.

choose each digit of x to make x different from one of the real numbers that is paired with an element of N

Sure that x is different from any real number that is paired.

Page 47: Computability Decidability

47

Illustration of the idea

suppose we have a corresponding f:

we construct x by let the first digit of x be anything different from the first fractional digit of f(1). let the second digit of x be anything different from the second fractional digit of f(2).

thus we can construct x which is different from f(n) for any n.

n f(n)

1 0.123456

2 0.500000

3 0.759685... ...

n f(n)

1 0.423456

2 0.530000

3 0.756685... ...

Page 48: Computability Decidability

48

Corollary 4.15

Some languages are not Turing-recognizable.

Proof idea: set of Turing-recognizable language is uncountable while set of

Turing machine is countable.

Because each Turing machine can recognize a single language and there are more languages than TMs, some languages are not recognized by any TM.

Thus, there exists some languages which are not Turing-recognizable.

Page 49: Computability Decidability

49

set of all TMs is countable.Proof idea:

first of allwe have to observe that the set of all * is countable, for

any alphabet .

with only finitely many strings of each length, we may form a list of * by written down all strings of length 0, length 1, length 2 and so on.

Page 50: Computability Decidability

50

set of all TMs is countable.Secondly

We can encode each TM into a string <M>

as the set of all strings is countable therefore the set of all TMs is countable.

Page 51: Computability Decidability

51

set of all languages is uncountable

Proof idea:

first of allwe have to observe that the set of all infinite binary

sequence is uncountable

An infinite binary sequence is an unending sequence of 0s and 1s.

we can prove by the diagonalization method.

(imagine as the same way as R)

Page 52: Computability Decidability

52

set of all languages is uncountableSecondly

Let B be the set of all infinite binary sequences.Let L be the set of all languages over alphabet .Show that L is uncountable by giving correspondence

with B.the idea is that “as B is uncountable thus L is also

uncountable.”

Page 53: Computability Decidability

53

set of all languages is uncountable

Correspondence of L and BShow that both sets have the same size.

Let * = {s1,s2,…}.

Each language A L has a unique sequence of B. (one-to-one and onto)

Characteristic sequence of A, (A)The ith bit of that sequence is a 1 if si A and is a 0 if

si A.

Page 54: Computability Decidability

54

set of all languages is uncountable

Example : Characteristic sequence

The function f: L B, where f(A) equals the Characteristic sequence of A, is one-to-one and onto and hence a correspondence. Therefore, as B is uncountable, L is uncountable as well.

* = { , 0 , 1 , 00 , 01 , 10 ,11

, 000 , 001 , … } ;

A = { 0 , 00 , 01 000 , 001 , … } ;

(A) = { 0 1 0 1 1 0 0 1 1 … } ;

Page 55: Computability Decidability

55

The Halting Problem

We have proved that there are some languages which are not Turing-recognizable.

Now, we want to show that such a TM which can such a TM which can recognize the non Turing-recognizable recognize the non Turing-recognizable language doesn’t existlanguage doesn’t exist.

Page 56: Computability Decidability

56

Proof of Theorem 9

ATM is undecidable.Proof:

Consider = {a}.

The set of all strings is * = {,a, aa, aaa, aaaa…}

= {,a1, a2, a3, a4…}

the set of all TMs is countable, thus we can order them as M1, M2, M3,…

to indicate which language is accepted by what machine, we can again use the characteristic sequence of that language.

Page 57: Computability Decidability

57

Proof of Theorem 9

Example:assume a machine Mi accepts a language L(Mi)

L(Mi) = {a2, a4, a6}

we can write

* = { a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 ,,,

… } ;

L(Mi) = { 0 1 0 1 0 1 0 0 … } ;

Page 58: Computability Decidability

58

1a 2a 3a 4a

)1(ML

0 1 10

)2(ML

)3(ML

01 0 1

0 1 11

)4(ML 0 10 0

Proof of Theorem 9

For each machine, we can write its characteristic sequence

Page 59: Computability Decidability

59

Consider the language

)}(:{ iii MLaaL

L consists from the 1’s in the diagonal

Proof of Theorem 9

Page 60: Computability Decidability

60

1a 2a 3a 4a

0 1 10

01 0 1

0 1 11

0 10 0

},,{ 43 aaL

)1(ML

)2(ML

)3(ML

)4(ML

Page 61: Computability Decidability

61

)}(:{ iii MLaaL

L consists from the 0’s in the diagonal

)}(:{ iii MLaaL

Consider the language L

Proof of Theorem 9

Since L is a properly defined language, we can consider its complement

Page 62: Computability Decidability

62

1a 2a 3a 4a

0 1 10

01 0 1

0 1 11

0 10 0

},,{ 21 aaL

)1(ML

)2(ML

)3(ML

)4(ML

Page 63: Computability Decidability

63

Claim 1:

Language is not recursively enumerableL

Proof of Theorem 4.9

If we can prove that it is not recursively enumerable, we can now find a language which is not Turing recognizable.

If we can prove that it is not recursively enumerable, we can now find a language which is not Turing recognizable.

Page 64: Computability Decidability

64

is recursively enumerable

LAssume for contradiction that

There must exist some machine

that accepts kM

L

LML k )(

Proof: Claim 1

Page 65: Computability Decidability

65

1a 2a 3a 4a

0 1 10

01 0 1

0 1 11

0 10 0

Question: ?1MMk

)1(ML

)2(ML

)3(ML

)4(ML

Page 66: Computability Decidability

66

1a 2a 3a 4a

0 1 10

01 0 1

0 1 11

0 10 0

)1(ML

)2(ML

)3(ML

)4(ML

Answer: 1MMk )(

)(

11

1

MLa

MLa k

)(

)(

11

1

MLa

MLa k

Page 67: Computability Decidability

67

1a 2a 3a 4a

0 1 10

01 0 1

0 1 11

0 10 0

)1(ML

)2(ML

)3(ML

)4(ML

Question: ?2MMk Answer: 2MMk )(

)(

22

2

MLa

MLa k

)(

)(

22

2

MLa

MLa k

Page 68: Computability Decidability

68

1a 2a 3a 4a

0 1 10

01 0 1

0 1 11

0 10 0

)1(ML

)2(ML

)3(ML

)4(ML

Question: ?3MMk Answer: 3MMk )(

)(

33

3

MLa

MLa k

)(

)(

33

3

MLa

MLa k

Page 69: Computability Decidability

69

Similarly: ik MM for any i

Because either:

)(

)(

ii

ki

MLa

MLa

)(

)(

ii

ki

MLa

MLa

)(

)(

ii

ki

MLa

MLa

)(

)(

ii

ki

MLa

MLa

or

Proof: Claim 1

Page 70: Computability Decidability

70

Therefore, the machine cannot exist kM

Therefore, the language

is not recursively enumerable

L

End of ProofEnd of Proof

Proof: Claim 1

Page 71: Computability Decidability

71

There is no There is no algorithmalgorithm that describes that describes L

(otherwise would be accepted by

some Turing Machine)

L

Observation:

Page 72: Computability Decidability

72

Recursive

Recursively Enumerable

Non Recursively Enumerable

L

Page 73: Computability Decidability

73

Testing whether TM accepts a given string : ATM

Try to construct a TM (H) to decide whether another TM (M) accepts a string (w) or not.

H is decider on (M,w)

accept if M accepts w

H(M,w) =

reject if M rejects w

Page 74: Computability Decidability

74

Testing whether TM accepts a given string : ATM

If w = the encoded string <M>

H is decider on (M,<M>)

accept if M accepts <M>

H(M,<M>) =

reject if M rejects <M>

Page 75: Computability Decidability

75

Testing whether TM accepts a given string : ATM

Now we construct a new TM (D) with H as a subroutine.

D does opposite to what its subroutine does.D = “On input <M>, where M is a TM,

Run H on input <M,<M>)Output the opposite to what H outputs; that is, if H

accepts, reject and if H rejects, accept.”

Page 76: Computability Decidability

76

Testing whether TM accepts a given string : ATM

accept if H rejects <M>

D(<M>) =

reject if H accepts <M>

accept if M rejects <M>

D(<M>) =

reject if M accepts <M>

Page 77: Computability Decidability

77

Testing whether TM accepts a given string : ATM

D(<M>)

H (M,<M>)

M (<M>)if M accepts <M> then H acceptsif M rejects <M> then H rejects

accept

reject accept

reject

Page 78: Computability Decidability

78

Testing whether TM accepts a given string : ATM

running M on <M>

1M

1 1

1

1

1

11

1

1M

2M

3M

4M

2M 3M 4M

1

Page 79: Computability Decidability

79

output of H

Testing whether TM accepts a given string : ATM

1M

0

1

10

0

1

0

1

1

0

1

0

0

1M

2M

3M

4M

2M 3M 4M

1

1

1

Page 80: Computability Decidability

80

Output of D

Testing whether TM accepts a given string : ATM

1M

0

1

10 0

1

0

1

1

0

1

0

0

1M

2M

3M

4M

2M 3M 4M

1

1

1

D 1 10 0

D

1

1

0

?

1

Page 81: Computability Decidability

81

A Language which is Recursively Enumerable and not Recursive

Page 82: Computability Decidability

82

We want to find a language which

There is a

Turing Machine

that accepts

the language

The machine

doesn’t halt

on some input

Is recursively

enumerable

But not

recursive

Page 83: Computability Decidability

83

We will prove that the language

)}(:{ iii MLaaL

Is recursively enumerable

but not recursive

Proof

Page 84: Computability Decidability

84

1a 2a 3a 4a

0 1 10

01 0 1

0 1 11

0 10 0

},,{ 43 aaL

)1(ML

)2(ML

)3(ML

)4(ML

Page 85: Computability Decidability

85

Theorem:

The language )}(:{ iii MLaaL

is recursively enumerable

Proof:

We will give a Turing Machine that accepts L

Page 86: Computability Decidability

86

Turing Machine that accepts L

For any input string w

• Find Turing machine iM

(using the enumeration procedure for Turing Machines)

• Simulate on inputiM ia

iM• If accepts, then accept w

• Compute for whichiaw i

End of Proof

Page 87: Computability Decidability

87

)}(:{ iii MLaaL

Recursively enumerable

)}(:{ iii MLaaL

Not recursively enumerable

(Thus, also not recursive)

Observation:

Page 88: Computability Decidability

88

The language )}(:{ iii MLaaL

is not recursive

Theorem:

Proof:

Assume for contradiction that

L is recursive

Page 89: Computability Decidability

89

Proof

But we know:

L is not recursively enumerable

thus, not recursive

CONTRADICTION!

Therefore, is not recursiveL

End of Proof

Then is recursive L

Page 90: Computability Decidability

90

L

Recursive

Recursively Enumerable

Non Recursively Enumerable

L

Page 91: Computability Decidability

91

Theorem

A language is decidable (recursive) if and only if it is both Turing-recognizable and Co-Turing-recognizable.

Co-Turing-recognizable language is the the complement of a Turing-recognizable language.

Page 92: Computability Decidability

92

Corollary

is not Turing-recognizable.

Proof:

ATM is Turing-recognizable.

if is Turing-recognizable,

ATM would be decidable.

But ATM is not decidable, thus

must not be Turing-recognizable.

ATM

ATM

ATM

Page 93: Computability Decidability

93

Recursively Enumerable and

Recursive

Languages

Page 94: Computability Decidability

94

Definition:

A language is recursively enumerable(rekursivt uppräknelig)

if some Turing machine accepts it

Page 95: Computability Decidability

95

For string :

Let be a recursively enumerable languageL

and the Turing Machine that accepts itM

Lw

w

if then halts in a final state M

Lwif then halts in a non-final stateM

or loops forever

Page 96: Computability Decidability

96

Definition:

A language is recursive

if some Turing machine accepts it

and halts on any input string

In other words:

A language is recursive if there is

a membership algorithm for it

Page 97: Computability Decidability

97

For string :

Let be a recursive languageL

and the Turing Machine that accepts itM

Lw

w

if then halts in a final state M

Lwif then halts in a non-final stateM

Page 98: Computability Decidability

98

We will prove:

1. There is a specific language

which is not recursively enumerable

(not accepted by any Turing Machine)

2. There is a specific language

which is recursively enumerable

but not recursive

Page 99: Computability Decidability

99

Recursive

Recursively Enumerable

Non Recursively Enumerable

Page 100: Computability Decidability

100

We will first prove:

• If a language is recursive then

there is an enumeration procedure for it

• A language is recursively enumerable

if and only if

there is an enumeration procedure for it

Page 101: Computability Decidability

101

Theorem:

if a language is recursive then

there is an enumeration procedure for it

L

Page 102: Computability Decidability

102

Proof:

MM~

Enumeration Machine

Accepts LEnumerates all

strings of input alphabet

Page 103: Computability Decidability

103

If the alphabet is then

can enumerate strings as follows:

},{ baM~

abaaabbabbaaaaab......

Page 104: Computability Decidability

104

Enumeration procedure

Repeat:

M~ generates a string

M

w

checks if Lw

YES: print to output w

NO: ignore w

End of Proof

Page 105: Computability Decidability

105

Example:

M~

abaaabbabbaaaaab......

)(ML

b

ab

bbaaa

......

,....},,,{ aaabbabbL Enumeration

Output

b

ab

bbaaa

......

Page 106: Computability Decidability

106

Theorem:

if language is recursively enumerable then

there is an enumeration procedure for it

L

Page 107: Computability Decidability

107

Proof:

MM~

Enumeration Machine

Accepts LEnumerates all

strings of input alphabet

Page 108: Computability Decidability

108

If the alphabet is then

can enumerate strings as follows:

},{ baM~

abaaabbabbaaaaab

Page 109: Computability Decidability

109

Enumeration procedure

Repeat: M~ generates a string

M

w

checks if Lw

YES: print to output w

NO: ignore w

NAIVE APPROACH

Problem:

If

machine may loop forever

LwM

Page 110: Computability Decidability

110

M~

M

1w

executes first step on

BETTER APPROACH

1w

M~ Generates second string 2w

M executes first step on 2w

second step on 1w

Generates first string

Page 111: Computability Decidability

111

M~ Generates third string 3w

M executes first step on 3w

second step on 2w

third step on 1w

And so on............

Page 112: Computability Decidability

112

1w 2w 3w 4w

1

Step

in

string

1 1 1

2 2 2 2

3 3 3 3

Page 113: Computability Decidability

113

If for any string

machine halts in a final state

then it prints on the output

Miw

iw

End of Proof

Page 114: Computability Decidability

114

Theorem:

If for language

there is an enumeration procedure

then is recursively enumerable

L

L

Page 115: Computability Decidability

115

Proof:

wInput Tape

Enumerator

for LCompare

Machine that

accepts L

Page 116: Computability Decidability

116

Turing machine that accepts L

Repeat:

• Using the enumerator,

generate the next string of L

For input string w

• Compare generated string with w

If same, accept and exit loop

End of Proof

Page 117: Computability Decidability

117

We have proven:

A language is recursively enumerable

if and only if

there is an enumeration procedure for it

Page 118: Computability Decidability

118

A Language which is not

Recursively Enumerable

Page 119: Computability Decidability

119

We want to find a language that

is not Recursively Enumerable

This language is not accepted by any

Turing Machine

Page 120: Computability Decidability

120

Consider alphabet }{a

Strings: ,,,, aaaaaaaaaa

1a 2a 3a 4a

Page 121: Computability Decidability

121

Consider Turing Machines

that accept languages over alphabet }{a

They are countable:

,,,, 4321 MMMM

Page 122: Computability Decidability

122

Example language accepted by

},,{)( aaaaaaaaaaaaML i

},,{)( 642 aaaML i

iM

Alternative representation

)( iML

1a 2a 3a 4a 5a 6a 7a

0 1 1 10 0 0

Page 123: Computability Decidability

123

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Page 124: Computability Decidability

124

Consider the language

)}(:{ iii MLaaL

L consists from the 1’s in the diagonal

Page 125: Computability Decidability

125

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

},,{ 43 aaL

Page 126: Computability Decidability

126

Consider the language

)}(:{ iii MLaaL

L consists from the 0’s in the diagonal

)}(:{ iii MLaaL

L

Page 127: Computability Decidability

127

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

},,{ 21 aaL

Page 128: Computability Decidability

128

Theorem:

Language is not recursively enumerableL

Page 129: Computability Decidability

129

Proof:

is recursively enumerableL

Assume for contradiction that

There must exist some machine

that accepts kM

L

LML k )(

Page 130: Computability Decidability

130

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Question: ?1MMk

Page 131: Computability Decidability

131

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Answer: 1MMk )(

)(

11

1

MLa

MLa k

Page 132: Computability Decidability

132

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Question: ?2MMk

Page 133: Computability Decidability

133

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Answer: 2MMk )(

)(

22

2

MLa

MLa k

Page 134: Computability Decidability

134

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Question: ?3MMk

Page 135: Computability Decidability

135

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Answer: 3MMk )(

)(

33

3

MLa

MLa k

Page 136: Computability Decidability

136

Similarly: ik MM

)(

)(

ii

ki

MLa

MLa

)(

)(

ii

ki

MLa

MLa

for any i

Because either:

or

Page 137: Computability Decidability

137

Thus the machine cannot exist kM

Therefore, the language

is not recursively enumerable

L

End of Proof

Page 138: Computability Decidability

138

Observation:

There is no algorithm that describes L

(otherwise would be accepted by

some Turing Machine)

L

Page 139: Computability Decidability

139

Recursive

Recursively Enumerable

Non Recursively Enumerable

L

Page 140: Computability Decidability

140

A Language which is Recursively Enumerable

and not Recursive

Page 141: Computability Decidability

141

We want to find a language which

There is a

Turing Machine

that accepts

the language

The machine

doesn’t halt

on some input

Is recursively

enumerable

But not

recursive

Page 142: Computability Decidability

142

We will prove that the language

)}(:{ iii MLaaL

Is recursively enumerable

but not recursive

Page 143: Computability Decidability

143

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

},,{ 43 aaL

Page 144: Computability Decidability

144

The language

Theorem:

)}(:{ iii MLaaL

is recursively enumerable

Page 145: Computability Decidability

145

Proof:

We will give a Turing Machine that

accepts L

Page 146: Computability Decidability

146

Turing Machine that accepts L

For any input string w

• Compute , for whichiaw

• Find Turing machine iM(using the enumeration procedure for Turing Machines)

• Simulate on inputiM ia

• If accepts, then accept iM w

i

End of Proof

Page 147: Computability Decidability

147

Observation:

)}(:{ iii MLaaL

)}(:{ iii MLaaL

Recursively enumerable

Not recursively enumerable

(Thus, also not recursive)

Page 148: Computability Decidability

148

Theorem:

The language )}(:{ iii MLaaL

is not recursive

Page 149: Computability Decidability

149

Proof:

Assume for contradiction that is recursiveL

Then is recursive L

Take the Turing Machine that accepts M L

halts on any input:M

If accepts then reject

If rejects then accept

MM

Page 150: Computability Decidability

150

L is recursive

But we know:

L is not recursively enumerable

thus, not recursive

CONTRADICTION!

Therefore, is not recursiveL

End of Proof

Page 151: Computability Decidability

151

L

Recursive

Recursively Enumerable

Non Recursively Enumerable

L