QWED

Type to search pages, engines and advisories.

    Looking for API details?Search the docs

    Guides

    How a claim gets proven

    A model says a rule follows, a total is right, a query is safe. This guide shows what a proof engine does with such a claim, using the checks qwed-verification 12.0.0 runs, and where proving stops.

    QWED project · Published · Updated

    The short answer

    A claim is proven when an engine decides it for every case its premise allows, not for a few samples. QWED's Logic engine asks Z3 whether any value meets the premise and breaks the claim: if one does, that value is the counterexample and the claim is false; if none does and the premise can hold, the claim follows. A premise that cannot hold proves nothing. SymPy works a figure out again, and SQLGlot reads a query's syntax tree. A decided claim comes back VERIFIED with a proof_ref, a hash of its evidence, whether it turned out true or false; whether to act on it is a separate decision.

    What does proven mean?

    That a claim holds for every value its premise allows, not only for the values someone tried. Trying x = 12 makes the first two claims below look true. Z3 asks a different question: is there any x that meets the premise and breaks the claim?

    • Meets the premise, and the claim holds
    • Meets the premise, and the claim fails: a counterexample
    • Does not meet the premise
    1. x>5 => x>3

      Is there an x above 5 that is not above 3?

      No. Every integer above 5 is above 3, so the claim follows.

      Proven to holdVERIFIED · DENYstatus=VALID
    2. x>5 => x>10

      Is there an x above 5 that is not above 10?

      Yes: 6, 7, 8, 9 and 10. Z3 returns one of them, here 6, as the counterexample.

      Proven falseVERIFIED · DENYstatus=INVALID, counterexample x=6
    3. x>5 AND x<3

      Is there an x above 5 and below 3?

      No x meets both. Constraints that contradict each other prove nothing.

      Could not be provenUNVERIFIABLE · DENYstatus=UNVERIFIABLE
    Each row is a line of qwed test in qwed-verification 12.0.0. Under each label: the status and admission the code returns, then the detail qwed test -v prints. No logic verdict is admitted yet, so all three are denied (What comes back?). x is an integer. Z3 decides for every integer, not only the fifteen drawn, and for the second line it may return any value from 6 to 10.

    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 UNVERIFIABLE or BLOCKED, never VERIFIED. 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 VERIFIED only on a deterministic sub-path, with a proof_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 VERIFIED for 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

    Written and reviewed by the QWED maintainers under the project's governance model. Found an error? Contact us.