3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-10-07 08:21:56 +00:00

initial files to support theory-solver based synthesis

This commit is contained in:
Nikolaj Bjorner 2023-08-08 09:24:34 -07:00
parent a7966dc436
commit 27dce71ea9
9 changed files with 264 additions and 22 deletions

View file

@ -44,6 +44,7 @@ z3_add_component(sat_smt
q_solver.cpp
recfun_solver.cpp
sat_th.cpp
synth_solver.cpp
tseitin_theory_checker.cpp
user_solver.cpp
COMPONENT_DEPENDENCIES

View file

@ -28,6 +28,7 @@ Author:
#include "sat/smt/fpa_solver.h"
#include "sat/smt/dt_solver.h"
#include "sat/smt/recfun_solver.h"
#include "sat/smt/synth_solver.h"
namespace euf {
@ -130,6 +131,7 @@ namespace euf {
arith_util arith(m);
datatype_util dt(m);
recfun::util rf(m);
if (pb.get_family_id() == fid)
ext = alloc(pb::solver, *this, fid);
else if (bvu.get_family_id() == fid)
@ -144,6 +146,8 @@ namespace euf {
ext = alloc(dt::solver, *this, fid);
else if (rf.get_family_id() == fid)
ext = alloc(recfun::solver, *this);
else if (m.mk_family_id("synth") == fid)
ext = alloc(synth::solver, *this);
if (ext)
add_solver(ext);

View file

@ -0,0 +1,90 @@
/*++
Copyright (c) 2020 Microsoft Corporation
Module Name:
synth_solver.h
Author:
Petra Hozzova 2023-08-08
Nikolaj Bjorner (nbjorner) 2020-08-17
--*/
#include "sat/smt/synth_solver.h"
#include "sat/smt/euf_solver.h"
namespace synth {
solver::solver(euf::solver& ctx):
th_euf_solver(ctx, symbol("synth"), ctx.get_manager().mk_family_id("synth")) {}
solver::~solver() {}
// recognize synthesis objective as part of search objective.
// register it for calls to check.
void solver::asserted(sat::literal lit) {
}
// block current model using realizer by E-graph (and arithmetic)
//
sat::check_result solver::check() {
return sat::check_result::CR_DONE;
}
// nothing particular to do
void solver::push_core() {
}
// nothing particular to do
void solver::pop_core(unsigned n) {
}
// nothing particular to do
bool solver::unit_propagate() {
return false;
}
// retrieve explanation for assertions made by synth solver. It only asserts unit literals so nothing to retrieve
void solver::get_antecedents(sat::literal l, sat::ext_justification_idx idx, sat::literal_vector & r, bool probing) {
}
// where we collect statistics (number of invocations?)
void solver::collect_statistics(statistics& st) const {}
// recognize synthesis objectives here.
sat::literal solver::internalize(expr* e, bool sign, bool root) {
NOT_IMPLEMENTED_YET();
return sat::null_literal;
}
// recognize synthesis objectives here and above
void solver::internalize(expr* e) {}
// display current state (eg. current set of realizers)
std::ostream& solver::display(std::ostream& out) const {
return out;
}
// justified by "synth".
std::ostream& solver::display_justification(std::ostream& out, sat::ext_justification_idx idx) const {
return out << "synth";
}
std::ostream& solver::display_constraint(std::ostream& out, sat::ext_constraint_idx idx) const {
return out << "synth";
}
// create a clone of the solver.
euf::th_solver* solver::clone(euf::solver& ctx) {
NOT_IMPLEMENTED_YET();
return nullptr;
}
}

View file

@ -0,0 +1,47 @@
/*++
Copyright (c) 2020 Microsoft Corporation
Module Name:
synth_solver.h
Author:
Petra Hozzova 2023-08-08
Nikolaj Bjorner (nbjorner) 2020-08-17
--*/
#pragma once
#include "sat/smt/sat_th.h"
#include "solver/solver.h"
namespace synth {
class solver : public euf::th_euf_solver {
public:
solver(euf::solver& ctx);
~solver() override;
void asserted(sat::literal lit) override;
sat::check_result check() override;
void push_core() override;
void pop_core(unsigned n) override;
bool unit_propagate() override;
void get_antecedents(sat::literal l, sat::ext_justification_idx idx, sat::literal_vector & r, bool probing) override;
void collect_statistics(statistics& st) const override;
sat::literal internalize(expr* e, bool sign, bool root) override;
void internalize(expr* e) override;
std::ostream& display(std::ostream& out) const override;
std::ostream& display_justification(std::ostream& out, sat::ext_justification_idx idx) const override;
std::ostream& display_constraint(std::ostream& out, sat::ext_constraint_idx idx) const override;
euf::th_solver* clone(euf::solver& ctx) override;
};
};