Skip to content

Commit

Permalink
bootstrap a problem from a file of constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
yanntm committed Jun 5, 2024
1 parent a21ceed commit 894a42f
Showing 1 changed file with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package fr.lip6.move.gal.structural.smt;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;

Expand All @@ -26,6 +28,7 @@ public class Problem {

private CandidateSolution solution = new CandidateSolution();
private boolean isEF;
private String smtFile;

public Problem(String name, boolean isEF, Expression pred) {
this.name = name;
Expand All @@ -45,6 +48,17 @@ public Problem(String name, boolean isEF, Expression pred) {
definition = declareBoolFunc(symbol, smt);
}

public Problem(String name, String smtFile, ISymbol symbol, VarSet support) {
this.name = name;
this.symbol = symbol;
this.predicate = null;
this.support = support;
this.definition = null;
this.refinedSymbol = null;
this.isEF = true;
this.smtFile = smtFile;
}

public static ICommand declareBoolFunc(ISymbol name, IExpr body) {
IFactory ef = SMT.instance.smtConfig.exprFactory;
org.smtlib.ISort.IApplication bools = SMT.instance.smtConfig.sortFactory.createSortExpression(ef.symbol("Bool"));
Expand All @@ -69,8 +83,21 @@ public void refineDefinition(IExpr additionalConstraint, SolverState solver) {

public boolean declareProblem(SolverState solver) {
solver.declareVars(support);
IResponse response = definition.execute(solver.getSolver());
return response.isOK();
if (definition == null) {
if (smtFile != null) {
try {
return solver.getSolver().readFile(new File(smtFile)).isOK();
} catch (IOException e) {
e.printStackTrace();
}
} else {
throw new IllegalStateException("No definition for problem " + name);
}
} else {
IResponse response = definition.execute(solver.getSolver());
return response.isOK();
}
return false;
}


Expand Down

0 comments on commit 894a42f

Please sign in to comment.