Impact
POST /verify/math (and batch math items) return VERIFIED, is_valid: true and admission ADMIT for false identities. Two separate causes: the parser folds superscript and subscript digits into the digits or names beside them, and the identity check accepts a zero difference that only exists because SymPy rounded a Float.
expression |
main @ d4ca8dc (route and batch) |
Correct |
|---|---|---|
2² = 22 |
VERIFIED, is_valid: true, ADMIT |
false: 2² = 4 |
(x+1)² = 2x + 2 |
VERIFIED, is_valid: true, ADMIT |
false |
2₃ = 23 |
VERIFIED, is_valid: true, ADMIT |
not the claim written |
1 + 1.0e-17 = 1 |
VERIFIED, is_valid: true, ADMIT |
false |
1.0e20 + 1 = 1.0e20 |
VERIFIED, is_valid: true, ADMIT |
false |
Float(1000, 1) + 1 = 1000 |
VERIFIED, is_valid: true, ADMIT |
false |
2² = 4 |
VERIFIED, is_valid: false (proven false) |
true claim |
3² + 4² = 5² |
VERIFIED, is_valid: false (proven false) |
true claim |
2 + 2 = 5 (control) |
VERIFIED, is_valid: false |
correct |
Models write ² often, so the first class is easy to hit by accident as well as on purpose.
More forms of the same causes, each VERIFIED, is_valid: true, ADMIT on main @ ec50c2ac: NFKC also reads letters in other forms as ASCII letters, so Ⅰ = I and ℑ(I) = -1 read a Roman numeral and a black-letter I as the imaginary unit I; implicit multiplication reads 1 000 as 1*000 and 2 2 as 2*2 (1 000 = 0, 2 2 = 4); and evaluation can hide the Float (1 + 1.0e-17 - 1 = 0, Integer(Float(1000, 1) + 1) = 1000).
Affected
qwed (PyPI) through 10.0.0. Reproduced on main @ d4ca8dc.
Reachable from:
POST /verify/mathina = bform, and batch math items;safe_parse_expr, and every engine that parses with it;VerificationEngine.verify_math, which serves/verify/natural_languageand the consensus SymPy engine:verify_math("1 + 1.0e-17", 1, tolerance=0),verify_math("1.0e20 + 1", 1e20)andverify_math("2²", 22)returnVERIFIEDwithis_correct: true.
Reproduction
from qwed_new.core.math_worker import verify_math_request, verify_batch_math
from qwed_new.core.diagnostics import admission_decision
for ex in ["2² = 22", "(x+1)² = 2x + 2", "2₃ = 23", "1 + 1.0e-17 = 1",
"1.0e20 + 1 = 1.0e20", "Float(1000, 1) + 1 = 1000", "2² = 4", "2 + 2 = 5"]:
for dr in (verify_math_request(ex, {}), verify_batch_math(ex)):
print(ascii(ex), dr.status.value, dr.developer_fields.get("is_valid"), admission_decision(dr).value)
Details
- Digit folding.
safe_parse_exprappliesunicodedata.normalize("NFKC", ...)before its charset check (src/qwed_new/core/safe_parser.py:1002; the same atsrc/qwed_new/core/verifier.py:458). NFKC maps²to2and₃to3, so2²becomes22and(x+1)²becomes(x+1)2, which implicit multiplication reads as(x+1)*2. - Float rounding as proof. The identity check returns
VERIFIEDwhendifference == 0(src/qwed_new/core/verifier.py:715) before it checksdifference.has(Float)(:717). SymPy has already rounded1 + 1.0e-17to1.0and1.0e20 + 1to1.0e20while parsing, so the difference is an exact zero.Floatis in the parser's namespace (src/qwed_new/core/safe_parser.py:897), so the input can also choose a low precision.
Related, not part of this report: a single letter before a bracket is a product (f(0) is f*0), as documented in the 9.0.0 fix for unknown function names. With it, f(a+b) = f(a) + f(b) and f(0) = 0 are ADMIT. Whether that reading should stay is a separate decision.
Patches
Fixed in 11.0.0. Upgrade with pip install -U "qwed>=11.0.0". Characters NFKC reads as other text (superscripts, subscripts, Roman numerals, squared units, letters in another width or font), two numbers with only space between them and numbers the parser splits in two are refused. When a side holds a Float, a zero difference stands only if the claim holds with its decimals read exactly; otherwise the claim is disproven or UNVERIFIABLE (math.inexact_decimal). Values, derivatives, indefinite integrals and limits are re-checked the same way, in VerificationEngine too. With no tolerance, verify_math still accepts a claim within its default bound, min(1e-6, max(1e-9 × |value|, 1e-12)) (since 9.0.0, GHSA-8hp7-jqjc-hrhf), so verify_math("1 + 1.0e-17", 1) still returns VERIFIED, with match {"kind": "default_bound"} rather than exact. Pass tolerance=0 to compare exactly.
Advisory page: https://qwedai.tech/security/advisories/ghsa-q7m5-rmvq-v848
