Skip to content

Commit de5dc80

Browse files
benbrastmckieclaude
andcommitted
fix: address review findings for PR #636
- Restore LogicalEquivalence typeclass instantiation (HasContext, IsEquiv, Congruence, HasHContext, LogicalEquivalence) following the HML pattern, adapted for Lukasiewicz primitives - Add Proposition.Equiv parametric on model class S with notation - Fix copyright: restore Fabrizio Montesi as co-author on LogicalEquivalence.lean - Fix "fork's" artifact in docstring - Fix "satifies" typo in Basic.lean - Simplify redundant have in t_box_diamond proof Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1c55318 commit de5dc80

2 files changed

Lines changed: 91 additions & 35 deletions

File tree

Cslib/Logics/Modal/Basic.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ theorem Satisfies.diamond_iff_exists {m : Model World Atom} :
187187
theorem Satisfies.and_iff_and {m : Model World Atom} :
188188
⇓Modal[m,w ⊨ φ₁ ∧ φ₂] ↔ ⇓Modal[m,w ⊨ φ₁] ∧ ⇓Modal[m,w ⊨ φ₂] := Satisfies.and_iff
189189

190-
/-- The theory of a world in a model is the set of all propositions that it satifies. -/
190+
/-- The theory of a world in a model is the set of all propositions that it satisfies. -/
191191
abbrev theory (m : Model World Atom) (w : World) : Set (Proposition Atom) :=
192192
{φ | ⇓Modal[m,w ⊨ φ]}
193193

@@ -266,8 +266,7 @@ theorem Satisfies.t_box_diamond [Std.Refl m.r] :
266266
rw [diamond_iff]
267267
exact ⟨w, hrefl, hφ⟩
268268
· intro h hbox
269-
have hφ := hbox w hrefl
270-
exact hφ
269+
exact hbox w hrefl
271270

272271
/-- The B axiom, valid for all symmetric models. -/
273272
theorem Satisfies.b {m : Model World Atom} [instSymm : Std.Symm m.r] {w : World}
Lines changed: 89 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/-
2-
Copyright (c) 2026 Benjamin Brast-McKie. All rights reserved.
2+
Copyright (c) 2026 Fabrizio Montesi, Benjamin Brast-McKie. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
4-
Authors: Benjamin Brast-McKie
4+
Authors: Fabrizio Montesi, Benjamin Brast-McKie
55
-/
66

77
module
88

99
public import Cslib.Logics.Modal.Basic
10+
public import Cslib.Foundations.Logic.LogicalEquivalence
1011

1112
/-! # Logical Equivalence for Modal Propositions
1213
@@ -16,11 +17,10 @@ models and worlds) is a congruence with respect to contexts.
1617
1718
## Main Definitions
1819
19-
* `Proposition.Context` -- a one-hole context matching the fork's `Proposition` constructors
20+
* `Proposition.Context` -- a one-hole context matching the `Proposition` constructors
2021
* `Proposition.Context.fill` -- substitute a proposition into the hole
21-
* `LogicallyEquivalent` -- two propositions are logically equivalent when they are satisfied by
22-
exactly the same model-world pairs
23-
* `LogicallyEquivalent.congruence` -- logical equivalence is preserved under all contexts
22+
* `Proposition.Equiv` -- two propositions are logically equivalent relative to a class of models
23+
* `LogicalEquivalence` -- typeclass instance connecting equivalence, congruence, and validity
2424
2525
## Design Notes
2626
@@ -33,6 +33,27 @@ sub-proposition positions (left and right), and `box` has one. The ground constr
3333

3434
namespace Cslib.Logic.Modal
3535

36+
open scoped InferenceSystem Proposition
37+
38+
/-- Logical equivalence for modal propositions, parametric on a class of models `S`.
39+
Two propositions are equivalent when they are satisfied by the same model-world pairs in `S`. -/
40+
def Proposition.Equiv (S : Set (Model World Atom)) (φ₁ φ₂ : Proposition Atom) : Prop :=
41+
∀ m ∈ S, ∀ w : World, ⇓Modal[m,w ⊨ φ₁] ↔ ⇓Modal[m,w ⊨ φ₂]
42+
43+
scoped notation φ₁ " ≡[" S "] " φ₂ => Proposition.Equiv S φ₁ φ₂
44+
45+
@[simp]
46+
theorem Proposition.equiv_def {S : Set (Model World Atom)}
47+
{φ₁ φ₂ : Proposition Atom} :
48+
(φ₁ ≡[S] φ₂) ↔ ∀ m ∈ S, ∀ w : World, ⇓Modal[m,w ⊨ φ₁] ↔ ⇓Modal[m,w ⊨ φ₂] :=
49+
Iff.rfl
50+
51+
theorem Proposition.equiv_iff {S : Set (Model World Atom)}
52+
{φ₁ φ₂ : Proposition Atom}
53+
(h : φ₁ ≡[S] φ₂) {m : Model World Atom} (hm : m ∈ S) {w : World} :
54+
⇓Modal[m,w ⊨ φ₁] ↔ ⇓Modal[m,w ⊨ φ₂] :=
55+
h m hm w
56+
3657
/-- A one-hole context for `Proposition`. Each constructor corresponds to a recursive position
3758
in `Proposition`: `impL` is the left argument of `imp`, `impR` is the right argument, and `box`
3859
is the argument of `box`. The `hole` constructor marks the position to be filled. -/
@@ -47,37 +68,73 @@ inductive Proposition.Context (Atom : Type u) : Type u where
4768
| box (c : Context Atom)
4869

