-
Notifications
You must be signed in to change notification settings - Fork 27
feat: MoSeL modality types #42
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
Merged
digama0
merged 2 commits into
leanprover-community:master
from
markusdemedeiros:modality-theory
Jul 3, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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,55 @@ | ||
| /- | ||
| Copyright (c) 2025 Markus de Medeiros. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Markus de Medeiros | ||
| -/ | ||
| import Iris.BI | ||
|
|
||
| namespace Iris.ProofMode | ||
| open Iris.BI | ||
|
|
||
| inductive ModalityAction (PROP1 PROP2 : Type u) : Type u where | ||
| | isEmpty : ModalityAction PROP1 PROP2 | ||
| | forall : PROP1 = PROP2 → (PROP1 → Prop) → ModalityAction PROP1 PROP2 | ||
| | transform : (PROP2 → PROP1 → Prop) → ModalityAction PROP1 PROP2 | ||
| | clear : ModalityAction PROP1 PROP2 | ||
| | id : PROP1 = PROP2 → ModalityAction PROP1 PROP2 | ||
|
|
||
| namespace ModalityAction | ||
|
|
||
| variable [BI PROP1] [BI PROP2] (s : ModalityAction PROP1 PROP2) | ||
|
|
||
| @[simp] | ||
| def intuitionistic_action_spec (M : PROP1 → PROP2) : Prop := | ||
| match s with | ||
| | .isEmpty => True | ||
| | .forall Hconv C => | ||
| (∀ P, C P → iprop(□ P) ⊢ Hconv ▸ M iprop(□ P)) ∧ | ||
| (∀ P Q, iprop(M P ∧ M Q) ⊢ M iprop(P ∧ Q)) | ||
| | .transform C => | ||
| (∀ P Q, C P Q → iprop(□ P) ⊢ M iprop(□ Q)) ∧ | ||
| (∀ P Q, iprop(M P ∧ M Q) ⊢ M iprop(P ∧ Q)) | ||
| | .clear => True | ||
| | .id H => ∀ P, iprop(□ P) ⊢ M (H ▸ iprop(□ P)) | ||
|
|
||
| @[simp] | ||
| def spatial_action_spec (M : PROP1 → PROP2) : Prop := | ||
| match s with | ||
| | .isEmpty => True | ||
| | .forall Hconv C => ∀ P, C P → P ⊢ Hconv ▸ M P | ||
| | .transform C => ∀ P Q, C P Q → P ⊢ M Q | ||
| | .clear => ∀ P, Absorbing (M P) | ||
| | .id Hconv => ∀ P, P ⊢ (Hconv ▸ M P) | ||
|
|
||
| end ModalityAction | ||
|
|
||
| class IsModal [BI PROP1] [BI PROP2] (M : PROP1 → PROP2) | ||
| (iaction saction : ModalityAction PROP1 PROP2) where | ||
| spec_intuitionistic : iaction.intuitionistic_action_spec M | ||
| spec_spatial : saction.spatial_action_spec M | ||
| emp : iprop(emp) ⊢ M iprop(emp) | ||
| mono : ∀ {P Q}, (P ⊢ Q) → M P ⊢ M Q | ||
| sep : ∀ {P Q}, iprop(M P ∗ M Q) ⊢ M iprop(P ∗ Q) | ||
|
|
||
| instance [BI PROP] : IsModal (PROP1 := PROP) id (.id rfl) (.id rfl) := by | ||
| constructor <;> simp | ||
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,38 @@ | ||
| /- | ||
| Copyright (c) 2025 Markus de Medeiros. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Markus de Medeiros | ||
| -/ | ||
| import Iris.BI | ||
| import Iris.BI.DerivedLaws | ||
| import Iris.ProofMode.Modalities | ||
|
|
||
| namespace Iris.ProofMode | ||
| open Iris.BI | ||
|
|
||
| section Modalities | ||
|
|
||
| variable [BI PROP] | ||
|
|
||
| instance : IsModal (PROP1 := PROP) persistently (.id rfl) .clear where | ||
| spec_intuitionistic _ := persistent | ||
| spec_spatial P := persistently_absorbing P | ||
| emp := persistently_emp_2 | ||
| mono := (persistently_mono ·) | ||
| sep := persistently_sep_2 | ||
|
|
||
| instance : IsModal (PROP1 := PROP) affinely (.id rfl) (.forall rfl Affine) where | ||
| spec_intuitionistic _ := affinely_intro .rfl | ||
| spec_spatial _ _ := affinely_intro .rfl | ||
| emp := affinely_intro .rfl | ||
| mono := (affinely_mono ·) | ||
| sep := affinely_sep_2 | ||
|
|
||
| instance : IsModal (PROP1 := PROP) intuitionistically (.id rfl) .isEmpty where | ||
| spec_intuitionistic _ := intuitionistic | ||
| spec_spatial := trivial | ||
| emp := intuitionistic | ||
| mono := (intuitionistically_mono ·) | ||
| sep := intuitionistically_sep_2 | ||
|
|
||
| end Modalities |
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.
@markusdemedeiros I put in the universes here because it may not be obvious that they are required to be the same by this definition. We may need to revisit this; I do not really understand the purpose of this definition but I suspect this is some coq universe shenanigans we'll have to do differently. Let's discuss this on zulip.