代写G5029 Limits of Computation BSc FINAL YEAR EXAMINATION May 2020 (A2)代写留学生Java程序

G5029

BSc FINAL YEAR EXAMINATION

May 2020 (A2)

Limits of Computation

1. This question is about WHILE and other notions of effective computability.

(a) The WHILE-language has one built-in data type, the type of binary trees where leaves contain always atom nil (for pure WHILE). Explain briefly why this is sufficient to define the notion of computability.         [4 marks]

(b)  Let foo be the following pure WHILE-program:

foo  read  L  {

out  :=  cons nil nil;

while  L  {

X  := hd  L;

if  X

{  L:=  tl  L

}

else  {

out  := nil;

L:= nil

}

}

}

write  out

i.  What  is   ‘fooIWHILE (「1」)  and  ‘fooIWHILE  (「[1]」),  respectively?     No  explanation required.                                                             [2 marks]

ii. Give the semantics of the program foo, in other words give a precise definition of the partial function ‘fooIWHILE   :  D  !  D? .   Do not re- explain or narrate the program.                    [6 marks]

(c)  Explain the semantical difference between a WHILE-expression and a WHILE-command. [4 marks]

(d) Write a WHILE-program that has the following data representation:

[  0,

[

[while,[var,0],[  [:=,1,[cons,[hd,[var,0]],[quote,nil]]  ], [:=,0,[tl,[var,0]]  ]

]

]

],

1]                                    [10 marks]

(e) Why is it important to have a computation model that supports programs- as-data?       [6 marks]

(f)  Consider now computability of functions on natural numbers, i.e. functions of type N N? .

i.  For each of  the  following  functions  f  on  natural  numbers  state whether they are WHILE-computable or  not.   Briefly  explain your answer in a sentence.

n

·

A.  f (n) =  ·>

n times

B.  f (n) = max Kn  where

Kn  = {k∈N |  ‘pIWHILE  (nil)=「k」for program p s.t. |p|     n}

C.  f (n) = { 0(1)   t(f)her(‘pI)wise(WHILE) (p) ⊥ where p is then-th WHILE-program

D.  f (n) = ⊥ for all n ∈ N

E.  f (n) = minKn where

Kn  = {k∈N |  ‘pIWHILE  (nil)=「k」for program p s.t. |p|     n} [10 marks]

ii.  Does computability of such functions depend on whether they are  implemented in WHILE or RAM? Briefly explain your answer.  [3 marks]

iii.  If we removed the conditional statement (if  then  else) from the  pure WHILE-language, could we still compute the same functions of type N → N?  that we did with the conditional?  Explain your answer briefly.                                       [5 marks]

2. This question is about semi-decidability, decidability, and various forms of reduction.

(a)  For each of  the  following  problems  state  whether  it  is  WHILE-semi- decidable or not. Explain your answer in one sentence.

i.  NAT: Given an element of D, does it encode a natural number?

ii.  HALT (the halting problem for WHILE);

iii. The complement of HALT;

iv. The complement of the Traveling Salesman Problem. [8 marks]

(b)  For the following sets A WHILE-data  state whether they are WHILE-

decidable or undecidable and explain your answer.  In cases where A is decidable this explanation should consist of a description of the decision procedure. Recall that「p」denotes the encoding of WHILE-program p in D.

i. A = {「p| p returns nil ifits input encodes a natural number }  [4 marks]

ii. A = {「p|「p」=「read X { while true {}} write X} .     [4 marks]

iii.  A = {「[p, k]| p ∈ O(nk ) }                                     [4 marks]

(c) This question addresses the importance of effective problem reduction in computability theory.

i.  For each of the following statements say whether the given effective reductions from A D  to  B D,  A     rec    B ,  are true or false. Explain each answer briefly.  In case where the answer is true this explanation should be a description of the reduction function.

A.  {「1」,「2」,「4}   rec  HALT

B.  {「n| n ∈ N ∧ nis odd}    rec  {「n| n ∈ N ∧ nis even}

C.  {nil}   rec  HALT

D.  HALT    rec  {nil}

E. D\ HALT    rec  {nil} [10 marks]

ii.  Explain  in  one  or  two  sentences  only  the  difference  between   effective problem reduction and polynomial time reduction.  [5 marks]

(d)  For each of the following statements about the recursion theorem say whether it is true or false. Explain your answer in one sentence.

i. The recursion theorem implies that there exists a WHILE program that returns its own description as data whatever the input.

ii. The recursion theorem does not apply to Java.

iii. The  recursion  theorem  implies  that  any  programming  language meeting the theorem’s assumptions allows indirectly for recursive program definitions.          [6 marks]

(e)  For each of the following problems state whether they are closed under the given operation. Explain your answer briefly.

i.  If  A and B  are  semi-decidable,  is  the set  C  =  A ∩ B,  i.e.  the intersection of A and B , semi-decidable?    [3 marks]

ii.  if A     N is decidable, is the set of all identical pairs of numbers, i.e.  { (a, a) | a ∈ A} decidable?     [3 marks]

iii.  if  A       N  is  decidable,  is  the  set  of  all  numbers  for  which  the  busy-beaver function returns a number in A that is smaller than 500 decidable, i.e. { a | a ∈ A ∧ BB (a) < 500 } decidable? [3 marks]

3. This question is about complexity.

(a) A function f : N N is a time bound for an L-program p if, and only if, for all input d 2 L-data it holds that timep(L)(d)      f (jdj) where jdj is the size of d.

i.  How does one  measure the size of d,  jdj,  for  d  2  WHILE-data? [2 marks]

ii.  In which situation do we have timep(L)(d) = ??                      [2 marks]

iii.  Explain why it makes a difference for the time bound of a WHILE-  program p on natural numbers whether p uses natural numbers in  unary or decimal representation, i.e. whether it encodes a number  like 12 as「12」or as a list「[1, 2]」where「 」denotes the standard encoding of data as presented in lectures.                          [6 marks]

(b)  For each of the following statements, state whether they are (known to be) true,  (known to be) false, or whether the answer is currently still unknown.  Accordingly, write as answer either true, false, or unknown, respectively.    Give  a  short  reason  for each answer  (one  sentence suffices).

i. The Halting Problem is in P.

ii. NP EXP

iii. P NP

iv.  WHILE lintime  TM

v. The Satisability Problem (SAT) is in P.

vi. Max-Cut P Integer Programming.

vii. The 0-1 Knapsack Problem is in P if one represents integers as unary numbers.

viii. NPSRAM NPWHILE

ix.  WHILE  lintime  WH1 LE.

x.  (The optimisation problem version of) TSP is not in APX.  [20 marks]

(c) A sequence s is a subsequence of a sequence t if s can be obtained from t by deleting some (maybe none) elements in t.   For  instance, the sequence 1, 4, 7, the sequence 2, 3, 4, 6 and sequence 4, 7 are all subsequences of  1, 2, 3, 4, 5, 6, 7,  respectively.   Subsequence  1, 4, 7  is obtained by deleting 2, 3, 5 and 6 ; subsequence 2, 3, 4, 6 is obtained by deleting 1, 4, 5 and 7 ; subsequence 4, 7 is obtained by deleting 1, 2, 3, 5 and 6.

The common subsequence problem (CSP)  is  the  following  decision problem:  given a set of finite sequences s1 , . . . , sn  (over a given finite alphabet), is there a sequence s of length at least K such that s is a subsequence of each sequence s1 ,. . . , sn?

Show that CSP is in NP.                                                              [8 marks]

(d) Argue  that PWHILE    is  closed  under  complement,   i.e.  argue  that  the following holds:

If A is in PWHILE , then A’s complement, D / A, is also in PWHILE .   [6 marks] (e) A sequence s is a subsequence of a sequence t if s can be obtained

from t  by  deleting  some  (maybe  none)  elements  in  t  as  set  out  in Question 3(c).

The increasing subsequence problem (ISP)  is the following decision problem:  given a sequence of integer numbers s and a number K , is there a sorted subsequence of s that has at least K elements?   By sorted we mean that the integers in the sequence appear in ascending order. For instance, for s = 4, 1, 8, 2, 1, 1, 5 and K = 3, the answer is YES as 1, 2, 5 is an increasing subsequence of s; for K = 4 the answer is YES, as 1, 1, 1, 5 is an increasing subsequence of s. For any K ≥ 5 the answer would be NO.

Show that ISP ≤P  CSP, i.e. that ISP is polynomially reducible to CSP where CSP was explained in Question 3c) – by answering the following questions:

