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
99public 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), and `imp` (implication). Conjunction, disjunction, negation, and verum are
21+ derived connectives following the Lukasiewicz convention.
2022- `Theory` : set of `Proposition`.
2123- `IsIntuitionistic` : a theory is intuitionistic if it contains the principle of explosion.
2224- `IsClassical` : an intuitionistic theory is classical if it further contains double negation
@@ -42,44 +44,54 @@ variable {Atom : Type u} [DecidableEq Atom]
4244
4345namespace Cslib.Logic.PL
4446
45- /-- Propositions. -/
47+ /-- Propositions. Primitives are atoms, falsum, and implication. -/
4648inductive Proposition (Atom : Type u) : Type u where
4749 /-- Propositional atoms -/
4850 | atom (x : Atom)
49- /-- Conjunction -/
50- | and (a b : Proposition Atom)
51- /-- Disjunction -/
52- | or (a b : Proposition Atom)
51+ /-- Falsum / bottom -/
52+ | bot
5353 /-- Implication -/
54- | impl (a b : Proposition Atom)
54+ | imp (a b : Proposition Atom)
5555deriving DecidableEq, BEq
5656
57- instance instBotProposition [Bot Atom] : Bot (Proposition Atom) := ⟨.atom ⊥⟩
58- instance instInhabitedOfBot [Bot Atom] : Inhabited Atom := ⟨⊥⟩
57+ /-- Negation as a derived connective: ¬A := A → ⊥ -/
58+ abbrev Proposition.neg : Proposition Atom → Proposition Atom := (Proposition.imp · .bot)
5959
60- /-- We view negation as a defined connective ~A := A → ⊥ -/
61- abbrev Proposition.neg [Bot Atom] : Proposition Atom → Proposition Atom := (Proposition.impl · ⊥)
60+ /-- Verum / top as a derived connective: ⊤ := ⊥ → ⊥ -/
61+ abbrev Proposition.top : Proposition Atom := .imp .bot .bot
6262
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)
63+ /-- Disjunction as a derived connective: A ∨ B := ¬A → B -/
64+ abbrev Proposition.or (A B : Proposition Atom) : Proposition Atom :=
65+ .imp (.imp A .bot) B
6566
66- instance instTopProposition [Inhabited Atom] : Top (Proposition Atom) := ⟨.top⟩
67+ /-- Conjunction as a derived connective: A ∧ B := ¬(A → ¬B) -/
68+ abbrev Proposition.and (A B : Proposition Atom) : Proposition Atom :=
69+ .imp (.imp A (.imp B .bot)) .bot
6770
68- example [Bot Atom] : (⊤ : Proposition Atom) = Proposition.impl ⊥ ⊥ := rfl
71+ /-- Biconditional as a derived connective: A ↔ B := (A → B) ∧ (B → A) -/
72+ abbrev Proposition.iff (A B : Proposition Atom) : Proposition Atom :=
73+ (A.imp B).and (B.imp A)
74+
75+ instance : Bot (Proposition Atom) := ⟨.bot⟩
76+ instance : Top (Proposition Atom) := ⟨.top⟩
6977
7078@[inherit_doc] scoped infix :36 " ∧ " => Proposition.and
7179@[inherit_doc] scoped infix :35 " ∨ " => Proposition.or
72- @[inherit_doc] scoped infix :30 " → " => Proposition.impl
80+ @[inherit_doc] scoped infix :30 " → " => Proposition.imp
7381@[inherit_doc] scoped prefix :40 " ¬ " => Proposition.neg
7482
83+ /-- Register `Proposition` as an instance of `PropositionalConnectives`. -/
84+ instance : PropositionalConnectives (Proposition Atom) where
85+ bot := .bot
86+ imp := .imp
87+
7588/-- Substitute each atom in a proposition for a proposition, possibly changing the atomic
7689language. -/
7790def Proposition.subst {Atom Atom' : Type u} (f : Atom → Proposition Atom') :
7891 Proposition Atom → Proposition Atom'
7992 | 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)
93+ | bot => .bot
94+ | imp A B => .imp (A.subst f) (B.subst f)
8395
8496-- This is probably a lawful monad, but that doesn't seem to be important.
8597instance : Monad Proposition where
@@ -102,45 +114,45 @@ instance : Functor Theory where
102114abbrev MPL : Theory (Atom) := ∅
103115
104116/-- Intuitionistic propositional logic adds the principle of explosion (ex falso quodlibet). -/
105- abbrev IPL [Bot Atom] : Theory Atom :=
106- Set.range (⊥ → ·)
117+ abbrev IPL : Theory Atom :=
118+ Set.range (Proposition.imp ⊥ ·)
107119
108120/-- Classical logic further adds double negation elimination. -/
109- abbrev CPL [Bot Atom] : Theory Atom :=
121+ abbrev CPL : Theory Atom :=
110122 Set.range (fun (A : Proposition Atom) ↦ ¬¬A → A)
111123
112124/-- A theory is intuitionistic if it validates ex falso quodlibet. -/
113125@ [scoped grind]
114- class IsIntuitionistic [Bot Atom] (T : Theory Atom) where
126+ class IsIntuitionistic (T : Theory Atom) where
115127 efq (A : Proposition Atom) : (⊥ → A) ∈ T
116128
117129omit [DecidableEq Atom] in
118130@ [scoped grind =]
119- theorem isIntuitionisticIff [Bot Atom] (T : Theory Atom) : IsIntuitionistic T ↔ IPL ⊆ T := by grind
131+ theorem isIntuitionisticIff (T : Theory Atom) : IsIntuitionistic T ↔ IPL ⊆ T := by grind
120132
121133/-- A theory is classical if it validates double-negation elimination. -/
122134@ [scoped grind]
123- class IsClassical [Bot Atom] (T : Theory Atom) where
135+ class IsClassical (T : Theory Atom) where
124136 dne (A : Proposition Atom) : (¬¬A → A) ∈ T
125137
126138omit [DecidableEq Atom] in
127139@ [scoped grind =]
128- theorem isClassicalIff [Bot Atom] (T : Theory Atom) : IsClassical T ↔ CPL ⊆ T := by grind
140+ theorem isClassicalIff (T : Theory Atom) : IsClassical T ↔ CPL ⊆ T := by grind
129141
130- instance instIsIntuitionisticIPL [Bot Atom] : IsIntuitionistic (Atom := Atom) IPL where
142+ instance instIsIntuitionisticIPL : IsIntuitionistic (Atom := Atom) IPL where
131143 efq A := Set.mem_range.mpr ⟨A, rfl⟩
132144
133- instance instIsClassicalCPL [Bot Atom] : IsClassical (Atom := Atom) CPL where
145+ instance instIsClassicalCPL : IsClassical (Atom := Atom) CPL where
134146 dne A := Set.mem_range.mpr ⟨A, rfl⟩
135147
136148omit [DecidableEq Atom] in
137149@ [scoped grind →]
138- theorem instIsIntuitionisticExtention [Bot Atom] {T T' : Theory Atom} [IsIntuitionistic T]
150+ theorem instIsIntuitionisticExtention {T T' : Theory Atom} [IsIntuitionistic T]
139151 (h : T ⊆ T') : IsIntuitionistic T' := by grind
140152
141153omit [DecidableEq Atom] in
142154@ [scoped grind →]
143- theorem instIsClassicalExtention [Bot Atom] {T T' : Theory Atom} [IsClassical T] (h : T ⊆ T') :
155+ theorem instIsClassicalExtention {T T' : Theory Atom} [IsClassical T] (h : T ⊆ T') :
144156 IsClassical T' := by grind
145157
146158/-- Attach a bottom element to a theory `T`, and the principle of explosion for that bottom. -/
0 commit comments