1. Arlen Cox
  2. z3

Commits

Leonardo de Moura  committed 4c98b56

old_params ==> front_end_params. Isolated abstract solver interface

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>

  • Participants
  • Parent commits 62cc752
  • Branches master

Comments (0)

Files changed (102)

File scripts/mk_project.py

View file
  • Ignore whitespace
     add_lib('parser_util', ['ast'], 'parsers/util')
     add_lib('grobner', ['ast'], 'math/grobner')
     add_lib('euclid', ['util'], 'math/euclid')
-    # Old (non-modular) parameter framework. It has been subsumed by util\params.h.
-    # However, it is still used by many old components.
-    add_lib('old_params', ['ast'])
+    # Front-end-params module still contain a lot of parameters for smt solver component.
+    # This should be fixed
+    add_lib('front_end_params', ['ast'])
     # Simplifier module will be deleted in the future.
     # It has been replaced with rewriter module.
-    add_lib('simplifier', ['rewriter', 'old_params'], 'ast/simplifier')
+    add_lib('simplifier', ['rewriter', 'front_end_params'], 'ast/simplifier')
     add_lib('normal_forms', ['rewriter', 'simplifier'], 'ast/normal_forms')
     add_lib('core_tactics', ['tactic', 'normal_forms'], 'tactic/core')
     add_lib('sat_tactic', ['tactic', 'sat'], 'sat/tactic')
     add_lib('nlsat_tactic', ['nlsat', 'sat_tactic', 'arith_tactics'], 'nlsat/tactic')
     add_lib('subpaving_tactic', ['core_tactics', 'subpaving'], 'math/subpaving/tactic')
     add_lib('aig_tactic', ['tactic'], 'tactic/aig')
-    add_lib('cmd_context', ['tactic', 'rewriter', 'model', 'old_params'])
+    add_lib('solver', ['model', 'tactic', 'front_end_params'])
+    add_lib('cmd_context', ['solver', 'rewriter'])
     add_lib('extra_cmds', ['cmd_context', 'subpaving_tactic', 'arith_tactics'], 'cmd_context/extra_cmds')
     add_lib('smt2parser', ['cmd_context', 'parser_util'], 'parsers/smt2')
     add_lib('pattern', ['normal_forms', 'smt2parser'], 'ast/pattern')
-    add_lib('macros', ['simplifier', 'old_params'], 'ast/macros')
-    add_lib('proof_checker', ['rewriter', 'old_params'], 'ast/proof_checker')
-    add_lib('bit_blaster', ['rewriter', 'simplifier', 'old_params'], 'ast/rewriter/bit_blaster')
-    add_lib('proto_model', ['model', 'simplifier', 'old_params'], 'smt/proto_model')
+    add_lib('macros', ['simplifier', 'front_end_params'], 'ast/macros')
+    add_lib('proof_checker', ['rewriter', 'front_end_params'], 'ast/proof_checker')
+    add_lib('bit_blaster', ['rewriter', 'simplifier', 'front_end_params'], 'ast/rewriter/bit_blaster')
+    add_lib('proto_model', ['model', 'simplifier', 'front_end_params'], 'smt/proto_model')
     add_lib('smt', ['bit_blaster', 'macros', 'normal_forms', 'cmd_context', 'proto_model',
                     'substitution', 'grobner', 'euclid', 'proof_checker', 'pattern', 'parser_util'])
     add_lib('user_plugin', ['smt'], 'smt/user_plugin')

File scripts/mk_util.py

View file
  • Ignore whitespace
 
 def cp_z3pyc_to_build():
     mk_dir(BUILD_DIR)
-    compileall.compile_dir(Z3PY_SRC_DIR, force=1)
+    if compileall.compile_dir(Z3PY_SRC_DIR, force=1) != 1:
+        raise MKException("failed to compile Z3Py sources")
     for pyc in filter(lambda f: f.endswith('.pyc'), os.listdir(Z3PY_SRC_DIR)):
         try:
             os.remove('%s/%s' % (BUILD_DIR, pyc))

File scripts/update_api.py

View file
  • Ignore whitespace
 mk_dotnet()
 mk_dotnet_wrappers()
 
+log_h.close()
+log_c.close()
+exe_c.close()
+core_py.close()
+
 if is_verbose():
     print "Generated '%s'" % ('%s/api_log_macros.h' % api_dir)
     print "Generated '%s'" % ('%s/api_log_macros.cpp' % api_dir)

File src/api/api_solver.cpp

View file
  • Ignore whitespace
         LOG_Z3_mk_solver_from_tactic(c, t);
         RESET_ERROR_CODE();
         Z3_solver_ref * s = alloc(Z3_solver_ref);
-        s->m_solver       = alloc(tactic2solver_api, to_tactic_ref(t));
+        s->m_solver       = alloc(tactic2solver, to_tactic_ref(t));
         s->m_solver->set_front_end_params(mk_c(c)->fparams());
         s->m_solver->init(mk_c(c)->m(), symbol::null);
         mk_c(c)->save_object(s);

File src/api/python/z3poly.py

  • Ignore whitespace
-############################################
-# Copyright (c) 2012 Microsoft Corporation
-# 
-# Z3 Polynomial interface
-#
-# Author: Leonardo de Moura (leonardo)
-############################################
-from z3 import *
-
-class PolynomialManager:
-    """Polynomial Manager.
-    """
-    def __init__(self, ctx=None):
-        self.ctx     = z3._get_ctx(ctx)
-        self.manager = Z3_mk_polynomial_manager(self.ctx_ref())
-        
-    def __del__(self):
-        Z3_del_polynomial_manager(self.ctx_ref(), self.manager)
-
-    def ctx_ref(self):
-        return self.ctx.ref()
-
-    def m(self):
-        return self.manager
-
-_main_pmanager = None
-def main_pmanager():
-    """Return a reference to the global Polynomial manager.
-    """
-    global _main_pmanager
-    if _main_pmanager == None:
-        _main_pmanager = PolynomialManager()
-    return _main_pmanager  
-
-def _get_pmanager(ctx):
-    if ctx == None:
-        return main_pmanager()
-    else:
-        return ctx
-
-class Polynomial:
-    """Multivariate polynomials.
-    """
-    def __init__(self, poly=None, m=None):
-        self.pmanager = _get_pmanager(m)
-        if poly == None:
-            self.poly = Z3_mk_zero_polynomial(self.ctx_ref(), self.m())
-        else:
-            self.poly = poly
-        Z3_polynomial_inc_ref(self.ctx_ref(), self.m(), self.poly)
-    
-    def __del__(self):
-        Z3_polynomial_dec_ref(self.ctx_ref(), self.m(), self.poly)
-
-    def m(self):
-        return self.pmanager.m()
-
-    def ctx_ref(self):
-        return self.pmanager.ctx_ref()
-    
-    def __repr__(self):
-        return Z3_polynomial_to_string(self.ctx_ref(), self.m(), self.poly)
-
-# test
-p = Polynomial()
-print p
-

File src/cmd_context/basic_cmds.cpp

View file
  • Ignore whitespace
 #include"cmd_util.h"
 #include"simplify_cmd.h"
 #include"eval_cmd.h"
