From af7a57c14376a82b2d782fb8661d818aa43f7a48 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 23:08:17 +0000 Subject: [PATCH 1/2] fix(proofs): check Idris proofs with --total; give parser determinism content verify-proofs.yml checked each standalone .idr file with `idris2 --check` alone, while every Idris row of the ledger records `--total`. A file that dropped `%default total` would still have passed. The loop now passes --total, matching both ipkgs (opts = "--total"). parseFromDeterministic stated `parseFrom ts = parseFrom ts`, which holds for any function and says nothing about the parser. It now states that the FROM-clause grammar is deterministic: two parses of the same tokens give the same source and remainder. The grammar is a relation, Parses, written apart from parseFrom with one constructor per production. parsesComplete shows that every parse it admits is the one parseFrom returns, and determinism follows. If two productions could read the same tokens, this would not check. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CYR5bf5FBLS7cXQK72aVNM --- .github/workflows/verify-proofs.yml | 2 +- verification/proofs/idris2/ParserTotality.idr | 33 +++++++++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/.github/workflows/verify-proofs.yml b/.github/workflows/verify-proofs.yml index 029cf2c4a..2a108cb98 100644 --- a/.github/workflows/verify-proofs.yml +++ b/.github/workflows/verify-proofs.yml @@ -191,7 +191,7 @@ jobs: failed=0 for f in *.idr; do echo "── $f ─────────────────────────────────────────────" - if idris2 --check "$f"; then + if idris2 --check --total "$f"; then echo "✓ $f" bash "$GITHUB_WORKSPACE/scripts/proof-ledger.sh" receipt idris2 pass "verification/proofs/idris2/$f" else diff --git a/verification/proofs/idris2/ParserTotality.idr b/verification/proofs/idris2/ParserTotality.idr index ae5e59eeb..f4522bbe4 100644 --- a/verification/proofs/idris2/ParserTotality.idr +++ b/verification/proofs/idris2/ParserTotality.idr @@ -69,10 +69,37 @@ parseFrom _ = Err ExpectedFromClaus -- Section 3: totality as a structural property ------------------------------------------------------------------------ -||| Property 1: parseFrom is a function: equal inputs give equal results. +||| The FROM-clause grammar as a relation, written apart from parseFrom: one +||| constructor per production. `Parses ts s rest` says the grammar reads +||| source s from the front of ts and leaves rest. +public export +data Parses : List Token -> Source -> List Token -> Type where + PStore : Parses (KwFrom :: KwStore :: Ident v :: rest) (Store v) rest + PStoreQuoted : Parses (KwFrom :: KwStore :: Quoted v :: rest) (Store v) rest + PFed : Parses (KwFrom :: KwFederation :: Ident v :: rest) (Federation v) rest + PFedQuoted : Parses (KwFrom :: KwFederation :: Quoted v :: rest) (Federation v) rest + PHexad : Parses (KwFrom :: KwHexad :: Ident v :: rest) (Hexad v) rest + +||| Every parse the grammar allows is the one parseFrom returns. If two +||| productions could read the same tokens differently, parseFrom could +||| return only one of them, and this would not check. +export +parsesComplete : Parses ts s rest -> parseFrom ts = Ok s rest +parsesComplete PStore = Refl +parsesComplete PStoreQuoted = Refl +parsesComplete PFed = Refl +parsesComplete PFedQuoted = Refl +parsesComplete PHexad = Refl + +||| Property 1: the grammar is deterministic. Two parses of the same tokens +||| give the same source and leave the same tokens. Derived from +||| parsesComplete: both parses are the one parseFrom returns. export -parseFromDeterministic : (ts : List Token) -> parseFrom ts = parseFrom ts -parseFromDeterministic _ = Refl +parseFromDeterministic : Parses ts s rest -> Parses ts s' rest' -> (s = s', rest = rest') +parseFromDeterministic p q = okInjective (trans (sym (parsesComplete p)) (parsesComplete q)) + where + okInjective : Ok a r = Ok a' r' -> (a = a', r = r') + okInjective Refl = (Refl, Refl) ||| Property 2: empty input gives the empty-input error. export From 393f128645d679ee8908ac8d8ed3376cf1358166 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 01:47:29 +0000 Subject: [PATCH 2/2] docs(verification): the documented local check passes --total, as CI does Codex on hyperpolymath/hypatia#1243: verification/README.adoc says its loop type-checks exactly as verify-proofs.yml does, but still ran idris2 --check without --total, so a file that lost %default total could pass locally and fail in CI. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CYR5bf5FBLS7cXQK72aVNM --- verification/README.adoc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/verification/README.adoc b/verification/README.adoc index fcaec9601..9a12fc122 100644 --- a/verification/README.adoc +++ b/verification/README.adoc @@ -18,12 +18,14 @@ Idris2, Lean 4, TLA+ and Agda proof sources for Hypatia's type-level guarantees. == Building Proofs The `proofs/` tree is not an Idris2 package; each file is type-checked -independently, exactly as `.github/workflows/verify-proofs.yml` does it: +independently, exactly as `.github/workflows/verify-proofs.yml` does it. +`--total` makes Idris refuse a partial definition even in a file that has +lost its `%default total`: [source,bash] ---- cd verification/proofs/idris2 -for f in *.idr; do idris2 --check "$f"; done +for f in *.idr; do idris2 --check --total "$f"; done ---- The Agda artefact is checked under the estate strict profile (capital