代写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.






热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图