-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: labeled and unique sorries #5757
base: master
Are you sure you want to change the base?
Conversation
Mathlib CI status (docs):
|
5ea2192
to
1efdc9c
Compare
Nice! I'm curious how this interacts with |
Interesting idea @alexkeizer! That wasn't the plan, but I'll look into it. Maybe it would be better to have a In the current implementation, the |
I should clarify, I think I'd prefer the unique names don't show up in Granted, 99% of the time we use the Having a separate |
@alexkeizer These unique sorries just pretty print as |
Motivation: `sorry` should have an indeterminate value so that it's harder to make "fake" theorems about stubbed-out definitions. This PR makes each instance of `sorry` be non-defeq to any other. For example, this now fails: ```lean example : (sorry : Nat) = sorry := rfl -- fails ``` However, this still succeeds: ```lean def f (n : Nat) : Nat := sorry example : f 0 = f 1 := rfl -- succeeds ``` One can be more careful by putting variables to the right of the colon: ```lean def f : (n : Nat) → Nat := sorry example : f 0 = f 1 := rfl -- fails ``` Details: Adds `Lean.Meta.mkUniqueSorry`, which creates a sorry that is not defeq to any other sorry. It also encodes the source position into the term. Makes the `sorry` term and `sorry` tactic create unique sorries. Adds support to the LSP so that "go to definition" on `sorry` in the Infoview goes to the origin of that particular `sorry`. Fixes `sorry` pretty printing: no more `sorryAx` in the Infoview. Removes `Lean.Meta.mkSyntheticSorry` in favor of `Lean.Meta.mkSorry`. pervasive mkUniqueSorry unique -> labeled sorries. Turns out using unique sorries for elaboration errors can compound the issues. In any case, they can still be labeled. improves addPPExplicitToExposeDiff when functions are overapplied fixes mdata bugs in location RPC handler fixes leanprover#4972 fix tests revert comment more unique
This PR makes it harder to create "fake" theorems about definitions that are stubbed-out with
sorry
by using an encoding that ensures eachsorry
is non-defeq to any other. For example, this now fails:However, this still succeeds, since the
sorry
is a single indeterminateNat
:One can be more careful by putting parameters to the right of the colon:
Most sources of synthetic sorries are now unique, except for elaboration errors, since making these unique tends to cause a confusing cascade of errors. In general however such sorries are labeled. This enables "go to definition" on
sorry
in the Infoview, which brings you to its origin. The optionset_option pp.sorrySource true
causes the pretty printer to show source position information on sorries.Details:
Adds
Lean.Meta.mkLabeledSorry
, which creates a sorry that is labeled with its source position. For example,(sorry : Nat)
might elaborate toIt can either be made unique (like the above) or merely labeled. Labeled sorries use an encoding that does not impact defeq:
Makes the
sorry
term, thesorry
tactic, and every elaboration failure create labeled sorries. Most are unique sorries, but some elaboration errors are labeled sorries.Renames
OmissionInfo
toDelabTermInfo
and adds configuration options to control LSP interactions. One field is a source position to use for "go to definition". This is used to implement "go to definition" on labeled sorries.Makes hovering over a labeled
sorry
show something friendlier than that fullsorryAx
expression. Instead, the first hover shows the simplifiedsorry `«lean.foo:48:11»
. Hovering over that hover shows the fullsorryAx
. Settingset_option pp.sorrySource true
makessorry
always start with printing with this source position information.Removes
Lean.Meta.mkSyntheticSorry
in favor ofLean.Meta.mkSorry
andLean.Meta.mkLabeledSorry
.Changes
sorryAx
so that thesynthetic
argument is no longer optional.Gives
addPPExplicitToExposeDiff
awareness of labeled sorries. It can setpp.sorrySource
when source positions differ.Modifies the delaborator framework so that delaborators can set Info themselves without it being overwritten.
Incidentally closes #4972.
Inspired by this Zulip thread.