-
Notifications
You must be signed in to change notification settings - Fork 373
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
Allow for Config attributes to be set directly #20029
base: master
Are you sure you want to change the base?
Allow for Config attributes to be set directly #20029
Conversation
Please note that the current code may not work, and only intended to sketch the general approach as the PR is still in draft |
PR summary cd065b4a1fImport changes for modified filesNo significant changes to the import graph Import changes for all files
Declarations diff
You can run this locally as follows## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>
## more verbose report:
./scripts/declarations_diff.sh long <optional_commit> The doc-module for No changes to technical debt.You can run this locally as
|
The My plan - once I have time - was to:
Does this make sense? |
I'm not quite sure what you mean by "the general configuration options can only be placed directly after the word simps in the attribute". Also what is the mechanism for actually storing the config options? I notice for the projections you're writing to a NameMapExtension. Where when does the data from the NameMapExtension actually get used to create a config type? Overall, I think I'm just having a bit of trouble understanding the data lifecycle. |
Here an entry to the environment extension gets written. This never gets modified afterwards: mathlib4/Mathlib/Tactic/Simps/Basic.lean Line 828 in cd065b4
Currently there is no Config options in this environment extension, but it will be if you add some Config options to ProjectionData
Currently, the syntax for the But maybe I'm overcomplicating things, and it's fine if we only allow such options in the @urkud @YaelDillies @sgouezel and others might have an opinion on the design. (We can also move this to a Zulip thread.) |
don't you already need to encode some config options in order to support the + and - notation. |
The configuration elaborator gets generated here, with : mathlib4/Mathlib/Tactic/Simps/Basic.lean Line 904 in cd065b4
It requires that the syntax gets declared as optConfig :mathlib4/Mathlib/Tactic/Simps/Basic.lean Line 133 in cd065b4
Place where structureExt gets read: mathlib4/Mathlib/Tactic/Simps/Basic.lean Line 803 in cd065b4
Do you have prior experience with metaprogramming? This might be a bit too complicated as a first metaprogramming task. |
I've done quite a bit of metaproggraming in lean3 and I've worked my way through most of the lean4 metaproggraming book. I think I have a pretty good understanding of elaborators as well as the metaprogramming monad system. I think my main weakness is understanding how things get stored in the environment such as NamedMapExtension |
So how does getRawProjections get used. Cause it seems like the return value is just thrown out: /-- Function elaborating `initialize_simps_projections`. -/
@[command_elab «initialize_simps_projections»] def elabInitializeSimpsProjections : CommandElab
| stx@`(initialize_simps_projections $[?%$trc]? $id $[($stxs,*)]? $[($stxs',*)]?) => do
let stxs := stxs.getD <| .mk #[]
let rules ← stxs.getElems.raw.mapM elabSimpsRule
let stxs' := stxs'.getD <| .mk #[]
let configs ← stxs'.getElems.raw.mapM elabConfigOption
let nm ← resolveGlobalConstNoOverload id
_ ← liftTermElabM <| addTermInfo id.raw <| ← mkConstWithLevelParams nm
_ ← liftCoreM <| getRawProjections stx nm true rules trc.isSome configs
| _ => throwUnsupportedSyntax Is its purpose in the elaborator just to write to to |
Allow for Config attributes to be set directly when using initialize_simp_projection as per issue #19895
Basically modified initialize_simp_projection so that the user has the option of specifying a tuple of config option values.
Ex:
These config options are then converted into projections.
---