Repository navigation
Conversation
8c3adb8 to
fba28f5
Compare
…nt them appearing on hover
PR summary aa408695b3Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
@thorimur I merged |
|
@urkud Ah, thanks; I had given up on keeping this PR fresh! I'll take a look soon. |
|
@urkud "Soon" has finally arrived. :) I've freshened this PR and its 3 dependents as well. |
| -- Mathlib `have` | ||
| | `(tfaeHave'|tfae_have $d:tfaeHaveIdLhs) => withMainContext do | ||
| let goal ← getMainGoal | ||
| let (_, tfaeList) ← getTFAEList (← goal.getType) | ||
| match d with | ||
| | `(tfaeHaveIdLhs| $b:ident : $t:tfaeType) => | ||
| let type ← elabTFAEType tfaeList t | ||
| evalTactic <|← `(tactic|have $b:ident : $(← exprToSyntax type)) | ||
| | _ => throwUnsupportedSyntax |
There was a problem hiding this comment.
I think the current consensus is that the mathlib-have should not be used inside mathlib anymore, and therefore ideally also not imported (see docs):
As a style choice, this [mathlib's
have] should not be used in mathlib; but is provided for downstream users who preferred the old style.
Maybe it's easiest to just drop the import together with this snippet?
Or is there a reasonable workaround which allows not to import the modified have here?
There was a problem hiding this comment.
Ah, that's right. :) I eliminated the import and moved the entirety of the old-style version to its own section below.
In parallel to Mathlib have, I think we ought to move the old tfae_have syntax to its own non-imported file in the PR that migrates Mathlib to the new syntax (#11000); what do you think?
| /- Convert `tfae_have i <arr> j ...` to `tfae_have tfae_i_arr_j : i <arr> j ...`. See | ||
| `expandHave`, which is responsible for inserting `this` in `have : A := ...`. -/ | ||
| macro_rules | ||
| | `(tfaeHave|tfae_have $hy:hygieneInfo $t:tfaeType := $val) => do | ||
| let id := HygieneInfo.mkIdent hy (← mkTFAEId t) (canonical := true) | ||
| `(tfaeHave|tfae_have $id : $t := $val) | ||
| | `(tfaeHave|tfae_have $hy:hygieneInfo $t:tfaeType $alts:matchAlts) => do | ||
| let id := HygieneInfo.mkIdent hy (← mkTFAEId t) (canonical := true) | ||
| `(tfaeHave|tfae_have $id : $t $alts) |
There was a problem hiding this comment.
I think it would be better to do this inside the elab and use Lean.Meta.mkFreshBinderNameForTactic in order to make the tactic hygienic.
I.e. the binder name should probably only be accessible if set_option tactic.hygienic false
There was a problem hiding this comment.
Hmm, I'm not sure—tfae_have is specifically meant to mimic have when the binder name is not provided, which means producing an accessible name like tfae_2_iff_3 in analogy to producing the accessible name this. (Note that this is the same mechanism used by have to accomplish that.)
(This is also how it currently behaves, so I'd be wary of breaking it!)
There was a problem hiding this comment.
ok that's a fair point!
joneugster
left a comment
There was a problem hiding this comment.
Thanks for the PR. I think it looks very clean and will be a good base for the upcoming improvements for the tfae tactic. I suggest
maintainer merge
|
🚀 Pull request has been placed on the maintainer queue by joneugster. |
|
LGTM. We can fix issues (if any) in the PR migrating Mathlib to the new syntax. Thanks a lot! |
This PR refactors `tfae_have` in terms of `have`, thus supporting all the syntax that `have` supports. We can now also write: ```lean example : TFAE [P, Q, R] := by tfae_have 1 → 2 := sorry tfae_have 2 → 1 | p => f p tfae_have ⟨mp, mpr⟩ : 2 ↔ 3 := sorry ... ``` Previously, `tfae_have` exclusively pushed a new goal to the top of the goal list, requiring that the result be proved via tactic. This PR does not deprecate or remove the "old-style" syntax, but does de-document it. The removal of old-style syntax is done in #11000. This tees us up for a `tfae` block tactic (#10991, #11003). See [Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/tfae_have.201.20.E2.86.92.202.20.3A.3D.20syntax). Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>
|
Pull request successfully merged into master. Build succeeded: |
tfae_have ... := syntaxtfae_have ... := syntax
This PR refactors
tfae_havein terms ofhave, thus supporting all the syntax thathavesupports. We can now also write:Previously,
tfae_haveexclusively pushed a new goal to the top of the goal list, requiring that the result be proved via tactic.This PR does not deprecate or remove the "old-style" syntax, but does de-document it. The removal of old-style syntax is done in #11000.
This tees us up for a
tfaeblock tactic (#10991, #11003).See Zulip.
Ref #2061