Skip to content

Commit 65a3af7

Browse files
benbrastmckieclaude
andcommitted
feat(Logics/Propositional): make IPL the base logic with primitive ex falso
Promote ex falso quodlibet (bottom-elimination) to an ungated primitive constructor of the natural-deduction Derivation, so IPL is the base propositional logic and the primitive bot constructor has an inference rule. IPL becomes the empty base theory; CPL still adds double negation elimination. The minimal-logic (MPL) layer is deferred to a separate PR: this removes MPL, the IsIntuitionistic typeclass, intuitionisticCompletion, and the derived efq rules, keeping the classical layer (byContra/lem/pierce and the IsClassical instances for CPL/LEM/Pierce) intact, re-proved via the efq constructor. Per reviewer feedback (Waring, CSLib Zulip 'Propositional Logic'): - Drop the connective typeclasses (Foundations/Logic/Connectives.lean and its registration instances) -- a separate development handled via PR #607. - Restore references (Gentzen 1935, Prawitz 1965, Troelstra-van Dalen 1988) and add the CSLib Zulip thread link. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019sHZHp7U5qSiEzioK1nGEH
1 parent cc44c14 commit 65a3af7

6 files changed

Lines changed: 76 additions & 172 deletions

File tree

Cslib.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public import Cslib.Foundations.Data.RelatesInSteps
7373
public import Cslib.Foundations.Data.Set.Saturation
7474
public import Cslib.Foundations.Data.StackTape
7575
public import Cslib.Foundations.Lint.Basic
76-
public import Cslib.Foundations.Logic.Connectives
7776
public import Cslib.Foundations.Logic.InferenceSystem
7877
public import Cslib.Foundations.Logic.LogicalEquivalence
7978
public import Cslib.Foundations.Relation.Attr

Cslib/Foundations/Logic/Connectives.lean

Lines changed: 0 additions & 71 deletions
This file was deleted.

Cslib/Logics/Propositional/Defs.lean

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Authors: Thomas Waring, Benjamin Brast-McKie
77
module
88

99
import Cslib.Init
10-
public import Cslib.Foundations.Logic.Connectives
1110
public import Cslib.Foundations.Logic.InferenceSystem
1211
public import Mathlib.Data.FunLike.Basic
1312
public import Mathlib.Data.Set.Basic
@@ -23,16 +22,12 @@ public import Mathlib.Order.TypeTags
2322
follows the natural deduction tradition ([Avigad2022]) in which `neg A` abbreviates `A → ⊥`
2423
rather than being taken as primitive.
2524
- `Theory` : set of `Proposition`.
26-
- `IsIntuitionistic` : an inference system is intuitionistic if it derives the principle of
27-
explosion.
2825
- `IsClassical` : an inference system is classical if it further derives double negation
2926
elimination.
3027
- `Proposition.subst` : replace `atom x` in a `A : Proposition Atom` with `f x`, for a function
3128
`f : Atom → Proposition Atom'`. This induces a monad structure on `Proposition`, with
3229
`pure := Proposition.atom`. `Theory` is a functor, by mapping each proposition `A ∈ T` to
3330
`f <$> A`.
34-
- `Theory.intuitionisticCompletion` : the freely generated intuitionistic theory extending a given
35-
theory.
3631
3732
## Notation
3833
@@ -85,19 +80,6 @@ instance : Top (Proposition Atom) := ⟨.top⟩
8580
@[inherit_doc] scoped infix:20 " ↔ " => Proposition.iff
8681
@[inherit_doc] scoped prefix:40 " ¬ " => Proposition.neg
8782

