Repository navigation
Tests for sorts that are Prop up to level normalization - #102
Merged
Merged
Conversation
Distilled from the kernel bug fixed in leanprover/lean4#14613. `ImaxProp : Sort (imax 1 0)` is a proposition, since `imax 1 0` normalizes to `0`. A kernel that tests whether a sort is `Prop` only syntactically mishandles it, and the test exports a closed, axiom-free proof of `False` that such a kernel accepts. The exploit uses two definitionally equal spellings of the type: proof irrelevance is stated through `ImaxAsProp : Prop := ImaxProp` (literal `Sort 0`, accepted by the buggy kernel too), while the data projection is stated on `ImaxProp` (literal `Sort (imax 1 0)`, where the buggy syntactic check fails and wrongly permits projecting the `Bool` field out of a proof). Congruence on the proof-irrelevance equation then equates `false` and `true`. Verified: the official kernel (v4.32.2, fix unreleased) accepts the proof; nanoda rejects it. Uses a mutual block, so a standalone regression test rather than a tutorial case. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01N8V39PLAKbpoG7ctgCFhbp
nomeata
force-pushed
the
joachim/issue14613
branch
from
July 31, 2026 11:17
c3a26d4 to
6666e7d
Compare
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.
Adds a regression test distilled from the kernel bug fixed in
leanprover/lean4#14613.
The bug
type_checker::is_propcomparedwhnf(infer_type e)againstPropsyntactically. The level
imax 1 0is definitionally0, so a type inSort (imax 1 0)really is a proposition, but the syntactic check answersfalse. As a resultinfer_projskips itsProprestriction and lets anon-proof (data) field be projected out of a proof — and proof irrelevance
then equates two such proofs, so projecting a
Boolfield out of them yieldsfalse = true, henceFalse, with no axiom dependencies.The test
tests/proj-of-imax-prop.{lean,yaml}exports a closed, axiom-free proofbadFalse : Falsethat a buggy kernel accepts. It uses two definitionallyequal spellings of the same type, each hitting the buggy check on the side it
needs:
ImaxAsProp : Prop := ImaxProp,whose type is the literal
Sort 0, so even the buggy kernel recognizes itas a proposition and equates
ImaxProp.mk falsewithImaxProp.mk true.imaxProjBool : ImaxProp → Boolis stated onImaxProp, whose type is the literalSort (imax 1 0), where the buggysyntactic check fails and wrongly permits the projection.
Congruence on the proof-irrelevance equation then equates
falseandtrue.The declaration cannot be written in surface syntax (levels are normalized
eagerly), so the projection is added under
debug.skipKernelTC; the filetherefore builds on both fixed and unfixed toolchains. A companion
ImaxPropDummyin the same mutual block is required for theBoolfield to beaccepted, since the kernel checks constructor field universes against the
resulting level of the block's first inductive.
Because it relies on a mutual inductive, this is a standalone regression test
rather than a tutorial case.
Verification
official(v4.32.2, fix unreleased): accepts the proof ofFalse—reported incorrect, as expected. Flips to correct once the fix ships.
nanoda: rejects it — correct.🤖 Generated with Claude Code