Skip to content

Tests for sorts that are Prop up to level normalization - #102

Merged
nomeata merged 1 commit into
masterfrom
joachim/issue14613
Jul 31, 2026
Merged

nomeata merged 1 commit into
masterfrom
joachim/issue14613

Conversation

@nomeata

@nomeata nomeata commented Jul 31, 2026 •

Copy link
Copy Markdown
Collaborator

Adds a regression test distilled from the kernel bug fixed in
leanprover/lean4#14613.

The bug

type_checker::is_prop compared whnf(infer_type e) against Prop
syntactically. The level imax 1 0 is definitionally 0, so a type in
Sort (imax 1 0) really is a proposition, but the syntactic check answers
false. As a result infer_proj skips its Prop restriction and lets a
non-proof (data) field be projected out of a proof — and proof irrelevance
then equates two such proofs, so projecting a Bool field out of them yields
false = true, hence False, with no axiom dependencies.

The test

tests/proj-of-imax-prop.{lean,yaml} exports a closed, axiom-free proof
badFalse : False that a buggy kernel accepts. It uses two definitionally
equal spellings of the same type, each hitting the buggy check on the side it
needs:

  • Proof irrelevance is stated through ImaxAsProp : Prop := ImaxProp,
    whose type is the literal Sort 0, so even the buggy kernel recognizes it
    as a proposition and equates ImaxProp.mk false with ImaxProp.mk true.
  • The data projection imaxProjBool : ImaxProp → Bool is stated on
    ImaxProp, whose type is the literal Sort (imax 1 0), where the buggy
    syntactic check fails and wrongly permits the projection.

Congruence on the proof-irrelevance equation then equates false and true.

The declaration cannot be written in surface syntax (levels are normalized
eagerly), so the projection is added under debug.skipKernelTC; the file
therefore builds on both fixed and unfixed toolchains. A companion
ImaxPropDummy in the same mutual block is required for the Bool field to be
accepted, 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 of False —
    reported incorrect, as expected. Flips to correct once the fix ships.
  • nanoda: rejects it — correct.

🤖 Generated with Claude Code

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
nomeata force-pushed the joachim/issue14613 branch from c3a26d4 to 6666e7d Compare July 31, 2026 11:17
@nomeata nomeata changed the title Tutorial tests for sorts that are Prop up to level normalization Tests for sorts that are Prop up to level normalization Jul 31, 2026
@nomeata
nomeata merged commit 23887b6 into master Jul 31, 2026
4 checks passed
@nomeata
nomeata deleted the joachim/issue14613 branch July 31, 2026 11:55
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.

1 participant