Skip to content
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

[refactor] instance declaration #376

Open
wants to merge 147 commits into
base: master
Choose a base branch
from
Open

[refactor] instance declaration #376

wants to merge 147 commits into from

Conversation

gares
Copy link
Member

@gares gares commented Aug 1, 2023

@ptorrx I did push here a cleanup which should simplify the main cleanup

TODO:

  • handle properly the rex.match ..__ELIM in instance.elpi
    • it is called by structure.elpi. it is the generic instance saying that that hom of a MEC are a monoid, that is a regular instance, not to be wrapped. see reexport-wrapper-as-instance
  • handle parameters in instance.elpi
    • should we be smart when the mixin instance to be wrapped and the argument expected by the wrapper need some glue? Eg if the mixin instance has an parameter, we could abstract it upfront and wrap under this binder.
      • we should unify and then abstract unresolved variables
  • eta-expand context if the mixin is wrapped
  • syntax in HB.structure to generate the wrapper mixin

@gares
Copy link
Member Author

gares commented Oct 5, 2023

rebasing over master, next time don't pull but git reset origin/refactor-instance

@gares
Copy link
Member Author

gares commented Oct 5, 2023

now cat.v works, but we broke #[hnf] somehow.

@gares
Copy link
Member Author

gares commented Oct 6, 2023

it is also broken in master, so we can ignore it here.

@gares
Copy link
Member Author

gares commented Oct 9, 2023

I had to rebase once again, sorry for the noise.

@@ -462,3 +473,8 @@ find-max-classes [M|Mixins] [C|Classes] :-
].
find-max-classes [M|_] _ :- coq.error "HB: cannot find a class containing mixin" M.

pred is-subject-lifter i:term, o:int, o:classname.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong if the lifter is casted: (hom : T -> T -> Type) hides (let x : T -> T -> Type := hom in x)
and this code should cross/reduce the let

theories/encat.v Outdated
Comment on lines 1021 to 1023
HB.mixin Record IsEnQuiver (V: Monoidal.type) C of Quiver C := {
hom_object : C -> C -> V
}.
Copy link
Member

@CohenCyril CohenCyril Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still not accurate. Indeed you would have both hom sets and hom objects. You should have only the latter.

Suggested change
HB.mixin Record IsEnQuiver (V: Monoidal.type) C of Quiver C := {
hom_object : C -> C -> V
}.
HB.mixin Record IsEnQuiver (V: Monoidal.type) C := {
hom_object : C -> C -> V
}.

Indeed in V-enriched cats, hom objects are generalizations of hom sets.

Copy link
Member

@CohenCyril CohenCyril Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Furthermore, you may weaken the dependency in V here:

Suggested change
HB.mixin Record IsEnQuiver (V: Monoidal.type) C of Quiver C := {
hom_object : C -> C -> V
}.
HB.mixin Record IsEnQuiver (V : Type) C := {
hom_object : C -> C -> V
}.

And gradually add what you actually require in subsequent declarations.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

theories/encat.v Outdated
Comment on lines 1042 to 1043
Notation "a ~^ b" := (hom_object a b)
(at level 99, b at level 200, format "a ~^ b") : cat_scope.
Copy link
Member

@CohenCyril CohenCyril Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I advocate for reusing the same notation in a different scope. E.g.

Suggested change
Notation "a ~^ b" := (hom_object a b)
(at level 99, b at level 200, format "a ~^ b") : cat_scope.
Notation "a ~> b" := (hom_object a b) : encat_scope.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK for a distinct name scope, but it might be better not to overload ~>, sometimes we need to use both hom and hom_object

theories/encat.v Outdated
Comment on lines 1148 to 470
Unset Universe Checking.
#[short(type="dcat")]
HB.structure Definition DCat : Set := { C of Cat C & H2Cat C }.
Set Universe Checking.
Copy link
Member

@CohenCyril CohenCyril Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record we discussed that this is not the right definition of double categories because the functoriality of the sources and targets functions $s, t : D_1 \to D_0$ is missing. We gave another definition -- closer to nlab -- but I do not see it here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I still have to push a few commits

theories/encat.v Outdated
Comment on lines 1175 to 1176
(* 2-morphisms *)
Definition hhom (D: DCat.type) := @hom (@D1 D).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, given the mismatch between the comment and the name we got it wrong.
We should have

Definition hhom (D : DCat.type) (a b : D) := {x : D1 | s10 x = a /\ t10 x = b }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I actually had already revised the definition (just pushed it), also because we additionally need an identify functor D0 -> D1, and it seems more natural to define it using the record HHomSet. However, there are some problems which have to do with wrapping and I haven't been able to solve yet

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, we actually need an identity D0 -> D1 and a composition functor, D1 *_D0 D1 -> D1.
Maybe the HHomSet way is better but I think we'd rather make the transposition a lifter, put a category structure on the transpose and define two-morphisms like this :

two_hom : forall (x y z t : D), (x ~> y) -> (z ~> t) -> (x ~>_(transpose D) z) -> (y ~>_(transpose D) t) -> Type

theories/encat.v Outdated
Definition h2hom (D: DCat.type) := @hom (@HHomSet D).

(* dummy def
Definition transpose (D: DCat.type) : U := D. *)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This def is not dummy, it's the alias which will receive the transposed structure.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this seems to say that the transpose is the same category as the original one...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the same carrier! But then we may put different instances on it as a category.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, it recasts D of DCat to a Type...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the transpose is the result of swapping horizontal and vertical morphisms...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure it is.... but as a canonical instance.

theories/encat.v Outdated
Definition hhom (D: DCat.type) := @hom (@D1 D).

Definition transpose (D: DCat.type) : U := D.

Copy link
Member Author

@gares gares Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definition hhom (D : DCat.type) (a b : D) := {x : D1 | s10 x = a /\ t10 x = b }
HB.instance Definition _ (D : DCat.type) : hasHom (transpose D) := hasHom.Build (@hhom D).
...

theories/encat.v Outdated
Comment on lines 1113 to 1123
Record GenComp T (h: T -> T -> U) := {
comp_first : @Total2 T h ;
comp_second : @Total2 T h ;
comp_adjacent : target comp_first = source comp_second
}.

(* the set of horizontal morphisms.
HB.tag needed to identify HHomSet as lifter *)
HB.tag Definition HHomSet (C: hquiver) := Total2 (@hhom C).

Definition HComp (C: hquiver) := GenComp (@hhom C).
Copy link
Member

@CohenCyril CohenCyril Nov 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Record GenComp T (h: T -> T -> U) := {
comp_first : @Total2 T h ;
comp_second : @Total2 T h ;
comp_adjacent : target comp_first = source comp_second
}.
(* the set of horizontal morphisms.
HB.tag needed to identify HHomSet as lifter *)
HB.tag Definition HHomSet (C: hquiver) := Total2 (@hhom C).
Definition HComp (C: hquiver) := GenComp (@hhom C).
Definition D1 {D0} := Total2 (@hhom D0).
Definition Type_PB {A B : Type} (s : cospan A B) : Type := { x : A * B | left2top x.1 = right2top x.2 }.
Definition D1_prod_D0_D1 D0 := Type_PB (Cospan (source : D1 -> D0) (target : D1 -> D0)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants