3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-07 09:55:19 +00:00
Commit graph

37 commits

Author SHA1 Message Date
Nikolaj Bjorner ac1552d194 wip - updates to proof logging and self-checking
move self-checking functionality to inside sat/smt so it can be used on-line and not just off-line.

when self-validation fails, use vs, not clause, to check. It allows self-validation without checking and maintaining RUP validation.

new options sat.smt.proof.check_rup, sat.smt.proof.check for online validation.

z3 sat.smt.proof.check=true sat.euf=true /v:1 sat.smt.proof.check_rup=true /st file.smt2 sat.smt.proof=p.smt2
2022-10-16 23:33:30 +02:00
Nikolaj Bjorner 993ff40826 fixes to proof logging and checking 2022-10-15 12:42:50 +02:00
Nikolaj Bjorner fceedf60dc wip - proofs 2022-10-10 16:41:09 +02:00
Nikolaj Bjorner de69874076 wip - adding proof checkers, fixes to quantifier proof certificates 2022-10-10 09:46:22 +02:00
Nikolaj Bjorner 4623117af8 wip - proof hints 2022-10-08 20:12:57 +02: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
Nikolaj Bjorner 9be8fc7857 Add EUF (congruence closure) proof hints and checker to the new core
EUF proofs are checked modulo union-find.
Equalities are added to to union-find if they are assumptions or if they can be derived using congruence closure. The congruence closure assumptions are added as proof-hints.
Note that this proof format does not track equality inferences, symmetry and transitivity. Instead they are handled by assuming a union-find based checker.
2022-09-25 14:26:20 -07:00
Nikolaj Bjorner e4ef1717e3 fix variable tracking bug in explanations with literals 2022-09-01 23:26:38 -07:00
Nikolaj Bjorner 3011b34b3b log E-matching based quantifier instantiations as hints 2022-08-31 18:59:02 -07:00
Nikolaj Bjorner dd90689339 build fixes
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2022-08-28 18:54:36 -07:00
Nikolaj Bjorner e2f4fc2307 overhaul of proof format for new solver
This commit overhauls the proof format (in development) for the new core.

NOTE: this functionality is work in progress with a long way to go.
It is shielded by the sat.euf option, which is off by default and in pre-release state.
It is too early to fuzz or use it. It is pushed into master to shed light on road-map for certifying inferences of sat.euf.

It retires the ad-hoc extension of DRUP used by the SAT solver.
Instead it relies on SMT with ad-hoc extensions for proof terms.
It adds the following commands (consumed by proof_cmds.cpp):

- assume  - for input clauses
- learn   - when a clause is learned (or redundant clause is added)
- del     - when a clause is deleted.

The commands take a list of expressions of type Bool and the
last argument can optionally be of type Proof.
When the last argument is of type Proof it is provided as a hint
to justify the learned clause.

Proof hints can be checked using a self-contained proof
checker. The sat/smt/euf_proof_checker.h class provides
a plugin dispatcher for checkers.
It is instantiated with a checker for arithmetic lemmas,
so far for Farkas proofs.

Use example:
```
(set-option :sat.euf true)
(set-option :tactic.default_tactic smt)
(set-option :sat.smt.proof f.proof)
(declare-const x Int)
(declare-const y Int)
(declare-const z Int)
(declare-const u Int)
(assert (< x y))
(assert (< y z))
(assert (< z x))
(check-sat)
```

Run z3 on a file with above content.
Then run z3 on f.proof

```
(verified-smt)
(verified-smt)
(verified-smt)
(verified-farkas)
(verified-smt)
```
2022-08-28 17:44:33 -07:00
Nikolaj Bjorner 458f417f44 move drat functionality into euf 2022-08-25 19:19:13 -07:00
Nikolaj Bjorner 1ffbe23ee3 add virtual destructor to fix build
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2022-08-25 18:37:24 -07:00
Nikolaj Bjorner 1894c86ee0 virtual
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2022-08-25 18:27:30 -07:00
Nikolaj Bjorner a628e4c4e5 updates to printer to get instantiations, take 1 2022-08-25 11:22:35 -07:00
Nikolaj Bjorner fb8532bf55 succinct logging
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2022-08-23 21:06:04 -07:00
Nikolaj Bjorner ce1f3987d9 fix unsoundness in quantifier propagation #6116 and add initial lemma logging 2022-08-23 19:10:01 -07:00
Nikolaj Bjorner b169292743 add parameter descriptions
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2022-08-16 08:26:53 -07:00
Nikolaj Bjorner 51ed13f96a update topological sort to use arrays instead of hash tables, expose Context over Z3Object for programmability
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2022-06-08 06:28:24 -07:00
Nikolaj Bjorner dcc01b874a prep for pragmas 2022-05-09 11:18:15 -07:00
Nikolaj Bjorner 6a9241ff0f #5429 2021-07-31 11:00:12 -07:00
Nikolaj Bjorner 1e8009bbfc build/labels 2021-07-30 22:29:00 -07:00
Nikolaj Bjorner 53ab931626 #5429
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2021-07-30 21:35:09 -07:00
Nikolaj Bjorner b02cba6106 rename propagation to explain 2021-02-27 17:25:11 -08:00
Nikolaj Bjorner 830f314a3f fixes to dt_solver and related 2021-02-27 11:03:20 -08:00
Nikolaj Bjorner a152bb1e80 remove template Context dependency in every trail object 2021-02-08 15:41:57 -08:00
Nikolaj Bjorner 11477f1ed1 fixes in new solver
fix logging and lemma signs in arith_solver, move logging of drat equalities to euf
2020-12-16 10:40:17 -08:00
Nikolaj Bjorner 4d55f83654 misc 2020-12-04 16:59:13 -08:00
Nikolaj Bjorner 12198d13ac fix #4794 2020-12-02 12:24:35 -08:00
Nikolaj Bjorner 2f756da294
adding dt-solver (#4739)
* adding dt-solver

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

* dt

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

* move mbp to self-contained module

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

* files

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

* Create CMakeLists.txt

* dt

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

* rename to bool_var2expr to indicate type class

* mbp

* na
2020-10-18 15:28:21 -07:00
Nikolaj Bjorner 6a4261d1af debugging bv
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-09-15 15:37:31 -07:00
Nikolaj Bjorner 796e2fd9eb
arrays (#4684)
* arrays

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

* arrays

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

* na

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

* arrays

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

* na

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

* fill

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

* update drat and fix euf bugs

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

* na

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

* na

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

* na

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

* const qualifiers

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

* na

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

* reorg ba

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

* reorg

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

* build warnings

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-09-13 19:29:59 -07:00
Nikolaj Bjorner d02b0cde7a
running updates to bv_solver (#4674)
* na

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

* na

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

* na

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

* na

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

* na

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

* na

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

* na

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

* na

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

* dbg

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

* bv

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

* drat and fresh

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

* move ackerman functionality

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

* na

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

* debugability

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

* towards debugability

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

* missing file

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

* na

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

* na

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

* remove csp

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-09-07 20:35:32 -07:00
Nikolaj Bjorner d83d0a83d6 na
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-09-02 14:43:49 -07:00
Nikolaj Bjorner 7c2fe46eb7 build fix 2020-09-02 12:35:12 -07:00
Nikolaj Bjorner 116390833b prepare for theory plugins
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-09-02 10:42:18 -07:00
Nikolaj Bjorner 4d41db3028 adding euf
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-08-31 14:36:16 -07:00