FA-72696 / Check-digit algorithms / Open access
UK VAT offset scheme compares against 55 · case 01
Numbers issued under the offset scheme are reported invalid.
ROOT CAUSE
The offset test is written (sum + c) % 97 == 55, which is not the same congruence as adding 55.
THE FAILURE
The offset test is written (sum + c) % 97 == 55, which is not the same congruence as adding 55.
Unsuccessful approach: Subtracting 55 instead of adding it tests a different residue class.
Case contract
UK VAT registration number check. Spaces are removed, the text is upper-cased and an optional GB prefix removed; the rest must be 9 ASCII digits (else "malformed"). Weights 8..2 apply to the first seven digits; the last two digits form a number c. Return "mod97" if (sum + c) is divisible by 97, "mod9755" if (sum + c + 55) is, else "invalid".
Why this case matters
Invoice processing screens supplier VAT numbers before reclaiming input tax.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(s):
t = s.replace(' ', '').upper()
if t.startswith('GB'):
t = t[2:]
if len(t) != 9 or not t.isascii() or not t.isdigit():
return 'malformed'
total = sum(int(ch) * w for ch, w in zip(t[:7], range(8, 1, -1)))
c = int(t[7:])
if (total + c) % 97 == 0:
return 'mod97'
if (total + c) % 97 == 55:
return 'mod9755'
return 'invalid'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["GB 261 7623 04"]', ['GB 261 7623 04'], 'mod9755'], ['regression ["GB260407726"]', ['GB260407726'], 'mod9755'], ['control ["GB041839277"]', ['GB041839277'], 'mod97'], ['control ["041839278"]', ['041839278'], 'invalid'], ['control ["261762305"]', ['261762305'], 'invalid'], ['control ["729236520"]', ['729236520'], 'mod97'], ['control ["729236521"]', ['729236521'], 'invalid'], ['control ["260407727"]', ['260407727'], 'invalid']], [['regression ["GB 225 8573 89"]', ['GB 225 8573 89'], 'mod9755'], ['regression ["GB784073455"]', ['GB784073455'], 'mod9755'], ['control ["260407727"]', ['260407727'], 'invalid'], ['control ["GB 029 3313 90"]', ['GB 029 3313 90'], 'mod97'], ['control ["029331391"]', ['029331391'], 'invalid'], ['control ["581077576"]', ['581077576'], 'invalid'], ['control ["GB658372602"]', ['GB658372602'], 'mod97'], ['control ["331553089"]', ['331553089'], 'mod97']], [['regression ["GB 307 8958 63"]', ['GB 307 8958 63'], 'mod9755'], ['regression ["GB 261 7623 04"]', ['GB 261 7623 04'], 'mod9755'], ['control ["331553089"]', ['331553089'], 'mod97'], ['control ["GB 397 1093 27"]', ['GB 397 1093 27'], 'mod97'], ['control ["GB801525174"]', ['GB801525174'], 'mod97'], ['control ["GB980780684"]', ['GB980780684'], 'mod97'], ['control ["980 7806 84"]', ['980 7806 84'], 'mod97'], ['control ["GB98078068"]', ['GB98078068'], 'malformed']], [['regression ["581077575"]', ['581077575'], 'mod9755'], ['regression ["GB 225 8573 89"]', ['GB 225 8573 89'], 'mod9755'], ['control ["GB98078068"]', ['GB98078068'], 'malformed'], ['control ["GB98078068X"]', ['GB98078068X'], 'malformed'], ['control ["gb980780684"]', ['gb980780684'], 'mod97'], ['control ["123456789"]', ['123456789'], 'invalid'], ['control ["GB041839277"]', ['GB041839277'], 'mod97'], ['control ["041839278"]', ['041839278'], 'invalid']], [['regression ["155142529"]', ['155142529'], 'mod9755'], ['regression ["GB 307 8958 63"]', ['GB 307 8958 63'], 'mod9755'], ['control ["041839278"]', ['041839278'], 'invalid'], ['control ["261762305"]', ['261762305'], 'invalid'], ['control ["729236520"]', ['729236520'], 'mod97'], ['control ["729236521"]', ['729236521'], 'invalid'], ['control ["260407727"]', ['260407727'], 'invalid'], ['control ["GB 029 3313 90"]', ['GB 029 3313 90'], 'mod97']]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression ["GB 261 7623 04"] | invalid | mod9755 | Failed |
| regression ["GB260407726"] | invalid | mod9755 | Failed |
| control ["GB041839277"] | mod97 | mod97 | Passed |
| control ["041839278"] | invalid | invalid | Passed |
| control ["261762305"] | invalid | invalid | Passed |
| control ["729236520"] | mod97 | mod97 | Passed |
| control ["729236521"] | invalid | invalid | Passed |
| control ["260407727"] | invalid | invalid | Passed |
SHA-256 / 29dc6d4436c4496d13262086305714cf72ed30bf42792a75e0dd226970037866
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(s):
t = s.replace(' ', '').upper()
if t.startswith('GB'):
t = t[2:]
if len(t) != 9 or not t.isascii() or not t.isdigit():
return 'malformed'
total = sum(int(ch) * w for ch, w in zip(t[:7], range(8, 1, -1)))
c = int(t[7:])
if (total + c) % 97 == 0:
return 'mod97'
if (total + c - 55) % 97 == 0:
return 'mod9755'
return 'invalid'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["GB 261 7623 04"]', ['GB 261 7623 04'], 'mod9755'], ['regression ["GB260407726"]', ['GB260407726'], 'mod9755'], ['control ["GB041839277"]', ['GB041839277'], 'mod97'], ['control ["041839278"]', ['041839278'], 'invalid'], ['control ["261762305"]', ['261762305'], 'invalid'], ['control ["729236520"]', ['729236520'], 'mod97'], ['control ["729236521"]', ['729236521'], 'invalid'], ['control ["260407727"]', ['260407727'], 'invalid']], [['regression ["GB 225 8573 89"]', ['GB 225 8573 89'], 'mod9755'], ['regression ["GB784073455"]', ['GB784073455'], 'mod9755'], ['control ["260407727"]', ['260407727'], 'invalid'], ['control ["GB 029 3313 90"]', ['GB 029 3313 90'], 'mod97'], ['control ["029331391"]', ['029331391'], 'invalid'], ['control ["581077576"]', ['581077576'], 'invalid'], ['control ["GB658372602"]', ['GB658372602'], 'mod97'], ['control ["331553089"]', ['331553089'], 'mod97']], [['regression ["GB 307 8958 63"]', ['GB 307 8958 63'], 'mod9755'], ['regression ["GB 261 7623 04"]', ['GB 261 7623 04'], 'mod9755'], ['control ["331553089"]', ['331553089'], 'mod97'], ['control ["GB 397 1093 27"]', ['GB 397 1093 27'], 'mod97'], ['control ["GB801525174"]', ['GB801525174'], 'mod97'], ['control ["GB980780684"]', ['GB980780684'], 'mod97'], ['control ["980 7806 84"]', ['980 7806 84'], 'mod97'], ['control ["GB98078068"]', ['GB98078068'], 'malformed']], [['regression ["581077575"]', ['581077575'], 'mod9755'], ['regression ["GB 225 8573 89"]', ['GB 225 8573 89'], 'mod9755'], ['control ["GB98078068"]', ['GB98078068'], 'malformed'], ['control ["GB98078068X"]', ['GB98078068X'], 'malformed'], ['control ["gb980780684"]', ['gb980780684'], 'mod97'], ['control ["123456789"]', ['123456789'], 'invalid'], ['control ["GB041839277"]', ['GB041839277'], 'mod97'], ['control ["041839278"]', ['041839278'], 'invalid']], [['regression ["155142529"]', ['155142529'], 'mod9755'], ['regression ["GB 307 8958 63"]', ['GB 307 8958 63'], 'mod9755'], ['control ["041839278"]', ['041839278'], 'invalid'], ['control ["261762305"]', ['261762305'], 'invalid'], ['control ["729236520"]', ['729236520'], 'mod97'], ['control ["729236521"]', ['729236521'], 'invalid'], ['control ["260407727"]', ['260407727'], 'invalid'], ['control ["GB 029 3313 90"]', ['GB 029 3313 90'], 'mod97']]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression ["GB 261 7623 04"] | invalid | mod9755 | Failed |
| regression ["GB260407726"] | invalid | mod9755 | Failed |
| control ["GB041839277"] | mod97 | mod97 | Passed |
| control ["041839278"] | invalid | invalid | Passed |
| control ["261762305"] | invalid | invalid | Passed |
| control ["729236520"] | mod97 | mod97 | Passed |
| control ["729236521"] | invalid | invalid | Passed |
| control ["260407727"] | invalid | invalid | Passed |
SHA-256 / 6c270485af417bcad64a6971943bd60f0972a1e94d775f69694264dce0aefe8c
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗Verification & scope
A deterministic, bounded teaching model of the named scheme under the stated contract; not a certified validator. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:48:40.847082+00:00.
Case digest / 61deaeea5f685f2b443c5dd6128caf9b423622b50f6a5d8b81ae89c6b9f2e318