How does Z3 decide a claim?
The Logic engine writes the premise and the claim in QWED's logic DSL and hands them to Z3, a solver from Microsoft Research. It does not ask Z3 whether the claim is true. It asks for a value that meets the premise and breaks the claim. For the second line above, that question is:
(AND (GT x 5) (NOT (GT x 10)))Z3 answers for all integers at once; it does not try them one by one. When both of its checks finish, there are three outcomes:
- Z3 finds such a value. The claim is
INVALID, and the value is the counterexample. The claim is proven false. - There is none, and the premise can hold. The claim is
VALID: it follows for every value the premise allows. - There is none, because the premise cannot hold. The result is
VACUOUS. Anything follows from a contradiction, so nothing is proven.
Z3 checks for a counterexample first. A counterexample meets the premise, so if one exists, the premise can hold, and only a claim with none needs the premise checked. If a check does not finish, because Z3 cannot decide or a step fails, there is no proof either way, and the result comes back BLOCKED · DENY.
What comes back?
A status, and a separate decision on whether to act. VALID and INVALID both become VERIFIED: the engine decided the claim. INVALID is marked false, with the counterexample as its evidence, and is denied. VACUOUS becomes UNVERIFIABLE · DENY. VERIFIED means decided, not true, just as 2+2=5 comes back VERIFIED · DENY from the Math engine.
A logic result is not admitted yet, even when the claim follows, so today a VALID one is VERIFIED · DENY as well. qwed test 12.0.0 prints ADMIT beside x>5 => x>3, but that word is a label in the command; the admission rules in the code refuse the result. Its verdict covers the constraints as written, and nothing yet checks that they mean what a question asked. On /verify/logic a model writes them from the question, so QWED proves the model's translation, not the question (#585). Every logic result records that the question's meaning was not verified, and the admission rules refuse such a result. How a result reads
How does SymPy check a figure?
The Math engine parses the expression with SymPy and works it out again. Whole numbers and fractions stay exact: 997*998*999 comes out as 994010994, as the third line of qwed test shows. An identity such as (x+1)**2 = x**2 + 2*x + 1 holds when the difference of its two sides simplifies to zero, which covers every x at once. How to check AI calculations
The figure a model claims is then compared with that value. Unless you pass a tolerance, a claim must match to 9 significant digits, and is never accepted more than 0.000001 away. Below 0.001 the bound is fixed instead: within 0.000000000001 of the value. A claim with six or more significant digits may also be the value rounded at its last digit, so 0.333333 matches 1/3. The result records which it was, in its match field: exact, default_bound, rounded_claim, or caller_tolerance when you passed one.
How does SQLGlot check a query?
The SQL engine parses the query with SQLGlot, in the query's own dialect, into a syntax tree. The checks run on that tree, not on the text. A condition that is always true, such as OR 1=1, folds to a constant. A second statement after a semicolon shows up as a second tree. Both come back proven unsafe and denied: VERIFIED · DENY.
MySQL runs the SQL inside its executable comments (/*! ... */), so those are expanded before parsing and their contents are checked too. Where SQLGlot and the database could split the same text into tokens differently, no analysis of the tree describes what would run. MySQL reads --1 OR 1=1 as code, for example, and SQLGlot reads it as a comment. Such a query comes back BLOCKED · DENY. AI-generated SQL
What is a proof_ref?
A SHA-256 hash of the evidence behind a VERIFIED result, written sha256: and 64 hex digits. For a logic result, the evidence is the statement decided and the counterexample, if there is one. It is written as JSON with its keys sorted before it is hashed, so the same evidence always gives the same hash, and changed evidence gives a different one.
QWED cannot build a VERIFIED result without a proof_ref. A result with no proof is UNVERIFIABLE and carries none. What each decision record holds
What is not proven?
- The meaning of a question. When a model turns text into constraints or an expression, the engine decides what the model wrote. Nothing yet checks that it means what was asked, so such a result is not admitted.
- What a search did not find. Symbolic looks for counterexamples in code and returns
UNVERIFIABLEorBLOCKED, neverVERIFIED. Not finding a counterexample is not a proof. - Signals. The advisory engines (Fact, Graph, Image, Reasoning, Consensus) add signals for review. Graph and Image can return
VERIFIEDonly on a deterministic sub-path, with aproof_ref, and Consensus never does. - The engines themselves. A proof is only as sound as SymPy, Z3, SQLGlot and QWED's own rules. Past soundness bugs are published as advisories, and each one in which an engine returned
VERIFIEDfor a false claim is reproduced in an eval that runs at every release. Evidence - Claims outside the engines. They come back
UNVERIFIABLE.
Everything QWED does not verify
Sources and further reading
- Z3 guide: introduction. Microsoft Research’s introduction to Z3, the SMT solver behind the Logic engine, and the logic it decides.
- SymPy tutorial: gotchas, equals signs. Why two expressions are compared by simplifying their difference to zero.
- SQLGlot documentation. The SQL parser the SQL engine uses: it reads a query, in its dialect, into a syntax tree.
- qwed-verification 12.0.0: cli_logic_proof.py. The two logic proofs qwed test runs, and the counterexamples it accepts.
- qwed-verification 12.0.0: dsl_logic_verifier.py. prove_from_dsl: the refutation Z3 is asked first, and when a claim is VALID, INVALID or VACUOUS.
- qwed-verification 12.0.0 README. What qwed test prints, how a result reads, the engines and what QWED does not do.
Written and reviewed by the QWED maintainers under the project's governance model. Found an error? Contact us.
