`Result::Entailment` along with corresponding changes to the enum values.
* Java API change: The name of CVC4's package is now `edu.stanford.CVC4`
instead of `edu.nyu.acsys.CVC4`.
+* Printing of BV constants: previously CVC4 would print BV constant
+ values as indexed symbols by default and in binary notation with the
+ option --bv-print-consts-in-binary. To be SMT-LIB compliant the
+ default behavior is now to print BV constant values in binary
+ notation and as indexed symbols with the new option
+ --bv-print-consts-as-indexed-symbols. The option
+ --bv-print-consts-in-binary has been removed.
Changes since 1.6
=================
help = "algebraic inferences for extended functions"
[[option]]
- name = "bvPrintConstsInBinary"
+ name = "bvPrintConstsAsIndexedSymbols"
category = "regular"
- long = "bv-print-consts-in-binary"
+ long = "bv-print-consts-as-indexed-symbols"
type = "bool"
default = "false"
help = "print bit-vector constants in binary (e.g. #b0001) instead of decimal (e.g. (_ bv1 4)), applies to SMT-LIB 2.x"
<< n.getConst<FloatingPointSize>().significand()
<< ")";
break;
- case kind::CONST_BITVECTOR: {
+ case kind::CONST_BITVECTOR:
+ {
const BitVector& bv = n.getConst<BitVector>();
- const Integer& x = bv.getValue();
- unsigned width = bv.getSize();
- if (d_variant == sygus_variant || options::bvPrintConstsInBinary())
+ if (options::bvPrintConstsAsIndexedSymbols())
{
- out << "#b" << bv.toString();
+ out << "(_ bv" << bv.getValue() << " " << bv.getSize() << ")";
}
else
{
- out << "(_ ";
- out << "bv" << x << " " << width;
- out << ")";
+ out << "#b" << bv.toString();
}
-
- // //out << "#b";
-
- // while(n-- > 0) {
- // out << (x.testBit(n) ? '1' : '0');
- // }
break;
}
case kind::CONST_FLOATINGPOINT:
- out << n.getConst<FloatingPoint>();
+ {
+ out << n.getConst<FloatingPoint>().toString(
+ options::bvPrintConstsAsIndexedSymbols());
break;
+ }
case kind::CONST_ROUNDINGMODE:
switch (n.getConst<RoundingMode>()) {
case roundNearestTiesToEven : out << "roundNearestTiesToEven"; break;
out << "(_ int2bv " << n.getConst<IntToBitVector>().d_size << ")";
break;
case kind::FLOATINGPOINT_TO_FP_IEEE_BITVECTOR_OP:
- // out << "to_fp_bv "
out << "(_ to_fp "
<< n.getConst<FloatingPointToFPIEEEBitVector>().t.exponent() << ' '
<< n.getConst<FloatingPointToFPIEEEBitVector>().t.significand()
<< ")";
break;
case kind::FLOATINGPOINT_TO_FP_FLOATINGPOINT_OP:
- // out << "to_fp_fp "
out << "(_ to_fp "
<< n.getConst<FloatingPointToFPFloatingPoint>().t.exponent() << ' '
<< n.getConst<FloatingPointToFPFloatingPoint>().t.significand()
<< ")";
break;
case kind::FLOATINGPOINT_TO_FP_REAL_OP:
- // out << "to_fp_real "
out << "(_ to_fp " << n.getConst<FloatingPointToFPReal>().t.exponent()
<< ' ' << n.getConst<FloatingPointToFPReal>().t.significand() << ")";
break;
case kind::FLOATINGPOINT_TO_FP_SIGNED_BITVECTOR_OP:
- // out << "to_fp_signed "
out << "(_ to_fp "
<< n.getConst<FloatingPointToFPSignedBitVector>().t.exponent() << ' '
<< n.getConst<FloatingPointToFPSignedBitVector>().t.significand()
return bv;
}
-
+std::string FloatingPoint::toString(bool printAsIndexed) const
+{
+ std::string str;
+ // retrive BV value
+ BitVector bv(pack());
+ unsigned largestSignificandBit =
+ t.significand() - 2; // -1 for -inclusive, -1 for hidden
+ unsigned largestExponentBit =
+ (t.exponent() - 1) + (largestSignificandBit + 1);
+ BitVector v[3];
+ v[0] = bv.extract(largestExponentBit + 1, largestExponentBit + 1);
+ v[1] = bv.extract(largestExponentBit, largestSignificandBit + 1);
+ v[2] = bv.extract(largestSignificandBit, 0);
+ str.append("(fp ");
+ for (unsigned i = 0; i < 3; ++i)
+ {
+ if (printAsIndexed)
+ {
+ str.append("(_ bv");
+ str.append(v[i].getValue().toString());
+ str.append(" ");
+ str.append(std::to_string(v[i].getSize()));
+ str.append(")");
+ }
+ else
+ {
+ str.append("#b");
+ str.append(v[i].toString());
+ }
+ if (i < 2)
+ {
+ str.append(" ");
+ }
+ }
+ return str;
+}
}/* CVC4 namespace */
return this->fpl;
}
+ /* Return string representation.
+ *
+ * If printAsIndexed is true then it prints
+ * the bit-vector components of the FP value as indexed symbols, otherwise
+ * in binary notation. */
+ std::string toString(bool printAsIndexed = false) const;
+
// Gives the corresponding IEEE-754 transfer format
BitVector pack (void) const;
*/
inline std::ostream& operator <<(std::ostream& os, const FloatingPoint& fp) CVC4_PUBLIC;
- inline std::ostream& operator <<(std::ostream& os, const FloatingPoint& fp) {
- BitVector bv(fp.pack());
-
- unsigned largestSignificandBit = fp.t.significand() - 2; // -1 for -inclusive, -1 for hidden
- unsigned largestExponentBit = (fp.t.exponent() - 1) + (largestSignificandBit + 1);
-
- return os
- << "(fp #b" << bv.extract(largestExponentBit + 1, largestExponentBit + 1)
- << " #b" << bv.extract(largestExponentBit, largestSignificandBit + 1)
- << " #b" << bv.extract(largestSignificandBit, 0)
- << ")";
+ inline std::ostream& operator<<(std::ostream& os, const FloatingPoint& fp)
+ {
+ // print in binary notation
+ return os << fp.toString();
}
inline std::ostream& operator <<(std::ostream& os, const FloatingPointSize& fps) CVC4_PUBLIC;
-; COMMAND-LINE: --bv-print-consts-in-binary
+; COMMAND-LINE:
; EXPECT: sat
; EXPECT: ((x #b0001))
(set-option :produce-models true)
-; COMMAND-LINE: --no-bv-print-consts-in-binary
+; COMMAND-LINE: --bv-print-consts-as-indexed-symbols
; EXPECT: sat
; EXPECT: ((x (_ bv1 4)))
(set-option :produce-models true)
; EXPECT: sat
-; EXPECT: ((|| (_ bv1 4)))
+; EXPECT: ((|| #b0001))
(set-option :produce-models true)
(set-logic QF_BV)
(declare-const || (_ BitVec 4))
; EXPECT: sat
-; EXPECT: ((|0_0| (_ bv1 4)))
-; EXPECT: ((x (_ bv3 4)))
+; EXPECT: ((|0_0| #b0001))
+; EXPECT: ((x #b0011))
(set-option :produce-models true)
(set-logic QF_BV)
(declare-const |0_0| (_ BitVec 4))