1 decidability continued…. 2 theorem: for a recursively enumerable language it is undecidable to...

51
1 Decidability continued…

Upload: mayra-hinman

Post on 14-Dec-2015

219 views

Category:

Documents


1 download

TRANSCRIPT

1

Decidability

continued…

2

Theorem:

For a recursively enumerable language Lit is undecidable to determine whether is finite L

Proof:

We will reduce the halting problemto this problem

3

Algorithm for finite languageproblem

M

YES

NO

Assume we have the finite language algorithm:

Let be the machine that accepts M L

)(ML

)(ML

finite

not finite

LML )(

4

Algorithm for Halting problem

M

w

YES

NO

halts onM w

We will design the halting problem algorithm:

doesn’t halt onM w

5

First construct machine : wM

When enters a halt state, accept any input (inifinite language)

M

Initially, simulates on input M w

Otherwise accept nothing (finite language)

6

M halts on

)( wML is not finite

if and only if

w

7

Algorithm for halting problem:

Inputs: machine and string M w

1. Construct wM

2. Determine if is finite )( wML

YES: then doesn’t halt on

NO: then halts on

M w

M w

8

construct

wM

Check if

)( wMLis finite

YES

NO

M

w

NO

YES

Machine for halting problem

9

Theorem:

For a recursively enumerable language Lit is undecidable to determine whether contains two different strings of same length L

Proof:We will reduce the halting problemto this problem

10

Algorithm for two-stringsproblem

M

YES

NO

Assume we have the two-strings algorithm:

Let be the machine that accepts M L

)(ML

)(ML

contains

Doesn’t contain

LML )(

two equal length strings

11

Algorithm for Halting problem

M

w

YES

NO

halts onM w

We will design the halting problem algorithm:

doesn’t halt onM w

12

First construct machine : wM

When enters a halt state, accept symbols or

M

Initially, simulates on input M w

a b(two equal length strings)

13

M halts on

wM

if and only if

w

accepts and a b

(two equal length strings)

14

Algorithm for halting problem:

Inputs: machine and string M w

1. Construct wM

2. Determine if accepts two strings of equal length

wM

YES: then halts on

NO: then doesn’t halt on

M w

M w

15

construct

wM

Check if)( wML

has twoequal lengthstrings

YES

NO

M

w

YES

NO

Machine for halting problem

16

The Post Correspondence Problem

17

Some undecidable problems forcontext-free languages:

• Is context-free grammar ambiguous?G

• Is ? )()( 21 GLGL

18

We need a tool to prove that the previousproblems for context-free languagesare undecidable:

The Post Correspondence Problem

19

The Post Correspondence Problem

Input: Two sequences of strings

nwwwA ,,, 21

nvvvB ,,, 21

20

There is a Post Correspondence Solutionif there is a sequence such that:kji ,,,

kjikji vvvwww

PC-solution

21

Example:11100 111

001 111 11

1w 2w 3w

1v 2v 3v

:A

:B

PC-solution: 3,1,2 312312 vvvwww

11100111

22

Example:00100 1000

0 11 011

1w 2w 3w

1v 2v 3v

:A

:B

There is no solution

Because total length of strings from is smaller than total length of strings from

BA

23

The Modified Post Correspondence Problem

Inputs: nwwwA ,,, 21

nvvvB ,,, 21

MPC-solution: kji ,,,,1

kjikji vvvvwwww 11

24

Example:11 100111

001111 11

1w 2w 3w

1v 2v 3v

:A

:B

MPC-solution: 2,3,1 321231 vvvwww

11100111

25

1. We will prove that the MPC problem is undecidable

2. We will prove that the PC problem is undecidable

26

1. We will prove that the MPC problem is undecidable

We will reduce the membership problemto the MPC problem

27

Membership problem

Input: recursive language string

Lw

Question: ?Lw

Undecidable

28

Membership problem

Input: unrestricted grammar string

Gw

Question: ?)(GLw

Undecidable

29

The reduction of the membership problemto the MPC problem:

For unrestricted grammar and string G w

we construct a pair such thatBA,

BA, has an MPC-solution if and only if )(GLw

30

A

FS

B

FF : special symbol

aa For every symbol

Grammar G

S : start variable

a

V V For every variable V

31

A

y

B

x

wEE

Grammar G

For every production

yx

E : special symbol

string w

32

Example:

Grammar : G

aacAC

CBb

BbbaABbS

|

String aaacw

33

A B

FS F:1w :1v

a a

b b

c c

A

B

CS

A

B

CS

:2w

:8w

:2v

:8v

34

A B

E aaacE:9w :9v

aABb S

Bbb S

C Bbaac

AC

:14w

:14v

35

)(GLaaac

aaacaACaABbS

Grammar : G

aacAC

CBb

BbbaABbS

|

36

bBAaSF

A

B

1w

aABbS

10w

1v 10v

37

CAabBAaSF

A

B

1w

aACaABbS

10w

1v 10v

14w 2w 5w 12w

14v 2v 5v 12v

38

EcaaaCAabBAaSF

A

B

1w

aaacaACaABbS

10w

1v 10v

14w 2w 5w 12w

14v 2v 5v 12v 14v 2v 13v 9v

14w 2w 13w 9w

39

Theorem:

),( BA has an MPC-solution if and only if )(GLw

40

Algorithm for membership problem:

Input: unrestricted grammar string

Gw

Construct the pair BA,

If has an MPC-solution then BA, )(GLw

else )(GLw

41

G

w

constructBA,

BA, MPCalgorithm

solution

No-solution

)(GLw

)(GLw

Membership machine

42

2. We will prove that the PC problem is undecidable

We will reduce the MPC problemto the PC problem

43

: input to the MPC problemBA,

nwwwA ,,, 21

nvvvB ,,, 21

44

We construct new sequences DC,

nwwwA ,,, 21

nvvvB ,,, 21

110 ,,,, nn wwwwC

110 ,,,, nn vvvvD

45

abcadwi

***** dacbawi

A

C

We insert a special symbol between any two symbols

46

abcadvi

dacbavi *****

B

D

47

1nw

C

Special Cases

10 *ww

*1nv

D

10 vv

48

Observation:

There is a PC-solution forif and only ifthere is a MPC-solution for

DC,

BA,

49

PC-solution 1010 nknk vwvwww

MPC-solution kk vvww 11

50

MPC-algorithm

Input: sequences BA,

Construct sequences DC,

Solve the PC problem for DC,

51

BA,construct

DC,DC, PC

algorithm

solution

No-solution

MPC algorithm