Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For each of the following equivalences, state whether it holds or not, justifying each answer rigorously. (i) ((P ? Q) ? R) ? P '

For each of the following equivalences, state whether it holds or not, justifying each answer rigorously. (i) ((P ? Q) ? R) ? P ' P ? (Q ? R) [3 marks] (ii) (?x P(x)) ? (?x Q(x)) ' ?x [P(x) ? Q(x)] [5 marks] (b) For the following formula, present either a sequent calculus proof or a falsifying interpretation. [?x ?y P(x, y)] ? [?x P(x, f(x))] [4 marks] (c) For the following formula, in modal logic S4, present either a sequent calculus proof or a falsifying interpretation. (A ? B) ? (A ? B)Write C program that prompts the user for an input string with all lowercase letters. Your program should then sort the characters in the string and print the sorted string

Write program that separately prompts the user for a first name and last name and outputs a string containing the following information,

Write program that prompts the user to enter the name of a file. The program encoded sentences in the file and writes the encoded sentences to the output file.

Write static method named textcount that takes a scanner representing a file as a parameter and that reports various statistics about the file. Write recursive function that takes positive int n as its input and returns sum of the first n squares Write function, RandomRange that takes an integer then it returns a list of length n, where n is an integer passed as an argument, and the numbers in the list are random numbers in the range 1 to n inclusive.


) Carefully describe the code you would generate for the JARGON virtual machine for the body of the function sum defined above. If you need to extend the virtual machine with new instructions, then define their semantics. (You do not need to remember the exact syntax of the JARGON instructions as long as you clearly explain what your code is doing.) [6 marks] 5 (TURN OVER) CST1.2019.4.6 4 Compiler Construction This question explores how exceptions might be added to SLANG and the JARGON virtual machine. We will raise an exception with raise e where e is an expression. We will "trap" an exception with the following expression. try e with f end If e evaluates to a value v, then v is the result of the try-expression. Otherwise, the evaluation of e raises an exception E and the try-expression continues by evaluating the function application f(E). To simplify things we will assume that each f is an identifier. Uncaught exceptions at the top-level will result in a runtime error. (a) Do we need to define a fixed type for exceptions? Justify your answer. [3 marks] (b) What typing rule or rules would you implement for the expression raise e? Justify your answer. [3 marks] (c) A compiler may rewrite expressions in order to optimise generated programs. For example, here are two rewrite rules to simplify conditional expressions: code replacement 1 if true then e1 else e2 e1 2 if false then e1 else e2 e2 For each of the rules below, argue that it is, or is not, a valid optimisation rule. code replacement 1 raise (raise e) raise e 2 e1 + (raise e2) raise e2 3 try (raise e) with f end f(e) 4 try e with (fun x -> raise x) end e [6 marks] (d) Carefully describe the stack-oriented code you would generate for both the raise- and try-expressions. [8 marks] 6 CST1.2019.4.7 5 Further Java A programmer designs a client-server booking system for a meeting room. The role of the server is to distribute bookings between clients when they connect. Clients open a socket connection to the server regularly for a short period. When a client connects, the client first sends to the server an instance of Message which contains any new bookings made by the client; in response, the server sends an instance of Message containing all bookings made by other clients since the client last connected; the server then closes the connection. The key parts of the Message and Booking classes are defined as follows: public class Message implements Serializable { private final String uniqueClientId; private final java.util.List bookings; ... } public class Booking implements Serializable { private final String uniqueClientId; private final java.util.Date startTime; private final java.util.Date endTime; private final String description; ... } (a) Write a Java implementation of the server, using a single thread to serve each client in turn. You may assume the existence of a static method processBookings, which accepts a list of new bookings from a specified client and returns a list of bookings to be sent back to the client. You may assume suitable accessor methods for Message and Booking; you do not need to handle exceptions. [8 marks] (b) The programmer decides to extend the booking system with vector clocks. (i) Write down a suitable data structure for a vector clock in Java. [2 marks] (ii) Describe in words how the system can be modified to incorporate vector clocks and allow clients to compute a partial order of Message objects. Discuss how vector clocks are initialised and updated. [6 marks] (iii) The programmer wants to use vector clocks to determine which booking occurred first, allowing clients to mark any subsequent bookings as in conflict and therefore cancelled. Describe when the vector clock algorithm cannot determine which booking is first, how this is detected, and propose a solution which resolves the ambiguity

Consider a restaurant software ordering system. The system should allow the waiter to handle customers' orders by adding them, cancelling them, scheduling parts of the order (to make the starter arrive earlier than the main course). The cashier should be allowed to let customers pay for their meals, and print receipts. (a) List two requirements (one functional and one non-functional) of the system using the MOSCOW requirement prioritisation method. [2 marks] (b) Draw a use case diagram for a restaurant ordering system and give the use case detailed description of the use case CancelOrder. [7 marks] (c) Define a class diagram with a maximum of three classes for the restaurant ordering system. [2 marks] (d) Show the activity of processing a meal order within the system using an activity diagram. [4 marks] (e) Show the use case realization (through interaction diagrams) of one of the use cases you have drawn for part (b).

imageimage

(a) A computer system is a complex system which has the ability to deal with many processing applications. Concurrently, the operation of accessing data in between processor and main memory is one of the important operations in computer system in order to obtain high performance processing. (1) Cache memory is a Random Access Memory (RAM), which allows a microprocessor access the memory more quickly than it can access regular RAM. Indentify TWO (2) types of cache in ARM processor and explain these caches with the aid of diagrams. (ii) There are TWO (2) terms used to characterize the cache efficiency in ARM processor. Discuss these terms, and explain how to compute the cache efficiency.

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

Discrete and Combinatorial Mathematics An Applied Introduction

Authors: Ralph P. Grimaldi

5th edition

201726343, 978-0201726343

More Books

Students also viewed these Computer Network questions

Question

What is the difference between adsorption and absorption?

Answered: 1 week ago