coq


How to define finite set of N elements in Coq?


How to define, for general parameter N:nat , finite set of N elements, $ A_{0},...A_{N-1} $ ?
Is there an elegant way to do it by recursive definition? Could someone point me into good example of reasoning about such structures?
A very convenient solution is to define the nth ordinal, 'I_n as a record:
Definition ordinal n := {
val :> nat;
_ : val < n;
}.
that is to say, a pair of a natural number, plus a proof that such natural number is less than n, where < : nat -> nat -> bool. It is very convenient to use a computable comparison operator here, in particular means that the proof itself is not very "important", which is what you normally want.
This is the solution used in math-comp, and it has nice properties, mainly injectivity of val, val_inj : injective val, which means that you can reuse most of the standard operations over nat with your new datatype. Note that you may want to define addition as either add i j := max n.-1 (i+j) or as (i+j) %% n.
Additionally, the library linked above provides general definitions for working with finite types, including a bijection of them to their cardinal ordinal.

Related Links

Apply partially instantiated lemma
Using reflexivity in Coq
High-speed calculation of Coq's theorems
Topological Definition of Continuous in Coq
Reference in Coq Lists library not found
Purpose of maximal vs non-maximal implicit arguments
Idris type system properties
How to destruct/generalize over Program's rewritten match statements
Show all axioms Coq
Product Type in Coq
Coq inductive definition for the entailment property
How to make sublists in Coq?
Nested theorems in Coq
Why does this rewrite fail in the context of dependent types
How to raise exception in Coq?(in match … end)
How to define set in coq without defining set as a list of elements

Categories

HOME
compiler-construction
wso2
blogger
reflection
dictionary
plone
office365api
platform-builder
dot
sqlite3
fsm
serverspec
medical
kibana-4
google-apps-marketplace
google-cloud-spanner
vb.net-2010
foselasticabundle
django-admin
fatal-error
transformation
footer
shared-hosting
dbext
reverse-proxy
autoconf
zurb-foundation-6
microsoft-sync-framework
buildbot
spring-mybatis
maquette
bpel
librato
junit5
ecto
bosh
copying
perlin-noise
windows-dev-center
bower-install
bytecode-manipulation
restlet
bootstrapper
preconditions
powershell-dsc
flashair
sencha-touch-2.3
thin
convertapi
python-webbrowser
aurelia-validation
pg-dump
yt-project
jquery-filter
spring-android
nxt
android-textview
log4c
savon
merge-conflict-resolution
gridview-sorting
bgp
php-internals
rhino-servicebus
associative-array
pyke
pervasive-sql
eclipse-clp
wireshark-dissector
jqgrid-formatter
computer-algebra-systems
event-bubbling
sailfish-os
c++03
has-many-through
aapt
doskey
inbox
tws
free-variable
pvrtc
labwindows
removeclass
subscript
stage
pydot
tomcat-valve
yslow
google-friend-connect
subviews
zend-translate
routedevent
ncqrs
virtual-functions
project-hosting

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App