+#include"front_end_params.h"
 
 class help_cmd : public cmd {
     svector<symbol> m_cmds;

File src/cmd_context/check_sat_result.h

  • Ignore whitespace
-/*++
-Copyright (c) 2012 Microsoft Corporation
-
-Module Name:
-
-    check_sat_result.h
-
-Abstract:
-    Abstract interface for storing the result produced by 
-    a check_sat like command
-
-Author:
-
-    Leonardo (leonardo) 2012-01-23
-
-Notes:
-
---*/
-#ifndef _CHECK_SAT_RESULT_H_
-#define _CHECK_SAT_RESULT_H_
-
-#include"model.h"
-#include"lbool.h"
-#include"statistics.h"
-
-class check_sat_result {
-protected:
-    unsigned    m_ref_count;
-    lbool       m_status; 
-public:
-    check_sat_result():m_ref_count(0), m_status(l_undef) {}
-    virtual ~check_sat_result() {}
-    void inc_ref() { m_ref_count++; }
-    void dec_ref() { SASSERT(m_ref_count > 0); m_ref_count--; if (m_ref_count == 0) dealloc(this); }
-    void set_status(lbool r) { m_status = r; }
-    lbool status() const { return m_status; }
-    virtual void collect_statistics(statistics & st) const = 0;
-    virtual void get_unsat_core(ptr_vector<expr> & r) = 0;
-    virtual void get_model(model_ref & m) = 0;
-    virtual proof * get_proof() = 0;
-    virtual std::string reason_unknown() const = 0;
-    virtual void get_labels(svector<symbol> & r) = 0;
-};
-
-struct simple_check_sat_result : public check_sat_result {
-    statistics      m_stats;
-    model_ref       m_model;
-    expr_ref_vector m_core;
-    proof_ref       m_proof;
-    std::string     m_unknown;
-
-    simple_check_sat_result(ast_manager & m):
-        m_core(m),
-        m_proof(m) {
-    }
-    virtual ~simple_check_sat_result() {}
-    virtual void collect_statistics(statistics & st) const { st.copy(m_stats); }
-    virtual void get_unsat_core(ptr_vector<expr> & r) { if (m_status == l_false) r.append(m_core.size(), m_core.c_ptr()); }
-    virtual void get_model(model_ref & m) { 
-        if (m_status != l_false) m = m_model; else m = 0; 
-    }
-    virtual proof * get_proof() { return m_status == l_false ? m_proof.get() : 0; }
-    virtual std::string reason_unknown() const { 
-        return m_unknown; 
-    }
-    virtual void get_labels(svector<symbol> & r) {}
-};
-
-#endif

File src/cmd_context/cmd_context.cpp

View file
  • Ignore whitespace
     }
 }
 
