Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(a) Describe how to construct the function cpo ((D E), v) of two cpos (D, vD) and (E, vE). Prove that ((D E), v) is

(a) Describe how to construct the function cpo ((D E), v) of two cpos (D, vD) and (E, vE). Prove that ((D E), v) is a cpo. (b) The function uncurry is inverse to the function curry; it takes a continuous function in (D1 (D2 E)) as argument and yields a continuous function in ((D1 D2) E) as result. Give a definition of uncurry and show it is a continuous function. (You may use general facts about continuous functions provided you state them clearly.) (c) Exhibit two terms of PCF which are contextually equivalent and yet have distinct denotations in the domain (B (B B)) B where B = {true, false} is the set of truth values. Explain why their denotations differ.

address every question

(a) Let M be an n-state deterministic finite automaton over the finite alphabet S. Write l(w) for the length of words w S . Suppose that M accepts the word x S , where l(x) > n. (i) Show that x is a concatenation of words uvw, where l(uv) 6 n, l(v) > 1, and M accepts the word zk = uvkw for all natural numbers k > 0. [8 marks] (ii) Hence show that if M accepts some word y S , it must accept some word z S such that l(z) < n; and that M accepts an infinite set of words if and only if it accepts some word x S such that n 6 l(x) < 2n. [5 marks] (b) Let S = {a, b} be an alphabet of two symbols. Explain whether each of the following languages over S is regular: (i) L1 = {uv | u, v S , l(v) = 2.l(u)} [3 marks] (ii) L2 = {ww | w S }

(a) Briefly outline how a sequence of symbols can be encoded as a sequence of Huffman codes, and explain under what assumptions Huffman encoding generates optimally compact code. (b) Estimate the number of bits needed to Huffman encode a random permutation of As, Bs and Cs, with each letter occurring one million times. [3 marks] (c) Estimate the number of bits needed to Huffman encode a random permutation of As, Bs and Cs, where A occurs two million times and B and C each occur one million times (d) Estimate how many bits would be needed to encode the sequence in part (b) above using arithmetic coding. You may assume that log2 3 is about 1.6. (e) Estimate, with justification, how many bits would be needed to encode the sequence in part (c) above using arithmetic coding. [4 marks] 4 Artificial Intelligence I (a) What are the advantages and disadvantages of constraint satisfaction problem (CSP) solvers compared with search algorithms such as A? search, etc? (b) Give general definition of a CSP. Define the way in which a solution is represented and what it means for a solution to be consistent and complete. (c) Assuming discrete binary constraints and finite domains, explain how breadthfirst-search might be used to find a solution and why this is an undesirable approach (d) Give brief description of the basic backtracking algorithm for finding a solution.

The syntax of parallel commands is given by: c ::= X := a | c0; c1 | c0 || c1 | if b then c | while b do c where X ranges over locations, a over arithmetic expressions, and b over boolean expressions. (a) Give operational semantics to parallel commands, assuming an operational semantics for arithmetic and boolean expressions. [5 marks] (b) This part is concerned with a Petri net semantics for parallel commands. There are to be two kinds of conditions: data conditions, pairs of locations and integers, which specify the contents of locations, and control conditions, which specify the local control points in parallel components of commands. A parallel command is to be represented by a basic net (where every condition has capacity one) in which a subset of control conditions I is to be distinguished as its initial conditions and another subset T is to be distinguished as its terminal conditions; the initial conditions are precisely those control conditions which hold at the start of execution of the command; the terminal conditions are precisely those control conditions which hold if and when the command terminates. A diagrammatic account suffices for answers to the questions below. (i) Describe an (infinite) net for X := X + 1. [2 marks] (ii) Describe a construction on nets for c0; c1. [Hint: Replace the terminal conditions T0 of c0 and the initial conditions I1 of c1 with their product T0 I1.] [4 marks] (iii) Describe a construction on nets for c0 || c1. [2 marks] (iv) Describe a construction on nets for if X > 0 then c. [2 marks] (v) Describe a construction on nets for while X > 0 do c.

