Skip to content

Commit 3462b98

Browse files
authored
SelfInverse operations on Algebras and their properties (#1914)
1 parent 97aa2b7 commit 3462b98

File tree

6 files changed

+115
-26
lines changed

6 files changed

+115
-26
lines changed

CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -1591,8 +1591,23 @@ Other minor changes
15911591
```
15921592
and their corresponding algebraic subbundles.
15931593

1594+
* Added new proofs to `Algebra.Consequences.Base`:
1595+
```agda
1596+
reflexive+selfInverse⇒involutive : Reflexive _≈_ →
1597+
SelfInverse _≈_ f →
1598+
Involutive _≈_ f
1599+
```
1600+
15941601
* Added new proofs to `Algebra.Consequences.Setoid`:
15951602
```agda
1603+
involutive⇒surjective : Involutive f → Surjective f
1604+
selfInverse⇒involutive : SelfInverse f → Involutive f
1605+
selfInverse⇒congruent : SelfInverse f → Congruent f
1606+
selfInverse⇒inverseᵇ : SelfInverse f → Inverseᵇ f f
1607+
selfInverse⇒surjective : SelfInverse f → Surjective f
1608+
selfInverse⇒injective : SelfInverse f → Injective f
1609+
selfInverse⇒bijective : SelfInverse f → Bijective f
1610+
15961611
comm+idˡ⇒id : Commutative _•_ → LeftIdentity e _•_ → Identity e _•_
15971612
comm+idʳ⇒id : Commutative _•_ → RightIdentity e _•_ → Identity e _•_
15981613
comm+zeˡ⇒ze : Commutative _•_ → LeftZero e _•_ → Zero e _•_
@@ -1683,6 +1698,8 @@ Other minor changes
16831698

16841699
* Added new definition to `Algebra.Definitions`:
16851700
```agda
1701+
SelfInverse : Op₁ A → Set _
1702+
16861703
LeftDividesˡ : Op₂ A → Op₂ A → Set _
16871704
LeftDividesʳ : Op₂ A → Op₂ A → Set _
16881705
RightDividesˡ : Op₂ A → Op₂ A → Set _

src/Algebra/Consequences/Base.agda

+16-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- The Agda standard library
33
--
44
-- Lemmas relating algebraic definitions (such as associativity and
5-
-- commutativity) that don't the equality relation to be a setoid.
5+
-- commutativity) that don't require the equality relation to be a setoid.
66
------------------------------------------------------------------------
77

88
{-# OPTIONS --without-K --safe #-}
@@ -14,9 +14,19 @@ open import Algebra.Core
1414
open import Algebra.Definitions
1515
open import Data.Sum.Base
1616
open import Relation.Binary.Core
17+
open import Relation.Binary.Definitions using (Reflexive)
18+
19+
module _ {ℓ} {_•_ : Op₂ A} (_≈_ : Rel A ℓ) where
20+
21+
sel⇒idem : Selective _≈_ _•_ Idempotent _≈_ _•_
22+
sel⇒idem sel x with sel x x
23+
... | inj₁ x•x≈x = x•x≈x
24+
... | inj₂ x•x≈x = x•x≈x
25+
26+
module _ {ℓ} {f : Op₁ A} (_≈_ : Rel A ℓ) where
27+
28+
reflexive+selfInverse⇒involutive : Reflexive _≈_
29+
SelfInverse _≈_ f
30+
Involutive _≈_ f
31+
reflexive+selfInverse⇒involutive refl inv _ = inv refl
1732

18-
sel⇒idem : {ℓ} {_•_ : Op₂ A} (_≈_ : Rel A ℓ)
19-
Selective _≈_ _•_ Idempotent _≈_ _•_
20-
sel⇒idem _ sel x with sel x x
21-
... | inj₁ x•x≈x = x•x≈x
22-
... | inj₂ x•x≈x = x•x≈x

src/Algebra/Consequences/Setoid.agda

+43
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ open import Algebra.Definitions _≈_
1717
open import Data.Sum.Base using (inj₁; inj₂)
1818
open import Data.Product using (_,_)
1919
open import Function.Base using (_$_)
20+
import Function.Definitions as FunDefs
2021
import Relation.Binary.Consequences as Bin
2122
open import Relation.Binary.Reasoning.Setoid S
2223
open import Relation.Unary using (Pred)
@@ -28,6 +29,48 @@ open import Relation.Unary using (Pred)
2829

2930
open import Algebra.Consequences.Base public
3031

32+
------------------------------------------------------------------------
33+
-- Involutive/SelfInverse functions
34+
35+
module _ {f : Op₁ A} (inv : Involutive f) where
36+
37+
open FunDefs _≈_ _≈_
38+
39+
involutive⇒surjective : Surjective f
40+
involutive⇒surjective y = f y , inv y
41+
42+
module _ {f : Op₁ A} (self : SelfInverse f) where
43+
44+
selfInverse⇒involutive : Involutive f
45+
selfInverse⇒involutive = reflexive+selfInverse⇒involutive _≈_ refl self
46+
47+
private
48+
49+
inv = selfInverse⇒involutive
50+
51+
open FunDefs _≈_ _≈_
52+
53+
selfInverse⇒congruent : Congruent f
54+
selfInverse⇒congruent {x} {y} x≈y = sym (self (begin
55+
f (f x) ≈⟨ inv x ⟩
56+
x ≈⟨ x≈y ⟩
57+
y ∎))
58+
59+
selfInverse⇒inverseᵇ : Inverseᵇ f f
60+
selfInverse⇒inverseᵇ = inv , inv
61+
62+
selfInverse⇒surjective : Surjective f
63+
selfInverse⇒surjective = involutive⇒surjective inv
64+
65+
selfInverse⇒injective : Injective f
66+
selfInverse⇒injective {x} {y} x≈y = begin
67+
x ≈˘⟨ self x≈y ⟩
68+
f (f y) ≈⟨ inv y ⟩
69+
y ∎
70+
71+
selfInverse⇒bijective : Bijective f
72+
selfInverse⇒bijective = selfInverse⇒injective , selfInverse⇒surjective
73+
3174
------------------------------------------------------------------------
3275
-- Magma-like structures
3376

src/Algebra/Definitions.agda

+3
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ _∙_ Absorbs _∘_ = ∀ x y → (x ∙ (x ∘ y)) ≈ x
126126
Absorptive : Op₂ A Op₂ A Set _
127127
Absorptive ∙ ∘ = (∙ Absorbs ∘) × (∘ Absorbs ∙)
128128

129+
SelfInverse : Op₁ A Set _
130+
SelfInverse f = {x y} f x ≈ y f y ≈ x
131+
129132
Involutive : Op₁ A Set _
130133
Involutive f = x f (f x) ≈ x
131134

src/Data/Parity/Properties.agda

+18-16
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ open import Relation.Nullary using (yes; no)
2525

2626
open import Algebra.Structures {A = Parity} _≡_
2727
open import Algebra.Definitions {A = Parity} _≡_
28-
29-
open import Algebra.Consequences.Propositional using (comm+distrˡ⇒distrʳ)
28+
open import Algebra.Consequences.Propositional
29+
using (selfInverse⇒involutive; selfInverse⇒injective; comm+distrˡ⇒distrʳ)
3030
open import Algebra.Morphism.Structures
3131

3232
------------------------------------------------------------------------
@@ -52,22 +52,24 @@ _≟_ : DecidableEquality Parity
5252
------------------------------------------------------------------------
5353
-- _⁻¹
5454

55-
p≢p⁻¹ : p p ≢ p ⁻¹
56-
p≢p⁻¹ 1ℙ ()
57-
p≢p⁻¹ 0ℙ ()
55+
-- Algebraic properties of _⁻¹
56+
57+
⁻¹-selfInverse : SelfInverse _⁻¹
58+
⁻¹-selfInverse { 1ℙ } { 0ℙ } refl = refl
59+
⁻¹-selfInverse { 0ℙ } { 1ℙ } refl = refl
5860

59-
⁻¹-inverts : {p q} p ⁻¹ ≡ q q ⁻¹ ≡ p
60-
⁻¹-inverts { 1ℙ } { 0ℙ } refl = refl
61-
⁻¹-inverts { 0ℙ } { 1ℙ } refl = refl
61+
⁻¹-involutive : Involutive _⁻¹
62+
⁻¹-involutive = selfInverse⇒involutive ⁻¹-selfInverse
6263

63-
⁻¹-involutive : p (p ⁻¹) ⁻¹ ≡ p
64-
⁻¹-involutive p = ⁻¹-inverts refl
64+
⁻¹-injective : Injective _≡_ _≡_ _⁻¹
65+
⁻¹-injective = selfInverse⇒injective ⁻¹-selfInverse
6566

66-
⁻¹-injective : {p q} p ⁻¹ ≡ q ⁻¹ p ≡ q
67-
⁻¹-injective {p} {q} eq = begin
68-
p ≡⟨ sym (⁻¹-inverts eq) ⟩
69-
(q ⁻¹) ⁻¹ ≡⟨ ⁻¹-involutive q ⟩
70-
q ∎ where open ≡-Reasoning
67+
------------------------------------------------------------------------
68+
-- other properties of _⁻¹
69+
70+
p≢p⁻¹ : p p ≢ p ⁻¹
71+
p≢p⁻¹ 1ℙ ()
72+
p≢p⁻¹ 0ℙ ()
7173

7274
------------------------------------------------------------------------
7375
-- ⁻¹ and _+_
@@ -480,7 +482,7 @@ toSign-isGroupIsomorphism = record
480482

481483
suc-homo-⁻¹ : n (parity (suc n)) ⁻¹ ≡ parity n
482484
suc-homo-⁻¹ zero = refl
483-
suc-homo-⁻¹ (suc n) = ⁻¹-inverts (suc-homo-⁻¹ n)
485+
suc-homo-⁻¹ (suc n) = ⁻¹-selfInverse (suc-homo-⁻¹ n)
484486

485487
-- parity is a _+_ homomorphism
486488

src/Data/Sign/Properties.agda

+18-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ open import Relation.Nullary.Decidable using (yes; no)
2121

2222
open import Algebra.Structures {A = Sign} _≡_
2323
open import Algebra.Definitions {A = Sign} _≡_
24+
open import Algebra.Consequences.Propositional
25+
using (selfInverse⇒involutive; selfInverse⇒injective)
2426

2527
------------------------------------------------------------------------
2628
-- Equality
@@ -45,14 +47,26 @@ _≟_ : DecidableEquality Sign
4547
------------------------------------------------------------------------
4648
-- opposite
4749

50+
-- Algebraic properties of opposite
51+
52+
opposite-selfInverse : SelfInverse opposite
53+
opposite-selfInverse { - } { + } refl = refl
54+
opposite-selfInverse { + } { - } refl = refl
55+
56+
opposite-involutive : Involutive opposite
57+
opposite-involutive = selfInverse⇒involutive opposite-selfInverse
58+
59+
opposite-injective : Injective _≡_ _≡_ opposite
60+
opposite-injective = selfInverse⇒injective opposite-selfInverse
61+
62+
63+
------------------------------------------------------------------------
64+
-- other properties of opposite
65+
4866
s≢opposite[s] : s s ≢ opposite s
4967
s≢opposite[s] - ()
5068
s≢opposite[s] + ()
5169

52-
opposite-injective : {s t} opposite s ≡ opposite t s ≡ t
53-
opposite-injective { - } { - } refl = refl
54-
opposite-injective { + } { + } refl = refl
55-
5670
------------------------------------------------------------------------
5771
-- _*_
5872

0 commit comments

Comments
 (0)