Skip to content

Commit a06477a

Browse files
committed
Refactor
1 parent 00a0bb8 commit a06477a

File tree

5 files changed

+84
-64
lines changed

5 files changed

+84
-64
lines changed

interfaces/ua_algebra.v

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,26 @@ Delimit Scope Algebra_scope with Algebra.
2727

2828
Open Scope Algebra_scope.
2929

30-
Local Notation SymbolType_internal := @ne_list.
31-
32-
(** A [Signature] is used to characterise [Algebra]s. It consists of
33-
- A type of [Sort]s, which represent the "objects" (types) an
34-
algebra for the signature must provide.
35-
- A type of Function [Symbol]s, which represent operations an
36-
algebra for the signature must provide.
37-
- For each symbol [u:Symbol], a [SymbolType] specifying the
38-
required type of the operation corresponding to [u] provided by
39-
the algebra for the signature. *)
30+
Definition SymbolType_internal : Type → Type := ne_list.
31+
32+
(** A [Signature] is used to characterise [Algebra]s. In particular
33+
a signature specifies which operations (functions) an algebra for
34+
the signature is expected to provide. A signature consists of
35+
- A type of [Sort]s. An algebra for the signature must provide
36+
a type for each [s : Sort].
37+
- A type of function symbols [Symbol]. For each function symbol
38+
[u : Symbol], an algebra for the signature must provide a
39+
corresponding operation.
40+
- The field [symbol_types σ u] indicates which type the operation
41+
corresponding to [u] should have. *)
4042

4143
Record Signature : Type := BuildSignature
4244
{ Sort : Type
4345
; Symbol : Type
4446
; symbol_types : Symbol → SymbolType_internal Sort }.
4547

46-
(** Notice we have this implicit coercion allowing us to use a
47-
signature [σ:Signature] as a map [Symbol σ → SymbolType σ]
48+
(** We have this implicit coercion allowing us to use a signature
49+
[σ:Signature] as a map [Symbol σ → SymbolType σ]
4850
(see [SymbolType] below). *)
4951

5052
Global Coercion symbol_types : Signature >-> Funclass.
@@ -59,8 +61,7 @@ Definition BuildSingleSortedSignature (sym : Type) (arities : sym → nat)
5961
associates [u] to a [SymbolType σ]. This represents the required
6062
type of the algebra operation corresponding to [u]. *)
6163

62-
Definition SymbolType (σ : Signature) : Type
63-
:= SymbolType_internal (Sort σ).
64+
Definition SymbolType (σ : Signature) : Type := ne_list (Sort σ).
6465

6566
(** For [s : SymbolType σ], [cod_symboltype σ] is the codomain of the
6667
symbol type [s]. *)
@@ -87,21 +88,19 @@ Definition arity_symboltype {σ} : SymbolType σ → nat
8788
(* [Carriers] is a notation because it will be used for an implicit
8889
coercion [Algebra >-> Funclass] below. *)
8990

90-
Notation Carriers := (λ (σ : Signature), Sort σ → Type).
91+
Notation Carriers := (λ σ, Sort σ → Type).
9192

9293
(** The function [Operation] maps a family of carriers [A : Carriers σ]
93-
and [w : SymbolType σ] to the corresponding function type. For
94-
example
94+
and [w : SymbolType σ] to the corresponding function type.
9595
9696
<<
97-
Operation A [:s1; s2; r:] = A s1 → A s2 → A r
97+
Operation A [:s1; s2; ...; sn; t:] = A s1 → A s2 → ... → A sn → A t
9898
>>
9999
100-
where [[:s1; s2; r:] : SymbolType σ] is a symbol type with domain
101-
[[s1; s2]] and codomain [r]. *)
100+
where [[:s1; s2; ...; sn; t:] : SymbolType σ] is a symbol type
101+
with domain [[s1; s2; ...; sn]] and codomain [t]. *)
102102

103-
Fixpoint Operation {σ : Signature} (A : Carriers σ) (w : SymbolType σ)
104-
: Type
103+
Fixpoint Operation {σ} (A : Carriers σ) (w : SymbolType σ) : Type
105104
:= match w with
106105
| [:s:] => A s
107106
| s ::: w' => A s → Operation A w'
@@ -185,13 +184,8 @@ Proof.
185184
(@hset_carriers_algebra σ).
186185
Defined.
187186

188-
Ltac change_issig_algebra A :=
189-
change (hset_carriers_algebra A) with (issig_algebra _ A).2.2 in *;
190-
change (operations A) with (issig_algebra _ A).2.1 in *;
191-
change (carriers A) with (issig_algebra _ A).1 in *.
192-
193187
(** To find a path between two algebras [A B : Algebra σ] it suffices
194-
to find a path between the carrier families and the operations. *)
188+
to find a path between the carriers and the operations. *)
195189

196190
Lemma path_algebra `{Funext} {σ : Signature} (A B : Algebra σ)
197191
: (∃ (p : carriers A = carriers B),
@@ -201,9 +195,11 @@ Lemma path_algebra `{Funext} {σ : Signature} (A B : Algebra σ)
201195
Proof.
202196
intros [p q].
203197
apply ((ap (issig_algebra σ))^-1).
204-
change_issig_algebra A. change_issig_algebra B.
198+
change (carriers A) with (issig_algebra _ A).1 in *.
199+
change (carriers B) with (issig_algebra _ B).1 in *.
205200
refine (path_sigma _ _ _ p _).
206201
apply path_sigma_hprop.
202+
simpl in *.
207203
by path_induction.
208204
Defined.
209205

theory/ua_homomorphism.v

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Require Import
77
HoTT.Basics.Equivalences
88
HoTT.Basics.PathGroupoids
99
HoTT.Types.Forall
10+
HoTT.Types.Arrow
1011
HoTT.Types.Universe
1112
HoTT.Types.Record
1213
HoTT.Types.Sigma
@@ -21,11 +22,11 @@ Section is_homomorphism.
2122
Context {σ} {A B : Algebra σ} (f : ∀ (s : Sort σ), A s → B s).
2223

2324
(** The family of functions [f] above is [OpPreserving α β] with
24-
respect to operations [α : A s1 → A s2 → ... → A sn → A r] and
25-
[β : B s1 → B s2 → ... → B sn → B r] if
25+
respect to operations [α : A s1 → A s2 → ... → A sn → A t] and
26+
[β : B s1 → B s2 → ... → B sn → B t] if
2627
2728
<<
28-
f r (α x1 x2 ... xn) = β (f s1 x1) (f s2 x2) ... (f sn xn)
29+
f t (α x1 x2 ... xn) = β (f s1 x1) (f s2 x2) ... (f sn xn)
2930
>>
3031
*)
3132

@@ -94,15 +95,18 @@ Defined.
9495
functions. *)
9596

