Skip to content

Commit 6d0c7ac

Browse files
authored
Merge pull request #1443 from andreaslyn/infinitary-universal-algebra
Term algebra and congruence
2 parents dd3c399 + 79fd12c commit 6d0c7ac

File tree

15 files changed

+579
-71
lines changed

15 files changed

+579
-71
lines changed

_CoqProject

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ theories/Spectra/Coinductive.v
354354
theories/Algebra/Universal/Algebra.v
355355
theories/Algebra/Universal/Homomorphism.v
356356
theories/Algebra/Universal/Operation.v
357+
theories/Algebra/Universal/Congruence.v
358+
theories/Algebra/Universal/TermAlgebra.v
357359

358360
#
359361
# Algebra

theories/Algebra/Universal/Algebra.v

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ Global Existing Instance hset_algebra.
9595

9696
Global Coercion carriers : Algebra >-> Funclass.
9797

98+
Bind Scope Algebra_scope with Algebra.
99+
98100
Definition SigAlgebra (σ : Signature) : Type
99101
:= {c : Carriers σ
100102
| { _ : forall (u : Symbol σ), Operation c (σ u)
@@ -158,8 +160,7 @@ Defined.
158160
Arguments path_path_algebra {_} {σ} {A B}%Algebra_scope (p q r)%path_scope.
159161

160162
Module notations_algebra.
161-
(** Conflicts with inverse notation so cannot be reserved *)
162-
Global Notation "u ^^ A" := (operations A u)
163-
(at level 6, no associativity)
164-
: Algebra_scope.
163+
164+
Global Notation "u .# A" := (operations A u) : Algebra_scope.
165+
165166
End notations_algebra.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
(** This file implements algebra congruence relation. It serves as a
2+
universal algebra generalization of normal subgroup, ring ideal, etc.
3+
4+
Congruence is used to construct quotients, in similarity with how
5+
normal subgroup and ring ideal is used to construct quotients. *)
6+
7+
Require Export HoTT.Algebra.Universal.Algebra.
8+
9+
Require Import
10+
HoTT.Basics
11+
HoTT.Types
12+
HoTT.HProp
13+
HoTT.Classes.interfaces.canonical_names
14+
HoTT.Algebra.Universal.Homomorphism.
15+
16+
Unset Elimination Schemes.
17+
18+
Import notations_algebra.
19+
20+
Section congruence.
21+
Context {σ : Signature} (A : Algebra σ) (Φ : forall s, Relation (A s)).
22+
23+
(** A finitary operation [f : A s1 * A s2 * ... * A sn -> A t]
24+
satisfies [OpCompatible f] iff
25+
26+
<<
27+
Φ s1 x1 y1 * Φ s2 x2 y2 * ... * Φ sn xn yn
28+
>>
29+
30+
implies
31+
32+
<<
33+
Φ t (f (x1, x2, ..., xn)) (f (y1, y2, ..., yn)).
34+
>>
35+
36+
The below definition generalizes this to infinitary operations.
37+
*)
38+
39+
Definition OpCompatible {w : SymbolType σ} (f : Operation A w) : Type
40+
:= forall (a b : DomOperation A w),
41+
(forall i : Arity w, Φ (sorts_dom w i) (a i) (b i)) ->
42+
Φ (sort_cod w) (f a) (f b).
43+
44+
Class OpsCompatible : Type
45+
:= ops_compatible : forall (u : Symbol σ), OpCompatible u.#A.
46+
47+
Global Instance trunc_ops_compatible `{Funext} {n : trunc_index}
48+
`{!forall s x y, IsTrunc n (Φ s x y)}
49+
: IsTrunc n OpsCompatible.
50+
Proof.
51+
apply trunc_forall.
52+
Defined.
53+
54+
(** A family of relations [Φ] is a congruence iff it is a family of
55+
mere equivalence relations and [OpsCompatible A Φ] holds. *)
56+
57+
Class IsCongruence : Type := Build_IsCongruence
58+
{ is_mere_relation_cong : forall (s : Sort σ), is_mere_relation (A s) (Φ s)
59+
; equiv_rel_cong : forall (s : Sort σ), EquivRel (Φ s)
60+
; ops_compatible_cong : OpsCompatible }.
61+
62+
Global Arguments Build_IsCongruence {is_mere_relation_cong}
63+
{equiv_rel_cong}
64+
{ops_compatible_cong}.
65+
66+
Global Existing Instance is_mere_relation_cong.
67+
68+
Global Existing Instance equiv_rel_cong.
69+
70+
Global Existing Instance ops_compatible_cong.
71+
72+
Global Instance hprop_is_congruence `{Funext} : IsHProp IsCongruence.
73+
Proof.
74+
apply (equiv_hprop_allpath _)^-1.
75+
intros [C1 C2 C3] [D1 D2 D3].
76+
by destruct (path_ishprop C1 D1),
77+
(path_ishprop C2 D2),
78+
(path_ishprop C3 D3).
79+
Defined.
80+
81+
End congruence.
82+
83+
(** A homomorphism [f : forall s, A s -> B s] is compatible
84+
with a congruence [Φ] iff [Φ s x y] implies [f s x = f s y]. *)
85+
86+
Definition HomCompatible {σ : Signature} {A B : Algebra σ}
87+
(Φ : forall s, Relation (A s)) `{!IsCongruence A Φ}
88+
(f : forall s, A s -> B s) `{!IsHomomorphism f}
89+
: Type
90+
:= forall s (x y : A s), Φ s x y -> f s x = f s y.
91+

theories/Algebra/Universal/Homomorphism.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Section is_homomorphism.
2828
Qed.
2929

3030
Class IsHomomorphism : Type
31-
:= oppreserving_hom : forall (u : Symbol σ), OpPreserving u^^A u^^B.
31+
:= oppreserving_hom : forall (u : Symbol σ), OpPreserving u.#A u.#B.
3232

3333
Global Instance hprop_is_homomorphism `{Funext}
3434
: IsHProp IsHomomorphism.

0 commit comments

Comments
 (0)