1. Verify the validity of the following correctness statements by adding all the intermediate assertions and so producing the proof tableau. State all the mathematical facts used. All variables are of type int. ASSERT (x == x0) int sign -1; if (x >= 0) sign = 13 x = x * sign; ASSERT (abs (x) == abs(x0) && x >= 0) abs(x) refers to the absolute value of x. This is surprisingly tricky for such a small and obviously correct code fragment, but still it is very satisfying to try it out on your own, so stop here and attempt it. If on the other hand you need a few hints, then read on. Hints: The tricky part is the missing else branch, which will force you to keep strengthening the post-condition until you find something that will match what you get from the then branch. The problem with this is that sign is free floating there, so you will need to strengthen its range. sign >= 0 is sufficient to infer the negated loop condition but is not enough. Do not be afraid to further restrict the range as much as you want; if it works to the end then you are all set, and if it does not work then you can always come back and modify the range.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

question 1

1. Verify the validity of the following correctness statements by adding all the intermediate
assertions and so producing the proof tableau. State all the mathematical facts used. All
variables are of type int.
ASSERT (x
==
x0)
int sign
-1;
if (x >= 0) sign
= 13
x = x * sign;
ASSERT (abs (x)
==
abs(x0) && x >= 0)
abs(x) refers to the absolute value of x. This is surprisingly tricky for such a small and
obviously correct code fragment, but still it is very satisfying to try it out on your own, so
stop here and attempt it. If on the other hand you need a few hints, then read on.
Hints: The tricky part is the missing else branch, which will force you to keep strengthening
the post-condition until you find something that will match what you get from the then
branch. The problem with this is that sign is free floating there, so you will need to strengthen
its range. sign >= 0 is sufficient to infer the negated loop condition but is not enough. Do
not be afraid to further restrict the range as much as you want; if it works to the end then you
are all set, and if it does not work then you can always come back and modify the range.
Transcribed Image Text:1. Verify the validity of the following correctness statements by adding all the intermediate assertions and so producing the proof tableau. State all the mathematical facts used. All variables are of type int. ASSERT (x == x0) int sign -1; if (x >= 0) sign = 13 x = x * sign; ASSERT (abs (x) == abs(x0) && x >= 0) abs(x) refers to the absolute value of x. This is surprisingly tricky for such a small and obviously correct code fragment, but still it is very satisfying to try it out on your own, so stop here and attempt it. If on the other hand you need a few hints, then read on. Hints: The tricky part is the missing else branch, which will force you to keep strengthening the post-condition until you find something that will match what you get from the then branch. The problem with this is that sign is free floating there, so you will need to strengthen its range. sign >= 0 is sufficient to infer the negated loop condition but is not enough. Do not be afraid to further restrict the range as much as you want; if it works to the end then you are all set, and if it does not work then you can always come back and modify the range.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education