66import com .microsoft .z3 .Expr ;
77import com .microsoft .z3 .FPExpr ;
88import com .microsoft .z3 .FuncDecl ;
9- import com .microsoft .z3 .FuncInterp ;
109import com .microsoft .z3 .IntExpr ;
1110import com .microsoft .z3 .IntNum ;
1211import com .microsoft .z3 .RealExpr ;
2524import liquidjava .diagnostics .errors .LJError ;
2625import liquidjava .diagnostics .errors .NotFoundError ;
2726import liquidjava .processor .context .AliasWrapper ;
27+ import liquidjava .utils .Pair ;
2828import liquidjava .utils .Utils ;
2929import liquidjava .utils .constants .Keys ;
3030import com .microsoft .z3 .enumerations .Z3_sort_kind ;
@@ -41,12 +41,12 @@ public class TranslatorToZ3 implements AutoCloseable {
4141 private final Map <String , Expr <?>> funcAppTranslation = new HashMap <>();
4242 private final Map <Expr <?>, String > exprToNameTranslation = new HashMap <>();
4343
44- public TranslatorToZ3 (liquidjava .processor .context .Context c ) {
45- TranslatorContextToZ3 .translateVariables (z3 , c .getContext (), varTranslation );
46- TranslatorContextToZ3 .storeVariablesSubtypes (z3 , c .getAllVariablesWithSupertypes (), varSuperTypes );
47- TranslatorContextToZ3 .addAliases (c .getAliases (), aliasTranslation );
48- TranslatorContextToZ3 .addGhostFunctions (z3 , c .getGhosts (), funcTranslation );
49- TranslatorContextToZ3 .addGhostStates (z3 , c .getGhostStates (), funcTranslation );
44+ public TranslatorToZ3 (liquidjava .processor .context .Context context ) {
45+ TranslatorContextToZ3 .translateVariables (z3 , context .getContext (), varTranslation );
46+ TranslatorContextToZ3 .storeVariablesSubtypes (z3 , context .getAllVariablesWithSupertypes (), varSuperTypes );
47+ TranslatorContextToZ3 .addAliases (context .getAliases (), aliasTranslation );
48+ TranslatorContextToZ3 .addGhostFunctions (z3 , context .getGhosts (), funcTranslation );
49+ TranslatorContextToZ3 .addGhostStates (z3 , context .getGhostStates (), funcTranslation );
5050 }
5151
5252 @ SuppressWarnings ("unchecked" )
@@ -60,23 +60,25 @@ public Solver makeSolverForExpression(Expr<?> e) {
6060 * Extracts the counterexample from the Z3 model
6161 */
6262 public Counterexample getCounterexample (Model model ) {
63- List <String > assignments = new ArrayList <>();
63+ List <Pair < String , String > > assignments = new ArrayList <>();
6464 // Extract constant variable assignments
6565 for (FuncDecl <?> decl : model .getDecls ()) {
6666 if (decl .getArity () == 0 ) {
6767 Symbol name = decl .getName ();
6868 Expr <?> value = model .getConstInterp (decl );
69+ Pair <String , String > assignment = new Pair <>(name .toString (), value .toString ());
6970 // Skip values of uninterpreted sorts
7071 if (value .getSort ().getSortKind () != Z3_sort_kind .Z3_UNINTERPRETED_SORT )
71- assignments .add (name + " == " + value );
72+ assignments .add (assignment );
7273 }
7374 }
7475 // Extract function application values
7576 for (Map .Entry <String , Expr <?>> entry : funcAppTranslation .entrySet ()) {
76- String label = entry .getKey ();
77+ String name = entry .getKey ();
7778 Expr <?> application = entry .getValue ();
7879 Expr <?> value = model .eval (application , true );
79- assignments .add (label + " = " + value );
80+ Pair <String , String > assignment = new Pair <>(name , value .toString ());
81+ assignments .add (assignment );
8082 }
8183 return new Counterexample (assignments );
8284 }
0 commit comments