-
Notifications
You must be signed in to change notification settings - Fork 152
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
base: main
Are you sure you want to change the base?
Changes from 16 commits
79f99fa
c738be6
a143c5b
a8adb15
ebc723c
0475e2f
b80b8ef
7d22222
8627585
ba8175f
09b5d84
a66500f
8417932
948b847
319e3a8
5fe8be9
6e1b5db
60daa55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,143 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
fmontesi marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (φ₁ ≡[S] φ₂) ↔ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (∀ m ∈ S, ∀ w : World, ⇓Modal[m,w ⊨ φ₁ ↔ φ₂]) := by rfl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+52
to
+60
Collaborator
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /-- 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+85
to
+96
Collaborator
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /-- Logical equivalence is a congruence. -/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| instance (S : Set (Model World Atom)) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Congruence (Proposition Atom) (Proposition.Equiv (Atom := Atom) S) where | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+99
to
+100
Collaborator
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+101
to
+118
Collaborator
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. The fill notation is fighting against
Suggested change
(The first have should be a |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /-- 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+142
to
+147
Collaborator
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. We don't usually provide types like this in an instance, right? There's also another notation lemma that needs to be extracted. See how:
Suggested change
works |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end Cslib.Logic.Modal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Out of scope for this PR, but
derivation_defis written backwards.