mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
rename card->pb
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
2b2d0e155c
commit
ee0abfbfe9
13 changed files with 79 additions and 79 deletions
|
@ -3,7 +3,7 @@ Copyright (c) 2013 Microsoft Corporation
|
|||
|
||||
Module Name:
|
||||
|
||||
card_decl_plugin.cpp
|
||||
pb_decl_plugin.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
|
@ -17,14 +17,14 @@ Revision History:
|
|||
|
||||
--*/
|
||||
|
||||
#include "card_decl_plugin.h"
|
||||
#include "pb_decl_plugin.h"
|
||||
|
||||
card_decl_plugin::card_decl_plugin():
|
||||
pb_decl_plugin::pb_decl_plugin():
|
||||
m_at_most_sym("at-most"),
|
||||
m_pble_sym("pble")
|
||||
{}
|
||||
|
||||
func_decl * card_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
|
||||
func_decl * pb_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
|
||||
unsigned arity, sort * const * domain, sort * range) {
|
||||
SASSERT(m_manager);
|
||||
ast_manager& m = *m_manager;
|
||||
|
@ -59,7 +59,7 @@ func_decl * card_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters,
|
|||
}
|
||||
}
|
||||
|
||||
void card_decl_plugin::get_op_names(svector<builtin_name> & op_names, symbol const & logic) {
|
||||
void pb_decl_plugin::get_op_names(svector<builtin_name> & op_names, symbol const & logic) {
|
||||
if (logic == symbol::null) {
|
||||
op_names.push_back(builtin_name(m_at_most_sym.bare_str(), OP_AT_MOST_K));
|
||||
op_names.push_back(builtin_name(m_pble_sym.bare_str(), OP_PB_LE));
|
||||
|
@ -67,12 +67,12 @@ void card_decl_plugin::get_op_names(svector<builtin_name> & op_names, symbol con
|
|||
}
|
||||
|
||||
|
||||
app * card_util::mk_at_most_k(unsigned num_args, expr * const * args, unsigned k) {
|
||||
app * pb_util::mk_at_most_k(unsigned num_args, expr * const * args, unsigned k) {
|
||||
parameter param(k);
|
||||
return m.mk_app(m_fid, OP_AT_MOST_K, 1, ¶m, num_args, args, m.mk_bool_sort());
|
||||
}
|
||||
|
||||
app * card_util::mk_le(unsigned num_args, int const * coeffs, expr * const * args, int k) {
|
||||
app * pb_util::mk_le(unsigned num_args, int const * coeffs, expr * const * args, int k) {
|
||||
vector<parameter> params;
|
||||
params.push_back(parameter(k));
|
||||
for (unsigned i = 0; i < num_args; ++i) {
|
||||
|
@ -82,11 +82,11 @@ app * card_util::mk_le(unsigned num_args, int const * coeffs, expr * const * arg
|
|||
}
|
||||
|
||||
|
||||
bool card_util::is_at_most_k(app *a) const {
|
||||
bool pb_util::is_at_most_k(app *a) const {
|
||||
return is_app_of(a, m_fid, OP_AT_MOST_K);
|
||||
}
|
||||
|
||||
bool card_util::is_at_most_k(app *a, unsigned& k) const {
|
||||
bool pb_util::is_at_most_k(app *a, unsigned& k) const {
|
||||
if (is_at_most_k(a)) {
|
||||
k = get_k(a);
|
||||
return true;
|
||||
|
@ -96,17 +96,17 @@ bool card_util::is_at_most_k(app *a, unsigned& k) const {
|
|||
}
|
||||
}
|
||||
|
||||
int card_util::get_k(app *a) const {
|
||||
int pb_util::get_k(app *a) const {
|
||||
SASSERT(is_at_most_k(a) || is_le(a));
|
||||
return a->get_decl()->get_parameter(0).get_int();
|
||||
}
|
||||
|
||||
|
||||
bool card_util::is_le(app *a) const {
|
||||
bool pb_util::is_le(app *a) const {
|
||||
return is_app_of(a, m_fid, OP_PB_LE);
|
||||
}
|
||||
|
||||
bool card_util::is_le(app* a, int& k) const {
|
||||
bool pb_util::is_le(app* a, int& k) const {
|
||||
if (is_le(a)) {
|
||||
k = get_k(a);
|
||||
return true;
|
||||
|
@ -116,7 +116,7 @@ bool card_util::is_le(app* a, int& k) const {
|
|||
}
|
||||
}
|
||||
|
||||
int card_util::get_le_coeff(app* a, unsigned index) {
|
||||
int pb_util::get_le_coeff(app* a, unsigned index) {
|
||||
if (is_at_most_k(a)) {
|
||||
return 1;
|
||||
}
|
|
@ -3,11 +3,11 @@ Copyright (c) 2013 Microsoft Corporation
|
|||
|
||||
Module Name:
|
||||
|
||||
card_decl_plugin.h
|
||||
pb_decl_plugin.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Cardinality Constraints plugin
|
||||
Pseudo-Boolean and Cardinality Constraints plugin
|
||||
|
||||
Author:
|
||||
|
||||
|
@ -24,26 +24,26 @@ hence:
|
|||
|
||||
|
||||
--*/
|
||||
#ifndef _CARD_DECL_PLUGIN_H_
|
||||
#define _CARD_DECL_PLUGIN_H_
|
||||
#ifndef _PB_DECL_PLUGIN_H_
|
||||
#define _PB_DECL_PLUGIN_H_
|
||||
|
||||
#include"ast.h"
|
||||
|
||||
enum card_op_kind {
|
||||
enum pb_op_kind {
|
||||
OP_AT_MOST_K, // at most K Booleans are true.
|
||||
OP_PB_LE, // pseudo-Boolean <= (generalizes at_most_k)
|
||||
LAST_CARD_OP
|
||||
LAST_PB_OP
|
||||
};
|
||||
|
||||
|
||||
class card_decl_plugin : public decl_plugin {
|
||||
class pb_decl_plugin : public decl_plugin {
|
||||
symbol m_at_most_sym;
|
||||
symbol m_pble_sym;
|
||||
func_decl * mk_at_most(unsigned arity, unsigned k);
|
||||
func_decl * mk_le(unsigned arity, int const* coeffs, int k);
|
||||
public:
|
||||
card_decl_plugin();
|
||||
virtual ~card_decl_plugin() {}
|
||||
pb_decl_plugin();
|
||||
virtual ~pb_decl_plugin() {}
|
||||
|
||||
virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) {
|
||||
UNREACHABLE();
|
||||
|
@ -51,7 +51,7 @@ public:
|
|||
}
|
||||
|
||||
virtual decl_plugin * mk_fresh() {
|
||||
return alloc(card_decl_plugin);
|
||||
return alloc(pb_decl_plugin);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -65,11 +65,11 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class card_util {
|
||||
class pb_util {
|
||||
ast_manager & m;
|
||||
family_id m_fid;
|
||||
public:
|
||||
card_util(ast_manager& m):m(m), m_fid(m.mk_family_id("card")) {}
|
||||
pb_util(ast_manager& m):m(m), m_fid(m.mk_family_id("pb")) {}
|
||||
ast_manager & get_manager() const { return m; }
|
||||
family_id get_family_id() const { return m_fid; }
|
||||
app * mk_at_most_k(unsigned num_args, expr * const * args, unsigned k);
|
||||
|
@ -83,5 +83,5 @@ public:
|
|||
};
|
||||
|
||||
|
||||
#endif /* _CARD_DECL_PLUGIN_H_ */
|
||||
#endif /* _PB_DECL_PLUGIN_H_ */
|
||||
|
|
@ -25,7 +25,7 @@ Revision History:
|
|||
#include"dl_decl_plugin.h"
|
||||
#include"seq_decl_plugin.h"
|
||||
#include"float_decl_plugin.h"
|
||||
#include"card_decl_plugin.h"
|
||||
#include"pb_decl_plugin.h"
|
||||
|
||||
void reg_decl_plugins(ast_manager & m) {
|
||||
if (!m.get_plugin(m.mk_family_id(symbol("arith")))) {
|
||||
|
@ -49,7 +49,7 @@ void reg_decl_plugins(ast_manager & m) {
|
|||
if (!m.get_plugin(m.mk_family_id(symbol("float")))) {
|
||||
m.register_plugin(symbol("float"), alloc(float_decl_plugin));
|
||||
}
|
||||
if (!m.get_plugin(m.mk_family_id(symbol("card")))) {
|
||||
m.register_plugin(symbol("card"), alloc(card_decl_plugin));
|
||||
if (!m.get_plugin(m.mk_family_id(symbol("pb")))) {
|
||||
m.register_plugin(symbol("pb"), alloc(pb_decl_plugin));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue