Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

HW1: Annotated commands Program Correctness (2023) Deadline: February 20, 9h 1

Instructions - Read carefully

ˆ This homework comprises three mandatory questions (1.1 –1.3, for which you can get up to
90 points) and one bonus question (1.4 – for which you can get up to extra 20 points).
ˆ The use of the LATEX template for homeworks (available in Brightspace) is mandatory.
You will get up to 10 points if you appropriately use this template to produce a PDF.
ˆ The grade is the number of points obtained divided by 10, with a maximum of 10.

ˆ Submit your solutions in PDF using Brightspace.


Late submissions and submissions that do not follow the LATEX template will not be accepted.

Mandatory Questions

Exercise 1.1 (25 points)


Consider the following command:

x := 2 · x; y := 2 · x; x := y − x;

Determine a post-regular specification for this command and write down its annotated proof.
Exercise 1.2 (25 points)
Determine an annotated command S that satisfies:

{P : x = 2 · y + 3 · X ∧ y = Y }
S
{Q : x = 2 · y + 3 · X ∧ y = 2 · Y }

Exercise 1.3 (40 points)


(a) (20 points) Determine an annotated command T that satisfies:
{P : (x mod 2 = 1 ∧ x = X + 1) ∨ (x mod 2 = 0 ∧ x = 3 · X)}
T
{Q : x = X}
(b) (20 points) Determine an annotated command S that satisfies:
{P : x = X}
S
{Q : x mod 2 = 0 ∧ (x = X + 1 ∨ x = 3 · X)}

Bonus Question

Exercise 1.4 (20 points (bonus))


Is there a program T that satisfies the following specification? Argue for your answer.

{P : x = X ∨ y = Y }
T
{Q : x = Y ∧ y = X}

You might also like