Presburger Arithmetic and Its Use in Verification
Presburger Arithmetic and Its Use in Verification
Presburger Arithmetic and Its Use in Verification
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Appendix B<br />
Source code of experiments<br />
B.1 Utilities.fs<br />
module Utilities<br />
open System<br />
open System.Thread<strong>in</strong>g.Tasks<br />
open System.Collections.Concurrent<br />
type System.Thread<strong>in</strong>g.Tasks.Task with<br />
static member WaitAll(ts) =<br />
Task.WaitAll [| for t <strong>in</strong> ts −> t :> Task |]<br />
let (%|)ab=(b % a =0)<br />
let rec gcd(l1, l2) =<br />
if l2 =0then l1 else gcd(l2, l1 % l2)<br />
// Calculate gcd of a list of postive <strong>in</strong>teger.<br />
// Rewrite to use tail recursion.<br />
let gcds ls =<br />
let rec recGcds ls res =<br />
match ls with<br />
|[]−> res<br />
| l::ls’ −> recGcds ls’ (gcd(res, abs(l)))<br />
match ls with<br />
|[]−> 1<br />
|[l]−> abs(l)<br />
| l::ls’ −> recGcds ls’ l<br />
let gcda ls =<br />
Array.fold(fun acc l −> gcd(abs(l), acc)) 1 ls<br />
let lcm(l1, l2) =<br />
(l1 / gcd(l1, l2)) ∗ l2<br />
71