diff --git a/src/test/java/UnifyTest.java b/src/test/java/UnifyTest.java index 4f7d453..cb26981 100644 --- a/src/test/java/UnifyTest.java +++ b/src/test/java/UnifyTest.java @@ -674,7 +674,1427 @@ public class UnifyTest { UnifyResultModel urm = new UnifyResultModel(cons, finiteClosure); UnifyTaskModel tasks = new UnifyTaskModel(); Set> solution = unifyAlgo.unify(undConstraints, oderConstraints, finiteClosure, new NullWriter(), false, urm, tasks); - System.out.println(solution); + System.out.println(solution.size()); + } + + @Test + public void scalark3(){ + UnifyType type1; + UnifyType type2; + + //und-constraints + Set undConstraints = new HashSet<>(); + //X <. E + type1 = new PlaceholderType("X"); + type2 = new PlaceholderType("E"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //L =. Scalar + type1 = new PlaceholderType("L"); + type2 = new ReferenceType("Scalar"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //F <. E + type1 = new PlaceholderType("F"); + type2 = new PlaceholderType("E"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //H =. Scalar + type1 = new PlaceholderType("H"); + type2 = new ReferenceType("Scalar"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //E >> oderConstraints = new ArrayList<>(); + Set> constraints = new HashSet<>(); + Constraint constraint = new Constraint<>(); + + //set #1 + constraints = new HashSet<>(); + //D =. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("D"); + type2 = new ReferenceType("java.lang.Integer"); + constraints.add(constraint); + //D =. java.lang.Float + constraint = new Constraint<>(); + type1 = new PlaceholderType("D"); + type2 = new ReferenceType("java.lang.Float"); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #2 + constraints = new HashSet<>(); + //F =. java.lang.Float + constraint = new Constraint<>(); + type1 = new PlaceholderType("F"); + type2 = new ReferenceType("java.lang.Float"); + constraints.add(constraint); + //F =. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("F"); + type2 = new ReferenceType("java.lang.Integer"); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #3 + constraints = new HashSet<>(); + //H =. ? extends Scalar + constraint = new Constraint<>(); + type1 = new PlaceholderType("H"); + type2 = new ExtendsType(new ReferenceType("Scalar")); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. J + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("J"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //java.lang.Integer =. J + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("J"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //H =. ? extends Vector + type1 = new PlaceholderType("H"); + type2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJU")))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //java.lang.Integer =. J + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("J"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //H =. Vector + type1 = new PlaceholderType("H"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJU"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //java.lang.Integer =. J + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("J"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //H =. ? extends AbstractList + type1 = new PlaceholderType("H"); + type2 = new ExtendsType(new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("AJT")))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //java.lang.Integer =. J + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("J"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //H =. Scalar + type1 = new PlaceholderType("H"); + type2 = new ReferenceType("Scalar"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //java.lang.Integer =. J + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("J"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //H =. AbstractList + type1 = new PlaceholderType("H"); + type2 = new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("AJT"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #4 + constraints = new HashSet<>(); + //E <. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //L =. Scalar + type1 = new PlaceholderType("L"); + type2 = new ReferenceType("Scalar"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. O + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("O"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //E <. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //AJV =. O + type1 = new PlaceholderType("AJV"); + type2 = new PlaceholderType("O"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //L =. AbstractList + type1 = new PlaceholderType("L"); + type2 = new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("AJV"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //E <. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //java.lang.Integer =. O + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("O"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //L =. ? extends Scalar + type1 = new PlaceholderType("L"); + type2 = new ExtendsType(new ReferenceType("Scalar")); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //E <. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //L =. ? extends AbstractList + type1 = new PlaceholderType("L"); + type2 = new ExtendsType(new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("AJV")))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //AJV =. O + type1 = new PlaceholderType("AJV"); + type2 = new PlaceholderType("O"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //L =. Vector + constraint = new Constraint<>(); + type1 = new PlaceholderType("L"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJW"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //E <. java.lang.Integer + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //AJW =. O + type1 = new PlaceholderType("AJW"); + type2 = new PlaceholderType("O"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //E <. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //AJW =. O + type1 = new PlaceholderType("AJW"); + type2 = new PlaceholderType("O"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //L =. ? extends Vector + type1 = new PlaceholderType("L"); + type2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJW")))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #5 + constraints = new HashSet<>(); + //E <. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //B =. ? extends Scalar + type1 = new PlaceholderType("B"); + type2 = new ExtendsType(new ReferenceType("Scalar")); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. S + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("S"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //AJX =. S + constraint = new Constraint<>(); + type1 = new PlaceholderType("AJX"); + type2 = new PlaceholderType("S"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //E <. java.lang.Integer + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //B =. AbstractList + type1 = new PlaceholderType("B"); + type2 = new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("AJX"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //AJX =. S + constraint = new Constraint<>(); + type1 = new PlaceholderType("AJX"); + type2 = new PlaceholderType("S"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //E <. java.lang.Integer + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //B =. ? extends AbstractList + type1 = new PlaceholderType("B"); + type2 = new ExtendsType(new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("AJX")))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //E <. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //B =. Vector + type1 = new PlaceholderType("B"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJY"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //AJY =. S + type1 = new PlaceholderType("AJY"); + type2 = new PlaceholderType("S"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //E <. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //AJY =. S + type1 = new PlaceholderType("AJY"); + type2 = new PlaceholderType("S"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //B =. ? extends Vector + type1 = new PlaceholderType("B"); + type2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJY")))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //E <. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //java.lang.Integer =. S + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("S"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //B =. Scalar + type1 = new PlaceholderType("B"); + type2 = new ReferenceType("Scalar"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #6 + constraints = new HashSet<>(); + //S <. java.lang.Float + constraint = new Constraint<>(); + type1 = new PlaceholderType("S"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //O <. java.lang.Float + type1 = new PlaceholderType("O"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //java.lang.Float =. U + type1 = new ReferenceType("java.lang.Float"); + type2 = new PlaceholderType("U"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //S <. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("S"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //O <. java.lang.Integer + type1 = new PlaceholderType("O"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //java.lang.Integer =. U + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("U"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #7 + constraints = new HashSet<>(); + //U <. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("U"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //C <. java.lang.Integer + type1 = new PlaceholderType("C"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //java.lang.Integer =. V + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("V"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //C <. java.lang.Float + constraint = new Constraint<>(); + type1 = new PlaceholderType("C"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //U <. java.lang.Float# + type1 = new PlaceholderType("U"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //java.lang.Float =. V + type1 = new ReferenceType("java.lang.Float"); + type2 = new PlaceholderType("V"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #8 + constraints = new HashSet<>(); + //W =. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("W"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //W =. java.lang.Float + constraint = new Constraint<>(); + type1 = new PlaceholderType("W"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #9 + constraints = new HashSet<>(); + //W <. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("W"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //E <. java.lang.Integer + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //java.lang.Integer =. X + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("X"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //W <. java.lang.Float + constraint = new Constraint<>(); + type1 = new PlaceholderType("W"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //E <. java.lang.Float + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //java.lang.Float =. X + type1 = new ReferenceType("java.lang.Float"); + type2 = new PlaceholderType("X"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //FiniteClosure + Set fcConstraints = new HashSet<>(); + //java.lang.Number < java.lang.Object + type1 = new ReferenceType("java.lang.Number"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Number < java.io.Serializable + type1 = new ReferenceType("java.lang.Number"); + type2 = new ReferenceType("java.io.Serializable"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.lang.Number + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.lang.Number"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.lang.Number + type1 = new ReferenceType("java.lang.Float"); + type2 = new ReferenceType("java.lang.Number"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.lang.Object + type1 = new ReferenceType("java.lang.Float"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.lang.constant.Constable + type1 = new ReferenceType("java.lang.Float"); + type2 = new ReferenceType("java.lang.constant.Constable"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.io.Serializable + type1 = new ReferenceType("java.lang.Float"); + type2 = new ReferenceType("java.io.Serializable"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.lang.Comparable + type1 = new ReferenceType("java.lang.Float"); + type2 = new ReferenceType("java.lang.Comparable", new TypeParams(new ReferenceType("java.lang.Float"))); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.lang.constant.ConstantDesc + type1 = new ReferenceType("java.lang.Float"); + type2 = new ReferenceType("java.lang.constant.ConstantDesc"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.lang.Object + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.lang.constant.Constable + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.lang.constant.Constable"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.io.Serializable + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.io.Serializable"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.lang.Comparable + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.lang.Comparable", new TypeParams(new ReferenceType("java.lang.Integer"))); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.lang.constant.ConstantDesc + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.lang.constant.ConstantDesc"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Comparable < java.lang.Object + type1 = new ReferenceType("java.lang.Comparable", new TypeParams(new ReferenceType("java.lang.Float"))); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Vector < java.lang.Object + type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Vector < AbstractList + type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + type2 = new ReferenceType("AbstractList", new TypeParams(new ReferenceType("java.lang.Integer"))); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Scalar < Vector + type1 = new ReferenceType("Scalar"); + type2 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.constant.ConstantDesc < java.lang.Object + type1 = new ReferenceType("java.lang.constant.ConstantDesc"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Scalar < java.lang.Object + type1 = new ReferenceType("Scalar"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Scalar < AbstractList + type1 = new ReferenceType("Scalar"); + type2 = new ReferenceType("AbstractList", new TypeParams(new ReferenceType("java.lang.Integer"))); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Vector < AbstractList + type1 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("EXP"))); + type2 = new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("EXP"))); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Vector < java.lang.Object + type1 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("EXP"))); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.constant.Constable < java.lang.Object + type1 = new ReferenceType("java.lang.constant.Constable"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.io.Serializable < java.lang.Object + type1 = new ReferenceType("java.io.Serializable"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //AbstractList < java.lang.Object + type1 = new ReferenceType("AbstractList", new TypeParams(new ReferenceType("java.lang.Integer"))); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Comparable < java.lang.Object + type1 = new ReferenceType("java.lang.Comparable", new TypeParams(new ReferenceType("java.lang.Integer"))); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + + FiniteClosure finiteClosure = new FiniteClosure(fcConstraints, new NullWriter()); + TypeUnify unifyAlgo = new TypeUnify(); + ConstraintSet< Pair> cons = new ConstraintSet<>(); + UnifyResultModelParallel urm = new UnifyResultModelParallel(cons, finiteClosure); + UnifyTaskModelParallel tasks = new UnifyTaskModelParallel(); + Set> solution = unifyAlgo.unify(undConstraints, oderConstraints, finiteClosure, new NullWriter(), false, urm, tasks); + System.out.println(solution.size()); + } + + @Test + public void matrixk2(){ + UnifyType type1; + UnifyType type2; + + //und-constraints + Set undConstraints = new HashSet<>(); + //T =. BC + type1 = new PlaceholderType("T"); + type2 = new PlaceholderType("BC"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Boolean =. G + type1 = new ReferenceType("java.lang.Boolean"); + type2 = new PlaceholderType("G"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //G =. java.lang.Boolean + type1 = new PlaceholderType("G"); + type2 = new ReferenceType("java.lang.Boolean"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //F <. E + type1 = new PlaceholderType("F"); + type2 = new PlaceholderType("E"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //E =. BJ + type1 = new PlaceholderType("E"); + type2 = new PlaceholderType("BJ"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //Vector <. R + type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + type2 = new PlaceholderType("R"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //P <. L + type1 = new PlaceholderType("P"); + type2 = new PlaceholderType("L"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //E >> oderConstraints = new ArrayList<>(); + Set> constraints = new HashSet<>(); + Constraint constraint = new Constraint<>(); + + //set #1 + constraints = new HashSet<>(); + //Matrix <. Matrix + constraint = new Constraint<>(); + type1 = new ReferenceType("Matrix"); + type2 = new ReferenceType("Matrix"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #2 + constraints = new HashSet<>(); + //F =. java.lang.Float + constraint = new Constraint<>(); + type1 = new PlaceholderType("F"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //F =. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("F"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #3 + constraints = new HashSet<>(); + //H =. ? extends Matrix + constraint = new Constraint<>(); + type1 = new PlaceholderType("H"); + type2 = new ExtendsType(new ReferenceType("Matrix")); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. J + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("J"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //H =. Vector + constraint = new Constraint<>(); + type1 = new PlaceholderType("H"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("ALB"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. J + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("J"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //H =. Matrix + constraint = new Constraint<>(); + type1 = new PlaceholderType("H"); + type2 = new ReferenceType("Matrix"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. J + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("J"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //H =. ? extends Vector + constraint = new Constraint<>(); + type1 = new PlaceholderType("H"); + type2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(new PlaceholderType("ALB")))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. J + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("J"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #4 + constraints = new HashSet<>(); + //ALC =. P + constraint = new Constraint<>(); + type1 = new PlaceholderType("ALC"); + type2 = new PlaceholderType("P"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //M =. Vector + type1 = new PlaceholderType("M"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("ALC"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //E <. java.lang.Integer + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + //Vector =. P + constraint = new Constraint<>(); + type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + type2 = new PlaceholderType("P"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //M =. ? extends Matrix + type1 = new PlaceholderType("M"); + type2 = new ExtendsType(new ReferenceType("Matrix")); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //E <. java.lang.Integer + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + //Vector =. P + constraint = new Constraint<>(); + type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + type2 = new PlaceholderType("P"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //M =. Matrix + type1 = new PlaceholderType("M"); + type2 = new ReferenceType("Matrix"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //E <. java.lang.Integer + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + //ALC =. P + constraint = new Constraint<>(); + type1 = new PlaceholderType("ALC"); + type2 = new PlaceholderType("P"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //M =. ? extends Vector + type1 = new PlaceholderType("M"); + type2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(new PlaceholderType("ALC")))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //E <. java.lang.Integer + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #5 + constraints = new HashSet<>(); + //Vector <. Vector + constraint = new Constraint<>(); + type1 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("ALD"))); + type2 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #6 + constraints = new HashSet<>(); + //U =. java.lang.Float + constraint = new Constraint<>(); + type1 = new PlaceholderType("U"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //U =. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("U"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #7 + constraints = new HashSet<>(); + //L =. ? extends Matrix + constraint = new Constraint<>(); + type1 = new PlaceholderType("L"); + type2 = new ExtendsType(new ReferenceType("Matrix")); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. X + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("X"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //L =. ? extends Vector + constraint = new Constraint<>(); + type1 = new PlaceholderType("L"); + type2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(new PlaceholderType("AMH")))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. X + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("X"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //L =. Matrix + constraint = new Constraint<>(); + type1 = new PlaceholderType("L"); + type2 = new ReferenceType("Matrix"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. X + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("X"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //L =. Vector + constraint = new Constraint<>(); + type1 = new PlaceholderType("L"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("AMH"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. X + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("X"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #8 + constraints = new HashSet<>(); + //AA =. java.lang.Float + constraint = new Constraint<>(); + type1 = new PlaceholderType("AA"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //AA =. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("AA"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #9 + constraints = new HashSet<>(); + //AC =. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("AC"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //AC =. java.lang.Float + constraint = new Constraint<>(); + type1 = new PlaceholderType("AC"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #10 + constraints = new HashSet<>(); + //L =. ? extends Matrix + constraint = new Constraint<>(); + type1 = new PlaceholderType("L"); + type2 = new ExtendsType(new ReferenceType("Matrix")); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. AF + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("AF"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //L =. ? extends Vector + constraint = new Constraint<>(); + type1 = new PlaceholderType("L"); + type2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(new PlaceholderType("ANL")))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. AF + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("AF"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //L =. Matrix + constraint = new Constraint<>(); + type1 = new PlaceholderType("L"); + type2 = new ReferenceType("Matrix"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. AF + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("AF"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //L =. Vector + constraint = new Constraint<>(); + type1 = new PlaceholderType("L"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("ANL"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. AF + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("AF"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #11 + constraints = new HashSet<>(); + //Vector =. AJ + constraint = new Constraint<>(); + type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + type2 = new PlaceholderType("AJ"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //L =. Matrix + type1 = new PlaceholderType("L"); + type2 = new ReferenceType("Matrix"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //AB <. java.lang.Integer + type1 = new PlaceholderType("AB"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + //ANM =. AJ + constraint = new Constraint<>(); + type1 = new PlaceholderType("ANM"); + type2 = new PlaceholderType("AJ"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //L =. ? extends Vector + type1 = new PlaceholderType("L"); + type2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(new PlaceholderType("ANM")))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //AB <. java.lang.Integer + type1 = new PlaceholderType("AB"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + //Vector =. AJ + constraint = new Constraint<>(); + type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + type2 = new PlaceholderType("AJ"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //L =. ? extends Matrix + type1 = new PlaceholderType("L"); + type2 = new ExtendsType(new ReferenceType("Matrix")); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //AB <. java.lang.Integer + type1 = new PlaceholderType("AB"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + //ANM =. AJ + constraint = new Constraint<>(); + type1 = new PlaceholderType("ANM"); + type2 = new PlaceholderType("AJ"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //L =. Vector + type1 = new PlaceholderType("L"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("ANM"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //AB <. java.lang.Integer + type1 = new PlaceholderType("AB"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #12 + constraints = new HashSet<>(); + //AB <. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("AB"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //Vector =. AN + type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + type2 = new PlaceholderType("AN"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //B =. Matrix + type1 = new PlaceholderType("B"); + type2 = new ReferenceType("Matrix"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //ANN =. AN + constraint = new Constraint<>(); + type1 = new PlaceholderType("ANN"); + type2 = new PlaceholderType("AN"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //AB <. java.lang.Integer + type1 = new PlaceholderType("AB"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //B =. ? extends Vector + type1 = new PlaceholderType("B"); + type2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(new PlaceholderType("ANN")))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //B =. Vector + constraint = new Constraint<>(); + type1 = new PlaceholderType("B"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("ANN"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //ANN =. AN + type1 = new PlaceholderType("ANN"); + type2 = new PlaceholderType("AN"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //AB <. java.lang.Integer + type1 = new PlaceholderType("AB"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + //B =. ? extends Matrix + constraint = new Constraint<>(); + type1 = new PlaceholderType("B"); + type2 = new ExtendsType(new ReferenceType("Matrix")); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //AB <. java.lang.Integer + type1 = new PlaceholderType("AB"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //Vector =. AN + type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + type2 = new PlaceholderType("AN"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #13 + constraints = new HashSet<>(); + //Vector =. AR + constraint = new Constraint<>(); + type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + type2 = new PlaceholderType("AR"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //AN =. ? extends Matrix + type1 = new PlaceholderType("AN"); + type2 = new ExtendsType(new ReferenceType("Matrix")); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //T <. java.lang.Integer + type1 = new PlaceholderType("T"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + //AN =. ? extends Vector + constraint = new Constraint<>(); + type1 = new PlaceholderType("AN"); + type2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(new PlaceholderType("ANO")))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //ANO =. AR + type1 = new PlaceholderType("ANO"); + type2 = new PlaceholderType("AR"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //T <. java.lang.Integer + type1 = new PlaceholderType("T"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + //AN =. Vector + constraint = new Constraint<>(); + type1 = new PlaceholderType("AN"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("ANO"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //ANO =. AR + type1 = new PlaceholderType("ANO"); + type2 = new PlaceholderType("AR"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //T <. java.lang.Integer + type1 = new PlaceholderType("T"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + //AN =. Matrix + constraint = new Constraint<>(); + type1 = new PlaceholderType("AN"); + type2 = new ReferenceType("Matrix"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //Vector =. AR + type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + type2 = new PlaceholderType("AR"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //T <. java.lang.Integer + type1 = new PlaceholderType("T"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #14 + constraints = new HashSet<>(); + //java.lang.Integer =. AT + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("AT"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //AJ <. java.lang.Integer + type1 = new PlaceholderType("AJ"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //AR <. java.lang.Integer + type1 = new PlaceholderType("AR"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + //java.lang.Float =. AT + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Float"); + type2 = new PlaceholderType("AT"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //AR <. java.lang.Float + type1 = new PlaceholderType("AR"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //AJ <. java.lang.Float + type1 = new PlaceholderType("AJ"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #15 + constraints = new HashSet<>(); + //java.lang.Float =. AU + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Float"); + type2 = new PlaceholderType("AU"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //AT <. java.lang.Float + type1 = new PlaceholderType("AT"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //Z <. java.lang.Float + type1 = new PlaceholderType("Z"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + //java.lang.Integer =. AU + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("AU"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //Z <. java.lang.Integer + type1 = new PlaceholderType("Z"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //AT <. java.lang.Integer + type1 = new PlaceholderType("AT"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #16 + constraints = new HashSet<>(); + //Z <. ANP + constraint = new Constraint<>(); + type1 = new PlaceholderType("Z"); + type2 = new PlaceholderType("ANP"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //R =. ? extends Vector + type1 = new PlaceholderType("R"); + type2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(new PlaceholderType("ANP")))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Boolean =. BA + type1 = new ReferenceType("java.lang.Boolean"); + type2 = new PlaceholderType("BA"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //R =. ? extends Matrix + constraint = new Constraint<>(); + type1 = new PlaceholderType("R"); + type2 = new ExtendsType(new ReferenceType("Matrix")); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //Z <. Vector + type1 = new PlaceholderType("Z"); + type2 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //java.lang.Boolean =. BA + type1 = new ReferenceType("java.lang.Boolean"); + type2 = new PlaceholderType("BA"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //Z <. ANP + constraint = new Constraint<>(); + type1 = new PlaceholderType("Z"); + type2 = new PlaceholderType("ANP"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //R =. Vector + type1 = new PlaceholderType("R"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("ANP"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Boolean =. BA + type1 = new ReferenceType("java.lang.Boolean"); + type2 = new PlaceholderType("BA"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //Z <. Vector + constraint = new Constraint<>(); + type1 = new PlaceholderType("Z"); + type2 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //java.lang.Boolean =. BA + type1 = new ReferenceType("java.lang.Boolean"); + type2 = new PlaceholderType("BA"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //R =. Matrix + type1 = new PlaceholderType("R"); + type2 = new ReferenceType("Matrix"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #17 + constraints = new HashSet<>(); + //R <. Vector + constraint = new Constraint<>(); + type1 = new PlaceholderType("R"); + type2 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //C =. ? extends Matrix + type1 = new PlaceholderType("C"); + type2 = new ExtendsType(new ReferenceType("Matrix")); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Boolean =. BH + type1 = new ReferenceType("java.lang.Boolean"); + type2 = new PlaceholderType("BH"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //java.lang.Boolean =. BH + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Boolean"); + type2 = new PlaceholderType("BH"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //R <. ANQ + type1 = new PlaceholderType("R"); + type2 = new PlaceholderType("ANQ"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //C =. Vector + type1 = new PlaceholderType("C"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("ANQ"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //R <. Vector + constraint = new Constraint<>(); + type1 = new PlaceholderType("R"); + type2 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //java.lang.Boolean =. BH + type1 = new ReferenceType("java.lang.Boolean"); + type2 = new PlaceholderType("BH"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //C =. Matrix + type1 = new PlaceholderType("C"); + type2 = new ReferenceType("Matrix"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //java.lang.Boolean =. BH + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Boolean"); + type2 = new PlaceholderType("BH"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //C =. ? extends Vector + type1 = new PlaceholderType("C"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("ANQ"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //R <. ANQ + type1 = new PlaceholderType("R"); + type2 = new PlaceholderType("ANQ"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //FiniteClosure + Set fcConstraints = new HashSet<>(); + //java.lang.Number < java.lang.Object + type1 = new ReferenceType("java.lang.Number"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Number < java.io.Serializable + type1 = new ReferenceType("java.lang.Number"); + type2 = new ReferenceType("java.io.Serializable"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.lang.Number + type1 = new ReferenceType("java.lang.Float"); + type2 = new ReferenceType("java.lang.Number"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.lang.Number + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.lang.Number"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.lang.Object + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.lang.constant.Constable + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.lang.constant.Constable"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.io.Serializable + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.io.Serializable"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.lang.constant.ConstantDesc + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.lang.constant.ConstantDesc"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.lang.Comparable + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.lang.Comparable", new TypeParams(new ReferenceType("java.lang.Integer"))); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.lang.Object + type1 = new ReferenceType("java.lang.Float"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.lang.constant.Constable + type1 = new ReferenceType("java.lang.Float"); + type2 = new ReferenceType("java.lang.constant.Constable"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.io.Serializable + type1 = new ReferenceType("java.lang.Float"); + type2 = new ReferenceType("java.io.Serializable"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.lang.Comparable + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.lang.Comparable", new TypeParams(new ReferenceType("java.lang.Float"))); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.lang.constant.ConstantDesc + type1 = new ReferenceType("java.lang.Float"); + type2 = new ReferenceType("java.lang.constant.ConstantDesc"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Vector < java.lang.Object + type1 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("FAU"))); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Scalar < java.lang.Object + type1 = new ReferenceType("Scalar", new TypeParams(new PlaceholderType("FCV"))); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Scalar < Vector + type1 = new ReferenceType("Scalar", new TypeParams(new PlaceholderType("FCV"))); + type2 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Comparable < java.lang.Object + type1 = new ReferenceType("java.lang.Comparable", new TypeParams(new ReferenceType("java.lang.Float"))); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Vector < java.lang.Object + type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Scalar < Vector + type1 = new ReferenceType("Scalar", new TypeParams(new PlaceholderType("FCV"))); + type2 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.constant.ConstantDesc < java.lang.Object + type1 = new ReferenceType("java.lang.constant.ConstantDesc"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.constant.Constable < java.lang.Object + type1 = new ReferenceType("java.lang.constant.Constable"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.io.Serializable < java.lang.Object + type1 = new ReferenceType("java.io.Serializable"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Vector> < java.lang.Object + type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))))); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Matrix < Vector> + type1 = new ReferenceType("Matrix"); + type2 = new ReferenceType("Vector", new TypeParams(new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))))); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Matrix < java.lang.Object + type1 = new ReferenceType("Matrix"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Comparable < java.lang.Object + type1 = new ReferenceType("java.lang.Comparable", new TypeParams(new ReferenceType("java.lang.Integer"))); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + + FiniteClosure finiteClosure = new FiniteClosure(fcConstraints, new NullWriter()); + TypeUnify unifyAlgo = new TypeUnify(); + ConstraintSet< Pair> cons = new ConstraintSet<>(); + UnifyResultModelParallel urm = new UnifyResultModelParallel(cons, finiteClosure); + UnifyTaskModelParallel tasks = new UnifyTaskModelParallel(); + Set> solution = unifyAlgo.unify(undConstraints, oderConstraints, finiteClosure, new NullWriter(), false, urm, tasks); System.out.println(solution.size()); } }