Z3
 
Loading...
Searching...
No Matches
Public Member Functions | Friends
rcf_num Class Reference

Wrapper for Z3 Real Closed Field (RCF) numerals. More...

#include <z3++.h>

Public Member Functions

 rcf_num (context &c, Z3_rcf_num n)
 
 rcf_num (context &c, int val)
 
 rcf_num (context &c, char const *val)
 
 rcf_num (rcf_num const &other)
 
rcf_numoperator= (rcf_num const &other)
 
 ~rcf_num ()
 
 operator Z3_rcf_num () const
 
Z3_context ctx () const
 
std::string to_string (bool compact=false) const
 Return string representation of the RCF numeral.
 
std::string to_decimal (unsigned precision=10) const
 Return decimal string representation with given precision.
 
rcf_num operator+ (rcf_num const &other) const
 
rcf_num operator- (rcf_num const &other) const
 
rcf_num operator* (rcf_num const &other) const
 
rcf_num operator/ (rcf_num const &other) const
 
rcf_num operator- () const
 
rcf_num power (unsigned k) const
 Return the power of this number raised to k.
 
rcf_num inv () const
 Return the multiplicative inverse (1/this).
 
bool operator< (rcf_num const &other) const
 
bool operator> (rcf_num const &other) const
 
bool operator<= (rcf_num const &other) const
 
bool operator>= (rcf_num const &other) const
 
bool operator== (rcf_num const &other) const
 
bool operator!= (rcf_num const &other) const
 
bool is_rational () const
 
bool is_algebraic () const
 
bool is_infinitesimal () const
 
bool is_transcendental () const
 

Friends

std::ostream & operator<< (std::ostream &out, rcf_num const &n)
 

Detailed Description

Wrapper for Z3 Real Closed Field (RCF) numerals.

RCF numerals can represent:

Definition at line 5055 of file z3++.h.

Constructor & Destructor Documentation

◆ rcf_num() [1/4]

rcf_num ( context c,
Z3_rcf_num  n 
)
inline

Definition at line 5066 of file z3++.h.

5066: m_ctx(c), m_num(n) {}

◆ rcf_num() [2/4]

rcf_num ( context c,
int  val 
)
inline

Definition at line 5068 of file z3++.h.

5068 : m_ctx(c) {
5069 m_num = Z3_rcf_mk_small_int(c, val);
5070 }
Z3_rcf_num Z3_API Z3_rcf_mk_small_int(Z3_context c, int val)
Return a RCF small integer.

◆ rcf_num() [3/4]

rcf_num ( context c,
char const val 
)
inline

Definition at line 5072 of file z3++.h.

5072 : m_ctx(c) {
5073 m_num = Z3_rcf_mk_rational(c, val);
5074 }
Z3_rcf_num Z3_API Z3_rcf_mk_rational(Z3_context c, Z3_string val)
Return a RCF rational using the given string.

◆ rcf_num() [4/4]

rcf_num ( rcf_num const other)
inline

Definition at line 5076 of file z3++.h.

5076 : m_ctx(other.m_ctx) {
5077 // Create a copy by converting to string and back
5078 std::string str = Z3_rcf_num_to_string(m_ctx, other.m_num, false, false);
5079 m_num = Z3_rcf_mk_rational(m_ctx, str.c_str());
5080 }
Z3_string Z3_API Z3_rcf_num_to_string(Z3_context c, Z3_rcf_num a, bool compact, bool html)
Convert the RCF numeral into a string.

◆ ~rcf_num()

~rcf_num ( )
inline

Definition at line 5092 of file z3++.h.

5092 {
5093 Z3_rcf_del(m_ctx, m_num);
5094 }
void Z3_API Z3_rcf_del(Z3_context c, Z3_rcf_num a)
Delete a RCF numeral created using the RCF API.

Member Function Documentation

◆ ctx()

Z3_context ctx ( ) const
inline

Definition at line 5097 of file z3++.h.

5097{ return m_ctx; }

