Skip to content

Commit 9216603

Browse files
Freek98ecavallo
andauthored
BooleanAlgebraStr now infers the underlying set (#1297)
* changed BooleanAlgebraStr to have only structure. * actually use change definition * cleaned up a bit. --------- Co-authored-by: Evan Cavallo <evanc@chalmers.se>
1 parent 3686f9d commit 9216603

2 files changed

Lines changed: 32 additions & 31 deletions

File tree

Cubical/Algebra/BooleanRing/Base.agda

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ BooleanRing ℓ = TypeWithStr ℓ BooleanRingStr
4343

4444
module _ {A : Type ℓ} (BRStr : BooleanRingStr A) where
4545
open CommRingStr
46-
open BooleanRingStr( BRStr)
46+
open BooleanRingStr BRStr
4747
BooleanRingStr→CommRingStr : CommRingStr A
4848
0r BooleanRingStr→CommRingStr = _
4949
1r BooleanRingStr→CommRingStr = _
@@ -80,21 +80,22 @@ module _ {ℓ : Level} (R : CommRing ℓ) (idem : isIdemRing R) where
8080
BoolHom : {ℓ ℓ' : Level} (A : BooleanRing ℓ) (B : BooleanRing ℓ') Type _
8181
BoolHom A B = CommRingHom (BooleanRing→CommRing A) (BooleanRing→CommRing B)
8282

83-
module BooleanAlgebraStr (A : BooleanRing ℓ) where
84-
open BooleanRingStr (A . snd)
85-
_∨_ : ⟨ A ⟩ ⟨ A ⟩ ⟨ A ⟩
83+
module BooleanAlgebraStr {A : Type ℓ} (RingStr : BooleanRingStr A) where
84+
CR = BooleanRing→CommRing (A , RingStr)
85+
open BooleanRingStr RingStr
86+
_∨_ : A A A
8687
a ∨ b = (a + b) + (a · b)
87-
_∧_ : ⟨ A ⟩ ⟨ A ⟩ ⟨ A ⟩
88+
_∧_ : A A A
8889
a ∧ b = a · b
89-
¬_ : ⟨ A ⟩ ⟨ A ⟩
90+
¬_ : A A
9091
¬ a = 𝟙 + a
9192

9293
infix 8 ¬_
9394
infixl 7 _∧_
9495
infixl 6 _∨_
9596

9697
private
97-
variable x y z : ⟨ A ⟩
98+
variable x y z : A
9899

99100
∧Idem : x ∧ x ≡ x
100101
∧Idem = ·Idem _
@@ -106,16 +107,16 @@ module BooleanAlgebraStr (A : BooleanRing ℓ) where
106107
∧Comm = ·Comm _ _
107108

108109
∨Assoc : (x ∨ ( y ∨ z ) ≡ ( x ∨ y ) ∨ z )
109-
∨Assoc = solve! (BooleanRing→CommRing A)
110+
∨Assoc = solve! CR
110111

111112
∨Comm : x ∨ y ≡ y ∨ x
112-
∨Comm = solve! (BooleanRing→CommRing A)
113+
∨Comm = solve! CR
113114

114115
∨IdR : x ∨ 𝟘 ≡ x
115-
∨IdR = solve! (BooleanRing→CommRing A)
116+
∨IdR = solve! CR
116117

117118
∨IdL : 𝟘 ∨ x ≡ x
118-
∨IdL = solve! (BooleanRing→CommRing A)
119+
∨IdL = solve! CR
119120

120121
∧IdR : x ∧ 𝟙 ≡ x
121122
∧IdR = ·IdR _
@@ -124,26 +125,26 @@ module BooleanAlgebraStr (A : BooleanRing ℓ) where
124125
∧IdL = ·IdL _
125126

126127
∧AnnihilR : x ∧ 𝟘 ≡ 𝟘
127-
∧AnnihilR = RingTheory.0RightAnnihilates (CommRing→Ring (BooleanRing→CommRing A)) _
128+
∧AnnihilR = RingTheory.0RightAnnihilates (CommRing→Ring CR) _
128129

129130
∧AnnihilL : 𝟘 ∧ x ≡ 𝟘
130-
∧AnnihilL = RingTheory.0LeftAnnihilates (CommRing→Ring (BooleanRing→CommRing A)) _
131+
∧AnnihilL = RingTheory.0LeftAnnihilates (CommRing→Ring CR) _
131132

132133
characteristic2 : x + x ≡ 𝟘
133-
characteristic2 {x = x} = RingTheory.+Idempotency→0 (CommRing→Ring (BooleanRing→CommRing A)) (x + x) 2x≡4x
134+
characteristic2 {x = x} = RingTheory.+Idempotency→0 (CommRing→Ring CR) (x + x) 2x≡4x
134135
where
135136
2x≡4x : x + x ≡ (x + x) + (x + x)
136137
2x≡4x =
137138
x + x
138139
≡⟨ sym (·Idem (x + x)) ⟩
139140
(x + x) · (x + x)
140-
≡⟨ solve! (BooleanRing→CommRing A)
141+
≡⟨ solve! CR
141142
((x · x) + (x · x)) + ((x · x) + (x · x))
142143
≡⟨ cong₂ _+_ (cong₂ _+_ (·Idem x) (·Idem x)) (cong₂ _+_ (·Idem x) (·Idem x)) ⟩
143144
(x + x) + (x + x) ∎
144145

145146
-IsId : x ≡ - x
146-
-IsId {x = x} = implicitInverse (BooleanRing→Ring A) x x characteristic2
147+
-IsId {x = x} = implicitInverse (CommRing→Ring CR) x x characteristic2
147148

148149
∨Idem : x ∨ x ≡ x
149150
∨Idem { x = x } =
@@ -158,7 +159,7 @@ module BooleanAlgebraStr (A : BooleanRing ℓ) where
158159
1Absorbs∨R : x ∨ 𝟙 ≡ 𝟙
159160
1Absorbs∨R {x = x} =
160161
(x + 𝟙) + (x · 𝟙)
161-
≡⟨ solve! (BooleanRing→CommRing A)
162+
≡⟨ solve! CR
162163
𝟙 + (x + x)
163164
≡⟨ cong (λ y 𝟙 + y) characteristic2 ⟩
164165
𝟙 + 𝟘
@@ -171,11 +172,11 @@ module BooleanAlgebraStr (A : BooleanRing ℓ) where
171172
∧DistR∨ : x ∧ ( y ∨ z) ≡ (x ∧ y) ∨ (x ∧ z)
172173
∧DistR∨ {x = x} {y = y} { z = z} =
173174
x · ((y + z) + (y · z))
174-
≡⟨ solve! (BooleanRing→CommRing A)
175+
≡⟨ solve! CR
175176
x · y + x · z + x · (y · z)
176177
≡⟨ cong (λ a x · y + x · z + a · (y · z)) (sym (·Idem x)) ⟩
177178
x · y + x · z + x · x · (y · z)
178-
≡⟨ solve! (BooleanRing→CommRing A)
179+
≡⟨ solve! CR
179180
x · y + x · z + (x · y) · (x · z) ∎
180181

181182
∧DistL∨ : (x ∨ y) ∧ z ≡ (x ∧ z) ∨ (y ∧ z)
@@ -184,19 +185,19 @@ module BooleanAlgebraStr (A : BooleanRing ℓ) where
184185
∨DistR∧ : x ∨ (y ∧ z) ≡ (x ∨ y) ∧ (x ∨ z)
185186
∨DistR∧ {x = x} {y = y} {z = z} =
186187
x + (y · z) + x · (y · z)
187-
≡⟨ solve! (BooleanRing→CommRing A)
188+
≡⟨ solve! CR
188189
x + 𝟘 + 𝟘 + y · z + 𝟘 + x · y · z
189190
≡⟨ cong (λ a a + 𝟘 + 𝟘 + y · z + 𝟘 + a · y · z) (sym (·Idem x)) ⟩
190191
x · x + 𝟘 + 𝟘 + y · z + 𝟘 + x · x · y · z
191192
≡⟨ cong (λ a x · x + 𝟘 + 𝟘 + y · z + a + x · x · y · z) (sym (characteristic2 {x = (x · y) · z})) ⟩
192193
x · x + 𝟘 + 𝟘 + y · z + (x · y · z + x · y · z) + x · x · y · z
193194
≡⟨ (cong₂ (λ a b x · x + a + b + y · z + (x · y · z + x · y · z) + x · x · y · z)) (xa-xxa≡0 z) (xa-xxa≡0 y) ⟩
194195
x · x + (x · z + x · x · z) + (x · y + x · x · y) + y · z + (x · y · z + x · y · z) + x · x · y · z
195-
≡⟨ solve! (BooleanRing→CommRing A)
196+
≡⟨ solve! CR
196197
(x + y + x · y) · (x + z + x · z) ∎ where
197-
xa≡xxa : (a : ⟨ A ⟩) x · a ≡ (x · x ) · a
198+
xa≡xxa : (a : A) x · a ≡ (x · x ) · a
198199
xa≡xxa a = cong (λ y y · a) (sym (·Idem x))
199-
xa-xxa≡0 : (a : ⟨ A ⟩) 𝟘 ≡ x · a + x · x · a
200+
xa-xxa≡0 : (a : A) 𝟘 ≡ x · a + x · x · a
200201
xa-xxa≡0 a =
201202
𝟘
202203
≡⟨ sym characteristic2 ⟩
@@ -210,7 +211,7 @@ module BooleanAlgebraStr (A : BooleanRing ℓ) where
210211
∧AbsorbL∨ : x ∧ (x ∨ y) ≡ x
211212
∧AbsorbL∨ {x = x} {y = y} =
212213
x · ((x + y) + (x · y))
213-
≡⟨ solve! (BooleanRing→CommRing A)
214+
≡⟨ solve! CR
214215
x · x + (x · y + x · x · y)
215216
≡⟨ cong (λ z z + ((x · y) + (z · y))) (·Idem x) ⟩
216217
x + (x · y + x · y)
@@ -222,7 +223,7 @@ module BooleanAlgebraStr (A : BooleanRing ℓ) where
222223
∨AbsorbL∧ : x ∨ (x ∧ y) ≡ x
223224
∨AbsorbL∧ {x = x} { y = y} =
224225
x + x · y + x · (x · y)
225-
≡⟨ solve! (BooleanRing→CommRing A)
226+
≡⟨ solve! CR
226227
x + (x · y + x · x · y)
227228
≡⟨ cong (λ z x + (x · y + z · y)) (·Idem x) ⟩
228229
x + (x · y + x · y)
@@ -234,7 +235,7 @@ module BooleanAlgebraStr (A : BooleanRing ℓ) where
234235
¬Cancels∧R : x ∧ ¬ x ≡ 𝟘
235236
¬Cancels∧R {x = x} =
236237
x · (𝟙 + x)
237-
≡⟨ solve! (BooleanRing→CommRing A)
238+
≡⟨ solve! CR
238239
x + x · x
239240
≡⟨ cong (λ y x + y) (·Idem x) ⟩
240241
x + x
@@ -249,7 +250,7 @@ module BooleanAlgebraStr (A : BooleanRing ℓ) where
249250
x + ¬ x + (x ∧ ¬ x)
250251
≡⟨ cong (λ z x + ¬ x + z) ¬Cancels∧R ⟩
251252
x + ¬ x + 𝟘
252-
≡⟨ solve! (BooleanRing→CommRing A)
253+
≡⟨ solve! CR
253254
x ∨ 𝟙
254255
≡⟨ 1Absorbs∨R ⟩
255256
𝟙 ∎
@@ -274,15 +275,15 @@ module BooleanAlgebraStr (A : BooleanRing ℓ) where
274275
¬1≡0 = characteristic2 {x = 𝟙}
275276

276277
DeMorgan¬∨ : ¬ (x ∨ y) ≡ ¬ x ∧ ¬ y
277-
DeMorgan¬∨ = solve! (BooleanRing→CommRing A)
278+
DeMorgan¬∨ = solve! CR
278279

279280
DeMorgan¬∧ : ¬ (x ∧ y) ≡ ¬ x ∨ ¬ y
280281
DeMorgan¬∧ {x = x} {y = y} =
281282
𝟙 + x · y
282-
≡⟨ solve! (BooleanRing→CommRing A)
283+
≡⟨ solve! CR
283284
𝟘 + 𝟘 + 𝟙 + x · y
284285
≡⟨ cong₂ (λ a b ((a + b) + 𝟙) + (x · y)) (sym (characteristic2 {x = 𝟙 + x})) (sym (characteristic2 {x = y})) ⟩
285286
((𝟙 + x) + (𝟙 + x)) + (y + y) + 𝟙 + x · y
286-
≡⟨ solve! (BooleanRing→CommRing A)
287+
≡⟨ solve! CR
287288
¬ x ∨ ¬ y ∎
288289

Cubical/Algebra/BooleanRing/Initial.agda

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module _ {ℓ : Level} (B : BooleanRing ℓ) where
1818
B' = BooleanRing→CommRing B
1919

2020
open CommRingStr (snd B')
21-
open BooleanAlgebraStr B
21+
open BooleanAlgebraStr (snd B)
2222
open IsCommRingHom
2323

2424
BoolBR→BAMap : Bool ⟨ B ⟩

0 commit comments

Comments
 (0)