Pull to refresh

A Dumb Introduction to Z3 (2025) (ar-ms.me)

by y1n0 27 comments 70 points
Read article View on HN

27 comments

[−] wren6991 27d ago
Z3 struggles with larger problems. CVC5 or Bitwuzla do a lot better once you get into anything complex.

If you're familiar with the Z3 Python API, you'll find the CVC5 one familiar.

Caveat: I mostly do logic design, maybe there are some software verification tasks where Z3 comes out ahead. I've never seen one though.

[−] neel_k 26d ago
I do software verification. In my experience, Z3 is consistently but noticeably better than CVC5 at the kinds of problems we generate, though the two tools are close enough that you definitely want to architect your verification tool to be able to use either one (or both at once, in case you hit a problem which is pathological in one but not the other).

One place where Z3 exposes a superior interface to CVC5 is when you want to do term simplification. CVC5 does not have any real analogue to Z3's simplification tactics (like ctx-solver-simplify), so if you want to take a term and simplify it with respect to a set of assumptions, Z3 is your only choice. I think CVC5 has all the machinery you need to implement that stuff inside of it, but as a user you can't access it.

The place where CVC5 really pulls ahead of Z3 is when you want to produce proofs (eg, to integrate SMT solving into a proof assistant like Lean, HOL, or Rocq). Both tools have support for generating proofs, but CVC5's are noticeably less buggy, to the point that Lean's SMT integration uses CVC5, even though Leo de Moura (Lean's designer) was also the original designer of Z3.

[−] humam_alhusaini 26d ago
I'm curious as to why Z3 is so much more popular than CVC5 if CVC5 is better for solving complex problems. Is it because Z3 is older?
[−] NooneAtAll3 26d ago
mostly because nobody ever mentioned CVC5 before
[−] algo_trader 26d ago
What would u recommend for freight/trucking optimiser? not real time.

(scaling to 100s-1000s of units)

[−] y1n0 26d ago
That’s interesting. I’m a logic designer too. How do you make use of it?
[−] Surac 26d ago
Problems solved nothing learned. Poking my problems into a black box and getting numbers let me only learn how to poke numbers into black boxes
[−] kenerwin88 26d ago
This is such weird timing, for the last few weeks I’ve been messing around with Z3 and other solvers for the first time and they’re so cool. In many ways more magical than LLMs to me in some ways. Great intro!
[−] asibahi 26d ago
Previously: https://news.ycombinator.com/item?id=45248558. Switched domains since then.
[−] jebarker 26d ago
I wonder how often interviewers object to the approach of solving their dynamic programming problem using a constraint solver?
[−] amelius 27d ago
If the tutorial uses Rust, why didn't they use a solver written in Rust? Z3 was written in C++.