mirror of
https://github.com/Z3Prover/z3
synced 2025-04-29 20:05:51 +00:00
QEL: Fast Approximated Quantifier Elimination (#6820)
* qe_lite: cleanup and comment no change to code * mbp_arrays: refactor out partial equality (peq) Partial array equality, PEQ, is used as an intermediate expression during MBP for arrays. We need to factor it out so that it can be shared between MBP-QEL and existing MBP. Partial array equality (peq) is used in MBP for arrays. Factoring this out to be used by multiple MBP implementations. * rewriter: new rewrite rules These rules are specializes for terms that are created in QEL. QEL commit is comming later * datatype_rw: new rewrite rule for ADTs The rule handles this special case: (cons (head x) (tail x)) --> x * array_rewriter rules for rewriting PEQs Special rules to simplify PEQs * th_rewriter: wire PEQ simplifications * spacer_iuc: avoid terms with default in IUC Spacer prfers to not have a term representing default value of an array. This guides IUC from picking such terms in interpolation * mbp_term_graph: replace root with repr * mbp_term_graph: formatting * mbp_term_graph: class_props, getters, setters Class properties allow to keep information for an equivalence class. Getters and setters for terms allow accessing information * mbp_term_graph: auxiliary methods for qel QEL commit is comming later in the history * mbp_term_graph: bug fix * mbp_term_graph: pick, refine repr, compute cgrnd * mbp_term_graph: internalize deq * mbp_term_graph: constructor * mbp_term_graph: optionally internalize equalities Reperesent equalities explicitly by nodes in the term_graph * qel * formatting * comments on term_lt * get terms and other api for mbp_qel * plugins for mbp_qel * mbp_qel_util: utilities for mbp_qel * qe_mbp: QEL-based mbp * qel: expose QEL API * spacer: replace qe_lite in qe_project_spacer by qel This changes the default projection engine that spacer uses. * cmd_context: debug commands for qel and mbp_qel New commands are mbp-qel -- MBP with term graphs qel -- QEL with term graphs qe-lite -- older qelite * qe_mbp: model-based rewriters for arrays * qe_mbp: QEL-based projection functions * qsat: wire in QEL-based mbp * qsat: debug code * qsat: maybe a bug fix Changed the code to follow the paper by adding all predicates above a given level, not just predicates of immediately preceding level. * chore: use new api to create solver in qsat * mbp_term_graph use all_of idiom * feat: solver for integer multiplication * array_peq: formatting, no change to code * mbp_qel_util: block comment + format * mbt_term_graph: clang-format * bug fix. Move dt rewrite to qe_mbp * array_peq: add header * run clang format on mbp plugins * clang format on mul solver * format do-while * format * format do-while * update release notes --------- Co-authored-by: hgvk94 <hgvk94@gmail.com> Co-authored-by: Isabel Garcia <igarciac@uwaterloo.ca>
This commit is contained in:
parent
5b2519d7a3
commit
51d3c279d0
35 changed files with 4170 additions and 1517 deletions
|
@ -1,9 +1,11 @@
|
|||
z3_add_component(qe_lite
|
||||
SOURCES
|
||||
qe_lite_tactic.cpp
|
||||
qel.cpp
|
||||
COMPONENT_DEPENDENCIES
|
||||
tactic
|
||||
mbp
|
||||
TACTIC_HEADERS
|
||||
qe_lite_tactic.h
|
||||
qel.h
|
||||
)
|
||||
|
|
|
@ -487,7 +487,7 @@ namespace qel {
|
|||
ptr_vector<var> vs;
|
||||
expr_ref_vector ts(m);
|
||||
expr_ref t(m);
|
||||
if (is_var_def(is_exists, args[i], vs, ts)) {
|
||||
if (is_var_def(is_exists, args[i], vs, ts)) { // vs is the variable, ts is the definition
|
||||
for (unsigned j = 0; j < vs.size(); ++j) {
|
||||
var* v = vs[j];
|
||||
t = ts.get(j);
|
||||
|
@ -2376,7 +2376,7 @@ public:
|
|||
m_array_der.set_is_variable_proc(is_var);
|
||||
m_der(fmls);
|
||||
m_fm(fmls);
|
||||
// AG: disalble m_array_der() since it interferes with other array handling
|
||||
// AG: disable m_array_der() since it interferes with other array handling
|
||||
if (m_use_array_der) m_array_der(fmls);
|
||||
TRACE("qe_lite", for (unsigned i = 0; i < fmls.size(); ++i) tout << mk_pp(fmls[i].get(), m) << "\n";);
|
||||
}
|
||||
|
@ -2392,7 +2392,7 @@ qe_lite::~qe_lite() {
|
|||
}
|
||||
|
||||
void qe_lite::operator()(app_ref_vector& vars, expr_ref& fml) {
|
||||
(*m_impl)(vars, fml);
|
||||
(*m_impl)(vars, fml);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ class tactic;
|
|||
class qe_lite {
|
||||
class impl;
|
||||
impl * m_impl;
|
||||
|
||||
public:
|
||||
/**
|
||||
use_array_der controls whether equalities over array reads are simplified
|
||||
|
|
54
src/qe/lite/qel.cpp
Normal file
54
src/qe/lite/qel.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*++
|
||||
|
||||
Module Name:
|
||||
|
||||
qel.cpp
|
||||
|
||||
Abstract:
|
||||
Light weight quantifier elimination (QEL) based on term graph.
|
||||
|
||||
The implementation is based on the following paper:
|
||||
|
||||
Isabel Garcia-Contreras, Hari Govind V. K., Sharon Shoham, Arie Gurfinkel:
|
||||
Fast Approximations of Quantifier Elimination. Computer-Aided Verification
|
||||
(CAV). 2023. URL: https://arxiv.org/abs/2306.10009
|
||||
|
||||
Author:
|
||||
|
||||
Hari Govind V K (hgvk94)
|
||||
Isabel Garcia (igcontreras)
|
||||
|
||||
Revision History:
|
||||
|
||||
|
||||
--*/
|
||||
#include "qe/lite/qel.h"
|
||||
#include "qe/mbp/mbp_term_graph.h"
|
||||
|
||||
class qel::impl {
|
||||
private:
|
||||
ast_manager &m;
|
||||
|
||||
public:
|
||||
impl(ast_manager &m, params_ref const &p) : m(m) {}
|
||||
|
||||
void operator()(app_ref_vector &vars, expr_ref &fml) {
|
||||
if (vars.empty()) return;
|
||||
|
||||
mbp::term_graph tg(m);
|
||||
tg.set_vars(vars);
|
||||
|
||||
expr_ref_vector lits(m);
|
||||
flatten_and(fml, lits);
|
||||
tg.add_lits(lits);
|
||||
tg.qel(vars, fml);
|
||||
}
|
||||
};
|
||||
|
||||
qel::qel(ast_manager &m, params_ref const &p) { m_impl = alloc(impl, m, p); }
|
||||
|
||||
qel::~qel() { dealloc(m_impl); }
|
||||
|
||||
void qel::operator()(app_ref_vector &vars, expr_ref &fml) {
|
||||
(*m_impl)(vars, fml);
|
||||
}
|
49
src/qe/lite/qel.h
Normal file
49
src/qe/lite/qel.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*++
|
||||
|
||||
Module Name:
|
||||
|
||||
qel.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Light weight quantifier elimination (QEL) based on term graph.
|
||||
|
||||
The implementation is based on the following paper:
|
||||
|
||||
Isabel Garcia-Contreras, Hari Govind V. K., Sharon Shoham, Arie Gurfinkel:
|
||||
Fast Approximations of Quantifier Elimination. Computer-Aided Verification
|
||||
(CAV). 2023. URL: https://arxiv.org/abs/2306.10009
|
||||
|
||||
Author:
|
||||
|
||||
Hari Govind V K (hgvk94)
|
||||
Isabel Garcia (igcontreras)
|
||||
|
||||
Revision History:
|
||||
|
||||
|
||||
--*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ast/ast.h"
|
||||
#include "ast/ast_util.h"
|
||||
#include "util/params.h"
|
||||
#include "util/uint_set.h"
|
||||
|
||||
class qel {
|
||||
class impl;
|
||||
impl *m_impl;
|
||||
|
||||
public:
|
||||
qel(ast_manager &m, params_ref const &p);
|
||||
|
||||
~qel();
|
||||
|
||||
/**
|
||||
\brief Applies light-weight elimination of `vars` provided as vector
|
||||
of expressions to the cube `fml`. Returns the updated formula and updated
|
||||
set of variables that were not eliminated.
|
||||
*/
|
||||
void operator()(app_ref_vector &vars, expr_ref &fml);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue