I'm using Descriptions, like they are described here, as a way of encoding the shape of inductive data types. However, I'm stuck on how to represent inductive types that are:
- Mutually inductive
- Have different indices
For example, suppose we've got something like this, where we're ordering different types:
data Foo : Set where
N : ℕ -> Foo
P : (Foo × Foo) -> Foo
data <N : ℕ -> ℕ -> Set where
<0 : (n : ℕ) -> <N zero n
<suc : (m n : ℕ) -> <N m n -> <N (suc m) (suc n)
data <P : (Foo × Foo) -> (Foo × Foo) -> Set
data <F : Foo -> Foo -> Set
data <P where
<Pair : (x1 x2 y1 y2 : Foo) -> <F x1 y1 -> <F x2 y2 -> <P (x1 , x2) (y1 , y2)
data <F where
<FN : ∀ (a b : ℕ) -> <N a b -> <F (N a) (N b)
<FP : ∀ (p1 p2 : (Foo × Foo) ) -> <P p1 p2 -> <F (P p1) (P p2)
That is, we've got a type of binary trees with nats at the leaves. We have a partial order between trees, where we compare nats in the usual way, and we compare pairs of nodes by comparing their respective subtrees.
Notice how <F
and <P
are mutually dependent on each other. Of course, we could inline this to make <F
and <P
one type, I'm trying to avoid that, for cases where <P
is more complicated.
What I'm wondering is: can the above partial order types be expressed using Descriptions?
I get stuck even trying to describe the above types as the fixed-point of an indexed functor. Usually we have an index type (I : Set)
and the functor has type (X : I -> Set) -> I -> Set
. But we can't have both "Foo" and "Foo × Foo" be our I value. Is there some trick that allows us to use
I = Foo ⊎ (Foo × Foo)
?
<
relations are equivalent to equality. Is this intended? – András Kovács