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
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
2.4. IMPLEMENTATION AND EXAMPLES 25<br />
The simplified list <strong>of</strong> verification conditions is:<br />
T rue, T rue,<br />
a ≠ 0 =⇒ ( x 12 = (− b a ) ⇒ (a ∗ x 12 + b = 0) ) ∧<br />
(a ≠ 0 =⇒<br />
(<br />
(a ∗ x12 + b = 0) ⇒ x 12 = (− b a )) )<br />
2.4.3 Solving Second Degree Equations<br />
1. Program[”SecondDegreeSolver-calling-FirstDegreeSolver”,SDS[↓ a,↓ b,↓ c],<br />
2. Module[{delta ,sqrtDelta,x1,x2,sol},<br />
3. If[a==0,<br />
4. sol := FDS[b,c]; Return[sol],<br />
4. delta :=(b*b)-(4*a*c);<br />
5. If[delta =0,<br />
6. x1 := -(b/(2*a));x2:=x1,<br />
7. If[delta > 0,<br />
8. sqrtDelta:=Sqrt[delta]; x1 := (-b+sqrtDelta)/(2*a); x2 := (-b-sqrtDelta)/(2*a),<br />
9. sqrtDelta := Sqrt[-delta ]; x1 := (-b-(i*sqrtDelta))/(2*a); x2:= (-b+(i*sqrtDelta))/(2*a)]];<br />
10. sol:={x1, x2};Return[sol]]],<br />
11. Pre ← T rue,<br />
12. Post ← ∀((x ∈ y) ⇐⇒ (a ∗ x 2 + b ∗ x + c = 0))<br />
x<br />
We display the verification conditions after simplification.<br />
T rue,<br />
(<br />
(x ∗ 1 = F DS[b, c]) ⇒ (b ∗ x ∗ 1 + c = 0) ∧ )<br />
(b ∗ x ∗ 1 + c = 0) ⇒ (x ∗ 1 = F DS[b, c]) =⇒<br />
(<br />
(x 4 = F DS[b, c]) ⇒ (b ∗ x 4 + c = 0) ∧ )<br />
(b ∗ x 4 + c = 0) ⇒ (x 4 = F DS[b, c]) ,<br />
T rue, T rue, T rue, T rue, T rue, T rue, T rue,<br />
(<br />
a ≠ 0 ∧ (b ∗ b − 4 ∗ a ∗ c = 0) =⇒ (a ∗ x 2 5 + b ∗ x 5 + c = 0) ⇒ (x 5 = − b<br />
2 ∗ a )∨<br />
((a ∗ x 2 5 + b ∗ x 5 + c = 0) ⇒ (x 5 = −<br />
b<br />
2 ∗ a )) ∧ (((x 5 = − b<br />
2 ∗ a )) ⇒ (a ∗ x2 5 + b ∗ x 5 + c = 0))∨<br />
((x 5 = (−<br />
b<br />
)<br />
2 ∗ a )) ⇒ (a ∗ x2 5 + b ∗ x 5 + c = 0)) ,<br />
a ≠ 0 ∧ b ∗ b − 4 ∗ a ∗ c > 0 ∧ (−b ∗ b) + 4 ∗ a ∗ c > 0 =⇒ b ∗ b − 4 ∗ a ∗ c ≥ 0,<br />
T rue, T rue, T rue, T rue, T rue, T rue, T rue, T rue, T rue,<br />
a ≠ 0 ∧ b ∗ b − 4 ∗ a ∗ c > 0 ∧ (−b ∗ b) + 4 ∗ a ∗ c > 0 =⇒<br />
(x 6 = (−b) + (√ b ∗ b − 4 ∗ a ∗ c)<br />
2 ∗ a<br />
(<br />
(((a ∗ x 2 6 + b ∗ x 6 + c = 0) ⇒<br />
)) ∨ ((a ∗ x 2 6 + b ∗ x 6 + c = 0) ⇒ (x 6 = (−b) − (√ b ∗ b − 4 ∗ a ∗ c)<br />
))) ∧<br />
2 ∗ a<br />
(((x 6 = (−b) + (√ b ∗ b − 4 ∗ a ∗ c)<br />
) ⇒ (a ∗ x 2 6 + b ∗ x 6 + c = 0))∨<br />
2 ∗ a<br />
)<br />
((x 6 = (−b) − (√ b ∗ b − 4 ∗ a ∗ c)<br />
) ⇒ (a ∗ x 2 6 + b ∗ x 6 + c = 0)))<br />
2 ∗ a<br />
,