Closed MarcusVoelker closed 9 years ago
ComputeInterpolant has been fixed to return a return value class that contains all the required out parameters of the corresponding C function (see #82).
Following is a patch for this issue, pushed to unstable:
diff --git a/src/interp/iz3mgr.cpp b/src/interp/iz3mgr.cpp
index 5a7f719..78dd6f1 100755
--- a/src/interp/iz3mgr.cpp
+++ b/src/interp/iz3mgr.cpp
@@ -556,6 +556,20 @@ void iz3mgr::get_farkas_coeffs(const ast &proof, std::vector<rational>& rats){
extract_lcd(rats);
}
+void iz3mgr::get_broken_gcd_test_coeffs(const ast &proof, std::vector<rational>& rats){
+ symb s = sym(proof);
+ int numps = s->get_num_parameters();
+ rats.resize(numps-2);
+ for(int i = 2; i < numps; i++){
+ rational r;
+ bool ok = s->get_parameter(i).is_rational(r);
+ if(!ok)
+ throw "Bad Farkas coefficient";
+ rats[i-2] = r;
+ }
+ extract_lcd(rats);
+}
+
void iz3mgr::get_assign_bounds_coeffs(const ast &proof, std::vector<ast>& coeffs){
std::vector<rational> rats;
get_assign_bounds_coeffs(proof,rats);
diff --git a/src/interp/iz3mgr.h b/src/interp/iz3mgr.h
index 54fb35a..8d4479f 100755
--- a/src/interp/iz3mgr.h
+++ b/src/interp/iz3mgr.h
@@ -424,6 +424,8 @@ class iz3mgr {
void get_farkas_coeffs(const ast &proof, std::vector<rational>& rats);
+ void get_broken_gcd_test_coeffs(const ast &proof, std::vector<rational>& rats);
+
void get_assign_bounds_coeffs(const ast &proof, std::vector<rational>& rats);
void get_assign_bounds_coeffs(const ast &proof, std::vector<ast>& rats);
diff --git a/src/interp/iz3translate.cpp b/src/interp/iz3translate.cpp
index 36cf802..360748b 100755
--- a/src/interp/iz3translate.cpp
+++ b/src/interp/iz3translate.cpp
@@ -1021,6 +1021,12 @@ public:
my_coeffs.push_back(make_int(c));
my_prem_cons.push_back(conc(prem(proof,i)));
}
+ else if(c.is_neg()){
+ int j = (i % 2 == 0) ? i + 1 : i - 1;
+ my_prems.push_back(prems[j]);
+ my_coeffs.push_back(make_int(-coeffs[j]));
+ my_prem_cons.push_back(conc(prem(proof,j)));
+ }
}
ast my_con = sum_inequalities(my_coeffs,my_prem_cons);
@@ -1882,7 +1891,7 @@ public:
}
case GCDTestKind: {
std::vector<rational> farkas_coeffs;
- get_farkas_coeffs(proof,farkas_coeffs);
+ get_broken_gcd_test_coeffs(proof,farkas_coeffs);
if(farkas_coeffs.size() != nprems){
pfgoto(proof);
throw unsupported();
Christophe, your new version of ComputeInterpolant does not seem to be in unstable.
Ken: Yes it is, see here. Note that this was a fix exclusively for the Java API, because Java doesn't support output parameters.
I think this issue is fixed. Closing.
I had z3 compute an interpolant via the Java API (using a hacked
ComputeInterpolant
function to bypass the unusable function in the current API, see below).This is the Java code I use
with the following
ComputeInterpolant
function added to InterpolationContext.java:When I run this function, the interpolant given is
(= |#PC'| 1)
, but as the output at the end of the function proves,B -> not(I)
is not a tautology, hence the interpolant is wrong.