3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-06-28 19:38:51 +00:00
Commit graph

412 commits

Author SHA1 Message Date
Lev Nachmanson
f07acb459f
Fix WASM build: remove duplicate mk_parallel_tactic definition (#9979)
## Problem

The [master WebAssembly
Build](https://github.com/Z3Prover/z3/actions/runs/28306680131) fails
with:

```
../src/solver/parallel_tactical.cpp:59:9: error: redefinition of 'mk_parallel_tactic'
   59 | tactic* mk_parallel_tactic(solver* s, params_ref const& /* p */) {
../src/solver/parallel_tactical.cpp:55:9: note: previous definition is here
```

## Cause

Commit 7564ccc3f (an unrelated lar_solver change) accidentally renamed
the dead `mk_parallel_tactic2` stub to `mk_parallel_tactic`, leaving two
identical definitions inside the `#ifdef SINGLE_THREAD` block. The WASM
build defines `SINGLE_THREAD`, so it hits the redefinition.

## Fix

`mk_parallel_tactic2` and its `non_parallel_tactic2` class were never
referenced anywhere. This removes the dead stub and orphaned class,
keeping the single `mk_parallel_tactic` that degrades to
`mk_solver2tactic(s)` in single-threaded mode (added in #9977).

Verified both `SINGLE_THREAD` and multi-threaded paths pass
`-fsyntax-only`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-27 18:25:04 -07:00
Lev Nachmanson
7564ccc3f1
capture row by pointer (#9973)
Capture row as a pointer as lambda strips the reference and the vector was copied by value in lar_solver!

---------

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-27 17:43:08 -07:00
Copilot
39ea5ce8c0
Fix SINGLE_THREAD build: add mk_parallel_tactic stub to parallel_tactical.cpp (#9977)
The `#ifdef SINGLE_THREAD` block in `parallel_tactical.cpp` only defined
`mk_parallel_tactic2`, leaving `mk_parallel_tactic` (called by
`smt_tactic_core.cpp`, `fd_solver.cpp`, and `inc_sat_solver.cpp`)
undefined — causing linker failures in the ST CI job.

## Changes

- **`src/solver/parallel_tactical.cpp`**: Add `mk_parallel_tactic` stub
inside `#ifdef SINGLE_THREAD` that falls back to `mk_solver2tactic(s)`,
consistent with how other parallel tactics degrade in single-threaded
mode (`par()` → `or_else_tactical`, `par_and_then()` →
`and_then_tactical`):

```cpp
#ifdef SINGLE_THREAD

tactic* mk_parallel_tactic2(solver* s, params_ref const& p) {
    return alloc(non_parallel_tactic2, s, p);
}

tactic* mk_parallel_tactic(solver* s, params_ref const& /* p */) {
    return mk_solver2tactic(s);
}

#else
// ... full parallel implementation
```

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-06-27 10:20:11 -06:00
Nikolaj Bjorner
612fab1c9a
Parallel tactic (#9824) (#9825)
Add new parallel algorithm as a tactic (parallel_tactical2.cpp)
Don't port over old experiments from smt_parallel that we aren't using
(sls, inprocessing, failed_literal_mode for bb detection)
Fix bugs: lease cancellation/reslimit race condition, involves changing
lease epoch to simple boolean flag
Also, now there is a single shared set of params for the tactic and
smt_parallel

**Test runs for the parallel_tactical2 vs old smt_parallel version:**
run-2747-Z3-threads-4-qflia-30s-stats.md
run-2746-Z3-threads-4-qflia-30s-parallel_tactic-stats.md
run-2745-Z3-threads-1-qfbv-30s-stats.md
run-3013-Z3-threads-4-qfbv-30s-parallel_tactic-stats.md --> note this is
indeed run-3013, I reran after a bugfix in inc_sat_solver
run-2743-Z3-threads-4-qfnia-30s-stats.md
run-2742-Z3-threads-4-qfnia-30s-parallel_tactic-stats.md

**Test runs for the new smt_parallel with bugfixes:**
run-2801-Z3-threads-4-qflia-30s-smtparallel-bugfixes-stats.md,
run-2800-Z3-threads-4-qflia-30s-smtparallel-bugfixes-stats.md
run-2797-Z3-threads-4-qfnia-30s-smtparallel-bugfixes-stats.md
compare to old smt_parallel:
run-2747-Z3-threads-4-qflia-30s-stats.md
run-2743-Z3-threads-4-qfnia-30s-stats.md

Note that there is a slight regression on lia in run-2800. The source of
this appears to be the new new LP largest-cube LIA heuristic param,
which is enabled by default. disabling this param in run-2801 restored
performance (I didn't change this in this PR though, just something to
note)

http://mtzguido.tplinkdns.com:8081/z3/compare_stats.html

---------

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
Co-authored-by: Ilana Shapiro <ilanashapiro@Ilanas-MacBook-Pro.local>
Co-authored-by: Ilana Shapiro <ilanashapiro@Ilanas-MBP.localdomain>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-06-26 10:36:15 -06:00
davedets
99a8a922ec
Use "override" keyword where needed. (#9892)
This is another PR towards the goal of getting Z3 to compile cleanly
when included via FetchContents into clang-tidy, which uses a pretty
strict set of warnings.

The PR adds
```
  "-Wsuggest-override"
  "-Winconsistent-missing-override"
 ```
 to the CLANG_ONLY_WARNINGS.  This exposes a relatively small number of places where method overrides did not use the "override" keyword.  The PR fixes those.
 
(In cmd_util.h, I also made the *_CMD macros be uniform in not ending the class they define with a semicolon; the invocation of the macro can add the semicolon.)
2026-06-18 13:36:14 -06:00
davedets
86de0cbd71
Eliminate unused private fields and local variables. (#9875)
This is another PR towards the goal of getting a clean build with clang,
using the compiler options used in building clang-tidy.

By default, without any new -W flags, clang warns about unused local
variables and private class fields. This PR deletes the handful of these
that clang found.

I'm assuming that the class "enode" in smt_context.cpp is the one in
smt_enode.h, so that
```
parent->get_expr()
```
calls a const method with no side effects.
2026-06-16 14:55:18 +01:00
Nikolaj Bjorner
1f5132c396 refactor solver to include settable stats 2026-06-07 14:17:38 -07:00
Copilot
316d249b3f
SMT2 front-end: accept HO_ALL and normalize curried expression-head applications (#9636)
The SMT2 front-end rejected valid higher-order inputs using `HO_ALL` and
failed on curried applications where the function position is itself an
expression (e.g., `((transfer top) 0)`).
This update adds `HO_ALL` support and makes curried parsing consistently
lower to implicit `select` chains.

- **Logic recognition**
  - Treat `HO_ALL` as an `ALL`-class logic in SMT logic classification.
- This unblocks `(set-logic HO_ALL)` in the standard SMT2 command path.

- **Curried application parsing**
- Extend application-frame handling to support parenthesized expression
heads, not only symbol heads.
- When the head is an expression, parse application arguments normally
and construct nested implicit selects:
    - `(f a b)` → `(select (select f a) b)`
- Preserve existing behavior for symbol-based applications, qualified
identifiers, and lambda-led forms.

- **Regression coverage**
- Add a focused parser/eval regression using the reported higher-order
case to lock in behavior.

```smt2
(set-logic HO_ALL)
(declare-fun transfer () (-> (-> Int Bool) (-> Int Bool)))
(assert (forall ((P (-> Int Bool))) (=> (P 0) ((transfer P) 0))))
(declare-fun top () (-> Int Bool))
(assert (forall ((x Int)) (top x)))
(assert (not ((transfer top) 0)))
(check-sat)
```

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-05-26 18:39:38 -07:00
Nikolaj Bjorner
95b3ffeb25 replace struct by class
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-05-22 14:14:23 -07:00
Nikolaj Bjorner
2ba86c1ac3 benchmark patching
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-05-20 13:32:23 -07:00
Nikolaj Bjorner
09b75d2122 connect parallel tactical2 as side load
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2026-05-13 14:59:05 -07:00
Copilot
5fa7d6d63d
Simplify parallel_tactical2.cpp for naming consistency and minor expression cleanup (#9526)
This updates `src/solver/parallel_tactical2.cpp` with targeted
simplifications to align style and reduce local verbosity without
changing solver behavior. The changes are limited to member naming
consistency, cast style consistency, and a small `expr_ref` construction
cleanup.

- **`batch_manager` member naming consistency**
- Renamed the two outlier private fields to follow the existing `m_`
convention:
    - `shared_clause_trail` → `m_shared_clause_trail`
    - `shared_clause_set` → `m_shared_clause_set`
- Updated all corresponding reads/writes in clause collection, reset,
and clause-return paths.

- **Cast style consistency**
- Replaced C-style cast in thread count calculation with
`static_cast<unsigned>(...)` for consistency with style already used in
the file.

- **Simplified `expr_ref` construction in cube assembly**
- Collapsed default-init + assignment into direct construction when
pushing cube literals.

```cpp
// Before
expr_ref lit(g2l.to());
lit = g2l(cur->get_literal().get());
cube.push_back(std::move(lit));

// After
cube.push_back(expr_ref(g2l(cur->get_literal().get()), g2l.to()));
```

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-05-13 16:57:52 -04:00
Copilot
85465dcc66
Add parallel_tactical2.cpp: portfolio parallel solver using the solver API (#9515)
* add parallel_tactical2.cpp: portfolio parallel solver using solver API

Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/8b3749c7-5957-41aa-85b5-2d76d4780d61

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* address code review: cap conflict growth, clarify cube/split comments, use mk_or for conflict clause

Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/8b3749c7-5957-41aa-85b5-2d76d4780d61

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-05-12 21:19:27 -04:00
Nuno Lopes
f6f8beaf78 Remove copies (#8583) 2026-02-18 21:02:22 -08:00
Copilot
31e4945922 Remove redundant non-virtual destructors with = default (#8462)
* Initial plan

* Remove 6 non-virtual destructors with no code (= default)

Co-authored-by: nunoplopes <2998477+nunoplopes@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: nunoplopes <2998477+nunoplopes@users.noreply.github.com>
2026-02-18 20:58:01 -08:00
Copilot
317dd92105 Standardize for-loop increments to prefix form (++i) (#8199)
* Initial plan

* Convert postfix to prefix increment in for loops

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Fix member variable increment conversion bug

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Update API generator to produce prefix increments

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2026-02-18 20:57:29 -08:00
Nikolaj Bjorner
04cb59fd74 include FS logic
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-11-21 13:14:53 -08:00
Nikolaj Bjorner
0e6b3a922a Add commands for forcing preferences during search
Add commands:

(prefer <formula>)
- will instruct case split queue to assign formula to true.
- prefer commands added within a scope are forgotten after leaving the scope.

(reset-preferences)
- resets asserted preferences. Has to be invoked at base level.

This provides functionality related to MathSAT and based on an ask by Tomáš Kolárik who is integrating the functionality with OpenSMT2
2025-10-02 10:47:10 -07:00
Nuno Lopes
c350ddf990 remove a few useless dynamic casts 2025-09-13 21:06:55 +01:00
Nikolaj Bjorner
7566cc744d display assumptions used 2025-09-11 10:20:55 -07:00
Copilot
eb7fd9efaa
Add virtual translate method to solver_factory class (#7780)
* Initial plan

* Add virtual translate method to solver_factory base class and all implementations

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Add documentation for the translate method in solver_factory

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
2025-08-14 11:54:34 -07:00
Nikolaj Bjorner
b33f444545 add an option to register callback on quantifier instantiation
Suppose a user propagator encodes axioms using quantifiers and uses E-matching for instantiation. If it wants to implement a custom priority scheme or drop some instances based on internal checks it can register a callback with quantifier instantiation
2025-08-06 21:11:55 -07:00
Nuno Lopes
f23b053fb9 remove a bunch of string copies 2025-08-03 10:41:38 +01:00
Nikolaj Bjorner
97193b4a1d call into collect_statistics in case of -T interrupt 2025-07-01 14:15:15 -07:00
Nikolaj Bjorner
c387b20ac6 move smt params to params directory, update release.yml 2025-06-09 10:47:22 -07: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
30021dd74f fix #7590 logic alphabet soup
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-03-19 08:57:32 -10:00
Nikolaj Bjorner
c2b7b58c78 #7468 - add option (get-info :parameters) to display solver parameters that were updated globally and distinct from defaults
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2025-02-10 11:57:14 -08:00
Nikolaj Bjorner
1ce6e66ac9 generalize logic detection to use sub-string matching 2025-01-30 16:34:54 -08:00
Nikolaj Bjorner
decaee83f3 move from justified_expr to dependent_expr by aligning datatypes 2025-01-22 11:46:10 -08:00
Nikolaj Bjorner
f3e7c8c9df include QF_SNIA 2025-01-13 08:13:39 -08:00
Nikolaj Bjorner
09825edcd8 remove compute depth in favor of already existing get_depth 2024-12-23 18:49:54 -08:00
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
05e053247d add facility to solve for a linear term over API 2024-11-30 09:34:27 -08:00
Nikolaj Bjorner
012fc1b72b more detailed tracing of where unmaterialized exceptions happen
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2024-11-19 18:15:50 -08:00
Nikolaj Bjorner
e855a50d9b add exception handling to easier diagnose #7418
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2024-11-19 11:46:54 -08:00
Nikolaj Bjorner
5168a13efa track exceptions in reason-unknown
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2024-11-19 09:29:23 -08:00
Nikolaj Bjorner
abd16740ce inherit more exceptions from std::exception
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2024-11-04 13:52:14 -08:00
Nikolaj Bjorner
92065462b4 use std::exception as base class to z3_exception
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2024-11-04 11:08:15 -08:00
Nikolaj Bjorner
5a5e39ae74 fix incrementality bug for pre-processing: replay has to be invoked on every push regardless. 2024-10-16 13:07:18 -07:00
Nikolaj Bjorner
efde656036 fix recursive self call for slice_solver check-sat-cc method
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2024-10-10 16:38:00 -07:00
Nikolaj Bjorner
da614c65e5 remove m_level attribute, use s->get_scope_level directly 2024-10-08 19:56:57 -07:00
Nikolaj Bjorner
8a95dd4d65 A slice solver option for interactive use case
A slice solver prunes the set of active assertions based on symbol occurrences in a goal that is tracked as a @query.
Ground assertions that have symbols intersecting with the query are included in the solver state, and quantifiers that with patterns that intersect with the slice are included. The slice is the fixedpoint of including symbols from all included assertions.
Enable the functionality for command-line use by setting solver.slice=true
2024-10-08 09:24:52 -07:00
Nuno Lopes
3586b613f7 remove default destructors 2024-10-02 22:20:12 +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
Nikolaj Bjorner
48712b4f60 Add initial value setting for variables in Z3 API, solver, and optimize modules 2024-09-18 16:13:15 +03:00
Nuno Lopes
8061765574 remove default destructors & some default constructors
Another ~700 KB reduction in binary size
2024-09-04 22:30:23 +01:00
Nikolaj Bjorner
3381fd2b52 spell check from https://github.com/microsoft/z3guide/pull/165
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
2024-01-12 09:57:46 -08:00
Nikolaj Bjorner
dff419a7cb pin expressions to fix unsound behavior 2023-12-18 16:57:52 -08:00
Bruce Mitchener
e90a844508
Use override more. (#7059) 2023-12-15 08:44:57 +00:00