(a) What is a minimum sum-of-products? [3 marks] (b) A full adder has data inputs (A0, B0) and a carry input (C0). The sum (S0) and carry (C1) are output. What are the minimum sum-of-products equations for S0 and C1? [6 marks] (c) How could the gate count for the implementation of output S0 be reduced using XOR gates? [2 marks] (d) For a 3-bit full adder (i.e. one which has three A inputs (A0, A1, A2), three B inputs (B0, B1, B2) and three sum outputs (S0, S1, S2)), the final carry output is C3. What is the sum-of-products equation for C3 in terms of the A and B inputs? [6 marks] (e) If we were to implement an 8-bit full adder, why would we look for a multi-level logic implementation for the carry output (C8)?

(a) Distinguish between the terms instance method and class method. [4 marks] (b) A newcomer to Java programming has written the following code: class Parent { public void test() { System.out.println("Parent"); } } public class Child extends Parent { public static void main(String[] args) { Parent p = new Parent(); Child c = new Child(); p.test(); c.test(); p = c; p.test(); c.test(); c = p; p.test(); c.test(); } public void test() { System.out.println("Child"); } } The javac compiler complains about one statement. Which one and why? Correct the code by inserting an appropriate cast. [4 marks] (c) With this correction the program will compile and run. Explain in outline what happens at run-time and show what output is printed. [5 marks] (d) Small print in the Java documentation says that you "cannot override a static method but you can hide it". If both test() methods are made static the program will again compile and run. Explain what happens this time and show what output is printed.

Consider the Prolog procedures named s and p defined as follows: s(H, [H|T], T). s(H, [N|T], [N|L]) :- s(H, T, L). p(X, [H|T]) :- s(H, X, Z), p(Z, T). p([], []). (a) Show how Prolog would evaluate the goal s(H, [a,b,c], T) giving all the successive instantiations of H and T that cause the goal to be satisfied, and hence describe in words what s does. [6 marks] (b) What value of Q causes the goal p([a], Q) to be satisfied? [3 marks] (c) What values of Q cause the goal p([a,b], Q) to be satisfied? [4 marks] (d) What values of Q cause the goal p([a,b,c], Q) to be satisfied? [5 marks] (e) Describe in words what p does.

State the requirements for (S, 6) to be: (a) a partially ordered set; (b) a totally ordered set; (c) a well ordered set. [5 marks] Let (N, 6) be the natural numbers under the standard ordering. Define the product ordering 6p on (NN) that is derived from this ordering. Which of conditions (a), (b), (c) does 6p satisfy? [3 marks] Let (S, 6) and (T, ) be partially ordered sets, and f : (S, 6) (T, ) be a function. What condition must be satisfied in order that f be monotonic? [2 marks] If f is a bijection, and both f and f 1 are monotonic, we say that (S, 6),(T, ) are isomorphic partially ordered sets. Suppose that (S, 6) is a partially ordered set. A topological sort of (S, 6) is defined by specifying a total ordering v on S such that the identity map : (S, 6) (S, v) is monotonic. Define two different topological sorts of (NN, 6p), one of which is isomorphic to N with the standard ordering, while the other is not. Justify your claims. [10 marks]

(a) List the three kinds of Java inner class and say which of the three is used in the following program. [4 marks] public class Trial { private boolean b = true; private Trial() { (new ClassIn()).test(); this.b = false; } public static void main(String args []) { new Trial(); } private class ClassIn { ClassIn() { boolean b = false; } private void test() { if (this.b) System.out.println("Yes"); else System.out.println("No"); } } } (b) The javac compiler complains about the condition in the if-statement. What is the complaint? Show two ways in which the condition may be fixed. [4 marks] (c) With either of these corrections the program will compile and run in the same way. Explain what happens at run-time and, in particular, show what output is printed. [6 marks] (d) Rearrange the code so that class ClassIn is a local class within the constructor Trial(). The program as a whole should perform as before.

Write program that reads a person's first and last names, separated by a space. Then the program outputs last name, comma, first name. Create program that takes in user input and stores the input into an array. Also within the program show how you can: show the elements in the array, remove an element from the array, add an element to the array. Write program that reads a list of integers ending with a negative, and that then outputs that list in reverse. After the negative that ends the list, a character indicates what character should separate the output integers

