The University of Waikato
Department of Computer Science Dr. Robi Malik
COMP 340-07B
Reasoning about Programs
Assignment 4
As a first step towards verification of the Euclidean Algorithm, we have to verify several properties of integer multiplication and division.
This assignment is to be done using the RISC ProofNavigator, which is installed in the Linux labs. Please download the theory file comp340-ass4.pn from the COMP 340-07B course home page,
http://cs.waikato.ac.nz/~robi/comp340-07b/
and use it for the following exercises.
Exercise 1
(1+1+1+1+2+2+1+1+2+1 marks) Given the axioms(MULTzero1) ∀x: 0·x= 0
(MULTsucc) ∀x: , y: (x+ 1)·y=x·y+y prove the following properties of integer multiplication.
a) (MULT1a) ∀x: 1·x=x b) (MULT1b) ∀x: x·1 =x
Hint. This and several of the following properties are proven by induction onx.
c) (MULTzero2) ∀x: x·0 =x
d) (MULTdist) ∀x: , y: , z: (x+y)·z =x·z+y·z e) (MULTassoc) ∀x: , y: , z: x·(y·z) = (x·y)·z f) (MULTcomm) ∀x: , y: x·y=y·x
Hint. The inductive step is proven by induction on y and requires careful planning.
g) (MULTinv0) ∀x: , y: (x·y = 0→x= 0∨y= 0)
Hint. This and the following properties at some stage require to establish that the result of multiplying two non-negative integers, e.g.a0·b0, is a non-negative integer.
This information can be introduced into the proof using the typeaxiom command as follows,
typeaxiom a 0,b 0 in mult;
h) (MULTmon0) ∀x: , y: , z: (x≥y→x·z ≥y·z) Hint. Prove this using clever instantiation of (MULTdist).
i) (MULTmon1) ∀x: , y: , z: (z 6= 0∧x·z ≥y·z → x≥y) j) (MULTmon2) ∀x: , y: (x6= 0→x·y≥y)
Exercise 2
(7 marks)Using the properties of multiplication from exercise 1, and given the definition of the
“divides” relation for non-negative integers,
(DIV) ∀x: , y: (x|y ↔ ∃n: y =n·x) prove the following properties.
Hint. Thedividespredicate is completely defined and can be expanded using the expand command.
a) (DIV0) ∀x: x|0
b) (DIV1) ∀x: 1|x
c) (DIVself) ∀x: x|x
d) (DIVplus) ∀x: , y: , z: (x|y∧x|z → x|(y+z))
e) (DIVminus) ∀x: , y: , z: (x|y∧x|z∧y≥z → x|(y−z)) f) (DIVtrans) ∀x: , y: , z: (x|y∧y|z → x|z)
g) (DIVless) ∀x: , y: (y6= 0∧x|y→x≤y)
Submission
The RISC ProofNavigator will save your proofs in a directory calledcomp340-ass4. Please pack this directory into a .tar.gz archive using the command
tar czf comp340-ass4.tar.gz comp340-ass4 and submit the archive through the assignment submission system at
http://byerley.cs.waikato.ac.nz/~tonym/submit/
before the due date. Please note that the assignment submission system works only from our computing laboratories on campus.
Due date: Tuesday, 14th August 2007, 15:00