Skip to content

Commit e7115d0

Browse files
committed
refactor: Proposition type to Lukasiewicz convention
Introduces bot/imp as primitive Proposition constructors (replacing and/or/impl), adds Connectives.lean typeclass hierarchy for derived connectives, simplifies NaturalDeduction/Basic.lean from 10 rules to 5, and adds ChagrovZakharyaschev1997 reference. Session: sess_1781224549_831844
1 parent 616e04b commit e7115d0

6 files changed

Lines changed: 188 additions & 104 deletions

File tree

Cslib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public import Cslib.Foundations.Data.Relation
6969
public import Cslib.Foundations.Data.Set.Saturation
7070
public import Cslib.Foundations.Data.StackTape
7171
public import Cslib.Foundations.Lint.Basic
72+
public import Cslib.Foundations.Logic.Connectives
7273
public import Cslib.Foundations.Logic.InferenceSystem
7374
public import Cslib.Foundations.Logic.LogicalEquivalence
7475
public import Cslib.Foundations.Semantics.FLTS.Basic
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/-
2+
Copyright (c) 2026 Benjamin Brast-McKie. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Benjamin Brast-McKie
5+
-/
6+
7+
module
8+
9+
import Cslib.Init
10+
11+
/-! # Connective Typeclasses for Composable Logics
12+
13+
This module defines a typeclass hierarchy for logical connectives, shared across the four
14+
logic levels (Propositional, Modal, Temporal, Bimodal). Each formula type registers itself
15+
as an instance of the appropriate connective class, enabling polymorphic axiom definitions
16+
and notation.
17+
18+
## Design
19+
20+
The hierarchy follows the Foundation pattern (FormalizedFormalLogic/Foundation):
21+
- **Atomic classes**: `HasBot`, `HasImp`, `HasBox`, `HasUntil`, `HasSince`
22+
- **Bundled classes**: `PropositionalConnectives`, `ModalConnectives`,
23+
`TemporalConnectives`, `BimodalConnectives`
24+
- **Derived connectives**: `LukasiewiczDerived` for `neg`, `top`, `or`, `and` from `bot`/`imp`
25+
26+
Each concrete formula type duplicates its constructors (Lean 4 cannot extend inductives)
27+
and registers as an instance of the appropriate bundled class.
28+
-/
29+
30+
@[expose] public section
31+
32+
namespace Cslib.Logic
33+
34+
/-- A type has a falsum (bottom) connective. -/
35+
class HasBot (F : Type*) where
36+
/-- The falsum/bottom connective. -/
37+
bot : F
38+
39+
/-- A type has an implication connective. -/
40+
class HasImp (F : Type*) where
41+
/-- The implication connective. -/
42+
imp : F → F → F
43+
44+
/-- A type has a necessity (box) modality. -/
45+
class HasBox (F : Type*) where
46+
/-- The necessity/box modality. -/
47+
box : F → F
48+
49+
/-- A type has an until temporal operator. -/
50+
class HasUntil (F : Type*) where
51+
/-- The until temporal operator. -/
52+
untl : F → F → F
53+
54+
/-- A type has a since temporal operator. -/
55+
class HasSince (F : Type*) where
56+
/-- The since temporal operator. -/
57+
snce : F → F → F
58+
59+
/-- Propositional connectives: falsum and implication. -/
60+
class PropositionalConnectives (F : Type*) extends HasBot F, HasImp F
61+
62+
/-- Modal connectives: propositional connectives plus necessity. -/
63+
class ModalConnectives (F : Type*) extends PropositionalConnectives F, HasBox F
64+
65+
/-- Temporal connectives: propositional connectives plus until and since. -/
66+
class TemporalConnectives (F : Type*) extends PropositionalConnectives F, HasUntil F, HasSince F
67+
68+
/-- Bimodal connectives: modal connectives plus until and since.
69+
Note: we extend `ModalConnectives` and add `HasUntil`/`HasSince` directly
70+
rather than extending `TemporalConnectives`, to avoid a typeclass diamond. -/
71+
class BimodalConnectives (F : Type*) extends ModalConnectives F, HasUntil F, HasSince F
72+
73+
/-- Lukasiewicz-style derived connectives from `bot` and `imp`.
74+
75+
Provides `neg`, `top`, `or`, `and` as abbreviations following the standard Lukasiewicz
76+
encoding: negation is implication to falsum, verum is `bot → bot`, disjunction is
77+
`¬φ → ψ`, and conjunction is `¬(φ → ¬ψ)`.
78+
79+
**Status**: This class is intentionally uninstantiated. Each concrete formula type
80+
(PL.Proposition, Modal.Proposition, Temporal.Formula, Bimodal.Formula) defines its
81+
own `abbrev` connectives directly on the inductive constructors, which are
82+
definitionally equal to these defaults. Registering typeclass instances would add
83+
resolution overhead at every use site with no benefit, since the `abbrev` definitions
84+
already compute. The class is retained as a specification artifact and for potential
85+
future use in polymorphic proof-system abstractions that need to quantify over derived
86+
connectives generically. -/
87+
class LukasiewiczDerived (F : Type*) [HasBot F] [HasImp F] where
88+
/-- Negation: `neg φ := imp φ bot` -/
89+
neg : F → F := fun φ => HasImp.imp φ HasBot.bot
90+
/-- Top/verum: `top := imp bot bot` -/
91+
top : F := HasImp.imp HasBot.bot HasBot.bot
92+
/-- Disjunction: `or φ ψ := imp (neg φ) ψ` where `neg φ := imp φ bot` -/
93+
or : F → F → F := fun φ ψ => HasImp.imp (HasImp.imp φ HasBot.bot) ψ
94+
/-- Conjunction: `and φ ψ := neg (imp φ (neg ψ))` -/
95+
and : F → F → F := fun φ ψ =>
96+
HasImp.imp (HasImp.imp φ (HasImp.imp ψ HasBot.bot)) HasBot.bot
97+
98+
end Cslib.Logic

Cslib/Foundations/Logic/InferenceSystem.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Authors: Fabrizio Montesi
66

77
module
88

9-
public import Cslib.Init
9+
import Cslib.Init
1010

11-
/-! -/
11+
/-! # Inference System Typeclass -/
1212

1313
@[expose] public section
1414

Cslib/Logics/Propositional/Defs.lean

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
/-
2-
Copyright (c) 2025 Thomas Waring. All rights reserved.
2+
Copyright (c) 2025 Thomas Waring, 2026 Benjamin Brast-McKie. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
4-
Authors: Thomas Waring
4+
Authors: Thomas Waring, Benjamin Brast-McKie
55
-/
66

77
module
88

99
public import Cslib.Init
10+
public import Cslib.Foundations.Logic.Connectives
1011
public import Mathlib.Data.FunLike.Basic
11-
public import Mathlib.Data.Set.Image
12+
public import Mathlib.Data.Set.Basic
1213
public import Mathlib.Order.TypeTags
1314

1415
/-! # Propositions and theories
1516
1617
## Main definitions
1718
18-
- `Proposition` : the type of propositions over a given type of atom. This type has a `Bot`
19-
instance whenever `Atom` does, and a `Top` whenever `Atom` is inhabited.
19+
- `Proposition` : the type of propositions over a given type of atom. Primitives are `atom`,
20+
`bot` (falsum), and `imp` (implication). Conjunction, disjunction, negation, and verum are
21+
derived connectives following the Lukasiewicz convention.
2022
- `Theory` : set of `Proposition`.
2123
- `IsIntuitionistic` : a theory is intuitionistic if it contains the principle of explosion.
2224
- `IsClassical` : an intuitionistic theory is classical if it further contains double negation
@@ -42,44 +44,54 @@ variable {Atom : Type u} [DecidableEq Atom]
4244

4345
namespace Cslib.Logic.PL
4446

45-
/-- Propositions. -/
47+
/-- Propositions. Primitives are atoms, falsum, and implication. -/
4648
inductive Proposition (Atom : Type u) : Type u where
4749
/-- Propositional atoms -/
4850
| atom (x : Atom)
49-
/-- Conjunction -/
50-
| and (a b : Proposition Atom)
51-
/-- Disjunction -/
52-
| or (a b : Proposition Atom)
51+
/-- Falsum / bottom -/
52+
| bot
5353
/-- Implication -/
54-
| impl (a b : Proposition Atom)
54+
| imp (a b : Proposition Atom)
5555
deriving DecidableEq, BEq
5656

57-
instance instBotProposition [Bot Atom] : Bot (Proposition Atom) := ⟨.atom ⊥⟩
58-
instance instInhabitedOfBot [Bot Atom] : Inhabited Atom := ⟨⊥⟩
57+
/-- Negation as a derived connective: ¬A := A → ⊥ -/
58+
abbrev Proposition.neg : Proposition Atom → Proposition Atom := (Proposition.imp · .bot)
5959

60-
/-- We view negation as a defined connective ~A := A → ⊥ -/
61-
abbrev Proposition.neg [Bot Atom] : Proposition Atom → Proposition Atom := (Proposition.impl · ⊥)
60+
/-- Verum / top as a derived connective: ⊤ := → ⊥ -/
61+
abbrev Proposition.top : Proposition Atom := .imp .bot .bot
6262

63-
/-- A fixed choice of a derivable proposition (of course any two are equivalent). -/
64-
abbrev Proposition.top [Inhabited Atom] : Proposition Atom := impl (.atom default) (.atom default)
63+
/-- Disjunction as a derived connective: A ∨ B := ¬A → B -/
64+
abbrev Proposition.or (A B : Proposition Atom) : Proposition Atom :=
65+
.imp (.imp A .bot) B
6566

66-
instance instTopProposition [Inhabited Atom] : Top (Proposition Atom) := ⟨.top⟩
67+
/-- Conjunction as a derived connective: A ∧ B := ¬(A → ¬B) -/
68+
abbrev Proposition.and (A B : Proposition Atom) : Proposition Atom :=
69+
.imp (.imp A (.imp B .bot)) .bot
6770

68-
example [Bot Atom] : (⊤ : Proposition Atom) = Proposition.impl ⊥ ⊥ := rfl
71+
/-- Biconditional as a derived connective: A ↔ B := (A → B) ∧ (B → A) -/
72+
abbrev Proposition.iff (A B : Proposition Atom) : Proposition Atom :=
73+
(A.imp B).and (B.imp A)
74+
75+
instance : Bot (Proposition Atom) := ⟨.bot⟩
76+
instance : Top (Proposition Atom) := ⟨.top⟩
6977

7078
@[inherit_doc] scoped infix:36 " ∧ " => Proposition.and
7179
@[inherit_doc] scoped infix:35 " ∨ " => Proposition.or
72-
@[inherit_doc] scoped infix:30 " → " => Proposition.impl
80+
@[inherit_doc] scoped infix:30 " → " => Proposition.imp
7381
@[inherit_doc] scoped prefix:40 " ¬ " => Proposition.neg
7482

83+
/-- Register `Proposition` as an instance of `PropositionalConnectives`. -/
84+
instance : PropositionalConnectives (Proposition Atom) where
85+
bot := .bot
86+
imp := .imp
87+
7588
/-- Substitute each atom in a proposition for a proposition, possibly changing the atomic
7689
language. -/
7790
def Proposition.subst {Atom Atom' : Type u} (f : Atom → Proposition Atom') :
7891
Proposition Atom → Proposition Atom'
7992
| atom x => f x
80-
| and A B => (A.subst f) ∧ (B.subst f)
81-
| or A B => (A.subst f) ∨ (B.subst f)
82-
| impl A B => (A.subst f) → (B.subst f)
93+
| bot => .bot
94+
| imp A B => .imp (A.subst f) (B.subst f)
8395

8496
-- This is probably a lawful monad, but that doesn't seem to be important.
8597
instance : Monad Proposition where
@@ -102,45 +114,45 @@ instance : Functor Theory where
102114
abbrev MPL : Theory (Atom) := ∅
103115

104116
/-- Intuitionistic propositional logic adds the principle of explosion (ex falso quodlibet). -/
105-
abbrev IPL [Bot Atom] : Theory Atom :=
106-
Set.range (⊥ → ·)
117+
abbrev IPL : Theory Atom :=
118+
Set.range (Proposition.imp ⊥ ·)
107119

108120
/-- Classical logic further adds double negation elimination. -/
109-
abbrev CPL [Bot Atom] : Theory Atom :=
121+
abbrev CPL : Theory Atom :=
110122
Set.range (fun (A : Proposition Atom) ↦ ¬¬A → A)
111123

112124
/-- A theory is intuitionistic if it validates ex falso quodlibet. -/
113125
@[scoped grind]
114-
class IsIntuitionistic [Bot Atom] (T : Theory Atom) where
126+
class IsIntuitionistic (T : Theory Atom) where
115127
efq (A : Proposition Atom) : (⊥ → A) ∈ T
116128

117129
omit [DecidableEq Atom] in
118130
@[scoped grind =]
119-
theorem isIntuitionisticIff [Bot Atom] (T : Theory Atom) : IsIntuitionistic T ↔ IPL ⊆ T := by grind
131+
theorem isIntuitionisticIff (T : Theory Atom) : IsIntuitionistic T ↔ IPL ⊆ T := by grind
120132

121133
/-- A theory is classical if it validates double-negation elimination. -/
122134
@[scoped grind]
123-
class IsClassical [Bot Atom] (T : Theory Atom) where
135+
class IsClassical (T : Theory Atom) where
124136
dne (A : Proposition Atom) : (¬¬A → A) ∈ T
125137

126138
omit [DecidableEq Atom] in
127139
@[scoped grind =]
128-
theorem isClassicalIff [Bot Atom] (T : Theory Atom) : IsClassical T ↔ CPL ⊆ T := by grind
140+
theorem isClassicalIff (T : Theory Atom) : IsClassical T ↔ CPL ⊆ T := by grind
129141

130-
instance instIsIntuitionisticIPL [Bot Atom] : IsIntuitionistic (Atom := Atom) IPL where
142+
instance instIsIntuitionisticIPL : IsIntuitionistic (Atom := Atom) IPL where
131143
efq A := Set.mem_range.mpr ⟨A, rfl⟩
132144

133-
instance instIsClassicalCPL [Bot Atom] : IsClassical (Atom := Atom) CPL where
145+
instance instIsClassicalCPL : IsClassical (Atom := Atom) CPL where
134146
dne A := Set.mem_range.mpr ⟨A, rfl⟩
135147

136148
omit [DecidableEq Atom] in
137149
@[scoped grind →]
138-
theorem instIsIntuitionisticExtention [Bot Atom] {T T' : Theory Atom} [IsIntuitionistic T]
150+
theorem instIsIntuitionisticExtention {T T' : Theory Atom} [IsIntuitionistic T]
139151
(h : T ⊆ T') : IsIntuitionistic T' := by grind
140152

141153
omit [DecidableEq Atom] in
142154
@[scoped grind →]
143-
theorem instIsClassicalExtention [Bot Atom] {T T' : Theory Atom} [IsClassical T] (h : T ⊆ T') :
155+
theorem instIsClassicalExtention {T T' : Theory Atom} [IsClassical T] (h : T ⊆ T') :
144156
IsClassical T' := by grind
145157

146158
/-- Attach a bottom element to a theory `T`, and the principle of explosion for that bottom. -/

0 commit comments

Comments
 (0)