9697
Lemma path_homomorphism `{Funext} {σ} {A B : Algebra σ}
97-
(f g : Homomorphism A B) (p : def_hom f = def_hom g) : f = g.
98+
(f g : Homomorphism A B) (p : ∀ s, f s == g s) : f = g.
9899
Proof.
99-
apply (ap (issig_homomorphism A B))^-1. by apply path_sigma_hprop.
100+
transparent assert (F : (def_hom f = def_hom g)).
101+
- funext s x. apply p.
102+
- apply (ap (issig_homomorphism A B))^-1. by apply path_sigma_hprop.
100103
Defined.
101104

102105
(** [f : Homomorphism A B] is an isomorphism if for each [s : Sort σ],
103106
[f s] is both injective and surjective. *)
104107

105-
Class IsIsomorphism {σ : Signature} {A B : Algebra σ} (f : Homomorphism A B)
108+
Class IsIsomorphism {σ : Signature} {A B : Algebra σ}
109+
(f : Homomorphism A B) : Type
106110
:= BuildIsIsomorphism
107111
{ injection_isomorphism : ∀ (s : Sort σ), Injective (f s)
108112
; surjection_isomorphism : ∀ (s : Sort σ), IsSurjection (f s) }.
@@ -111,7 +115,8 @@ Global Existing Instance injection_isomorphism.
111115

112116
Global Existing Instance surjection_isomorphism.
113117

114-
Definition SigIsIsomorphism {σ} {A B : Algebra σ} (f : Homomorphism A B) : Type
118+
Definition SigIsIsomorphism {σ} {A B : Algebra σ}
119+
(f : Homomorphism A B) : Type
115120
:= { injection_isomorphism : ∀ (s : Sort σ), Injective (f s)
116121
| ∀ (s : Sort σ), IsSurjection (f s) }.
117122

@@ -157,7 +162,11 @@ Defined.
157162
*)
158163

159164
Section equiv_carriers_isomorphism.
160-
Context {σ} {A B : Algebra σ} (f : Homomorphism A B) {Is : IsIsomorphism f}.
165+
Context
166+
{σ : Signature}
167+
{A B : Algebra σ}
168+
(f : Homomorphism A B)
169+
{Is : IsIsomorphism f}.
161170

162171
Global Instance isequiv_carriers_isomorphism
163172
: ∀ (s : Sort σ), IsEquiv (f s).
@@ -176,11 +185,12 @@ End equiv_carriers_isomorphism.
176185
uncurried algebra operations in the sense that
177186
178187
<<
179-
f r (α (x1,x2,...,xn,tt)) = β (f s1 x1,f s2 x1,...,f sn xn,tt)
188+
f t (α (x1,x2,...,xn,tt)) = β (f s1 x1,f s2 x1,...,f sn xn,tt)
180189
>>
181190
182-
for all [(x1,x2,...,xn,tt) : FamilyProd A [s1;s2;...;sn]], where [α]
183-
and [β] are uncurried algebra operations in [A] and [B] respectively.
191+
for all [(x1,x2,...,xn,tt) : FamilyProd A [s1;s2;...;sn]], where
192+
[α] and [β] are uncurried algebra operations in [A] and [B]
193+
respectively.
184194
*)
185195

186196
Section homomorphism_ap_operation.
@@ -250,7 +260,7 @@ Section hom_inv.
250260
intros a b P.
251261
induction (σ u).
252262
- rewrite <- P. apply (eissect (f t)).
253-
- intro. apply IHn.
263+
- intro. apply IHs.
254264
exact (transport (λ y, OpPreserving f _ (b y))
255265
(eisretr (f t) x) (P (_^-1 x))).
256266
Qed.
@@ -326,11 +336,26 @@ Section hom_compose.
326336
Qed.
327337
End hom_compose.
328338

339+
Lemma path_forall_recr_beta `{Funext} {A : Type} {B : A → Type}
340+
(a : A) (P : (∀ x, B x) → B a → Type) (f g : ∀ a, B a)
341+
(e : f == g) (Pa : P f (f a))
342+
: transport (fun f => P f (f a)) (path_forall f g e) Pa
343+
= transport (fun x => P x (g a))
344+
(path_forall f g e) (transport (fun y => P f y) (e a) Pa).
345+
Proof.
346+
rewrite <- (eissect (path_forall f g) e).
347+
change ((_^-1 (path_forall f g e))) with ((apD10 (path_forall f g e))).
348+
destruct (path_forall f g e).
349+
unfold apD10.
350+
rewrite (path_forall_1 f).
351+
reflexivity.
352+
Defined.
353+
329354
(** The following section proves that there is a path between
330355
isomorphic algebras. *)
331356

332357
Section path_isomorphism.
333-
Context `{Univalence} {σ} {A B : Algebra σ}.
358+
Context `{Univalence} {σ : Signature} {A B : Algebra σ}.
334359

335360
(** Recall that there is an implicit coercion
336361
@@ -344,20 +369,20 @@ Section path_isomorphism.
344369
then by function extensionality and univalence there is a path
345370
between the carriers, [carriers A = carriers B]. *)
346371

347-
Definition path_carriers_equiv (f : ∀ (s : Sort σ), A s <~> B s)
348-
: carriers A = carriers B
349-
:= path_forall A Bs, path_universe (f s)).
372+
Definition path_carriers_equiv {I : Type} {X Y : I → Type} (f : ∀ i, X i <~> Y i)
373+
: X = Y
374+
:= path_forall X Yi, path_universe (f i)).
350375

