3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-07-13 16:06:39 +00:00
Commit graph

3405 commits

Author SHA1 Message Date
Nikolaj Bjorner
9d35a8c702 updates to euf-completion to 2025-06-07 15:39:31 -07:00
Nikolaj Bjorner
1cd162203d make rule processing fully incremental 2025-06-06 20:45:54 +02:00
Nikolaj Bjorner
d33d6ebe83 handle build warnings 2025-06-06 15:13:31 +02:00
Nikolaj Bjorner
7566f088f9 vtable
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-06-06 15:02:34 +02:00
Nikolaj Bjorner
e2cf4d99fb add better bit-blasting for rotation #7673 2025-06-06 12:30:00 +02:00
Nikolaj Bjorner
564830ab31 enable conditional euf-completion with (optional) solver
This allows using z3 for limited E-saturation simplification.
The tactic rewrites all assertions using the E-graph induced by the equalities and instantiated equality axioms.
It does allow solving with conditionals, although this is a first inefficient cut.

The following is a sample use case that rewrites to false.
```
(declare-fun prime () Int)
(declare-fun add (Int Int) Int)
(declare-fun mul (Int Int) Int)
(declare-fun ^ (Int Int) Int)
(declare-fun sub (Int Int) Int)
(declare-fun i () Int)
(declare-fun j () Int)
(declare-fun base () Int)
(declare-fun S () (Seq Int))
(declare-fun hash ((Seq Int) Int Int Int Int) Int)
(assert (let ((a!1 (mul (seq.nth S i) (^ base (sub (sub j i) 1)))))
(let ((a!2 (mod (add (hash S base prime (add i 1) j) a!1) prime)))
  (not (= (hash S base prime i j) a!2)))))
(assert (forall ((x Int))
  (! (= (mod (mod x prime) prime) (mod x prime))
     :pattern ((mod (mod x prime) prime)))))
(assert (forall ((x Int) (y Int))
  (! (= (mod (mul x y) prime) (mod (mul (mod x prime) y) prime))
     :pattern ((mod (mul x y) prime))
     :pattern ((mod (mul (mod x prime) y) prime)))))
(assert (forall ((x Int) (y Int))
  (! (= (mod (mul x y) prime) (mod (mul x (mod y prime)) prime))
     :pattern ((mod (mul x y) prime))
     :pattern ((mod (mul x (mod y prime)) prime)))))
(assert (forall ((x Int) (y Int))
  (! (= (mod (add x y) prime) (mod (add x (mod y prime)) prime))
     :pattern ((mod (add x y) prime))
     :pattern ((mod (add x (mod y prime)) prime)))))
(assert (forall ((x Int) (y Int))
  (! (= (mod (add x y) prime) (mod (add (mod x prime) y) prime))
     :pattern ((mod (add x y) prime))
     :pattern ((mod (add (mod x prime) y) prime)))))
(assert (forall ((x Int) (y Int))
  (! (= (mul x (^ x y)) (^ x (add y 1))) :pattern ((mul x (^ x y))))))
(assert (forall ((x Int) (y Int)) (! (= (mul x y) (mul y x)) :pattern ((mul x y)))))
(assert (forall ((x Int) (y Int)) (! (= (add x y) (add y x)) :pattern ((add x y)))))
(assert (forall ((x Int) (y Int)) (! (= (mul x y) (mul y x)) :pattern ((mul x y)))))
(assert (forall ((x Int) (y Int) (z Int))
  (! (= (add x (add y z)) (add (add x y) z))
     :pattern ((add x (add y z)))
     :pattern ((add (add x y) z)))))
(assert (forall ((x Int) (y Int) (z Int))
  (! (= (mul x (mul y z)) (mul (mul x y) z))
     :pattern ((mul x (mul y z)))
     :pattern ((mul (mul x y) z)))))
(assert (forall ((x Int) (y Int) (z Int))
  (! (= (sub (sub x y) z) (sub (sub x z) y)) :pattern ((sub (sub x y) z)))))
(assert (forall ((x Int) (y Int) (z Int))
  (! (= (mul x (add y z)) (add (mul x y) (mul x z)))
     :pattern ((mul x (add y z))))))
(assert (forall ((x Int)) (! (= (sub (add x 1) 1) x) :pattern ((add x 1)))))
(assert (forall ((x Int)) (! (= (add (sub x 1) 1) x) :pattern ((sub x 1)))))
(assert (let ((a!1 (^ base (sub (sub (sub j 1) i) 1))))
(let ((a!2 (mod (add (hash S base prime (add i 1) (sub j 1))
                     (mul (seq.nth S i) a!1))
                prime)))
  (= (hash S base prime i (sub j 1)) a!2))))
(assert (let ((a!1 (add (seq.nth S (- j 1)) (mul base (hash S base prime i (sub j 1))))))
  (= (hash S base prime i j) (mod a!1 prime))))
(assert (let ((a!1 (add (seq.nth S (- j 1))
                (mul base (hash S base prime (add i 1) (sub j 1))))))
  (= (hash S base prime (add i 1) j) (mod a!1 prime))))
(apply euf-completion)
```

To use conditional rewriting you can
```
(assert (not (= 0 prime)))
```
and update axioms using modulus with prime to be of the form:
```
(=> (not (= 0 prime)) <original-body of quantifier>)
```
2025-06-06 11:42:31 +02:00
Nikolaj Bjorner
ef284cca5d for Arie 2025-06-04 14:24:01 +02:00
Nikolaj Bjorner
2714dc2623 fix #7661 2025-05-29 17:46:51 +01:00
LeeYoungJoon
0a93ff515d
Centralize and document TRACE tags using X-macros (#7657)
* Introduce X-macro-based trace tag definition
- Created trace_tags.def to centralize TRACE tag definitions
- Each tag includes a symbolic name and description
- Set up enum class TraceTag for type-safe usage in TRACE macros

* Add script to generate Markdown documentation from trace_tags.def
- Python script parses trace_tags.def and outputs trace_tags.md

* Refactor TRACE_NEW to prepend TraceTag and pass enum to is_trace_enabled

* trace: improve trace tag handling system with hierarchical tagging

- Introduce hierarchical tag-class structure: enabling a tag class activates all child tags
- Unify TRACE, STRACE, SCTRACE, and CTRACE under enum TraceTag
- Implement initial version of trace_tag.def using X(tag, tag_class, description)
  (class names and descriptions to be refined in a future update)

* trace: replace all string-based TRACE tags with enum TraceTag
- Migrated all TRACE, STRACE, SCTRACE, and CTRACE macros to use enum TraceTag values instead of raw string literals

* trace : add cstring header

* trace : Add Markdown documentation generation from trace_tags.def via mk_api_doc.py

* trace : rename macro parameter 'class' to 'tag_class' and remove Unicode comment in trace_tags.h.

* trace : Add TODO comment for future implementation of tag_class activation

* trace : Disable code related to tag_class until implementation is ready (#7663).
2025-05-28 14:31:25 +01:00
Nikolaj Bjorner
d766292dab add seed parameter, fix trail undo order from insertion to ensure lifetime 2025-05-27 18:03:00 +01:00
Nikolaj Bjorner
80c553d24a missing file
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-05-24 00:20:30 +01:00
Nikolaj Bjorner
77fed8b97c v1 of a randomizer simplifier 2025-05-24 00:15:47 +01:00
Nikolaj Bjorner
7ca94e8fef add E-matching to EUF completion 2025-05-10 16:15:04 -07:00
Nikolaj Bjorner
a51239c641 update namespace, hoist exported functions outside of embedded namespace 2025-05-07 15:57:47 -07:00
Nikolaj Bjorner
644118660f list euf dependency in api cmakefile
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-05-07 15:47:03 -07:00
Nikolaj Bjorner
9a299eb9ff move mam to euf 2025-05-07 14:38:59 -07:00
Nikolaj Bjorner
4bedb5f8fc fix #7638 2025-05-03 11:04:41 -07:00
Nikolaj Bjorner
b502126ebc fix #7634 2025-04-27 23:57:57 -07:00
Nuno Lopes
322e4441b3 Fix conversion of signed 1-bit BV to FP
Fixes https://github.com/AliveToolkit/alive2/issues/1193
2025-04-25 12:38:00 +01:00
Nikolaj Bjorner
1510b3112e fix build warnings 2025-04-14 10:34:09 -07:00
Nikolaj Bjorner
e86a918ae7 turn on ite simplification by default 2025-03-26 11:30:08 -07:00
Nikolaj Bjorner
8368094618 fix indentation 2025-03-25 21:27:38 -07:00
Nikolaj Bjorner
4fd6ba442a replace costly ite reduction by disjointnes check 2025-03-25 21:15:03 -07:00
Nikolaj Bjorner
392bc166a3 optimize bool rewriter 2025-03-25 14:07:52 -07:00
Nikolaj Bjorner
29712503a0 add option to rewrite ite value trees 2025-03-25 11:09:56 -07:00
Nikolaj Bjorner
7e4a1f246e fix crash in elim_constr2 2025-03-24 12:36:13 -07:00
Nikolaj Bjorner
99ec42c0d7 additional simplifications to seq 2025-03-19 08:57:31 -10:00
Nikolaj Bjorner
13c098f4b2 better equality solving pre-processing with bv 2025-03-12 17:18:26 -07:00
Nikolaj Bjorner
d980ac9a05 fix #7582 2025-03-12 17:17:47 -07:00
Nikolaj Bjorner
fa5a50c4f9 fix #7295
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-03-12 11:43:31 -07:00
Nikolaj Bjorner
80f00f191a fix #7572 and fix #7574
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-03-07 10:46:29 -08:00
Nikolaj Bjorner
1fec0fa35b remove verbose output
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-02-19 15:35:51 -08:00
Nikolaj Bjorner
01fbc0e8e7 fix #7563 2025-02-19 14:55:27 -08:00
Nikolaj Bjorner
3e5abef145 fix #7549 2025-02-18 21:38:06 -08:00
Nikolaj Bjorner
28f3f8046e #7559 2025-02-18 20:50:06 -08:00
Nikolaj Bjorner
674e1b8f98 remove equality check on container 2025-02-18 20:15:42 -08:00
Nikolaj Bjorner
a5e5a35755 code simplification 2025-02-18 19:07:58 -08:00
Nikolaj Bjorner
a143ed3bff taking a look at mbp_qel for arrays
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-02-18 16:28:49 -08:00
Nikolaj Bjorner
b27a2aa7fc remove calls to removed def constructor
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-02-16 10:13:00 -08:00
Nikolaj Bjorner
62126fd6e2 fix build warnings
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-02-10 11:51:21 -08:00
Nikolaj Bjorner
d465bdbb87 include extensionality constraints for arrays 2025-01-31 11:06:40 -08:00
Clemens Eisenhofer
9557e7cacf
Minor (#7540) 2025-01-31 08:22:30 -08:00
Nikolaj Bjorner
eb825855fa increase the log level on callbacks with bit-indices that get set 2025-01-30 16:34:36 -08:00
Nikolaj Bjorner
c9ac4d6f75 pre-flatten use list before iterating over m_unsat
select_max_same_sign accesses the use-list which may cause it to be flattened.
2025-01-30 16:34:17 -08:00
Nikolaj Bjorner
e3566288a4 fixes based on benchmarking UFDTLIA/NIA/BV 2025-01-29 17:00:26 -08:00
Nikolaj Bjorner
f1e0950069 fix several crashes exposed by QF_UFDTNIA benchmark sets 2025-01-29 16:23:38 -08:00
Nikolaj Bjorner
bfe4673dac this check is not an invariant in the first place
but nice to have.
2025-01-29 16:23:18 -08:00
Nikolaj Bjorner
51357f6d06 Add selective filter on Ackerman axioms 2025-01-29 11:42:50 -08:00
Clemens Eisenhofer
c2a0919f79
Removed no progress case in seq-sls (#7537) 2025-01-29 09:43:57 -08:00
Nikolaj Bjorner
6d3cfb63da add eval1 functionality for replace_all 2025-01-29 04:36:55 -08:00