(a) A (phrase-structured) grammar is often defined to be a 4-tuple (N, T, R, S) where R is a set of production rules. Explain what the other components of the 4-tuple are. Explain also the (most general form of) production rules, how these are conventionally restricted and why one might wish to restrict them. [6 marks] (b) Give a grammar which is ambiguous. [2 marks] (c) Give a grammar which is not a regular grammar but which generates a regular language containing an infinite number of strings. [2 marks] (d) Is it possible to write a grammar which generates the strings {aa, aaa, aaaaa, . . . , ap , . . .} where p is prime? (A general argument for or against suffices.) [2 marks] (e) It is desired to construct a simple "pocket-calculator" program using yacc and lex (or other similar automated tools of your choice) which can parse strings such as "1+(10-5-3)*5+2=" and print the result, 13 in this case. Outline the overall structure of your program components. Give full details of the input to yacc and lex (or equivalent). (Precise syntactic details are not important, but your answer should show an understanding of the principles involved.)

(a) Calculate the maximum resolution needed by a movie projector in a movie theatre. Clearly state any assumptions that you make. [6 marks] (b) Describe, in detail, an error diffusion algorithm for converting greyscale images to bi-level black and white images at the same resolution. [8 marks] (c) Explain how this could be extended to provide an algorithm to print full colour RGB images on a CMYK laser printer, assuming that one pixel in the image maps to one pixel on the printer. [6 marks] 11 Introduction to Security (a) A and B play a simple game. A chooses a number RA Z3 and B chooses a number RB Z3. Then A and B communicate their respective choice to each other simultaneously, meaning that the players cannot change their choice after having seen that of the opponent. These rules decide who wins the game: RA RB + 1 (mod 3) A wins RB RA + 1 (mod 3) B wins In any other case, the result of the game is a draw. (i) What complication arises when this game is played at a distance, for example via e-mail? [2 marks] (ii) Suggest a cryptographic protocol that prevents cheating when this game is played via e-mail. Your solution should not rely on a trusted third party. [6 marks] (iii) What assumptions do you make about the cryptographic functions used in your solution of part (ii)? [3 marks] (iv) What assumptions do you make about the amount of computing power available to the opponent in your solution of part (ii)? [3 marks] (b) Outline briefly the purpose of an organisation's security policy and what steps should be considered in its development.

(a) Explain informally, i.e. without reference to any particular model of computation, why the Halting Problem is undecidable. [6 marks] (b) Briefly describe two mathematical problems, other than the Halting Problem, that are algorithmically undecidable. [4 marks] (c) What does it mean for a partial function to be register machine computable? Show how the informal argument in part (a) can be turned into a rigorous proof that there is no register machine deciding the Halting Problem for register machine computable functions.

(a) A device driver process carries out character I/O via a Universal Asynchronous Receiver/Transmitter (UART). (i) Why is hardware-software synchronisation needed? [1 mark] (ii) Describe polled operation. [2 marks] (iii) Describe interrupt-driven operation. [2 marks] (iv) Draw a state transition diagram for the device-driver process. Indicate the events that cause each transition and in each case explain the effect on the device driver's process descriptor and the operating system's scheduling queues. Assume interrupt-driven software. [7 marks] (b) The device driver process fills/empties a buffer of fixed size in an I/O buffer area. A process carrying out application requests reads and writes data in variable-sized amounts from the buffer. (i) Why must mutually exclusive access to the buffer be enforced? [2 marks] (ii) Why is condition synchronisation needed? [2 marks] (iii) What is wrong with the following pseudocode fragment from the devicedriver's specification, where: buffer-lock is a semaphore initialised to 1, space is a semaphore initialised to the buffer size in bytes, data is a semaphore initialised to 0? on input: on output: WAIT(buffer-lock); WAIT(buffer-lock); if buffer is full then WAIT(space); if buffer is empty then WAIT(data); write a character into the buffer; read a character from the buffer; SIGNAL(buffer-lock); SIGNAL(buffer-lock);

Imagine that you are the user interface designer responsible for a system that manages the shutdown of a nuclear power station. (a) Comment on hazards, risks and reliability. (b) What special procedures should be followed during design? (c) There is some debate among the team about whether the operator should be in the control loop. What options are there? (d) In order to assess alternative options like those in part (c): (i) How could you estimate the speed of operator action based on a draft interface layout? (ii) How could you measure the speed of operator action using alternative prototypes? (iii) How could you estimate the probability of operator error?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions