Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a type theory in which the equivalence of identically shaped inductive datatypes is representable?

Say I have two inductively defined datatypes:

Inductive list1 (A : Type) : Type :=
 | nil1 : list1 A
 | cons1 : A -> list1 A -> list1 A.

and

Inductive list2 (A : Type) : Type :=
 | nil2 : list2 A
 | cons2 : A -> list2 A -> list2 A.

For any P (list1 a) I should be able to construct a P (list2 a), by applying the exact same method I used to construct P (list1 a) except replacing nil1 with nil2, list1 with list2 and cons1 with cons2. Similarly, any function that takes list1 a as a parameter could be extended to take a list2 a.

Is there a type system that allows me to speak of two datatypes having the same shape in this manner (having identically shaped constructors), and prove P (list1 a) -> P (list2 a)? For instance, is this something that univalence, HOTT, or a cubical/observational type system allows? It might also allow defining functions like reverse: list_like a -> list_like a that accept both list1s and list2s as parameters.

like image 844
LogicChains Avatar asked Jan 20 '18 11:01

LogicChains


1 Answers

In HoTT with univalence, it is indeed provable that list1 A is equal to list2 A for all A. Given a proof p : list1 A = list2 A, transport (or subst) gives you P (list1 A) -> P (list2 A) for any P. In cubical type theories, such transporting may also compute as expected. To my knowledge, cubical type theory (CCHM or cartesian) is the only setting where this currently works. cubicaltt is the most usable (but still not really practical) implementation.

like image 94
András Kovács Avatar answered Nov 15 '22 10:11

András Kovács