Skip to content

feat: logical equivalence for modal logic#535

Open
fmontesi wants to merge 18 commits into
mainfrom
modal-equiv
Open

feat: logical equivalence for modal logic#535
fmontesi wants to merge 18 commits into
mainfrom
modal-equiv

Conversation

@fmontesi
Copy link
Copy Markdown
Collaborator

@fmontesi fmontesi commented May 2, 2026

Adds logical equivalence for modal logic, proving that it is a Congruence (for any modal logic, regardless of the class of models considered) and a LogicalEquivalence (for logic K, i.e., when considering the class of all models).

The PR also renames Proposition.neg to Proposition.not and adds a useful lemma on Proposition.iff.

Depends on #528.

@fmontesi fmontesi requested a review from chenson2018 as a code owner May 2, 2026 12:43
@fmontesi fmontesi added the logic label May 2, 2026
Copy link
Copy Markdown
Collaborator

@thomaskwaring thomaskwaring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some minor comments but lgtm on the whole!

Comment thread Cslib/Logics/Modal/Basic.lean
Comment thread Cslib/Logics/Modal/LogicalEquivalence.lean
Comment thread Cslib/Logics/Modal/LogicalEquivalence.lean
@fmontesi
Copy link
Copy Markdown
Collaborator Author

Thanks, @thomaskwaring. All done!

@fmontesi fmontesi enabled auto-merge May 31, 2026 11:49
theorem Satisfies.iff_iff_iff {m : Model World Atom} :
⇓Modal[m,w ⊨ φ₁ ↔ φ₂] ↔ (⇓Modal[m,w ⊨ φ₁] ↔ ⇓Modal[m,w ⊨ φ₂]) := by
simp only [Proposition.iff]
grind [=_ derivation_def]
Copy link
Copy Markdown
Collaborator

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_def is written backwards.

Comment on lines +85 to +96
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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
instance {World Atom} (S : Set (Model World Atom)) : IsEquiv (Proposition Atom) (Proposition.Equiv S) := by
rw [← equivalence_iff_isEquiv]
grind [Equivalence]

Comment on lines +52 to +60
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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
grind

Comment on lines +99 to +100
instance (S : Set (Model World Atom)) :
Congruence (Proposition Atom) (Proposition.Equiv (Atom := Atom) S) where
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
instance (S : Set (Model World Atom)) :
Congruence (Proposition Atom) (Proposition.Equiv (Atom := Atom) S) where
instance {World Atom} (S : Set (Model World Atom)) : Congruence (Proposition Atom) (Proposition.Equiv S) where

Comment on lines +101 to +118
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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fill notation is fighting against grind here. See how this works:

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
elim ctx φ₁ φ₂ heqv m hₘ w := by
have (Γ : HasContext.Context (Proposition Atom)) (φ) : Γ.fill φ = Γ<[φ] := rfl
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

(The first have should be a grind lemma somewhere.)

Comment on lines +142 to +147
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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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
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
eqvFillValid heqv c h := by
have (φ : Proposition Atom) : Modal[c.m,c.w ⊨ φ] = c<[φ] := rfl
specialize heqv c.m
grind

works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants