Skip to content

Commit

Permalink
Precisely track base case results in k-induction engine
Browse files Browse the repository at this point in the history
  • Loading branch information
agacek committed Apr 18, 2015
1 parent 1ad2c6e commit feec105
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions jkind/src/jkind/engines/KInductionEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import static java.util.stream.Collectors.toList;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import jkind.JKindSettings;
import jkind.engines.invariant.InvariantSet;
Expand Down Expand Up @@ -33,6 +35,7 @@ public class KInductionEngine extends SolverBasedEngine {
private int kCurrent = 0;
private int kLimit = 0;
private InvariantSet invariants = new InvariantSet();
private Map<Integer, List<String>> baseStepValid = new HashMap<>();

public KInductionEngine(Specification spec, JKindSettings settings, Director director) {
super(NAME, spec, settings, director);
Expand All @@ -44,6 +47,7 @@ public void main() {
for (kCurrent = 0; kCurrent <= settings.n; kCurrent++) {
comment("K = " + kCurrent);
processMessagesAndWait();
pruneUnknownProperties(kCurrent);
createVariables(kCurrent);
assertTransitionAndInvariants(kCurrent);
checkProperties(kCurrent);
Expand All @@ -58,6 +62,25 @@ private void processMessagesAndWait() {
processMessagesAndWaitUntil(() -> kCurrent <= kLimit);
}

private void pruneUnknownProperties(int kCurrent) {
List<String> bmcValid = baseStepValid.remove(kCurrent);
if (bmcValid == null) {
return;
}

List<String> unknown = difference(properties, bmcValid);
properties.removeAll(unknown);
if (!unknown.isEmpty()) {
sendUnknown(unknown);
}
}

private List<String> difference(List<String> list1, List<String> list2) {
List<String> result = new ArrayList<>(list1);
result.removeAll(list2);
return result;
}

private void checkProperties(int k) {
List<String> possiblyValid = new ArrayList<>(properties);

Expand Down Expand Up @@ -137,17 +160,7 @@ private void sendUnknown(List<String> unknown) {
@Override
protected void handleMessage(BaseStepMessage bsm) {
kLimit = bsm.step;

List<String> unknown = difference(properties, bsm.properties);
if (!unknown.isEmpty()) {
sendUnknown(unknown);
}
}

private List<String> difference(List<String> list1, List<String> list2) {
List<String> result = new ArrayList<>(list1);
result.removeAll(list2);
return result;
baseStepValid.put(bsm.step, bsm.properties);
}

@Override
Expand Down

0 comments on commit feec105

Please sign in to comment.