Skip to content
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: config options for fail_if_no_progress #3757

Open
wants to merge 51 commits into
base: master
Choose a base branch
from

Conversation

thorimur
Copy link
Collaborator

@thorimur thorimur commented May 1, 2023

This PR creates config options for fail_if_no_progress that allow the user to tweak what exactly counts as "progress". This includes whether to use defeq or BEq, what transparency to use, and which parts of the goal and local context to check.

It also splits off the comparison functionality into Mathlib.Lean.Meta.Compare, which provides fully configurable comparison functions for common complex metaprogramming types not specific to fail_if_no_progress. These types are Expr, LocalDecl, LocalContext, MetavarDecl, MVarId, and List MVarId.


See zulip for a couple review questions.

Status update: this PR is now basically done, save for some extra tests which should probably be included.

Open in Gitpod

@thorimur thorimur added WIP Work in progress t-meta Tactics, attributes or user commands labels May 1, 2023
@alexjbest
Copy link
Member

@thorimur what's the status of this, is there anything I can do to help move it forward?

@kim-em kim-em added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jun 2, 2023
@thorimur thorimur force-pushed the fail_if_no_progress branch from f37e947 to c181194 Compare June 5, 2023 00:01
@kim-em kim-em removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jun 5, 2023
@kim-em kim-em added the awaiting-author A reviewer has asked the author a question or requested changes label Jun 20, 2023
thorimur added 3 commits July 9, 2023 01:33
* evaluates tactics given instead of running them on the main goal
* uses config to specify/restrict progress check
@thorimur thorimur force-pushed the fail_if_no_progress branch from c181194 to ab5540e Compare July 9, 2023 05:34
@thorimur thorimur removed the awaiting-author A reviewer has asked the author a question or requested changes label Jul 9, 2023
Copy link
Collaborator

@joneugster joneugster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm :)

Comment on lines 58 to 59
* Different `ExprComparisonConfig`s for each location expressions are compared, ideally with
default propagation from the top level when writing configs, one way or another
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't make sense of this sentence.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewritten. :)

Comment on lines 128 to 129
def runAndFailIfNoProgress (goal : MVarId) (tacs : TacticM Unit)
(cfg : FailIfNoProgress.Config := {}) : TacticM (List MVarId) := do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a weird type signature. Perhaps that return type should be MetaM (List MVarId)?

Possibly also tacs should be a MVarId \to MetaM (List MVarId)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this make sense? My objections are:

  • This is all operating in MetaM anyway, using run. (maybe TermElabM, whatever)
  • TacticM shouldn't ever be returning List MVarId: that's what its state is for!
  • I want a purely MetaM level version of all this anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right! Looking back I actually don't know why I even defined runAndFailIfNoProgress. I replaced it with MVarId.failIfNoProgress, MVarId.failIfNoProgress', and MVarId.failIfNoProgress1 in analogy to the corresponding liftMetaTactics, all in MetaM.

@@ -1,12 +1,18 @@
import Mathlib.Tactic.FailIfNoProgress
import Mathlib.Data.List.Basic

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not going to insist, but it seems the ratio of configuration options to tests is high! We could add more exhaustive tests, or perhaps just try next time to resist the temptation to add so many knobs that we can't even be bothered testing them. :-)

@kim-em kim-em added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review labels Aug 27, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Sep 10, 2023
@bors bors bot changed the base branch from master to ScottCarnahan/BinomialRing2 September 17, 2023 03:23
@kim-em kim-em changed the base branch from ScottCarnahan/BinomialRing2 to master September 17, 2023 12:18
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Oct 22, 2023

/-- Returns `true` if using `BEq` (`.beq`) and `false` if using `isDefEq` (`.defEq`). -/
def EqKind.isBEq : EqKind → Bool
| .beq => true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[lint-style] reported by reviewdog 🐶

Suggested change
| .beq => true
| .beq => true

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this is part of the linter. There's currently an RFC about this: leanprover/lean4#2580.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the RFC has much traction. :-)

@thorimur thorimur added WIP Work in progress and removed awaiting-author A reviewer has asked the author a question or requested changes labels Oct 22, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) t-meta Tactics, attributes or user commands WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants