mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 09:05:31 +00:00
moving parameters to theory_pb
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
4027de42f6
commit
c5b82796ca
15 changed files with 159 additions and 162 deletions
|
@ -47,6 +47,7 @@ void smt_params::updt_params(params_ref const & p) {
|
|||
qi_params::updt_params(p);
|
||||
theory_arith_params::updt_params(p);
|
||||
theory_bv_params::updt_params(p);
|
||||
theory_pb_params::updt_params(p);
|
||||
updt_local_params(p);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ Revision History:
|
|||
#include"theory_arith_params.h"
|
||||
#include"theory_array_params.h"
|
||||
#include"theory_bv_params.h"
|
||||
#include"theory_pb_params.h"
|
||||
#include"theory_datatype_params.h"
|
||||
#include"preprocessor_params.h"
|
||||
#include"context_params.h"
|
||||
|
@ -73,7 +74,8 @@ struct smt_params : public preprocessor_params,
|
|||
public qi_params,
|
||||
public theory_arith_params,
|
||||
public theory_array_params,
|
||||
public theory_bv_params,
|
||||
public theory_bv_params,
|
||||
public theory_pb_params,
|
||||
public theory_datatype_params {
|
||||
bool m_display_proof;
|
||||
bool m_display_dot_proof;
|
||||
|
|
|
@ -41,4 +41,8 @@ def_module_params(module_name='smt',
|
|||
('arith.propagation_mode', UINT, 2, '0 - no propagation, 1 - propagate existing literals, 2 - refine bounds'),
|
||||
('arith.branch_cut_ratio', UINT, 2, 'branch/cut ratio for linear integer arithmetic'),
|
||||
('arith.int_eq_branch', BOOL, False, 'branching using derived integer equations'),
|
||||
('arith.ignore_int', BOOL, False, 'treat integer variables as real')))
|
||||
('arith.ignore_int', BOOL, False, 'treat integer variables as real'),
|
||||
('pb.conflict_frequency', UINT, 0, 'conflict frequency for Pseudo-Boolean theory'),
|
||||
('pb.learn_complements', BOOL, True, 'learn complement literals for Pseudo-Boolean theory'),
|
||||
('pb.enable_compilation', BOOL, True, 'enable compilation into sorting circuits for Pseudo-Boolean')))
|
||||
|
||||
|
|
27
src/smt/params/theory_pb_params.cpp
Normal file
27
src/smt/params/theory_pb_params.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*++
|
||||
Copyright (c) 2014 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
theory_pb_params.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
<abstract>
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2014-01-01
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
#include"theory_pb_params.h"
|
||||
#include"smt_params_helper.hpp"
|
||||
|
||||
void theory_pb_params::updt_params(params_ref const & _p) {
|
||||
smt_params_helper p(_p);
|
||||
m_pb_conflict_frequency = p.pb_conflict_frequency();
|
||||
m_pb_learn_complements = p.pb_learn_complements();
|
||||
m_pb_enable_compilation = p.pb_enable_compilation();
|
||||
}
|
39
src/smt/params/theory_pb_params.h
Normal file
39
src/smt/params/theory_pb_params.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
theory_pb_params.h
|
||||
|
||||
Abstract:
|
||||
|
||||
<abstract>
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2014-01-01
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _THEORY_PB_PARAMS_H_
|
||||
#define _THEORY_PB_PARAMS_H_
|
||||
|
||||
#include"params.h"
|
||||
|
||||
|
||||
struct theory_pb_params {
|
||||
unsigned m_pb_conflict_frequency;
|
||||
bool m_pb_learn_complements;
|
||||
bool m_pb_enable_compilation;
|
||||
theory_pb_params(params_ref const & p = params_ref()):
|
||||
m_pb_conflict_frequency(0),
|
||||
m_pb_learn_complements(true),
|
||||
m_pb_enable_compilation(true)
|
||||
{}
|
||||
|
||||
void updt_params(params_ref const & p);
|
||||
};
|
||||
|
||||
#endif /* _THEORY_PB_PARAMS_H_ */
|
||||
|
|
@ -793,7 +793,7 @@ namespace smt {
|
|||
|
||||
void setup::setup_card() {
|
||||
// m_context.register_plugin(alloc(theory_card, m_manager));
|
||||
m_context.register_plugin(alloc(theory_pb, m_manager));
|
||||
m_context.register_plugin(alloc(theory_pb, m_manager, m_params));
|
||||
}
|
||||
|
||||
void setup::setup_unknown() {
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace smt {
|
|||
class setup {
|
||||
context & m_context;
|
||||
ast_manager & m_manager;
|
||||
smt_params & m_params;
|
||||
smt_params & m_params;
|
||||
symbol m_logic;
|
||||
bool m_already_configured;
|
||||
void setup_auto_config();
|
||||
|
|
|
@ -816,20 +816,23 @@ namespace smt {
|
|||
return true;
|
||||
}
|
||||
|
||||
theory_pb::theory_pb(ast_manager& m):
|
||||
theory_pb::theory_pb(ast_manager& m, theory_pb_params& p):
|
||||
theory(m.mk_family_id("pb")),
|
||||
m_params(p),
|
||||
m_util(m),
|
||||
m_lemma(null_literal),
|
||||
m_learn_complements(false),
|
||||
m_conflict_frequency(0xF)
|
||||
{}
|
||||
m_lemma(null_literal)
|
||||
{
|
||||
m_learn_complements = p.m_pb_learn_complements;
|
||||
m_conflict_frequency = p.m_pb_conflict_frequency;
|
||||
m_enable_compilation = p.m_pb_enable_compilation;
|
||||
}
|
||||
|
||||
theory_pb::~theory_pb() {
|
||||
reset_eh();
|
||||
}
|
||||
|
||||
theory * theory_pb::mk_fresh(context * new_ctx) {
|
||||
return alloc(theory_pb, new_ctx->get_manager());
|
||||
return alloc(theory_pb, new_ctx->get_manager(), m_params);
|
||||
}
|
||||
|
||||
bool theory_pb::internalize_atom(app * atom, bool gate_ctx) {
|
||||
|
@ -910,20 +913,21 @@ namespace smt {
|
|||
|
||||
|
||||
// pre-compile threshold for cardinality
|
||||
bool is_cardinality = true;
|
||||
for (unsigned i = 0; is_cardinality && i < args.size(); ++i) {
|
||||
is_cardinality = (args[i].second < rational(8));
|
||||
bool enable_compile = m_enable_compilation;
|
||||
for (unsigned i = 0; enable_compile && i < args.size(); ++i) {
|
||||
enable_compile = (args[i].second < rational(8));
|
||||
}
|
||||
if (is_cardinality) {
|
||||
if (enable_compile) {
|
||||
unsigned log = 1, n = 1;
|
||||
while (n <= args.size()) {
|
||||
++log;
|
||||
n *= 2;
|
||||
}
|
||||
unsigned th = 10*args.size()*log;
|
||||
unsigned th = args.size()*log; // 10*
|
||||
c->m_compilation_threshold = th;
|
||||
IF_VERBOSE(2, verbose_stream() << "(smt.pb setting compilation threhshold to " << th << ")\n";);
|
||||
TRACE("pb", tout << "compilation threshold: " << th << "\n";);
|
||||
}
|
||||
}
|
||||
else {
|
||||
c->m_compilation_threshold = UINT_MAX;
|
||||
}
|
||||
|
@ -1429,6 +1433,14 @@ namespace smt {
|
|||
literal_vector in;
|
||||
for (unsigned i = 0; i < num_args; ++i) {
|
||||
rational n = c.coeff(i);
|
||||
lbool val = ctx.get_assignment(c.lit());
|
||||
if (val != l_undef &&
|
||||
ctx.get_assign_level(thl) == ctx.get_base_level()) {
|
||||
if (val == l_true) {
|
||||
k -= n.get_unsigned();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
while (n.is_pos()) {
|
||||
in.push_back(c.lit(i));
|
||||
n -= rational::one();
|
||||
|
@ -1765,7 +1777,7 @@ namespace smt {
|
|||
// same order as the assignment stack.
|
||||
// It is not a correctness bug but causes to miss lemmas.
|
||||
//
|
||||
IF_VERBOSE(1, display_resolved_lemma(verbose_stream()););
|
||||
IF_VERBOSE(2, display_resolved_lemma(verbose_stream()););
|
||||
TRACE("pb", display_resolved_lemma(tout););
|
||||
return false;
|
||||
}
|
||||
|
@ -1851,12 +1863,12 @@ namespace smt {
|
|||
// 3x + 3y + z + u >= 4
|
||||
// ~x /\ ~y => z + u >=
|
||||
|
||||
IF_VERBOSE(2, display(verbose_stream() << "lemma1: ", m_lemma););
|
||||
IF_VERBOSE(4, display(verbose_stream() << "lemma1: ", m_lemma););
|
||||
hoist_maximal_values();
|
||||
lbool is_true = m_lemma.normalize();
|
||||
m_lemma.prune();
|
||||
|
||||
IF_VERBOSE(2, display(verbose_stream() << "lemma2: ", m_lemma););
|
||||
IF_VERBOSE(4, display(verbose_stream() << "lemma2: ", m_lemma););
|
||||
switch(is_true) {
|
||||
case l_true:
|
||||
UNREACHABLE();
|
||||
|
|
|
@ -23,6 +23,7 @@ Notes:
|
|||
#include "smt_theory.h"
|
||||
#include "pb_decl_plugin.h"
|
||||
#include "smt_clause.h"
|
||||
#include "theory_pb_params.h"
|
||||
|
||||
namespace smt {
|
||||
class theory_pb : public theory {
|
||||
|
@ -59,7 +60,7 @@ namespace smt {
|
|||
unsigned m_num_propagations;
|
||||
unsigned m_compilation_threshold;
|
||||
lbool m_compiled;
|
||||
|
||||
|
||||
ineq(literal l) : m_lit(l) {
|
||||
reset();
|
||||
}
|
||||
|
@ -102,7 +103,8 @@ namespace smt {
|
|||
};
|
||||
|
||||
typedef ptr_vector<ineq> watch_list;
|
||||
|
||||
|
||||
theory_pb_params m_params;
|
||||
u_map<watch_list*> m_watch; // per literal.
|
||||
u_map<ineq*> m_ineqs; // per inequality.
|
||||
unsigned_vector m_ineqs_trail;
|
||||
|
@ -115,6 +117,7 @@ namespace smt {
|
|||
ptr_vector<ineq> m_to_compile; // inequalities to compile.
|
||||
unsigned m_conflict_frequency;
|
||||
bool m_learn_complements;
|
||||
bool m_enable_compilation;
|
||||
|
||||
// internalize_atom:
|
||||
literal compile_arg(expr* arg);
|
||||
|
@ -172,7 +175,7 @@ namespace smt {
|
|||
void validate_assign(ineq const& c, literal_vector const& lits, literal l) const;
|
||||
void validate_watch(ineq const& c) const;
|
||||
public:
|
||||
theory_pb(ast_manager& m);
|
||||
theory_pb(ast_manager& m, theory_pb_params& p);
|
||||
|
||||
virtual ~theory_pb();
|
||||
|
||||
|
@ -194,9 +197,6 @@ namespace smt {
|
|||
virtual model_value_proc * mk_value(enode * n, model_generator & mg);
|
||||
virtual void init_model(model_generator & m);
|
||||
|
||||
void set_conflict_frequency(unsigned f) { m_conflict_frequency = f; }
|
||||
void set_learn_complements(bool l) { m_learn_complements = l; }
|
||||
|
||||
static literal assert_ge(context& ctx, unsigned k, unsigned n, literal const* xs);
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue