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+ import Cslib.Init
10+ public import Cslib.Foundations.Logic.Connectives
911public import Cslib.Foundations.Logic.InferenceSystem
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 the natural deduction tradition ([ Avigad2022 ] ) in which `neg A` abbreviates `A → ⊥`
24+ rather than being taken as primitive.
2025- `Theory` : set of `Proposition`.
21- - `IsIntuitionistic` : a theory is intuitionistic if it contains the principle of explosion.
22- - `IsClassical` : an intuitionistic theory is classical if it further contains double negation
23- elimination.
26+ - `IsIntuitionistic` : an inference system is intuitionistic if it derives the principle of
27+ explosion.
28+ - `IsClassical` : an inference system is classical if it further derives double negation
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.
3036
3137 ## Notation
3238
3339We introduce notation for the logical connectives: `⊥ ⊤ ∧ ∨ → ¬` for, respectively, falsum, verum,
3440conjunction, disjunction, implication and negation.
41+
42+ ## References
43+
44+ * [ J. Avigad, *Mathematical Logic and Computation* ] [Avigad2022 ]
3545 -/
3646
3747@[expose] public section
@@ -42,44 +52,61 @@ variable {Atom : Type u} [DecidableEq Atom]
4252
4353namespace Cslib.Logic.PL
4454
45- /-- Propositions. -/
55+ /-- Propositions. Primitives are atoms, falsum, implication, conjunction, and disjunction. -/
4656inductive Proposition (Atom : Type u) : Type u where
4757 /-- Propositional atoms -/
4858 | atom (x : Atom)
59+ /-- Falsum / bottom -/
60+ | bot
61+ /-- Implication -/
62+ | imp (a b : Proposition Atom)
4963 /-- Conjunction -/
5064 | and (a b : Proposition Atom)
5165 /-- Disjunction -/
5266 | or (a b : Proposition Atom)
53- /-- Implication -/
54- | impl (a b : Proposition Atom)
5567deriving DecidableEq, BEq
5668
57- instance instBotProposition [Bot Atom] : Bot (Proposition Atom) := ⟨.atom ⊥⟩
58- instance instInhabitedOfBot [Bot Atom] : Inhabited Atom := ⟨⊥⟩
69+ /-- Negation as a derived connective: ¬A := A → ⊥ -/
70+ abbrev Proposition.neg : Proposition Atom → Proposition Atom := (Proposition.imp · .bot)
5971
60- /-- We view negation as a defined connective ~A := A → ⊥ -/
61- abbrev Proposition.neg [Bot Atom] : Proposition Atom → Proposition Atom := (Proposition.impl · ⊥)
72+ /-- Verum / top as a derived connective: ⊤ := ⊥ → ⊥ -/
73+ abbrev Proposition.top : Proposition Atom := .imp .bot .bot
6274
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)
75+ /-- Biconditional as a derived connective: A ↔ B := (A → B) ∧ (B → A) -/
76+ abbrev Proposition.iff (A B : Proposition Atom) : Proposition Atom :=
77+ (A.imp B).and (B.imp A)
6578
66- instance instTopProposition [Inhabited Atom] : Top (Proposition Atom) := ⟨.top⟩
67-
68- example [Bot Atom] : (⊤ : Proposition Atom) = Proposition.impl ⊥ ⊥ := rfl
79+ instance : Bot (Proposition Atom) := ⟨.bot⟩
80+ instance : Top (Proposition Atom) := ⟨.top⟩
6981
7082@[inherit_doc] scoped infix :36 " ∧ " => Proposition.and
7183@[inherit_doc] scoped infix :35 " ∨ " => Proposition.or
72- @[inherit_doc] scoped infix :30 " → " => Proposition.impl
84+ @[inherit_doc] scoped infix :30 " → " => Proposition.imp
85+ @[inherit_doc] scoped infix :20 " ↔ " => Proposition.iff
7386@[inherit_doc] scoped prefix :40 " ¬ " => Proposition.neg
7487
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+
75101/-- Substitute each atom in a proposition for a proposition, possibly changing the atomic
76102language. -/
77103def Proposition.subst {Atom Atom' : Type u} (f : Atom → Proposition Atom') :
78104 Proposition Atom → Proposition Atom'
79105 | 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)
106+ | bot => .bot
107+ | imp A B => .imp (A.subst f) (B.subst f)
108+ | and A B => .and (A.subst f) (B.subst f)
109+ | or A B => .or (A.subst f) (B.subst f)
83110
84111-- This is probably a lawful monad, but that doesn't seem to be important.
85112instance : Monad Proposition where
@@ -99,41 +126,43 @@ instance : Functor Theory where
99126 map f := Set.image (f <$> ·)
100127
101128/-- The empty theory corresponds to minimal propositional logic. -/
102- abbrev MPL (Atom : Type u) : Theory (Atom) := ∅
129+ abbrev MPL : Theory (Atom) := ∅
103130
104131/-- Intuitionistic propositional logic adds the principle of explosion (ex falso quodlibet). -/
105- abbrev IPL (Atom : Type u) [Bot Atom] : Theory Atom := {⊥ → A | A : Proposition Atom}
132+ abbrev IPL : Theory Atom :=
133+ Set.range (Proposition.imp ⊥ ·)
106134
107135omit [DecidableEq Atom] in
108- lemma efq_mem_ipl [Bot Atom] (A : Proposition Atom) : (⊥ → A) ∈ IPL Atom := ⟨A, rfl⟩
109-
110- /-- Attach a bottom element to a theory `T`, and the principle of explosion for that bottom. -/
111- @[reducible]
112- def intuitionisticCompletion (T : Theory Atom) : Theory (WithBot Atom) :=
113- (WithBot.some <$> T) ∪ IPL (WithBot Atom)
136+ lemma efq_mem_ipl (A : Proposition Atom) : (⊥ → A) ∈ IPL (Atom := Atom) := ⟨A, rfl⟩
114137
115138/-- Classical logic further adds double negation elimination. -/
116- abbrev CPL (Atom : Type u) [Bot Atom] : Theory Atom := {¬¬A → A | A : Proposition Atom}
139+ abbrev CPL : Theory Atom :=
140+ Set.range (fun (A : Proposition Atom) ↦ ¬¬A → A)
117141
118142omit [DecidableEq Atom] in
119- lemma dne_mem_cpl [Bot Atom] (A : Proposition Atom) : (¬¬A → A) ∈ CPL Atom := ⟨A, rfl⟩
143+ lemma dne_mem_cpl (A : Proposition Atom) : (¬¬A → A) ∈ CPL (Atom := Atom) := ⟨A, rfl⟩
144+
145+ /-- Attach a bottom element to a theory `T`, and the principle of explosion for that bottom. -/
146+ @[reducible]
147+ def intuitionisticCompletion (T : Theory Atom) : Theory (WithBot Atom) :=
148+ (WithBot.some <$> T) ∪ IPL
120149
121150open InferenceSystem
122151
123152/-- An inference system is intuitionistic if it derives ex falso quodlibet. TODO: this should be
124153generalised outside the `PL` scope, once we have typeclasses to express that a type possesses an
125154implication connective. -/
126155@ [scoped grind]
127- class IsIntuitionistic (Atom : Type u) [Bot Atom] (S : Type *)
156+ class IsIntuitionistic (Atom : Type u) (S : Type *)
128157 [InferenceSystem S (Proposition Atom)] where
129- /-- The principle of explosion (ex falso quolibet ). -/
158+ /-- The principle of explosion (ex falso quodlibet ). -/
130159 efq (A : Proposition Atom) : S⇓(⊥ → A)
131160
132161/-- An inference system is classical if it validates double-negation elimination. TODO: this should
133162be generalised outside the `PL` scope, once we have typeclasses to express that a type possesses an
134163implication connective. -/
135164@ [scoped grind]
136- class IsClassical (Atom : Type u) [Bot Atom] (S : Type *)
165+ class IsClassical (Atom : Type u) (S : Type *)
137166 [InferenceSystem S (Proposition Atom)] where
138167 /-- Double-negation elimination. -/
139168 dne (A : Proposition Atom) : S⇓(¬¬A → A)
0 commit comments