File tree Expand file tree Collapse file tree
liquidjava-verifier/src/main/java/liquidjava/diagnostics Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import liquidjava .rj_language .ast .BinaryExpression ;
1010import liquidjava .rj_language .ast .Expression ;
1111import liquidjava .rj_language .ast .GroupExpression ;
12+ import liquidjava .smt .Counterexample ;
1213import liquidjava .utils .Utils ;
1314import spoon .reflect .cu .SourcePosition ;
1415import spoon .reflect .reference .CtTypeReference ;
@@ -130,6 +131,16 @@ public static void simplificationInput(Predicate predicate) {
130131 System .out .println (SMT_TAG + " unsimplified: " + predicate );
131132 }
132133
134+ public static void counterexampleAssignments (Counterexample counterexample ) {
135+ if (!enabled () || counterexample == null || counterexample .assignments ().isEmpty ()) {
136+ return ;
137+ }
138+ System .out .println (SMT_TAG + " counterexample assignments:" );
139+ for (var assignment : counterexample .assignments ()) {
140+ System .out .println (SMT_TAG + " " + assignment .first () + " = " + assignment .second ());
141+ }
142+ }
143+
133144 private static String plainLabel (VCImplication node ) {
134145 return node .getName () + " : " + simpleType (node .getType ());
135146 }
Original file line number Diff line number Diff line change 44import java .util .List ;
55import java .util .stream .Collectors ;
66
7- import liquidjava .api . CommandLineLauncher ;
7+ import liquidjava .diagnostics . DebugLog ;
88import liquidjava .diagnostics .TranslationTable ;
99import liquidjava .rj_language .ast .Expression ;
1010import liquidjava .rj_language .ast .formatter .VariableFormatter ;
@@ -44,6 +44,8 @@ public String getCounterExampleString() {
4444 if (counterexample == null || counterexample .assignments ().isEmpty ())
4545 return null ;
4646
47+ DebugLog .counterexampleAssignments (counterexample );
48+
4749 List <String > foundVarNames = new ArrayList <>();
4850 found .getValue ().getVariableNames (foundVarNames );
4951 // also keep resolved static-final constants (e.g. Integer.MAX_VALUE) referenced by either side of the
@@ -53,8 +55,8 @@ public String getCounterExampleString() {
5355 List <String > foundAssignments = found .getValue ().getConjuncts ().stream ().map (Expression ::toString ).toList ();
5456 String counterexampleString = counterexample .assignments ().stream ()
5557 // only include variables that appear in the found value and are not already fixed there
56- .filter (a -> CommandLineLauncher . cmdArgs . debugMode || ( foundVarNames .contains (a .first ())
57- && !foundAssignments .contains (a .first () + " == " + a .second ())))
58+ .filter (a -> foundVarNames .contains (a .first ())
59+ && !foundAssignments .contains (a .first () + " == " + a .second ()))
5860 // format as "var == value"
5961 .map (a -> VariableFormatter .format (a .first ()) + " == " + a .second ())
6062 // join with "&&"
You can’t perform that action at this time.
0 commit comments