Referenced by ArithRef::__add__(), BitVecRef::__add__(), BitVecRef::__and__(), FuncDeclRef::__call__(), AstMap::__contains__(), AstRef::__copy__(), Goal::__copy__(), AstVector::__copy__(), FuncInterp::__copy__(), ModelRef::__copy__(), AstRef::__deepcopy__(), Datatype::__deepcopy__(), ParamsRef::__deepcopy__(), ParamDescrsRef::__deepcopy__(), Goal::__deepcopy__(), AstVector::__deepcopy__(), AstMap::__deepcopy__(), FuncEntry::__deepcopy__(), FuncInterp::__deepcopy__(), ModelRef::__deepcopy__(), Statistics::__deepcopy__(), Context::__del__(), AstRef::__del__(), ScopedConstructor::__del__(), ScopedConstructorList::__del__(), ParamsRef::__del__(), ParamDescrsRef::__del__(), Goal::__del__(), AstVector::__del__(), AstMap::__del__(), FuncEntry::__del__(), FuncInterp::__del__(), ModelRef::__del__(), Statistics::__del__(), Solver::__del__(), ArithRef::__div__(), BitVecRef::__div__(), ExprRef::__eq__(), ArithRef::__ge__(), BitVecRef::__ge__(), AstVector::__getitem__(), ModelRef::__getitem__(), Statistics::__getitem__(), AstMap::__getitem__(), ArithRef::__gt__(), BitVecRef::__gt__(), BitVecRef::__invert__(), ArithRef::__le__(), BitVecRef::__le__(), AstVector::__len__(), AstMap::__len__(), ModelRef::__len__(), Statistics::__len__(), BitVecRef::__lshift__(), ArithRef::__lt__(), BitVecRef::__lt__(), ArithRef::__mod__(), BitVecRef::__mod__(), BoolRef::__mul__(), ArithRef::__mul__(), BitVecRef::__mul__(), ExprRef::__ne__(), ArithRef::__neg__(), BitVecRef::__neg__(), BitVecRef::__or__(), ArithRef::__pow__(), ArithRef::__radd__(), BitVecRef::__radd__(), BitVecRef::__rand__(), ArithRef::__rdiv__(), BitVecRef::__rdiv__(), ParamsRef::__repr__(), ParamDescrsRef::__repr__(), AstMap::__repr__(), Statistics::__repr__(), BitVecRef::__rlshift__(), ArithRef::__rmod__(), BitVecRef::__rmod__(), ArithRef::__rmul__(), BitVecRef::__rmul__(), BitVecRef::__ror__(), ArithRef::__rpow__(), BitVecRef::__rrshift__(), BitVecRef::__rshift__(), ArithRef::__rsub__(), BitVecRef::__rsub__(), BitVecRef::__rxor__(), AstVector::__setitem__(), AstMap::__setitem__(), ArithRef::__sub__(), BitVecRef::__sub__(), BitVecRef::__xor__(), DatatypeSortRef::accessor(), ExprRef::arg(), FuncEntry::arg_value(), FuncInterp::arity(), Goal::as_expr(), Solver::assert_and_track(), Goal::assert_exprs(), Solver::assert_exprs(), QuantifierRef::body(), FiniteSetSortRef::cast(), Solver::check(), Goal::convert_model(), AstRef::ctx_ref(), ExprRef::decl(), ModelRef::decls(), ArrayRef::default(), RatNumRef::denominator(), Goal::depth(), Goal::dimacs(), FuncDeclRef::domain(), ArraySortRef::domain_n(), FuncInterp::else_value(), FuncInterp::entry(), AstMap::erase(), ModelRef::eval(), Goal::get(), ParamDescrsRef::get_documentation(), ModelRef::get_interp(), Statistics::get_key_value(), ParamDescrsRef::get_kind(), ParamDescrsRef::get_name(), ModelRef::get_sort(), ModelRef::get_universe(), Goal::inconsistent(), AstMap::keys(), Statistics::keys(), Solver::model(), SortRef::name(), QuantifierRef::no_pattern(), FuncEntry::num_args(), FuncInterp::num_entries(), Solver::num_scopes(), ModelRef::num_sorts(), FuncDeclRef::params(), QuantifierRef::pattern(), AlgebraicNumRef::poly(), Solver::pop(), Goal::prec(), ModelRef::project(), ModelRef::project_with_witness(), Solver::push(), AstVector::push(), QuantifierRef::qid(), FuncDeclRef::range(), ArraySortRef::range(), DatatypeSortRef::recognizer(), Context::ref(), AstMap::reset(), Solver::reset(), AstVector::resize(), Solver::set(), ParamsRef::set(), Goal::sexpr(), AstVector::sexpr(), ModelRef::sexpr(), ParamDescrsRef::size(), Goal::size(), QuantifierRef::skolem_id(), AstVector::translate(), AstRef::translate(), Goal::translate(), ModelRef::translate(), ExprRef::update(), DatatypeRef::update_field(), ParamsRef::validate(), FuncEntry::value(), QuantifierRef::var_name(), and QuantifierRef::var_sort().

