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

How to do “negative” match in Ltac?
How to match a “match” expression?
Inverting an obviously untrue hypothesis does not prove falsehood
COQ gets wrong by proving “forall n:nat, ( n <= 0) -> n=0”
How can I do intros in a different order without using generalize dependent in Coq?
Defining isomorphism classes in Coq
How to prove (forall n m : nat, (n <? m) = false -> m <= n) in Coq?
How to do pseudo polynomial divisions in Coq/Ssreflect
How to prove functions equal, knowing their bodies are equal?
Using dependent types in Coq (safe nth function)
Case based proof using nat comparisons in COQ
Change a function at one point
Apply a function to both sides of an equality in Coq?
Coq induction start at specific nat
Extraction of Type Scheme
Contracting nested let statments

Categories

HOME
heroku
tinymce
angular-material
include
fft
octobercms
jsp-tags
getelementsbytagname
leon
malloc
microservices
twitter-bootstrap-4
survey
icloud
azure-media-services
google-translate
reveal.js
google-apps-marketplace
remote-access
workload-scheduler
dosgi
finite-automata
lucene.net
language-agnostic
zurb-foundation-6
tibco-mdm
h2db
shopware
pepper
status
fgetcsv
entitlements
maquette
typo3-6.2.x
neo4j-spatial
xacml
gsoap
skia
socialengine
twilio-api
exuberant-ctags
lxd
repo
subset-sum
nssegmentedcontrol
restlet
jquery-bootgrid
withings
starteam
sas-visual-analytics
pango
multipeer-connectivity
boost-multi-index
dotnetzip
elgg
csound
boost-preprocessor
ifs
sqlbulkcopy
blacklist
android-fonts
spring-android
persist
hover-over
packagist
maven-tomcat-plugin
intel-fortran
lemon
angular-leaflet-directive
splash
rake-task
android-imagebutton
qcodo
undefined-reference
meteor-velocity
stxxl
farseer
quartz-graphics
padarn
android-screen-support
wsdl-2.0
referrer
pysimplesoap
php-parser
invite
actionview
iphone-web-app
sudzc
web-application-design
gin
filtered-index
mirah
port-number
windows-live-messenger

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App