-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Algebra operations #1428
Algebra operations #1428
Conversation
(** Functions [head_dom'] and [head_dom] are used to get the first | ||
element of a nonempty operation domain [a : forall i, A (ss i)]. *) | ||
|
||
Monomorphic Definition head_dom' {σ} (A : Carriers σ) (n : nat) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am making certain definitions monomorphic to avoid unverse blowup.
@@ -112,14 +112,14 @@ Proof. | |||
+ rewrite path_fin_fsucc_incl, path_nat_fin_incl. | |||
apply IHn. | |||
+ reflexivity. | |||
Qed. | |||
Defined. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need the computation for operation_curry
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's curious, since it's a path in nat
. Is it not possible to just use the fact that nat
is a set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is because I want the definitional equality from operation_curry
: https://github.com/HoTT/HoTT/blob/9e8e09146747077eb81c6f152bc5f04b4d7cd5f5/theories/Algebra/Universal/Operation.v#L141
@@ -79,7 +79,8 @@ Proof. | |||
(hset_path2 1 (@path_succ_finnat n u u.2)) idpath). | |||
Defined. | |||
|
|||
Definition is_bounded_fin_to_nat {n} (k : Fin n) : fin_to_nat k < n. | |||
Monomorphic Definition is_bounded_fin_to_nat {n} (k : Fin n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Monomorphic to avoid universe blowup
theories/Spaces/Finite/Vect.v
Outdated
(** Finite-dimensional vector. Note that the induction principle | ||
[vect_ind] uses funext and does not compute. *) | ||
|
||
Definition Vect (n : nat) (A : Type) : Type := Fin n -> A. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure whether vector is a good name for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's at least a traditional name in dependent type theory, right? Although I guess it's more common to define as an indexed family than as a function type. But yeah, it might be confusing if we start also doing linear algebra. (-: Any other suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why you decided to define them this way rather than as an inductive family? It seems like the latter would use less funext, for one thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that Vect
is a traditional name in dependent type theory, but perhaps not suitable here. An alternative is FinSeq
for finite sequence.
In the multi-sorted universal algebra that I am developing, this type occurs as the of sorts for the domain of finitary operations: https://github.com/HoTT/HoTT/blob/9e8e09146747077eb81c6f152bc5f04b4d7cd5f5/theories/Algebra/Universal/Operation.v#L77
In my initial approach I defined the inductive family and proved the two equivalent, but I do not need the inductive family, so I decided to leave it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use funext to derive the induction principle for the type, which I just included for completeness. I do not expect to need that for universal algebra.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FinSeq
could be good. Why is this definition preferable to the inductive one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the inductive family is often preferable, but in my particular case I need this one to instantiate the SymbolTypeOf
record: https://github.com/HoTT/HoTT/blob/bce95e43fe3407706ac0eae1bd9ddaf7d42fb2b9/theories/Algebra/Universal/Algebra.v#L23 when Arity
is Fin n
.
I am fine with having both notions of FinSeq
. The "default" inductive definition in HoTT.Spaces.FinSeq
and this one in HoTT.Spaces.Finite.FinSeq
. What do you think?
theories/Spaces/Finite/Vect.v
Outdated
(** A non-empty vector is the [vcons] of its head and tail, | ||
[path_expand_vcons'] and [path_expand_vcons]. *) | ||
|
||
Lemma path_expand_vcons' {A : Type} (n : nat) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The remaining lemmas are here to prove vect_ind
. I do not think that I will need it, but I formalised vect_ind
for completeness.
Sure. No need to add the inductive one until someone needs or wants it.
…On Fri, Mar 26, 2021 at 4:01 PM Andreas Lynge ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In theories/Spaces/Finite/Vect.v
<#1428 (comment)>:
> @@ -0,0 +1,212 @@
+Require Import
+ HoTT.Basics
+ HoTT.Types
+ HoTT.HSet
+ HoTT.DProp
+ HoTT.Spaces.Finite.Fin
+ HoTT.Spaces.Finite.FinInduction
+ HoTT.Spaces.Nat.
+
+(** Finite-dimensional vector. Note that the induction principle
+ [vect_ind] uses funext and does not compute. *)
+
+Definition Vect (n : nat) (A : Type) : Type := Fin n -> A.
I think the inductive family is often preferable, but in my particular
case I need this one to instantiate the SymbolTypeOf record:
https://github.com/HoTT/HoTT/blob/bce95e43fe3407706ac0eae1bd9ddaf7d42fb2b9/theories/Algebra/Universal/Algebra.v#L23
when Arity is Fin n.
I am fine with having both notions of FinSeq. The "default" inductive
definition in HoTT.Spaces.FinSeq and this one in HoTT.Spaces.Finite.FinSeq.
What do you think?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1428 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAE53SAGBW4ZKTBFSJM6CSTTFUG6PANCNFSM4ZZ6MGMQ>
.
|
3fae52a
to
e7d9b94
Compare
I have rebased and changed |
The universe issues here are interesting. We can fix some issues by changing Fixpoint Fin (n : nat) : Type0
:= match n with
| 0 => Empty
| S n => Fin n + Unit
end. It makes sense to stick it in the lowest universe, just like we do with This let's us reduce the universes in Definition FinSeq@{u} (n : nat) (A : Type@{u}) : Type@{u} := Fin n -> A. This means that This should reduce some of the blowup I observed. |
Good idea. I have added those changes. |
c6cac28
to
da0c0a6
Compare
Started work on algebra operations Added Finite.Vect Make some definitions monomorphic to fix universe blowup in Finite.FinNat
Put Fin in lowest universe and 1 universe for FinSeq.
da0c0a6
to
7137029
Compare
Are we OK with merging this? |
Looks fine to me. |
Started work on algebra operations
Added Finite/FinSeq.v
Make some definitions monomorphic to fix universe blowup in Finite/FinNat.v