// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java
// public static ITabularFormula createFormula(int... values)
// {
//     if (values.length%3 != 0)
//     {
//         throw new IllegalArgumentException("Number of values must be a multiple of 3");
//     }
//     ITabularFormula formula = new SimpleFormula();
//     for (int i = 0; i < values.length; i +=3)
//     {
//         SimpleTriplet triplet = new SimpleTriplet(values[i], values[i + 1], values[i + 2]);
//         formula.unionOrAdd(triplet);
//     }
//     return formula;
// }
// 
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimplePermutation.java
// public static IPermutation createPermutation(int... variables)
// {
//     IPermutation permutation = new SimplePermutation();
//         
//     for (int varName : variables)
//     {
//         permutation.add(varName);
//     }
//         
//     return permutation;
// }
// 
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java
// public static final ITripletValue _101_instance = new _101();
// 
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java
// public static final ITripletValue _000_instance = new _000();


import org.junit.BeforeClass;
import org.junit.Test;
import static com.anjlab.sat3.Helper.createFormula;
import static com.anjlab.sat3.SimplePermutation.createPermutation;
import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance;
import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

    }

    @Test
    public void testJoin2BetweenTiers() throws Throwable
    {
        for (int a1 = 1; a1 <= 3; a1++)
        for (int b1 = 1; b1 <= 3; b1++)
        for (int c1 = 1; c1 <= 3; c1++)
            for (int a2 = 3; a2 <= 5; a2++)
            for (int b2 = 3; b2 <= 5; b2++)
            for (int c2 = 3; c2 <= 5; c2++)
                for (int a3 = 5; a3 <= 7; a3++)
                for (int b3 = 5; b3 <= 7; b3++)
                for (int c3 = 5; c3 <= 7; c3++)
                {
                    if (a1 == b1 || a1 == c1 || b1 == c1) continue;
                    if (a2 == b2 || a2 == c2 || b2 == c2) continue;
                    if (a3 == b3 || a3 == c3 || b3 == c3) continue;
                    
                    Join2BetweenTiers method = new Join2BetweenTiers();
                    ITabularFormula formula = createFormula(a1, b1, c1, a3, b3, c3);
                    SimpleTier tier = new SimpleTier(a2, b2, c2);
                    tier.add(_101_instance);
                    try
                    {
                        assertTrue("Should join", method.tryJoin(formula, tier));
                        assertEquals(3, formula.getPermutation().get(2));
                        assertEquals(4, formula.getPermutation().get(3));
                        assertEquals(5, formula.getPermutation().get(4));
                        

// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java
// public static ITabularFormula createFormula(int... values)
// {
//     if (values.length%3 != 0)
//     {
//         throw new IllegalArgumentException("Number of values must be a multiple of 3");
//     }
//     ITabularFormula formula = new SimpleFormula();
//     for (int i = 0; i < values.length; i +=3)
//     {
//         SimpleTriplet triplet = new SimpleTriplet(values[i], values[i + 1], values[i + 2]);
//         formula.unionOrAdd(triplet);
//     }
//     return formula;
// }
// 
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimplePermutation.java
// public static IPermutation createPermutation(int... variables)
// {
//     IPermutation permutation = new SimplePermutation();
//         
//     for (int varName : variables)
//     {
//         permutation.add(varName);
//     }
//         
//     return permutation;
// }
// 
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java
// public static final ITripletValue _101_instance = new _101();
// 
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java
// public static final ITripletValue _000_instance = new _000();


// Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestJoinMethods.java
import org.junit.BeforeClass;
import org.junit.Test;
import static com.anjlab.sat3.Helper.createFormula;
import static com.anjlab.sat3.SimplePermutation.createPermutation;
import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance;
import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

    }

    @Test
    public void testJoin2BetweenTiers() throws Throwable
    {
        for (int a1 = 1; a1 <= 3; a1++)
        for (int b1 = 1; b1 <= 3; b1++)
        for (int c1 = 1; c1 <= 3; c1++)
            for (int a2 = 3; a2 <= 5; a2++)
            for (int b2 = 3; b2 <= 5; b2++)
            for (int c2 = 3; c2 <= 5; c2++)
                for (int a3 = 5; a3 <= 7; a3++)
                for (int b3 = 5; b3 <= 7; b3++)
                for (int c3 = 5; c3 <= 7; c3++)
                {
                    if (a1 == b1 || a1 == c1 || b1 == c1) continue;
                    if (a2 == b2 || a2 == c2 || b2 == c2) continue;
                    if (a3 == b3 || a3 == c3 || b3 == c3) continue;
                    
                    Join2BetweenTiers method = new Join2BetweenTiers();
                    ITabularFormula formula = createFormula(a1, b1, c1, a3, b3, c3);
                    SimpleTier tier = new SimpleTier(a2, b2, c2);
                    tier.add(_101_instance);
                    try
                    {
                        assertTrue("Should join", method.tryJoin(formula, tier));
                        assertEquals(3, formula.getPermutation().get(2));
                        assertEquals(4, formula.getPermutation().get(3));
                        assertEquals(5, formula.getPermutation().get(4));
                        

                        formula.complete(createPermutation(1, 2, 3, 4, 5, 6, 7));
