The program is shown on the simulator below:
Memory Cells |
---|
Program Counter | Time |
---|---|
0 | 0 |
We are given the program instructions and the PC at time 0. We use this information to make claims about the program's state at time 1. For example:
- Since the PC is 0 at time 0 and instruction #0 is an ADDI instruction, at time 1, PC is 1.
- Since the PC is 0 at time 0 and instruction #0 is
addi dst=3 src=0 imm=3
, at time 1, memory cell #3 becomes 3.
Then we use the claims about time 1 to prove claims about time 2, and so on. Eventually, at time 14, we prove that memory cell #5 stores 21 and the program terminates.
Quiz (1 point)
addi dst=3 src=0 imm=3
addi dst=4 src=0 imm=0
addi dst=5 src=0 imm=0
addi dst=5 src=5 imm=7
addi dst=4 src=4 imm=1
beq left=3 right=4 imm=1
jump imm=3
if the following are true:
- instruction #0 is
addi dst=3 src=0 imm=3
- the PC at time 0 = 0
then value of cell 3 at time 1 = 3
- instruction #0 is
if the following are true:
- instruction #0 is
addi dst=3 src=0 imm=3
- the PC at time 0 = 0
then the PC at time 1 = 1
- instruction #0 is
if the following are true:
- instruction #1 is
addi dst=4 src=0 imm=0
- the PC at time 1 = 1
then value of cell 4 at time 2 = 0
- instruction #1 is
if the following are true:
- instruction #1 is
addi dst=4 src=0 imm=0
- the PC at time 1 = 1
then the PC at time 2 = 2
- instruction #1 is
if the following are true:
- instruction #1 is
addi dst=4 src=0 imm=0
- the PC at time 1 = 1
- value of cell 3 at time 1 = 3
then value of cell 3 at time 2 = 3
- instruction #1 is
if the following are true:
- instruction #2 is
addi dst=5 src=0 imm=0
- the PC at time 2 = 2
then value of cell 5 at time 3 = 0
- instruction #2 is
if the following are true:
- instruction #2 is
addi dst=5 src=0 imm=0
- the PC at time 2 = 2
then the PC at time 3 = 3
- instruction #2 is
if the following are true:
- instruction #2 is
addi dst=5 src=0 imm=0
- the PC at time 2 = 2
- value of cell 3 at time 2 = 3
then value of cell 3 at time 3 = 3
- instruction #2 is
if the following are true:
- instruction #2 is
addi dst=5 src=0 imm=0
- the PC at time 2 = 2
- value of cell 4 at time 2 = 0
then value of cell 4 at time 3 = 0
- instruction #2 is
if the following are true:
- instruction #3 is
addi dst=5 src=5 imm=7
- the PC at time 3 = 3
- value of cell 5 at time 3 = 0
then value of cell 5 at time 4 = 7
- instruction #3 is
if the following are true:
- instruction #3 is
addi dst=5 src=5 imm=7
- the PC at time 3 = 3
then the PC at time 4 = 4
- instruction #3 is
if the following are true:
- instruction #3 is
addi dst=5 src=5 imm=7
- the PC at time 3 = 3
- value of cell 3 at time 3 = 3
then value of cell 3 at time 4 = 3
- instruction #3 is
if the following are true:
- instruction #3 is
addi dst=5 src=5 imm=7
- the PC at time 3 = 3
- value of cell 4 at time 3 = 0
then value of cell 4 at time 4 = 0
- instruction #3 is
if the following are true:
- instruction #4 is
addi dst=4 src=4 imm=1
- the PC at time 4 = 4
- value of cell 4 at time 4 = 0
then value of cell 4 at time 5 = 1
- instruction #4 is
if the following are true:
- instruction #4 is
addi dst=4 src=4 imm=1
- the PC at time 4 = 4
then the PC at time 5 = 5
- instruction #4 is
if the following are true:
- instruction #4 is
addi dst=4 src=4 imm=1
- the PC at time 4 = 4
- value of cell 3 at time 4 = 3
then value of cell 3 at time 5 = 3
- instruction #4 is
if the following are true:
- instruction #4 is
addi dst=4 src=4 imm=1
- the PC at time 4 = 4
- value of cell 5 at time 4 = 7
then value of cell 5 at time 5 = 7
- instruction #4 is
if the following are true:
- instruction #5 is
beq left=3 right=4 imm=1
- the PC at time 5 = 5
- value of cell 3 at time 5 = 3
- value of cell 4 at time 5 = 1
then the PC at time 6 = 6
- instruction #5 is
if the following are true:
- instruction #5 is
beq left=3 right=4 imm=1
- the PC at time 5 = 5
- value of cell 3 at time 5 = 3
then value of cell 3 at time 6 = 3
- instruction #5 is
if the following are true:
- instruction #5 is
beq left=3 right=4 imm=1
- the PC at time 5 = 5
- value of cell 4 at time 5 = 1
then value of cell 4 at time 6 = 1
- instruction #5 is
if the following are true:
- instruction #5 is
beq left=3 right=4 imm=1
- the PC at time 5 = 5
- value of cell 5 at time 5 = 7
then value of cell 5 at time 6 = 7
- instruction #5 is
if the following are true:
- instruction #6 is
jump imm=3
- the PC at time 6 = 6
then the PC at time 7 = 3
- instruction #6 is
if the following are true:
- instruction #6 is
jump imm=3
- the PC at time 6 = 6
- value of cell 3 at time 6 = 3
then value of cell 3 at time 7 = 3
- instruction #6 is
if the following are true:
- instruction #6 is
jump imm=3
- the PC at time 6 = 6
- value of cell 4 at time 6 = 1
then value of cell 4 at time 7 = 1
- instruction #6 is
if the following are true:
- instruction #6 is
jump imm=3
- the PC at time 6 = 6
- value of cell 5 at time 6 = 7
then value of cell 5 at time 7 = 7
- instruction #6 is
if the following are true:
- instruction #3 is
addi dst=5 src=5 imm=7
- the PC at time 7 = 3
- value of cell 5 at time 7 = 7
then value of cell 5 at time 8 = 14
- instruction #3 is
if the following are true:
- instruction #3 is
addi dst=5 src=5 imm=7
- the PC at time 7 = 3
then the PC at time 8 = 4
- instruction #3 is
if the following are true:
- instruction #3 is
addi dst=5 src=5 imm=7
- the PC at time 7 = 3
- value of cell 3 at time 7 = 3
then value of cell 3 at time 8 = 3
- instruction #3 is
if the following are true:
- instruction #3 is
addi dst=5 src=5 imm=7
- the PC at time 7 = 3
- value of cell 4 at time 7 = 1
then value of cell 4 at time 8 = 1
- instruction #3 is
if the following are true:
- instruction #4 is
addi dst=4 src=4 imm=1
- the PC at time 8 = 4
- value of cell 4 at time 8 = 1
then value of cell 4 at time 9 = 2
- instruction #4 is
if the following are true:
- instruction #4 is
addi dst=4 src=4 imm=1
- the PC at time 8 = 4
then the PC at time 9 = 5
- instruction #4 is
if the following are true:
- instruction #4 is
addi dst=4 src=4 imm=1
- the PC at time 8 = 4
- value of cell 3 at time 8 = 3
then value of cell 3 at time 9 = 3
- instruction #4 is
if the following are true:
- instruction #4 is
addi dst=4 src=4 imm=1
- the PC at time 8 = 4
- value of cell 5 at time 8 = 14
then value of cell 5 at time 9 = 14
- instruction #4 is
if the following are true:
- instruction #5 is
beq left=3 right=4 imm=1
- the PC at time 9 = 5
- value of cell 3 at time 9 = 3
- value of cell 4 at time 9 = 2
then the PC at time 10 = 6
- instruction #5 is
if the following are true:
- instruction #5 is
beq left=3 right=4 imm=1
- the PC at time 9 = 5
- value of cell 3 at time 9 = 3
then value of cell 3 at time 10 = 3
- instruction #5 is
if the following are true:
- instruction #5 is
beq left=3 right=4 imm=1
- the PC at time 9 = 5
- value of cell 4 at time 9 = 2
then value of cell 4 at time 10 = 2
- instruction #5 is
if the following are true:
- instruction #5 is
beq left=3 right=4 imm=1
- the PC at time 9 = 5
- value of cell 5 at time 9 = 14
then value of cell 5 at time 10 = 14
- instruction #5 is
if the following are true:
- instruction #6 is
jump imm=3
- the PC at time 10 = 6
then the PC at time 11 = 3
- instruction #6 is
if the following are true:
- instruction #6 is
jump imm=3
- the PC at time 10 = 6
- value of cell 3 at time 10 = 3
then value of cell 3 at time 11 = 3
- instruction #6 is
if the following are true:
- instruction #6 is
jump imm=3
- the PC at time 10 = 6
- value of cell 4 at time 10 = 2
then value of cell 4 at time 11 = 2
- instruction #6 is
if the following are true:
- instruction #6 is
jump imm=3
- the PC at time 10 = 6
- value of cell 5 at time 10 = 14
then value of cell 5 at time 11 = 14
- instruction #6 is
if the following are true:
- instruction #3 is
addi dst=5 src=5 imm=7
- the PC at time 11 = 3
- value of cell 5 at time 11 = 14
then value of cell 5 at time 12 = 21
- instruction #3 is
if the following are true:
- instruction #3 is
addi dst=5 src=5 imm=7
- the PC at time 11 = 3
then the PC at time 12 = 4
- instruction #3 is
if the following are true:
- instruction #3 is
addi dst=5 src=5 imm=7
- the PC at time 11 = 3
- value of cell 3 at time 11 = 3
then value of cell 3 at time 12 = 3
- instruction #3 is
if the following are true:
- instruction #3 is
addi dst=5 src=5 imm=7
- the PC at time 11 = 3
- value of cell 4 at time 11 = 2
then value of cell 4 at time 12 = 2
- instruction #3 is
if the following are true:
- instruction #4 is
addi dst=4 src=4 imm=1
- the PC at time 12 = 4
- value of cell 4 at time 12 = 2
then value of cell 4 at time 13 = 3
- instruction #4 is
if the following are true:
- instruction #4 is
addi dst=4 src=4 imm=1
- the PC at time 12 = 4
then the PC at time 13 = 5
- instruction #4 is
if the following are true:
- instruction #4 is
addi dst=4 src=4 imm=1
- the PC at time 12 = 4
- value of cell 3 at time 12 = 3
then value of cell 3 at time 13 = 3
- instruction #4 is
if the following are true:
- instruction #4 is
addi dst=4 src=4 imm=1
- the PC at time 12 = 4
- value of cell 5 at time 12 = 21
then value of cell 5 at time 13 = 21
- instruction #4 is
if the following are true:
- instruction #5 is
beq left=3 right=4 imm=1
- the PC at time 13 = 5
- value of cell 3 at time 13 = 3
- value of cell 4 at time 13 = 3
then the PC at time 14 = 7
- instruction #5 is
if the following are true:
- instruction #5 is
beq left=3 right=4 imm=1
- the PC at time 13 = 5
- value of cell 3 at time 13 = 3
then value of cell 3 at time 14 = 3
- instruction #5 is
if the following are true:
- instruction #5 is
beq left=3 right=4 imm=1
- the PC at time 13 = 5
- value of cell 4 at time 13 = 3
then value of cell 4 at time 14 = 3
- instruction #5 is
if the following are true:
- instruction #5 is
beq left=3 right=4 imm=1
- the PC at time 13 = 5
- value of cell 5 at time 13 = 21
then value of cell 5 at time 14 = 21
- instruction #5 is
Please write your proof in the table below. Each row should contain one claim. The last claim is the statement that you are trying to prove.