88-
/-- Register `Proposition` as an instance of `PropositionalConnectives`. -/
89-
instance : PropositionalConnectives (Proposition Atom) where
90-
bot := .bot
91-
imp := .imp
92-
93-
/-- Register `HasAnd` instance for `Proposition`. -/
94-
instance : HasAnd (Proposition Atom) where
95-
and := .and
96-
97-
/-- Register `HasOr` instance for `Proposition`. -/
98-
instance : HasOr (Proposition Atom) where
99-
or := .or
100-
10183
/-- Substitute each atom in a proposition for a proposition, possibly changing the atomic
10284
language. -/
10385
def Proposition.subst {Atom Atom' : Type u} (f : Atom → Proposition Atom') :
@@ -125,15 +107,9 @@ protected def subst {Atom Atom' : Type u} (T : Theory Atom) (f : Atom → Propos
125107
instance : Functor Theory where
126108
map f := Set.image (f <$> ·)
127109

128-
/-- The empty theory corresponds to minimal propositional logic. -/
129-
abbrev MPL : Theory (Atom) := ∅
130-
131-
/-- Intuitionistic propositional logic adds the principle of explosion (ex falso quodlibet). -/
132-
abbrev IPL : Theory Atom :=
133-
Set.range (Proposition.imp ⊥ ·)
134-
135-
omit [DecidableEq Atom] in
136-
lemma efq_mem_ipl (A : Proposition Atom) : (⊥ → A) ∈ IPL (Atom := Atom) := ⟨A, rfl⟩
110+
/-- Intuitionistic propositional logic: the base theory. Ex falso quodlibet is a primitive
111+
inference rule (see `Derivation.efq`), so no explosion axioms are needed. -/
112+
abbrev IPL : Theory Atom := ∅
137113

138114
/-- Classical logic further adds double negation elimination. -/
139115
abbrev CPL : Theory Atom :=
@@ -142,24 +118,8 @@ abbrev CPL : Theory Atom :=
142118
omit [DecidableEq Atom] in
143119
lemma dne_mem_cpl (A : Proposition Atom) : (¬¬A → A) ∈ CPL (Atom := Atom) := ⟨A, rfl⟩
144120

145-
/-- Extend a theory `T` to an intuitionistic theory over a larger atom type by adding the principle
146-
of explosion. The atom type is extended with `WithBot` to ensure the result is over a strictly
147-
larger language. -/
148-
@[reducible]
149-
def intuitionisticCompletion (T : Theory Atom) : Theory (WithBot Atom) :=
150-
(WithBot.some <$> T) ∪ IPL
151-
152121
open InferenceSystem
153122

154-
/-- An inference system is intuitionistic if it derives ex falso quodlibet. TODO: this should be
155-
generalised outside the `PL` scope, once we have typeclasses to express that a type possesses an
156-
implication connective. -/
157-
@[scoped grind]
158-
class IsIntuitionistic (Atom : Type u) (S : Type*)
159-
[InferenceSystem S (Proposition Atom)] where
160-
/-- The principle of explosion (ex falso quodlibet). -/
161-
efq (A : Proposition Atom) : S⇓(⊥ → A)
162-
163123
/-- An inference system is classical if it validates double-negation elimination. TODO: this should
164124
be generalised outside the `PL` scope, once we have typeclasses to express that a type possesses an
165125
implication connective. -/

Cslib/Logics/Propositional/NaturalDeduction/Basic.lean

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public import Mathlib.Data.Finset.Image
1313

1414
/-! # Natural deduction for propositional logic
1515
16-
We define, for minimal logic, deduction trees (a `Type`) and derivability (a `Prop`) relative to a
16+
We define deduction trees (a `Type`) and derivability (a `Prop`) relative to a
1717
`Theory` (set of propositions).
1818
1919
## Main definitions
@@ -44,18 +44,24 @@ abbreviates a derivation of `A` in the empty context: `T⇓(∅ ⊢ A)`.
4444
4545
The primitive inference rules are: axiom (from theory), assumption (from context),
4646
conjunction introduction and elimination (×2), disjunction introduction (×2) and elimination,
47-
and implication introduction and elimination — 10 constructors in total. Ex falso quodlibet
48-
(bottom elimination) is a derived rule requiring `[IsIntuitionistic T]`.
47+
implication introduction and elimination, and ex falso quodlibet (⊥-elimination) — 11 constructors
48+
in total. IPL is the base logic; ex falso is primitive so no extra axioms are needed for explosion.
49+
Taking ex falso quodlibet as a primitive rule gives `⊥` an elimination rule rather than leaving it
50+
a constructor with no inference behaviour, following the natural-deduction tradition
51+
[Gentzen1935], [Prawitz1965], [TroelstraVanDalen1988].
4952
5053
Logic strength is controlled by the theory parameter:
51-
- `MPL` (minimal propositional logic, see [Avigad2022] §3): no axioms beyond the
52-
10 primitive rules; bottom has no special status.
53-
- `IPL` (intuitionistic propositional logic): adds the principle of explosion `⊥ → A`.
54+
- `IPL` (intuitionistic propositional logic): the base theory (empty); ex falso is a primitive rule.
5455
- `CPL` (classical propositional logic): adds double negation elimination `¬¬A → A`.
5556
57+
The design of this module was discussed on the
58+
[CSLib Zulip thread on Propositional Logic](https://leanprover.zulipchat.com/#narrow/channel/513188-CSLib/topic/Propositional.20Logic).
59+
5660
## References
5761
58-
* [J. Avigad, *Mathematical Logic and Computation*][Avigad2022]
62+
* [G. Gentzen, *Untersuchungen über das logische Schließen. I*][Gentzen1935]
63+
* [D. Prawitz, *Natural Deduction: A Proof-Theoretical Study*][Prawitz1965]
64+
* [A. S. Troelstra, D. van Dalen, *Constructivism in Mathematics*][TroelstraVanDalen1988]
5965
-/
6066

6167
@[expose] public section
@@ -83,8 +89,7 @@ scoped notation Γ:60 " ⊢ " A => (⟨Γ, A⟩ : Sequent)
8389

8490
/-- A `T`-derivation of {A₁, ..., Aₙ} ⊢ B demonstrates B using (undischarged) assumptions among Aᵢ,
8591
possibly appealing to axioms from `T`. Primitives: axiom, assumption, conjunction intro/elim,
86-
disjunction intro/elim, and implication intro/elim.
87-
Ex falso quodlibet (bottom elimination) is a derived rule requiring `[IsIntuitionistic T]`. -/
92+
disjunction intro/elim, implication intro/elim, and ex falso quodlibet (⊥-elimination). -/
8893
inductive Theory.Derivation {T : Theory Atom} : Ctx Atom → Proposition Atom → Type u where
8994
/-- Axiom -/
9095
| ax {Γ : Ctx Atom} {A : Proposition Atom} (_ : A ∈ T) : Derivation Γ A
@@ -115,6 +120,9 @@ inductive Theory.Derivation {T : Theory Atom} : Ctx Atom → Proposition Atom
115120
/-- Implication elimination (modus ponens) -/
116121
| impE {Γ : Ctx Atom} {A B : Proposition Atom} :
117122
Derivation Γ (A → B) → Derivation Γ A → Derivation Γ B
123+
/-- Ex falso quodlibet (⊥-elimination). Makes IPL the base logic: from a derivation of
124+
`⊥`, derive any proposition. -/
125+
| efq {Γ : Ctx Atom} {A : Proposition Atom} : Derivation Γ ⊥ → Derivation Γ A
118126

119127
/-- Inference system for derivations under the theory `T`. -/
120128
instance (T : Theory Atom) : InferenceSystem T (Sequent (Atom := Atom)) where
@@ -161,8 +169,8 @@ theorem Theory.equiv_iff {A B : Proposition Atom} :
161169
· intro ⟨⟨D⟩, ⟨E⟩⟩
162170
exact ⟨D, E⟩
163171

164-
/-- Minimally equivalent propositions. -/
165-
abbrev Equiv : Proposition Atom → Proposition Atom → Prop := MPL.Equiv
172+
/-- Equivalent propositions (over the base theory IPL). -/
173+
abbrev Equiv : Proposition Atom → Proposition Atom → Prop := IPL.Equiv
166174

167175
@[inherit_doc]
168176
scoped infix:29 " ≡ " => Equiv
@@ -187,6 +195,7 @@ def Theory.Derivation.weak {T T' : Theory Atom} {Γ Δ : Ctx Atom} {A : Proposit
187195
(DB.weak hTheory (Finset.insert_subset_insert _ hCtx))
188196
| @impI _ _ _ A B Γ D => impI (Δ) <| D.weak hTheory <| Finset.insert_subset_insert _ hCtx
189197
| impE D D' => impE (D.weak hTheory hCtx) (D'.weak hTheory hCtx)
198+
| efq D => efq (D.weak hTheory hCtx)
190199

191200
/-- Weakening the theory only. -/
192201
def Theory.Derivation.weakTheory {T T' : Theory Atom} {Γ : Ctx Atom} {A : Proposition Atom}
@@ -271,6 +280,7 @@ def Theory.Derivation.subs {Γ Γ' Δ : Ctx Atom} {B : Proposition Atom}
271280
rw [show insert A' (Γ \ Γ' ∪ Δ) = (insert A' Γ \ Γ') ∪ insert A' Δ by grind]
272281
exact E.subs Ds |>.weakCtx (by grind)
273282
| impE E E' => impE (E.subs Ds) (E'.subs Ds)
283+
| efq E => efq (E.subs Ds)
274284

275285
/-- Transport a derivation along a substitution of atoms. -/
276286
def Theory.Derivation.substAtom {Atom Atom' : Type u} [DecidableEq Atom] [DecidableEq Atom']
@@ -289,6 +299,7 @@ def Theory.Derivation.substAtom {Atom Atom' : Type u} [DecidableEq Atom] [Decida
289299
((Finset.image_insert (· >>= f) _ _) ▸ (DB.substAtom f))
290300
| impI _ D => impI _ <| (Finset.image_insert (· >>= f) _ _) ▸ (D.substAtom f)
291301
| impE D E => impE (D.substAtom f) (E.substAtom f)
302+
| efq D => efq (D.substAtom f)
292303

293304
theorem DerivableIn.substAtom {Atom Atom' : Type u} [DecidableEq Atom] [DecidableEq Atom']
294305
{T : Theory Atom}

Cslib/Logics/Propositional/NaturalDeduction/Theory.lean

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ public import Cslib.Logics.Propositional.NaturalDeduction.Basic
99

1010
/-! # Results on propositional theories
1111
12-
In this file we prove the expected results that `IPL` is an intuitionistic theory, and
13-
`CPL` is a classical theory. We provide derived rules for common intuitionistic and classical
14-
proof patterns.
12+
In this file we prove that `CPL` is a classical theory. We provide derived rules for common
13+
classical proof patterns.
1514
1615
Since `Proposition` has `bot` as a primitive constructor, no `[Bot Atom]` constraint is needed:
1716
`⊥ : Proposition Atom` is always available as `.bot`.
@@ -23,48 +22,21 @@ universe u
2322

2423
namespace Cslib.Logic.PL
2524

26-
open Proposition Theory InferenceSystem DerivableIn Derivation IsIntuitionistic IsClassical
25+
open Proposition Theory InferenceSystem DerivableIn Derivation IsClassical
2726

2827
variable {Atom : Type u} [DecidableEq Atom] {T : Theory Atom}
2928

3029
namespace Theory
3130

32-
/-- `IPL` is intuitionistic: it contains `⊥ → A` for all `A`. -/
33-
instance instIsIntuitionisticIPL : IsIntuitionistic Atom (IPL (Atom := Atom)) where
34-
efq A := ax (efq_mem_ipl A)
35-
3631
/-- `CPL` is classical: it contains `¬¬A → A` for all `A`. -/
3732
instance instIsClassicalCPL : IsClassical Atom (CPL (Atom := Atom)) where
3833
dne A := ax (dne_mem_cpl A)
3934

40-
/-- The intuitionistic completion of any theory is intuitionistic. -/
41-
instance instIsIntuitionisticIntuitionisticCompletion [DecidableEq (WithBot Atom)]
42-
(T : Theory Atom) :
43-
IsIntuitionistic (WithBot Atom) T.intuitionisticCompletion where
44-
efq A := ax (Set.mem_union_right _ (efq_mem_ipl A))
45-
46-
/-- Derivation of efq in an arbitrary context. -/
47-
def IsIntuitionistic.efqCtx [IsIntuitionistic Atom T] (Γ : Ctx Atom) (A : Proposition Atom)
48-
: T⇓(Γ ⊢ ⊥ → A) := (efq A : T⇓(⊥ → A)).weakCtx (Finset.empty_subset Γ)
49-
50-
/-- Efq as a derived rule. -/
51-
def IsIntuitionistic.efqRule [IsIntuitionistic Atom T] (Γ : Ctx Atom) (A : Proposition Atom)
52-
(D : T⇓(Γ ⊢ ⊥)) : T⇓(Γ ⊢ A) :=
53-
impE (A := ⊥) (efqCtx Γ A) D
54-
55-
/-- Prove any proposition from contradictory hypotheses. -/
56-
def IsIntuitionistic.contra [IsIntuitionistic Atom T] {Γ : Ctx Atom} (A B : Proposition Atom)
57-
(hΓ : A ∈ Γ) (hΓ' : (¬A) ∈ Γ) : T⇓(Γ ⊢ B) :=
58-
efqRule Γ B <| impE (ass hΓ') (ass hΓ)
59-
6035
/-- Proof by contradiction as a derived rule. -/
6136
def IsClassical.byContra [IsClassical Atom T] {Γ : Ctx Atom} {A : Proposition Atom}
6237
(D : T⇓(insert (¬ A) Γ ⊢ ⊥)) : T⇓(Γ ⊢ A) :=
6338
impE (A := ¬¬A) ((dne A : T⇓(¬¬A → A)) |>.weakCtx <| Finset.empty_subset ..) D.impI
6439

65-
instance instIsIntuitionisticOfIsClassical [IsClassical Atom T] : IsIntuitionistic Atom T where
66-
efq A := impI _ <| byContra <| ass (by grind)
67-
6840
/-- Law of excluded middle in a classical theory. -/
6941
def IsClassical.lem [IsClassical Atom T] (A : Proposition Atom) : T⇓(A ∨ ¬ A) := by
7042
apply byContra
@@ -80,7 +52,8 @@ def IsClassical.pierce [IsClassical Atom T] (A B : Proposition Atom) : T⇓(((A
8052
apply impI; apply byContra
8153
apply impE (ass <| Finset.mem_insert_self ..)
8254
apply impE (A := A → B) (ass <| by grind); apply impI
83-
apply contra A B <;> grind
55+
exact efq (impE (ass <| Finset.mem_insert.mpr (Or.inr (Finset.mem_insert_self _ _)))
56+
(ass <| Finset.mem_insert_self _ _))
8457

8558
/-- The axiom system consisting of instances of LEM. -/
8659
def LEM : Theory Atom := {A ∨ ¬ A | A : Proposition Atom}
@@ -96,23 +69,23 @@ omit [DecidableEq Atom] in
9669
lemma pierce_mem_pierce (A B : Proposition Atom) :
9770
(((A → B) → A) → A) ∈ Pierce (Atom := Atom) := ⟨A, B, rfl⟩
9871

99-
instance instIsClassicalLEM : IsClassical Atom (LEM ∪ IPL : Theory Atom) where
72+
instance instIsClassicalLEM : IsClassical Atom (LEM : Theory Atom) where
10073
dne A := by
10174
apply impI
10275
apply orE
103-
· exact ax <| Set.mem_union_left _ <| lem_mem_lem A
76+
· exact ax (lem_mem_lem A)
10477
· exact ass (Finset.mem_insert_self A _)
105-
· apply impE (A := ⊥) (ax <| Set.mem_union_right _ (efq_mem_ipl A))
78+
· apply efq
10679
apply impE (A := ¬ A)
10780
· exact ass (Finset.mem_insert.mpr (Or.inr (Finset.mem_insert_self _ _)))
10881
· exact ass (Finset.mem_insert_self _ _)
10982

110-
instance instIsClassicalPierce : IsClassical Atom (Pierce ∪ IPL : Theory Atom) where
83+
instance instIsClassicalPierce : IsClassical Atom (Pierce : Theory Atom) where
11184
dne A := by
11285
apply impI
113-
apply impE (A := (A → ⊥) → A) (ax <| Set.mem_union_left _ <| pierce_mem_pierce A ⊥)
86+
apply impE (A := (A → ⊥) → A) (ax <| pierce_mem_pierce A ⊥)
11487
apply impI
115-
apply impE (A := ⊥) (ax <| Set.mem_union_right _ (efq_mem_ipl A))
88+
apply efq
11689
apply impE (A := ¬ A)
11790
· exact ass (Finset.mem_insert.mpr (Or.inr (Finset.mem_insert_self _ _)))
11891
· exact ass (Finset.mem_insert_self _ _)

0 commit comments

Comments
 (0)