Skip to content

Commit

Permalink
#210, rework smtlib2 Horn clause parsing: convert to CNF first (keepi…
Browse files Browse the repository at this point in the history
…ng the Boolean structure of interpreted parts intact), then generate horn clauses
  • Loading branch information
alexandernutz committed May 25, 2018
1 parent 48c7898 commit 247d629
Show file tree
Hide file tree
Showing 5 changed files with 299 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public String toString() {
}

// return mTransitionFormula.getFormula().toString();
return mFormula.toString();
return mFormula.toStringDirect();
// return String.format("(%s) ^^ (%s) ~~> (%s) || in : %s || out : %s ",
// cobody, mTransitionFormula, body,
// return String.format("(%s) ^^ (%s) ~~> (%s)", cobody,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ private void processFile(final File file) throws IOException {
final ConstructAndInitializeBackendSmtSolver caibss =
new HCGBuilderHelper.ConstructAndInitializeBackendSmtSolver(mServices, mStorage,
"treeAutomizerSolver");
script = new HornClauseParserScript(file.getName(), caibss.getScript(), caibss.getLogicForExternalSolver(),
caibss.getSolverSettings());
script = new HornClauseParserScript(mServices, file.getName(), caibss.getScript(),
caibss.getLogicForExternalSolver(), caibss.getSolverSettings());
} else {
if (useExternalSolver) {
mLogger.info("Starting external SMT solver with command " + commandExternalSolver);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ public HornClauseBody(final HornClauseParserScript script) {
mParserScript = script;
}

/***
* Copy constructor
*/
public HornClauseBody(final HornClauseBody original) {
mCobody = new HornClauseCobody(original.mCobody);
mParserScript = original.mParserScript;
}

/***
* Add literal to the cobody.
* @param literal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public class HornClauseCobody {

private boolean mFinalized = false;

private final List<HornClausePredicateSymbol> mPredicateSymbols = new ArrayList<>();
private final List<List<TermVariable>> mPredicateSymbolToVariables = new ArrayList<>();
private final List<HornClausePredicateSymbol> mPredicateSymbols;
private final List<List<TermVariable>> mPredicateSymbolToVariables;

private final HornClauseParserScript mParserScript;

Expand All @@ -68,10 +68,27 @@ public class HornClauseCobody {
*/
public HornClauseCobody(final HornClauseParserScript parserScript) {
mPredicates = new ArrayList<>();
mPredicateSymbols = new ArrayList<>();
mPredicateSymbolToVariables = new ArrayList<>();
mTransitions = new HashSet<>();
mParserScript = parserScript;
}

/**
*
* @param original
*/
public HornClauseCobody(final HornClauseCobody original) {
mPredicates = new ArrayList<>(original.mPredicates);
mPredicateSymbols = new ArrayList<>(original.mPredicateSymbols);
mPredicateSymbolToVariables = new ArrayList<>();
for (final List<TermVariable> l : original.mPredicateSymbolToVariables) {
mPredicateSymbolToVariables.add(new ArrayList<>(l));
}
mTransitions = new HashSet<>(original.mTransitions);
mParserScript = original.mParserScript;
}

/***
* Add a literal predicate to the cobody.
* @param literal
Expand Down Expand Up @@ -171,8 +188,8 @@ private void computePredicates(final HCSymbolTable symbolTable) {
final List<TermVariable> parameterTermVariables = Arrays.asList(pred.getParameters()).stream()
.map(t -> (TermVariable) t)
.collect(Collectors.toList());
assert parameterTermVariables.size() == new HashSet<>(parameterTermVariables).size() : "TODO: eliminate "
+ "duplicate arguments";
// assert parameterTermVariables.size() == new HashSet<>(parameterTermVariables).size() : "TODO: eliminate "
// + "duplicate arguments";
final List<TermVariable> bodyVars = parameterTermVariables;
mPredicateSymbolToVariables.add(bodyVars);
}
Expand Down
Loading

0 comments on commit 247d629

Please sign in to comment.