29.04.2014 Views

Presburger Arithmetic and Its Use in Verification

Presburger Arithmetic and Its Use in Verification

Presburger Arithmetic and Its Use in Verification

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.

APPENDIX B. SOURCE CODE OF EXPERIMENTS<br />

else <strong>in</strong>validArg "evalFormula" (str<strong>in</strong>g xts)<br />

| And fs −> if List.exists (fun f −> evalFormula xts f = FF) fs then FF else TT<br />

| Or fs −> if List.exists (fun f −> evalFormula xts f = TT) fs then TT else FF<br />

| Not f −> match evalFormula xts f with<br />

| TT −> FF<br />

| FF −> TT<br />

| f’ −> <strong>in</strong>validArg "evalFormula" (str<strong>in</strong>g xts)<br />

| TT −> TT<br />

| FF −> FF<br />

| _ −> <strong>in</strong>validArg "evalFormula" (str<strong>in</strong>g xts)<br />

/// Partition functions<br />

let partitionEval groundVal rangeArray formula =<br />

let len = Array.length rangeArray<br />

let loopResult = Parallel.For(0, len, fun i (loopState: ParallelLoopState) −><br />

if evalFormula rangeArray.[i] formula =<br />

groundVal then<br />

loopState.Stop()<br />

else<br />

()<br />

)<br />

not (loopResult.IsCompleted || loopResult.LowestBreakIteration.HasValue)<br />

// Break the array to balance chunks<br />

let partitionBalanceEval groundVal rangeArray formula =<br />

let len = Array.length rangeArray<br />

let source =[|0..len−1|]<br />

let partitions = Partitioner.Create(source, true)<br />

let loopResult = Parallel.ForEach(partitions, fun i (loopState:<br />

ParallelLoopState) −><br />

if evalFormula rangeArray<br />

.[i] formula =<br />

groundVal then<br />

loopState.Stop()<br />

else<br />

()<br />

)<br />

not (loopResult.IsCompleted || loopResult.LowestBreakIteration.HasValue)<br />

// Sequential<br />

let seqEval groundVal rangeArray formula = rangeArray |> Array.exists(fun r −><br />

evalFormula r formula = groundVal)<br />

let evalSAnd vr formula =<br />

if vr =[]then formula<br />

else<br />

if seqEval FF (genRangeArray vr) formula then FF else TT<br />

84

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

Saved successfully!

Ooh no, something went wrong!