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(tactic/frozen): add tactics about frozen locals #7652

Closed
wants to merge 1 commit into from

Conversation

JLimperg
Copy link
Collaborator

In Lean, any revert can fail due to frozen local instances. I add some
tactics to detect this situation and unfreeze local instances as necessary. See
the module docs for details.


I need this to make some of my other tactics more robust.

Open in Gitpod

In Lean, any `revert` can fail due to frozen local instances. I add some
tactics to detect this situation and unfreeze local instances as necessary. See
the module docs for details.

---

I need this to make some of my other tactics more robust.
@JLimperg JLimperg added the WIP Work in progress label May 18, 2021
@eric-wieser eric-wieser added the t-meta Tactics, attributes or user commands label May 19, 2021
the local constants whose unique names appear in `hs` are frozen. -/
meta def unfreeze_if_necessary_for_name_set (hs : name_set) : tactic bool := do
tt ← any_is_frozen_name_set hs | pure ff,
unfreeze_local_instances,
Copy link
Member

Choose a reason for hiding this comment

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

unfreeze should always be followed by freeze, since thawed instances are slow. Please check out and use the unfreezing combinator.

Copy link
Member

Choose a reason for hiding this comment

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

BTW, there's also unfreezing_hyp which is similar to this function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I found the unfreezing combinator after I had written all this stuff. My eventual use case is to make sure that certain reverts aren't blocked by frozen instances. Is it even worth checking whether the revert would be blocked (which can be somewhat expensive), versus just unfreezing (revert_lst ...) without the check?

Copy link
Member

Choose a reason for hiding this comment

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

Freeze and unfreeze are fairly cheap. Freeze requires lean to check for every hypothesis whether it is a type class or not, but that's it. There should be no performance impact (after the freeze) if the instances do not change.

The main performance issue is staying in the unfrozen state, because this disables the TC cache.

@gebner gebner added the awaiting-author A reviewer has asked the author a question or requested changes label May 20, 2021
@YaelDillies
Copy link
Collaborator

This is made fully redundant by the way Lean 4 deals with the instance cache.

@YaelDillies YaelDillies deleted the frozen-locals branch April 19, 2023 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-author A reviewer has asked the author a question or requested changes t-meta Tactics, attributes or user commands WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants