Automated Formal Static Analysis and Retrieval of Source Code - JKU
Automated Formal Static Analysis and Retrieval of Source Code - JKU
Automated Formal Static Analysis and Retrieval of Source Code - JKU
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
2.4. IMPLEMENTATION AND EXAMPLES 21<br />
We present in the following the sequence <strong>of</strong> transformations after the logical <strong>and</strong> algebraic<br />
simplifications:<br />
n ≥ 0 ⇒ (1 = x 0 )<br />
n > 0 ⇒ (x = x 1 )<br />
T rue, T rue<br />
n > 0 ∧ (Mod[n, 2] = 0) ∧ n − 1 > 0 ∧ (−n) + 1 > 0 ⇒ n ≥ 0<br />
n > 0 ∧ (Mod[n, 2] = 0) ∧ n − 1 > 0 ∧ (−n) + 1 > 0 ⇒ ((x 2 ) n 2 = x n )<br />
T rue, T rue, T rue<br />
n > 0 ∧ Mod[n, 2] ≠ 0 ∧ n − 1 > 0 ∧ (−n) + 1 > 0 ⇒ n − 1 ≥ 0<br />
T rue<br />
n > 0 ∧ Mod[n, 2] ≠ 0 ∧ n − 1 > 0 ∧ (−n) + 1 > 0 ⇒ (x ∗ (x 2 ) n−1<br />
2 = x n )<br />
In this version, the verification conditions are written in the Theorema version (quoted formulae).<br />
We transformed them into the Mathematica syntax <strong>and</strong> apply the built-in FullSimplify,<br />
we reduced them to the truth constant T rue, one for each formula. With a special list simplification<br />
rule, we reduced them to one truth constant T rue.<br />
In the next sections, we exemplify the features <strong>of</strong> the verification conditions generator <strong>and</strong><br />
formulae simplifier on three small programs. We have chosen them in order to distinguish the<br />
features <strong>of</strong> the system.<br />
2.4 Implementation <strong>and</strong> Examples<br />
The prototype environment (called FwdVCG) which follows the theoretical basis presented in<br />
Section 2.2 is built on top <strong>of</strong> the computer algebra system Mathematica <strong>and</strong> uses the existing<br />
Theorema environment for imperative program verification which supposes that:<br />
• the programs are considered procedures with input parameters <strong>and</strong> m<strong>and</strong>atory return values<br />
(output parameters);<br />
• expressions are Theorema boolean <strong>and</strong> arithmetic expressions;<br />
• the specification <strong>and</strong> the program are identified by specific comm<strong>and</strong>s: Pre, Post <strong>and</strong><br />
Program respectively.<br />
The verification conditions generator takes as input a program together with its specification<br />
<strong>and</strong> generates the corresponding pro<strong>of</strong> obligations which arise from its analysis.<br />
For specifying a program in the Theorema system we use the comm<strong>and</strong> Program <strong>and</strong> for<br />
writing the specification, the keywords Pre, Post. All these constructs <strong>and</strong> also the syntax <strong>of</strong><br />
the imperative programs is based on [Kir99].