i.  Describe the required reduction function f.                        [4 marks]

ii. Argue that the function f you defined satisfies the condition of a reduction function,  i.e. x  2  ISP iff f(x)  2  CSP (you will need to explain what x is).                                      [2 marks]

You don’t have to show that the function is computable in polynomial time or total.






热门主题

课程名

omp9727 ddes9903 mgt253 fc021 int2067/int5051 bsb151 babs2202 mis2002s phya21 18-213 cege0012 math39512 math38032 mech5125 mdia1002 cisc102 07 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 efim20036 mn-3503 comp9414 math21112 fins5568 comp4337 bcpm000028 info6030 inft6800 bcpm0054 comp(2041|9044) 110.807 bma0092 cs365 math20212 ce335 math2010 ec3450 comm1170 cenv6141 ftec5580 ecmt1010 csci-ua.0480-003 econ12-200 ectb60h3f cs247—assignment ib3960 tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 econ7230 msinm014/msing014/msing014b math2014 math350-real eec180 stat141b econ2101 fit2004 comp643 bu1002 cm2030 mn7182sr ectb60h3s ib2d30 ohss7000 fit3175 econ20120/econ30320 acct7104 compsci 369 math226 127.241 info1110 37007 math137a mgt4701 comm1180 fc300 ectb60h3 llp120 bio99 econ7030 csse2310/csse7231 comm1190 125.330 110.309 csc3100 bu1007 comp 636 qbus3600 compx222 stat437 kit317 hw1 ag942 fit3139 115.213 ipa61006 econ214 envm7512 6010acc fit4005 fins5542 slsp5360m 119729 cs148 hld-4267-r comp4002/gam cava1001 or4023 cosc2758/cosc2938 cse140 fu010055 csci410 finc3017 comp9417 fsc60504 24309 bsys702 mgec61 cive9831m pubh5010 5bus1037 info90004 p6769 bsan3209 plana4310 caes1000 econ0060 ap/adms4540 ast101h5f plan6392 625.609.81 csmai21 fnce6012 misy262 ifb106tc csci910 502it comp603/ense600 4035 csca08 8iar101 bsd131 msci242l csci 4261 elec51020 blaw1002 ec3044 acct40115 csi2108–cryptographic 158225 7014mhr econ60822 ecn302 philo225-24a acst2001 fit9132 comp1117b ad654 comp3221 st332 cs170 econ0033 engr228-digital law-10027u fit5057 ve311 sle210 n1608 msim3101 badp2003 mth002 6012acc 072243a 3809ict amath 483 ifn556 cven4051 2024 comp9024 158.739-2024 comp 3023 ecs122a com63004 bms5021 comp1028
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图