22
33import java .util .ArrayList ;
44import java .util .List ;
5+ import java .util .stream .Collectors ;
56
67import liquidjava .api .CommandLineLauncher ;
78import liquidjava .processor .VCImplication ;
89import liquidjava .rj_language .Predicate ;
910import liquidjava .rj_language .ast .BinaryExpression ;
1011import liquidjava .rj_language .ast .Expression ;
1112import liquidjava .rj_language .ast .GroupExpression ;
13+ import liquidjava .rj_language .opt .derivation_node .ValDerivationNode ;
1214import liquidjava .smt .Counterexample ;
1315import liquidjava .utils .Utils ;
1416import spoon .reflect .cu .SourcePosition ;
@@ -30,6 +32,7 @@ public final class DebugLog {
3032
3133 private static final String SMT_TAG = Colors .BLUE + "[SMT]" + Colors .RESET ;
3234 private static final String SMT_CHECK = Colors .SALMON + "[SMT CHECK]" + Colors .RESET ;
35+ private static final String SMP_TAG = Colors .YELLOW + "[SMP]" + Colors .RESET ;
3336
3437 private DebugLog () {
3538 }
@@ -124,21 +127,31 @@ public static void smtStart(VCImplication chain, Predicate extraPremise, Predica
124127 System .out .println (SMT_TAG + " " + formatConclusion (conclusion ));
125128 }
126129
127- public static void simplificationInput (Predicate predicate ) {
130+ /**
131+ * Print the simplifier input and output side by side. This keeps the raw expression visible in debug traces while
132+ * callers continue using the simplified expression for user-facing diagnostics.
133+ */
134+ public static void simplification (Expression input , Expression output ) {
128135 if (!enabled ()) {
129136 return ;
130137 }
131- System .out .println (SMT_TAG + " unsimplified: " + predicate );
138+ System .out .println (SMP_TAG + " Simplified " + Colors .CYAN + input + Colors .RESET + " to " + Colors .YELLOW
139+ + output + Colors .RESET );
132140 }
133141
134- public static void counterexampleAssignments (Counterexample counterexample ) {
142+ /**
143+ * Print every assignment returned by the solver before error reporting filters the user-facing counterexample down
144+ * to the variables mentioned in the diagnostic.
145+ */
146+ public static void counterexample (Counterexample counterexample ) {
135147 if (!enabled () || counterexample == null || counterexample .assignments ().isEmpty ()) {
136148 return ;
137149 }
138- System .out .println (SMT_TAG + " unfiltered counterexample assignments:" );
139- for (var assignment : counterexample .assignments ()) {
140- System .out .println (SMT_TAG + " " + assignment .first () + " = " + assignment .second ());
141- }
150+ System .out
151+ .println (SMP_TAG
152+ + " Counterexample: " + Colors .RED + counterexample .assignments ().stream ()
153+ .map (a -> a .first () + " = " + a .second ()).collect (Collectors .joining (" && " ))
154+ + Colors .RESET );
142155 }
143156
144157 private static String plainLabel (VCImplication node ) {
@@ -233,14 +246,14 @@ public static void smtUnsat() {
233246 if (!enabled ()) {
234247 return ;
235248 }
236- System .out .println (SMT_TAG + " result : " + Colors .GREEN + "UNSAT (subtype holds)" + Colors .RESET );
249+ System .out .println (SMT_TAG + " Result : " + Colors .GREEN + "UNSAT (subtype holds)" + Colors .RESET );
237250 }
238251
239252 public static void smtSat (Object counterexample ) {
240253 if (!enabled ()) {
241254 return ;
242255 }
243- String header = SMT_TAG + " result : " + Colors .RED + "SAT (subtype fails)" + Colors .RESET ;
256+ String header = SMT_TAG + " Result : " + Colors .RED + "SAT (subtype fails)" + Colors .RESET ;
244257 String pretty = formatCounterexample (counterexample );
245258 if (pretty == null ) {
246259 System .out .println (header );
@@ -284,7 +297,7 @@ public static void smtUnknown() {
284297 if (!enabled ()) {
285298 return ;
286299 }
287- System .out .println (SMT_TAG + " result : " + Colors .YELLOW + "UNKNOWN (treated as OK)" + Colors .RESET );
300+ System .out .println (SMT_TAG + " Result : " + Colors .YELLOW + "UNKNOWN (treated as OK)" + Colors .RESET );
288301 }
289302
290303 /**
@@ -310,7 +323,7 @@ public static void smtError(String message) {
310323 if (!enabled ()) {
311324 return ;
312325 }
313- System .out .println (SMT_TAG + " result : " + Colors .RED + "ERROR" + Colors .RESET + " — "
326+ System .out .println (SMT_TAG + " Result : " + Colors .RED + "ERROR" + Colors .RESET + " — "
314327 + (message == null ? "(no message)" : message ));
315328 }
316329}
0 commit comments