File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
liquidjava-verifier/src/main/java/liquidjava/diagnostics/errors Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 11package liquidjava .diagnostics .errors ;
22
3+ import java .util .List ;
4+ import java .util .stream .Collectors ;
5+
36import liquidjava .diagnostics .TranslationTable ;
47import liquidjava .rj_language .opt .derivation_node .ValDerivationNode ;
58import liquidjava .smt .Counterexample ;
@@ -37,11 +40,23 @@ public String getCounterExampleString() {
3740 if (counterexample == null || counterexample .assignments ().isEmpty ())
3841 return null ;
3942
43+ // filter out assignments of variables that do not appear in the found value
44+ String foundValue = found .getValue ().toString ();
45+ List <String > relevantAssignments = counterexample .assignments ().stream ()
46+ .filter (a -> {
47+ String varName = a .contains (" == " ) ? a .substring (0 , a .indexOf (" == " )).trim () : a ;
48+ return foundValue .contains (varName );
49+ })
50+ .collect (Collectors .toList ());
51+
52+ if (relevantAssignments .isEmpty ())
53+ return null ;
54+
4055 // join assignements with &&
41- String counterexampleExp = String .join (" && " , counterexample . assignments () );
56+ String counterexampleExp = String .join (" && " , relevantAssignments );
4257
4358 // check if counterexample is trivial (same as the found value)
44- if (counterexampleExp .equals (found . getValue (). toString () ))
59+ if (counterexampleExp .equals (foundValue ))
4560 return null ;
4661
4762 return counterexampleExp ;
You can’t perform that action at this time.
0 commit comments