forked from JavaTX/JavaCompilerCore
cartesian products
This commit is contained in:
parent
97e0e2fc72
commit
53dd7b019e
@ -54,13 +54,18 @@ public class Unify {
|
||||
List<List<Set<MPair>>> pairSetsSet = calculatePairSets(eq2s, fc);
|
||||
|
||||
// The sets of the "first level"
|
||||
Set<Set<MPair>> sets = new HashSet<Set<MPair>>();
|
||||
sets.add(eq1s); // Add Eq1'
|
||||
Set<Set<?>> sets = new HashSet<Set<?>>();
|
||||
|
||||
if(eq1s.size() != 0)
|
||||
sets.add(eq1s); // Add Eq1'
|
||||
|
||||
// Add the set of [a =. Theta | (a=. Theta) in Eq2']
|
||||
sets.add(eq2s.stream()
|
||||
Set<MPair> bufferSet = eq2s.stream()
|
||||
.filter(x -> x.getPairOp() == PairOperator.EQUALSDOT && x.getLhsType() instanceof PlaceholderType)
|
||||
.collect(Collectors.toSet()));
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if(bufferSet.size() != 0)
|
||||
sets.add(bufferSet);
|
||||
|
||||
/* Up to here, no cartesian products are calculated.
|
||||
* Around here, filters for pairs and sets can be applied */
|
||||
@ -69,13 +74,19 @@ public class Unify {
|
||||
|
||||
// Calculate the inner cartesian products
|
||||
// Cartesian products of the second level
|
||||
|
||||
// AddAll -> nur add
|
||||
for(List<Set<MPair>> pairSets : pairSetsSet) // Prüfen ob addAll stimmt oder ob hier eigentlich nur 1 set sein sollte
|
||||
setOps.cartesianProduct(pairSets).forEach(x -> sets.add(new HashSet<MPair>(x)));
|
||||
sets.add(setOps.cartesianProduct(pairSets).stream().map(x -> new HashSet<>(x)).collect(Collectors.toSet()));
|
||||
|
||||
System.out.println(sets);
|
||||
|
||||
// Calculate the outer cartesian products
|
||||
// Cartesian products of the first level
|
||||
Set<List<MPair>> eqsSet = setOps.cartesianProduct(new ArrayList<>(sets));
|
||||
Set<List<Object>> eqsSet = setOps.cartesianProduct(new ArrayList<>(sets));
|
||||
|
||||
|
||||
System.out.println(eqsSet);
|
||||
/*
|
||||
* Step 5: Substitution
|
||||
*/
|
||||
@ -90,7 +101,8 @@ public class Unify {
|
||||
* Step 7: Filter result for solved pairs
|
||||
*/
|
||||
|
||||
throw new NotImplementedException();
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
protected Set<MPair> applyTypeUnificationRules(Set<MPair> eq, IFiniteClosure fc) {
|
||||
|
@ -25,12 +25,14 @@ public class UnifyTest extends Unify {
|
||||
IFiniteClosure fc = fcb.getCollectionExample();
|
||||
|
||||
// Vector<Integer> <. Vector<A>
|
||||
// Vector<Integer <. Vector<C>
|
||||
// A <. Number
|
||||
// Double <. B
|
||||
// B <. Object
|
||||
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", "C"), PairOperator.SMALLERDOT));
|
||||
eq.add(new MPair(tf.getPlaceholderType("A"), tf.getSimpleType("Number"), 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.getPlaceholderType("B"), tf.getSimpleType("Object"), PairOperator.EQUALSDOT));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user