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

  Function declare that it can throw an ioexception

Every C++ function that performs file I/O will thus need to either declare that it can throw an IOException, or contain a try-catch-finally block to deal with it. Response?

  Write a program using vectors and iterators

Create a program that uses at least two functions that will be called from your main. This program is a number game program that asks for parts of your phone and after manipulating it mathematically, eventually outputs your entire phone number. The d..

  Inventory items stored in Sudbury

Give the details of all suppliers in the Sault Ste Marie, list all inventory items with a quantity less than 100 units and list all the inventory items stored in Sudbury

  Write a class volumeofbox that calculate the volume

write a class VolumeOfBox that calculate the volume by this formula : length * breadth *

  Write the code to exchange the values of these two variables

Write the code to exchange the values of these two variables (so that after the swap xp points to what yp originally pointed to and vice-versa.

  Execute the next line which is enter your last name

C++ in VS and I'm trying to run the following program. As soon as I put in my name after the 2nd cout statement, the program ends.

  Write a function that returns the day of the year

Write a function day_of_year(month, day, year) that returns the day of the year (an integer between 1 and 366) specified by the three augments.

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Lab9 c if you can start with attachments file first get

if you can start with attachments file first get that part then start with the lab 9 ltbrgtcmpet301lab9

  Evaluates the gross pay of a set of employees

Write a C program that will calculate the gross pay of a set of employees - determines both the overtime hours (anything over 40 hours) and the gross pay, and outputs

  Prepare a program that uses at least two functions that can

prepare a program that uses at least two functions that can be called from your main. this program is a number game

  Program to print out invalid number to character

The integer must contain 3 distinct non-zero number, or the program will print out invalid number.it should print out invalid query.

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