File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
liquidjava-verifier/src/main/java/liquidjava Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 55import java .util .stream .Collectors ;
66
77import liquidjava .diagnostics .TranslationTable ;
8+ import liquidjava .rj_language .ast .Expression ;
89import liquidjava .rj_language .opt .derivation_node .ValDerivationNode ;
910import liquidjava .smt .Counterexample ;
1011import liquidjava .utils .VariableFormatter ;
@@ -46,16 +47,17 @@ public String getCounterExampleString() {
4647
4748 List <String > foundVarNames = new ArrayList <>();
4849 found .getValue ().getVariableNames (foundVarNames );
50+ List <String > foundAssignments = found .getValue ().getConjuncts ().stream ().map (Expression ::toString ).toList ();
4951 String counterexampleString = counterexample .assignments ().stream ()
50- // only include variables that appear in the found value
51- .filter (a -> foundVarNames .contains (a .first ()))
52+ // only include variables that appear in the found value and are not already fixed there
53+ .filter (a -> foundVarNames .contains (a .first ())
54+ && !foundAssignments .contains (a .first () + " == " + a .second ()))
5255 // format as "var == value"
5356 .map (a -> VariableFormatter .formatVariable (a .first ()) + " == " + a .second ())
5457 // join with "&&"
5558 .collect (Collectors .joining (" && " ));
5659
57- String foundString = VariableFormatter .formatText (found .getValue ().toString ());
58- if (counterexampleString .isEmpty () || counterexampleString .equals (foundString ))
60+ if (counterexampleString .isEmpty ())
5961 return null ;
6062
6163 return counterexampleString ;
Original file line number Diff line number Diff line change @@ -81,6 +81,16 @@ public boolean isBooleanExpression() {
8181 return false ;
8282 }
8383
84+ public List <Expression > getConjuncts () {
85+ if (this instanceof BinaryExpression binaryExpression && "&&" .equals (binaryExpression .getOperator ())) {
86+ List <Expression > conjuncts = new ArrayList <>();
87+ conjuncts .addAll (binaryExpression .getFirstOperand ().getConjuncts ());
88+ conjuncts .addAll (binaryExpression .getSecondOperand ().getConjuncts ());
89+ return conjuncts ;
90+ }
91+ return List .of (this );
92+ }
93+
8494 /**
8595 * Substitutes the expression first given expression by the second
8696 *
You can’t perform that action at this time.
0 commit comments