use of kodkod.engine.fol2sat.HigherOrderDeclException in project org.alloytools.alloy by AlloyTools.
the class HOL2ProcTranslator method visit.
@Override
public Formula visit(QuantifiedFormula qf) {
for (Decl decl : qf.decls()) {
if (decl.multiplicity() != Multiplicity.ONE) {
if (!isSkolemizableUpToNow())
throw new HigherOrderDeclException(decl);
assert qf.decls().size() == 1 : "not implemented for quantifiers with multiple decls";
QuantifiedFormula revQuant = (QuantifiedFormula) qf.formula().quantify(qf.quantifier().opposite, decl);
conversions.add(new Conversion(qf, revQuant));
return revQuant;
}
}
return super.visit(qf);
}
use of kodkod.engine.fol2sat.HigherOrderDeclException in project org.alloytools.alloy by AlloyTools.
the class Lists method main.
/**
* Usage: java examples.Lists [scope]
*/
public static void main(String[] args) {
if (args.length < 1)
usage();
try {
final int n = Integer.parseInt(args[0]);
final Lists model = new Lists();
final Bounds b = model.bounds(n);
final Solver solver = new Solver();
solver.options().setSolver(SATFactory.MiniSat);
// solver.options().setFlatten(false);
// solver.options().setSkolemize(false);
Formula f = model.runShow();
System.out.println("running show");
Solution s = solver.solve(f, b);
System.out.println(s);
f = model.checkEmpties();
System.out.println("checking empties");
s = solver.solve(f, b);
System.out.println(s);
f = model.checkReflexive();
System.out.println("checking reflexive");
s = solver.solve(f, b);
System.out.println(s);
f = model.checkSymmetric();
System.out.println("checking symmetric");
s = solver.solve(f, b);
System.out.println(s);
} catch (NumberFormatException nfe) {
usage();
} catch (HigherOrderDeclException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnboundLeafException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of kodkod.engine.fol2sat.HigherOrderDeclException in project org.alloytools.alloy by AlloyTools.
the class TranslateAlloyToKodkod method execute_commandFromBook.
/**
* Based on the specified "options", execute one command and return the
* resulting A4Solution object.
* <p>
* Note: it will first test whether the model fits one of the model from the
* "Software Abstractions" book; if so, it will use the exact instance that was
* in the book.
*
* @param rep - if nonnull, we'll send compilation diagnostic messages to it
* @param sigs - the list of sigs; this list must be complete
* @param cmd - the Command to execute
* @param opt - the set of options guiding the execution of the command
* @return null if the user chose "save to FILE" as the SAT solver, and nonnull
* if the solver finishes the entire solving and is either satisfiable
* or unsatisfiable.
* <p>
* If the return value X is satisfiable, you can call X.next() to get
* the next satisfying solution X2; and you can call X2.next() to get
* the next satisfying solution X3... until you get an unsatisfying
* solution.
*/
public static A4Solution execute_commandFromBook(A4Reporter rep, Iterable<Sig> sigs, Command cmd, A4Options opt) throws Err {
if (rep == null)
rep = A4Reporter.NOP;
TranslateAlloyToKodkod tr = null;
try {
if (cmd.parent != null || !cmd.getGrowableSigs().isEmpty())
return execute_greedyCommand(rep, sigs, cmd, opt);
tr = new TranslateAlloyToKodkod(rep, opt, sigs, cmd);
tr.makeFacts(cmd.formula);
return tr.frame.solve(rep, cmd, new Simplifier(), true);
} catch (UnsatisfiedLinkError ex) {
throw new ErrorFatal("The required JNI library cannot be found: " + ex.toString().trim(), ex);
} catch (CapacityExceededException ex) {
throw rethrow(ex);
} catch (HigherOrderDeclException ex) {
Pos p = tr != null ? tr.frame.kv2typepos(ex.decl().variable()).b : Pos.UNKNOWN;
throw new ErrorType(p, "Analysis cannot be performed since it requires higher-order quantification that could not be skolemized.");
} catch (Throwable ex) {
if (ex instanceof Err)
throw (Err) ex;
else
throw new ErrorFatal("Unknown exception occurred: " + ex, ex);
}
}
use of kodkod.engine.fol2sat.HigherOrderDeclException in project org.alloytools.alloy by AlloyTools.
the class LAT258 method main.
/**
* Usage: java examples.tptp.LAT258 [scope]
*/
public static void main(String[] args) {
if (args.length < 1)
usage();
try {
final int n = Integer.parseInt(args[0]);
final LAT258 model = new LAT258();
final Bounds b = model.bounds(n);
final Solver solver = new Solver();
solver.options().setSolver(SATFactory.MiniSat);
final Formula f = model.checkGoalToBeProved();
System.out.println(f);
// System.out.println(b);
final Solution s = solver.solve(f, b);
System.out.println(s);
} catch (NumberFormatException nfe) {
usage();
} catch (HigherOrderDeclException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnboundLeafException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of kodkod.engine.fol2sat.HigherOrderDeclException in project org.alloytools.alloy by AlloyTools.
the class FileSystem method main.
/**
* Usage: java examples.alloy.FileSystem [scope]
*/
public static void main(String[] args) {
if (args.length < 1)
usage();
try {
final int n = Integer.parseInt(args[0]);
final FileSystem model = new FileSystem();
final Formula f = model.checkNoDirAliases();
System.out.println(f);
final Bounds b = model.bounds(n);
final Solver solver = new Solver();
solver.options().setSolver(SATFactory.MiniSat);
final Solution s = solver.solve(f, b);
System.out.println(s);
} catch (NumberFormatException nfe) {
usage();
} catch (HigherOrderDeclException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnboundLeafException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations