use of de.bmoth.modelchecker.ModelCheckingResult in project bmoth by hhu-stups.
the class Issue59Test method testIssue59WithAdditionalInvariant.
@Test
public void testIssue59WithAdditionalInvariant() {
String machine = "MACHINE SimpleMachine\n";
machine += "VARIABLES x\n";
machine += "INVARIANT x : INTEGER &\n";
machine += "\tx**2 = x*x &\n";
machine += "\t#x.(x:INTEGER & {x} \\/ {1,2} = {1,2})\n";
machine += "INITIALISATION x := -3\n";
machine += "OPERATIONS\n";
machine += "\tIncX = SELECT x < 50 THEN x := x+1 END\n";
machine += "END";
ModelCheckingResult result = new ExplicitStateModelChecker(parseMachine(machine)).check();
assertEquals(true, result.isCorrect());
}
use of de.bmoth.modelchecker.ModelCheckingResult in project bmoth by hhu-stups.
the class Issue66Test method testMachine.
@Test
public void testMachine() throws IOException {
MachineNode theMachine = parseMachineFromFile(dir + "LargeExponent.mch");
ModelCheckingResult result = ExplicitStateModelChecker.check(theMachine);
assertEquals(false, result.isCorrect());
}
use of de.bmoth.modelchecker.ModelCheckingResult in project bmoth by hhu-stups.
the class ExplicitStateModelChecker method doModelCheck.
@Override
protected ModelCheckingResult doModelCheck() {
final int maxInitialStates = BMothPreferences.getIntPreference(BMothPreferences.IntPreference.MAX_INITIAL_STATE);
final int maxTransitions = BMothPreferences.getIntPreference(BMothPreferences.IntPreference.MAX_TRANSITIONS);
stateSpace = new StateSpace();
visited = new HashSet<>();
Queue<State> queue = new LinkedList<>();
// prepare initial states
BoolExpr initialValueConstraint = getMachineTranslator().getInitialValueConstraint();
Set<Model> models = finder.findSolutions(initialValueConstraint, maxInitialStates);
models.stream().map(this::getStateFromModel).filter(this::isUnknown).forEach(root -> {
stateSpace.addRootVertex(root);
queue.add(root);
});
final BoolExpr invariant = getMachineTranslator().getInvariantConstraint();
solver.add(invariant);
// create joint operations constraint and permanently add to separate
// solver
final BoolExpr operationsConstraint = getMachineTranslator().getCombinedOperationConstraint();
opSolver.add(operationsConstraint);
while (!isAborted() && !queue.isEmpty()) {
solver.push();
State current = queue.poll();
visited.add(current);
// apply current state - remains stored in solver for loop iteration
BoolExpr stateConstraint = current.getStateConstraint(getContext());
solver.add(stateConstraint);
// check invariant & state
Status check = solver.check();
switch(check) {
case UNKNOWN:
return createUnknown(visited.size(), solver.getReasonUnknown());
case UNSATISFIABLE:
return createCounterExampleFound(visited.size(), current, stateSpace);
case SATISFIABLE:
default:
}
// compute successors on separate finder
models = opFinder.findSolutions(stateConstraint, maxTransitions);
models.stream().map(this::getStateFromModel).forEach(successor -> {
if (isUnknown(successor)) {
stateSpace.addVertex(successor);
queue.add(successor);
}
stateSpace.addEdge(current, successor);
});
solver.pop();
}
if (isAborted()) {
return createAborted(visited.size());
} else {
ModelCheckingResult resultVerified = createVerified(visited.size(), stateSpace);
if (buechiAutomaton != null) {
// do ltl model check
labelStateSpace();
List<List<State>> cycles = new TarjanSimpleCycles<>(stateSpace).findSimpleCycles();
for (List<State> cycle : cycles) {
// if there is an accepting Buechi state in the cycle, a counterexample is found
for (State state : cycle) {
if (buechiAutomaton.isAcceptingSet(state.getBuechiNodes())) {
return createLTLCounterExampleFound(visited.size(), state);
}
}
}
}
return resultVerified;
}
}
Aggregations