Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions 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.
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education