• Home
  • Queen's University
  • Software Specifications
  • Formal Verification and Assertions in Software Specifications

Formal Verification and Assertions in Software Specifications

CISC 223 - Assignment 7 (Winter 2014) Due: beginning of class (3:30 PM), Wednesday March 19 1. (2 marks) Here A is an array of integers. Give assertions involving universal and/or existential quantification which formalize the following properties concerning the array segment A[0:n-1]: (a) The entries in the segment A[0:n-1] are in strictly increasing order. (b) Every entry in the segment A[0: n-1] occurs more than once. 2. (4 marks) Verify the validity of the following correctness statements by adding all the intermediate assertions, that is, give the proof tableau showing the validity of the cor- rectness statement. All variables are of type int. Also state any mathematical facts used. (a) ASSERT( x == x0 && z >= 1 ) y = x+1; X = X+Z; ASSERT ( y >= x0 && x >= y ) (b) ASSERT ( true ) if (x >= y) x = y - 1; else y = y + 1; ASSERT ( x < y ) 3. (4 marks) Verify the below code using the suggested invariant. That is, give a complete proof tableau by adding all the intermediate assertions. Also make an argument for termination. ASSERT (num >= 0 && den > 0) quot = 0; rem = num; while (rem >= den) INVAR( num == quot * den + rem && 0 <= rem && 0 < den) { rem = rem - den; quot++; } ASSERT( num == quot * den + rem && 0 <= rem < den) Note: This is Exercise 3.12 in the textbook and a discussion of the code appears on page 69. Regulations on assignments . The assignments may be done in groups consisting of one, two, three or four students. If more than one students are collaborating on an assignment, they must submit a single joint solution. . Clearly print (or type) the name(s) and student number(s), and course number, at the top of the first page. Additionally each student collaborating on an assignment must sign the top of the first page. . If the submission consists of more than one page, the pages must be stapled together. . Note: You are asked to write your solutions using non-erasable pen (or to type the solutions). Solutions written in pencil or erasable ink will be marked, but they will not be considered for remarking after the assignments are returned.