remove superfluous unification step

This commit is contained in:
Johanna Stuber 2021-03-04 19:06:53 +01:00
parent 6cea905dc4
commit 3acdc46bef
2 changed files with 5 additions and 3 deletions

View File

@ -91,8 +91,11 @@ public class LatexCreatorConstraints implements StepVisitor {
numberGenerator.push();
});
typeInferer.getMGU().ifPresent(mgu -> {
result.add(generateMGU(constraintSets));
numberGenerator.push();
// avoid superfluous step if unification only has one step (that equals the mgu)
if (typeInferer.getUnificationSteps().get().size() > 2) {
result.add(generateMGU(constraintSets));
numberGenerator.push();
}
result.add(generateMGU(constraintSets) + LATEX_NEW_LINE + generateFinalType());
numberGenerator.push();
});

View File

@ -39,7 +39,6 @@ class LatexCreatorConstraintsTest {
+ TREE_VARIABLE + "_{1}" + EQUALS + GENERATED_ASSUMPTION_VARIABLE + "_{1}" + LATEX_CURLY_RIGHT
+ PAREN_RIGHT + SPLIT_END + ALIGN_END,
ALIGN_BEGIN + constraintSet + MGU_START + mgu + ALIGN_END,
ALIGN_BEGIN + constraintSet + MGU_START + mgu + ALIGN_END,
ALIGN_BEGIN + constraintSet + MGU_START + mgu + LATEX_NEW_LINE + AMPERSAND + SIGMA + PAREN_LEFT
+ TREE_VARIABLE + "_{1}" + PAREN_RIGHT + EQUALS + GENERATED_ASSUMPTION_VARIABLE
+ "_{1}" + ALIGN_END);