use of kodkod.ast.Expression in project org.alloytools.alloy by AlloyTools.
the class BugTests method testFelix_03062008_2.
public final void testFelix_03062008_2() {
Relation x5 = Relation.unary("Role");
Relation x6 = Relation.unary("Session");
List<String> atomlist = Arrays.asList("Role$0", "Session$0", "Session$1");
Universe universe = new Universe(atomlist);
TupleFactory factory = universe.factory();
Bounds bounds = new Bounds(universe);
TupleSet x5_upper = factory.noneOf(1);
x5_upper.add(factory.tuple("Role$0"));
bounds.bound(x5, x5_upper);
TupleSet x6_upper = factory.noneOf(1);
x6_upper.add(factory.tuple("Session$0"));
x6_upper.add(factory.tuple("Session$1"));
bounds.bound(x6, x6_upper);
Variable x11 = Variable.unary("x_a");
Decls x10 = x11.oneOf(x6);
Variable x15 = Variable.unary("x_b");
Decls x14 = x15.oneOf(x5);
Variable x17 = Variable.unary("x_c");
Decls x16 = x17.oneOf(x5);
Decls x13 = x14.and(x16);
Expression x20 = x15.product(x17);
Expression x19 = x11.product(x20);
Formula x18 = x19.some();
Formula x12 = x18.forSome(x13);
Formula x9 = x12.forAll(x10);
Formula x24 = x5.some();
Formula x23 = x24.not();
Formula x28 = x5.eq(x5);
Formula x29 = x6.eq(x6);
Formula x25 = x28.and(x29);
Formula x22 = x23.and(x25);
Formula x8 = x9.and(x22).and(x5.no()).and(x6.no());
Solver solver = new Solver();
solver.options().setSolver(SATFactory.DefaultSAT4J);
solver.options().setBitwidth(2);
// solver.options().setFlatten(false);
solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT);
solver.options().setSymmetryBreaking(20);
solver.options().setSkolemDepth(2);
System.out.flush();
Solution sol = solver.solve(x8, bounds);
Instance inst = sol.instance();
assertNotNull(inst);
for (Relation rel : inst.relations()) {
if (rel != x5 && rel != x6) {
final TupleSet range = inst.tuples(x6).product(inst.tuples(x5));
assertTrue(range.containsAll(inst.tuples(rel)));
}
}
}
use of kodkod.ast.Expression in project org.alloytools.alloy by AlloyTools.
the class Netconfig method connectedSites.
/**
* Returns the connectedSites predicate.
*
* @return connectedSites
*/
public Formula connectedSites(Expression sites, Expression endTime) {
final Variable s = Variable.unary("s");
final Variable r = Variable.unary("r");
final Expression linksAtEndTime = satellite.union(lineOfSight).join(endTime);
final Formula f = sites.difference(s).in(r.join(linksAtEndTime.closure()).join(site));
return f.forSome(r.oneOf(site.join(s))).forAll(s.oneOf(sites));
}
use of kodkod.ast.Expression in project org.alloytools.alloy by AlloyTools.
the class Netconfig method declarations.
/**
* Returns the constraints implicit in signature and field declarations.
*
* @return the constraints implicit in signature and field declarations.
*/
public Formula declarations() {
// HQ + Sub in Site && no HQ & Sub
final Formula hqSub = HQ.union(Sub).in(Site).and(HQ.intersection(Sub).no());
// site is a function from Router to Site
final Formula siteFun = site.function(Router, Site);
// satellite in Router->Router->Time && lineOfSight in
// Router->Router->Time
final Expression rrt = Router.product(Router).product(Time);
final Formula satLos = satellite.in(rrt).and(lineOfSight.in(rrt));
// tick is a total ordering on time
final Formula tord = tick.totalOrder(Time, start, end);
return hqSub.and(siteFun).and(satLos).and(tord);
}
use of kodkod.ast.Expression in project org.alloytools.alloy by AlloyTools.
the class ALG195_1 method co1h.
/**
* Returns the part of the conjecture 1 that applies to the given h.
*
* @return the part of the conjecture 1 that applies to the given h.
*/
private final Formula co1h(Relation h) {
Formula f = Formula.TRUE;
for (Relation x : e1) {
for (Relation y : e1) {
// h(op1(x,y))
Expression expr0 = (y.join(x.join(op1))).join(h);
// op2(h(x),h(y))
Expression expr1 = (y.join(h)).join((x.join(h)).join(op2));
f = f.and(expr0.eq(expr1));
}
}
return f.and(s2.eq(s1.join(h)));
}
use of kodkod.ast.Expression in project org.alloytools.alloy by AlloyTools.
the class ALG195_1 method ax14and15.
/**
* Parametrization of axioms 14 and 15.
*
* @requires e's are unary, op is ternary
*/
Formula ax14and15(Relation[] e, Relation op) {
// op(e5,...)
final Expression expr0 = e[5].join(op);
// op(e5,e5)
final Expression expr1 = e[5].join(expr0);
// op(e5,op(e5,e5))
final Expression expr2 = expr1.join(expr0);
// op(op(e5,op(e5,e5)),op(e5,op(e5,e5)))
final Expression expr3 = expr2.join(expr2.join(op));
// op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),...)
final Expression expr3a = expr3.join(op);
// op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),e5)
final Expression expr4 = e[5].join(expr3a);
// e0 = op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),op(e5,op(e5,e5)))
final Formula f0 = e[0].eq(expr2.join(expr3a));
// e1 = op(e5,e5)
final Formula f1 = e[1].eq(expr1);
// e2 = op(op(e5,op(e5,e5)),op(e5,op(e5,e5)))
final Formula f2 = e[2].eq(expr3);
// e3 = op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),e5)
final Formula f3 = e[3].eq(expr4);
// e4 = op(e5,op(e5,e5))
final Formula f4 = e[4].eq(expr2);
// e6 =
// op(op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),e5),op(e5,op(e5,e5)))
final Formula f6 = e[6].eq(expr2.join(expr4.join(op)));
return f0.and(f1).and(f2).and(f3).and(f4).and(f6);
}
Aggregations