11/-
2- Copyright (c) 2025 Thomas Waring. All rights reserved.
2+ Copyright (c) 2025 Thomas Waring, 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 Cslib.Foundations.Logic.Connectives
1011public import Mathlib.Data.FunLike.Basic
11- public import Mathlib.Data.Set.Image
12+ public import Mathlib.Data.Set.Basic
1213public 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), `imp` (implication), `and` (conjunction), and `or` (disjunction). Negation
21+ (`neg`), verum (`top`), and biconditional (`iff`) are derived connectives (`abbrev`s). This
22+ follows natural deduction style ([ Gentzen1935 ] , [ Prawitz1965 ] , Ch. I sec. 1.2) and the
23+ constructive mathematics tradition ([ Johansson1937 ] , [ TroelstraVanDalen1988 ] ) in which `neg A`
24+ abbreviates `A → ⊥` rather than being taken as primitive.
2025- `Theory` : set of `Proposition`.
2126- `IsIntuitionistic` : a theory is intuitionistic if it contains the principle of explosion.
2227- `IsClassical` : an intuitionistic theory is classical if it further contains double negation
23- elimination.
28+ elimination.
2429- `Proposition.subst` : replace `atom x` in a `A : Proposition Atom` with `f x`, for a function
2530 `f : Atom → Proposition Atom'`. This induces a monad structure on `Proposition`, with
2631 `pure := Proposition.atom`. `Theory` is a functor, by mapping each proposition `A ∈ T` to
2732 `f <$> A`.
2833- `Theory.intuitionisticCompletion` : the freely generated intuitionistic theory extending a given
29- theory.
34+ theory.
3035
3136 ## Notation
3237
3338We introduce notation for the logical connectives: `⊥ ⊤ ∧ ∨ → ¬` for, respectively, falsum, verum,
3439conjunction, disjunction, implication and negation.
40+
41+ ## References
42+
43+ * [ I. Johansson, *Der Minimalkalkül, ein reduzierter intuitionistischer Formalismus* ] [Johansson1937 ]
44+ * [ G. Gentzen, *Untersuchungen über das logische Schließen* ] [Gentzen1935 ]
45+ * [ D. Prawitz, *Natural Deduction: A Proof-Theoretical Study* ] [Prawitz1965 ]
46+ * [A. S. Troelstra, D. van Dalen,
47+ *Constructivism in Mathematics: An Introduction* ][ TroelstraVanDalen1988 ]
48+ * [ A. Church, *Introduction to Mathematical Logic* ] [Church1956 ]
3549 -/
3650
3751@[expose] public section
@@ -42,44 +56,61 @@ variable {Atom : Type u} [DecidableEq Atom]
4256
4357namespace Cslib.Logic.PL
4458
45- /-- Propositions. -/
59+ /-- Propositions. Primitives are atoms, falsum, implication, conjunction, and disjunction. -/
4660inductive Proposition (Atom : Type u) : Type u where
4761 /-- Propositional atoms -/
4862 | atom (x : Atom)
63+ /-- Falsum / bottom -/
64+ | bot
65+ /-- Implication -/
66+ | imp (a b : Proposition Atom)
4967 /-- Conjunction -/
5068 | and (a b : Proposition Atom)
5169 /-- Disjunction -/
5270 | or (a b : Proposition Atom)
53- /-- Implication -/
54- | impl (a b : Proposition Atom)
5571deriving DecidableEq, BEq
5672
57- instance instBotProposition [Bot Atom] : Bot (Proposition Atom) := ⟨.atom ⊥⟩
58- instance instInhabitedOfBot [Bot Atom] : Inhabited Atom := ⟨⊥⟩
73+ /-- Negation as a derived connective: ¬A := A → ⊥ -/
74+ abbrev Proposition.neg : Proposition Atom → Proposition Atom := (Proposition.imp · .bot)
5975
60- /-- We view negation as a defined connective ~A := A → ⊥ -/
61- abbrev Proposition.neg [Bot Atom] : Proposition Atom → Proposition Atom := (Proposition.impl · ⊥)
76+ /-- Verum / top as a derived connective: ⊤ := ⊥ → ⊥ -/
77+ abbrev Proposition.top : Proposition Atom := .imp .bot .bot
6278
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)
79+ /-- Biconditional as a derived connective: A ↔ B := (A → B) ∧ (B → A) -/
80+ abbrev Proposition.iff (A B : Proposition Atom) : Proposition Atom :=
81+ (A.imp B).and (B.imp A)
6582
66- instance instTopProposition [Inhabited Atom] : Top (Proposition Atom) := ⟨.top⟩
67-
68- example [Bot Atom] : (⊤ : Proposition Atom) = Proposition.impl ⊥ ⊥ := rfl
83+ instance : Bot (Proposition Atom) := ⟨.bot⟩
84+ instance : Top (Proposition Atom) := ⟨.top⟩
6985
7086@[inherit_doc] scoped infix :36 " ∧ " => Proposition.and
7187@[inherit_doc] scoped infix :35 " ∨ " => Proposition.or
72- @[inherit_doc] scoped infix :30 " → " => Proposition.impl
88+ @[inherit_doc] scoped infix :30 " → " => Proposition.imp
89+ @[inherit_doc] scoped infix :20 " ↔ " => Proposition.iff
7390@[inherit_doc] scoped prefix :40 " ¬ " => Proposition.neg
7491
92+ /-- Register `Proposition` as an instance of `PropositionalConnectives`. -/
93+ instance : PropositionalConnectives (Proposition Atom) where
94+ bot := .bot
95+ imp := .imp
96+
97+ /-- Register `HasAnd` instance for `Proposition`. -/
98+ instance : HasAnd (Proposition Atom) where
99+ and := .and
100+
101+ /-- Register `HasOr` instance for `Proposition`. -/
102+ instance : HasOr (Proposition Atom) where
103+ or := .or
104+
75105/-- Substitute each atom in a proposition for a proposition, possibly changing the atomic
76106language. -/
77107def Proposition.subst {Atom Atom' : Type u} (f : Atom → Proposition Atom') :
78108 Proposition Atom → Proposition Atom'
79109 | 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)
110+ | bot => .bot
111+ | imp A B => .imp (A.subst f) (B.subst f)
112+ | and A B => .and (A.subst f) (B.subst f)
113+ | or A B => .or (A.subst f) (B.subst f)
83114
84115-- This is probably a lawful monad, but that doesn't seem to be important.
85116instance : Monad Proposition where
@@ -102,45 +133,45 @@ instance : Functor Theory where
102133abbrev MPL : Theory (Atom) := ∅
103134
104135/-- Intuitionistic propositional logic adds the principle of explosion (ex falso quodlibet). -/
105- abbrev IPL [Bot Atom] : Theory Atom :=
106- Set.range (⊥ → ·)
136+ abbrev IPL : Theory Atom :=
137+ Set.range (Proposition.imp ⊥ ·)
107138
108139/-- Classical logic further adds double negation elimination. -/
109- abbrev CPL [Bot Atom] : Theory Atom :=
140+ abbrev CPL : Theory Atom :=
110141 Set.range (fun (A : Proposition Atom) ↦ ¬¬A → A)
111142
112143/-- A theory is intuitionistic if it validates ex falso quodlibet. -/
113144@ [scoped grind]
114- class IsIntuitionistic [Bot Atom] (T : Theory Atom) where
145+ class IsIntuitionistic (T : Theory Atom) where
115146 efq (A : Proposition Atom) : (⊥ → A) ∈ T
116147
117148omit [DecidableEq Atom] in
118149@ [scoped grind =]
119- theorem isIntuitionisticIff [Bot Atom] (T : Theory Atom) : IsIntuitionistic T ↔ IPL ⊆ T := by grind
150+ theorem isIntuitionisticIff (T : Theory Atom) : IsIntuitionistic T ↔ IPL ⊆ T := by grind
120151
121152/-- A theory is classical if it validates double-negation elimination. -/
122153@ [scoped grind]
123- class IsClassical [Bot Atom] (T : Theory Atom) where
154+ class IsClassical (T : Theory Atom) where
124155 dne (A : Proposition Atom) : (¬¬A → A) ∈ T
125156
126157omit [DecidableEq Atom] in
127158@ [scoped grind =]
128- theorem isClassicalIff [Bot Atom] (T : Theory Atom) : IsClassical T ↔ CPL ⊆ T := by grind
159+ theorem isClassicalIff (T : Theory Atom) : IsClassical T ↔ CPL ⊆ T := by grind
129160
130- instance instIsIntuitionisticIPL [Bot Atom] : IsIntuitionistic (Atom := Atom) IPL where
161+ instance instIsIntuitionisticIPL : IsIntuitionistic (Atom := Atom) IPL where
131162 efq A := Set.mem_range.mpr ⟨A, rfl⟩
132163
133- instance instIsClassicalCPL [Bot Atom] : IsClassical (Atom := Atom) CPL where
164+ instance instIsClassicalCPL : IsClassical (Atom := Atom) CPL where
134165 dne A := Set.mem_range.mpr ⟨A, rfl⟩
135166
136167omit [DecidableEq Atom] in
137168@ [scoped grind →]
138- theorem instIsIntuitionisticExtention [Bot Atom] {T T' : Theory Atom} [IsIntuitionistic T]
169+ theorem instIsIntuitionisticExtention {T T' : Theory Atom} [IsIntuitionistic T]
139170 (h : T ⊆ T') : IsIntuitionistic T' := by grind
140171
141172omit [DecidableEq Atom] in
142173@ [scoped grind →]
143- theorem instIsClassicalExtention [Bot Atom] {T T' : Theory Atom} [IsClassical T] (h : T ⊆ T') :
174+ theorem instIsClassicalExtention {T T' : Theory Atom} [IsClassical T] (h : T ⊆ T') :
144175 IsClassical T' := by grind
145176
146177/-- Attach a bottom element to a theory `T`, and the principle of explosion for that bottom. -/
0 commit comments