3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-25 20:46:01 +00:00

move into separate component

This commit is contained in:
Jakob Rath 2022-03-10 16:10:56 +01:00
parent d4a28d4553
commit afc711d6ec
7 changed files with 98 additions and 34 deletions

View file

@ -0,0 +1,4 @@
z3_add_component(polysat_univariate_solver
SOURCES
univariate_solver.cpp
)

View file

@ -0,0 +1,90 @@
/*++
Copyright (c) 2022 Microsoft Corporation
Module Name:
polysat univariate solver
Abstract:
Solve univariate constraints for polysat using bitblasting
Author:
Nikolaj Bjorner (nbjorner) 2022-03-10
Jakob Rath 2022-03-10
--*/
#include "math/polysat/univariate/univariate_solver.h"
#include "solver/solver.h"
#include "util/util.h"
namespace polysat {
class univariate_bitblast_solver : public univariate_solver {
ast_manager m;
scoped_ptr<solver> s;
public:
univariate_bitblast_solver() {
NOT_IMPLEMENTED_YET();
// which concrete solver do we want here?
// need to set params to enable model and unsat core generation; and bit blasting?
s = mk_smt2_solver(m, params_ref::get_empty());
}
~univariate_bitblast_solver() override = default;
void push() override {
s->push();
}
void pop(unsigned n) override {
s->pop(n);
}
void add_ule(univariate lhs, univariate rhs, bool sign, dep_t dep) override {
// s->assert_expr();
NOT_IMPLEMENTED_YET();
}
void add_umul_ovfl(univariate lhs, univariate rhs, bool sign, dep_t dep) override {
NOT_IMPLEMENTED_YET();
}
void add_smul_ovfl(univariate lhs, univariate rhs, bool sign, dep_t dep) override {
NOT_IMPLEMENTED_YET();
}
void add_smul_udfl(univariate lhs, univariate rhs, bool sign, dep_t dep) override {
NOT_IMPLEMENTED_YET();
}
lbool check() override {
// TODO: need to pass assumptions to get an unsat core?
return s->check_sat();
}
dep_vector unsat_core() override {
SASSERT(s->status() == l_false);
expr_ref_vector core(m);
s->get_unsat_core(core);
NOT_IMPLEMENTED_YET();
return {};
}
rational model() override {
SASSERT(s->status() == l_true);
model_ref model;
s->get_model(model);
NOT_IMPLEMENTED_YET();
return {};
}
};
scoped_ptr<univariate_solver> mk_univariate_bitblast_solver() {
return alloc(univariate_bitblast_solver);
}
}

View file

@ -0,0 +1,52 @@
/*++
Copyright (c) 2022 Microsoft Corporation
Module Name:
polysat abstract univariate solver
Abstract:
Solver interface for univariate polynomials over modular arithmetic.
Author:
Nikolaj Bjorner (nbjorner) 2022-03-10
Jakob Rath 2022-03-10
--*/
#pragma once
#include "util/lbool.h"
#include "util/rational.h"
#include "util/vector.h"
#include "util/util.h"
namespace polysat {
class univariate_solver {
public:
using dep_t = unsigned;
using dep_vector = svector<dep_t>;
using univariate = vector<rational>;
virtual ~univariate_solver() = default;
virtual void push() = 0;
virtual void pop(unsigned n) = 0;
virtual lbool check() = 0;
virtual dep_vector unsat_core() = 0;
virtual rational model() = 0;
virtual void add_ule(univariate lhs, univariate rhs, bool sign, dep_t dep) = 0;
virtual void add_umul_ovfl(univariate lhs, univariate rhs, bool sign, dep_t dep) = 0;
virtual void add_smul_ovfl(univariate lhs, univariate rhs, bool sign, dep_t dep) = 0;
virtual void add_smul_udfl(univariate lhs, univariate rhs, bool sign, dep_t dep) = 0;
// op constraints?
};
scoped_ptr<univariate_solver> mk_univariate_bitblast_solver();
}