unify case 1

This commit is contained in:
Florian Steurer 2016-03-17 16:35:33 +01:00
parent d19a79bd63
commit fa9627b883
3 changed files with 36 additions and 31 deletions

View File

@ -144,6 +144,7 @@ public class FiniteClosure implements IFiniteClosure {
return new HashSet<Type>(); return new HashSet<Type>();
Set<Type> result = new HashSet<Type>(); Set<Type> result = new HashSet<Type>();
result.add(type);
Type t = type.getExtendedType(); Type t = type.getExtendedType();
@ -158,6 +159,7 @@ public class FiniteClosure implements IFiniteClosure {
return new HashSet<Type>(); return new HashSet<Type>();
Set<Type> result = new HashSet<Type>(); Set<Type> result = new HashSet<Type>();
result.add(type);
Type t = type.getSuperedType(); Type t = type.getSuperedType();
@ -194,6 +196,7 @@ public class FiniteClosure implements IFiniteClosure {
return new HashSet<Type>(); return new HashSet<Type>();
Set<Type> result = new HashSet<Type>(); Set<Type> result = new HashSet<Type>();
result.add(type);
Type t = type.getExtendedType(); Type t = type.getExtendedType();
@ -213,6 +216,7 @@ public class FiniteClosure implements IFiniteClosure {
return new HashSet<Type>(); return new HashSet<Type>();
Set<Type> result = new HashSet<Type>(); Set<Type> result = new HashSet<Type>();
result.add(type);
Type t = type.getSuperedType(); Type t = type.getSuperedType();

View File

@ -232,14 +232,14 @@ public class Unify {
Set<MPair> set = new HashSet<>(); Set<MPair> set = new HashSet<>();
IUnify unify = new MartelliMontanariUnify(); IUnify unify = new MartelliMontanariUnify();
//Set<Type> cs = fc.getAllTypes(rhsType.getName()); Set<Type> cs = fc.getAllTypes(rhsType.getName());
Type c = rhsType;
//Set<Type> thetaQs = cs.stream().flatMap(x -> fc.smaller(x).stream()).collect(Collectors.toCollection(HashSet::new)); Set<Type> thetaQs = cs.stream().flatMap(
Set<Type> thetaQs = fc.smaller(c); x -> fc.smaller(x).stream().filter(y -> y.getTypeParams().arePlaceholders())
).collect(Collectors.toCollection(HashSet::new));
for(Type c : cs) {
Set<Type> thetaQPrimes = new HashSet<>(); Set<Type> thetaQPrimes = new HashSet<>();
TypeParams cParams = c.getTypeParams(); TypeParams cParams = c.getTypeParams();
if(cParams.size() == 0) if(cParams.size() == 0)
thetaQPrimes.add(c); thetaQPrimes.add(c);
@ -267,6 +267,7 @@ public class Unify {
} }
} }
} }
}
result.add(set); result.add(set);
} }

View File

@ -38,7 +38,7 @@ public class UnifyTest extends Unify {
eq.add(new MPair(tf.getSimpleType("Vector", tf.getSimpleType("Integer")), tf.getSimpleType("Vector", "A"), PairOperator.SMALLERDOT)); eq.add(new MPair(tf.getSimpleType("Vector", tf.getSimpleType("Integer")), tf.getSimpleType("Vector", "A"), PairOperator.SMALLERDOT));
//eq.add(new MPair(tf.getSimpleType("Vector", tf.getSimpleType("Number")), tf.getSimpleType("Vector", "A"), PairOperator.SMALLERDOT)); //eq.add(new MPair(tf.getSimpleType("Vector", tf.getSimpleType("Number")), tf.getSimpleType("Vector", "A"), PairOperator.SMALLERDOT));
//eq.add(new MPair(tf.getSimpleType("Vector", tf.getSimpleType("Integer")), tf.getSimpleType("Vector", "C"), PairOperator.SMALLERDOT)); //eq.add(new MPair(tf.getSimpleType("Vector", tf.getSimpleType("Integer")), tf.getSimpleType("Vector", "C"), PairOperator.SMALLERDOT));
eq.add(new MPair(tf.getPlaceholderType("A"), tf.getSimpleType("List", tf.getSimpleType("Number")), PairOperator.SMALLERDOT)); eq.add(new MPair(tf.getPlaceholderType("A"), tf.getSimpleType("Number"), PairOperator.SMALLERDOT));
//eq.add(new MPair(tf.getSimpleType("Number"), tf.getPlaceholderType("A"), PairOperator.SMALLERDOT)); //eq.add(new MPair(tf.getSimpleType("Number"), tf.getPlaceholderType("A"), PairOperator.SMALLERDOT));
//eq.add(new MPair(tf.getPlaceholderType("A"), tf.getPlaceholderType("C"), PairOperator.SMALLERDOT)); //eq.add(new MPair(tf.getPlaceholderType("A"), tf.getPlaceholderType("C"), PairOperator.SMALLERDOT));
//eq.add(new MPair(tf.getSimpleType("Double"), tf.getPlaceholderType("B"), PairOperator.SMALLERDOT)); //eq.add(new MPair(tf.getSimpleType("Double"), tf.getPlaceholderType("B"), PairOperator.SMALLERDOT));