351376
(** Given a family of equivalences [f : ∀ (s : Sort σ), A s <~> B s]
352377
which is [OpPreserving f α β] with respect to algebra operations
353378
354379
<<
355-
α : A s1 → A s2 → ... → A sn → A r
356-
β : B s1 → B s2 → ... → B sn → B r
380+
α : A s1 → A s2 → ... → A sn → A t
381+
β : B s1 → B s2 → ... → B sn → B t
357382
>>
358383
359384
By transporting [α] along the path [path_carriers_equiv f] we
360-
find a path from the transported [α] to [β]. *)
385+
find a path from the transported operation [α] to [β]. *)
361386

362387
Lemma path_operations_equiv (f : ∀ (s : Sort σ), A s <~> B s)
363388
{w : SymbolType σ} (α : Operation A w) (β : Operation B w)
@@ -367,15 +392,20 @@ Section path_isomorphism.
367392
Proof.
368393
unfold path_carriers_equiv.
369394
induction w; simpl in *.
370-
- transport_path_forall_hammer.
395+
- rewrite (path_forall_recr_beta t (λ _ x, x) A B (λ s, path_universe (f s)) α).
396+
induction (path_forall A B (λ s : Sort σ, path_universe (f s))).
397+
(* transport_path_forall_hammer. *)
398+
371399
exact (ap10 (transport_idmap_path_universe (f t)) α @ P).
372400
- funext y.
373-
transport_path_forall_hammer.
401+
402+
set (Λ := λ (a : Sort σ → Type) (b:Type), b → Operation a w).
403+
rewrite (path_forall_recr_beta t Λ A B (λ s, path_universe (f s)) α).
404+
(*transport_path_forall_hammer.*)
405+
374406
rewrite transport_forall_constant.
375-
rewrite transport_forall.
376-
rewrite transport_const.
407+
rewrite transport_arrow_toconst.
377408
rewrite (transport_path_universe_V (f t)).
378-
destruct (path_universe (f t)).
379409
specialize (P ((f t)^-1 y)).
380410
rewrite (eisretr (f t)) in P.
381411
exact (IHw (α ((f t)^-1 y)) (β y) P).

theory/ua_quotient_algebra.v

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,10 @@ Section ump_quotient_algebra.
292292
ump_quotient_algebra_lr ump_quotient_algebra_rl).
293293
- intro F.
294294
apply path_sigma_hprop.
295-
apply path_homomorphism.
296-
funext s.
297-
now apply path_forall.
295+
by apply path_homomorphism.
298296
- intro G.
299297
apply path_homomorphism.
300-
funext s.
301-
refine (eissect (quotient_ump (Φ s) (BuildhSet (B s))) (G s)).
298+
intro s.
299+
refine (ap10 (eissect (quotient_ump (Φ s) _) (G s))).
302300
Defined.
303301
End ump_quotient_algebra.

theory/ua_second_isomorphism.v

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,7 @@ Section second_isomorphism'.
313313
Lemma path_hom_second_isomorphisms
314314
: hom_second_isomorphism P Φ = hom_second_isomorphism'.
315315
Proof.
316-
apply path_homomorphism.
317-
funext s x.
318-
generalize dependent x.
316+
apply path_homomorphism. intro s.
319317
refine (quotient_ind_prop (Ψ s) _ _). intros [x E].
320318
apply path_sigma_hprop.
321319
unfold hom_second_isomorphism'.

theory/ua_third_isomorphism.v

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,7 @@ Section third_isomorphism'.
294294
Lemma path_hom_third_isomorphisms
295295
: hom_third_isomorphism Φ Ψ subrel = hom_third_isomorphism'.
296296
Proof.
297-
apply path_homomorphism.
298-
funext s x.
299-
generalize dependent x.
297+
apply path_homomorphism. intro s.
300298
refine (quotient_ind_prop (Θ s) _ _).
301299
refine (quotient_ind_prop (Ψ s) _ _). intro x.
302300
unfold hom_third_isomorphism'.

0 commit comments

Comments
 (0)