+bool cmd_context::is_smtlib2_compliant() const { 
+    return params().m_smtlib2_compliant; 
+}
+
+bool cmd_context::produce_models() const { 
+    return params().m_model; 
+}
+
+bool cmd_context::produce_proofs() const { 
+    return params().m_proof_mode != PGM_DISABLED; 
+}
+
 cmd_context::check_sat_state cmd_context::cs_state() const {
     if (m_check_sat_result.get() == 0)
         return css_clear;

File src/cmd_context/cmd_context.h

View file
  • Ignore whitespace
 public:
     cmd_context(front_end_params * params = 0, bool main_ctx = true, ast_manager * m = 0, symbol const & l = symbol::null);
     ~cmd_context(); 
-    bool is_smtlib2_compliant() const { return params().m_smtlib2_compliant; }
+    bool is_smtlib2_compliant() const;
     void set_logic(symbol const & s);
     bool has_logic() const { return m_logic != symbol::null; }
     symbol const & get_logic() const { return m_logic; }
     void set_global_decls(bool flag) { SASSERT(!has_manager()); m_global_decls = flag; }
     unsigned random_seed() const { return m_random_seed; }
     void set_random_seed(unsigned s) { m_random_seed = s; }
-    bool produce_models() const { return params().m_model; }
-    bool produce_proofs() const { return params().m_proof_mode != PGM_DISABLED; }
+    bool produce_models() const;
+    bool produce_proofs() const;
     bool produce_unsat_cores() const { return m_produce_unsat_cores; }
     void set_produce_unsat_cores(bool flag) { m_produce_unsat_cores = flag; }
     bool produce_assignments() const { return m_produce_assignments; }

File src/cmd_context/progress_callback.h

  • Ignore whitespace
-/*++
-Copyright (c) 2008 Microsoft Corporation
-
-Module Name:
-
-    progress_callback.h
-
-Abstract:
-
-    Virtual callback for reporting progress.
-
-Author:
-
-    Michal Moskal (micmo) 2009-02-17.
-
-Revision History:
-
---*/
-#ifndef _PROGRESS_CALLBACK_H_
-#define _PROGRESS_CALLBACK_H_
-
-class progress_callback {
-public:
-    virtual ~progress_callback() {}
-    
-    // Called approx. every m_progress_sampling_freq miliseconds
-    virtual void slow_progress_sample() { }
-    
-    // Called on every check for reqsource limit exceeded (mach more frequent).
-    virtual void fast_progress_sample() { }
-};
-
-#endif

File src/cmd_context/solver.cpp

  • Ignore whitespace
-/*++
-Copyright (c) 2011 Microsoft Corporation
-
-Module Name:
-
-    solver.h
-
-Abstract:
-
-    abstract solver interface
-
-Author:
-
-    Leonardo (leonardo) 2011-03-19
-
-Notes:
-
---*/
-#include"solver.h"
-
-unsigned solver::get_num_assertions() const {
-    NOT_IMPLEMENTED_YET();
-    return 0;
-}
-
-expr * solver::get_assertion(unsigned idx) const {
-    NOT_IMPLEMENTED_YET();
-    return 0;
-}
-
-void solver::display(std::ostream & out) const {
-    out << "(solver)";
-}
-

File src/cmd_context/solver.h

  • Ignore whitespace
-/*++
-Copyright (c) 2011 Microsoft Corporation
-
-Module Name:
-
-    solver.h
-
-Abstract:
-
-    abstract solver interface
-
-Author:
-
-    Leonardo (leonardo) 2011-03-19
-
-Notes:
-
---*/
-#ifndef _SOLVER_H_
-#define _SOLVER_H_
-
-#include"check_sat_result.h"
-#include"front_end_params.h"
-#include"progress_callback.h"
-#include"params.h"
-
-class solver : public check_sat_result {
-public:
-    virtual ~solver() {}
-    
-    // for backward compatibility
-    virtual void set_front_end_params(front_end_params & p) {} 
-
-    virtual void updt_params(params_ref const & p) {}
-    virtual void collect_param_descrs(param_descrs & r) {}
-
-    virtual void set_produce_proofs(bool f) {}
-    virtual void set_produce_models(bool f) {}
-    virtual void set_produce_unsat_cores(bool f) {}
-    
-    virtual void init(ast_manager & m, symbol const & logic) = 0;
-    virtual void reset() = 0;
-    virtual void assert_expr(expr * t) = 0;
-    virtual void push() = 0;
-    virtual void pop(unsigned n) = 0;
-    virtual unsigned get_scope_level() const = 0;
-    virtual lbool check_sat(unsigned num_assumptions, expr * const * assumptions) = 0;
-
-    virtual void set_cancel(bool f) {}
-    void cancel() { set_cancel(true); }
-    void reset_cancel() { set_cancel(false); }
-
-    virtual void set_progress_callback(progress_callback * callback) = 0;
-
-    virtual unsigned get_num_assertions() const;
-    virtual expr * get_assertion(unsigned idx) const;
-
-    virtual void display(std::ostream & out) const;
-};
-
-#endif

File src/cmd_context/strategic_solver.cpp

  • Ignore whitespace
-/*++
-Copyright (c) 2011 Microsoft Corporation
-
-Module Name:
-
-    strategic_solver.h
-
-Abstract:
-
-    Strategies -> Solver
-
-Author:
-
-    Leonardo (leonardo) 2011-05-19
-
-Notes:
-
---*/
-#include"strategic_solver.h"
-#include"cmd_context.h"
-#include"scoped_timer.h"
-#include"params2front_end_params.h"
-#include"ast_smt2_pp.h"
-
-// minimum verbosity level for portfolio verbose messages
-#define PS_VB_LVL 15
-
-strategic_solver::strategic_solver():
-    m_manager(0),
-    m_fparams(0),
-    m_force_tactic(false),
-    m_inc_mode(false),
-    m_check_sat_executed(false),
-    m_inc_solver(0),
-    m_inc_solver_timeout(UINT_MAX),
-    m_inc_unknown_behavior(IUB_USE_TACTIC_IF_QF),
-    m_default_fct(0),
-    m_curr_tactic(0),
-    m_proof(0),
-    m_callback(0) {
-    m_use_inc_solver_results = false;
-    DEBUG_CODE(m_num_scopes = 0;);
-    m_produce_proofs = false;
-    m_produce_models = false;
-    m_produce_unsat_cores = false;
-}
-
-strategic_solver::~strategic_solver() {
-    SASSERT(!m_curr_tactic);
-    dictionary<tactic_factory*>::iterator it  = m_logic2fct.begin();
-    dictionary<tactic_factory*>::iterator end = m_logic2fct.end();
-    for (; it != end; ++it) {
-        dealloc(it->m_value);
-    }
-    if (m_proof)
-        m().dec_ref(m_proof);
-}
-
-bool strategic_solver::has_quantifiers() const {
-    unsigned sz = get_num_assertions();
-    for (unsigned i = 0; i < sz; i++) {
-        if (::has_quantifiers(get_assertion(i)))
-            return true;
-    }
-    return false;
-}
-
-/**
-   \brief Return true if a tactic should be used when the incremental solver returns unknown.
-*/
-bool strategic_solver::use_tactic_when_undef() const {
-    switch (m_inc_unknown_behavior) {
-    case IUB_RETURN_UNDEF: return false;
-    case IUB_USE_TACTIC_IF_QF: return !has_quantifiers();
-    case IUB_USE_TACTIC: return true;
-    default:
-        UNREACHABLE();
-        return false;
-    }
-}
-
-void strategic_solver::set_inc_solver(solver * s) {
-    SASSERT(m_inc_solver == 0);
-    SASSERT(m_num_scopes == 0);
-    m_inc_solver = s;
-    if (m_callback)
-        m_inc_solver->set_progress_callback(m_callback);
-}
-
-void strategic_solver::updt_params(params_ref const & p) {
-    if (m_inc_solver)
-        m_inc_solver->updt_params(p);
-    if (m_fparams)
-        params2front_end_params(p, *m_fparams);
-}
-
-
-void strategic_solver::collect_param_descrs(param_descrs & r) {
-    if (m_inc_solver)
-        m_inc_solver->collect_param_descrs(r);
-}
-
-/**
-   \brief Set a timeout for each check_sat query that is processed by the inc_solver.
-   timeout == UINT_MAX means infinite
-   After the timeout a strategy is used.
-*/
-void strategic_solver::set_inc_solver_timeout(unsigned timeout) {
-    m_inc_solver_timeout = timeout;
-}
-
-/**
-   \brief Set the default tactic factory.
-   It is used if there is no tactic for a given logic.
-*/
-void strategic_solver::set_default_tactic(tactic_factory * fct) {
-    m_default_fct = fct;
-}
-
-/**
-   \brief Set a tactic factory for a given logic.
-*/
-void strategic_solver::set_tactic_for(symbol const & logic, tactic_factory * fct) {
-    tactic_factory * old_fct;
-    if (m_logic2fct.find(logic, old_fct)) {
-        dealloc(old_fct);
-    }
-    m_logic2fct.insert(logic, fct);
-}
-
-void strategic_solver::init(ast_manager & m, symbol const & logic) {
-    m_manager = &m;
-    m_logic   = logic;
-    if (m_inc_mode) {
-        SASSERT(m_inc_solver);
-        m_inc_solver->init(m, logic);
-    }
-}
-
-// delayed inc solver initialization
-void strategic_solver::init_inc_solver() {
-    if (m_inc_mode) 
-        return; // solver was already initialized
-    if (!m_inc_solver)
-        return; // inc solver was not installed
-    m_inc_mode = true;
-    m_inc_solver->set_front_end_params(*m_fparams);
-    m_inc_solver->init(m(), m_logic);
-    unsigned sz = get_num_assertions();
-    for (unsigned i = 0; i < sz; i++) {
-        m_inc_solver->assert_expr(get_assertion(i));
-    }
-}
-
-void strategic_solver::collect_statistics(statistics & st) const {
-    if (m_use_inc_solver_results) {
-        SASSERT(m_inc_solver);
-        m_inc_solver->collect_statistics(st);
-    }
-    else {
-        if (m_curr_tactic) 
-            m_curr_tactic->collect_statistics(st); // m_curr_tactic is still being executed.
-        else
-            st.copy(m_stats);
-    }
-}
-
-void strategic_solver::reset() {
-    m_logic    = symbol::null;
-    m_inc_mode = false;
-    m_check_sat_executed = false;
-    if (m_inc_solver)
-        m_inc_solver->reset();
-    SASSERT(!m_curr_tactic);
-    m_use_inc_solver_results = false;
-    reset_results();
-}
-
-void strategic_solver::reset_results() {
-    m_use_inc_solver_results = false;
-    m_model = 0;
-    if (m_proof) {
-        m().dec_ref(m_proof);
-        m_proof = 0;
-    }
-    m_reason_unknown.clear();
-    m_stats.reset();
-}
-
-void strategic_solver::assert_expr(expr * t) {
-    if (m_check_sat_executed && !m_inc_mode) {
-        // a check sat was already executed --> switch to incremental mode
-        init_inc_solver();
-        SASSERT(m_inc_solver == 0 || m_inc_mode);
-    }
-    if (m_inc_mode) {
-        SASSERT(m_inc_solver);
-        m_inc_solver->assert_expr(t);
-    }
-}
-
-void strategic_solver::push() {
-    DEBUG_CODE(m_num_scopes++;);
-    init_inc_solver();
-    if (m_inc_solver)
-        m_inc_solver->push();
-}
-
-void strategic_solver::pop(unsigned n) {
-    DEBUG_CODE({
-            SASSERT(n <= m_num_scopes);
-            m_num_scopes -= n;
-        });
-    init_inc_solver();
-    if (m_inc_solver)
-        m_inc_solver->pop(n);
-}
-
-unsigned strategic_solver::get_scope_level() const {
-    if (m_inc_solver)
-        return m_inc_solver->get_scope_level();
-    else
-        return 0;
-}
-
-struct aux_timeout_eh : public event_handler {
-    solver *        m_solver;
-    volatile bool   m_canceled;
-    aux_timeout_eh(solver * s):m_solver(s), m_canceled(false) {}
-    virtual void operator()() {
-        m_solver->cancel();
-        m_canceled = true;
-    }
-};
-
-struct strategic_solver::mk_tactic {
-    strategic_solver *  m_solver;
-
-    mk_tactic(strategic_solver * s, tactic_factory * f):m_solver(s) {
-        ast_manager & m = s->m();
-        params_ref p;
-        front_end_params2params(*s->m_fparams, p);
-        tactic * tct = (*f)(m, p);
-        tct->set_front_end_params(*s->m_fparams);
-        tct->set_logic(s->m_logic);
-        if (s->m_callback)
-            tct->set_progress_callback(s->m_callback);
-        #pragma omp critical (strategic_solver) 
-        {
-            s->m_curr_tactic = tct;
-        }
-    }
-
-    ~mk_tactic() {
-        #pragma omp critical (strategic_solver)
-        {
-            m_solver->m_curr_tactic = 0;
-        }
-    }
-};
-
-tactic_factory * strategic_solver::get_tactic_factory() const {
-    tactic_factory * f = 0;
-    if (m_logic2fct.find(m_logic, f))
-        return f;
-    return m_default_fct.get();
-}
-
-lbool strategic_solver::check_sat_with_assumptions(unsigned num_assumptions, expr * const * assumptions) {
-    if (!m_inc_solver) {
-        IF_VERBOSE(PS_VB_LVL, verbose_stream() << "incremental solver was not installed, returning unknown...\n";);
-        m_use_inc_solver_results = false;
-        m_reason_unknown         = "incomplete";
-        return l_undef; 
-    }
-    init_inc_solver();
-    m_use_inc_solver_results = true;
-    return m_inc_solver->check_sat(num_assumptions, assumptions);
-}
-
-lbool strategic_solver::check_sat(unsigned num_assumptions, expr * const * assumptions) {
-    reset_results();
-    m_check_sat_executed = true;
-    if (num_assumptions > 0 || // assumptions were provided
-        (!m_fparams->m_auto_config && !m_force_tactic) // auto config and force_tactic are turned off
-        ) {
-        // must use incremental solver
-        return check_sat_with_assumptions(num_assumptions, assumptions);
-    }
-
-    tactic_factory * factory = get_tactic_factory();
-    if (factory == 0)
-        init_inc_solver(); // try to switch to incremental solver
-    
-    if (m_inc_mode) {
-        SASSERT(m_inc_solver);
-        unsigned timeout = m_inc_solver_timeout;
-        if (factory == 0)
-            timeout = UINT_MAX; // there is no tactic available
-        if (timeout == UINT_MAX) {
-            IF_VERBOSE(PS_VB_LVL, verbose_stream() << "using incremental solver (without a timeout).\n";);            
-            m_use_inc_solver_results = true;
-            lbool r = m_inc_solver->check_sat(0, 0);
-            if (r != l_undef || factory == 0 || !use_tactic_when_undef()) {
-                m_use_inc_solver_results = true;
-                return r;
-            }
-        }
-        else {
-            IF_VERBOSE(PS_VB_LVL, verbose_stream() << "using incremental solver (with timeout).\n";);            
-            SASSERT(factory != 0);
-            aux_timeout_eh eh(m_inc_solver.get());
-            lbool r;
-            {
-                scoped_timer timer(m_inc_solver_timeout, &eh);
-                r = m_inc_solver->check_sat(0, 0);
-            }
-            if ((r != l_undef || !use_tactic_when_undef()) && !eh.m_canceled) {
-                m_use_inc_solver_results = true;
-                return r;
-            }
-        }
-        IF_VERBOSE(PS_VB_LVL, verbose_stream() << "incremental solver failed, trying tactic.\n";);                        
-    }
-    
-    m_use_inc_solver_results = false;
-    
-    if (factory == 0) {
-        IF_VERBOSE(PS_VB_LVL, verbose_stream() << "there is no tactic available for the current logic.\n";);            
-        m_reason_unknown         = "incomplete";
-        return l_undef; 
-    }
-
-    goal_ref g = alloc(goal, m(), m_produce_proofs, m_produce_models, m_produce_unsat_cores);
-    unsigned sz = get_num_assertions();
-    for (unsigned i = 0; i < sz; i++) {
-        g->assert_expr(get_assertion(i));
-    }
-    expr_dependency_ref core(m());
-    
-    mk_tactic tct_maker(this, factory);
-    SASSERT(m_curr_tactic);
-
-    proof_ref pr(m());
-    lbool r = ::check_sat(*(m_curr_tactic.get()), g, m_model, pr, core, m_reason_unknown);
-    m_curr_tactic->collect_statistics(m_stats);
-    if (pr) {
-        m_proof = pr; 
-        m().inc_ref(m_proof);
-    }
-    return r;
-}
-
-void strategic_solver::set_cancel(bool f) {
-    if (m_inc_solver)
-        m_inc_solver->set_cancel(f);
-    #pragma omp critical (strategic_solver)
-    {
-        if (m_curr_tactic)
-            m_curr_tactic->set_cancel(f);
-    }
-}
-
-void strategic_solver::get_unsat_core(ptr_vector<expr> & r) {
-    if (m_use_inc_solver_results) {
-        SASSERT(m_inc_solver);
-        m_inc_solver->get_unsat_core(r); 
-    }
-}
-
-void strategic_solver::get_model(model_ref & m) {
-    if (m_use_inc_solver_results) {
-        SASSERT(m_inc_solver);
-        m_inc_solver->get_model(m);
-    }
-    else {
-        m = m_model;
-    }
-}
-
-proof * strategic_solver::get_proof() {
-    if (m_use_inc_solver_results) {
-        SASSERT(m_inc_solver);
-        return m_inc_solver->get_proof();
-    }
-    else {
-        return m_proof;
-    }
-}
-
-std::string strategic_solver::reason_unknown() const {
-    if (m_use_inc_solver_results) {
-        SASSERT(m_inc_solver);
-        return m_inc_solver->reason_unknown();
-    }
-    return m_reason_unknown;
-}
-
-void strategic_solver::get_labels(svector<symbol> & r) {
-    if (m_use_inc_solver_results) {
-        SASSERT(m_inc_solver);
-        m_inc_solver->get_labels(r);
-    }
-}
-
-void strategic_solver::set_progress_callback(progress_callback * callback) { 
-    m_callback = callback; 
-    if (m_inc_solver)
-        m_inc_solver->set_progress_callback(callback);
-}
-
-void strategic_solver::display(std::ostream & out) const {
-    if (m_manager) {
-        unsigned num = get_num_assertions();
-        out << "(solver";
-        for (unsigned i = 0; i < num; i++) {
-            out << "\n  " << mk_ismt2_pp(get_assertion(i), m(), 2);
-        }
-        out << ")";
-    }
-    else {
-        out << "(solver)";
-    }
-}
-
-strategic_solver_cmd::strategic_solver_cmd(cmd_context & ctx):
-    m_ctx(ctx) {
-}
-
-unsigned strategic_solver_cmd::get_num_assertions() const {
-    return static_cast<unsigned>(m_ctx.end_assertions() - m_ctx.begin_assertions());
-}
-
-expr * strategic_solver_cmd::get_assertion(unsigned idx) const {
-    SASSERT(idx < get_num_assertions());
-    return m_ctx.begin_assertions()[idx];
-}
-
-strategic_solver_api::ctx::ctx(ast_manager & m):m_assertions(m) {
-}
-
-void strategic_solver_api::init(ast_manager & m, symbol const & logic) {
-    strategic_solver::init(m, logic);
-    m_ctx = alloc(ctx, m);
-}
-
-unsigned strategic_solver_api::get_num_assertions() const {
-    if (m_ctx == 0)
-        return 0;
-    return m_ctx->m_assertions.size();
-}
-
-expr * strategic_solver_api::get_assertion(unsigned idx) const {
-    SASSERT(m_ctx);
-    return m_ctx->m_assertions.get(idx);
-}
-
-void strategic_solver_api::assert_expr(expr * t) {
-    SASSERT(m_ctx);
-    strategic_solver::assert_expr(t);
-    m_ctx->m_assertions.push_back(t);
-}
-
-void strategic_solver_api::push() {
-    SASSERT(m_ctx);
-    strategic_solver::push();
-    m_ctx->m_scopes.push_back(m_ctx->m_assertions.size());
-}
-
-void strategic_solver_api::pop(unsigned n) {
-    SASSERT(m_ctx);
-    unsigned new_lvl = m_ctx->m_scopes.size() - n;
-    unsigned old_sz  = m_ctx->m_scopes[new_lvl];
-    m_ctx->m_assertions.shrink(old_sz);
-    m_ctx->m_scopes.shrink(new_lvl);
-    strategic_solver::pop(n);
-}
-
-void strategic_solver_api::reset() {
-    m_ctx = 0;
-    strategic_solver::reset();
-}
-
-
-

File src/cmd_context/strategic_solver.h

  • Ignore whitespace
-/*++
-Copyright (c) 2011 Microsoft Corporation
-
-Module Name:
-
-    strategic_solver.h
-
-Abstract:
-
-    Strategies -> Solver
-
-Author:
-
-    Leonardo (leonardo) 2011-05-19
-
-Notes:
-
---*/
-#ifndef _STRATEGIC_SOLVER_H_
-#define _STRATEGIC_SOLVER_H_
-
-#include"solver.h"
-#include"tactic.h"
-
-class progress_callback;
-struct front_end_params;
-
-class strategic_solver : public solver {
-public:
-    // Behavior when the incremental solver returns unknown.
-    enum inc_unknown_behavior {
-        IUB_RETURN_UNDEF,      // just return unknown
-        IUB_USE_TACTIC_IF_QF,  // invoke tactic if problem is quantifier free
-        IUB_USE_TACTIC         // invoke tactic
-    };
-
-private:
-    ast_manager *        m_manager;
-    front_end_params *   m_fparams;
-    symbol               m_logic;
-    bool                 m_force_tactic; // use tactics even when auto_config = false
-    bool                 m_inc_mode;
-    bool                 m_check_sat_executed;
-    scoped_ptr<solver>   m_inc_solver;
-    unsigned             m_inc_solver_timeout;
-    inc_unknown_behavior m_inc_unknown_behavior;
-    scoped_ptr<tactic_factory>  m_default_fct;
-    dictionary<tactic_factory*> m_logic2fct;
-
-    ref<tactic>          m_curr_tactic;
-    
-    bool                 m_use_inc_solver_results;
-    model_ref            m_model;
-    proof *              m_proof;
-    std::string          m_reason_unknown;
-    statistics           m_stats;
-
-#ifdef Z3DEBUG
-    unsigned             m_num_scopes;
-#endif
-
-    bool                 m_produce_proofs;
-    bool                 m_produce_models;
-    bool                 m_produce_unsat_cores;
-
-    progress_callback *  m_callback;
-
-    void reset_results();
-    void init_inc_solver();
-    tactic_factory * get_tactic_factory() const;
-    lbool check_sat_with_assumptions(unsigned num_assumptions, expr * const * assumptions);
-
-    struct mk_tactic;
-
-    bool has_quantifiers() const;
-    bool use_tactic_when_undef() const;
-
-public:
-    strategic_solver();
-    ~strategic_solver();
-
-    ast_manager & m() const { SASSERT(m_manager); return *m_manager; }
-
-    void set_inc_solver(solver * s);
-    void set_inc_solver_timeout(unsigned timeout);
-    void set_default_tactic(tactic_factory * fct);
-    void set_tactic_for(symbol const & logic, tactic_factory * fct);
-    void set_inc_unknown_behavior(inc_unknown_behavior b) { m_inc_unknown_behavior = b; }
-    void force_tactic(bool f) { m_force_tactic = f; }
-
-    virtual void set_front_end_params(front_end_params & p) { m_fparams = &p; }
-
-    virtual void updt_params(params_ref const & p);
-    virtual void collect_param_descrs(param_descrs & r);
-
-    virtual void set_produce_proofs(bool f) { m_produce_proofs = f; }
-    virtual void set_produce_models(bool f) { m_produce_models = f; }
-    virtual void set_produce_unsat_cores(bool f) { m_produce_unsat_cores = f; }
-
-    virtual unsigned get_num_assertions() const = 0;
-    virtual expr * get_assertion(unsigned idx) const = 0;
-    
-    virtual void display(std::ostream & out) const;
-    
-    virtual void init(ast_manager & m, symbol const & logic);
-    virtual void collect_statistics(statistics & st) const;
-    virtual void reset();
-    virtual void assert_expr(expr * t);
-    virtual void push();
-    virtual void pop(unsigned n);
-    virtual unsigned get_scope_level() const;
-    virtual lbool check_sat(unsigned num_assumptions, expr * const * assumptions);
-    virtual void get_unsat_core(ptr_vector<expr> & r);
-    virtual void get_model(model_ref & m);
-    virtual proof * get_proof();
-    virtual std::string reason_unknown() const;
-    virtual void get_labels(svector<symbol> & r);
-    virtual void set_cancel(bool f);
-    virtual void set_progress_callback(progress_callback * callback);
-};
-
-// Specialization for the SMT 2.0 command language frontend
-class strategic_solver_cmd : public strategic_solver {
-    cmd_context &        m_ctx;
-public:
-    strategic_solver_cmd(cmd_context & ctx);
-    virtual unsigned get_num_assertions() const;
-    virtual expr * get_assertion(unsigned idx) const;
-};
-
-// Specialization for Z3 API
-class strategic_solver_api : public strategic_solver {
-    struct ctx {
-        expr_ref_vector              m_assertions;
-        unsigned_vector              m_scopes;
-        ctx(ast_manager & m);
-    };
-    scoped_ptr<ctx>            m_ctx;
-public:
-    strategic_solver_api() {}
-
-    virtual void init(ast_manager & m, symbol const & logic);
-
-    virtual void assert_expr(expr * t);
-    virtual void push();
-    virtual void pop(unsigned n);
-    virtual void reset();
-
-    virtual unsigned get_num_assertions() const;
-    virtual expr * get_assertion(unsigned idx) const;
-};
-
-
-
-#endif

File src/cmd_context/strategic_solver_cmd.cpp

View file
  • Ignore whitespace
+/*++
+Copyright (c) 2012 Microsoft Corporation
+
+Module Name:
+
+    strategic_solver_cmd.h
+
+Abstract:
+
+    Specialization of the strategic solver that
+    used cmd_context to access the assertion set.
+
+Author:
+
+    Leonardo (leonardo) 2012-11-01
+
+Notes:
+
+--*/
+#include"strategic_solver_cmd.h"
+#include"cmd_context.h"
+
+strategic_solver_cmd::strategic_solver_cmd(cmd_context & ctx):
+    m_ctx(ctx) {
+}
+
+unsigned strategic_solver_cmd::get_num_assertions() const {
+    return static_cast<unsigned>(m_ctx.end_assertions() - m_ctx.begin_assertions());
+}
+
+expr * strategic_solver_cmd::get_assertion(unsigned idx) const {
+    SASSERT(idx < get_num_assertions());
+    return m_ctx.begin_assertions()[idx];
+}

File src/cmd_context/strategic_solver_cmd.h

View file
  • Ignore whitespace
+/*++
+Copyright (c) 2012 Microsoft Corporation
+
+Module Name:
+
+    strategic_solver_cmd.h
+
+Abstract:
+
+    Specialization of the strategic solver that
+    used cmd_context to access the assertion set.
+
+Author:
+
+    Leonardo (leonardo) 2012-11-01
+
+Notes:
+
+--*/
+#ifndef _STRATEGIC_SOLVER_CMD_H_
+#define _STRATEGIC_SOLVER_CMD_H_
+
+#include"strategic_solver.h"
+
+class cmd_context;
+
+/**
+   Specialization for the SMT 2.0 command language frontend.
+
+   The strategic solver does not have to maintain a copy of the assertion set in the cmd_context.
+*/
+class strategic_solver_cmd : public strategic_solver_core {
+    cmd_context &        m_ctx;
+public:
+    strategic_solver_cmd(cmd_context & ctx);
+    virtual unsigned get_num_assertions() const;
+    virtual expr * get_assertion(unsigned idx) const;
+};
+
+#endif 

File src/cmd_context/tactic2solver.cpp

  • Ignore whitespace
-/*++
-Copyright (c) 2012 Microsoft Corporation
-
-Module Name:
-
-    tactic2solver.cpp
-
-Abstract:
-
-    Wrapper for implementing the solver interface
-    using a tactic.
-
-    This is a light version of the strategic solver.
-
-Author:
-
-    Leonardo (leonardo) 2012-01-23
-
-Notes:
-
---*/
-#include"tactic2solver.h"
-#include"params2front_end_params.h"
-#include"ast_smt2_pp.h"
-
-tactic2solver::ctx::ctx(ast_manager & m, symbol const & logic):
-    m_logic(logic),
-    m_assertions(m) {
-}
-
-tactic2solver::~tactic2solver() {
-}
-
-void tactic2solver::init(ast_manager & m, symbol const & logic) {
-    m_ctx = alloc(ctx, m, logic);
-}
-
-void tactic2solver::updt_params(params_ref const & p) {
-    m_params = p;
-}
-
-void tactic2solver::collect_param_descrs(param_descrs & r) {
-    if (m_ctx) {
-        if (!m_ctx->m_tactic) {
-            #pragma omp critical (tactic2solver)
-            {
-                m_ctx->m_tactic = get_tactic(m_ctx->m(), m_params);
-            }
-
-            if (m_ctx->m_tactic) {
-                m_ctx->m_tactic->collect_param_descrs(r);
-            }
-
-            #pragma omp critical (tactic2solver)
-            {
-                m_ctx->m_tactic = 0;
-            }
-        }
-        else {
-            m_ctx->m_tactic->collect_param_descrs(r);
-        }
-    }
-}
-
-void tactic2solver::reset() {
-    SASSERT(m_ctx);
-    m_ctx->m_assertions.reset();
-    m_ctx->m_scopes.reset();
-    m_ctx->m_result = 0;
-}
-
-void tactic2solver::assert_expr(expr * t) {
-    SASSERT(m_ctx);
-    m_ctx->m_assertions.push_back(t);
-    m_ctx->m_result = 0;
-}
-
-void tactic2solver::push() {
-    SASSERT(m_ctx);
-    m_ctx->m_scopes.push_back(m_ctx->m_assertions.size());
-    m_ctx->m_result = 0;
-}
-
-void tactic2solver::pop(unsigned n) {
-    SASSERT(m_ctx);
-    unsigned new_lvl = m_ctx->m_scopes.size() - n;
-    unsigned old_sz  = m_ctx->m_scopes[new_lvl];
-    m_ctx->m_assertions.shrink(old_sz);
-    m_ctx->m_scopes.shrink(new_lvl);
-    m_ctx->m_result = 0;
-}
-
-unsigned tactic2solver::get_scope_level() const {
-    SASSERT(m_ctx);
-    return m_ctx->m_scopes.size();
-}
-
-lbool tactic2solver::check_sat(unsigned num_assumptions, expr * const * assumptions) {
-    SASSERT(m_ctx);
-    ast_manager & m = m_ctx->m();
-    params_ref p = m_params;
-    if (m_fparams)
-        front_end_params2params(*m_fparams, p);
-    #pragma omp critical (tactic2solver)
-    {
-        m_ctx->m_tactic = get_tactic(m, p);
-        if (m_ctx->m_tactic) {
-            m_ctx->m_result = alloc(simple_check_sat_result, m);
-        }
-    }
-    if (!m_ctx->m_tactic)
-        return l_undef;
-    tactic & t                       = *(m_ctx->m_tactic);
-    simple_check_sat_result & result = *(m_ctx->m_result);
-    if (m_fparams)
-        t.set_front_end_params(*m_fparams);
-    goal_ref g = alloc(goal, m, m_produce_proofs, m_produce_models, m_produce_unsat_cores);
-    t.set_logic(m_ctx->m_logic);
-    unsigned sz = m_ctx->m_assertions.size();
-    for (unsigned i = 0; i < sz; i++) {
-        g->assert_expr(m_ctx->m_assertions.get(i));
-    }
-    for (unsigned i = 0; i < num_assumptions; i++) {
-        g->assert_expr(assumptions[i], m.mk_asserted(assumptions[i]), m.mk_leaf(assumptions[i]));
-    }
-
-    model_ref           md;
-    proof_ref           pr(m);
-    expr_dependency_ref core(m);
-    std::string         reason_unknown = "unknown";
-    try {
-        switch (::check_sat(t, g, md, pr, core, reason_unknown)) {
-        case l_true: 
-            result.set_status(l_true);
-            break;
-        case l_false: 
-            result.set_status(l_false);
-            break;
-        default: 
-            result.set_status(l_undef);
-            if (reason_unknown != "")
-                result.m_unknown = reason_unknown;
-            break;
-        }
-    }
-    catch (z3_error & ex) {
-        throw ex;
-    }
-    catch (z3_exception & ex) {
-        TRACE("tactic2solver", tout << "exception: " << ex.msg() << "\n";);
-        result.set_status(l_undef);
-        result.m_unknown = ex.msg();
-    }
-    t.collect_statistics(result.m_stats);
-    result.m_model = md;
-    result.m_proof = pr;
-    if (m_produce_unsat_cores) {
-        ptr_vector<expr> core_elems;
-        m.linearize(core, core_elems);
-        result.m_core.append(core_elems.size(), core_elems.c_ptr());
-    }
-    
-    #pragma omp critical (tactic2solver)
-    {
-        m_ctx->m_tactic = 0;
-    }
-    return result.status();
-}
-
-void tactic2solver::set_cancel(bool f) {
-    #pragma omp critical (tactic2solver)
-    {
-        if (m_ctx && m_ctx->m_tactic)
-            m_ctx->m_tactic->set_cancel(f);
-    }
-}
-
-void tactic2solver::collect_statistics(statistics & st) const {
-    if (m_ctx->m_result.get())
-        m_ctx->m_result->collect_statistics(st);
-}
-
-void tactic2solver::get_unsat_core(ptr_vector<expr> & r) {
-    if (m_ctx->m_result.get())
-        m_ctx->m_result->get_unsat_core(r);
-}
-
-void tactic2solver::get_model(model_ref & m) {
-    if (m_ctx->m_result.get())
-        m_ctx->m_result->get_model(m);
-}
-
-proof * tactic2solver::get_proof() {
-    if (m_ctx->m_result.get())
-        return m_ctx->m_result->get_proof();
-    else
-        return 0;
-}
-
-std::string tactic2solver::reason_unknown() const {
-    if (m_ctx->m_result.get())
-        return m_ctx->m_result->reason_unknown();
-    else
-        return std::string("unknown");
-}
-
-unsigned tactic2solver::get_num_assertions() const {
-    if (m_ctx) 
-        return m_ctx->m_assertions.size();
-    else
-        return 0;
-}
-
-expr * tactic2solver::get_assertion(unsigned idx) const {
-    SASSERT(m_ctx);
-    return m_ctx->m_assertions.get(idx);
-}
-
-void tactic2solver::display(std::ostream & out) const {
-    if (m_ctx) {
-        ast_manager & m = m_ctx->m_assertions.m();
-        unsigned num = m_ctx->m_assertions.size();
-        out << "(solver";
-        for (unsigned i = 0; i < num; i++) {
-            out << "\n  " << mk_ismt2_pp(m_ctx->m_assertions.get(i), m, 2);
-        }
-        out << ")";
-    }
-    else {
-        out << "(solver)";
-    }
-}
-
-void tactic2solver_cmd::set_tactic(tactic_factory * f) {
-    m_tactic_factory = f;
-}
-
-tactic * tactic2solver_cmd::get_tactic(ast_manager & m, params_ref const & p) {
-    if (m_tactic_factory == 0)
-        return 0;
-    return (*m_tactic_factory)(m, p);
-}
-
-tactic * tactic2solver_api::get_tactic(ast_manager & m, params_ref const & p) {
-    m_tactic->cleanup();
-    m_tactic->updt_params(p);
-    return m_tactic.get();
-}
-

File src/cmd_context/tactic2solver.h

  • Ignore whitespace
-/*++
-Copyright (c) 2012 Microsoft Corporation
-
-Module Name:
-
-    tactic2solver.h
-
-Abstract:
-
-    Wrapper for implementing the external solver interface
-    using a tactic.
-
-    This is a light version of the strategic solver.
-
-Author:
-
-    Leonardo (leonardo) 2012-01-23
-
-Notes:
-
---*/
-#ifndef _TACTIC2SOLVER_H_
-#define _TACTIC2SOLVER_H_
-
-#include"solver.h"
-#include"tactic.h"
-
-class tactic2solver : public solver {
-    struct ctx {
-        symbol                       m_logic;
-        expr_ref_vector              m_assertions;
-        unsigned_vector              m_scopes;
-        ref<simple_check_sat_result> m_result;
-        tactic_ref                   m_tactic;
-        ctx(ast_manager & m, symbol const & logic);
-        ast_manager & m() const { return m_assertions.m(); }
-    };
-    scoped_ptr<ctx>            m_ctx;
-    front_end_params *         m_fparams;
-    params_ref                 m_params;
-    bool                       m_produce_models;
-    bool                       m_produce_proofs;
-    bool                       m_produce_unsat_cores;
-public:
-    tactic2solver():m_ctx(0), m_fparams(0), m_produce_models(false), m_produce_proofs(false), m_produce_unsat_cores(false) {}
-    virtual ~tactic2solver();
-
-    virtual tactic * get_tactic(ast_manager & m, params_ref const & p) = 0;
-    
-    virtual void set_front_end_params(front_end_params & p) { m_fparams = &p; } 
-
-    virtual void updt_params(params_ref const & p);
-    virtual void collect_param_descrs(param_descrs & r);
-
-    virtual void set_produce_proofs(bool f) { m_produce_proofs = f; }
-    virtual void set_produce_models(bool f) { m_produce_models = f; }
-    virtual void set_produce_unsat_cores(bool f) { m_produce_unsat_cores = f; }
-
-    virtual void init(ast_manager & m, symbol const & logic);
-    virtual void reset();
-    virtual void assert_expr(expr * t);
-    virtual void push();
-    virtual void pop(unsigned n);
-    virtual unsigned get_scope_level() const;
-    virtual lbool check_sat(unsigned num_assumptions, expr * const * assumptions);
-
-    virtual void set_cancel(bool f);
-
-    virtual void collect_statistics(statistics & st) const;
-    virtual void get_unsat_core(ptr_vector<expr> & r);
-    virtual void get_model(model_ref & m);
-    virtual proof * get_proof();
-    virtual std::string reason_unknown() const;
-    virtual void get_labels(svector<symbol> & r) {}
-
-    virtual void set_progress_callback(progress_callback * callback) {}
-
-    virtual unsigned get_num_assertions() const;
-    virtual expr * get_assertion(unsigned idx) const;
-
-    virtual void display(std::ostream & out) const;
-};
-
-/**
-   \brief Specialization for cmd_context
-*/
-class tactic2solver_cmd : public tactic2solver {
-    scoped_ptr<tactic_factory> m_tactic_factory;
-public:
-    virtual ~tactic2solver_cmd() {}
-    /**
-       \brief Set tactic that will be used to process the satisfiability queries.
-    */
-    void set_tactic(tactic_factory * f); 
-    virtual tactic * get_tactic(ast_manager & m, params_ref const & p);
-};
-
-/**
-   \brief Specialization for API
-*/
-class tactic2solver_api : public tactic2solver {
-    tactic_ref m_tactic;
-public:
-    tactic2solver_api(tactic * t):m_tactic(t) {}
-    virtual ~tactic2solver_api() {}
-    virtual tactic * get_tactic(ast_manager & m, params_ref const & p);
-};
-
-
-#endif

File src/front_end_params/arith_simplifier_params.cpp

View file
  • Ignore whitespace
+/*++
+Copyright (c) 2006 Microsoft Corporation
+
+Module Name:
+
+    arith_simplifier_params.cpp
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Leonardo de Moura (leonardo) 2008-05-09.
+
+Revision History:
+
+--*/
+
+#include"arith_simplifier_params.h"
+
+void arith_simplifier_params::register_params(ini_params & p) {
+    p.register_bool_param("ARITH_EXPAND_EQS", m_arith_expand_eqs);
+    p.register_bool_param("ARITH_PROCESS_ALL_EQS", m_arith_process_all_eqs);
+}
+

File src/front_end_params/arith_simplifier_params.h

View file
  • Ignore whitespace
+/*++
+Copyright (c) 2006 Microsoft Corporation
+
+Module Name:
+
+    arith_simplifier_params.h
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Leonardo de Moura (leonardo) 2008-05-09.
+
+Revision History:
+
+--*/
+#ifndef _ARITH_SIMPLIFIER_PARAMS_H_
+#define _ARITH_SIMPLIFIER_PARAMS_H_
+
+#include"ini_file.h"
+
+struct arith_simplifier_params {
+    bool    m_arith_expand_eqs;
+    bool    m_arith_process_all_eqs;
+
+    arith_simplifier_params():
+        m_arith_expand_eqs(false),
+        m_arith_process_all_eqs(false) {
+    }
+    
+    void register_params(ini_params & p);
+};
+    
+#endif /* _ARITH_SIMPLIFIER_PARAMS_H_ */
+

File src/front_end_params/bit_blaster_params.h

View file
  • Ignore whitespace
+/*++
+Copyright (c) 2006 Microsoft Corporation
+
+Module Name:
+
+    bit_blaster_params.h
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Leonardo de Moura (leonardo) 2008-10-02.
+
+Revision History:
+
+--*/
+#ifndef _BIT_BLASTER_PARAMS_H_
+#define _BIT_BLASTER_PARAMS_H_
+
+#include"ini_file.h"
+
+struct bit_blaster_params {
+    bool  m_bb_eager;
+    bool  m_bb_ext_gates;
+    bool  m_bb_quantifiers;
+    bit_blaster_params():
+        m_bb_eager(false),
+        m_bb_ext_gates(false),
+        m_bb_quantifiers(false) {
+    }
+    void register_params(ini_params & p) {
+        p.register_bool_param("BB_EAGER", m_bb_eager, "eager bit blasting");
+        p.register_bool_param("BB_EXT_GATES", m_bb_ext_gates, "use extended gates during bit-blasting");
+        p.register_bool_param("BB_QUANTIFIERS", m_bb_quantifiers, "convert bit-vectors to Booleans in quantifiers");
+    }
+};
+
+#endif /* _BIT_BLASTER_PARAMS_H_ */
+

File src/front_end_params/bv_simplifier_params.h

View file
  • Ignore whitespace
+/*++
+Copyright (c) 2006 Microsoft Corporation
+
+Module Name:
+
+    bv_simplifier_params.h
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Leonardo de Moura (leonardo) 2008-10-10.
+
+Revision History:
+
+--*/
+#ifndef _BV_SIMPLIFIER_PARAMS_H_
+#define _BV_SIMPLIFIER_PARAMS_H_
+
+#include"ini_file.h"
+
+struct bv_simplifier_params {
+    bool  m_hi_div0; //!< if true, uses the hardware interpretation for div0, mod0, ... if false, div0, mod0, ... are considered uninterpreted.
+    bool  m_bv2int_distribute; //!< if true allows downward propagation of bv2int.
+
+    bv_simplifier_params():
+        m_hi_div0(true),
+        m_bv2int_distribute(true) {
+    }
+    void register_params(ini_params & p) {
+        p.register_bool_param("HI_DIV0", m_hi_div0, "if true, then Z3 uses the usual hardware interpretation for division (rem, mod) by zero. Otherwise, these operations are considered uninterpreted.");
+        p.register_bool_param("BV2INT_DISTRIBUTE", m_bv2int_distribute, "if true, then int2bv is distributed over arithmetical operators.");
+    }
+};
+
+#endif /* _BV_SIMPLIFIER_PARAMS_H_ */
+

File src/front_end_params/cnf_params.cpp

View file
  • Ignore whitespace
+/*++
+Copyright (c) 2006 Microsoft Corporation
+
+Module Name:
+
+    cnf_params.cpp
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Leonardo de Moura (leonardo) 2008-01-23.
+
+Revision History:
+
+--*/
+
+#include"cnf_params.h"
+
+void cnf_params::register_params(ini_params & p) {
+    p.register_unsigned_param("CNF_FACTOR", m_cnf_factor, "the maximum number of clauses that can be created when converting a subformula");
+    p.register_int_param("CNF_MODE", 0, 3, reinterpret_cast<int&>(m_cnf_mode), "CNF translation mode: 0 - disabled, 1 - quantifiers in CNF, 2 - 0 + opportunistic, 3 - full");
+}
+

File src/front_end_params/cnf_params.h

View file
  • Ignore whitespace
+/*++
+Copyright (c) 2006 Microsoft Corporation
+
+Module Name:
+
+    cnf_params.h
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Leonardo de Moura (leonardo) 2008-01-23.
+
+Revision History:
+
+--*/
+#ifndef _CNF_PARAMS_H_
+#define _CNF_PARAMS_H_
+
+#include"ini_file.h"
+
+/**
+   \brief CNF translation mode.  The cheapest mode is CNF_QUANT, and
+   the most expensive is CNF_FULL.
+*/
+enum cnf_mode {
+    CNF_DISABLED, /* CNF translator is disabled. 
+                     This mode is sufficient when using E-matching.
+                  */
+    CNF_QUANT, /* A subformula is put into CNF if it is inside of a
+                  quantifier.
+               
+                  This mode is sufficient when using Superposition
+                  Calculus.
+               */
+    CNF_OPPORTUNISTIC, /* a subformula is also put in CNF if it is cheap. */
+    CNF_FULL /* Everything is put into CNF, new names are introduced
+                if it is too expensive. */
+};
+
+struct cnf_params {
+    cnf_mode m_cnf_mode;
+    unsigned m_cnf_factor;
+    cnf_params():
+        m_cnf_mode(CNF_DISABLED),
+        m_cnf_factor(4) {
+    }
+    
+    void register_params(ini_params & p);
+};
+
+
+#endif /* _CNF_PARAMS_H_ */
+

File src/front_end_params/dyn_ack_params.cpp

View file
  • Ignore whitespace
+/*++
+Copyright (c) 2006 Microsoft Corporation
+
+Module Name:
+
+    dyn_ack_params.cpp
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Leonardo de Moura (leonardo) 2007-05-18.
+
+Revision History:
+
+--*/
+#include"dyn_ack_params.h"
+
+void dyn_ack_params::register_params(ini_params & p) {
+    p.register_int_param("DACK", 0, 2, reinterpret_cast<int&>(m_dack), 
+                         "0 - disable dynamic ackermannization, 1 - expand Leibniz's axiom if a congruence is the root of a conflict, 2 - expand Leibniz's axiom if a congruence is used during conflict resolution.");
+    p.register_bool_param("DACK_EQ", m_dack_eq, "enable dynamic ackermannization for transtivity of equalities");
+    p.register_unsigned_param("DACK_THRESHOLD", m_dack_threshold, "number of times the congruence rule must be used before Leibniz's axiom is expanded");
+    p.register_double_param("DACK_FACTOR", m_dack_factor, "number of instance per conflict");
+    p.register_unsigned_param("DACK_GC", m_dack_gc, "Dynamic ackermannization garbage collection frequency (per conflict).");
+    p.register_double_param("DACK_GC_INV_DECAY", m_dack_gc_inv_decay);
+}
+
+

File src/front_end_params/dyn_ack_params.h

View file
  • Ignore whitespace
+/*++
+Copyright (c) 2006 Microsoft Corporation
+
+Module Name:
+
+    dyn_ack_params.h
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Leonardo de Moura (leonardo) 2007-05-18.
+
+Revision History:
+
+--*/
+#ifndef _DYN_ACK_PARAMS_H_
+#define _DYN_ACK_PARAMS_H_
+
+#include"ini_file.h"
+
+enum dyn_ack_strategy {
+    DACK_DISABLED,
+    DACK_ROOT, // congruence is the root of the conflict
+    DACK_CR    // congruence used during conflict resolution
+};
+
+struct dyn_ack_params {
+    dyn_ack_strategy m_dack;
+    bool             m_dack_eq;
+    double           m_dack_factor;
+    unsigned         m_dack_threshold;
+    unsigned         m_dack_gc;
+    double           m_dack_gc_inv_decay;
+
+public:
+    dyn_ack_params():
+        m_dack(DACK_ROOT),
+        m_dack_eq(false),
+        m_dack_factor(0.1),
+        m_dack_threshold(10),
+        m_dack_gc(2000), 
+        m_dack_gc_inv_decay(0.8) {
+    }
+
+    void register_params(ini_params & p);
+};
+
+
+#endif /* _DYN_ACK_PARAMS_H_ */
+

File src/front_end_params/front_end_params.cpp

View file
  • Ignore whitespace
+/*++
+Copyright (c) 2006 Microsoft Corporation
+
+Module Name:
+
+    front_end_params.cpp
+
+Abstract:
+
+    <abstract>
+
+Author:
+
+    Leonardo de Moura (leonardo) 2007-05-10.
+