-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support for dependently typed labels for variables and binders #1
Comments
Hi Jason, sorry to be slow. I've been trying to write up what I do know. I don't know how to accommodate this sort of construction but would very much like to. Can you clarify where the dependent monoid abstraction might be used? Right now, where we use monoids, it is always a list of binder values. As you are getting at, the list of in-scope binders at a variable node does not actually constrain the possibles values for that variable. I think I understand the dependent monoid abstraction itself but I don't see where it might fit into the bigger picture, can you sketch an example? |
Sorry it took me so long to get back to you. On looking at things again, I think monoids are already enough to give intrinsic typing (the DTM abstraction needs to be upgraded to allow the variable type and the expression type to be indexed over the "current monoid-element of binders in scope"; is there any reason to disallow this?). Dependent monoids would allow an extension from simply-typed lambda calculus to something like dependently-typed lambda calculus (you'd need to separate "term-level terms" and "type-level terms"), by allowing the type of "next binder" to depend on the binders already in scope. |
I think you are right and there is no reason not to do this. It starts to look a lot like Fiore et. al's presheaf approach, except it tracks free and bound variables separately instead of dumping them into a single context. I think
This is for locally nameless but could be adapated for de Bruijn or even fully named. |
It would be nice to support well-typed-by-construction expression types, such as nested abstract syntax where we have
expr : Type -> Type
, we label both variables inexpr V
with labels of typeV
and we label binders withunit
, and we haveabs : unit -> expr (option V) -> expr V
(i.e., a new binder extendsV
intooption V
); or intrinsically typed syntax where we have a type of type codestype
, and we label binders withtype
and we label variables inexpr ctx
with indices ofctx
, wherectx : list type
, and whereabs : forall (t : type), expr (t :: ctx) -> expr ctx
.I believe (one of) the construction(s) you need for this is to generalize monoid to dependent monoid. I haven't seen this anywhere in the literature, and as far as I know, @Soares came up with it:
Note that
DependentMonoid X M
is isomorphic to a category whose objects areX
and whose morphisms fromx
toy
are of type{ m : M x | ext (x; m) = y }
, where composition is given byT
. Equivalently, a category with objectsX
and morphismsHom x y
is isomorphic to a dependent monoid withX := X
andM x := { y : X & Hom x y }
(ext
is "target", i.e.,fun v => projT1 (projT2 v)
, andT
is composition). Said another way, a dependent monoid looks like a category where morphisms are indexed only on their source and not also on their target.You can specialize this to a non-dependent monoid by setting
X := unit
.Do you think this will allow handling nested abstract syntax and intrinsically typed syntax?
The text was updated successfully, but these errors were encountered: