coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Gregory Malecha <gmalecha AT gmail.com>
- To: Coq Club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] finite data types
- Date: Mon, 18 Mar 2019 23:12:46 -0400
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=gmalecha AT gmail.com; spf=Pass smtp.mailfrom=gmalecha AT gmail.com; spf=None smtp.helo=postmaster AT mail-wr1-f52.google.com
- Ironport-phdr: 9a23:/Gks/h0sxtl1+X8TsmDT+DRfVm0co7zxezQtwd8ZseIVLfad9pjvdHbS+e9qxAeQG9mCs7Qc0qL/iOPJYSQ4+5GPsXQPItRndiQuroEopTEmG9OPEkbhLfTnPGQQFcVGU0J5rTngaRAGUMnxaEfPrXKs8DUcBgvwNRZvJuTyB4Xek9m72/q99pHOfwlEniaxba5vJxiqsAvdsdUbj5F/Iagr0BvJpXVIe+VSxWx2IF+Yggjx6MSt8pN96ipco/0u+dJOXqX8ZKQ4UKdXDC86PGAv5c3krgfMQA2S7XYBSGoWkx5IAw/Y7BHmW5r6ryX3uvZh1CScIMb7Vq4/Vyi84Kh3SR/okCYHOCA/8GHLkcx7kaZXrAu8qxBj34LYZYeYO/1jcKPAZtMaXXROUdpNVyJPBYO8apEAD+sHPe1Fq4XwqF8DoR64CAKxBu3g1yVIi2f50q000esvEQ/I0g89EdwQrHvZt8/6OLsIXO2v0KXE0TfOYvVL0jn98ojIdRUhrOmNU7Jqb8XRxk4vFxnFj16NroLqJTeV2foRvGib9eVrSOWii2Eiqw5rpjig2NsjionTiY8OxVDE8D92wIcxJdGiVEF7ZtukHYJWuiqHOYV2RcYiTHtpuCY80rAGuJi7fDILyJs93RLfZeaHf5CH4hLiSOaRISp4i2l/dLK+gBa/91WrxO7kVsSszlpGsi5InsPPu30NzRDf9NaLRuZn8kqhxzqC0R3Y5PteLkAuj6XbLoYswr4umZoXtkTOBir2l1/3jK+Sb0kl9PKo5/n+brXoppKQKZV4ig75MqQplcy/Bfo3PhISUGic/OSwzLzj/UvnT7VWlvA6jLXVvZTAKckYpqO1GRFZ3pg+5xqlDzqqzswUnXwdI1JEfBKHgZLpO1bLIP3gAve/hk6jkDN1yP/aPr3uGI7ALnfGkLj7fLZ971RQxxY0zdBa/55UEK0OIOrvWk/ts9zVFgM2Mwutw+r+FNp90p4eVnmUD6+CMKLStEeI6fg1L+mNYo8Vojf9JOI/6/7gl39q0WMaKIKuxNM8bG2yVqBtJFzcan7xiP8AF30Lt0wwVrq5pkeFVGt8fXu9WLgtrhQyDI+tDY6LEo+oibiM1yeyNpJTb2FCTFuLFCG7JM2/R/4QZXfKcYdamTseWO3kFtZ4hEOe8TTiwr8iFdL6vygRtJbtzt9wvrSBmhQ79DgyBMOYgTjUEzNE21gQTjpz55hR5FRnww7ag6d9iv1cU9dU4qERC1poBdvn1+V/TuvKdEfBc9OOEgv0R9ynBXQuVIt0zYJUJUl6HNqmg1bI2C/4W7I=
I think the coq-bbv opam package provides many definitions about a dependent representation of bitvectors. Unfortunately, storing indicies can be quite costly, so if you are going to do a lot of computation, the definition that you have is actually faster.
On Mon, Mar 18, 2019 at 10:36 AM Maximilian Wuttke <s8mawutt AT stud.uni-saarland.de> wrote:
For the finite type of numbers `0,...,n-1` there already is `Fin.t n` in
Coq's standard library. [1]
It is a classical example for a dependent inductive type.
However, this type can be quite tricky for beginners.
I have heard of implementations of machine integers (like unsigned 8),
but I currently don't have a link.
For general *finite types*, you can do something like
```
Require Import List.
Class finite (X:Type) :=
{
enum : list X;
enum_complete : forall (x:X), In x enum;
}.
Instance finite_unit : finite unit :=
{| enum := cons tt nil |}.
Proof. abstract now intros []; constructor. Defined.
```
[1] https://coq.inria.fr/distrib/current/stdlib/Coq.Vectors.Fin.html
Sincerely
Maximilian
On 18/03/2019 15:10, fritjof AT uni-bremen.de wrote:
> Hi,
>
> I want to create a finite data type, like *Unsinged 8*,
> which containes values from 0 to 2^8 -1.
> I came up with an idea like:
>
> Definition unsigned (max:Z) : Set :=
> { x : Z | x >= 0 /\ x < max}.
>
> Definition unsigned_8 := unsigned (2^8).
>
> But I'm not sure, if this is the right way.
>
> Does someone know if there is a better way to define
> finite types?
>
> --f.
>
gregory malecha
- [Coq-Club] finite data types, fritjof, 03/18/2019
- Re: [Coq-Club] finite data types, Mario Alvarez Picallo, 03/18/2019
- Re: [Coq-Club] finite data types, Jan Bessai, 03/18/2019
- Re: [Coq-Club] finite data types, Maximilian Wuttke, 03/18/2019
- Re: [Coq-Club] finite data types, Gregory Malecha, 03/19/2019
- Re: [Coq-Club] finite data types, Alix Trieu, 03/19/2019
- Re: [Coq-Club] finite data types, Xavier Leroy, 03/19/2019
- Re: [Coq-Club] finite data types, Gaëtan Gilbert, 03/19/2019
- Re: [Coq-Club] finite data types, Xavier Leroy, 03/19/2019
- Re: [Coq-Club] finite data types, Fritjof Bornebusch, 03/20/2019
- Re: [Coq-Club] finite data types, Emilio Jesús Gallego Arias, 03/20/2019
- Re: [Coq-Club] finite data types, Xavier Leroy, 03/19/2019
- Re: [Coq-Club] finite data types, Gaëtan Gilbert, 03/19/2019
- Re: [Coq-Club] finite data types, Xavier Leroy, 03/19/2019
Archive powered by MHonArc 2.6.18.