coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Sylvain Boulmé <Sylvain.Boulme AT univ-grenoble-alpes.fr>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Problems with dependently typed function
- Date: Fri, 22 Mar 2019 09:33:50 +0100
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=Sylvain.Boulme AT univ-grenoble-alpes.fr; spf=Pass smtp.mailfrom=Sylvain.Boulme AT univ-grenoble-alpes.fr; spf=None smtp.helo=postmaster AT zm-mta-out-1.u-ga.fr
- Ironport-phdr: 9a23:iOcqzxPHA+hsD29vdOwl6mtUPXoX/o7sNwtQ0KIMzox0Iv75rarrMEGX3/hxlliBBdydt6sczbWO+Pm5BiQp2tWoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6nK94iQPFRrhKAF7Ovr6GpLIj8Swyuu+54Dfbx9HiTagfb9+Nhe7oRneusULnIdvKLs6xwfUrHdPZ+lY335jK0iJnxb76Mew/Zpj/DpVtvk86cNOUrj0crohQ7BAAzsoL2465MvwtRneVgSP/WcTUn8XkhVTHQfI6gzxU4rrvSv7sup93zSaPdHzQLspVzmu87tnRRn1gyoBKjU38nzYitZogaxGvhyhqRxxzY3abo6bO/VxfL/Sc9wBSGpdXctcTTBNDp+yYoYNCecKIOZWr5P6p1sLtRawGAmtBOfxyjBSh3/227U13vkmEQHb2AwgGsgJu2nTodvoNKYSVf61w7PJzTXFdf9bxDD96JXMchAkv/6BRq9wcczQyUkxDg/FgU+QppLjPzOSzesNt3aU4/N6WuKrk24otRpxriKhxsc2k4TEgJ8exFPc9Shh3Yo4JcO0RFR5bNOmCpdcqT2WO5dsTs4iQmxkoCI3xqEctZKmYSQG1o4rywPCZ/GFaYSF5gzvWeCMKjlinn1lYqiwhxOq/Eig1OL8Us603U5LrypAi9XMs2wN2AbK5siAV/t94l6t1SuV2wDO8+1ELlo7mbDVK5472rIwl5wTvlrfHiLuhUn7jLGael8m9+Wq8ejrfKnqqoOGO4J0iwzyKqEulda+AeQ8PAgORW+b+eGk2bP+/Uz5RKtKgec3kqnfqpzXOMMbprO9Aw9QzIku8Au/DzGn0NQGhHUHI0hFdwyBj4juIF7OJO73Ae6ljFSoiDdk2evGMqfvApXXNnTDiqvufa5h605Azwo+1cxQ55VNCr0YPP3zXlLxu8fDAx8iMw20xv7nB89n2oMfX2KPGK6ZP7nIvV+G/OJ8a9WLMYQSoXP2L+Uvz//ol34w31EHLoez2p5CU2G8AP1nJXKzZmfoh1ZJRVwbuhQ3TeqsolqfVTteT2u0Xrx56Ss2DoWsCYqGT4S1jafH0j3tTc4eXXxPFl3ZSSSgTI6DQfpZMHvDcP8kqSQNUP2ac6Fk0BivsAHgzL89crjJ/CwG8J352d5y7ene0Bg27TFvScqHgTjUEzNE21gQTjpz55hR5FRnww3fg7V+guIdGsZe4fRDVgp/PJrEwvc8BcqgAlucLOfMc06vR5CdOR90Tt81xIVUMVR4XtC+h1XEwjbvWvkI0rOCQpIuoPrR
Hi Christian,
In your case, you need to pass the argument of "tyDenote t" under the match. Intuitively, this is needed in order to make the dependent-match perform a kind of "type coercion" on "tyDenote t".
Definition liftVal t: (tyDenote t) -> exp t :=
match t in ty return (tyDenote t) -> exp t with
| Nat => NatLit
| Nat' => Nat'Lit
| Bool => BoolLit
end.
If your are not very familiar with dependent pattern-matching, the more easiest way is to build such complex terms, is to use the interactive prover. On your example, this gives:
Definition liftVal t (x:tyDenote t): exp t.
destruct t; simpl in * |- *.
- apply NatLit; auto.
- apply Nat'Lit; auto.
- apply BoolLit; auto.
Defined.
Then, you can "Print liftVal" and copy paste it in your file, if you prefer have the underlying term...
Regards,
Sylvain.
Le 22/03/2019 à 09:17, Christian Kjær Larsen a écrit :
Inductive ty : Set :=
| Nat : ty
| Nat' : ty
| Bool : ty.
Definition tyDenote (t : ty) : Set :=
match t with
| Nat => nat
| Nat' => nat
| Bool => bool
end.
Inductive exp : ty -> Set :=
| NatLit : nat -> exp Nat
| Nat'Lit : nat -> exp Nat'
| BoolLit : bool -> exp Bool.
Definition liftVal t (x : tyDenote t) : exp t :=
match t in ty return exp t with
| Nat => NatLit x
| Nat' => Nat'Lit x
| Bool => BoolLit x
end.
- [Coq-Club] Problems with dependently typed function, Christian Kjær Larsen, 03/22/2019
- Re: [Coq-Club] Problems with dependently typed function, Gaëtan Gilbert, 03/22/2019
- Re: [Coq-Club] Problems with dependently typed function, Beta Ziliani, 03/22/2019
- Re: [Coq-Club] Problems with dependently typed function, Jean-Francois Monin, 03/22/2019
- Re: [Coq-Club] Problems with dependently typed function, Stefan Monnier, 03/22/2019
- Re: [Coq-Club] Problems with dependently typed function, Jean-Francois Monin, 03/22/2019
- Re: [Coq-Club] Problems with dependently typed function, Beta Ziliani, 03/22/2019
- Re: [Coq-Club] Problems with dependently typed function, Sylvain Boulmé, 03/22/2019
- Re: [Coq-Club] Problems with dependently typed function, Gaëtan Gilbert, 03/22/2019
Archive powered by MHonArc 2.6.18.