mirror of
https://github.com/saymrwulf/ltl-accumulator-verified.git
synced 2026-09-04 20:03:44 +00:00
STATEMENT BINDING (Phase 3d). The coverage gate pins every constant's name,
kind and axiom cone, both directions, and none of selftest_audit.sh's nine
attacks defeat it. It is nevertheless blind to what a declaration SAYS — and
that is demonstrated here rather than argued:
Wrapping one branch of `LTLAcc.pinAccept`'s body in `id (…)` is
definitionally equal. Every downstream proof still compiles. The name, the
kind, the type and the axiom cone are unchanged. The inventory gate reports
"222 constants, environment == allowlist" — GREEN.
That edit is harmless by construction; the point is that nothing stood between
it and a genuinely vacuous redefinition of a specification. Proofs/Inventory.lean
now also emits, for every inventoried constant, its fully-elaborated TYPE, and
for every definition its fully-elaborated BODY — 266 lines over 222 constants.
Proof terms are deliberately absent: by proof irrelevance a theorem's content
is its statement. check.sh Phase 3d binds the SHA-256 and the block is
committed as AUDIT-MANIFEST.txt so a mismatch is DIFFED, not merely reported.
The existing gate is untouched, per the standing rule that the port flows FROM
this repo, not to it: INV lines are byte-identical, inventory_gate.sh is
unchanged, and all nine of its attacks still fail as before.
selftest_statements.sh replays the defeq edit as case 1, asserting BOTH that
the coverage gate passes it and that Phase 3d catches it — so if the coverage
gate ever grows to see this, the test says so instead of quietly re-labelling.
Cases 2-4 cover a hand-edited committed block, a truncated block, and a
constant inventoried without a statement.
FIDELITY PIN (unrelated, found while running the button). Phase 4 had been
failing since 2026-07-23: LIED_PIN_DIV expected 3,867 divergences between the
Lean model and the deployed consistency verifier, and observed 0. Cause is
pacta ddbb5a4, which restored the RFC 9162 2.1.4.2 Step-7 terminal `sn == 0`
condition; that one conjunct removes every divergence in the pinned
73,573-case family. KNOWN-GAPS gap 14 already recorded the closure on the day
it landed — only this constant was stale, so the button had been red for five
days with nobody running it. The pin now reads 0 with the history in a comment.
Nothing about the paper, public log entry 13, or the attested commit 172a1d0
changes; the historical divergence stays reproducible at the tagged pre-fix
commit.
KNOWN-GAPS gap 16 records what the binding does not buy: identity, not
meaning; an author who edits and re-pins in one commit is caught by review and
not by the script; and proof terms are unbound by design.
Button green end to end: ATTESTATION GREEN (Lean + fidelity).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
196 lines
8.6 KiB
Python
196 lines
8.6 KiB
Python
#!/usr/bin/env python3
|
|
"""S7 definition-fidelity harness for ltl-accumulator-verified.
|
|
|
|
Differential-tests the LEAN definitions (transliterated in lean_defs.py:
|
|
MTH / Path / Root / ConsRec, post-refactor decidable-if base) against the
|
|
DEPLOYED pacta verifiers, over the EXACT case generation of the paper's
|
|
tests/test_paper_verifiers.py — this run establishes agreement between the mechanized objects and the
|
|
deployed RFC 9162 code EXHAUSTIVELY OVER all size/index (and old/new
|
|
size) pairs through 256 FOR the two fixed generated datasets and the
|
|
listed mutation classes (honest, wrong-leaf, wrong-index, wrong-root,
|
|
truncated/padded proof, and out-of-range m≥n / n0>n1 / n0=0). It is not
|
|
a proof of extensional equality over all inputs — and extensional
|
|
equality is in fact FALSE for consistency: the lied-size family below
|
|
pins the known one-sided divergence (deployed accepts claimed sizes an
|
|
honest proof was never generated for; the mechanized ConsRec rejects —
|
|
KNOWN-GAPS gap 14). The Lean-to-Python bridge remains trusted
|
|
quoted-source inspection (see KNOWN-GAPS).
|
|
|
|
Requires the pacta repo on PYTHONPATH (its src/). Bound NMAX matches the
|
|
paper.
|
|
"""
|
|
import hashlib
|
|
import os
|
|
import sys
|
|
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
PACTA_SRC = os.environ.get("PACTA_SRC",
|
|
os.path.join(HERE, "..", "..", "..", "proof-aware-crypto-tooling-agent", "src"))
|
|
sys.path.insert(0, PACTA_SRC)
|
|
sys.path.insert(0, HERE)
|
|
|
|
# deployed (pacta) side
|
|
from pacta.transparency import ( # noqa: E402
|
|
consistency_proof, inclusion_proof, merkle_root,
|
|
verify_consistency, verify_inclusion,
|
|
)
|
|
# lean (mechanized) side
|
|
import lean_defs as L # noqa: E402
|
|
|
|
NMAX = int(os.environ.get("FIDELITY_NMAX", "256"))
|
|
# lied-size family pins (gap 14; valid for the default FIDELITY_LIED_NMAX=60):
|
|
# 73,573 boundary cases.
|
|
#
|
|
# The divergence count was 3,867 (3,405 lied-old-size + 462 lied-new-size,
|
|
# smallest witness n=3, m=2 claimed 1) until pacta `ddbb5a4` (2026-07-23)
|
|
# restored the RFC 9162 2.1.4.2 Step-7 terminal condition `sn == 0` to
|
|
# verify_consistency. That one conjunct removes EVERY divergence in this
|
|
# family, so the pin is now 0: the deployed verifier and the mechanized
|
|
# ConsRec model agree on all 73,573 boundary cases.
|
|
#
|
|
# The pin was left at 3,867 when the fix landed, which made this assertion —
|
|
# and therefore check.sh Phase 4 — fail from 2026-07-23 until it was noticed
|
|
# on 2026-07-28. KNOWN-GAPS.md gap 14 had already recorded the closure; only
|
|
# this constant was stale. Nothing about the paper, public log entry 13, or
|
|
# the attested commit 172a1d0 changes: the historical divergence remains
|
|
# truthfully recorded and reproducible at `vulnerable/sn0-consistency-fd2f6ba`.
|
|
LIED_PIN_TOTAL = 73_573
|
|
LIED_PIN_DIV = 0
|
|
|
|
|
|
def _h(b):
|
|
return hashlib.sha256(b).digest()
|
|
|
|
|
|
def inclusion():
|
|
total = 0
|
|
root_checks = 0
|
|
path_checks = 0
|
|
for n in range(1, NMAX + 1):
|
|
data = [bytes([i % 251]) + bytes([(i * 5) % 256]) * (i % 3) for i in range(n)]
|
|
root = merkle_root(data)
|
|
# root fidelity: Lean MTH == deployed merkle_root
|
|
assert L.MTH(data) == root, ("MTH drift", n)
|
|
root_checks += 1
|
|
for m in range(n):
|
|
P = inclusion_proof(data, m)
|
|
# path fidelity: Lean Path == deployed inclusion_proof
|
|
assert L.Path(m, data) == P, ("Path drift", n, m)
|
|
path_checks += 1
|
|
cases = [
|
|
(data[m], m, n, P, root),
|
|
(data[m] + b"!", m, n, P, root),
|
|
(data[m], (m + 1) % n, n, P, root),
|
|
(data[m], m, n, P, _h(b"q")),
|
|
(data[m], n, n, P, root), # out-of-range m = n (review F1)
|
|
(data[m], n + 3, n, P, root), # out-of-range m > n (review F1)
|
|
]
|
|
if P:
|
|
cases.append((data[m], m, n, P[:-1], root))
|
|
for d2, m2, n2, P2, r2 in cases:
|
|
total += 1
|
|
dep = verify_inclusion(d2, m2, n2, P2, r2)
|
|
lean = L.accept_incl(d2, m2, n2, P2, r2)
|
|
assert dep == lean, ("INCL VERIFIER DRIFT", n, m, dep, lean)
|
|
return total, root_checks, path_checks
|
|
|
|
|
|
def consistency():
|
|
total = 0
|
|
for n in range(1, NMAX + 1):
|
|
data = [bytes([i % 251]) + bytes([(i * 7) % 256]) * (i % 4) for i in range(n)]
|
|
r1 = merkle_root(data)
|
|
assert L.MTH(data) == r1, ("MTH drift (cons)", n)
|
|
for m in range(1, n + 1):
|
|
P = consistency_proof(data, m)
|
|
r0 = merkle_root(data[:m])
|
|
cases = [
|
|
(m, n, r0, r1, P), # honest consistency
|
|
(m, n, _h(b"x"), r1, P),
|
|
(m, n, r0, _h(b"y"), P),
|
|
(m, n, r0, r1, P + [_h(b"z")]),
|
|
(n + 1, n, r1, r0, P), # n0 > n1 (review F1)
|
|
(0, n, r0, r1, P), # n0 = 0 escape (review F1)
|
|
]
|
|
if P:
|
|
cases.append((m, n, r0, r1, P[:-1]))
|
|
for mm, nn, a, bb, pp in cases:
|
|
total += 1
|
|
dep = verify_consistency(mm, nn, a, bb, pp)
|
|
lean = L.accept_cons(mm, nn, a, bb, pp)
|
|
assert dep == lean, ("CONS VERIFIER DRIFT", n, m, dep, lean)
|
|
return total
|
|
|
|
|
|
def lied_sizes():
|
|
"""Lied-size boundary family (round-3 review, Claude F1* / gap 14).
|
|
|
|
The deployed RFC 9162 iterative verify_consistency accepts honest
|
|
proofs under CLAIMED sizes the proof was never generated for (when
|
|
the claimed old size is a power of two it seeds the walk with the
|
|
old root and uses the sizes only as bit-navigation state); the
|
|
mechanized ConsRec binds the split geometry to the sizes and
|
|
rejects. Divergences in this family are therefore EXPECTED and
|
|
documented — what this pins is:
|
|
(a) the DIRECTION: every divergence must be deployed=True /
|
|
lean=False (the mechanized model is the stricter one; a
|
|
lean=True/deployed=False case would break soundness transfer
|
|
and fails the run immediately), and
|
|
(b) the exact divergence COUNT, so any drift in either verifier
|
|
shows up as a pin failure.
|
|
Inclusion showed zero divergences under identical abuse (round-3
|
|
addendum); the inclusion side is covered by the m>=n families above.
|
|
"""
|
|
lied_nmax = int(os.environ.get("FIDELITY_LIED_NMAX", "60"))
|
|
total = 0
|
|
div = 0
|
|
for n in range(2, lied_nmax):
|
|
data = [bytes([i % 251]) for i in range(n)]
|
|
r1 = merkle_root(data)
|
|
for m_true in range(1, n):
|
|
P = consistency_proof(data, m_true)
|
|
r0 = merkle_root(data[:m_true])
|
|
for m_lie in range(0, n + 1): # lied OLD size
|
|
if m_lie == m_true:
|
|
continue
|
|
total += 1
|
|
dep = verify_consistency(m_lie, n, r0, r1, P)
|
|
lean = L.accept_cons(m_lie, n, r0, r1, P)
|
|
if dep != lean:
|
|
div += 1
|
|
assert dep and not lean, (
|
|
"ONE-SIDEDNESS BROKEN: lean accepts, deployed rejects",
|
|
n, m_true, m_lie)
|
|
for n_lie in (n - 1, n + 1, n + 7): # lied NEW size
|
|
if n_lie < m_true or n_lie == n or n_lie < 1:
|
|
continue
|
|
total += 1
|
|
dep = verify_consistency(m_true, n_lie, r0, r1, P)
|
|
lean = L.accept_cons(m_true, n_lie, r0, r1, P)
|
|
if dep != lean:
|
|
div += 1
|
|
assert dep and not lean, (
|
|
"ONE-SIDEDNESS BROKEN: lean accepts, deployed rejects",
|
|
n, m_true, "n_lie", n_lie)
|
|
return total, div
|
|
|
|
|
|
def main():
|
|
print(f"S7 fidelity: Lean defs vs deployed pacta, NMAX={NMAX}")
|
|
ti, rc, pc = inclusion()
|
|
print(f" inclusion: {ti} verifier cases, {rc} MTH==merkle_root, {pc} Path==inclusion_proof — all agree")
|
|
tc = consistency()
|
|
print(f" consistency baseline family: {tc} verifier cases (incl. honest), MTH checks — all agree")
|
|
tl, dl = lied_sizes()
|
|
print(f" lied-sizes: {tl} boundary cases, {dl} EXPECTED divergences, all deployed-accepts-only (gap 14)")
|
|
# pinned counts (identical generation to the paper's harness)
|
|
assert ti == 230_271, ti # re-pinned after adding out-of-range families (F1)
|
|
assert tc == 230_016, tc
|
|
assert (tl, dl) == (LIED_PIN_TOTAL, LIED_PIN_DIV), (tl, dl)
|
|
print(f" PINNED: inclusion={ti} (230,271) consistency={tc} (230,016) lied-sizes={tl}/{dl}")
|
|
print("=== FIDELITY GREEN: agreement over the pinned case families "
|
|
"(not extensional equality; KNOWN-GAPS gap 14) ===")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|