COMPUTER SCIENCE TRIPOS

Similar documents
Regular Languages and Finite Automata

PROG0101 Fundamentals of Programming PROG0101 FUNDAMENTALS OF PROGRAMMING. Chapter 3 Algorithms

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

3. Mathematical Induction

Properties of Real Numbers

Lecture 7: NP-Complete Problems

9.4. The Scalar Product. Introduction. Prerequisites. Learning Style. Learning Outcomes

Full and Complete Binary Trees

Programming Languages

Regular Expressions and Automata using Haskell

Mathematical Induction. Lecture 10-11

ML for the Working Programmer

Creating, Solving, and Graphing Systems of Linear Equations and Linear Inequalities

NP-Completeness and Cook s Theorem

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

You can probably work with decimal. binary numbers needed by the. Working with binary numbers is time- consuming & error-prone.

Instructor Özgür ZEYDAN (PhD) CIV 112 Computer Programming

Algorithm & Flowchart & Pseudo code. Staff Incharge: S.Sasirekha

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

University of Ostrava. Reasoning in Description Logic with Semantic Tableau Binary Trees

The Classes P and NP

Chapter 6: Programming Languages

Grade Level Year Total Points Core Points % At Standard %

Solutions Q1, Q3, Q4.(a), Q5, Q6 to INTLOGS16 Test 1

SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89. by Joseph Collison

KS3 Computing Group 1 Programme of Study hours per week

Answer Key for California State Standards: Algebra I

Functional Programming. Functional Programming Languages. Chapter 14. Introduction

Automata and Formal Languages

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 4 Nancy Lynch

CMPSCI 250: Introduction to Computation. Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013

Handout #1: Mathematical Reasoning

Reading 13 : Finite State Automata and Regular Expressions

Let s put together a Manual Processor

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 OUTCOME 3 PART 1

Formal Verification of Software

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.

Figure 1: Graphical example of a mergesort 1.

Notes on Determinant

Chapter 13: Program Development and Programming Languages

Overview. Essential Questions. Precalculus, Quarter 4, Unit 4.5 Build Arithmetic and Geometric Sequences and Series

WESTMORELAND COUNTY PUBLIC SCHOOLS Integrated Instructional Pacing Guide and Checklist Computer Math

CS510 Software Engineering

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Logic in Computer Science: Logic Gates

Why? A central concept in Computer Science. Algorithms are ubiquitous.

Lecture 1: Oracle Turing Machines

MICROPROCESSOR AND MICROCOMPUTER BASICS

Introduction to Logic in Computer Science: Autumn 2006

C H A P T E R Regular Expressions regular expression

Integer Operations. Overview. Grade 7 Mathematics, Quarter 1, Unit 1.1. Number of Instructional Days: 15 (1 day = 45 minutes) Essential Questions

Higher Computing Science Course Assessment Specification (C716 76)

2 SYSTEM DESCRIPTION TECHNIQUES

26 Integers: Multiplication, Division, and Order

Compiler Construction

Artificial Intelligence

Database Programming with PL/SQL: Learning Objectives

Base Conversion written by Cathy Saxton

Division of Mathematical Sciences

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

K80TTQ1EP-??,VO.L,XU0H5BY,_71ZVPKOE678_X,N2Y-8HI4VS,,6Z28DDW5N7ADY013

M.S. Computer Science Program

= = 3 4, Now assume that P (k) is true for some fixed k 2. This means that

BOOLEAN ALGEBRA & LOGIC GATES

1 Definition of a Turing machine

MACHINE ARCHITECTURE & LANGUAGE

Circuits and Boolean Expressions

FOREWORD. Executive Secretary

CHAPTER 7 GENERAL PROOF SYSTEMS

Zachary Monaco Georgia College Olympic Coloring: Go For The Gold

Testing LTL Formula Translation into Büchi Automata

Course Syllabus For Operations Management. Management Information Systems

Concepts of Database Management Seventh Edition. Chapter 9 Database Management Approaches

1.2 Solving a System of Linear Equations

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

1 Operational Semantics for While

İSTANBUL AYDIN UNIVERSITY

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

6 EXTENDING ALGEBRA. 6.0 Introduction. 6.1 The cubic equation. Objectives

Chapter 1. Computation theory

2) Write in detail the issues in the design of code generator.

Flowchart Techniques

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

Informatique Fondamentale IMA S8

CHAPTER 3. Methods of Proofs. 1. Logical Arguments and Formal Proofs

CONTENTS 1. Peter Kahn. Spring 2007

Computer Programming I & II*

Indiana State Core Curriculum Standards updated 2009 Algebra I

8051 MICROCONTROLLER COURSE

So let us begin our quest to find the holy grail of real analysis.

Sources: On the Web: Slides will be available on:

An Introduction to Assembly Programming with the ARM 32-bit Processor Family

ALGORITHMS AND FLOWCHARTS. By Miss Reham Tufail

In mathematics, there are four attainment targets: using and applying mathematics; number and algebra; shape, space and measures, and handling data.

Solving simultaneous equations using the inverse matrix

Computer Science/Mathematics Curriculum Pepperdine University

Rigorous Software Development CSCI-GA

Transcription:

CST.98.5.1 COMPUTER SCIENCE TRIPOS Part IB Wednesday 3 June 1998 1.30 to 4.30 Paper 5 Answer five questions. No more than two questions from any one section are to be answered. Submit the answers in five separate bundles, each with its own cover sheet. On each cover sheet, write the numbers of all attempted questions, and circle the number of the question attached. Write on one side of the paper only. SECTION A 1 Structured Hardware Design Describe individually or explain the differences between an FPGA (field programmable gate array) and a PAL (programmable array logic) device. [10 marks] Outline an implementation of a synchronous counter in both styles of programmable logic. What are the primary performance limitations when building large counters in each style of logic? 1 [TURN OVER

CST.98.5.2 2 Computer Design Early computers (and early microprocessors) were accumulator machines. RISC computers replaced the accumulator with a register file. (a) What is a register file and why is it preferable to an accumulator? Illustrate your answer by writing a loop to calculate factorial of 10 for an accumulator and a RISC processor (you may invent instruction sets and assume that a multiply instruction is available). [12 marks] (b) (c) Why is the Intel x86 processor family often referred to as being an extended accumulator machine? The Intel x86 LOOP instruction decrements the CX register and, if the result is not zero, jumps to a given label. Why is a compiler likely to find it hard to exploit this instruction, especially for nested loops? 3 Digital Communication I How can packet loss occur in a network? Outline a way in which packet loss can be reduced. Can it be eliminated completely? How does an ARQ system deal with packet loss? An ARQ implementation should keep as much data in transit as the receiver is willing to receive. Discuss. 2

CST.98.5.3 4 Computer Graphics and Image Processing Describe an algorithm for clipping a line against a rectangle. Show that it works using the above three examples. [9 marks] [3 marks] y 30 A' 2 A(0,1) B(0,0) 1 1 B'(3,2) 2 x The above diagram shows a complicated 2D transformation applied to a unit square. The overall transformation can be described in terms of a number of simpler transformations. Describe each of these simple transformations and give a matrix representation of each using homogeneous coordinates. Use the matrices from the previous part to find the (x, y) coordinates of point A, the image of point A under the overall transformation. [2 marks] 3 [TURN OVER

CST.98.5.4 SECTION B 5 Introduction to Security Some banks issue their Automatic Teller Machine (ATM) card customers with a randomly selected personal indentification number (PIN). Others issue their customers with an initial PIN only, and let the customers choose their own PIN the first time they use the card in an ATM. Describe the advantages and disadvantages of these approaches. Again, some banks compute the customer PIN by encrypting the account number using DES and a key known only to their central systems and ATMs, taking the first four hex digits of the result, replacing the digits A,..., F with 0,..., 5 respectively, and finally, if the first digit of the result is 0, replacing it with a 1. What is the probability that a criminal can get the PIN right given three guesses? Yet other banks have used DES, and a key known only to their central systems and ATMs, to encrypt the PIN (whether randomly generated or customer selected); they then write the result on the magnetic strip on the customer s card, so that the ATM can verify it without reference to the central system. Describe the disadvantages of this arrangement. In order to prevent attacks based on manipulating magnetic strips, banks in some countries have moved to using smart cards. What effect would you expect such a move to have on the incidence of card-based fraud? 4

CST.98.5.5 6 Compiler Construction Explain how a parse-tree representation of a program may be converted into a stack-based intermediate language giving sketches of code to translate expressions, assignments and the if-then-else command; you should also explain how occurrences of a variable in an expression or assignment are translated. The program may be assumed to conform to the following syntax: E -> n x E + E f(e,e) D -> let f(x,x) = {Dseq; Cseq; E} let x = E C -> x := E; if E then C else C Cseq -> C C Cseq Dseq -> D D Dseq with start symbol Dseq. Here n corresponds to integer constants, x corresponds to identifiers used as variable names and f corresponds to identifiers used as function names (you may assume these are disjoint). The function declaration construct has the effect of defining a function which, when called, makes declarations, performs commands and then returns the result of its expression; note that therefore functions may be defined within functions, but the above restriction on identifiers means that they cannot be returned as results. [20 marks] 7 Prolog for Artificial Intelligence Write Prolog programs that define the following predicates. Your programs should ensure that backtracking does not produce spurious alternative solutions. (a) The nth element of a list: nth(x,n,l) instantiates X to the Nth element of list L. Assume that list elements are numbered increasing from 1. (b) The last element of a list: last(x,l) instantiates X to the last element of list L. (c) Remove an element from a list: remove(x,l,m) instantiates M to a list containing all the elements of list L except for every occurrence of term X. (d) Substitute one element for another: subst(l,x,y,m) instantiates M to a list containing all the elements of list L except that every occurrence of term X in L is replaced by term Y in M. 5 [TURN OVER

CST.98.5.6 8 Databases The relational model of data was introduced in the early 1970s in a sequence of papers by E.F. Codd. This model proposes a tabular view of data, with a simple Data Manipulation Language (DML) based on relational algebra or relational calculus. Briefly explain the essential features of the model and its DML. Later work by Codd and others addressed weaknesses in the expressive power of the relational model. For each of the following give an example to show how the weakness arises, and explain an approach proposed to resolve the difficulty: (a) computing the transitive closure (b) manipulating collections of records (c) handling entity specialisation In case (c) you should outline the proposals of either the Object-Oriented Database System Manifesto or the Third Generation Database System Manifesto. SECTION C 9 Foundations of Functional Programming State the connection between the β-equality relation (= β ) and the β-reduction relation on λ-terms. Prove that = β is non-trivial, in the sense that there exist λ-terms M and N such that M β N. Compare the call-by-name and call-by-value reduction strategies, giving examples to illustrate that (a) sometimes the call-by-name strategy gives fewer reductions than the call-by-value strategy, and vice versa; (b) the call-by-name strategy terminates when the normal form exists, whereas the call-by-value strategy need not. Given the λ-term (λx.xi)(λy.(λz.zzzz)(yt)) where I is λu.u, display reduction paths arising from the call-by-name and call-by-value reduction strategies. Also, find the reduction path which consists of the fewest reduction steps and comment on your answer. [10 marks] 6

CST.98.5.7 10 Logic and Proof Construct an ordered binary decision diagram (OBDD) for the formula [(P Q) ( R Q)] R, showing each step carefully. What does the OBDD tell us about whether the formula is (a) valid, (b) satisfiable and (c) inconsistent? [10 marks] Attempt to prove the above formula using the sequent calculus until either it is proved or the proof cannot be continued. Design a method for determining whether a propositional formula is inconsistent. The method should work by examining the formula s disjunctive normal form. Demonstrate your method by applying it to the formula [(P Q) (Q P )]. 7 [TURN OVER

CST.98.5.8 11 Complexity Theory (a) Describe the problem 3-SAT. [2 marks] (b) (c) Show how any instance of the seemingly more general problem n-sat can be reduced to an equivalent one where each term has exactly three literals in it. Estimate how much larger the reduced problem would be than the original one. A certain computation using a non-deterministic Turing machine completes in T time-steps. The Turing machine has k states and uses an alphabet of N symbols. A major theorem underpinning the concept of NP-completeness is based on a conversion of a description of such computations to boolean formulae which characterise them. Explain how, in such a reduction, boolean variables may be used to describe states that the Turing machine might be in. Show how to derive those components of the boolean formula that relate just to the way in which the Turing machine moves its read write head. Your explanation should be sufficiently complete and carefully explained that it could be used as a specification of a program that would perform that part of the translation from Turing machine descriptions to boolean formulae. You should not attempt to explain the rest of the boolean formula or how it fits into a complete proof or program. [11 marks] (d) In terms of T, k and N, about how many symbols does it take to write the boolean expression you generate? [3 marks] 8

CST.98.5.9 12 Semantics of Programming Languages An abstract machine for evaluating closed terms of the untyped lambda calculus has configurations which are non-empty lists of closed terms. Its transitions are of two forms: ( app) ( abs) (M 1 M 2 ) :: L M 1 :: M 2 :: L λ x (M 1 ) :: M 2 :: L M 1 [M 2 /x] :: L where :: denotes list concatenation and M 1 [M 2 /x] denotes the result of substituting M 2 for all free occurrences of the variable x in M 1. Let be the binary relation between closed terms inductively defined by the following axioms and rules: ( abs ) ( app ) λ x (M) λ x (M) M 1 λ x (M 2 ) M 2 [M 3 /x] λ x (M 4 ). M 1 M 3 λ x (M 4 ) (a) Prove by Rule Induction that if M 1 λ x (M 2 ) holds, then so does M 1 :: L λ x M 2 :: L, where denotes the reflexive-transitive closure of the transition relation. (b) (c) Prove by Mathematical Induction on n that if (... ((M[M 0 /x] M 1 )M 2 )...)M n λ x (M ), then (... ((((λ x (M))M 0 )M 1 )M 2 )...)M n λ x (M ). Given a configuration M :: L, let M@L denote the closed term defined by induction on the length of the list L by: M@nil def = M and M@(M :: L) def = (M M )@L. Using (b), show by case analysis for that if M 1 :: L 1 M 2 :: L 2 and M 2 @L 2 λ x (M ) hold, then so does M 1 @L 1 λ x (M ). (d) Deduce from (a) and (c) that M 1 λ x (M 2 ) holds if and only if M 1 :: nil λ x (M 2 ) :: nil does. 9