600.102: Foundations of Computer Science

Fall Semester 2005: September 8, 2005 - December 12, 2005

Assignment 5: Theory and Practice

Out on: October 24, 2005
Due by: October 30, 2005 by 5:59 pm for full credit (11:59 pm for 10% off, hard deadline)
Collaboration: None
Grading: Packaging 10%, Style 10%, Performance 10%, Design 10%, Functionality 60%

Overview

The fifth assignment for 600.102: Foundations of Computer Science covers material from Weeks 6 and 7 and the corresponding reading. This is a little longer than usual I think. Let me know if it is too long, then I'll make the next one shorter again. :-)

Problem 1: Finite Names

Sketch a finite automaton that accepts all your names: It should accept your first name, your last name, and any "middle names" or "nick names" you might have (and are willing to share). The "alphabet" of this finite automaton is obviously "the usual" English alphabet.

For example, the automaton I would have to design for myself should accept the strings Peter, Hans, and Froehlich but nothing else.

Please make sure to clearly mark initial state and final states! If you need "non-standard" characters, make them up. You don't have to show an explicit error state.

Problem 2: Binary Lambdas

In class we defined the encoding of true, false, and if into λ-calculus as follows:

I mentioned that we can also encode the usual and, or and not functions. Do exactly that: For each of those functions, derive an encoding into λ-calculus. Give your encodings as λ-expressions without abbreviations; reduce your λ-expressions as far as possible.

Please make sure to derive your encodings. Don't just "state" the encoding, show us step-by-step how you developed it. Also describe the overall idea you used to get to your encodings.

Problem 3: Pythonized Guessing

Remember the "Guess the Number" game from Assignment 4? You are going to write that game in Python now. Here is the description again:

Write a Python program guess.py that plays the (infamous) "Guess the Number" game. The "player" thinks of a number from 1 to 100, and your program "guesses" that number by asking a few questions:

Think of a number between 1 and 100.
Hit return when you're ready.

Is your number between 1 and 50? n
Is your number between 50 and 75? y
Is your number between 50 and 62? n
Is your number between 63 and 69?
...

And so on, eventually you print the number the "player" thought of (assuming he or she answers consistently of course). Actually, there are not too many questions left, but you're writing this, not me.

Small hint: You don't need functions for this. Of course you're free to use them anyway, but you're probably making things too complicated.

Problem 4: Random Python

Ready for another trip down memory lane? For Assignment 4 we provided this MIPS code to generate random numbers. Translate the algorithm we used there from MIPS into Python. When run, your program random.py should print the exact same numbers as random.s when run on the SPIM simulator.

Deliverables

Please turn in a gzip compressed tarball of your assignment (the extension should be .tar.gz). The tarball should uncompress into a directory cs102-assignment-5-login with login replaced by your Unix login name (so I would use cs102-assignment-5-phf); uncompressing should not create any other files in the current directory. Include a README file that briefly explains what your programs do and contains any other notes you want us to check out before grading (and of course your answers to "written" problems). This file should be a plain Unix text file (not M$ Word, not PDF); it should be formatted in a decent way and it should contain your contact information.

Grading

For reference, here is a short explanation of the grading criteria. Packaging refers to the proper organization of the stuff you hand in, following the guidelines for Deliverables above. Style refers to programming style, including things like consistent indentation, appropriate identifiers, useful comments, etc. Simple, clean, readable code is what you should be aiming for. Performance refers to how fast your program can produce the required results compared to other submissions. Design refers to proper modularization and the proper choice of algorithms and data structures. Functionality refers to your programs being able to do what they should according to the specification given above; if the specification is ambiguous and you had to make a certain choice, defend that choice in your README file.

If your programs do not run because of syntax errors you will get no points whatsoever. If your programs fail miserably, i.e. terminate with an exception of any kind, we will take off 10%.

Bonus Problem

There is no bonus problem for this assignment. I think you have enough to do as it is... :-)

Updated: $Id: assignment-5.html 75 2005-10-25 03:22:14Z phf $ Validate: XHTML CSS
Copyright © 2005 Peter H. Fröhlich. All rights reserved.