use of jkind.api.JKindApi in project AGREE by loonwerks.
the class PreferencesUtil method getConsistencyApi.
public static KindApi getConsistencyApi() {
KindApi api = getKindApi();
if (api instanceof JKindApi) {
IPreferenceStore prefs = getPreferenceStore();
int depth = prefs.getInt(PreferenceConstants.PREF_CONSIST_DEPTH) + 1;
((JKindApi) api).setN(depth);
((JKindApi) api).setPdrMax(0);
if (prefs.getBoolean(PreferenceConstants.PREF_SUPPORT)) {
((JKindApi) api).setIvcReduction();
}
}
return api;
}
use of jkind.api.JKindApi in project AMASE by loonwerks.
the class PreferencesUtil method getJKindApi.
private static JKindApi getJKindApi() {
IPreferenceStore prefs = getPreferenceStore();
JKindApi api = new JKindApi();
api.setJKindJar(getJKindJar());
try {
api.setEnvironment("Z3_HOME", Z3Plugin.getZ3Directory());
} catch (NoClassDefFoundError e) {
e.printStackTrace();
// Z3Plugin not present
} catch (Exception e) {
// Some unknown exception finding Z3
e.printStackTrace();
}
String solverString = prefs.getString(PreferenceConstants.PREF_SOLVER).toUpperCase().replaceAll(" ", "");
SolverOption solver = SolverOption.valueOf(solverString);
api.setSolver(solver);
if (prefs.getBoolean(PreferenceConstants.PREF_INDUCT_CEX)) {
api.setInductiveCounterexamples();
}
if (prefs.getBoolean(PreferenceConstants.PREF_SMOOTH_CEX) && solver == SolverOption.YICES) {
api.setSmoothCounterexamples();
}
if (prefs.getBoolean(PreferenceConstants.PREF_SUPPORT)) {
api.setIvcReduction();
}
api.setN(prefs.getInt(PreferenceConstants.PREF_DEPTH));
api.setTimeout(prefs.getInt(PreferenceConstants.PREF_TIMEOUT));
api.setPdrMax(prefs.getInt(PreferenceConstants.PREF_PDR_MAX));
// api.setPdrInvariants();
if (prefs.getBoolean(PreferenceConstants.PREF_NO_KINDUCTION)) {
api.disableKInduction();
}
return api;
}
use of jkind.api.JKindApi in project AMASE by loonwerks.
the class PreferencesUtil method getKindApi.
public static KindApi getKindApi() {
IPreferenceStore prefs = getPreferenceStore();
String modelChecker = prefs.getString(PreferenceConstants.PREF_MODEL_CHECKER);
String remoteUrl = prefs.getString(PreferenceConstants.PREF_REMOTE_URL);
KindApi api = getKindApi(modelChecker, remoteUrl);
if (prefs.getBoolean(PreferenceConstants.PREF_DEBUG)) {
api.setApiDebug();
}
if (api instanceof JKindApi) {
((JKindApi) api).setAllIvcs();
}
return api;
}
use of jkind.api.JKindApi in project AMASE by loonwerks.
the class FaultsVerifyAllHandler method doAnalysis.
@Override
protected IStatus doAnalysis(final Element root, final IProgressMonitor globalMonitor) {
Thread analysisThread = new Thread() {
@Override
public void run() {
// Record the analysis start time and get model hashcode for
// saving to property analysis log, if necessary
String modelHash = "";
long startTime = 0;
if (Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_PROP_LOG)) {
try {
modelHash = AgreeFileUtil.getModelHashcode(root);
startTime = System.currentTimeMillis();
} catch (Exception e) {
System.out.println(e.getMessage());
return;
}
}
activateTerminateHandlers(globalMonitor);
KindApi api = PreferencesUtil.getKindApi();
KindApi consistApi = PreferencesUtil.getConsistencyApi();
JRealizabilityApi realApi = PreferencesUtil.getJRealizabilityApi();
// Due to the way the queue is constructed in traversal,
// reversing the queue will result in subcomponent instances
// being analyzed prior to their enclosing component instance.
// Reverse the queue using a stack.
{
Stack<JKindResult> stack = new Stack<>();
while (!queue.isEmpty()) {
stack.push(queue.remove());
}
while (!stack.empty()) {
queue.add(stack.pop());
}
}
while (!queue.isEmpty() && !globalMonitor.isCanceled()) {
JKindResult result = queue.peek();
NullProgressMonitor subMonitor = new NullProgressMonitor();
monitorRef.set(subMonitor);
Program program = doFaultPropagationInjection(result, linker.getProgram(result));
linker.setProgram(result, program);
if (api instanceof JKindApi) {
String resultName = result.getName();
String adviceFileName = rerunAdviceMap.get(resultName);
if (adviceFileName == null) {
adviceFileName = "agree_advice" + adviceCount++;
rerunAdviceMap.put(resultName, adviceFileName);
} else {
((JKindApi) api).setReadAdviceFile(adviceFileName);
}
((JKindApi) api).setWriteAdviceFile(adviceFileName);
}
try {
if (result instanceof ConsistencyResult) {
consistApi.execute(program, result, subMonitor);
} else if (result instanceof JRealizabilityResult) {
realApi.execute(program, (JRealizabilityResult) result, subMonitor);
} else {
api.execute(program, result, subMonitor);
}
} catch (JKindException e) {
System.out.println("******** JKindException Text ********");
e.printStackTrace(System.out);
String errStr = e.getMessage();
int l = Math.min(errStr.length(), 300);
System.out.println(e.getMessage().substring(0, l));
break;
}
// Print to property analysis log, if necessary
if (Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_PROP_LOG)) {
AgreeFileUtil.printLog(result, startTime, modelHash);
}
queue.remove();
}
while (!queue.isEmpty()) {
queue.remove().cancel();
}
AddFaultsToAgree.resetStaticVars();
deactivateTerminateHandlers();
enableRerunHandler(root);
}
};
analysisThread.start();
return Status.OK_STATUS;
}
use of jkind.api.JKindApi in project AMASE by loonwerks.
the class PreferencesUtil method getConsistencyApi.
public static KindApi getConsistencyApi() {
KindApi api = getKindApi();
if (api instanceof JKindApi) {
IPreferenceStore prefs = getPreferenceStore();
int depth = prefs.getInt(PreferenceConstants.PREF_CONSIST_DEPTH) + 1;
((JKindApi) api).setN(depth);
((JKindApi) api).disableInvariantGeneration();
// ((JKindApi) api).disableKInduction();
((JKindApi) api).setPdrMax(0);
}
return api;
}
Aggregations