Test "corner-cases/proj-maybe-prop"
Expected: 🤷 either · Size: 8.1 KB · Lines: 131 · lean4export: 3.1.0 · Lean: 4.29.1 · 📄 Declaration · 🔗 Source
Projecting out of a structure that may or may not be a proposition.
MaybeProp is a structure whose sort is a bare level parameter: a
proposition for u := 0 and a data type for every other u. Lean's
inductive command refuses to declare one ("the resulting universe is not
Prop, but it may be Prop for some parameter values"), but the kernel
accepts it. The exported definition projects out its first field,
field : PUnit.{u}.
The official kernel accepts this. The field is not a proof for every u,
but the projection is sound at every instantiation: MaybeProp.{u} is a
proposition only for u := 0, and there the field's type PUnit.{0} is a
proposition too. That is no coincidence. A structure that is not a Prop
had every constructor field's universe checked against its resulting
universe (see the tutorial's typeWithTooHighTypeField), here u ≤ u, and
such an inequality survives instantiation — so wherever the structure does
turn out to be a proposition, so do all of its fields.
At the same time, the official kernel here allows more projections than the
recursor allows: MaybeProp.rec eliminates into Prop only, so this
projection cannot be expressed through the recursor. The elaborator does not
currently rely on this extra power, so for now it is reasonable for a
checker to be more restrictive here and reject the projection — for example
by asking "could this be a proposition?" and then demanding that the field
be definitely a proof. See
https://github.com/leanprover/lean4/issues/7637 for discussion.
| Checker | Result | ⏱️ | 🧠 | |||
|---|---|---|---|---|---|---|
| mathgraph | 👍 | 1 ms | 33.8 MB | |||
| nanoda | ✋ | 1 ms | 3.3 MB | |||
| nanobruijn | ✋ | 1 ms | 9.7 MB | |||
| ind-models | 👍 | 63 ms | 106.3 MB | |||
| official | 👍 | 28 ms | 65.8 MB | |||
| lean4lean | ✋ | 28 ms | 99.4 MB | |||
| evmlean | 👍 | 1.1 s | 133.0 MB | |||
| mini | 👍 | 35 ms | 75.0 MB | |||
| sokonanoda | 👍 | 1 ms | 33.8 MB | |||
| nanoclo | ✋ | 1 ms | 49.6 MB | |||
| zignodamus | 👍 | 1 ms | 4.8 MB | |||
| vow-lean-kernel | 👍 | 96 ms | 8.2 MB | |||
| official-v4.28.0 | 👍 | 35 ms | 72.9 MB | |||
| still-nanoda | 👍 | 1 ms | 3.1 MB | |||
| kiota | 👍 | 1 ms | 7.0 MB | |||
| rpylean | 👍 | 1 ms | 8.2 MB | |||
| nyaya | 👍 | 3 ms | 9.8 MB | |||
| parse-only | 👍 | 28 ms | 65.6 MB |