CVC4: small improvements for FP.
@@ -26,6 +26,8 @@ import edu.nyu.acsys.CVC4.FloatingPoint;
import edu.nyu.acsys.CVC4.FloatingPointConvertSort;
import edu.nyu.acsys.CVC4.FloatingPointSize;
import edu.nyu.acsys.CVC4.FloatingPointToFPFloatingPoint;
+import edu.nyu.acsys.CVC4.FloatingPointToFPSignedBitVector;
+import edu.nyu.acsys.CVC4.FloatingPointToFPUnsignedBitVector;
import edu.nyu.acsys.CVC4.FloatingPointToSBV;
import edu.nyu.acsys.CVC4.Kind;
import edu.nyu.acsys.CVC4.Rational;
@@ -120,9 +122,7 @@ public class CVC4FloatingPointFormulaManager
} catch (NumberFormatException e1) {
try {
// then try something like -123/456
- org.sosy_lab.common.rationals.Rational r =
- org.sosy_lab.common.rationals.Rational.ofString(pN);
- return new Rational(r.getNum().longValueExact(), r.getDen().longValueExact());
+ return new Rational(pN);
} catch (NumberFormatException e2) {
// we cannot handle the number
@@ -178,6 +178,20 @@ public class CVC4FloatingPointFormulaManager
FormulaType<?> formulaType = getFormulaCreator().getFormulaType(pNumber);
if (formulaType.isFloatingPointType()) {
return castToImpl(pNumber, pTargetType, pRoundingMode);
+
+ } else if (formulaType.isBitvectorType()) {
+ long pExponentSize = pTargetType.getExponentSize();
+ long pMantissaSize = pTargetType.getMantissaSize();
+ FloatingPointSize fpSize = new FloatingPointSize(pExponentSize, pMantissaSize + 1);
+ FloatingPointConvertSort fpConvert = new FloatingPointConvertSort(fpSize);
+ final Expr op;
+ if (pSigned) {
+ op = exprManager.mkConst(new FloatingPointToFPSignedBitVector(fpConvert));
+ } else {
+ op = exprManager.mkConst(new FloatingPointToFPUnsignedBitVector(fpConvert));
+ }
+ return exprManager.mkExpr(op, pRoundingMode, pNumber);
+
} else {
return genericCast(pNumber, pTargetType);
}
@@ -287,13 +301,13 @@ public class CVC4FloatingPointFormulaManager
@Override
protected Expr toIeeeBitvectorImpl(Expr pNumber) {
- final Expr op = exprManager.mkConst(Kind.FLOATINGPOINT_TO_FP_IEEE_BITVECTOR);
- return exprManager.mkExpr(op, pNumber);
+ // TODO possible work-around: use a tmp-variable "TMP" and add an
+ // additional constraint "pNumer == fromIeeeBitvectorImpl(TMP)" for it in all use-cases.
+ throw new UnsupportedOperationException("FP to IEEE-BV is not supported");
}
@Override
protected Expr round(Expr pFormula, FloatingPointRoundingMode pRoundingMode) {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException();
+ return exprManager.mkExpr(Kind.FLOATINGPOINT_RTI, getRoundingModeImpl(pRoundingMode), pFormula);
}
}
