Skip to content

Kernel: is_proof_type requires a sort (fixes proof of False) - #26

Merged
gimbalzero merged 2 commits into
mainfrom
fix-17-proj-prop
Nov 22, 2026
Merged

gimbalzero merged 2 commits into
mainfrom
fix-17-proj-prop

Conversation

@gimbalzero

@gimbalzero gimbalzero commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Closes #17

Certus accepted a proof of False with no axioms (Arena bugs/proj-of-subst-prop). is_proof_type returned false ("not a proposition") when the inferred type of t did not reduce to a sort. For Owner witness, whose sort gate witness is a stuck Eq.rec, infer_proj therefore treated a proof as data and allowed p.1 : Bool. Proof irrelevance then equates Owner.mk witness false with Owner.mk witness true.

Fix

As in leanprover/lean4#14807, is_proof_type now calls ensure_sort on the inferred type: the type must reduce to a sort, and otherwise checking fails with type expected. It can no longer answer "not a proposition" for something whose sort it cannot determine.

Audit of every caller of is_proof_type

All callers are in tc.rs. inductive.rs does not call it: its Prop decisions (result_level, field universes, elim_only_at_zero, K-target) go through ensure_sort/sort_of, which already fail with type expected on a non-sort.

Call site Unsafe answer before Now
infer_proj: is_prop_struct = is_proof_type(xt) false on a stuck sort skipped the data-projection guard. This is the bug. Errors, so the projection is rejected.
infer_proj: field check !is_proof_type(d) (twice) false was the safe direction (it rejected the projection). Still rejects, now with type expected.
ctor_when_structure (structure eta for iota): skips expansion if the type is a Prop false on a stuck sort would eta-expand a proof into Projs, including data projections out of it. Errors, so reduction fails closed.
is_def_eq_core proof irrelevance on infer(a) false skipped proof irrelevance. That only loses equalities (incomplete, not unsound). Errors, which matches Lean after #14807. The type of a well-typed term's type is always a sort, so this never fires on valid input.

Test

crates/certus-kernel/tests/arena.rs checks the Arena reproducer. fixtures/proj-of-subst-prop.ndjson is the unchanged round-2026-09 file (256 KB, sha256 1c9d8a26…5b9d, verified). The test requires rejection at PR14806Subst.observe with type expected. It fails on main with "proof of False was ACCEPTED (110 declarations)".

Rebased onto main with #24 merged. This PR deletes the bugs/proj-of-subst-prop line from tests/arena/known-unsound.txt. Local python3 tests/arena/run.py (round-2026-09, -j 2 --timeout 60 --memory-limit 1) gives 0 FALSE-ACCEPT and 0 known-false-accept: 110 correct-accept, 70 correct-reject, 3 false-reject (#19 ×2, #20) and 10 errors from the 1 GB local memory cap (#21, #22 and other perf tests). None of these depend on this change.

Timing: certus check sum_explicit.cert.ndjson takes 0.006 s, the same as before.

🤖 Generated with Claude Code

gimbalzero and others added 2 commits November 21, 2026 11:12
`is_proof_type` answered "not a proposition" when the inferred type of `t`
did not reduce to a sort. For a structure whose sort is a stuck term this
let `infer_proj` skip the "no data out of a proof" guard, and together with
proof irrelevance that proves `False` (Arena bugs/proj-of-subst-prop).

As in leanprover/lean4#14807, the type of `t` must now reduce to a sort, and
otherwise checking fails with "type expected". Adds the Arena reproducer as
a fixture and a regression test that requires its rejection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@gimbalzero
gimbalzero merged commit 0cf007a into main Nov 22, 2026
4 checks passed
@gimbalzero
gimbalzero deleted the fix-17-proj-prop branch November 22, 2026 07:09
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.

Soundness: projection out of a Prop whose sort is stuck proves False (Arena bugs/proj-of-subst-prop)

1 participant