Skip to content

Commit 449b54c

Browse files
Displayed algebra (UniMath#2008)
This PR introduces enhancements to the module on universal algebra. Along with several minor improvements, we introduce the concept of _displayed algebra_. This work will be presented at [HOTT-UF 2025](https://hott-uf.github.io/2025/). --------- Co-authored-by: Calosci Matteo <calomat@libero.it> Co-authored-by: CalosciMatteo <116155090+CalosciMatteo@users.noreply.github.com>
1 parent 77f1c04 commit 449b54c

File tree

14 files changed

+1919
-13
lines changed

14 files changed

+1919
-13
lines changed

UniMath/Algebra/.package/files

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@ Modules/Quotient.v
2525
Modules.v
2626
Matrix.v
2727
Universal/HVectors.v
28+
Universal/HVecRel.v
2829
Universal/SortedTypes.v
2930
Universal/Signatures.v
3031
Universal/Algebras.v
32+
Universal/Algebras_eq.v
33+
Universal/SubAlgebras.v
34+
Universal/DisplayedAlgebras.v
35+
Universal/Congruences.v
3136
Universal/Terms.v
3237
Universal/TermAlgebras.v
3338
Universal/VTerms.v

UniMath/Algebra/Universal/Algebras.v

Lines changed: 120 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
(** Gianluca Amato, Marco Maggesi, Cosimo Perini Brogi 2019-2023 *)
33

44
Require Import UniMath.Foundations.All.
5+
Require Import UniMath.MoreFoundations.All.
56

67
Require Export UniMath.Algebra.Universal.SortedTypes.
78
Require Export UniMath.Algebra.Universal.Signatures.
@@ -103,9 +104,10 @@ Bind Scope hom_scope with hom.
103104

104105
Local Open Scope hom.
105106

106-
Definition hom2fun {σ: signature} {A1 A2: algebra σ} (f: A1 ↷ A2): ∏ s: sorts σ, support A1 s → support A2 s:= pr1 f.
107+
Definition hom2fun {σ: signature} {A1 A2: algebra σ} (f: A1 ↷ A2)
108+
: sfun (support A1) (support A2) := pr1 f.
107109

108-
Coercion hom2fun: hom >-> Funclass.
110+
Coercion hom2fun: hom >-> sfun.
109111

110112
Definition hom2axiom {σ: signature} {A1 A2: algebra σ} (f: A1 ↷ A2) := pr2 f.
111113

@@ -234,5 +236,121 @@ Definition make_hSetalgebra {σ : signature} {A: algebra σ} (setproperty: has_s
234236
Definition hSetalgebra_to_algebra {σ : signature} (A: hSetalgebra σ): algebra σ
235237
:= ((λ s : sorts σ, pr1 (pr1 A s)),, pr2 A).
236238

239+
Coercion hSetalgebra_to_algebra : hSetalgebra >-> algebra.
240+
237241
Definition has_supportsets_hSetalgebra {σ : signature} (A: hSetalgebra σ): has_supportsets (hSetalgebra_to_algebra A)
238242
:= λ s: sorts σ, setproperty (pr1 A s).
243+
244+
Lemma transportf_fun_op {σ : signature} {A B : sUU (sorts σ)}
245+
(p : A = B)
246+
(nm : names σ) (f : (A⋆ (arity nm) → A (sort nm)))
247+
: transportf (λ x : sUU (sorts σ), x⋆ (arity nm) → x (sort nm)) p f
248+
= (transportf (λ x : sUU (sorts σ), x (sort nm)) p) ∘ f ∘ (transportb (λ x : sUU (sorts σ), x⋆ (arity nm)) p).
249+
Proof.
250+
induction p.
251+
apply idpath.
252+
Defined.
253+
254+
Lemma transportf_fun_op2 {σ : signature} {A : sUU (sorts σ)}
255+
(D D' : ∏ s : sorts σ, A s → UU)
256+
(p : D = D')
257+
(nm : names σ)
258+
(base_xs : hvec (vec_map A (arity nm)))
259+
(opsAnm : (A⋆ (arity nm) → A (sort nm)))
260+
(f : hvec (h1lower (h1map D base_xs)) → D (sort nm) (opsAnm base_xs))
261+
: transportf
262+
(λ x : ∏ s : sorts σ, A s → UU,
263+
hvec (h1lower (h1map x base_xs)) → x (sort nm) (opsAnm base_xs))
264+
p f
265+
= (transportf
266+
(λ D0 : ∏ s : sorts σ, A s → UU , D0 (sort nm) (opsAnm base_xs)) p) ∘ f ∘
267+
(transportb (λ D0, hvec (h1lower (h1map D0 base_xs))) p).
268+
Proof.
269+
induction p.
270+
apply idpath.
271+
Defined.
272+
273+
(*The proof is the same of [transportf_funextsec], but this statement is not captured by it*)
274+
Lemma transportf_funextsec_op
275+
{S : UU} {A : sUU S}
276+
{l : list S}
277+
(D D' : ∏ s : S, A s → UU)
278+
(H : ∏ (s: S), D s = D' s)
279+
(s : S)
280+
(a : A s)
281+
(d : D s a)
282+
283+
: transportf (λ D0 : ∏ s : S, A s → UU, D0 s a) (funextsec _ _ _ H) d =
284+
transportf (λ Ds0 : A s -> UU, Ds0 a) (H s) d.
285+
Proof.
286+
use (toforallpaths_induction' S (λ s, A s → UU) D D'
287+
(λ H', transportf
288+
(λ D0 : ∏ s : S, A s → UU, D0 s a)
289+
(funextsec (λ s : S, A s → UU) D D' H') d
290+
= transportf
291+
(λ Ds0 : A s → UU, Ds0 a)
292+
(H' s) d ) _ H).
293+
intro e.
294+
clear H.
295+
simpl.
296+
297+
set (XR := homotinvweqweq (weqtoforallpaths _ D D') e).
298+
set (H := funextsec (λ s, A s → UU) D D' (toforallpaths _ D D' e)).
299+
set (P' := (λ D0 : ∏ s : S, A s → UU, D0 s a)).
300+
use pathscomp0.
301+
- exact (transportf P' e d).
302+
- use (transportf_paths _ XR).
303+
- induction e. apply idpath.
304+
Defined.
305+
306+
Lemma transportb_funextsec_op
307+
{S : UU} {A : sUU S}
308+
{l : list S}
309+
(D D' : ∏ s : S, A s → UU)
310+
(H : ∏ (s: S), D s = D' s)
311+
(s : S)
312+
(a : A s)
313+
(d : D' s a)
314+
315+
: transportb (λ D0 : ∏ s : S, A s → UU, D0 s a) (funextsec _ _ _ H) d =
316+
transportb (λ Ds0 : A s -> UU, Ds0 a) (H s) d.
317+
Proof.
318+
use (toforallpaths_induction' S (λ s, A s → UU) D D'
319+
(λ H', transportb
320+
(λ D0 : ∏ s : S, A s → UU, D0 s a)
321+
(funextsec (λ s : S, A s → UU) D D' H') d
322+
= transportb
323+
(λ Ds0 : A s → UU, Ds0 a)
324+
(H' s) d ) _ H).
325+
intro e.
326+
clear H.
327+
simpl.
328+
329+
set (XR := homotinvweqweq (weqtoforallpaths _ D D') e).
330+
set (H := funextsec (λ s, A s → UU) D D' (toforallpaths _ D D' e)).
331+
set (P' := (λ D0 : ∏ s : S, A s → UU, D0 s a)).
332+
use pathscomp0.
333+
- exact (transportb P' e d).
334+
- use (transportf_paths _ _).
335+
use invrot.
336+
eapply pathscomp0.
337+
{ use pathsinv0inv0. }
338+
exact XR.
339+
- induction e. apply idpath.
340+
Defined.
341+
342+
Lemma transportf_funextsec_op'
343+
{σ : signature} {A : algebra σ}
344+
(D D' : ∏ s : sorts σ, A s → UU)
345+
(H : ∏ (s: sorts σ), D s = D' s)
346+
(nm : names σ)
347+
(base_xs : hvec (vec_map A (arity nm)))
348+
(opsAnm : (A⋆ (arity nm) → A (sort nm)))
349+
(f : D (sort nm) (ops A nm base_xs))
350+
351+
: transportf (λ D0 : ∏ s : sorts σ, A s → UU, D0 (sort nm) (ops A nm base_xs)) (funextsec _ _ _ H) f =
352+
transportf (λ Ds0 : A (sort nm) -> UU, Ds0 (ops A nm base_xs)) (H (sort nm)) f.
353+
Proof.
354+
use transportf_funextsec_op.
355+
exact (arity nm).
356+
Defined.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
Require Import UniMath.Foundations.All.
2+
Require Import UniMath.MoreFoundations.All.
3+
4+
Require Import UniMath.Algebra.Universal.Algebras.
5+
6+
Local Open Scope sorted.
7+
Local Open Scope hom_scope.
8+
9+
Theorem make_algebra_support_eq {σ : signature} {A B : algebra σ}
10+
(h : A s→ B) (isweq : ∏ s:(sorts σ), isweq (h s))
11+
: support A = support B.
12+
Proof.
13+
use funextsec.
14+
intro s.
15+
use weqtopaths.
16+
exact (h s ,, isweq s).
17+
Defined.
18+
19+
Theorem make_algebra_eq {σ : signature} {A B : algebra σ}
20+
(h : A ↷ B) (isweq : ∏ s:(sorts σ), isweq (h s))
21+
: A = B.
22+
Proof.
23+
use total2_paths2_f.
24+
- use (make_algebra_support_eq h isweq).
25+
- eapply pathscomp0.
26+
{ use transportf_sec_constant. }
27+
use funextsec.
28+
intro nm.
29+
eapply pathscomp0.
30+
{ use transportf_fun_op. }
31+
use funextsec.
32+
intro xs.
33+
simpl.
34+
eapply pathscomp0.
35+
{ use (transportf_funextfun (λ arg, arg) _ _ _ (sort nm)). }
36+
change (λ x0 : UU, x0) with (idfun UU).
37+
simpl.
38+
change (λ x0 : UU, x0) with (idfun UU).
39+
eapply pathscomp0.
40+
{ use (maponpaths (λ arg, arg _) (weqpath_transport _)). }
41+
cbn.
42+
eapply pathscomp0.
43+
{ eapply (maponpaths (h (sort nm))).
44+
eapply (maponpaths (ops A nm)).
45+
use transportb_funextfun_hvec. }
46+
simpl.
47+
eapply pathscomp0.
48+
{ use (pr2 h). }
49+
use maponpaths.
50+
unfold starfun.
51+
eapply pathscomp0.
52+
{ use h1map_compose. }
53+
simpl.
54+
eapply pathscomp0.
55+
2 :{ use h1map_idfun. }
56+
use (maponpaths (λ arg, h1map arg xs)).
57+
use funextsec.
58+
intro s.
59+
simpl.
60+
use funextsec.
61+
intro b.
62+
simpl.
63+
use (pathsweq1' (h s,, isweq s)).
64+
use (maponpaths (λ arg, arg b)).
65+
use weqpath_transportb'.
66+
Defined.
67+
68+
Theorem support_make_algebra_eq {σ : signature} {A B : algebra σ}
69+
(h : A ↷ B) (isweq : ∏ s:(sorts σ), isweq (h s))
70+
: maponpaths support (make_algebra_eq h isweq) = make_algebra_support_eq h isweq.
71+
Proof.
72+
use total2_paths2_comp1.
73+
Defined.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
Require Import UniMath.Foundations.All.
2+
Require Import UniMath.MoreFoundations.Notations.
3+
4+
Require Import UniMath.Algebra.Universal.Algebras.
5+
Require Import UniMath.Algebra.Universal.HVecRel.
6+
7+
Local Open Scope sorted.
8+
9+
Definition shrel {S : UU} (A : sUU S) : UU
10+
:= ∏ (s:S), hrel (A s).
11+
12+
Definition extensionallift
13+
{S : UU} {A : sUU S} (R : shrel A)
14+
(P : ∏ (s:S) (R:hrel (A s)), UU) : UU
15+
:= ∏ (s:S), P s (R s).
16+
17+
Definition siseqrel {S : UU} {A : sUU S} (R : shrel A)
18+
:= extensionallift R (λ _ R, iseqrel R).
19+
20+
(*Generalization of [[iscomprelfun]]*)
21+
Definition iscomprelfunrel {X Y : UU}
22+
(RX : hrel X) (RY : hrel Y) (f : X -> Y)
23+
: UU
24+
:= ∏ x x' : X, RX x x' -> RY (f x) (f x').
25+
26+
Definition shrelList
27+
{σ : signature} {A : algebra σ} (R : shrel A) (l : list (sorts σ))
28+
: hrel (A⋆ l).
29+
Proof.
30+
unfold star.
31+
use hrelhvec.
32+
change (hvec (((vec_map hrel) ∘ (vec_map (support A))) l)).
33+
use (transportf hvec (vec_map_comp (support A) (hrel) l)).
34+
use h01map.
35+
exact R.
36+
Defined.
37+
38+
Definition iscompatible {σ : signature}
39+
(A : algebra σ) (R : shrel A)
40+
:= ∏ nm: names σ, iscomprelfunrel (shrelList R (arity nm)) (R (sort nm)) (ops A nm).
41+
42+
Definition iscong {σ : signature}
43+
(A : algebra σ) (R : shrel A)
44+
:= siseqrel R × iscompatible A R.
45+
46+
Definition congruence {σ : signature} (A : algebra σ)
47+
:= ∑ (R : shrel A), iscong A R.
48+
49+
Definition eqrelofcong {σ : signature} {A : algebra σ} (R : congruence A) (s: sorts σ)
50+
: eqrel (support A s)
51+
:= (pr1 R) s ,, (pr12 R) s.
52+
53+
Coercion eqrelofcong : congruence >-> Funclass.
54+
55+
Definition quotalgebra {σ : signature} (A : algebra σ) (R : congruence A)
56+
: algebra σ.
57+
Proof.
58+
Proof.
59+
use make_algebra.
60+
- intro s.
61+
exact (setquot (eqrelofcong R s)).
62+
- simpl.
63+
intros nm xs.
64+
use (setquotuniv _ (setquot (eqrelofcong R (sort nm)),,_)).
65+
+ exact (A⋆ (arity nm)).
66+
+ use shrelList.
67+
apply R.
68+
+ use isasetsetquot.
69+
+ apply (funcomp (ops A nm) (setquotpr ((eqrelofcong R) (sort nm)))).
70+
+ simpl.
71+
intros a1s b1s rel_ab.
72+
simpl.
73+
use (iscompsetquotpr (eqrelofcong R (sort nm))).
74+
use (pr2 (pr2 R) nm _ _ rel_ab). (*TODO: name pr2 and make opportune coercions*)
75+
+ simpl.
76+
use hvectosetquot.
77+
unfold star in xs.
78+
refine (eqweqmap (maponpaths hvec _) xs).
79+
eapply pathscomp0. { use h01maph1lower. }
80+
eapply pathscomp0. { use h1lower_vec_map_comp. exact (support A). }
81+
use maponpaths.
82+
use pathsinv0.
83+
use h1h01map_transport_vec_map_comp.
84+
Defined.

0 commit comments

Comments
 (0)