Repository navigation
Introduce a "scope" mechanism to judgments and use for binder instantiation - #463
Merged
Merged
Conversation
Collaborator
|
Thanks for contributing to formality! :) |
This comment has been minimized.
This comment has been minimized.
jackh726
force-pushed
the
judgment-scope
branch
from
October 6, 2026 18:21
f2089c9 to
c62d77b
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
|
My thoughts:I really like the scope mechanism. Quite nice. I'd like to see it factored out into its own PR that we can land first, that should be relatively easy to merge, and then to look more closely at the follow-up changes. |
nikomatsakis
requested changes
Oct 15, 2026
jackh726
force-pushed
the
judgment-scope
branch
from
October 16, 2026 03:13
c62d77b to
94afba1
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
nikomatsakis
approved these changes
Oct 16, 2026
A rule can prove some of its conditions inside a scope:
(
(scope(enter_forall(env, binder) => (env, body)) with(c)
(prove(env, body) => c))
--------------------
(prove(env, Goal::ForAll(binder)) => c)
)
* The expression enters the scope. It evaluates to a pair: the scope, and
what is inside it, which the pattern binds for the nested conditions.
Like any other condition's expression, it may fail; the rule then does
not apply.
* Those bindings, and any the nested conditions make, end with the
`scope` condition.
* Only the `with` variables come out. Each proof of the nested conditions
leaves the scope with its values for them (`Scope::leave`), and the
rest of the rule sees what that yields.
So a rule cannot forget to leave a scope, nor use what was inside it
afterwards.
nikomatsakis
force-pushed
the
judgment-scope
branch
from
October 16, 2026 09:12
9d03abf to
956b762
Compare
Collaborator
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
nikomatsakis
enabled auto-merge
October 16, 2026 09:12
nikomatsakis
approved these changes
Oct 16, 2026
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.
What does this PR do?
This introduces a new
scope(...)primitive to judgement functions, which effectively function like a closure. This can allow us to run some code when we exit that scope.AI disclosure