-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathVerificationRunResult.cs
More file actions
68 lines (63 loc) · 2.5 KB
/
VerificationRunResult.cs
File metadata and controls
68 lines (63 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Boogie;
using Microsoft.Boogie.SMTLib;
namespace VC
{
public record VerificationRunResult
(
int VcNum,
int Iteration,
DateTime StartTime,
SolverOutcome Outcome,
TimeSpan RunTime,
int MaxCounterExamples,
List<Counterexample> CounterExamples,
List<AssertCmd> Asserts,
IEnumerable<TrackedNodeComponent> CoveredElements,
int ResourceCount,
int SmtInputSize,
SolverKind? SolverUsed
) {
public void ComputePerAssertOutcomes(out Dictionary<AssertCmd, SolverOutcome> perAssertOutcome,
out Dictionary<AssertCmd, Counterexample> perAssertCounterExamples) {
perAssertOutcome = new();
perAssertCounterExamples = new();
if (Outcome == SolverOutcome.Valid) {
perAssertOutcome = Asserts.ToDictionary(cmd => cmd, _ => SolverOutcome.Valid);
} else {
foreach (var counterExample in CounterExamples) {
AssertCmd underlyingAssert;
if (counterExample is AssertCounterexample assertCounterexample) {
underlyingAssert = assertCounterexample.FailingAssert;
} else if (counterExample is CallCounterexample callCounterexample) {
underlyingAssert = callCounterexample.FailingAssert;
} else if (counterExample is ReturnCounterexample returnCounterexample) {
underlyingAssert = returnCounterexample.FailingAssert;
} else {
continue;
}
// We ensure that the underlyingAssert is among the original asserts
if (!Asserts.Contains(underlyingAssert)) {
continue;
}
perAssertOutcome.TryAdd(underlyingAssert, SolverOutcome.Invalid);
perAssertCounterExamples.TryAdd(underlyingAssert, counterExample);
}
var remainingOutcome =
Outcome == SolverOutcome.Invalid && CounterExamples.Count < MaxCounterExamples
// We could not extract more counterexamples, remaining assertions are thus valid
? SolverOutcome.Valid
: Outcome == SolverOutcome.Invalid
// We reached the maximum number of counterexamples, we can't infer anything for the remaining assertions
? SolverOutcome.Undetermined
// TimeOut, OutOfMemory, OutOfResource, Undetermined for a single split also applies to assertions
: Outcome;
foreach (var assert in Asserts) {
perAssertOutcome.TryAdd(assert, remainingOutcome);
}
}
}
}
}