Skip to content

fix(proofs): check Idris proofs with --total; give parser determinism content - #1243

Open
hyperpolymath wants to merge 2 commits into
mainfrom
claude/eager-wright-zwwbe2-idris-total
Open

hyperpolymath wants to merge 2 commits into
mainfrom
claude/eager-wright-zwwbe2-idris-total

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

Two holes in how hypatia checks its Idris proofs. Both are in the claims the proof ledger makes, not in the parser itself.

1. The per-file check did not pass --total. verify-proofs.yml checked each standalone file under verification/proofs/idris2/ with idris2 --check alone. Every Idris row in verification/proof-ledger.jsonl records the checker as idris2 --check (--total). Every file declares %default total today, but a file that dropped that line would still pass. The loop now runs idris2 --check --total. That matches both packages, whose .ipkg files already set opts = "--total".

2. parseFromDeterministic proved nothing about the parser. It stated parseFrom ts = parseFrom ts, which holds for any function. It now states that the FROM-clause grammar is deterministic:

  • Parses is the grammar as a relation, written apart from parseFrom, with one constructor per production.
  • parsesComplete: every parse the grammar allows is the one parseFrom returns.
  • parseFromDeterministic: two parses of the same tokens give the same source and leave the same tokens. It is derived from parsesComplete.

If two productions could read the same tokens, parsesComplete would not check. The theorem name, the ledger row and its status do not change.

Evidence

Idris 2 0.7.0, built from the v0.7.0 tag on Chez Scheme 9.5.8.

  • All 15 files in verification/proofs/idris2/ check with idris2 --check --total.
  • Planted partial function. A file without %default total holding loop n = loop n:
    • idris2 --check: exit 0.
    • idris2 --check --total: exit 1, Error: loop is not total, possibly not terminating due to recursive path Planted.loop.
  • The determinism theorem has teeth. Adding an overlapping production, PAmbiguous : Parses (KwFrom :: KwStore :: Ident v :: rest) (Hexad v) rest, makes parsesComplete fail: Mismatch between: Hexad v and Store v.
  • Ledger, before (main at 3e2b800) and after (this branch). Identical on both:
    • scripts/proof-ledger.sh check: "57 rows valid; 35 proven of 57; 0 proven-with-postulates, 13 tested-only, 2 argued, 7 open."
    • render --check: the block is current.
    • claims: 4 quoted censuses agree.
    • tests/proof-ledger-test.sh: 53 passed, 0 failed.
  • scripts/check-proof-status.sh, scripts/check-trusted-base.sh and scripts/check-readme-claims.sh pass.
  • actionlint 1.7.7 on verify-proofs.yml: clean.

Not run: the CI workflow itself. This PR's Verify Proofs run is the first run of the new flag.

Relation to the open stack

This PR is separate from #1189, #1190 and #1191, and is based on main. #1189 also edits ParserTotality.idr, but only after line 146. This PR changes lines 72 to 107, so the two merge without conflict.


Generated by Claude Code

… 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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CYR5bf5FBLS7cXQK72aVNM
@gitnotebooks

gitnotebooks Bot commented Nov 30, 2026

Copy link
Copy Markdown

Review these changes at https://app.gitnotebooks.com/hyperpolymath/hypatia/pull/1243

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 55 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 8ea3bf85-2c6f-45aa-87df-a7b255ba28c8
Commits

Reviewing files that changed from the base of the PR and between af7a57c and 393f128.

Files selected for processing: 1

  • verification/README.adoc

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Proof verification now checks totality for each Idris proof file.
    • Parser proofs cover the supported FROM-clause forms and confirm that parsing the same tokens yields a consistent source and remainder.

The parser proof defines supported FROM-clause parses, proves that each matches parseFrom, and establishes determinism for parses of the same tokens. The Idris verification workflow now runs each file check with totality checking enabled.

Changes: Parser totality verification

Layer / File(s) Summary
Define and prove parser determinism
verification/proofs/idris2/ParserTotality.idr
Adds the Parses relation for supported FROM-clause productions. Adds parsesComplete and proves that two parses of the same tokens have equal sources and remainders.
Enable totality checks
.github/workflows/verify-proofs.yml
Adds --total to the per-file Idris check command.

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

Possibly related PRs

Merge Risk: Minimal · previous review af7a5

This change makes the Idris proof check enforce totality and replaces a tautological parser determinism statement with a real proof. No concrete merge-blocking risk was found. The new CI flag will first run in this PR's own Verify Proofs run.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names both changes in the PR: the verify-proofs workflow now runs idris2 with --total, and parseFromDeterministic is given real content. It is 77 characters and states the main changes clear…
Description check Passed The description explains both changes in detail. It covers the --total flag in verify-proofs.yml and the new Parses relation, parsesComplete and parseFromDeterministic in ParserTotality.idr. It also g…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names both changes in the PR: the verify-proofs workflow now runs idris2 with --total, and parseFromDeterministic is given real content. It is 77 characters and states the main changes clearly. It uses a conventional-commit prefix, which is acceptable.

Full details: Description check

Explanation

The description explains both changes in detail. It covers the --total flag in verify-proofs.yml and the new Parses relation, parsesComplete and parseFromDeterministic in ParserTotality.idr. It also gives verification evidence and notes the relation to the open PR stack.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: aa37bc61-b498-44c6-b267-d1783e7cf3a8
Commits

Reviewing files that changed from the base of the PR and between 3e2b800 and af7a57c.

Files selected for processing: 2

  • .github/workflows/verify-proofs.yml
  • verification/proofs/idris2/ParserTotality.idr

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Recent review details

Context from checks skipped due to timeout: 1

  • GitHub Check: CodeRabbit
Additional comments: 2

verification/proofs/idris2/ParserTotality.idr: 1

72-81: LGTM!

Also applies to: 83-92, 98-102

.github/workflows/verify-proofs.yml: 1

194-194: LGTM!

@hyperpolymath
hyperpolymath marked this pull request as ready for review December 1, 2026 01:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-01T01:45:59.535469Z af7a57c Draft marked ready
🔒 Security Review ❌ Failed 2026-12-01T01:43:01.776867Z
We couldn’t complete this review. Comment @codex security review to try again.
af7a57c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af7a57c143

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/verify-proofs.yml Resolved
coderabbitai[bot]
coderabbitai Bot previously approved these changes Dec 1, 2026
…does

Codex on #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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CYR5bf5FBLS7cXQK72aVNM
@sonarqubecloud

sonarqubecloud Bot commented Dec 1, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants