11/-
2- Copyright (c) 2025 Thomas Waring. All rights reserved.
2+ Copyright (c) 2025 Thomas Waring, 2026 Benjamin Brast-McKie . All rights reserved.
33Released under Apache 2.0 license as described in the file LICENSE.
4- Authors: Thomas Waring
4+ Authors: Thomas Waring, Benjamin Brast-McKie
55-/
66
77module
88
9- public import Cslib.Init
9+ import Cslib.Init
10+ public import Aesop.BuiltinRules
11+ public import Cslib.Foundations.Logic.Connectives
1012public import Mathlib.Data.FunLike.Basic
11- public import Mathlib.Data.Set.Image
13+ public import Mathlib.Data.Set.Basic
1214public import Mathlib.Order.TypeTags
1315
1416/-! # Propositions and theories
1517
1618## Main definitions
1719
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.
20+ - `Proposition` : the type of propositions over a given type of atom. Primitives are `atom`,
21+ `bot` (falsum), `imp` (implication), `and` (conjunction), and `or` (disjunction). Negation
22+ (`neg`), verum (`top`), and biconditional (`iff`) are derived connectives (`abbrev`s). This
23+ follows natural deduction style ([ Gentzen1935 ] , [ Prawitz1965 ] , Ch. I sec. 1.2) and the
24+ constructive mathematics tradition ([ Johansson1937 ] , [ TroelstraVanDalen1988 ] ) in which `neg A`
25+ abbreviates `A → ⊥` rather than being taken as primitive.
2026- `Theory` : set of `Proposition`.
2127- `IsIntuitionistic` : a theory is intuitionistic if it contains the principle of explosion.
2228- `IsClassical` : an intuitionistic theory is classical if it further contains double negation
23- elimination.
29+ elimination.
2430- `Proposition.subst` : replace `atom x` in a `A : Proposition Atom` with `f x`, for a function
2531 `f : Atom → Proposition Atom'`. This induces a monad structure on `Proposition`, with
2632 `pure := Proposition.atom`. `Theory` is a functor, by mapping each proposition `A ∈ T` to
2733 `f <$> A`.
2834- `Theory.intuitionisticCompletion` : the freely generated intuitionistic theory extending a given
29- theory.
35+ theory.
36+
37+ ## Architecture
38+
39+ Two proof systems are defined for this propositional language:
40+
41+ - **Layer 1 — Natural Deduction** (`NaturalDeduction/Basic.lean`): a `Theory.Derivation` inductive
42+ with 10 primitive constructors (axiom, assumption, conjunction intro/elim ×2, disjunction
43+ intro ×2/elim, implication intro/elim). The theory parameter controls logic strength: `MPL`
44+ (Johansson's minimal logic, [ Johansson1937 ] ), `IPL` (intuitionistic), and `CPL` (classical).
45+
46+ - **Layer 2 — Hilbert System** (`ProofSystem/`): an axiom predicate hierarchy
47+ (`MinPropAxiom` / `IntPropAxiom` / `PropositionalAxiom`) with sequent derivability and a
48+ Hilbert-style proof-theoretic treatment.
49+
50+ - **Bridge** : `NaturalDeduction/Equivalence.lean` establishes extensional equivalence between the
51+ two proof systems for all three logic strengths, in both closed-context (`hilbert_iff_nd`,
52+ `hilbert_iff_nd_min`, `hilbert_iff_nd_int`, `hilbert_iff_nd_cl`) and context-based forms
53+ (`hilbert_iff_nd_ctx`, `hilbert_iff_nd_ctx_min`, `hilbert_iff_nd_ctx_int`,
54+ `hilbert_iff_nd_ctx_cl`).
3055
3156 ## Notation
3257
3358We introduce notation for the logical connectives: `⊥ ⊤ ∧ ∨ → ¬` for, respectively, falsum, verum,
3459conjunction, disjunction, implication and negation.
60+
61+ ## References
62+
63+ * [ I. Johansson, *Der Minimalkalkül, ein reduzierter intuitionistischer Formalismus* ] [Johansson1937 ]
64+ * [ G. Gentzen, *Untersuchungen über das logische Schließen* ] [Gentzen1935 ]
65+ * [ D. Prawitz, *Natural Deduction: A Proof-Theoretical Study* ] [Prawitz1965 ]
66+ * [A. S. Troelstra, D. van Dalen,
67+ *Constructivism in Mathematics: An Introduction* ][ TroelstraVanDalen1988 ]
68+ * [ A. Church, *Introduction to Mathematical Logic* ] [Church1956 ]
3569 -/
3670
3771@[expose] public section
@@ -42,44 +76,61 @@ variable {Atom : Type u} [DecidableEq Atom]
4276
4377namespace Cslib.Logic.PL
4478
45- /-- Propositions. -/
79+ /-- Propositions. Primitives are atoms, falsum, implication, conjunction, and disjunction. -/
4680inductive Proposition (Atom : Type u) : Type u where
4781 /-- Propositional atoms -/
4882 | atom (x : Atom)
83+ /-- Falsum / bottom -/
84+ | bot
85+ /-- Implication -/
86+ | imp (a b : Proposition Atom)
4987 /-- Conjunction -/
5088 | and (a b : Proposition Atom)
5189 /-- Disjunction -/
5290 | or (a b : Proposition Atom)
53- /-- Implication -/
54- | impl (a b : Proposition Atom)
5591deriving DecidableEq, BEq
5692
57- instance instBotProposition [Bot Atom] : Bot (Proposition Atom) := ⟨.atom ⊥⟩
58- instance instInhabitedOfBot [Bot Atom] : Inhabited Atom := ⟨⊥⟩
59-
60- /-- We view negation as a defined connective ~A := A → ⊥ -/
61- abbrev Proposition.neg [Bot Atom] : Proposition Atom → Proposition Atom := (Proposition.impl · ⊥)
93+ /-- Negation as a derived connective: ¬A := A → ⊥ -/
94+ abbrev Proposition.neg : Proposition Atom → Proposition Atom := (Proposition.imp · .bot)
6295
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)
96+ /-- Verum / top as a derived connective: ⊤ := ⊥ → ⊥ -/
97+ abbrev Proposition.top : Proposition Atom := .imp .bot .bot
6598
66- instance instTopProposition [Inhabited Atom] : Top (Proposition Atom) := ⟨.top⟩
99+ /-- Biconditional as a derived connective: A ↔ B := (A → B) ∧ (B → A) -/
100+ abbrev Proposition.iff (A B : Proposition Atom) : Proposition Atom :=
101+ (A.imp B).and (B.imp A)
67102
68- example [Bot Atom] : (⊤ : Proposition Atom) = Proposition.impl ⊥ ⊥ := rfl
103+ instance : Bot (Proposition Atom) := ⟨.bot⟩
104+ instance : Top (Proposition Atom) := ⟨.top⟩
69105
70106@[inherit_doc] scoped infix :36 " ∧ " => Proposition.and
71107@[inherit_doc] scoped infix :35 " ∨ " => Proposition.or
72- @[inherit_doc] scoped infix :30 " → " => Proposition.impl
108+ @[inherit_doc] scoped infix :30 " → " => Proposition.imp
109+ @[inherit_doc] scoped infix :20 " ↔ " => Proposition.iff
73110@[inherit_doc] scoped prefix :40 " ¬ " => Proposition.neg
74111
112+ /-- Register `Proposition` as an instance of `PropositionalConnectives`. -/
113+ instance : PropositionalConnectives (Proposition Atom) where
114+ bot := .bot
115+ imp := .imp
116+
117+ /-- Register `HasAnd` instance for `Proposition`. -/
118+ instance : HasAnd (Proposition Atom) where
119+ and := .and
120+
121+ /-- Register `HasOr` instance for `Proposition`. -/
122+ instance : HasOr (Proposition Atom) where
123+ or := .or
124+
75125/-- Substitute each atom in a proposition for a proposition, possibly changing the atomic
76126language. -/
77127def Proposition.subst {Atom Atom' : Type u} (f : Atom → Proposition Atom') :
78128 Proposition Atom → Proposition Atom'
79129 | 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)
130+ | bot => .bot
131+ | imp A B => .imp (A.subst f) (B.subst f)
132+ | and A B => .and (A.subst f) (B.subst f)
133+ | or A B => .or (A.subst f) (B.subst f)
83134
84135-- This is probably a lawful monad, but that doesn't seem to be important.
85136instance : Monad Proposition where
@@ -102,45 +153,45 @@ instance : Functor Theory where
102153abbrev MPL : Theory (Atom) := ∅
103154
104155/-- Intuitionistic propositional logic adds the principle of explosion (ex falso quodlibet). -/
105- abbrev IPL [Bot Atom] : Theory Atom :=
106- Set.range (⊥ → ·)
156+ abbrev IPL : Theory Atom :=
157+ Set.range (Proposition.imp ⊥ ·)
107158
108159/-- Classical logic further adds double negation elimination. -/
109- abbrev CPL [Bot Atom] : Theory Atom :=
160+ abbrev CPL : Theory Atom :=
110161 Set.range (fun (A : Proposition Atom) ↦ ¬¬A → A)
111162
112163/-- A theory is intuitionistic if it validates ex falso quodlibet. -/
113164@ [scoped grind]
114- class IsIntuitionistic [Bot Atom] (T : Theory Atom) where
165+ class IsIntuitionistic (T : Theory Atom) where
115166 efq (A : Proposition Atom) : (⊥ → A) ∈ T
116167
117168omit [DecidableEq Atom] in
118169@ [scoped grind =]
119- theorem isIntuitionisticIff [Bot Atom] (T : Theory Atom) : IsIntuitionistic T ↔ IPL ⊆ T := by grind
170+ theorem isIntuitionisticIff (T : Theory Atom) : IsIntuitionistic T ↔ IPL ⊆ T := by grind
120171
121172/-- A theory is classical if it validates double-negation elimination. -/
122173@ [scoped grind]
123- class IsClassical [Bot Atom] (T : Theory Atom) where
174+ class IsClassical (T : Theory Atom) where
124175 dne (A : Proposition Atom) : (¬¬A → A) ∈ T
125176
126177omit [DecidableEq Atom] in
127178@ [scoped grind =]
128- theorem isClassicalIff [Bot Atom] (T : Theory Atom) : IsClassical T ↔ CPL ⊆ T := by grind
179+ theorem isClassicalIff (T : Theory Atom) : IsClassical T ↔ CPL ⊆ T := by grind
129180
130- instance instIsIntuitionisticIPL [Bot Atom] : IsIntuitionistic (Atom := Atom) IPL where
181+ instance instIsIntuitionisticIPL : IsIntuitionistic (Atom := Atom) IPL where
131182 efq A := Set.mem_range.mpr ⟨A, rfl⟩
132183
133- instance instIsClassicalCPL [Bot Atom] : IsClassical (Atom := Atom) CPL where
184+ instance instIsClassicalCPL : IsClassical (Atom := Atom) CPL where
134185 dne A := Set.mem_range.mpr ⟨A, rfl⟩
135186
136187omit [DecidableEq Atom] in
137188@ [scoped grind →]
138- theorem instIsIntuitionisticExtention [Bot Atom] {T T' : Theory Atom} [IsIntuitionistic T]
189+ theorem instIsIntuitionisticExtention {T T' : Theory Atom} [IsIntuitionistic T]
139190 (h : T ⊆ T') : IsIntuitionistic T' := by grind
140191
141192omit [DecidableEq Atom] in
142193@ [scoped grind →]
143- theorem instIsClassicalExtention [Bot Atom] {T T' : Theory Atom} [IsClassical T] (h : T ⊆ T') :
194+ theorem instIsClassicalExtention {T T' : Theory Atom} [IsClassical T] (h : T ⊆ T') :
144195 IsClassical T' := by grind
145196
146197/-- Attach a bottom element to a theory `T`, and the principle of explosion for that bottom. -/
0 commit comments