◆ inv()

rcf_num inv ( ) const
inline

Return the multiplicative inverse (1/this).

Definition at line 5154 of file z3++.h.

5154 {
5155 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5156 Z3_rcf_inv(m_ctx, m_num));
5157 }
rcf_num(context &c, Z3_rcf_num n)
Definition z3++.h:5066
Z3_rcf_num Z3_API Z3_rcf_inv(Z3_context c, Z3_rcf_num a)
Return the value 1/a.

◆ is_algebraic()

bool is_algebraic ( ) const
inline

Definition at line 5195 of file z3++.h.

5195 {
5196 return Z3_rcf_is_algebraic(m_ctx, m_num);
5197 }
bool Z3_API Z3_rcf_is_algebraic(Z3_context c, Z3_rcf_num a)
Return true if a represents an algebraic number.

◆ is_infinitesimal()

bool is_infinitesimal ( ) const
inline

Definition at line 5199 of file z3++.h.

5199 {
5200 return Z3_rcf_is_infinitesimal(m_ctx, m_num);
5201 }
bool Z3_API Z3_rcf_is_infinitesimal(Z3_context c, Z3_rcf_num a)
Return true if a represents an infinitesimal.

◆ is_rational()

bool is_rational ( ) const
inline

Definition at line 5191 of file z3++.h.

5191 {
5192 return Z3_rcf_is_rational(m_ctx, m_num);
5193 }
bool Z3_API Z3_rcf_is_rational(Z3_context c, Z3_rcf_num a)
Return true if a represents a rational number.

◆ is_transcendental()

bool is_transcendental ( ) const
inline

Definition at line 5203 of file z3++.h.

5203 {
5204 return Z3_rcf_is_transcendental(m_ctx, m_num);
5205 }
bool Z3_API Z3_rcf_is_transcendental(Z3_context c, Z3_rcf_num a)
Return true if a represents a transcendental number.

◆ operator Z3_rcf_num()

operator Z3_rcf_num ( ) const
inline

Definition at line 5096 of file z3++.h.

5096{ return m_num; }

◆ operator!=()

bool operator!= ( rcf_num const other) const
inline

Definition at line 5185 of file z3++.h.

5185 {
5186 check_context(other);
5187 return Z3_rcf_neq(m_ctx, m_num, other.m_num);
5188 }
bool Z3_API Z3_rcf_neq(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a != b.

◆ operator*()

rcf_num operator* ( rcf_num const other) const
inline

Definition at line 5126 of file z3++.h.

5126 {
5127 check_context(other);
5128 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5129 Z3_rcf_mul(m_ctx, m_num, other.m_num));
5130 }
Z3_rcf_num Z3_API Z3_rcf_mul(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return the value a * b.

◆ operator+()

rcf_num operator+ ( rcf_num const other) const
inline

Definition at line 5114 of file z3++.h.

5114 {
5115 check_context(other);
5116 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5117 Z3_rcf_add(m_ctx, m_num, other.m_num));
5118 }
Z3_rcf_num Z3_API Z3_rcf_add(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return the value a + b.

◆ operator-() [1/2]

rcf_num operator- ( ) const
inline

Definition at line 5138 of file z3++.h.

5138 {
5139 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5140 Z3_rcf_neg(m_ctx, m_num));
5141 }
Z3_rcf_num Z3_API Z3_rcf_neg(Z3_context c, Z3_rcf_num a)
Return the value -a.

◆ operator-() [2/2]

