3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-10 11:17:07 +00:00
Commit graph

257 commits

Author SHA1 Message Date
Nikolaj Bjorner d047b86439 pypi publish
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2024-09-26 21:35:28 +01:00
Nikolaj Bjorner f4452a0348 pypi publish
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2024-09-26 21:34:55 +01:00
Nikolaj Bjorner 0c48a50d59 Add support for initializing variable values in solver and optimize contexts in Z3 2024-09-20 18:28:26 +03:00
Nuno Lopes cab3c45863 remove unnecessary parameter copies 2023-12-22 16:11:06 +00:00
Nuno Lopes 4898a156d8 shrink ast's app by 8 bytes on 64-bit platforms when number of args > 0 2023-12-20 16:58:45 +00:00
Nuno Lopes 00593609c5 minor code simplification 2023-08-30 12:50:29 +01:00
Nuno Lopes 57c667e355 remove unused code 2023-08-20 15:16:47 +01:00
Nuno Lopes 8210aafb69 ast compare_nodes: fail faster when comparing quantifier expressions 2023-08-20 14:09:04 +01:00
Nikolaj Bjorner 30e8330907 fix #6813
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2023-07-15 17:03:44 -07:00
Nikolaj Bjorner 8a913981f6 fix #6813 - proofs terms are fragile with respect to simplificiation of not(not(e)). It would be better if proof terms didn't have to track this level of detail, but the legacy proof format assumes strictly checkable proofs. A patch is to fixup terms within the mk_transitivity constructor
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2023-07-15 17:03:04 -07:00
Nikolaj Bjorner 939bf1c725 wip - alpha support for polymorphism
An initial update to support polymorphism from SMTLIB3 and the API (so far C, Python).

The WIP SMTLIB3 format is assumed to be supporting the following declaration

```
(declare-type-var A)
```
Whenever A is used in a type signature of a function/constant or bound quantified variable, it is taken to mean that all instantiations of A are included in the signature and assertions.
For example, if the function f is declared with signature A -> A, then there is a version of f for all instances of A.
The semantics of polymorphism appears to follow previous proposals: the instances are effectively different functions.
This may clash with some other notions, such as the type signature forall 'a . 'a -> 'a would be inhabited by a unique function (the identity), while this is not enforced in this version (and hopefully never because it is more busy work).

The C API has the function 'Z3_mk_type_variable' to create a type variable and applying functions modulo polymorphic type signatures is possible.
The kind Z3_TYPE_VAR is added to sort discriminators.

This version is considered as early alpha. It passes a first rudimentary unit test involving quantified axioms, declare-fun, define-fun, and define-fun-rec.
2023-07-12 18:09:02 -07:00
Nikolaj Bjorner d6f2c23627 #6805 2023-07-11 09:41:29 -07:00
Nikolaj Bjorner 5806869ae4 fix #6792, add scaffolding for type variables
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2023-07-07 17:22:56 -07:00
Nikolaj Bjorner 84b9204616 inherit and reset rlimit counter on children limits
addresses rlimit leak reported by @mtzguido
2023-04-05 16:39:21 -07:00
Nikolaj Bjorner 1b0c76e3f0 fixes to mbqi in the new core based on #6575 2023-02-10 16:56:06 -08:00
Nikolaj Bjorner 4f7f4376b8 fix bug in new core not detecting conflict, fix #6525, add tactic doc
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2023-01-14 17:20:43 -05:00
Nikolaj Bjorner 78f9e6b31a extend error type message with more information - display the arguments that are passed 2022-11-06 11:57:21 -08:00
Nikolaj Bjorner 07dd1065db added API to monitor clause inferences
See RELEASE_NOTES for more information
examples pending.
2022-10-19 08:34:55 -07: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 9732169b04 #6320 2022-09-05 13:44:27 -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 5c2c0ae900 force-push on new_eq, new_diseq in user propagator, other fixes to Python bindings for user propagator
This update allows the python bindings for user-propagator to handle functions that are declared to be registered with the user propagator plugin. It fixes a bug in UserPropagateBase.add to allow registering terms dynamically during search.
It also fixes a bug in theory_user_propagate as scopes were not fully pushed when the solver gets the callbacks for new equalities and new disequalities.
It also adds equality and disequality interfaces to the sat/smt solver version (which isn't being exercised in earnest yet)
2022-07-25 03:42:29 +02:00
Nikolaj Bjorner a374e2c575 ignore qid if they are both numerical - come from the parser
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2022-07-05 15:47:48 -07:00
Nikolaj Bjorner 6e53621146 #6112
add q->get_qid() to comparison of quantifiers
2022-07-05 13:17:04 -07:00
Nuno Lopes 73a24ca0a9 remove '#include <iostream>' from headers and from unneeded places
It's harmful to have iostream everywhere as it injects functions in the compiled files
2022-06-17 14:10:19 +01:00
Nikolaj Bjorner 8efa3c8ade introduce notion of beta redex to deal with lambdas in non-extensional positions
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2022-06-10 17:35:01 -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 fe08c9976e fix #6081 2022-06-06 11:29:11 -07:00
Nikolaj Bjorner 40fe472e95
nit 2022-05-18 13:23:33 -07:00
Nuno Lopes 43f7636826 remove some copies/moves 2022-03-09 12:46:41 +00:00
Nuno Lopes 689e2d41de remove a bunch of unneeded memory allocations 2022-02-25 16:08:23 +00:00
Nikolaj Bjorner 6a412f7f04 allow to pass Booleans as arguments to arithmetic expressions 2022-01-31 12:00:54 -08:00
Nikolaj Bjorner c2595b9bc8 #5379
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2021-07-06 18:58:27 +02:00
Nuno Lopes 5a66dfad2a change parameter::hash so that the least significant bits arent overriden
the 3rd bit was being stuck by the parameter kind, leading to increased number of hash collisions
2021-05-27 09:38:21 +01:00
Nuno Lopes 36ca98cbbe ast: remove 2 default constructors 2021-05-24 14:59:03 +01:00
Nuno Lopes f8406623b4 switch parameter to an std::variant
plus fix mem leak & move constructor for zstrings
2021-05-23 13:07:29 +01:00
Nikolaj Bjorner 20a67e47ca remove symbol -> zstring -> symbol round-trips
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2021-05-22 13:12:49 -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
Nuno Lopes a6ef99d56e constify ids of builtin AST families + remove some dead code 2021-04-04 18:13:52 +01:00
Nikolaj Bjorner 9098084217 reduce overhead of creating seq-plugin, enable parameter cleanup for #5095 2021-03-15 11:54:44 -07:00
Nikolaj Bjorner 8f577d3943 remove ast_manager get_sort method entirely 2021-02-02 13:57:01 -08:00
Nikolaj Bjorner 3ae4c6e9de refactor get_sort 2021-02-02 04:45:54 -08:00
Nikolaj Bjorner 4455f6caf8 move to get_sort as method, add opt_lns pass, disable xor simplification unless configured, fix perf bug in model converter update trail 2021-02-02 03:58:19 -08:00
Nikolaj Bjorner 6c9bdc949e fix #4848 2020-12-07 05:59:55 -08:00
Nikolaj Bjorner 768e2c1d0d tune hoist-rewriter
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-11-09 11:25:17 -08:00
Nikolaj Bjorner 72d407a49f
mbp (#4741)
* 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

* add projection

* na

* na

* na

* na

* na

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

* deps

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

* testing arith/q

* na

* newline for model printing

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-10-21 15:48:40 -07:00
Nikolaj Bjorner 1d8d58710c fix #4725
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-10-06 08:41:30 -07:00
Nikolaj Bjorner 518296dbc1 some compile warnings
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-09-30 15:59:42 -07:00
Nikolaj Bjorner 6f63f8761c
optimizations to bv-solver and euf-egraph (#4698)
* additional bit-vector propagators

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

* rename restrict (not a keyword, but well) #4694, tune euf

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

* merge

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

* add pb rewriting to pb2bv #4697

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-09-20 06:47:27 -07:00
Nikolaj Bjorner 6a4261d1af debugging bv
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2020-09-15 15:37:31 -07:00