4970
/-- Fill the hole in a context with a proposition. -/
71+
@[scoped grind =]
5072
def Proposition.Context.fill : Proposition.Context Atom → Proposition Atom → Proposition Atom
5173
| .hole, φ => φ
5274
| .impL c ψ, φ => .imp (c.fill φ) ψ
5375
| .impR ψ c, φ => .imp ψ (c.fill φ)
5476
| .box c, φ => .box (c.fill φ)
5577

56-
/-- Two propositions are logically equivalent when they agree on satisfaction across all models
57-
and worlds. -/
58-
def LogicallyEquivalent.{v} {Atom : Type u} (φ ψ : Proposition Atom) : Prop :=
59-
∀ (World : Type v) (m : Model World Atom) (w : World), Satisfies m w φ ↔ Satisfies m w ψ
60-
61-
/-- Logical equivalence is a congruence: if `φ` and `ψ` are logically equivalent, then
62-
`c.fill φ` and `c.fill ψ` are logically equivalent for any context `c`. -/
63-
theorem LogicallyEquivalent.congruence.{v} {Atom : Type u} {φ ψ : Proposition Atom}
64-
(c : Proposition.Context Atom) (h : LogicallyEquivalent.{v} φ ψ) :
65-
LogicallyEquivalent.{v} (c.fill φ) (c.fill ψ) := by
66-
intro World m
67-
induction c with
68-
| hole => exact h World m
69-
| impL c _ ih =>
70-
intro w
71-
simp only [Proposition.Context.fill, Satisfies]
72-
exact ⟨fun hf ha => hf ((ih w).mpr ha), fun hf ha => hf ((ih w).mp ha)⟩
73-
| impR _ c ih =>
74-
intro w
75-
simp only [Proposition.Context.fill, Satisfies]
76-
exact ⟨fun hf ha => (ih w).mp (hf ha), fun hf ha => (ih w).mpr (hf ha)⟩
77-
| box c ih =>
78-
intro w
79-
simp only [Proposition.Context.fill, Satisfies]
80-
exact ⟨fun hf w' hr => (ih w').mp (hf w' hr),
81-
fun hf w' hr => (ih w').mpr (hf w' hr)⟩
78+
instance : HasContext (Proposition Atom) :=
79+
⟨Proposition.Context Atom, Proposition.Context.fill⟩
80+
81+
@[simp]
82+
theorem Proposition.Context.fill_def (c : Proposition.Context Atom) (φ : Proposition Atom) :
83+
(c : HasContext.Context (Proposition Atom))<[φ] = c.fill φ := rfl
84+
85+
instance : IsEquiv (Proposition Atom)
86+
(Proposition.Equiv (World := World) (S : Set (Model World Atom))) where
87+
refl _ _ _ _ := Iff.rfl
88+
symm _ _ hab m hm w := (hab m hm w).symm
89+
trans _ _ _ hab hbc m hm w := (hab m hm w).trans (hbc m hm w)
90+
91+
instance : Congruence (Proposition Atom)
92+
(Proposition.Equiv (World := World) (S : Set (Model World Atom))) where
93+
elim := by
94+
intro ctx a b hab
95+
change Proposition.Equiv S (ctx.fill a) (ctx.fill b)
96+
intro m hm
97+
induction ctx with
98+
| hole => exact hab m hm
99+
| impL c _ ih =>
100+
intro w
101+
simp only [Proposition.Context.fill, derivation_def, Satisfies]
102+
exact ⟨fun hf ha => hf ((ih w).mpr ha), fun hf ha => hf ((ih w).mp ha)⟩
103+
| impR _ c ih =>
104+
intro w
105+
simp only [Proposition.Context.fill, derivation_def, Satisfies]
106+
exact ⟨fun hf ha => (ih w).mp (hf ha), fun hf ha => (ih w).mpr (hf ha)⟩
107+
| box c ih =>
108+
intro w
109+
simp only [Proposition.Context.fill, derivation_def, Satisfies]
110+
exact ⟨fun hf w' hr => (ih w').mp (hf w' hr),
111+
fun hf w' hr => (ih w').mpr (hf w' hr)⟩
112+
113+
/-- Judgemental contexts for satisfaction. -/
114+
structure Satisfies.Context (World : Type*) (Atom : Type*) where
115+
/-- The class of models. -/
116+
S : Set (Model World Atom)
117+
/-- The model. -/
118+
m : Model World Atom
119+
/-- Evidence that the model belongs to the class. -/
120+
hm : m ∈ S
121+
/-- The world satisfying the proposition. -/
122+
w : World
123+
124+
/-- Fills a judgemental context with a proposition to obtain a judgement. -/
125+
def Satisfies.Context.fill (c : Satisfies.Context World Atom) (φ : Proposition Atom) :
126+
Judgement World Atom :=
127+
⟨c.m, c.w, φ⟩
128+
129+
instance : HasHContext (Judgement World Atom) (Proposition Atom) :=
130+
⟨Satisfies.Context World Atom, Satisfies.Context.fill⟩
131+
132+
instance : LogicalEquivalence
133+
(Proposition Atom) (Judgement World Atom) Satisfies.Bundled where
134+
eqv := Proposition.Equiv Set.univ
135+
eqvFillValid heqv c h := by
136+
change Satisfies c.m c.w _
137+
have h' : Satisfies c.m c.w _ := h
138+
exact (heqv c.m (Set.mem_univ _) c.w).mp h'
82139

83140
end Cslib.Logic.Modal

0 commit comments

Comments
 (0)