3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-07-17 18:06:40 +00:00
Commit graph

93 commits

Author SHA1 Message Date
Nuno Lopes
029d726eb8 minor code simplification 2023-09-25 15:33:40 +01:00
Nikolaj Bjorner
06a8987314 fix #6748
destructive equality resolution uses an occurs check function that is only safe for quantifier-free formulas. In the special case where a bound variable is Boolean and occurs on a side of an equality the other side cannot have a quantifier.
2023-06-07 15:59:39 -07:00
Nikolaj Bjorner
76aad689c6 Update smt_context_pp.cpp
print units in statistics
2023-02-28 17:40:08 -08:00
Nikolaj Bjorner
84af521514 fixes #6439 #6436 2022-11-04 09:36:06 -07:00
Arie Gurfinkel
d2b618df23
Spacer Global Guidance (#6026)
* Make spacer_sem_matcher::reset() public

* Add .clang-format for src/muz/spacer

* Mark substitution::get_bindings() as const

* Fix in spacer_antiunify

* Various helper methods in spacer_util

Minor functions to compute number of free variables, detect presence of certain
sub-expressions, etc.

The diff is ugly because of clang-format

* Add spacer_cluster for clustering lemmas

A cluster of lemmas is a set of lemmas that are all instances of the same
pattern, where a pattern is a qff formula with free variables.

Currently, the instances are required to be explicit, that is, they are all
obtained by substituting concrete values (i.e., numbers) for free variables of
the pattern.

Lemmas are clustered in cluster_db in each predicate transformer.

* Integrate spacer_cluster into spacer_context

* Custom clang-format pragmas for spacer_context

spacer_context.(cpp|h) are large and have inconsistent formatting. Disable
clang-format for them until merge with main z3 branch and re-format.

* Computation of convex closure and matrix kernel

Various LA functions. The implementations are somewhat preliminary.

Convex closure is simplemented via syntactic convex closure procedure.
Kernel computation considers many common cases.

spacer_arith_kernel_sage implements kernel computation by call external
Sage binary. It is used only for debugging and experiments. There is no
link dependence on Sage. If desired, it can be removed.

* Add spacer_concretize

* Utility methods for spacer conjecture rule

* Add spacer_expand_bnd_generalizer

Generalizes arithmetic inequality literals of the form x <= c,
by changing constant c to other constants found in the problem.

* Add spacer_global_generalizer

Global generalizer checks every new lemma against a cluster
of previously learned lemmas, and, if possible, conjectures
a new pob, that, when blocked, generalizes multiple existing
lemmas.

* Remove fp.spacer.print_json option

The option is used to dump state of spacer into json for debugging.

It has been replaced by `fp.spacer.trace_file` that allows dumping an execution
of spacer. The json file can be reconstructed from the trace file elsewhere.

* Workaround for segfault in spacer_proof_utils

Issue #3 in hgvk94/z3

Segfault in some proof reduction. Avoid by bailing out on reduction.

* Revert bug for incomplete models

* Use local fresh variables in spacer_global_generalizer

* Cleanup of spacer_convex_closure

* Allow arbitrary expressions to name cols in convex_closure

* WIP: convex closure

* WIP: convex closure

* Fix bindings order in spacer_global_generalizer

The matcher creates substitution using std_order, which is
reverse of expected order (variable 0 is last). Adjust the code
appropriately for that.

* Increase verbosity level for smt_context stats

* Dead code in qe_mbp

* bug fixes in spacer_global_generalizer::subsumer

* Partially remove dependence of size of m_alphas

I want m_alphas to potentially be greater than currently used alpha variables.
This is helpful for reusing them across multiple calls to convex closure

* Subtle bug in kernel computation

Coefficient was being passed by reference and, therefore, was
being changed indirectly.

In the process, updated the code to be more generic to avoid rational
computation in the middle of matrix manipulation.

* another test for sparse_matrix_ops::kernel

* Implementation of matrix kernel using Fraction Free Elimination

Ensures that the kernel is int for int matrices. All divisions are exact.

* clang-format sparse_matrix_ops.h

* another implementation of ffe kernel in sparse_matrix_ops

* Re-do arith_kernel and convex_closure

* update spacer_global_generalization for new subsumer

* remove spacer.gg.use_sage parameter

* cleanup of spacer_global_generalizer

* Removed dependency on sage

* fix in spacer_convex_closure

* spacer_sem_matcher: consider an additional semantic matching

disabled until it is shown useful

* spacer_global_generalizer: improve do_conjecture

 - if conjecture does not apply to pob, use lemma instead
 - better normalization
 - improve debug prints

* spacer_conjecture: formatting

* spacer_cluster: improve debug prints

* spacer_context: improve debug prints

* spacer_context: re-queue may pobs

enabled even if global re-queue is disabled

* spacer_cluster print formatting

* reset methods on pob

* cleanup of print and local variable names

* formatting

* reset generalization data once it has been used

* refactored extra pob creation during global guidance

* fix bug copying sparse matrix into spacer matrix

* bug fix in spacer_convex_closure

* formatting change in spacer_context

* spacer_cluster: get_min_lvl

chose level based on pob as well as lemmas

* spacer_context: add desired_level to pob

desired_level indicates at which level pob should be proved.
A pob will be pushed to desired_level if necessary

* spacer_context: renamed subsume stats

the name of success/failed was switched

* spacer_convex_closure: fix prototype of is_congruent_mod()

* spacer_convex_closure: hacks in infer_div_pred()

* spacer_util: do not expand literals with mod

By default, equality literal t=p is expanded into t<=p && t>=p

Disable the expansion in case t contains 'mod' operator since such
expansion is usually not helpful for divisibility

* spacer_util: rename m_util into m_arith

* spacer_util: cleanup normalize()

* spacer_util: formatting

* spacer_context: formatting cleanup on subsume and conjecture

* spacer_context: fix handling may pobs when abs_weakness is enabled

A pob might be undef, so weakness must be bumped up

* spacer_arith_kernel: enhance debug print

* spacer_global_generalizer: improve matching on conjecture

* spacer_global_generalizer: set desired level on conjecture pob

* spacer_global_generalizer: debug print

* spacer_global_generalizer: set min level on new pobs

the new level should not be higher than the pob that was generalized

* spacer_global_generalizer: do no re-create closed pobs

If a generalized pob exist and closed, do not re-create it.

* spacer_context: normalize twice

* spacer_context: forward propagate only same kind of pobs

* sketch of inductive generalizer

A better implementation of inductive generalizer that in addition to dropping
literals also attempts to weaken them.

Current implementation is a sketch to be extended based on examples/requirements.

* fix ordering in spacer_cluster_util

* fix resetting of substitution matcher in spacer_conjecture

Old code would forget to reset the substitution provided to the sem_matcher.
Thus, if the substitution was matched once (i.e., one literal of interest is
found), no other literal would be matched.

* add spacer_util is_normalized() method

used for debugging only

* simplify normalization of pob expressions

pob expressions are normalized to increase syntactic matching.
Some of the normalization rules seem out of place, so removing them for now.

* fix in spacer_global_generalizer

If conjecture fails, do not try other generalization strategies -- they will not apply.

* fix in spacer_context

do not check that may pob is blocked by existing lemmas.
It is likely to be blocked. Our goal is to block it again and generalize
to a new lemma.

This can be further improved by moving directly to generalization when pob is
blocked by existing lemmas...

Co-authored-by: hgvk94 <hgvk94@gmail.com>
2022-08-30 15:47:00 -07:00
Nikolaj Bjorner
54648f6b50 add stats for binary clause creation
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2022-05-10 14:58:15 -07:00
Nikolaj Bjorner
a326ad4cd9 flag incomplete on lambdas #5803 2022-01-31 11:54:06 -08:00
Nikolaj Bjorner
87d4ce2659 working on #5614
there are some different sources for the performance regression illustrated by the example. The mitigations will be enabled separately:
- m_bv_to_propagate is too expensive
- lp_bound_propagator misses equalities in two different ways:
   - it resets row checks after backtracking even though they could still propagate
   - it misses equalities for fixed rows when the fixed constant value does not correspond to a fixed variable.

FYI @levnach
2021-11-02 14:55:39 -07:00
Nikolaj Bjorner
115203e87c fixes to sat.euf ematching #5573 2021-10-16 15:52:37 -07:00
Nikolaj Bjorner
52032b9ef8 #5467 2021-10-12 10:16:15 -07:00
Nikolaj Bjorner
2973d3bdc1 fix #5392 2021-07-07 23:43:30 +02:00
Nikolaj Bjorner
00deb12238 signed
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2021-05-21 15:51:27 -07:00
Nikolaj Bjorner
03d2c5f3d0 consolidate literals 2021-05-20 12:58:27 -07:00
Nikolaj Bjorner
4a6083836a call it data instead of c_ptr for approaching C++11 std::vector convention. 2021-04-13 18:17:35 -07:00
Nikolaj Bjorner
0b0efa83ca debugging #5127 2021-04-06 20:09:50 -07:00
Nikolaj Bjorner
026065ff71 streamline pb solver interface and naming after removal of xor 2021-02-28 12:32:04 -08:00
Nikolaj Bjorner
be50f38903 enforce sign coherence #4740
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-11-09 14:30:00 -08:00
Nikolaj Bjorner
638ef9ed03 enforce sign coherence #4740
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-11-09 14:28:49 -08:00
Nikolaj Bjorner
c07cfc0e69 include path to thread and guard by SINGLE_THREAD
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-10-29 16:43:15 -07:00
Nikolaj Bjorner
ac4bcb9034 update logging for lemmas 2020-10-29 15:09:23 -07:00
Nikolaj Bjorner
601ba2a361 #4765
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-10-29 12:10:00 -07:00
Nikolaj Bjorner
367e5fdd52
delay internalize (#4714)
* adding array solver

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* use default in model construction

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* debug delay internalization

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* bv

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* arrays

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* get rid of implied values and bounds

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* redo egraph

* remove out

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* remove files

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-09-28 19:24:16 -07:00
Nikolaj Bjorner
549753845e
bv and gc of literals (#4692)
* bv and gc of literals

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* overload

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* diseq

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* diseq

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-09-17 14:24:07 -07:00
Nikolaj Bjorner
2d52367368 build
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-09-15 16:45:11 -07:00
Nikolaj Bjorner
80cc45c5c1 display justifications compactly for tracing #4575
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-07-08 13:32:41 -07:00
Nikolaj Bjorner
ee9c797822 address #3886 and #3891 by revamping nl_arith decoupling of monomial analysis and access
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-04-10 01:33:46 -07:00
Nikolaj Bjorner
066413516f disable temp debug
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-04-09 19:39:31 -07:00
Nikolaj Bjorner
c4b52edb29 add back assertion for #3849
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-04-09 18:08:40 -07:00
Nikolaj Bjorner
ee8aa50750 na
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-03-25 19:43:55 -07:00
Nikolaj Bjorner
e16c62d6e2 don't reset core after it has been populated for the cut #3451 and presumably other bugs
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-03-25 19:43:55 -07:00
Lev Nachmanson
c562a1f883 remove debug code and improve printing
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2020-02-04 16:08:24 -08:00
Nikolaj Bjorner
5f2720562b adding threads to smt core
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-01-31 17:08:53 -08:00
Lev Nachmanson
882b8ee63b NB's review
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2020-01-28 10:04:21 -08:00
Lev Nachmanson
f5c8ead995 port Grobner
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2020-01-28 10:04:21 -08:00
Lev Nachmanson
3e0cf4b96d port Grobner: fixes in nex simplifications
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2020-01-28 10:04:21 -08:00
Lev Nachmanson
8eaa2bfb02 sort nla_expr
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2020-01-28 10:04:21 -08:00
Lev Nachmanson
97ef190f4f full recursion on horner, not finished
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2020-01-28 10:04:21 -08:00
Lev Nachmanson
73e63e1ad9 fix a bug in nla_intervals
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2020-01-28 10:04:21 -08:00
Lev Nachmanson
e49dbbe465 fix ordered lemma
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2020-01-28 10:04:21 -08:00
Lev Nachmanson
54ba889b7b debug order lemma, introduce sign for factors
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2020-01-28 10:04:21 -08:00
Lev Nachmanson
b32f2703d4 fix in emonomials
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2020-01-28 10:04:21 -08:00
Lev Nachmanson
8cdf754990 debug emons
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
2020-01-28 10:04:21 -08:00
Nikolaj Bjorner
7e415c1b69 update to logging 2019-12-04 23:08:41 +03:00
Nikolaj Bjorner
2f6a9ba39b na
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-12-03 20:34:56 +01:00
Nikolaj Bjorner
23029daf5e investigating relevancy
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-11-05 17:16:30 +01:00
Nikolaj Bjorner
e816d16724 fix #2527
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-08-31 10:09:52 -04:00
Nikolaj Bjorner
a337a51374 fixes for #2513
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-08-23 23:29:24 +03:00
Nikolaj Bjorner
48fc3d752e add clause proof module, small improvements to bapa
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-05-30 15:49:19 -07:00
Nikolaj Bjorner
94dae2da3a fix fourth bug produced by repros by Mark Dunlop
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-01-27 18:11:18 -08:00
Nikolaj Bjorner
442e47dfce fix datatype occurs check bug reported by Gerhard Schellhorn
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-01-17 16:34:26 -08:00