coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Guillaume Brunerie <guillaume.brunerie AT gmail.com>
- To: coq-club AT inria.fr
- Subject: [Coq-Club] Mutually recursive type and function
- Date: Thu, 15 Sep 2011 00:22:13 +0200
Hi,
(this question is probably easy, I think I’m missing something)
I want to define recursively a dependent type [T] and a function [f] such that
T : nat -> Type
f : forall n : nat, A n -> T n (* [A : nat -> Type] has been defined earlier *)
I have [T (S n)] depending on [f n] and [T n], and [f (S n)] also depending on [f n] and [T n] (and [T (S n)] because it’s in the type of [f (S n)]).
I naively tried the following:
Fixpoint T (n : nat) : Type :=
[…]
with f (n : nat) : A n -> T n :=
[…].
But this didn’t work because [T] does not exists yet and Coq wants to type [f] before adding [T] to the environment.
I also tried defining [T] and [f] as one function:
Fixpoint Tf (n : nat) : {B : Type & A n -> B} :=
match n with
| 0 => […]
| S n' => […]
end.
This didn’t work either, I think this is because in the first branch of the match Coq want a function of type [A n -> B] but I just have something of type [A 0 -> B] (and there is the same problem in the second branch, is this what is called dependent pattern matching?)
Could you help me define [T] and [f]?
Thanks,
Guillaume Brunerie
- [Coq-Club] Mutually recursive type and function, Guillaume Brunerie
- Re: [Coq-Club] Mutually recursive type and function,
Adam Chlipala
- Re: [Coq-Club] Mutually recursive type and function,
Guillaume Brunerie
- Re: [Coq-Club] Mutually recursive type and function,
Adam Chlipala
- Re: [Coq-Club] Mutually recursive type and function, Bas Spitters
- Re: [Coq-Club] Mutually recursive type and function,
Adam Chlipala
- Message not available
- Re: [Coq-Club] Mutually recursive type and function, Bruno Barras
- Re: [Coq-Club] Mutually recursive type and function,
Guillaume Brunerie
- Re: [Coq-Club] Mutually recursive type and function,
Adam Chlipala
Archive powered by MhonArc 2.6.16.