fix: improved dependency tracking in metacontext and abstractMVars#13025
Draft
fix: improved dependency tracking in metacontext and abstractMVars#13025
abstractMVars#13025Conversation
This PR fixes some issues involving tracking dependencies through metavariables. First, functions like `Lean.exprDependsOn'` were not following dependencies through delayed metavariable assignments. Second, `abstractMVars` was abstracting metavariables that free variables in the expression themselves depended on, creating type incorrect terms. API changes: - `findExprDependsOn` has been split into two; the metavariable version is `findExprDependsOnMVar`. This is because they have different considerations for metavariable dependence — only the latter needs to follow delayed assignments for example - These functions now take an optional local context, for tracing dependencies through types and values of free variables. - Similary, `findLocalDeclDependsOn` has an accompanying `findLocalDeclDependsOnMVar`. - `dependsOnPred` is deprecated in favor of `findExprDependsOn` - `localDeclDependsOnPred` is deprecated in favor of `findLocalDeclDependsOn` - added `collectFVarDeps` and `collectMVarDeps` for finding the complete sets of backward dependencies of an expression, with respect to a given local context Closes #2483, closes #9286
|
Mathlib CI status (docs):
|
Collaborator
|
Reference manual CI status:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes some issues involving tracking dependencies through metavariables. First, functions like
Lean.exprDependsOn'were not following dependencies through delayed metavariable assignments. Second,abstractMVarswas abstracting metavariables that free variables in the expression themselves depended on, creating type incorrect terms.API changes:
findExprDependsOnhas been split into two; the metavariable version isfindExprDependsOnMVar. This is because they have different considerations for metavariable dependence — only the latter needs to follow delayed assignments for examplefindLocalDeclDependsOnhas an accompanyingfindLocalDeclDependsOnMVar.dependsOnPredis deprecated in favor offindExprDependsOnlocalDeclDependsOnPredis deprecated in favor offindLocalDeclDependsOncollectFVarDepsandcollectMVarDepsfor finding the complete sets of backward dependencies of an expression, with respect to a given local contextsetMVarUserNamesAtnow takes a predicate rather than an arrayabstractMVarshas additional options, for exampleisLambdato control whether to get a forall or lambda, andinferNamesfor whether to use themkForallFVars'machinery to infer names for anonymous metavariablesAbstractMVarsResulthas been extended with a little more information, and themvarsfield has been replaced withexprArgs, anticipating a potential feature whereabstractMVarscan properly handle delayed assignments. Currently it treats them as plain metavariables, which can lead to underapplied delayed assignments if you use this field for creating an application!Closes #2483, closes #9286