coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Klaus Ostermann <klaus.ostermann AT uni-tuebingen.de>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] How to represent tabular data in Coq
- Date: Wed, 10 May 2017 10:19:57 +0200
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=klaus.ostermann AT uni-tuebingen.de; spf=None smtp.mailfrom=klaus.ostermann AT uni-tuebingen.de; spf=None smtp.helo=postmaster AT mx03.uni-tuebingen.de
- Ironport-phdr: 9a23:dWlDVhAOy9GIEQdct9SjUyQJP3N1i/DPJgcQr6AfoPdwSPT8psbcNUDSrc9gkEXOFd2CrakV16yO6+jJYi8p2d65qncMcZhBBVcuqP49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6JvjvGo7Vks+7y/2+94fdbghMizexe69+IAmrpgjNq8cahpdvJLwswRXTuHtIfOpWxWJsJV2Nmhv3+9m98p1+/SlOovwt78FPX7n0cKQ+VrxYES8pM3sp683xtBnMVhWA630BWWgLiBVIAgzF7BbnXpfttybxq+Rw1DWGMcDwULs7Xiiv4qlpRRLmkSsLKzE0+3zThsFwkK5XpRSsrAF9zYHJeoGYLPpwcL7Dc9MURmRPUMheWCNDDYygYIUCFPYBMORCooXhu1cDoxmzCA+xD+3v0D9IgXr20LU/3eQlCw7GwRcgFM8XvnTPsNX6Kr0SUeWvw6nOyzXIcvRb2TT56IfSbxAhuuuAXbVrccrN10YvDQbFgU+WqYzjJD6Vy+INs2mC4+p8SOKglXUoqwB3ojig2MgsjJPFiZ8LxV3d8yhy3Yg7Jdq9SEFhYN6kFoNdty6bN4tqQsMiXnpntDwmxb0BvJ63ZDQFyJQjxx7ec/yIaYyI7Qj5WOaXPzh4mHRoc6+8iRaq6UWs1+PxW8au3FpUtCZIksPAum4Q2xHd8sSKRPlw8l2/1TqTygzf8ONJLVopmafbK5MsxKM7mIAJvkTZBCD2nV37jK+IeUUg/eil8+HnY7r6qpKSLYN0lwf+MqU3lsyjHOQ3LBMBX2md+eSzyrLj+1f1T6hUgfEuk6nZto7VJdgDq6KkDQJY3Zwv5wilAzqmytgUg2QLIVxddBKClYfpOlXOIP7iDfe4hlShiDRrx/TcMb38GZXBNH/DkKz9fblj8U5czRA8zdZZ559PF7EBJvPzVlbttNzFEBA2KA20w+DoCNpj0IMSQ3+ADbGBPKPIrVCI/v4vI/WLZIINpDn9LOEl6+fygn89hF8SZrKk3YAXaXC9BvRpOV+VYXvqgtcbEGcFpBAyTOLwiA7KbTkGbHGrGqk4+zsTCYS8DI6FSJr+rqaG2XKYGpRLfShhEUyBC3LhcYPMD/QIYT+JZMh6jjEeULGnTac80xDrqBL3wbthIefSvCEV48GwnONp7vHewElhvQd/CN6QhjzVQg==
Dear Ben,
thanks these are very useful pointers.
A few question, though: Why don't you use the "In" predicate from
the standard library instead of "member"?
Haven't you only given me the interface for tables but not their
representation?
How would I construct an actual table?
The difference between "member" and "members" is also interesting.
How do I "see" that "member" requires UIP?
Another mailing list member pointed me to another solution based on
hlists like
described in Chlipala's book
(http://adam.chlipala.net/cpdt/html/DataStruct.html).
With hlist, a table could be represented as:
Definition table (A R C : Type) (r : list R) (c : list C) : Type :=
hlist (fun _ => hlist (fun _ => A) c) r.
Definition lookup A R C (r : list R) (c : list C) (t : table A r c) x y
(mx : member x r) (my : member y c) : A :=
hget my (hget mx t).
I found out that in my particular application it is useful if the type
of cells can
depend on the row and column labels. With hlist, this can be encoded as:
Definition table' (R C : Type) (r : list R) (c : list C)(celltype: R ->
C -> Type) : Type :=
hlist (fun r => hlist (fun c => celltype r c) c) r.
Definition lookup' R C (r : list R) (c : list C) ct (t : table' r c ct) x y
(mx : member x r) (my : member y c) : ct x y :=
hget my (hget mx t).
I've constructed a small library around these definitions. If anyone
wants to take a look:
https://gist.github.com/klauso/ffcff8c37fe62f3af5dc1cde878d941c
Thanks and best regards,
Klaus
- [Coq-Club] How to represent tabular data in Coq, Klaus Ostermann, 05/08/2017
- Re: [Coq-Club] How to represent tabular data in Coq, Wilayat Khan, 05/09/2017
- <Possible follow-up(s)>
- Re: [Coq-Club] How to represent tabular data in Coq, Ben Sherman, 05/10/2017
- Re: [Coq-Club] How to represent tabular data in Coq, Klaus Ostermann, 05/10/2017
- Re: [Coq-Club] How to represent tabular data in Coq, Ben Sherman, 05/17/2017
- Re: [Coq-Club] How to represent tabular data in Coq, Jason Gross, 05/17/2017
Archive powered by MHonArc 2.6.18.