lean4lean: bump to bce3448, and a request to reconsider tutorial/096-097 - #167
Conversation
|
That's a good discussion, but a bump PR isn't quite the right place. I expect we will revisit some of these questions proper in the near future and make it less ambiguous what lean kernels should support and what not. Until then I suggest to support no less than what the official kernel supports (so that proof and meta code out there can rely on it). If there is behavior that is
then I'm game to labeling such behavior difference as |
/--
error: Invalid universe polymorphic resulting type: The resulting universe is not `Prop`, but it may be `Prop` for some parameter values:
Sort u
Hint: A possible solution is to use levels of the form `max 1 _` or `_ + 1` to ensure the universe is of the form `Type _`
-/
#guard_msgs in
structure Wrap (α : Sort u) : Sort u where
val : α
As mentioned, the alternative is to relax the restrictions on inductives, but this will change the generated recursors so I don't want to unilaterally make such a change as it will cause lean imports to become unreadable by lean4lean. If you make the change in lean I'll update lean4lean correspondingly. |
|
This means leanprover/lean4#14893 wouldn't fly anymore, right? |
|
At least for cases like Of course you want to stay compatible, but there are ways to do that. E.g. a flag. Or, if you want the proof to apply, generate a There are probably more ways for you to not feel blocked by the arena tests checking for the official behavior. But if it makes you happy, please do submit a PR that moves these checks out of the tutorial and into new tests marked |
Bumps the
lean4leanchecker tobce3448(fixing a performance issue onmathlibtest).Separately, we think
tutorial/096_projMaybePropandtutorial/097_projMaybePropPastshould beeitherratherthan
accept. The new version will continue to reject them.tutorial/096_projMaybeProplean4lean rejects this one deliberately, and we would like to argue the question is unsettled
rather than that we are incomplete.
The tutorial's own text for
095_MaybePropstates the rule we are applying:The kernel answers "it might be a proposition" when it generates the recursor:
Accepting
projMaybePropanswers the opposite way at the projection.fun x => x.0cannot bewritten with that recursor — the motive would have to be
fun _ => PUnit.{u}, of typeMaybeProp → Sort u, and Lean's own kernel rejects the attempt withapplication type mismatch.So under the expected outcome,
Expr.projcomputes something the type's own eliminator cannot.lean4lean declines to be more powerful at
projthan atrec, which is why it testsisNeverZerowhere Lean tests!isAlwaysZero.We are not claiming Lean is unsound here. The soundness argument in the test description is
correct: the field bound
u ≤ usurvives instantiation, so wherever the structure is aproposition its fields are too. The claim is only that a kernel may reasonably answer this either
way, which is what
eitheris for — comparenested-nonuniform-param, whose description saysthat since it is not a demonstrated unsoundness "it is not settled whether a checker should accept
or reject it".
There is also a third position that is consistent in the other direction: let recursor generation
eliminate large whenever every constructor field's universe is bounded by the inductive's — which
is precisely the fact that makes this projection sound. Then
MaybeProp.recwould belarge-eliminating and
projMaybePropwould be spellable, and both checks would accept. That is achange to recursor generation rather than to the projection rule, which is part of why we think
the present situation is an open question rather than a defect on either side.
tutorial/097_projMaybePropPastThis one we ask for as a consequence, and we want to be candid that it is weaker.
In isolation,
fun x => x.2 : MaybeProp.{u} → Trueis expressible with the recursor —Trueisa proposition, so
motive := fun _ => Trueis fine, and Lean acceptsMaybeProp.rec (motive := fun _ => True) (fun _ _ tail => tail) x. lean4lean rejects it onlybecause
infer_projwalks the constructor telescope generically: reaching field 2 meanssubstituting
x.0intoproof's type first, even though the result typeTruedoes not dependon it.
But that is exactly what the test's own description says:
So it is a rider on 096 rather than an independent question, and scoring both charges the same
choice twice. If 096 stays
acceptthen 097 should too, and we will simply fail both.Either outcome is fine by us — if you would rather keep both as
acceptand have the divergencerecorded on our side, we have already documented it in lean4lean's
divergences.md.