Add Lean-backed logical evaluation and harden NICE scraping - #16
Draft
buley wants to merge 2 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this is worth caring about
AMFV will only be as trustworthy as the boundaries that feed and evaluate it. The NICE scraper had several ways to produce output that looked reasonable while changing what evidence entered the system:
Those are not cosmetic scraper defects. They are provenance defects: downstream evaluation can be internally consistent and still be evaluating the wrong corpus.
Why Lean, and why now
This PR does not add Lean because medical software sounds mathematical. It adds Lean because the risky rules here are small, finite logical gates with expensive failure modes.
Lean gives us a place to state those gates precisely, try adversarial cases against them, and require future changes to preserve them. Adding that layer now is comparatively cheap: the interfaces are still taking shape, the models are dependency-free, and the proof surface can remain smaller than the Python it constrains. Waiting until these assumptions are spread across a mature ingestion and evaluation pipeline would make the same work both harder and less useful.
The practical payoff is immediate rather than aspirational: formalizing the intended rules exposed concrete URL-scope and accounting bugs in the existing scraper, and this PR fixes them.
Lean is a development and CI dependency only. It is not added to the production runtime, and the formal project has no Mathlib or other external Lean dependencies.
What changes
lakeproject underformal/;lean-spectags;How the bridge stays maintainable
The source tags are deliberately reviewable rather than magical. A repository checker verifies that every tag names a real theorem, that the theorem has an empty axiom footprint, that a paired Python test exists, and that the formal project has not acquired undeclared dependencies. Reviewers can move from a Python boundary to the corresponding statement without needing to infer which proof was intended.
The shared fixtures provide the other half of the bridge: Lean and Python must emit the same stable accept/reject result and violation code for the cases we use as regression tests.
Proof boundary
These proofs establish properties of the finite models in
formal/. They do not prove arbitrary Python bytecode correct, parse arbitrary HTML, establish the medical truth of evidence, or prove a source corpus complete. The Python tests and conformance checks are what connect the model to the implementation.That boundary is intentional. The goal is a useful logical evaluation layer, not a claim that formal methods have certified the whole application.
Review map
Verification
lake build --wfail