Debian Codegraph @

src/Algebra/Morphism/Consequences.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Some properties of Magma homomorphisms
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 module Algebra.Morphism.Consequences where
10
11 open import Algebra using (Magma)
12 open import Algebra.Morphism.Definitions using (Homomorphic₂)
13 open import Data.Product.Base using (_,_)
14 open import Function.Base using (id; _∘_)
15 open import Function.Definitions
16 using (Injective; Congruent; Inverseᵇ; Inverseˡ)
17 import Relation.Binary.Reasoning.Setoid as ≈-Reasoning
18
19 ------------------------------------------------------------------------
20 -- If f and g are mutually inverse maps between A and B, g is congruent,
21 -- f is a homomorphism, then g is a homomorphism.
22
23 module _ {α α= β β=} (M₁ : Magma α α=) (M₂ : Magma β β=) where
24
25 private
26 open module M₁ = Magma M₁ using () renaming (_≈_ to _≈₁_; _∙_ to _∙₁_)
27 open module M₂ = Magma M₂ using () renaming (_≈_ to _≈₂_; _∙_ to _∙₂_)
28
29 homomorphic₂-inv : ∀ {f g} → Congruent _≈₂_ _≈₁_ g →
30 Inverseᵇ _≈₁_ _≈₂_ f g →
31 Homomorphic₂ _ _ _≈₂_ f _∙₁_ _∙₂_ →
32 Homomorphic₂ _ _ _≈₁_ g _∙₂_ _∙₁_
33 homomorphic₂-inv {f} {g} g-cong (invˡ , invʳ) homo x y = begin
34 g (x ∙₂ y) ≈⟨ g-cong (M₂.∙-cong (invˡ M₁.refl) (invˡ M₁.refl)) ⟨
35 g (f (g x) ∙₂ f (g y)) ≈⟨ g-cong (homo (g x) (g y)) ⟨
36 g (f (g x ∙₁ g y)) ≈⟨ invʳ M₂.refl ⟩
37 g x ∙₁ g y ∎
38 where open ≈-Reasoning M₁.setoid
39
40 homomorphic₂-inj : ∀ {f g} → Injective _≈₁_ _≈₂_ f →
41 Inverseˡ _≈₁_ _≈₂_ f g →
42 Homomorphic₂ _ _ _≈₂_ f _∙₁_ _∙₂_ →
43 Homomorphic₂ _ _ _≈₁_ g _∙₂_ _∙₁_
44 homomorphic₂-inj {f} {g} inj invˡ homo x y = inj (begin
45 f (g (x ∙₂ y)) ≈⟨ invˡ M₁.refl ⟩
46 x ∙₂ y ≈⟨ M₂.∙-cong (invˡ M₁.refl) (invˡ M₁.refl) ⟨
47 f (g x) ∙₂ f (g y) ≈⟨ homo (g x) (g y) ⟨
48 f (g x ∙₁ g y) ∎)
49 where open ≈-Reasoning M₂.setoid