3.2 Empirical Study
In this section, we conduct an empirical experimen-
tation using c++ language of the examples presented
in the previous section and some others examples that
have been presented in (Benabdelali et al., 2018). To
implement the specifications, we use the concept of
test oracle that checks the programs reliability thresh-
old according to specification R. Therefore, in all ex-
amples implementations, our test oracle always con-
tains the c ++ code source of our specifications. We
define a general format, which we instantiate it for
each example to calculate the reliability of programs
with respect to given specification:
typedef struct {int n, x, y;}state;
state sinitial;state sfinal;
//--------------------------------------------
bool domR (state sinitial)
{ }// domain of specification
//--------------------------------------------
bool R (state sinitial, state sfinal)
{ }// specification
//--------------------------------------------
bool oracle (state sinitial, state sfinal)
{ }//oracle of correctness with respect to R
//--------------------------------------------
state p1(int n)
{ }// The candidates programs p1, p2, p3, etc...
//--------------------------------------------
int randomgeneration(int n)
{}//random generator
//--------------------------------------------
void tesdriver(int testdatasize)
{int counters1=0;int counters2=0;..//initialize
for(int testindex=1; testindex <= testdatasize;
++testindex){sinitial.n=randomgeneration(10000);
....}// run the test oracle on our programs
std::cout << "reliability of p1 : " <<
(counters1/static_cast<double>(testdatasize))
<< std::endl;
std::cout << "reliability of p2 : " <<
(counters2/static_cast<double>(testdatasize))
<< std::endl;
....}// check the reliability of each program
int main(){tesdriver();}
// run the tesdriver function n number times
So, for each experimentation, we just instantiate
domR, R and oracle, redefine our variables, and of
course write the programs. we define a test driver and
a random test data generator. Then we apply each test
driver to the programs generated in the corresponding
derivation. We take the example of Fermat Decompo-
sition, we generate 4 000 random numbers (as a test
data size) between 1 and 10 000. For each random
number, we execute the programs P
0
, P
1
, P
2
, P
3
and
we see which satisfies the specification R (with the or-
acle test that translates the specification R). For each
random number, if the program is correct with respect
to R, the program counter is incremented and at the
end (until we finished the generation of 4000 random
number) the counter sum of each program is divided
on test data size. As a result, for each program we
obtain a probability that will be the reliability thresh-
old according to R. Table 2 summarizes the reliability
results of the examples that we have used for the pro-
gram derivation based relative correctness.
The results obtained in each example, shows that
the reliability evolves from one program to another.
We start from a program abort that never runs suc-
cessfully since, it always gives 0 for reliability with
respect to R(it’s useless to mention it in the table),
and we enhance the transforation until we reach a cor-
rect program, or a sufficiently reliable program. Note
when we obtain reliability percentage strictly greater
than 0 and strictly less than 1 the program is partially
correct with respect to R. Furthermore, in the program
derivation process by correctness enhancement, de-
riving a reliable program follows the same process as
deriving a correct program, except that the derivation
terminates as soon as the required reliability thresh-
old matches or exceeds the selected threshold. Ac-
cording to the programs reliability results obtained in
each example, we argue that for most software prod-
ucts, as for products in general, absolute correctness
is not necessary; often, a high reliability threshold is
sufficient. This could greatly reduce the development
costs and complexity.
3.3 Towards a Mechanism for Program
Derivation Process
In the previous sections and with samples examples,
we have realized a proof of concept regarding the
program derivation process using relative correctness.
We have showed that when going from P
i
to P
i+1
we
improved the reliability of the latter according to the
specification R and we end the derivation where the
desired level of reliability has been achieved and/or
when we attain program correctness. However, un-
til there, we have reasoned as if the programs that
we have derived are at our disposal in some way or
other. Therefore, the objective of this section is to
find a mechanism that helps and guides the developer
in his program derivation process. So, we propose
three possible attempts.
3.3.1 Different Possible Scenarios
The various examples presented above and in (Ben-
abdelali et al., 2018), lead us to conclude that we can
use the program derivation process using relative cor-
rectness in at least four scenarios that will show how
Deriving Programs by Reliability Enhancement
215