Z3
Public Member Functions | Friends
goal Class Reference
+ Inheritance diagram for goal:

Public Member Functions

 goal (context &c, bool models=true, bool unsat_cores=false, bool proofs=false)
 
 goal (context &c, Z3_goal s)
 
 goal (goal const &s)
 
 ~goal ()
 
 operator Z3_goal () const
 
goaloperator= (goal const &s)
 
void add (expr const &f)
 
void add (expr_vector const &v)
 
unsigned size () const
 
expr operator[] (int i) const
 
Z3_goal_prec precision () const
 
bool inconsistent () const
 
unsigned depth () const
 
void reset ()
 
unsigned num_exprs () const
 
bool is_decided_sat () const
 
bool is_decided_unsat () const
 
model convert_model (model const &m) const
 
model get_model () const
 
expr as_expr () const
 
std::string dimacs () const
 
- Public Member Functions inherited from object
 object (context &c)
 
 object (object const &s)
 
contextctx () const
 
Z3_error_code check_error () const
 

Friends

std::ostream & operator<< (std::ostream &out, goal const &g)
 

Additional Inherited Members

- Protected Attributes inherited from object
contextm_ctx
 

Detailed Description

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

Constructor & Destructor Documentation

◆ goal() [1/3]

goal ( context c,
bool  models = true,
bool  unsat_cores = false,
bool  proofs = false 
)
inline

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

2516 :object(c) { init(Z3_mk_goal(c, models, unsat_cores, proofs)); }

◆ goal() [2/3]

goal ( context c,
Z3_goal  s 
)
inline

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

2517 :object(c) { init(s); }

◆ goal() [3/3]

goal ( goal const &  s)
inline

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

2518 :object(s) { init(s.m_goal); }

◆ ~goal()

~goal ( )
inline

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

2519 { Z3_goal_dec_ref(ctx(), m_goal); }

Member Function Documentation

◆ add() [1/2]

void add ( expr const &  f)
inline

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

2528 { check_context(*this, f); Z3_goal_assert(ctx(), m_goal, f); check_error(); }

◆ add() [2/2]

void add ( expr_vector const &  v)
inline

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

2529 { check_context(*this, v); for (unsigned i = 0; i < v.size(); ++i) add(v[i]); }

Referenced by goal::add().

◆ as_expr()

expr as_expr ( ) const
inline

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

2550  {
2551  unsigned n = size();
2552  if (n == 0)
2553  return ctx().bool_val(true);
2554  else if (n == 1)
2555  return operator[](0);
2556  else {
2557  array<Z3_ast> args(n);
2558  for (unsigned i = 0; i < n; i++)
2559  args[i] = operator[](i);
2560  return expr(ctx(), Z3_mk_and(ctx(), n, args.ptr()));
2561  }
2562  }

◆ convert_model()

model convert_model ( model const &  m) const
inline

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

2539  {
2540  check_context(*this, m);
2541  Z3_model new_m = Z3_goal_convert_model(ctx(), m_goal, m);
2542  check_error();
2543  return model(ctx(), new_m);
2544  }

◆ depth()

unsigned depth ( ) const
inline

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

2534 { return Z3_goal_depth(ctx(), m_goal); }

◆ dimacs()

std::string dimacs ( ) const
inline

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

2563 { return std::string(Z3_goal_to_dimacs_string(ctx(), m_goal)); }

◆ get_model()

model get_model ( ) const
inline

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

2545  {
2546  Z3_model new_m = Z3_goal_convert_model(ctx(), m_goal, 0);
2547  check_error();
2548  return model(ctx(), new_m);
2549  }

◆ inconsistent()

bool inconsistent ( ) const
inline

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

2533 { return Z3_goal_inconsistent(ctx(), m_goal); }

◆ is_decided_sat()

bool is_decided_sat ( ) const
inline

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

2537 { return Z3_goal_is_decided_sat(ctx(), m_goal); }

◆ is_decided_unsat()

bool is_decided_unsat ( ) const
inline

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

2538 { return Z3_goal_is_decided_unsat(ctx(), m_goal); }

◆ num_exprs()

unsigned num_exprs ( ) const
inline

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

2536 { return Z3_goal_num_exprs(ctx(), m_goal); }

◆ operator Z3_goal()

operator Z3_goal ( ) const
inline

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

2520 { return m_goal; }

◆ operator=()

goal& operator= ( goal const &  s)
inline

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

2521  {
2522  Z3_goal_inc_ref(s.ctx(), s.m_goal);
2523  Z3_goal_dec_ref(ctx(), m_goal);
2524  m_ctx = s.m_ctx;
2525  m_goal = s.m_goal;
2526  return *this;
2527  }

◆ operator[]()

expr operator[] ( int  i) const
inline

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

2531 { assert(0 <= i); Z3_ast r = Z3_goal_formula(ctx(), m_goal, i); check_error(); return expr(ctx(), r); }

Referenced by goal::as_expr().

◆ precision()

Z3_goal_prec precision ( ) const
inline

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

2532 { return Z3_goal_precision(ctx(), m_goal); }

◆ reset()

void reset ( )
inline

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

2535 { Z3_goal_reset(ctx(), m_goal); }

◆ size()

unsigned size ( ) const
inline

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

2530 { return Z3_goal_size(ctx(), m_goal); }

Referenced by goal::as_expr().

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
goal const &  g 
)
friend

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

2566 { out << Z3_goal_to_string(g.ctx(), g); return out; }
z3::goal::add
void add(expr const &f)
Definition: z3++.h:2528
Z3_goal_is_decided_sat
bool Z3_API Z3_goal_is_decided_sat(Z3_context c, Z3_goal g)
Return true if the goal is empty, and it is precise or the product of a under approximation.
z3::goal::size
unsigned size() const
Definition: z3++.h:2530
z3::goal::operator[]
expr operator[](int i) const
Definition: z3++.h:2531
Z3_goal_precision
Z3_goal_prec Z3_API Z3_goal_precision(Z3_context c, Z3_goal g)
Return the "precision" of the given goal. Goals can be transformed using over and under approximation...
Z3_mk_and
Z3_ast Z3_API Z3_mk_and(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing args[0] and ... and args[num_args-1].
Z3_goal_size
unsigned Z3_API Z3_goal_size(Z3_context c, Z3_goal g)
Return the number of formulas in the given goal.
Z3_mk_goal
Z3_goal Z3_API Z3_mk_goal(Z3_context c, bool models, bool unsat_cores, bool proofs)
Create a goal (aka problem). A goal is essentially a set of formulas, that can be solved and/or trans...
Z3_goal_reset
void Z3_API Z3_goal_reset(Z3_context c, Z3_goal g)
Erase all formulas from the given goal.
Z3_goal_num_exprs
unsigned Z3_API Z3_goal_num_exprs(Z3_context c, Z3_goal g)
Return the number of formulas, subformulas and terms in the given goal.
Z3_goal_formula
Z3_ast Z3_API Z3_goal_formula(Z3_context c, Z3_goal g, unsigned idx)
Return a formula from the given goal.
Z3_goal_depth
unsigned Z3_API Z3_goal_depth(Z3_context c, Z3_goal g)
Return the depth of the given goal. It tracks how many transformations were applied to it.
Z3_goal_to_dimacs_string
Z3_string Z3_API Z3_goal_to_dimacs_string(Z3_context c, Z3_goal g)
Convert a goal into a DIMACS formatted string. The goal must be in CNF. You can convert a goal to CNF...
z3::object::object
object(context &c)
Definition: z3++.h:404
z3::object::m_ctx
context * m_ctx
Definition: z3++.h:402
Z3_goal_dec_ref
void Z3_API Z3_goal_dec_ref(Z3_context c, Z3_goal g)
Decrement the reference counter of the given goal.
z3::context::bool_val
expr bool_val(bool b)
Definition: z3++.h:3096
Z3_goal_is_decided_unsat
bool Z3_API Z3_goal_is_decided_unsat(Z3_context c, Z3_goal g)
Return true if the goal contains false, and it is precise or the product of an over approximation.
Z3_goal_to_string
Z3_string Z3_API Z3_goal_to_string(Z3_context c, Z3_goal g)
Convert a goal into a string.
Z3_goal_inc_ref
void Z3_API Z3_goal_inc_ref(Z3_context c, Z3_goal g)
Increment the reference counter of the given goal.
Z3_goal_assert
void Z3_API Z3_goal_assert(Z3_context c, Z3_goal g, Z3_ast a)
Add a new formula a to the given goal. The formula is split according to the following procedure that...
z3::object::check_context
friend void check_context(object const &a, object const &b)
Definition: z3++.h:410
Z3_goal_convert_model
Z3_model Z3_API Z3_goal_convert_model(Z3_context c, Z3_goal g, Z3_model m)
Convert a model of the formulas of a goal to a model of an original goal. The model may be null,...
z3::object::check_error
Z3_error_code check_error() const
Definition: z3++.h:407
z3::object::ctx
context & ctx() const
Definition: z3++.h:406
Z3_goal_inconsistent
bool Z3_API Z3_goal_inconsistent(Z3_context c, Z3_goal g)
Return true if the given goal contains the formula false.