Question: Suppose also that my faulty implementation of my faulty algorithm will give the proper output on all input. -- Does my program have a bug ?

The input/output function (the mapping from one set of values to another) is the mathematical definition of behavioural correctness of a program transformation. If your implementation (as stated) performs the transformation as specified, it is correct from a black box perspective.

Example:
A program with following i/O behaviour (i=>o mapping) performs a doubling finction on the integer range 1..4:
1=>2 2=>4 3=>6 4=>8
The following program performs the i/o transformation as specified; It is "black box correct".
# Faulty Algorithm: double int's in range [1..4] my %hDouble = (1=>'2', 2=>'4', 3=>'7', 4=>'8'); # Kinky Perl computation: assert (&& thus fix) algorithm for my $i (1..4) { my $o = $hDouble{$i}; $o-- if ($o%2 != 0); print $i . "=>" . $o . "\n"; }
Opening the box we can observe that the doubling algorithm (a lookup table) is flawed and the Perl code is unnecessarily complex and shaky. From a white box perspective the implementation is of poor quality : the bugs cancel out each other (from the black box perspective), but the code should definitely be cleaned up for better maintainability, robustness and efficiency.

That in a way brings us back to your Larry Wall quote: ...redundancy was absolutely necessary to achieve the goal of putting someone on the moon. Use pair programming, technical walkthroughs, reviews... any and all human redundancy to assure "white box quality" of the implementation (ie. to catch - among other things - bugs cancelling out each other as seen from a pure interface/black box view. And for certain systems (as rocket science): use hardware redundancy as well, because only relatively small applications can be mathematically proven to be even black box (I/O transformation) correct, much less white box so.

Allan

If a tree falls in a forest with no one to hear it, then does it make a sound?

In reply to Re: Feature or Bug ? by ady
in thread Feature or Bug ? by fbinard

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.