Home Assignment 2 for Programming Theory (TDDD 47) Version 1.2 Deadline: Monday week 40 (4 October 2010). Provide explanations to justify how and why your solutions work. Put your solutions, addressed to Jonas Wallgren, in the “Post till IDA” slot at CafeĢ Java. Keep a copy of your solutions for the homework reporting session (Wednesday week 40). The numbers in parentheses refer to the old version of our textbook. A. Exercise 5.7 (4.7) from the book. (Comparing functions from State ,→ State). B. 1. Consider a subset Y = { gn | n ≥ 0 } of State ,→ State where ( gn s = s[ y 7→ (s x) + (−1)n · (s z) ] undef if − n < s x ≤ n if s x ≤ −n or s x > n Is Y a chain in (State ,→ State, v) ? 2. Modify the definition of gn so that if Y is a chain then the resulting set Z = { hn | n ≥ 0 } is not a chain, and if Y is not a chain then Z is a chain. The modified definition should be of the form ( hn s = s[ y 7→ (s x) + . . . ] undef if − n < s x ≤ n if s x ≤ −n or s x > n 3. Out of the two definitions of Y and Z consider that defining a chain. Modify the conditions following “if” such that the resulting set W of functions is not a chain. 4. Let X be the one of the sets Y, Z that is a chain. What is the least F upper bound X of X ? Add one element h to X so that X ∪ {h} is not a chain, and does not have an upper bound. Add one element g to X so that X ∪ {g} is not a chain, but has a least upper bound. Can you find a g such that the least upper bounds of X and X ∪ {g} are not the same? 1 C. Which of the following functions from (State ,→ State) → (State ,→ State) are monotone? F1 g = ⊥ F0 g = g ( F2 g = ( F3 g s = gs s g1 g2 if g = g2 otherwise ( if s x 6= 0 otherwise F4 g s = ( F5 g s = where g2 v g1 , g2 6= g1 s gs (g s)[x 7→ 0] s if s x 6= 0 otherwise if g s undefined otherwise D. (Optional!) Choose a monotone function from F3 , . . . , F5 and check whether it is continuous. E. Exercise 6.9 (4.70) from the textbook. (Add call by value arguments to the language Proc; modify its denotational semantics to describe this extension.) Part of the task is already done, by defining the semantics of the procedure call by: Sds [[call p(a1 , a2 )]] envV envP sto = envP p (A[[a1 ]]s, A[[a2 ]]s) sto where s = lookup envV sto It remains to describe the semantics of procedure declarations. Your answers may be in Swedish or English. It is allowed to discuss the exercises with others, but you are supposed to solve each exercise individually. It is absolutely not allowed to copy solutions from others. The maximal marks for problems A, B, C, D, and E are, respectively, 1, 7, 5, 2, 7. To pass one needs 10 points including at least 3 for problem E. 2