@@ -73,8 +73,9 @@ public Set<String> trueBindersToKeep(VCImplication chain) {
7373 }
7474
7575 /**
76- * Binders whose refinement shares no term with expected, directly or through other facts of the chain, and whose
77- * variable no other row mentions: expected does not depend on them. None without expected terms
76+ * Binders that share no term with expected, neither their variable nor a term of their refinement, directly or
77+ * through other facts of the chain, and whose variable no other row mentions: expected does not depend on them.
78+ * None without expected terms
7879 */
7980 public Set <String > unlinkedBinders (VCImplication chain ) {
8081 Set <String > unlinked = new HashSet <>();
@@ -83,12 +84,16 @@ public Set<String> unlinkedBinders(VCImplication chain) {
8384 List <Expression > facts = factsOf (chain .toPredicate ().getExpression ());
8485 Set <String > linked = linkedTerms (facts , expectedTerms , VCSimplificationUtils ::termsOf );
8586 for (VCImplication row = chain ; row != null ; row = row .getNext ())
86- if (row .hasBinder () && termsOf (row .getRefinement ().getExpression ()).stream ().noneMatch (linked ::contains )
87- && !mentionedByOtherRows (chain , row ))
87+ if (row .hasBinder () && !isLinked (row , linked ) && !mentionedByOtherRows (chain , row ))
8888 unlinked .add (row .getName ());
8989 return unlinked ;
9090 }
9191
92+ private static boolean isLinked (VCImplication row , Set <String > linked ) {
93+ return linked .contains (row .getName ())
94+ || termsOf (row .getRefinement ().getExpression ()).stream ().anyMatch (linked ::contains );
95+ }
96+
9297 private static boolean mentionedByOtherRows (VCImplication chain , VCImplication row ) {
9398 for (VCImplication other = chain ; other != null ; other = other .getNext ())
9499 if (other != row && containsVar (other .getRefinement ().getExpression (), row .getName ()))
0 commit comments