rcf_num operator- ( rcf_num const other) const
inline

Definition at line 5120 of file z3++.h.

5120 {
5121 check_context(other);
5122 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5123 Z3_rcf_sub(m_ctx, m_num, other.m_num));
5124 }
Z3_rcf_num Z3_API Z3_rcf_sub(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return the value a - b.

◆ operator/()

rcf_num operator/ ( rcf_num const other) const
inline

Definition at line 5132 of file z3++.h.

5132 {
5133 check_context(other);
5134 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5135 Z3_rcf_div(m_ctx, m_num, other.m_num));
5136 }
Z3_rcf_num Z3_API Z3_rcf_div(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return the value a / b.

◆ operator<()

bool operator< ( rcf_num const other) const
inline

Definition at line 5160 of file z3++.h.

5160 {
5161 check_context(other);
5162 return Z3_rcf_lt(m_ctx, m_num, other.m_num);
5163 }
bool Z3_API Z3_rcf_lt(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a < b.

◆ operator<=()

bool operator<= ( rcf_num const other) const
inline

Definition at line 5170 of file z3++.h.

5170 {
5171 check_context(other);
5172 return Z3_rcf_le(m_ctx, m_num, other.m_num);
5173 }
bool Z3_API Z3_rcf_le(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a <= b.

◆ operator=()

rcf_num & operator= ( rcf_num const other)
inline

Definition at line 5082 of file z3++.h.

5082 {
5083 if (this != &other) {
5084 Z3_rcf_del(m_ctx, m_num);
5085 m_ctx = other.m_ctx;
5086 std::string str = Z3_rcf_num_to_string(m_ctx, other.m_num, false, false);
5087 m_num = Z3_rcf_mk_rational(m_ctx, str.c_str());
5088 }
5089 return *this;
5090 }

◆ operator==()

bool operator== ( rcf_num const other) const
inline

Definition at line 5180 of file z3++.h.

5180 {
5181 check_context(other);
5182 return Z3_rcf_eq(m_ctx, m_num, other.m_num);
5183 }
bool Z3_API Z3_rcf_eq(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a == b.

◆ operator>()

bool operator> ( rcf_num const other) const
inline

Definition at line 5165 of file z3++.h.

5165 {
5166 check_context(other);
5167 return Z3_rcf_gt(m_ctx, m_num, other.m_num);
5168 }
bool Z3_API Z3_rcf_gt(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a > b.

◆ operator>=()

bool operator>= ( rcf_num const other) const
inline

Definition at line 5175 of file z3++.h.

5175 {
5176 check_context(other);
5177 return Z3_rcf_ge(m_ctx, m_num, other.m_num);
5178 }
bool Z3_API Z3_rcf_ge(Z3_context c, Z3_rcf_num a, Z3_rcf_num b)
Return true if a >= b.

◆ power()

rcf_num power ( unsigned  k) const
inline

Return the power of this number raised to k.

Definition at line 5146 of file z3++.h.

5146 {
5147 return rcf_num(*const_cast<context*>(reinterpret_cast<context const*>(&m_ctx)),
5148 Z3_rcf_power(m_ctx, m_num, k));
5149 }
Z3_rcf_num Z3_API Z3_rcf_power(Z3_context c, Z3_rcf_num a, unsigned k)
Return the value a^k.

◆ to_decimal()

std::string to_decimal ( unsigned  precision = 10) const
inline

Return decimal string representation with given precision.

Definition at line 5109 of file z3++.h.

5109 {
5110 return std::string(Z3_rcf_num_to_decimal_string(m_ctx, m_num, precision));
5111 }
Z3_string Z3_API Z3_rcf_num_to_decimal_string(Z3_context c, Z3_rcf_num a, unsigned prec)
Convert the RCF numeral into a string in decimal notation.

◆ to_string()

std::string to_string ( bool  compact = false) const
inline

Return string representation of the RCF numeral.

Definition at line 5102 of file z3++.h.

5102 {
5103 return std::string(Z3_rcf_num_to_string(m_ctx, m_num, compact, false));
5104 }

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
rcf_num const n 
)
friend

Definition at line 5207 of file z3++.h.

5207 {
5208 return out << n.to_string();
5209 }