3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-24 20:16:00 +00:00
z3/src/smt/theory_lra.h
Nikolaj Bjorner 87f7a20e14 Add (updated and general) solve_for functionality for arithmetic, add congruence_explain to API to retrieve explanation for why two terms are congruent Tweak handling of smt.qi.max_instantations
Add API solve_for(vars).
It takes a list of variables and returns a triangular solved form for the variables.
Currently for arithmetic. The solved form is a list with elements of the form (var, term, guard).
Variables solved in the tail of the list do not occur before in the list.
For example it can return a solution [(x, z, True), (y, x + z, True)] because first x was solved to be z,
then y was solved to be x + z which is the same as 2z.

Add congruent_explain that retuns an explanation for congruent terms.
Terms congruent in the final state after calling SimpleSolver().check() can be queried for
an explanation, i.e., a list of literals that collectively entail the equality under congruence closure.
The literals are asserted in the final state of search.

Adjust smt_context cancellation for the smt.qi.max_instantiations parameter.
It gets checked when qi-queue elements are consumed.
Prior it was checked on insertion time, which didn't allow for processing as many
instantations as there were in the queue. Moreover, it would not cancel the solver.
So it would keep adding instantations to the queue when it was full / depleted the
configuration limit.
2024-12-19 23:27:57 +01:00

111 lines
2.9 KiB
C++

/*++
Copyright (c) 2016 Microsoft Corporation
Module Name:
theory_lra.h
Abstract:
<abstract>
Author:
Lev Nachmanson (levnach) 2016-25-3
Nikolaj Bjorner (nbjorner)
Revision History:
--*/
#pragma once
#include "smt/theory_opt.h"
namespace smt {
class theory_lra : public theory, public theory_opt {
public:
class imp;
private:
imp* m_imp;
public:
theory_lra(context& ctx);
~theory_lra() override;
theory* mk_fresh(context* new_ctx) override;
char const* get_name() const override { return "arithmetic"; }
void init() override;
bool internalize_atom(app * atom, bool gate_ctx) override;
bool internalize_term(app * term) override;
void internalize_eq_eh(app * atom, bool_var v) override;
void assign_eh(bool_var v, bool is_true) override;
lbool get_phase(bool_var v) override;
void new_eq_eh(theory_var v1, theory_var v2) override;
bool use_diseqs() const override;
void new_diseq_eh(theory_var v1, theory_var v2) override;
void push_scope_eh() override;
void pop_scope_eh(unsigned num_scopes) override;
void restart_eh() override;
void relevant_eh(app* e) override;
void init_search_eh() override;
final_check_status final_check_eh() override;
bool is_shared(theory_var v) const override;
bool can_propagate() override;
void propagate() override;
justification * why_is_diseq(theory_var v1, theory_var v2) override;
// virtual void flush_eh();
void reset_eh() override;
void apply_sort_cnstr(enode * n, sort * s) override;
void init_model(model_generator & m) override;
void initialize_value(expr* var, expr* value) override;
model_value_proc * mk_value(enode * n, model_generator & mg) override;
void validate_model(proto_model& mdl) override;
bool get_value(enode* n, expr_ref& r) override;
bool include_func_interp(func_decl* f) override;
bool get_value(enode* n, rational& r);
bool get_lower(enode* n, expr_ref& r);
bool get_upper(enode* n, expr_ref& r);
bool get_lower(enode* n, rational& r, bool& is_strict);
bool get_upper(enode* n, rational& r, bool& is_strict);
void solve_for(vector<solution>& s) override;
void display(std::ostream & out) const override;
void collect_statistics(::statistics & st) const override;
void setup() override;
// optimization
expr_ref mk_ge(generic_model_converter& fm, theory_var v, inf_rational const& val);
inf_eps value(theory_var) override;
inf_eps maximize(theory_var v, expr_ref& blocker, bool& has_shared) override;
theory_var add_objective(app* term) override;
};
}