25.11.2014 Aufrufe

Verifikation reaktiver Systeme - Universität Kaiserslautern

Verifikation reaktiver Systeme - Universität Kaiserslautern

Verifikation reaktiver Systeme - Universität Kaiserslautern

MEHR ANZEIGEN
WENIGER ANZEIGEN

Sie wollen auch ein ePaper? Erhöhen Sie die Reichweite Ihrer Titel.

YUMPU macht aus Druck-PDFs automatisch weboptimierte ePaper, die Google liebt.

230<br />

To complete the proof of the parity checking device, the two parts of the<br />

verification are finally combined:<br />

(* goal is ‘‘!inp out. PARITY_IMP(inp,out) ==> !t. out t = PARITY t inp‘‘ *)<br />

e(RW_TAC std_ss []);<br />

e(MATCH_MP_TAC UNIQUELESS_LEMMA);<br />

e(PROVE_TAC[PARITY_LEMMA]);<br />

val PARITY_CORRECT = top_thm();<br />

Certainly, this examples does not need a theorem prover in order to be verified.<br />

Due to the small number of states and the lack of arithmetic components,<br />

other verification methods would be more appropriate. But, it shows the basics<br />

needed to do theorem proving, whereas the next example shows the power of<br />

the theorem proving method.<br />

3.2 Binary Greatest Common Divisor<br />

The binary method to determine the greatest common divisor of two numbers<br />

has been discovered by Roland Silver and John Terzian in 1962. They have<br />

never published it, but soon, the method became well known in computer science<br />

[8]. It only needs three operations: shifting, subtraction and testing whether a<br />

number is odd or even. Other, more complicated operations (like division) are<br />

not required. Therefore, it is primarily suited to binary arithmetic. It is based<br />

on the following three facts:<br />

– If u is even, and v is even: gcd(u, v) =2· gcd( u/2 ,v/2)<br />

– If u is even, and v is odd: gcd(u, v) =gcd(u/2 ,v)<br />

– If u is greater than v: gcd(u, v) =gcd(u − v, v)<br />

Figure 4 shows a schematic that implements the algorithm: Initially, the<br />

registers x and y store the input values. Like the Euclidean algorithm, the gcd<br />

is calculated in several steps. In each step, one of the three facts mentioned<br />

above are used. To verify this component, two things should be shown: First,<br />

the result should be eventually computed, and this value should be really the<br />

greatest common divisor of the inputs. While the first point is obvious (Consider<br />

the sum u+v as variant.), the partial correctness can be shown using the following<br />

invariant:<br />

– Invariant: Letu and v be the numbers whose greatest common divisor is<br />

calculated, and let x, y and k be the values of the respective registers. In<br />

each step, gcd(u, v) =gcd(x, y) · 2 k holds.<br />

(* BGCD_EVEN_EVEN |- !x y. EVEN x /\ EVEN y<br />

==> (gcd x y = 2*gcd (x DIV 2) (y DIV 2)) *)<br />

(* BGCD_EVEN_ODD |- !x y. EVEN x /\ ODD y<br />

==> (gcd x y = gcd (x DIV 2) y) *)<br />

(* BGCD_ODD_EVEN |- !x y. ODD x /\ EVEN y<br />

==> (gcd x y = gcd x (y DIV 2)) *)

Hurra! Ihre Datei wurde hochgeladen und ist bereit für die Veröffentlichung.

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!