3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-26 21:16:02 +00:00
Commit graph

75 commits

Author SHA1 Message Date
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
Nikolaj Bjorner
a3f35b6830 Add command to set initial value hints for solver in various components 2024-09-18 17:48:03 +03:00
Bruce Mitchener
53f89a81c1
Fix some typos. (#7115) 2024-02-07 23:06:43 -08:00
Nikolaj Bjorner
d11e5c8ca6 address compiler warnings, and user question #6544 2023-01-19 19:02:43 -08:00
Nikolaj Bjorner
25b0b1430c move bound_manager to simplifiers, add bound manager to extract_eqs for solve-eqs #6532 2023-01-12 12:42:28 -08:00
Nikolaj Bjorner
fcea32344e add missing tactic descriptions, add rewrite for tamagochi
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2023-01-08 13:32:26 -08:00
Nikolaj Bjorner
f6d411d54b experimental feature to access congruence closure of SimpleSolver
This update includes an experimental feature to access a congruence closure data-structure after search.
It comes with several caveats as pre-processing is free to eliminate terms. It is therefore necessary to use a solver that does not eliminate the terms you want to track for congruence of. This is partially addressed by using SimpleSolver or incremental mode solving.

```python
from z3 import *
s = SimpleSolver()
x, y, z = Ints('x y z')
s.add(x == y)
s.add(y == z)
s.check()
print(s.root(x), s.root(y), s.root(z))
print(s.next(x), s.next(y), s.next(z))
```
2022-12-30 21:41:27 -08:00
Nikolaj Bjorner
1dca6402fb move model and proof converters to self-contained module 2022-11-03 05:23:01 -07:00
Nikolaj Bjorner
ccda49bad5 fix #6376
have solver throw an exception when user supplies a non-propositional assumption
2022-09-30 13:03:34 -04:00
Nikolaj Bjorner
107981f099 update proof formats for new core
- update proof format for quantifier instantiation to track original literals
- update proof replay tools with ability to extract proof object

The formats and features are subject to heavy revisions.

Example
```
(set-option :sat.euf true)
(set-option :sat.smt.proof eufproof.smt2)
(declare-fun f (Int) Int)
(declare-const x Int)
(assert (or (= (f (f (f x))) x) (= (f (f x)) x)))
(assert (not (= (f (f (f (f (f (f x)))))) x)))
(check-sat)
```

eufproof.smt2 is:
```
(declare-fun x () Int)
(declare-fun f (Int) Int)
(define-const $24 Int (f x))
(define-const $25 Int (f $24))
(define-const $26 Int (f $25))
(define-const $27 Bool (= $26 x))
(define-const $28 Bool (= $25 x))
(assume $27 $28)
(define-const $30 Int (f $26))
(define-const $31 Int (f $30))
(define-const $32 Int (f $31))
(define-const $33 Bool (= $32 x))
(assume (not $33))
(declare-fun rup () Proof)
(infer (not $33) rup)
(declare-fun euf (Bool Bool Proof Proof Proof Proof) Proof)
(declare-fun cc (Bool) Proof)
(define-const $42 Bool (= $32 $30))
(define-const $43 Proof (cc $42))
(define-const $40 Bool (= $31 $24))
(define-const $41 Proof (cc $40))
(define-const $38 Bool (= $30 $25))
(define-const $39 Proof (cc $38))
(define-const $36 Bool (= $24 $26))
(define-const $37 Proof (cc $36))
(define-const $34 Bool (not $33))
(define-const $44 Proof (euf $34 $28 $37 $39 $41 $43))
(infer (not $28) $33 $44)
(infer (not $28) rup)
(infer $27 rup)
(declare-fun euf (Bool Bool Proof Proof Proof) Proof)
(define-const $49 Bool (= $32 $26))
(define-const $50 Proof (cc $49))
(define-const $47 Bool (= $31 $25))
(define-const $48 Proof (cc $47))
(define-const $45 Bool (= $24 $30))
(define-const $46 Proof (cc $45))
(define-const $51 Proof (euf $34 $27 $46 $48 $50))
(infer $33 $51)
(infer rup)
```

Example of inspecting proof from Python:

```
from z3 import *

def parse(file):
    s = Solver()
    set_option("solver.proof.save", True)
    set_option("solver.proof.check", False)
    s.from_file(file)
    for step in s.proof().children():
        print(step)

parse("../eufproof.smt2")
```

Proof checking (self-validation) is on by default.
Proof saving is off by default.

You can use the proof logs and the proof terms to retrieve quantifier instantiations from the new core.

The self-checker contains a few built-in tuned checkers but falls back to self-checking inferred clauses using SMT.
2022-09-28 10:40:43 -07:00
Bruce Mitchener
5d0dea05aa
Remove empty leaf destructors. (#6211) 2022-07-30 10:07:03 +01:00
Nuno Lopes
d9fcfdab34 fix debug build 2022-06-17 14:35:33 +01:00
Nikolaj Bjorner
3cc9d7f443 improve pre-processing 2022-04-15 12:55:26 +02:00
Henrich Lauko
96671cfc73
Add and fix a few general compiler warnings. (#5628)
* rewriter: fix unused variable warnings

* cmake: make missing non-virtual dtors error

* treewide: add missing virtual destructors

* cmake: add a few more checks

* api: add missing virtual destructor to user_propagator_base

* examples: compile cpp example with compiler warnings

* model: fix unused variable warnings

* rewriter: fix logical-op-parentheses warnings

* sat: fix unused variable warnings

* smt: fix unused variable warnings
2021-10-29 15:42:32 +02:00
Nikolaj Bjorner
6f31d83633 fix #5541 2021-09-20 10:10:28 -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
0ec567fe15 integrate v2 of lns 2021-02-04 15:47:40 -08:00
Nikolaj Bjorner
fb1509d011 expose internal API for set_phase 2021-02-02 14:29:06 -08:00
Nikolaj Bjorner
8f577d3943 remove ast_manager get_sort method entirely 2021-02-02 13:57:01 -08:00
Nikolaj Bjorner
937b61fc88 fix build, refactor 2021-02-02 05:26:57 -08:00
Nikolaj Bjorner
3ae4c6e9de refactor get_sort 2021-02-02 04:45:54 -08:00
Nikolaj Bjorner
65464f5944 include order 2020-11-22 15:39:09 -08: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
629e981e01 fix regression in get-consequence on QF_FD
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-09-08 12:43:18 -07:00
Arie Gurfinkel
687a16a796
SMTFD is back (#4676) 2020-09-04 10:50:35 -07:00
Nikolaj Bjorner
54a75d6a91 remove SMTFD
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-09-02 12:39:23 -07:00
Nikolaj Bjorner
59d8895d15 add accessors for implied values to API
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-07-28 19:46:39 -07:00
Nikolaj Bjorner
d0e20e44ff booyah
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-07-04 15:56:30 -07:00
Nikolaj Bjorner
426e4cc75c fix #3557
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-04-03 16:37:59 -07:00
Nikolaj Bjorner
5af139055d fix #3079
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-02-23 09:45:05 -08:00
Nikolaj Bjorner
030da1f8ac build warnings
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-01-05 20:50:36 -08:00
Nikolaj Bjorner
fec94d1552 fix #2805
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-12-20 12:48:19 -08:00
Nikolaj Bjorner
5da0902dd4 remove smt option
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-12-07 11:31:21 +03:00
Nikolaj Bjorner
9af4cc0fd6 links to API (related to issue in z3doc)
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-12-03 12:20:11 +01:00
Nikolaj Bjorner
1eab774b91 fix #2774
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-12-02 15:22:03 -08:00
Nikolaj Bjorner
b371592c0d unused variable warnings
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-11-30 19:21:35 -08:00
Nikolaj Bjorner
a257ec0cc1 build warnings #2748
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-11-28 15:36:54 -08:00
Nikolaj Bjorner
c36d9f7b3e fix #2741
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-11-26 19:45:34 -08:00
Nikolaj Bjorner
5f90e72d85 ensure generation is increased #2667
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-11-13 19:18:54 -08:00
Nikolaj Bjorner
12819640b7 fix E instantiation
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-11-11 17:10:47 -08:00
Nikolaj Bjorner
74cfcc4730 clang warnings
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-11-11 07:19:20 -08:00
Nikolaj Bjorner
20598e3bd2 address clang warnings
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-11-11 07:16:46 -08:00
Nikolaj Bjorner
779183da06 fixing smtfd
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-11-10 18:23:32 -08:00
Nikolaj Bjorner
4fabaf95aa remove deprecated and bind1st and unused warnings
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-11-08 13:26:50 -08:00
Nikolaj Bjorner
a78f899225 expand deep stores by lambdas to avoid expanding select/store axioms
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-11-03 10:29:10 +01:00
Nikolaj Bjorner
16d4ccd396 na
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-10-31 10:06:09 -07:00
Nikolaj Bjorner
8125fb134f na
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-10-23 20:19:06 -07:00
Nikolaj Bjorner
e5504247e9 use propagation filter
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-10-20 16:00:20 -07:00
Nikolaj Bjorner
11736f078e ensure statistics survive cancelation in tactics, fix propagation for smtfd
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-10-18 19:22:46 -07:00
Nikolaj Bjorner
203ba12abc moving to context reset model
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2019-10-18 19:22:46 -07:00