CIS301 Exercise Set 1

10 points. Due Saturday, February 1
Please do your own work --- whatever you submit must be stored in your brain as well as in your computer files.

Question 1. Type your answer in a .txt file named Q1.txt:
For this circuit,


(a) Write the proposition (linear representation) that this circuit depicts.
(b) Write the proposition's complete truth table. Use the values t and f. (Not 0 and 1 --- we are moving into symbolic logic, where propositions are true or false.)

Show the values of all the internal subexpressions of the proposition as well as the value of the overall proposition, like it's done in the lecture notes, Chapter 0. (The truth table will have 4 rows --- fill in all the columns for all the logical operators for all 4 rows.)

(c) Say that the circuit will be embedded on a chip where the P wire always gets value f. Write a different proposition that mentions only Q that has the same behavior as the original. (Hint: use the truth table you wrote in (b) to discover the new proposition.)

For the remaining exercises, do your work with the CIS301 proof checker, using the checker's v (verbose) option, as demo-ed in class and as described in the Beginner's Guide, http://www.cis.ksu.edu/~schmidt/301s14/cis301/howtocheck.html.

IMPORTANT: As in all other posted examples and exercises, I have used blank spaces only to indent the code lines. Please be careful not to mix tabs and blanks in your indentations!

Question 2. Prove the assertion stated at the last line of the program. Place your solution in the file, Q2.py, and check it with the checker, generating the file, Q2A.py.htm.

# Q2.py
x = readInt()
y = x * 2
z = x + 1
x = x - 1
# prove:  x + z == y

Question 3. Do the same here as in Question 2, with the file named Q3.py:

# Q3.py
x = readInt()
assert x > 0
a = x * 2
x = x + 1
# prove:  a >= x  and  a > 0

Question 4. Do the same, but with Q4.py:

# Q4.py
money = readInt()
withdraw = readInt()
assert money >= 0 and withdraw <= money
m = money
money = money - withdraw
# prove:   money >= 0  and  withdraw + money == m

How to submit your assignment on K-State Online

Please make a folder and place in it the following: Then, zip the folder and submit the zipped folder to the CIS301 page at K-State online. Please be certain to upload the zipped folder and then press the SUBMIT button. You must receive a confirmation in your web browser that says you submitted your assignment --- if you don't see the confirmation, try again and try to figure out what you forgot to do.

Bring your work with you to class on the 31st, so that we can review it on the board.