Java Code Examples for kodkod.ast.Relation#ternary()

The following examples show how to use kodkod.ast.Relation#ternary() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BugTests.java    From org.alloytools.alloy with Apache License 2.0 6 votes vote down vote up
public final void testEmina_01232006() {
    final List<String> atoms = new ArrayList<String>(5);
    for (int i = 0; i < 5; i++)
        atoms.add("a" + i);
    final Universe u = new Universe(atoms);
    final TupleFactory tf = u.factory();

    final Relation r1 = Relation.unary("r1"), r2 = Relation.binary("r2"), r3 = Relation.ternary("r3");
    final Bounds b = new Bounds(u);
    final TupleSet r2Bound = tf.noneOf(2);
    for (int i = 0; i < 4; i++)
        r2Bound.add(tf.tuple(atoms.get(i), atoms.get(i)));
    r2Bound.add(tf.tuple("a4", "a1"));
    r2Bound.add(tf.tuple("a4", "a2"));
    b.bound(r2, r2Bound);
    b.bound(r1, tf.setOf("a0", "a3"), tf.setOf("a0", "a3", "a4"));
    b.bound(r3, tf.setOf(tf.tuple("a0", "a0", "a0"), tf.tuple("a3", "a3", "a3")));
    final Formula f = r1.product(r2).in(r3);

    final Instance instance = solver.solve(f, b).instance();
    assertTrue((new Evaluator(instance)).evaluate(f));
    // System.out.println(instance);
    // System.out.println((new Evaluator(instance)).evaluate(f ));

}
 
Example 2
Source File: RegressionTests.java    From kodkod with MIT License 6 votes vote down vote up
@Test
public final void testEmina_10092006() {
	Relation r = Relation.ternary("r");
	final Variable a = Variable.unary("A");
	final Variable b = Variable.unary("B");
	final Variable c = Variable.unary("C");		
	final Variable d = Variable.unary("D");
	final Formula f0 = (b.join(a.join(r))).eq(d.join(c.join(r)));
	final Formula f1 = a.in(c).and(b.in(d));
	final Formula f = f0.implies(f1).
	forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)).and(c.oneOf(UNIV)).and(d.oneOf(UNIV)));
	final Universe u = new Universe(Arrays.asList("a0","a1"));
	final Bounds bounds = new Bounds(u);
	bounds.bound(r, u.factory().allOf(3));
	//		System.out.println(f); System.out.println(bounds);
	solver.options().setSymmetryBreaking(0);
	final Solution s = solver.solve(f, bounds);
	//		System.out.println(s);
	assertEquals(Solution.Outcome.SATISFIABLE, s.outcome());
}
 
Example 3
Source File: SET948.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new instance of SET948.
 */
public SET948() {
    empty = Relation.unary("empty");
    subset = Relation.binary("subset");
    in = Relation.binary("in");
    disjoint = Relation.binary("disjoint");
    union = Relation.binary("union");
    intersect2 = Relation.ternary("set_intersection2");
    union2 = Relation.ternary("set_union2");
}
 
Example 4
Source File: SET943.java    From kodkod with MIT License 5 votes vote down vote up
/**
 * Constructs a new instance of SET943.
 */
public SET943() {
	empty = Relation.unary("empty");
	subset = Relation.binary("subset");
	in = Relation.binary("in");
	union = Relation.binary("union");
	union2 = Relation.ternary("set_union2");
}
 
Example 5
Source File: Hotel.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new instance of the hotel problem.
 */
public Hotel() {
    this.Time = Relation.unary("Time");
    this.Event = Relation.unary("Event");
    this.first = Relation.unary("first");
    this.last = Relation.unary("last");
    this.pre = Relation.binary("pre");
    this.post = Relation.binary("post");
    this.next = Relation.binary("next");

    this.Key = Relation.unary("Key");
    this.Card = Relation.unary("Card");
    this.Guest = Relation.unary("Guest");
    this.Room = Relation.unary("Room");
    this.HotelEvent = Relation.unary("HotelEvent");
    this.RoomCardEvent = Relation.unary("RoomCardEvent");
    this.Checkin = Relation.unary("Checkin");
    this.Enter = Relation.unary("Enter");
    this.NormalEnter = Relation.unary("NormalEnter");
    this.RecodeEnter = Relation.unary("RecodeEnter");
    this.Checkout = Relation.unary("Checkout");

    this.key = Relation.ternary("key");
    this.prev = Relation.ternary("prev");
    this.occ = Relation.ternary("occ");
    this.holds = Relation.ternary("holds");

    this.guest = Relation.binary("guest");
    this.room = Relation.binary("room");
    this.card = Relation.binary("card");
    this.k1 = Relation.binary("k1");
    this.k2 = Relation.binary("k2");
}
 
Example 6
Source File: Quasigroups7.java    From kodkod with MIT License 5 votes vote down vote up
/**
 * Constructs a new instance of Quasigroups7.
 */
Quasigroups7() {
	op1 = Relation.ternary("op1");
	op2 = Relation.ternary("op2");
	s1 = Relation.unary("e1");
	s2 = Relation.unary("e2");
	e1 = new Relation[7];
	e2 = new Relation[7];
	h = new Relation[7];
	for(int i = 0; i < 7; i++) {
		e1[i] = Relation.unary("e1"+i);
		e2[i] = Relation.unary("e2"+i);
		h[i] = Relation.binary("h"+(i+1));
	}
}
 
Example 7
Source File: ALG195_1.java    From kodkod with MIT License 5 votes vote down vote up
/**
 * Constructs a new instance of Quasigroups7.
 */
ALG195_1() {
	op1 = Relation.ternary("op1");
	op2 = Relation.ternary("op2");
	s1 = Relation.unary("s1");
	s2 = Relation.unary("s2");
	e1 = new Relation[7];
	e2 = new Relation[7];
	h = new Relation[7];
	for(int i = 0; i < 7; i++) {
		e1[i] = Relation.unary("e1"+i);
		e2[i] = Relation.unary("e2"+i);
		h[i] = Relation.binary("h"+(i+1));
	}
}
 
Example 8
Source File: SET948.java    From kodkod with MIT License 5 votes vote down vote up
/**
 * Constructs a new instance of SET948.
 */
public SET948() {
	empty = Relation.unary("empty");
	subset = Relation.binary("subset");
	in = Relation.binary("in");
	disjoint = Relation.binary("disjoint");
	union = Relation.binary("union");
	intersect2 = Relation.ternary("set_intersection2");
	union2 = Relation.ternary("set_union2");
}
 
Example 9
Source File: Dijkstra.java    From kodkod with MIT License 5 votes vote down vote up
/**
 * Creates an instance of Dijkstra example.
 */
public Dijkstra() {
	Process = Relation.unary("Process");
	Mutex = Relation.unary("Mutex");
	State = Relation.unary("State");
	holds = Relation.ternary("holds");
	waits = Relation.ternary("waits");
	sfirst = Relation.unary("sfirst");
	slast = Relation.unary("slast");
	sord = Relation.binary("sord");
	mfirst = Relation.unary("mfirst");
	mlast = Relation.unary("mlast");
	mord = Relation.binary("mord");
}
 
Example 10
Source File: TOP020.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new instance of TOP020.
 */
public TOP020() {
    hausdorff = Relation.unary("a_hausdorff_top_space");
    member = Relation.binary("a_member_of");
    open = Relation.binary("open_in");
    disjoint = Relation.binary("disjoint");
    closed = Relation.binary("closed_in");
    coerce = Relation.binary("coerce_to_class");
    diagonal = Relation.binary("the_diagonal_top");
    product = Relation.ternary("the_product_of");
    tsproduct = Relation.ternary("the_product_top_space_of");
    ordered = Relation.ternary("ordered_pair");
}
 
Example 11
Source File: BugTests.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
public final void testGreg_11232005() {
    final List<String> atoms = new ArrayList<String>(3);
    atoms.add("-1");
    atoms.add("0");
    atoms.add("1");
    final Universe u = new Universe(atoms);
    final TupleFactory t = u.factory();

    final Relation inc = Relation.binary("inc"), add = Relation.ternary("add"), one = Relation.unary("1"),
                    param0 = Relation.unary("param0"), ints = Relation.unary("int");

    // (one param0 && ((1 . (param0 . add)) in (param0 . ^inc)))
    final Formula f = param0.one().and((one.join(param0.join(add))).in(param0.join(inc.closure())));

    final Bounds b = new Bounds(u);

    b.bound(param0, t.allOf(1));
    b.boundExactly(one, t.setOf(t.tuple("1")));
    b.boundExactly(ints, t.allOf(1));
    b.boundExactly(inc, t.setOf(t.tuple("-1", "0"), t.tuple("0", "1")));
    // [1, 1, -1], [1, -1, 0], [1, 0, 1], [-1, 1, 0], [-1, -1, 1],
    // [-1, 0, -1], [0, 1, 1], [0, -1, -1], [0, 0, 0]]
    b.boundExactly(add, t.setOf(t.tuple("1", "1", "-1"), t.tuple("1", "-1", "0"), t.tuple("1", "0", "1"), t.tuple("-1", "1", "0"), t.tuple("-1", "-1", "1"), t.tuple("-1", "0", "-1"), t.tuple("0", "1", "1"), t.tuple("0", "-1", "-1"), t.tuple("0", "0", "0")));

    // System.out.println(f);
    // System.out.println(b);

    final Instance instance = solver.solve(f, b).instance();
    assertTrue((new Evaluator(instance)).evaluate(f));
    // System.out.println(instance);
    // System.out.println((new Evaluator(instance)).evaluate(f ));

}
 
Example 12
Source File: NUM374.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new instance of NUM374.
 */
public NUM374() {
    n1 = Relation.unary("n1");
    sum = Relation.ternary("sum");
    product = Relation.ternary("product");
    exponent = Relation.ternary("exponent");
}
 
Example 13
Source File: Hotel.java    From kodkod with MIT License 5 votes vote down vote up
/**
 * Constructs a new instance of the hotel problem.
 */
public Hotel() { 
	this.Time = Relation.unary("Time");
	this.Event = Relation.unary("Event");
	this.first = Relation.unary("first");
	this.last = Relation.unary("last");
	this.pre = Relation.binary("pre");
	this.post = Relation.binary("post");
	this.next = Relation.binary("next");
	
	
	this.Key = Relation.unary("Key");
	this.Card = Relation.unary("Card");
	this.Guest = Relation.unary("Guest");
	this.Room = Relation.unary("Room");
	this.HotelEvent = Relation.unary("HotelEvent");
	this.RoomCardEvent = Relation.unary("RoomCardEvent");
	this.Checkin = Relation.unary("Checkin");
	this.Enter = Relation.unary("Enter");
	this.NormalEnter = Relation.unary("NormalEnter");
	this.RecodeEnter = Relation.unary("RecodeEnter");
	this.Checkout = Relation.unary("Checkout");
	
	this.key = Relation.ternary("key");
	this.prev = Relation.ternary("prev");
	this.occ = Relation.ternary("occ");
	this.holds = Relation.ternary("holds");
	
	this.guest = Relation.binary("guest");
	this.room = Relation.binary("room");
	this.card = Relation.binary("card");
	this.k1 = Relation.binary("k1");
	this.k2 = Relation.binary("k2");
}
 
Example 14
Source File: SET967.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new instance of SET967.
 */
public SET967() {
    empty = Relation.unary("empty");
    subset = Relation.binary("subset");
    in = Relation.binary("in");
    disjoint = Relation.binary("disjoint");
    union = Relation.binary("union");
    singleton = Relation.binary("singleton");
    intersect2 = Relation.ternary("set_intersection2");
    union2 = Relation.ternary("set_union2");
    cartesian2 = Relation.ternary("cartesian_product2");
    ordered = Relation.ternary("ordered_pair");
    unordered = Relation.ternary("unordered_pair");
}
 
Example 15
Source File: TOP020.java    From kodkod with MIT License 5 votes vote down vote up
/**
 * Constructs a new instance of TOP020.
 */
public TOP020() {
	hausdorff = Relation.unary("a_hausdorff_top_space");
	member = Relation.binary("a_member_of");
	open = Relation.binary("open_in");
	disjoint = Relation.binary("disjoint");
	closed = Relation.binary("closed_in");
	coerce = Relation.binary("coerce_to_class");
	diagonal = Relation.binary("the_diagonal_top");
	product = Relation.ternary("the_product_of");
	tsproduct = Relation.ternary("the_product_top_space_of");
	ordered = Relation.ternary("ordered_pair");
}
 
Example 16
Source File: TranslatorTest.java    From kodkod with MIT License 4 votes vote down vote up
public TranslatorTest() {
		this.solver = new Solver();
		List<Integer> atoms = new ArrayList<Integer>(10);
		for (int i = 0; i < 10; i++) {
			atoms.add(i);
		}
		final Universe universe = new Universe(atoms);
		this.factory = universe.factory();
		this.t112 = factory.tuple(1, 4);
		this.t212 = factory.tuple(2, 57);
		this.t312 = factory.tuple(3, 345);
		this.r1 = new Relation[4];
		this.r2 = new Relation[4];
		this.r3 = new Relation[4];
		for (int i = 0; i < 4; i++) {
			
			r1[i] = Relation.unary("r1" + i);
			r2[i] = Relation.binary("r2" + i);
			r3[i] = Relation.ternary("r3" + i);
			
			
		}
		
		bounds = new Bounds(universe);
		
		bounds.bound(r1[0],	factory.allOf(1));
		bounds.bound(r1[1],	factory.range(factory.tuple(2),  t112));
		bounds.bound(r1[2],	factory.range(t112, t112));
		bounds.bound(r1[3],	factory.range(factory.tuple(5),factory.tuple(8)));
		
		bounds.bound(r2[0],	factory.allOf(2));
		bounds.bound(r2[1],	factory.area(factory.tuple(2,35),t212));
		bounds.bound(r2[2],	factory.setOf(t212));
		bounds.bound(r2[3],	factory.area(factory.tuple(2,60), factory.tuple(2,86)));
		
		bounds.bound(r3[0],	factory.allOf(3));
		bounds.bound(r3[1],	factory.area(factory.tuple(3,123), t312));
		bounds.bound(r3[2],	factory.setOf(t312));
		bounds.bound(r3[3],	factory.area(factory.tuple(3,700),factory.tuple(3,897)));
		
//		System.out.println(bounds.upperBound(r3[0]).size());
//		System.out.println(bounds.upperBound(r3[1]).size());
//		System.out.println(bounds.upperBound(r3[2]).size());
//		System.out.println(bounds.upperBound(r3[3]).size());
		
		
	}
 
Example 17
Source File: NUM378.java    From kodkod with MIT License 4 votes vote down vote up
/**
 * Constructs a new instance of NUM378.
 */
public NUM378() {
	succ = Relation.binary("succ");
	sum = Relation.ternary("sum");
}
 
Example 18
Source File: LatinSquare.java    From kodkod with MIT License 4 votes vote down vote up
/**
 * Constructs a model of a Latin square.
 */
public LatinSquare() {
	square = Relation.ternary("square");
}
 
