use of kodkod.instance.Bounds in project org.alloytools.alloy by AlloyTools.
the class GEO159 method bounds.
/**
* Returns a bounds with the given number of maximum curves and points
*
* @return a bounds with the given number of maximum curves and points
*/
@Override
public Bounds bounds(int scope) {
final Bounds b = super.bounds(scope);
final TupleSet c = b.upperBound(curve);
final TupleSet p = b.upperBound(point);
b.bound(between, c.product(p).product(p).product(p));
return b;
}
use of kodkod.instance.Bounds 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.instance.Bounds in project org.alloytools.alloy by AlloyTools.
the class LAT258 method bounds.
/**
* Returns the bounds for the given scope.
*
* @return the bounds for the given scope.
*/
public final Bounds bounds(int n) {
assert n > 0;
final List<String> atoms = new ArrayList<String>(n);
for (int i = 0; i < n; i++) atoms.add("n" + i);
final Universe univ = new Universe(atoms);
final TupleFactory f = univ.factory();
final Bounds b = new Bounds(univ);
b.bound(goal, f.setOf("n0"));
final TupleSet all1 = f.allOf(1);
b.bound(p, all1);
b.bound(t, all1);
b.bound(v, all1);
b.bound(w, all1);
b.bound(u, all1);
b.bound(x, all1);
b.bound(y, all1);
b.bound(z, all1);
b.bound(lessThan, f.allOf(2));
final TupleSet all3 = f.allOf(3);
b.bound(join, all3);
b.bound(meet, all3);
return b;
}
use of kodkod.instance.Bounds in project org.alloytools.alloy by AlloyTools.
the class DiffEg method bounds.
/**
* Returns the bounds for the given alloy scope.
*
* @return bounds for the given alloy scope
*/
public final Bounds bounds(int scope) {
assert scope > 0;
final List<String> atoms = new ArrayList<String>(4 * scope + 1);
// Subject, Resource, Action, Conflicted
for (int i = 0; i < scope; i++) atoms.add("Subject" + i);
for (int i = 0; i < scope; i++) atoms.add("Resource" + i);
for (int i = 0; i < scope; i++) atoms.add("Action" + i);
for (int i = 0; i < scope; i++) atoms.add("Conflicted" + i);
for (int i = 0; i < scope; i++) atoms.add("Request" + i);
final Universe u = new Universe(atoms);
final TupleFactory f = u.factory();
final Bounds b = new Bounds(u);
final int max = scope - 1;
b.bound(Subject, f.range(f.tuple("Subject0"), f.tuple("Subject" + max)));
b.bound(Resource, f.range(f.tuple("Resource0"), f.tuple("Resource" + max)));
b.bound(Action, f.range(f.tuple("Action0"), f.tuple("Action" + max)));
b.bound(Conflicted, f.range(f.tuple("Conflicted0"), f.tuple("Conflicted" + max)));
b.bound(Request, f.range(f.tuple("Request0"), f.tuple("Request" + max)));
// sRequest, rRequest, action, sConflicted, rConflicted;
b.bound(sRequest, b.upperBound(Request).product(b.upperBound(Subject)));
b.bound(rRequest, b.upperBound(Request).product(b.upperBound(Resource)));
b.bound(action, b.upperBound(Request).product(b.upperBound(Action)));
b.bound(sConflicted, b.upperBound(Conflicted).product(b.upperBound(Subject)));
b.bound(rConflicted, b.upperBound(Conflicted).product(b.upperBound(Resource)));
return b;
}
use of kodkod.instance.Bounds 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