-
Notifications
You must be signed in to change notification settings - Fork 125
Refine+AInvs: performance improvements (clear_named_theorems, avoid interpretation Arch and interpret Arch) #1047
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
Open
Xaphiosis
wants to merge
7
commits into
seL4:master
Choose a base branch
from
Xaphiosis:refine_nmc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5e48f32
lib: add clear_named_theorems command and test
Xaphiosis baf33c0
ainvs: introduce Arch_assms named_theorems
Xaphiosis 404c6d8
refine: use Arch_assms in lieu of named_theorems
Xaphiosis 678f305
refine: remove remaining "interpretation Arch ."
Xaphiosis 88df3a1
ainvs: use Arch_assms in lieu of named_theorems
Xaphiosis 083c234
ainvs: remove remaining "interpretation Arch ."
Xaphiosis ba917d4
riscv64+aarch64 access: locale access to vs_lookup_table'
Xaphiosis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| (* | ||
| * Copyright 2026, Proofcraft Pty Ltd | ||
| * | ||
| * SPDX-License-Identifier: BSD-2-Clause | ||
| *) | ||
|
|
||
| (* Clearing an existing named_theorems within the current context, allowing the same named_theorems | ||
| to be re-used multiple times as an accumulator. *) | ||
|
|
||
| theory Clear_Named_Theorems | ||
| imports Main | ||
| keywords "clear_named_theorems" :: thy_decl | ||
| begin | ||
|
|
||
| ML \<open> | ||
| local | ||
|
|
||
| (* We need to lift from a Context.generic transformer to a local_theory transformer. | ||
| Context.proof_map looks like it should do this, but using it with Named_Theorems.clear does not | ||
| have any effect. It is unclear why that's the case. | ||
| Going via Local_Theory.declaration does work, even if we have to give it a "morphism" that | ||
| doesn't actually contain a morphism. *) | ||
| fun alt_proof_map f = | ||
| Local_Theory.declaration {syntax = false, pervasive = false, pos = \<^here>} (fn _ => f); | ||
|
|
||
| val _ = | ||
| Outer_Syntax.local_theory \<^command_keyword>\<open>clear_named_theorems\<close> | ||
| "clear named collection of theorems" | ||
| ((Parse.name_position) >> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| (fn (b,pos) => fn ctxt => | ||
| alt_proof_map (Named_Theorems.clear (Named_Theorems.check ctxt (b, pos))) ctxt)); | ||
|
|
||
| in end\<close> | ||
|
|
||
| end | ||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| (* | ||
| * Copyright 2026, Proofcraft Pty Ltd | ||
| * | ||
| * SPDX-License-Identifier: BSD-2-Clause | ||
| *) | ||
|
|
||
| theory Clear_Named_Theorems_Test | ||
| imports Lib.Clear_Named_Theorems | ||
| begin | ||
|
|
||
| section \<open>Interacting with named theorems in global theory context\<close> | ||
|
|
||
| named_theorems glob_thms | ||
|
|
||
| thm glob_thms (* empty *) | ||
|
|
||
| declare TrueI[glob_thms] | ||
| thm glob_thms (* True *) | ||
|
|
||
| clear_named_theorems glob_thms | ||
|
|
||
| thm glob_thms (* empty again *) | ||
|
|
||
|
|
||
| section \<open>Interacting with named theorems inside locale context\<close> | ||
|
|
||
| locale Arch | ||
|
|
||
| context Arch begin | ||
|
|
||
| named_theorems Arch_assms | ||
|
|
||
| declare TrueI[Arch_assms] | ||
| thm Arch_assms (* True *) | ||
|
|
||
| clear_named_theorems Arch_assms | ||
| thm Arch_assms (* empty again *) | ||
|
|
||
| end (* Arch *) | ||
|
|
||
| text \<open>Remember that named theorems are locale-aware, so attempts to directly access them from a | ||
| different context don't do what one might expect:\<close> | ||
|
|
||
| context Arch begin | ||
|
|
||
| declare TrueI[Arch_assms] | ||
|
|
||
| end (* Arch *) | ||
|
|
||
| thm Arch.Arch_assms (* empty! *) | ||
| clear_named_theorems Arch.Arch_assms (* no effect! *) | ||
|
|
||
| context Arch begin | ||
|
|
||
| thm Arch_assms (* True *) | ||
|
|
||
| text \<open>In cases where we need direct access to the set of theorems accumulated in a named theorems | ||
| from outside its locale, the current set of theorems must be captured under a non-dynamic name:\<close> | ||
|
|
||
| lemmas Arch_assms_final = Arch_assms | ||
| thm Arch_assms_final (* True *) | ||
|
|
||
| end (* Arch *) | ||
|
|
||
| thm Arch.Arch_assms_final (* True *) | ||
|
|
||
| end | ||
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably replace
(fn _ => f)by(K f)as the more usual form in the Isabelle sources.alt_proof_mapis not really the right name, becauseproof_mapis exactly not the thing we're doing. Looking at the code ofLocal_Theory.declaration,proof_mapis just one of multiple primitive steps in there. Basicallyproof_mapis a primitive lifting operation, anddeclarationdoes all of the actual context handling of the locale. What we're doing really is a declaration command like adeclare(and we're also giving the keyword typethy_decl, which is correct), so maybelocal_declareas a name? The morphism is safe to ignore in this case, because we are not referring to any localefixesor anything like that, so there is nothing to transform.