24.04.2013 Views

Verification of Parameterised FPGA Circuit Descriptions with Layout ...

Verification of Parameterised FPGA Circuit Descriptions with Layout ...

Verification of Parameterised FPGA Circuit Descriptions with Layout ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 4. VERIFYING CIRCUIT LAYOUTS 77<br />

consts<br />

maxf :: "(int∗int∗(int⇒ int))⇒ int"<br />

recdef maxf "measure (λ(b, t, f). nat(t+1−b))"<br />

"maxf (bot, top, fun) = (if (top < bot) then 0<br />

else (<br />

case (top = bot) <strong>of</strong> True ⇒ fun top<br />

| False ⇒ (<br />

let one = fun top in<br />

let two = maxf (bot, top − 1, fun) in<br />

max one two)))"<br />

consts<br />

sum :: "(int∗int∗(int⇒ int))⇒ int"<br />

recdef sum "measure (λ(b, t, f). nat(t+1−b))"<br />

"sum (bot, top, fun) = (<br />

case (top < bot) <strong>of</strong> True ⇒ 0<br />

| False ⇒ sum (bot, top − 1, fun) + (fun top))"<br />

Figure 4.6: Definitions <strong>of</strong> the Quartz sum and maxf functions in Quartz<strong>Layout</strong><br />

Theorem 11 is particularly useful since we are <strong>of</strong>ten confronted <strong>with</strong> expressions <strong>of</strong> this form<br />

where a, b and c are size functions for various blocks. Using this theorem we can simplify<br />

the logical proposition substantially, since we will prove that 0 ≤ x for all size expressions x<br />

as a matter <strong>of</strong> course and can use these theorems in other pro<strong>of</strong>s.<br />

While Isabelle/HOL already includes definitions <strong>of</strong> max and if, we have to define the complex<br />

functions maxf and sum. The definitions <strong>of</strong> these functions from theory Functions can be<br />

seen in Figure 4.6. These definitions have the same semantics as the appropriate clauses <strong>of</strong><br />

the semantic function for Quartz expressions Eσ β µ given on page 42.<br />

The functions are defined using the recdef method <strong>of</strong> declaring arbitrary recursive functions.<br />

The measure functions allow Isabelle/HOL to prove termination <strong>of</strong> the functions by showing<br />

that the supplied measure decreases for each recursive call. We use “case” rather than “if”<br />

expressions <strong>with</strong>in the functions to avoid problems <strong>with</strong> the use <strong>of</strong> Isabelle’s simplifier where<br />

conditionals are repeatedly split, leading to a loop. Besides this, the two function identically<br />

and the equivalence between the two can be proved easily (see theorem maxf expand if in<br />

Appendix B.7 for such a pro<strong>of</strong> for the maxf function).<br />

We prove the correctness <strong>of</strong> the maxf function, showing that it implements a logical definition:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!