Solution to the naur text-processing problem

Assignment Help C/C++ Programming
Reference no: EM13670847

Design and implement a solution to the Naur text-processing problem using the language specified by your instructor. Execute it against test data and record the number of faults you find and the cause of each fault (e.g., logic fault, loop counter fault). Do not correct any of the faults you detect. So you goal is to just detect the faults, not to correct them.

An important aspect of correctness proofs is that they should be done in conjunction with design and coding. As Dijkstra put it, "The programmer should let the program proof and program grow hand in hand" [Dijkstra, 1972]. For example, when a loop is incorporated into the design, a loop invariant is put forward; and as the design is refined stepwise, so is the invariant. Developing a product in this way gives the programmer confidence that the product is correct and tends to reduce the number of faults. Quoting Dijkstra again, "The only effective way to raise the confidence level of a program significantly is to give a convincing proof of its correctness" [Dijkstra, 1972]. But even if a product is proven to be correct, it must be thoroughly tested as well. To illustrate the necessity for testing in conjunction with correctness proving, consider the following.

In 1969, Naur reported on a technique for constructing and proving a product correct [Naur, 1969]. The technique was illustrated by what Naur termed a line-editing problem; today this would be considered a text-processing problem. It may be stated as follows: Given a text consisting of words separated by blank characters or by newline (new line) characters, convert it to line-by-line form in accordance with the following rules:

1. Line breaks must be made only where the given text contains a blank or newline;

2. Each line is filled as far as possible, as long as

3. No line will contain more than maxpos characters.

Naur constructed a procedure using his technique and informally proved its correctness. The procedure consisted of approximately 25 lines of code. The paper then was reviewed by Leavenworth in Computing Reviews [Leavenworth, 1970]. The reviewer pointed out that, in the output of Naur's procedure, the first word of the first line is preceded by a blank unless the first word is exactly maxpos characters long.

Although this may seem a trivial fault, it is a fault that surely would have been detected had the procedure been tested, that is, executed with test data rather than only proven correct. But worse was to come. London [1971] detected three additional faults in Naur's procedure. One is that the procedure does not terminate unless a word longer than maxpos characters is encountered. Again, this fault is likely to have been detected if the procedure had been tested. London then presented a corrected version of the procedure and proved formally that the resulting procedure was correct; recall that Naur had used only informal proof techniques.

The next episode in this saga is that Good enough and Gerhart [1975] found three faults that London had not detected, despite his formal "proof." These included the fact that the last word is not output unless it is followed by a blank or newline. Yet again, a reasonable choice of test data would have detected this fault without much difficulty. In fact, of the total of seven faults collectively detected by Leavenworth, London, and Good enough and Gerhart, four could have been detected simply by running the procedure on test data, such as the illustrations given in Naur's original paper. The lesson from this saga is clear. Even if a product has been proven correct, it still must be tested thoroughly.

Reference no: EM13670847

Questions Cloud

Determine what total force is exerted on the object : A small object with mass 5.00 kilogram moves counterclockwise with constant speed 5.50 m/s in a circle of radius 3.00 meter centered at the origin. Determine what total force is exerted on the object
Find what the speed of the ball as it strikes the ground : A 0.17 kilogram baseball is launched from the roof of a building15 meter above the ground. Find the speed of the ball as it strikes the ground
Find what is the output voltage of the array : A modded Prius electric car is powered by sixty lithium-iron-phosphate batteries. At a freeway speed of 108 km/h, the average frictional force on the vehicle is only 200 Newton. find what is the output voltage of the array
Draw a venn diagram : Draw a Venn diagram. If a person is chosen at random from the group, what is the probability that the person does not own a microwave, a computer or a DVD player?
Solution to the naur text-processing problem : Design and implement a solution to the Naur text-processing problem using the language specified by your instructor. Execute it against test data and record the number of faults you find and the cause of each fault
Compute what the magnitude of the force : A force in the +y direction applied at the point x=2.3 meter, y=1.4 meter gives rise to a torque of 66 N•m about the origin. Estimate what the magnitude of the force
Obtain the change in speed of the object : A constant force of magnitude of 8.0 Newton is exerted for 4.0 s on a 16 kilogram object initially at rest. Obtain the change in speed of the object
Determine the acceleration of the automobile : A 9000 Newton automobile is pushed along a level road by four students who apply a total forward force of magnitude 500 Newton. determine the acceleration of the automobile
Evaluate what is the new angular speed of the sphere : A 1.4 kilogram 15 centimeter diameter solid sphere is rotating about its diameter at 70 rev/min. If an additional 5.0 mJ of energy are added to the kinetic energy, evaluate what is the new angular speed of the sphere

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a program which has a base process which communicates

write a program which has a base process which communicates with child processes acting as bombers that it

  Write and test a function to calculate the sum of the series

stop accumulating the sum when the term to add or subtract becomes smaller than a given small number(precision) oassed as an argument.

  Pros and cons of choosing two servers

Classify the two alternatives in terms of what type of application architecture they use. b. Outline the pros and cons of the two alternatives and make a recommendation to Fred about which is better.

  Program on basic arithmetic operation

Two integers must be compared before the arithmetic operation and Subtract the two integers provided the first integer is greater than the second integer, otherwise add the two integers and subtract the second integer from the first integer.

  Need c++ solution to cover the final stage of euro 2012

From Group Fase to elimination fases, it´s not the user who defines teams, because that must be made automatically according to classification in group fase - considering regulations.

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

  Lab-1the goal of this lab is to better familiarize you with

lab-1the goal of this lab is to better familiarize you with polymorphism and the factory design pattern two key

  That takes the time as six integer arguments

Write a C function seconds_since_jan1() that takes the time as six integer arguments (year, month, day, hour, minute, and second) and returns the number of seconds since the beginning of the year.

  Problems on oops

Problems on OOPS

  What do the loops print

What do the following loops print? Work out the answer by tracing the code, not by using the computer. a. int s = 1; for (int n = 1; n

  1 design and implement a c program for the given

1. design and implement a c program for the given specification.2. show a structure diagram for your program using the

  A store with a bag of groceries

write C++ statements that remove all the items from storeBag and place them into one of two new bags, as follows: Place all occurrences of bread and eggs into fragileBag, and all other items into groceryBag. When you are done, storeBag should be empt..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd