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. SOURCE CODE OF EXPERIMENTS<br />
acc2.Add(c1)<br />
merge(n1−1, n2, l1, l2, t1, t2, acc1, acc2)<br />
else<br />
if c2 0 then<br />
acc1.Add(v2)<br />
acc2.Add(c2)<br />
merge(n1, n2−1, l1, l2, t1, t2, acc1, acc2)<br />
let (++) (t1: Term) (t2:Term) =<br />
let l1 = t1.vars.Length<br />
let l2 = t2.vars.Length<br />
let acc1 = new ResizeArray(l1 + l2)<br />
let acc2 = new ResizeArray(l1 + l2)<br />
merge(l1, l2, l1, l2, t1, t2, acc1, acc2)<br />
Term(t1.constant + t2.constant, acc1.ToArray(), acc2.ToArray())<br />
let (~~) (t: Term) =<br />
Term(−t.constant, t.vars, Array.map (fun c −> −c) t.coeffs)<br />
let (−−) t1 t2 = t1 ++ ( ~~ t2)<br />
let (∗∗)a (t: Term) =<br />
if a =0then Zero<br />
elif a =1then t<br />
else<br />
Term(a∗t.constant, t.vars, Array.map (fun c −> a∗c) t.coeffs)<br />
let (∗/∗)(t: Term) a =<br />
if a =0then <strong>in</strong>validArg "Term" "Division␣by␣zero"<br />
elif a =1then t<br />
else<br />
Term(t.constant/a, t.vars, Array.map (fun c −> c/a) t.coeffs)<br />
let rec f<strong>in</strong>dIndex f xs i =<br />
if i >= Array.length xs then −1<br />
elif fxs.[i] then i<br />
else f<strong>in</strong>dIndex f xs (i+1)<br />
// F<strong>in</strong>d coefficient of variable x <strong>in</strong> term t<br />
let f<strong>in</strong>dCoeff (t: Term, x) =<br />
try<br />
let i = Array.f<strong>in</strong>dIndex (fun v −> v = x) t.vars<br />
t.coeffs.[i]<br />
with<br />
|:?System.Collections.Generic.KeyNotFoundException −> 0<br />
// Filter out variable x <strong>in</strong> term t<br />
let filterOut (t: Term, x): Term =<br />
74