-
Notifications
You must be signed in to change notification settings - Fork 150
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
Open
fmontesi
wants to merge
18
commits into
main
Choose a base branch
from
modal-equiv
base: main
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.
+169
−11
Open
Changes from all commits
Commits
Show all changes
18 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 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,149 @@ | ||
| /- | ||
| 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 | ||
| apply Iff.intro <;> intro h' | ||
| · simp_all only [valid] | ||
| intro m hin w | ||
| specialize h m hin w | ||
| grind | ||
| · simp_all only [valid] | ||
| intro m hin w | ||
| specialize h m hin w | ||
| 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⟩ | ||
|
|
||
| open scoped Proposition Proposition.Context | ||
|
|
||
| /-- Logical equivalence is an equivalence relation. -/ | ||
| instance (S : Set (Model World Atom)) : | ||
| IsEquiv (Proposition Atom) (Proposition.Equiv (Atom := Atom) S) where | ||
| refl := by grind | ||
| symm := by | ||
| intro φ₁ φ₂ h m hₘ w | ||
| specialize h m hₘ w | ||
| grind | ||
| trans := by | ||
| intro φ₁ φ₂ φ₃ h₁ h₂ m hₘ w | ||
| specialize h₁ m hₘ w | ||
| specialize h₂ m hₘ w | ||
| grind | ||
|
|
||
| /-- Logical equivalence is a congruence. -/ | ||
| instance (S : Set (Model World Atom)) : | ||
| Congruence (Proposition Atom) (Proposition.Equiv (Atom := Atom) S) where | ||
| elim : | ||
| Covariant (Proposition.Context Atom) (Proposition Atom) (Proposition.Context.fill) | ||
| (Proposition.Equiv S) := by | ||
| intro ctx φ₁ φ₂ heqv m hₘ w | ||
| specialize heqv m hₘ | ||
| 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 => | ||
| simp only [Satisfies.iff_iff_iff] | ||
| apply Iff.intro | ||
| all_goals | ||
| intro h | ||
| rcases h with ⟨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 where | ||
| m := c.m | ||
| w := c.w | ||
| φ := φ | ||
|
|
||
| instance judgementalContext : | ||
| HasHContext (Judgement World Atom) (Proposition Atom) := | ||
| ⟨Satisfies.Context World Atom, Satisfies.Context.fill⟩ | ||
|
|
||
| /-- 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 {φ₁ φ₂ : Proposition Atom} (heqv : φ₁ ≡[Set.univ] φ₂) | ||
| (c : HasHContext.Context (Judgement World Atom) (Proposition Atom)) | ||
| (h : ⇓c<[φ₁]) : ⇓c<[φ₂] := by | ||
| simp only [HasHContext.fill, Satisfies.Context.fill] at ⊢ h | ||
| 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.