Skip to content

[cubical] Fibrant unbased path types - #5439

Merged
Saizan merged 17 commits into
agda:masterfrom
ecavallo:interval-sort
Jun 24, 2021
Merged

Saizan merged 17 commits into
agda:masterfrom
ecavallo:interval-sort

Conversation

@ecavallo

Copy link
Copy Markdown
Contributor

Arranges so that functions from the interval into Set can be placed in Set rather than SSet:

Path : Set -> Set
Path A = I -> A

(This shouldn't be possible if we replace I with an arbitrary type in SSet.) Following @Saizan's suggestion, this is accomplished by creating a separate sort ISet <= SSet for the interval.

I need some help tracking down a bug: I can successfully declare {-# BUILTIN INTERVALUNIV ISet #-}, but if I try to import a file that does so (eg see test/Succeed/CubicalPrims) I get:

An internal error has occurred. Please report this as a bug.
Location of the error: __IMPOSSIBLE_VERBOSE__, called at src/full/Agda/TypeChecking/Monad/Signature.hs:727:32 in Agda-2.6.2-8fa8cd605ee63433cc7c553f0296c75b82d356e8783f4b10baca3a83452dbdb5:Agda.TypeChecking.Monad.Signature

I think I also need to add some kind of requireCubical to my changes in TypeChecking.Rules.Builtin (and maybe elsewhere?), but not sure what exactly.

@Saizan

Saizan commented Jun 10, 2021

Copy link
Copy Markdown
Collaborator

I bet this is just because alphabetically INTERVALUNIV comes later than INTERVAL so things get loaded out of order.

@ecavallo

Copy link
Copy Markdown
Contributor Author

Yep, that was it.

@mortberg

Copy link
Copy Markdown
Contributor

Nice! I guess we'll need functions in the library for converting between line types (I -> A) and path types? It will be interesting to see how often we have to use these functions

@ecavallo

Copy link
Copy Markdown
Contributor Author

I realized that the current ISet is closed under datatypes, which I didn't intend and which seems undesirable. We can then write things like the following, although maybe the hole can't actually be filled in Agda.

data ⊥ : Set where

data UhOh : I → ISet where
  one : UhOh i1

ohno : ⊥
ohno = primTransp (λ i → UhOh i → ⊥) i0 {!!} one

@Saizan

Saizan commented Jun 10, 2021

Copy link
Copy Markdown
Collaborator

Hah! You can blacklist IntervalUniv in checkDataDef, look for checkIndexSorts.

I suppose records could be useful instead?

@Saizan Saizan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice! I guess we'll need functions in the library for converting between line types (I -> A) and path types? It will be interesting to see how often we have to use these functions

The conversion function is just eta expansion, it's the same when you have a path and try to use transp.

Comment thread src/full/Agda/TypeChecking/Primitive.hs Resolved
@ecavallo

Copy link
Copy Markdown
Contributor Author

I suppose records could be useful instead?

Yeah, maybe we can then simplify the extent-type type signature you gave on Zuiip, from

Ext : (@flat n : Nat) -> (A : I^n -> U) (phi : flat (I^n -> I)) (a : (r : I^n) -> Partial (eta phi r) (A r)) -> U

to

Ext : {@flat J : ISet} (A : J -> U) (phi : flat (J -> I)) (a : (r : J) -> Partial (eta phi r) (A r)) -> U

But the way things are currently set up, I think I need to disallow any kind of data type or record with parameters from landing in ISet, because the implementation of coercion in J -> A for J : ISet doesn't do any kind of coercion in the domain.

@Saizan

Saizan commented Jun 11, 2021

Copy link
Copy Markdown
Collaborator

Yeah, that makes sense, otherwise we would have to set-up a version of transp for ISet types.

@ecavallo

Copy link
Copy Markdown
Contributor Author

Is it straightforward to enforce that restriction? I could imagine it being hard to notice that you are in a module with some parameters.

@Saizan

Saizan commented Jun 11, 2021

Copy link
Copy Markdown
Collaborator

It should be, afaict things are already lambda-lifted to the top-level in checkDataDef. See the fields dataPars and dataIxs in the definition of dataDef.

@ecavallo

Copy link
Copy Markdown
Contributor Author

Forbidding parameters in record types does get in the way of the extent type stretch goal, though, because we can't write

record _×_ (I J : ISet) : ISet where
  field
    fst : I
    snd : J

although we can at least define individual instances.

@ecavallo

Copy link
Copy Markdown
Contributor Author

We could just only allow ISet parameters.

@Saizan

Saizan commented Jun 11, 2021

Copy link
Copy Markdown
Collaborator

It's all about what we need for transp (\ i -> (x : J i) -> B i x) r t, right?
Seems dodgy to just proceed as if J were constant. What we can do though is wait until J is manifestly constant, and arrange for canonical forms of ISet to be so.

Otherwise we bite the bullet and introduce a dedicated transp for ISet.

@ecavallo

Copy link
Copy Markdown
Contributor Author

Is the current implementation of coercion for functions where the domain is in LockUniv dodgy? Currently the coercion in the domain in that case is just the identity function (https://github.com/ecavallo/agda/blob/9c43f618f42851efd10c66734d9e3e09fdea10e0/src/full/Agda/TypeChecking/Primitive/Cubical.hs#L1084):

          LockUniv -> return $ Just $ \ _ _ a0 -> a0

In any case, I'm more inclined now to simply exclude all records from ISet for the moment unless it's very easy to keep them. The universe can always be enlarged in a future PR.

@Saizan

Saizan commented Jun 17, 2021 via email

Copy link
Copy Markdown
Collaborator

@ecavallo

Copy link
Copy Markdown
Contributor Author

What would be the way to wait until J is manifestly constant? I went to check in the IntervalUniv case if the x (domain type) is the interval, but I don't know how to do this.

@Saizan

Saizan commented Jun 17, 2021

Copy link
Copy Markdown
Collaborator

You can reduce the type and check that it's a Def q [] where q is the same QName you get from getName' builtinInterval.

Comment thread doc/release-notes/2.6.2.md Resolved
@ecavallo

Copy link
Copy Markdown
Contributor Author

The thing I'm not sure about now is how to restrict use of IUniv to the cubical mode. I see requireCubical used in TypeChecking.Rules.Builtin for other postulates, but I don't see how to use this with a BuiltinSort.

@Saizan

Saizan commented Jun 21, 2021

Copy link
Copy Markdown
Collaborator

You could add the check in bindBuiltinNoDef I think.

@ecavallo

Copy link
Copy Markdown
Contributor Author

OK, that's everything I'm aware that I need to do, unless I should add some Fail tests.

A remark for the future: I think the more principled version of IUniv would be a sort (or hierarchy of sorts, presumably) for types that support transport but not composition. This is exactly what is needed to be the domain of a fibrant function type, and such a universe could be closed under all sorts of things. (It's also all that's needed of the argument types to the constructors of an fibrant inductive type, since hcomp is free there.) But I don't know if it would be particularly useful to have around, except for encoding extension types as we discussed above, and for that application something more limited (just closed under products) would be enough.

@ecavallo
ecavallo marked this pull request as ready for review June 21, 2021 11:08
@Saizan

Saizan commented Jun 21, 2021

Copy link
Copy Markdown
Collaborator

A Fail test for IUniv without --erased-cubical/--cubical would be great.
Maybe also ones for records and datatypes in IUniv?

@Saizan

Saizan commented Jun 24, 2021

Copy link
Copy Markdown
Collaborator

The windows errors seem quite random, I presume we should merge. I am going to do a squash and merge to simplify the history.

@ecavallo

Copy link
Copy Markdown
Contributor Author

Thanks for all the help!

@Saizan
Saizan merged commit 007a26f into agda:master Jun 24, 2021
@Saizan

Saizan commented Jun 24, 2021

Copy link
Copy Markdown
Collaborator

Thanks for the work, btw!

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.

3 participants