Skip to content

Commit 3ab8023

Browse files
committed
refactor: Proposition to bot/imp primitive basis
Refactor the propositional `Proposition` to `{atom, bot, imp}` primitives, with negation, conjunction, disjunction, and verum as derived `abbrev`s. `{imp, bot}` is functionally complete for classical logic, so the other connectives are definable rather than postulated: this keeps the inductive minimal (fewer cases in every recursion and induction) and lets the derived connectives unfold definitionally, so reasoning about them needs no separate axioms or bridging lemmas. - Add `Cslib/Foundations/Logic/Connectives.lean`: the connective typeclass hierarchy (`HasBot`, `HasImp`, `HasBox`, `HasUntil`, `HasSince`; bundled `PropositionalConnectives`/`ModalConnectives`/`TemporalConnectives`/ `BimodalConnectives`; and `ImpBotDerived` for the derived-connective defaults). - Replace `and`/`or`/`impl` constructors with `bot`/`imp` in `Propositional/Defs.lean`; update `complexity`, `atoms`, and `subst`. - Cut the natural-deduction rules from 10 to 5; the derived-connective rules become derivable rather than primitive. - Add bibliography entries (Church, Gentzen, Heyting, Chagrov & Zakharyaschev, Prawitz, Troelstra & van Dalen).
1 parent 616e04b commit 3ab8023

6 files changed

Lines changed: 266 additions & 109 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: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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**: `ImpBotDerived` 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+
Falsum and implication are taken as the only propositional primitives because `{imp, bot}`
30+
is functionally complete for classical logic: every other connective is definable, so it can
31+
be a derived `abbrev` rather than a constructor. This keeps the inductive formula types as
32+
small as possible -- minimising the case count in every recursion and induction over formulas
33+
-- and lets the derived connectives unfold to `imp`/`bot` definitionally, so reasoning about
34+
`¬`, `∧`, `∨`, and `↔` needs no separate axioms or bridging lemmas.
35+
36+
## References
37+
38+
* [A. Church, *Introduction to Mathematical Logic*][Church1956]
39+
* [A. Heyting, *Die formalen Regeln der intuitionistischen Logik*][Heyting1930]
40+
* [G. Gentzen, *Untersuchungen über das logische Schließen*][Gentzen1935]
41+
* [A. Chagrov, M. Zakharyaschev, *Modal Logic*][ChagrovZakharyaschev1997], Chapter 1
42+
-/
43+
44+
@[expose] public section
45+
46+
namespace Cslib.Logic
47+
48+
/-- A type has a falsum (bottom) connective. -/
49+
class HasBot (F : Type*) where
50+
/-- The falsum/bottom connective. -/
51+
bot : F
52+
53+
/-- A type has an implication connective. -/
54+
class HasImp (F : Type*) where
55+
/-- The implication connective. -/
56+
imp : F → F → F
57+
58+
/-- A type has a necessity (box) modality. -/
59+
class HasBox (F : Type*) where
60+
/-- The necessity/box modality. -/
61+
box : F → F
62+
63+
/-- A type has an until temporal operator. -/
64+
class HasUntil (F : Type*) where
65+
/-- The until temporal operator. -/
66+
untl : F → F → F
67+
68+
/-- A type has a since temporal operator. -/
69+
class HasSince (F : Type*) where
70+
/-- The since temporal operator. -/
71+
snce : F → F → F
72+
73+
/-- Propositional connectives: falsum and implication. -/
74+
class PropositionalConnectives (F : Type*) extends HasBot F, HasImp F
75+
76+
/-- Modal connectives: propositional connectives plus necessity. -/
77+
class ModalConnectives (F : Type*) extends PropositionalConnectives F, HasBox F
78+
79+
/-- Temporal connectives: propositional connectives plus until and since. -/
80+
class TemporalConnectives (F : Type*) extends PropositionalConnectives F, HasUntil F, HasSince F
81+
82+
/-- Bimodal connectives: modal connectives plus until and since.
83+
Note: we extend `ModalConnectives` and add `HasUntil`/`HasSince` directly
84+
rather than extending `TemporalConnectives`, to avoid a typeclass diamond. -/
85+
class BimodalConnectives (F : Type*) extends ModalConnectives F, HasUntil F, HasSince F
86+
87+
/-- Derived connectives definable from `bot` and `imp` alone.
88+
89+
Provides `neg`, `top`, `or`, `and` as abbreviations: negation is implication to falsum
90+
(`neg φ := imp φ bot`), verum is `imp bot bot`, disjunction is `imp (neg φ) ψ`, and conjunction
91+
is `neg (imp φ (neg ψ))`. These are forced once `{imp, bot}` is fixed as the primitive basis --
92+
each is the truth-functional definition of the connective in terms of implication and falsum --
93+
so the choice carries no information beyond the basis itself.
94+
95+
**Status**: This class is intentionally uninstantiated. Each concrete formula type
96+
(PL.Proposition, Modal.Proposition, Temporal.Formula, Bimodal.Formula) defines its
97+
own `abbrev` connectives directly on the inductive constructors, which are
98+
definitionally equal to these defaults. Registering typeclass instances would add
99+
resolution overhead at every use site with no benefit, since the `abbrev` definitions
100+
already compute. The class is retained as a specification artifact and for potential
101+
future use in polymorphic proof-system abstractions that need to quantify over derived
102+
connectives generically. -/
103+
class ImpBotDerived (F : Type*) [HasBot F] [HasImp F] where
104+
/-- Negation: `neg φ := imp φ bot` -/
105+
neg : F → F := fun φ => HasImp.imp φ HasBot.bot
106+
/-- Top/verum: `top := imp bot bot` -/
107+
top : F := HasImp.imp HasBot.bot HasBot.bot
108+
/-- Disjunction: `or φ ψ := imp (neg φ) ψ` where `neg φ := imp φ bot` -/
109+
or : F → F → F := fun φ ψ => HasImp.imp (HasImp.imp φ HasBot.bot) ψ
110+
/-- Conjunction: `and φ ψ := neg (imp φ (neg ψ))` -/
111+
and : F → F → F := fun φ ψ =>
112+
HasImp.imp (HasImp.imp φ (HasImp.imp ψ HasBot.bot)) HasBot.bot
113+
114+
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: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
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); since `{imp, bot}` is functionally complete for
21+
classical logic, conjunction, disjunction, negation, and verum are derived connectives
22+
(`abbrev`s) rather than constructors, keeping the inductive minimal.
2023
- `Theory` : set of `Proposition`.
2124
- `IsIntuitionistic` : a theory is intuitionistic if it contains the principle of explosion.
2225
- `IsClassical` : an intuitionistic theory is classical if it further contains double negation
@@ -32,6 +35,11 @@ theory.
3235
3336
We introduce notation for the logical connectives: `⊥ ⊤ ∧ ∨ → ¬` for, respectively, falsum, verum,
3437
conjunction, disjunction, implication and negation.
38+
39+
## References
40+
41+
* [A. Church, *Introduction to Mathematical Logic*][Church1956]
42+
* [A. Chagrov, M. Zakharyaschev, *Modal Logic*][ChagrovZakharyaschev1997], Chapter 1
3543
-/
3644

3745
@[expose] public section
@@ -42,44 +50,54 @@ variable {Atom : Type u} [DecidableEq Atom]
4250

4351
namespace Cslib.Logic.PL
4452

45-
/-- Propositions. -/
53+
/-- Propositions. Primitives are atoms, falsum, and implication. -/
4654
inductive Proposition (Atom : Type u) : Type u where
4755
/-- Propositional atoms -/
4856
| atom (x : Atom)
49-
/-- Conjunction -/
50-
| and (a b : Proposition Atom)
51-
/-- Disjunction -/
52-
| or (a b : Proposition Atom)
57+
/-- Falsum / bottom -/
58+
| bot
5359
/-- Implication -/
54-
| impl (a b : Proposition Atom)
60+
| imp (a b : Proposition Atom)
5561
deriving DecidableEq, BEq
5662

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

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

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)
69+
/-- Disjunction as a derived connective: A ∨ B := ¬A → B -/
70+
abbrev Proposition.or (A B : Proposition Atom) : Proposition Atom :=
71+
.imp (.imp A .bot) B
6572

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

68-
example [Bot Atom] : (⊤ : Proposition Atom) = Proposition.impl ⊥ ⊥ := rfl
77+
/-- Biconditional as a derived connective: A ↔ B := (A → B) ∧ (B → A) -/
78+
abbrev Proposition.iff (A B : Proposition Atom) : Proposition Atom :=
79+
(A.imp B).and (B.imp A)
80+
81+
instance : Bot (Proposition Atom) := ⟨.bot⟩
82+
instance : Top (Proposition Atom) := ⟨.top⟩
6983

7084
@[inherit_doc] scoped infix:36 " ∧ " => Proposition.and
7185
@[inherit_doc] scoped infix:35 " ∨ " => Proposition.or
72-
@[inherit_doc] scoped infix:30 " → " => Proposition.impl
86+
@[inherit_doc] scoped infix:30 " → " => Proposition.imp
7387
@[inherit_doc] scoped prefix:40 " ¬ " => Proposition.neg
7488

89+
/-- Register `Proposition` as an instance of `PropositionalConnectives`. -/
90+
instance : PropositionalConnectives (Proposition Atom) where
91+
bot := .bot
92+
imp := .imp
93+
7594
/-- Substitute each atom in a proposition for a proposition, possibly changing the atomic
7695
language. -/
7796
def Proposition.subst {Atom Atom' : Type u} (f : Atom → Proposition Atom') :
7897
Proposition Atom → Proposition Atom'
7998
| 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)
99+
| bot => .bot
100+
| imp A B => .imp (A.subst f) (B.subst f)
83101

84102
-- This is probably a lawful monad, but that doesn't seem to be important.
85103
instance : Monad Proposition where
@@ -102,45 +120,45 @@ instance : Functor Theory where
102120
abbrev MPL : Theory (Atom) := ∅
103121

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

108126
/-- Classical logic further adds double negation elimination. -/
109-
abbrev CPL [Bot Atom] : Theory Atom :=
127+
abbrev CPL : Theory Atom :=
110128
Set.range (fun (A : Proposition Atom) ↦ ¬¬A → A)
111129

112130
/-- A theory is intuitionistic if it validates ex falso quodlibet. -/
113131
@[scoped grind]
114-
class IsIntuitionistic [Bot Atom] (T : Theory Atom) where
132+
class IsIntuitionistic (T : Theory Atom) where
115133
efq (A : Proposition Atom) : (⊥ → A) ∈ T
116134

117135
omit [DecidableEq Atom] in
118136
@[scoped grind =]
119-
theorem isIntuitionisticIff [Bot Atom] (T : Theory Atom) : IsIntuitionistic T ↔ IPL ⊆ T := by grind
137+
theorem isIntuitionisticIff (T : Theory Atom) : IsIntuitionistic T ↔ IPL ⊆ T := by grind
120138

121139
/-- A theory is classical if it validates double-negation elimination. -/
122140
@[scoped grind]
123-
class IsClassical [Bot Atom] (T : Theory Atom) where
141+
class IsClassical (T : Theory Atom) where
124142
dne (A : Proposition Atom) : (¬¬A → A) ∈ T
125143

126144
omit [DecidableEq Atom] in
127145
@[scoped grind =]
128-
theorem isClassicalIff [Bot Atom] (T : Theory Atom) : IsClassical T ↔ CPL ⊆ T := by grind
146+
theorem isClassicalIff (T : Theory Atom) : IsClassical T ↔ CPL ⊆ T := by grind
129147

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

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

136154
omit [DecidableEq Atom] in
137155
@[scoped grind →]
138-
theorem instIsIntuitionisticExtention [Bot Atom] {T T' : Theory Atom} [IsIntuitionistic T]
156+
theorem instIsIntuitionisticExtention {T T' : Theory Atom} [IsIntuitionistic T]
139157
(h : T ⊆ T') : IsIntuitionistic T' := by grind
140158

141159
omit [DecidableEq Atom] in
142160
@[scoped grind →]
143-
theorem instIsClassicalExtention [Bot Atom] {T T' : Theory Atom} [IsClassical T] (h : T ⊆ T') :
161+
theorem instIsClassicalExtention {T T' : Theory Atom} [IsClassical T] (h : T ⊆ T') :
144162
IsClassical T' := by grind
145163

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

0 commit comments

Comments
 (0)