Example 19
Source File: TranslatorTest.java    From org.alloytools.alloy with Apache License 2.0 4 votes vote down vote up
public final void testFlattening() {
    final List<String> atoms = new ArrayList<String>(9);
    atoms.add("-1");
    atoms.add("0");
    atoms.add("1");
    atoms.add("null");
    for (int i = 0; i < 5; i++) {
        atoms.add("m" + i);
    }
    final Universe u = new Universe(atoms);
    final TupleFactory t = u.factory();

    final Relation[] m = new Relation[5];
    for (int i = 0; i < 5; i++) {
        m[i] = Relation.unary("m" + i);
    }

    final Relation univ = Relation.unary("univ"), none = Relation.unary("none"), iden = Relation.binary("inden"),
                    mutant = Relation.unary("mutant"), inc = Relation.binary("inc"), add = Relation.ternary("add"),
                    i0 = Relation.unary("i0"), zero = Relation.unary("0"), one = Relation.unary("1"),
                    ints = Relation.unary("int");

    final Bounds b = new Bounds(u);

    b.boundExactly(univ, t.allOf(1));
    b.boundExactly(none, t.noneOf(1));
    TupleSet idenSet = t.noneOf(2);
    for (String atom : atoms) {
        idenSet.add(t.tuple(atom, atom));
    }
    b.boundExactly(iden, idenSet);

    b.bound(mutant, t.range(t.tuple("m0"), t.tuple("m4")));
    for (int i = 0; i < 5; i++) {
        b.boundExactly(m[i], t.setOf("m" + i));
    }

    b.bound(i0, t.range(t.tuple("-1"), t.tuple("1")));
    b.boundExactly(zero, t.setOf(t.tuple("0")));
    b.boundExactly(one, t.setOf(t.tuple("1")));
    b.boundExactly(ints, t.allOf(1));
    b.boundExactly(inc, t.setOf(t.tuple("-1", "0"), t.tuple("0", "1")));

    // [1, 1, -1], [1, -1, 0], [1, 0, 1], [-1, 1, 0], [-1, -1, 1],
    // [-1, 0, -1], [0, 1, 1], [0, -1, -1], [0, 0, 0]]
    b.boundExactly(add, t.setOf(t.tuple("1", "1", "-1"), t.tuple("1", "-1", "0"), t.tuple("1", "0", "1"), t.tuple("-1", "1", "0"), t.tuple("-1", "-1", "1"), t.tuple("-1", "0", "-1"), t.tuple("0", "1", "1"), t.tuple("0", "-1", "-1"), t.tuple("0", "0", "0")));

    /*
     * ((one i0 && one mutant) && !((if (i0 in (0 . ^~inc)) then ((add . 0) . i0)
     * else i0) = (if !((if (mutant in m4) then (if (i0 in 0) then 1 else 0) else
     * (if (mutant in m3) then (if ((i0 = 0) || (i0 in (0 . ^~inc))) then 1 else 0)
     * else (if (mutant in m2) then (if (i0 in (0 . ^inc)) then 1 else 0) else (if
     * (mutant in m1) then (if ((i0 = 0) || (i0 in (0 . ^inc))) then 1 else 0) else
     * (if (mutant in m0) then (if !(i0 in 0) then 1 else 0) else (if (i0 in (0 .
     * ^~inc)) then 1 else 0)))))) in 0) then ((add . 0) . i0) else i0)))
     */

    final Formula[] cm = new Formula[5];
    for (int i = 0; i < 5; i++) {
        cm[i] = mutant.in(m[i]);
    }

    // (i0 in (0 . ^~inc))
    final Formula fs0 = i0.in(zero.join(inc.transpose().closure()));
    // (i0 in (0 . ^inc))
    final Formula fs1 = i0.in(zero.join(inc.closure()));
    // (i0 = 0)
    final Formula fs2 = i0.eq(zero);

    final Expression em0 = cm[0].thenElse(i0.in(zero).not().thenElse(one, zero), fs0.thenElse(one, zero));
    final Expression em1 = cm[1].thenElse((fs2.or(fs1)).thenElse(one, zero), em0);
    final Expression em2 = cm[2].thenElse(fs1.thenElse(one, zero), em1);
    final Expression em3 = cm[3].thenElse(fs2.or(fs0).thenElse(one, zero), em2);
    final Expression em4 = cm[4].thenElse(i0.in(zero).thenElse(one, zero), em3);

    final Expression es1 = add.join(zero).join(i0);
    final Expression expr2 = em4.in(zero).not().thenElse(es1, i0);
    final Expression expr1 = fs0.thenElse(es1, i0);

    final Formula f = i0.one().and(mutant.one()).and(expr1.eq(expr2).not());

    final Instance instance = solver.solve(f, b).instance();
    assertNotNull(instance);

    // System.out.println(instance);

}
 
Example 20
Source File: BugTests.java    From org.alloytools.alloy with Apache License 2.0 4 votes vote down vote up
public final void testVincent_03182006() {
    final Relation cAttributes = Relation.binary("cAttributes"), Int = Relation.unary("Integer"),
                    c6001 = Relation.unary("6.001"), one = Relation.unary("ONE"),
                    prereqsetUsed = Relation.binary("prereqsetUsed"), Course = Relation.unary("Course"),
                    CardinalityGrouping = Relation.unary("CardinalityGrouping"), pCourses = Relation.binary("pCourses"),
                    dec = Relation.binary("dec"), c6002 = Relation.unary("6.002"), greater = Relation.binary("greater"),
                    size = Relation.binary("size"), less = Relation.binary("less"),
                    sAttributes = Relation.binary("sAttributes"), PrereqSet = Relation.unary("PrereqSet"),
                    inc = Relation.binary("inc"), next = Relation.binary("next"), equal = Relation.binary("equal"),
                    Semester = Relation.unary("Semester"), index = Relation.ternary("index"),
                    sCourses = Relation.binary("sCourses"), prev = Relation.binary("prev"),
                    prereqs = Relation.binary("prereqs");
    // [6.002, 8.02, 6.003, 6.001, Spring 2006, Fall 2006, [8.02], [6.001],
    // [], Spring, Even, Fall, 1, 2]
    final List<String> atoms = new ArrayList<String>(14);
    atoms.add("6.002");
    atoms.add("8.02");
    atoms.add("6.003");
    atoms.add("6.001");
    atoms.add("Spring 2006");
    atoms.add("Fall 2006");
    atoms.add("[8.02]");
    atoms.add("[6.001]");
    atoms.add("[]");
    atoms.add("Spring");
    atoms.add("Even");
    atoms.add("Fall");
    atoms.add("1");
    atoms.add("2");
    final Universe u = new Universe(atoms);
    final Bounds b = new Bounds(u);
    final TupleFactory f = u.factory();

    b.bound(cAttributes, f.noneOf(2));
    b.boundExactly(Int, f.range(f.tuple("1"), f.tuple("2")));
    b.boundExactly(c6001, f.setOf(f.tuple("6.001")));
    b.boundExactly(one, f.setOf(f.tuple("1")));
    b.bound(prereqsetUsed, f.setOf(f.tuple("6.002", "[8.02]"), f.tuple("8.02", "[]"), f.tuple("6.003", "[6.001]"), f.tuple("6.001", "[]")));
    b.bound(Course, f.range(f.tuple("6.002"), f.tuple("6.001")));
    b.bound(CardinalityGrouping, f.noneOf(1));
    b.boundExactly(pCourses, f.setOf(f.tuple("[8.02]", "8.02"), f.tuple("[6.001]", "6.001")));
    b.boundExactly(dec, f.setOf(f.tuple("2", "1")));
    b.boundExactly(greater, b.upperBound(dec));
    b.bound(size, f.noneOf(2));
    b.boundExactly(c6002, f.setOf(f.tuple("6.002")));
    b.boundExactly(less, f.setOf(f.tuple("1", "2")));
    b.boundExactly(sAttributes, f.setOf(f.tuple("Spring 2006", "Spring"), f.tuple("Spring 2006", "Even"), f.tuple("Fall 2006", "Even"), f.tuple("Fall 2006", "Fall")));
    b.boundExactly(PrereqSet, f.setOf("[8.02]", "[6.001]", "[]"));
    b.boundExactly(inc, b.upperBound(less));
    b.boundExactly(next, f.setOf(f.tuple("Spring 2006", "Fall 2006")));
    b.boundExactly(equal, f.setOf(f.tuple("1", "1"), f.tuple("2", "2")));
    b.boundExactly(Semester, f.setOf("Spring 2006", "Fall 2006"));
    b.bound(index, f.noneOf(3));
    b.bound(sCourses, f.range(f.tuple("Spring 2006"), f.tuple("Fall 2006")).product(f.range(f.tuple("6.002"), f.tuple("6.001"))));
    b.boundExactly(prev, f.setOf(f.tuple("Fall 2006", "Spring 2006")));
    b.boundExactly(prereqs, f.setOf(f.tuple("6.002", "[8.02]"), f.tuple("8.02", "[]"), f.tuple("6.003", "[6.001]"), f.tuple("6.001", "[]")));
    // for(Relation r : b.relations()) {
    // System.out.println(r + " " + r.arity() + " " + b.lowerBound(r) + " ;
    // " + b.upperBound(r));
    // }
    // System.out.println(u);

    final Formula f0 = sCourses.in(Semester.product(Course));
    final Formula f1 = size.function(CardinalityGrouping, Int);
    final Formula f2 = prereqsetUsed.function(Semester.join(sCourses), PrereqSet);
    final Formula f3 = prereqsetUsed.in(prereqs);
    final Variable s = Variable.unary("s");
    final Expression e0 = s.join(sCourses).join(prereqsetUsed).join(pCourses);
    final Expression e1 = s.join(prev.closure()).join(sCourses);
    final Formula f4 = e0.in(e1).forAll(s.oneOf(Semester));
    final Formula f5 = c6002.in(Semester.join(sCourses));
    final Variable e = Variable.unary("e");
    final Expression e3 = Semester.join(sCourses).difference(e);
    final Formula f60 = c6002.in(e3);
    final Formula f61 = e3.join(prereqsetUsed).join(pCourses).in(e3);
    final Formula f6 = (f60.and(f61)).not().forAll(e.oneOf(Semester.join(sCourses)));
    final Variable c = Variable.unary("c");
    final Formula f7 = c.join(cAttributes).in(s.join(sAttributes)).forAll(c.oneOf(s.join(sCourses))).forAll(s.oneOf(Semester));
    final Variable s1 = Variable.unary("s1"), s2 = Variable.unary("s2");
    final Formula f8 = s1.join(sCourses).intersection(s2.join(sCourses)).no().forAll(s2.oneOf(Semester.difference(s1))).forAll(s1.oneOf(Semester));
    final Formula f9 = c6001.intersection(Semester.join(sCourses)).no();

    final Formula x = f0.and(f1).and(f2).and(f3).and(f4).and(f5).and(f6).and(f7).and(f8);
    final Formula y = x.and(f9);

    // System.out.println(x);
    // System.out.println(y);

    solver.options().setSolver(SATFactory.DefaultSAT4J);
    Solution solution = solver.solve(x, b);
    // System.out.println(solution); // SATISFIABLE
    assertEquals(solution.outcome(), Solution.Outcome.SATISFIABLE);

    Solution solution2 = solver.solve(y, b);
    // System.out.println(solution2); // SATISFIABLE!!!???
    // System.out.println((new
    // Evaluator(solution2.instance())).evaluate(x));
    assertEquals(solution2.outcome(), Solution.Outcome.SATISFIABLE);

}