-
Notifications
You must be signed in to change notification settings - Fork 159
feat: logical equivalence for modal logic #535
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
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
79f99fa
Modal Logic
fmontesi c738be6
Update Cslib/Foundations/Data/Relation.lean
fmontesi a143c5b
Update Cslib/Foundations/Data/Relation.lean
fmontesi a8adb15
reducible fix
fmontesi ebc723c
Classical.arbitrary
fmontesi 0475e2f
fix refl_serial
fmontesi b80b8ef
Modal notation
fmontesi 7d22222
review fixes
fmontesi 8627585
rename _char theorems
fmontesi ba8175f
Logical Equivalence for Modal Logic
fmontesi 09b5d84
modules
fmontesi a66500f
Use union and set inclusion
fmontesi 8417932
subset
fmontesi 948b847
Merge branch 'main' into modal-equiv
fmontesi 319e3a8
Merge branch 'main' into modal-equiv
fmontesi 5fe8be9
fix eqvFillValid name
fmontesi 6e1b5db
iff_iff_iff
fmontesi 60daa55
iff_equiv
fmontesi 4e6a47f
Update Cslib/Logics/Modal/LogicalEquivalence.lean
fmontesi 3881ade
Update Cslib/Logics/Modal/LogicalEquivalence.lean
fmontesi b9f946d
Update Cslib/Logics/Modal/LogicalEquivalence.lean
fmontesi 4957128
Update Cslib/Logics/Modal/LogicalEquivalence.lean
fmontesi bd895b7
Update Cslib/Logics/Modal/LogicalEquivalence.lean
fmontesi d7ba18e
char limit
fmontesi de8a1ca
extract lemmas
fmontesi f87d6ce
fix derivation_def
fmontesi 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
Some comments aren't visible on the classic Files Changed page.
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
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,132 @@ | ||
| /- | ||
| Copyright (c) 2026 Fabrizio Montesi. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Fabrizio Montesi | ||
| -/ | ||
|
|
||
| module | ||
|
|
||
| public import Cslib.Logics.Modal.Basic | ||
| public import Cslib.Foundations.Logic.LogicalEquivalence | ||
|
|
||
| /-! # Logical Equivalence in Modal Logic | ||
|
|
||
| This module defines logical equivalence for modal propositions. | ||
| The definitions are parametric on the class of models under consideration. | ||
|
|
||
| We also instantiate `LogicalEquivalence` for Modal Logic K, i.e., equivalence | ||
| for the class of all models. | ||
| -/ | ||
|
|
||
| @[expose] public section | ||
|
|
||
| namespace Cslib.Logic.Modal | ||
|
|
||
| open scoped InferenceSystem Proposition Satisfies | ||
|
|
||
| /-- The modal propositions `φ₁` and `φ₂` are equivalent in the class of models `S`. -/ | ||
| def Proposition.Equiv (S : Set (Model World Atom)) (φ₁ φ₂ : Proposition Atom) | ||
| : Prop := | ||
| ∀ m ∈ S, ∀ w : World, ⇓Modal[m,w ⊨ φ₁ ↔ φ₂] | ||
|
|
||
| @[inherit_doc] | ||
| scoped notation φ₁ " ≡[" S "] " φ₂ => Proposition.Equiv S φ₁ φ₂ | ||
|
|
||
| @[inherit_doc] | ||
| scoped notation φ₁ " ≡ " φ₂ => Proposition.Equiv Set.univ φ₁ φ₂ | ||
|
|
||
| @[scoped grind =] | ||
| theorem Proposition.equiv_def (S : Set (Model World Atom)) (φ₁ φ₂ : Proposition Atom) : | ||
| (φ₁ ≡[S] φ₂) ↔ | ||
| (∀ m ∈ S, ∀ w : World, ⇓Modal[m,w ⊨ φ₁ ↔ φ₂]) := by rfl | ||
|
|
||
| @[scoped grind =] | ||
| theorem Proposition.equiv_iff (S : Set (Model World Atom)) (φ₁ φ₂ : Proposition Atom) : | ||
| (φ₁ ≡[S] φ₂) ↔ | ||
| (∀ m ∈ S, ∀ w : World, ⇓Modal[m,w ⊨ φ₁] ↔ ⇓Modal[m,w ⊨ φ₂]) := by | ||
| simp [Proposition.equiv_def, Satisfies.iff_iff_iff] | ||
|
|
||
| theorem Proposition.equiv_valid (S : Set (Model World Atom)) | ||
| (φ₁ φ₂ : Proposition Atom) (h : φ₁ ≡[S] φ₂) : | ||
| (φ₁.valid S ↔ φ₂.valid S) := by | ||
| grind | ||
|
|
||
| /-- Propositional contexts. -/ | ||
| inductive Proposition.Context (Atom : Type u) : Type u where | ||
| | hole | ||
| | not (c : Context Atom) | ||
| | andL (c : Context Atom) (φ : Proposition Atom) | ||
| | andR (φ : Proposition Atom) (c : Context Atom) | ||
| | diamond (c : Context Atom) | ||
|
|
||
| /-- Replaces a hole in a propositional context with a proposition. -/ | ||
| @[scoped grind =] | ||
| def Proposition.Context.fill (c : Context Atom) (φ : Proposition Atom) := | ||
| match c with | ||
| | hole => φ | ||
| | not c => .not (c.fill φ) | ||
| | andL c φ' => (c.fill φ).and φ' | ||
| | andR φ' c => φ'.and (c.fill φ) | ||
| | diamond c => .diamond (c.fill φ) | ||
|
|
||
| instance : HasContext (Proposition Atom) := ⟨Proposition.Context Atom, Proposition.Context.fill⟩ | ||
|
|
||
| @[scoped grind =_] | ||
| lemma Proposition.Context.fill_def {Γ : HasContext.Context (Proposition Atom)} : | ||
| Γ.fill φ = Γ<[φ] := rfl | ||
|
|
||
| open scoped Proposition Proposition.Context | ||
|
|
||
| /-- Logical equivalence is an equivalence relation. -/ | ||
| instance {World Atom} (S : Set (Model World Atom)) : | ||
| IsEquiv (Proposition Atom) (Proposition.Equiv S) := by | ||
| rw [← equivalence_iff_isEquiv] | ||
| grind [Equivalence] | ||
|
|
||
| /-- Logical equivalence is a congruence. -/ | ||
| instance {World Atom} (S : Set (Model World Atom)) : | ||
| Congruence (Proposition Atom) (Proposition.Equiv S) where | ||
| elim ctx φ₁ φ₂ heqv m hₘ w := by | ||
| induction ctx generalizing w | ||
| case hole => grind | ||
| case not c ih | andL c ih | andR c ih => | ||
| specialize ih w | ||
| grind | ||
| case diamond c ih => | ||
| rw [Satisfies.iff_iff_iff] | ||
| apply Iff.intro | ||
| all_goals | ||
| rintro ⟨w', h⟩ | ||
| specialize ih w' | ||
| grind | ||
|
|
||
| /-- Judgemental contexts. -/ | ||
| structure Satisfies.Context (World Atom : Type*) where | ||
| /-- The model to consider. -/ | ||
| m : Model World Atom | ||
| /-- The world to check propositions against. -/ | ||
| w : World | ||
|
|
||
| /-- Fills a judgemental context with a proposition. -/ | ||
| def Satisfies.Context.fill (c : Satisfies.Context World Atom) (φ : Proposition Atom) : | ||
| Judgement World Atom := Modal[c.m, c.w ⊨ φ] | ||
|
|
||
| instance judgementalContext : | ||
| HasHContext (Judgement World Atom) (Proposition Atom) := | ||
| ⟨Satisfies.Context World Atom, Satisfies.Context.fill⟩ | ||
|
|
||
| @[scoped grind =_] | ||
| lemma Satisfies.Context.fill_def {c : Satisfies.Context World Atom} : | ||
| Modal[c.m,c.w ⊨ φ] = c<[φ] := rfl | ||
|
|
||
| open scoped Satisfies.Context | ||
|
|
||
| /-- Logical equivalence for Modal Logic K. That is, no assumptions on models are made. -/ | ||
|
fmontesi marked this conversation as resolved.
|
||
| instance : LogicalEquivalence | ||
| (Proposition Atom) (Judgement World Atom) Satisfies.Bundled where | ||
| eqv := Proposition.Equiv Set.univ | ||
| eqvFillValid heqv c h := by | ||
| specialize heqv c.m | ||
| grind | ||
|
|
||
| end Cslib.Logic.Modal | ||
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.
Uh oh!
There was an error while loading. Please reload this page.