3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-12 06:00:53 +00:00
z3/src/tactic/core
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
..
blast_term_ite_tactic.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
blast_term_ite_tactic.h doc 2022-12-07 08:51:18 -08:00
CMakeLists.txt enable conditional euf-completion with (optional) solver 2025-06-06 11:42:31 +02:00
cofactor_elim_term_ite.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
cofactor_elim_term_ite.h booyah 2020-07-04 15:56:30 -07:00
cofactor_term_ite_tactic.cpp refactoring to use for-range 2025-05-15 10:57:46 -07:00
cofactor_term_ite_tactic.h increase build version, better propagation in euf-egraph, handle assumptions in sat.smt 2023-01-17 14:07:07 -08:00
collect_occs.cpp outline of invertible reduction 2018-06-30 13:46:29 -07:00
collect_occs.h booyah 2020-07-04 15:56:30 -07:00
collect_statistics_tactic.cpp remove a couple more std::endl 2023-01-03 09:49:58 +00:00
collect_statistics_tactic.h booyah 2020-07-04 15:56:30 -07:00
ctx_simplify_tactic.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
ctx_simplify_tactic.h doc 2022-12-07 08:51:18 -08:00
demodulator_tactic.h update release notes 2023-01-31 12:19:33 -08:00
der_tactic.cpp use iterators on goal and other refactoring 2025-03-16 20:04:04 -07:00
der_tactic.h add der description 2022-12-06 05:46:52 -08:00
distribute_forall_tactic.h update release notes 2023-01-31 12:19:33 -08:00
dom_simplify_tactic.h update release notes 2023-01-31 12:19:33 -08:00
elim_term_ite_tactic.cpp move model and proof converters to self-contained module 2022-11-03 05:23:01 -07:00
elim_term_ite_tactic.h doc 2022-12-07 08:51:18 -08:00
elim_uncnstr2_tactic.h update release notes 2023-01-31 12:19:33 -08:00
elim_uncnstr_tactic.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
elim_uncnstr_tactic.h elim_uncnstr_tactic: remove m_imp idiom to reduce mem alloc 2018-12-21 19:48:18 +00:00
eliminate_predicates_tactic.h enable interactive example 2023-03-25 18:13:44 +01:00
injectivity_tactic.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
injectivity_tactic.h cave in to supporting proofs (partially) in simplifiers, updated doc 2022-12-06 17:02:04 -08:00
nnf_tactic.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
nnf_tactic.h remove comment that does not align with result 2022-12-06 15:53:55 -08:00
occf_tactic.cpp move model and proof converters to self-contained module 2022-11-03 05:23:01 -07:00
occf_tactic.h more tactic descriptions 2023-01-05 20:23:01 -08:00
pb_preprocess_tactic.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
pb_preprocess_tactic.h doc 2022-12-07 08:51:18 -08:00
propagate_values2_tactic.h update release notes 2023-01-31 12:19:33 -08:00
propagate_values_tactic.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
propagate_values_tactic.h spread a few anonymous namespaces and remove some m_imp idioms 2018-12-21 23:02:15 +00:00
reduce_args_tactic.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
reduce_args_tactic.h update release notes 2023-01-31 12:19:33 -08:00
simplify_tactic.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
simplify_tactic.h Fix : typo-in-simplify-tactic (#7587) 2025-03-18 13:43:12 -10:00
solve_eqs_tactic.h update release notes 2023-01-31 12:19:33 -08:00
special_relations_tactic.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
special_relations_tactic.h Remove empty leaf destructors. (#6211) 2022-07-30 10:07:03 +01:00
split_clause_tactic.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
split_clause_tactic.h add tactic doc 2023-01-10 18:58:25 -08:00
symmetry_reduce_tactic.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
symmetry_reduce_tactic.h more tactic descriptions 2023-01-05 20:23:01 -08:00
tseitin_cnf_tactic.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
tseitin_cnf_tactic.h more tactic descriptions 2023-01-05 20:23:01 -08:00