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?
相关问题
- Rewriting with John Major's equality
- Python: Calculate difference between all elements
- Grouping integers by set membership in Python
- Computing unique intersections of subsets
- Find Closest Element in a Set
相关文章
- C#中 public virtual string Category { get; }这么写会报错:
- coq error when trying to use Case. Example from So
- How to switch the current goal in Coq?
- What does “Error: Universe inconsistency” mean in
- Compare sets inside a set
- Set properties to jsf managed-bean
- Efficient all-pairs set intersection on GPU
- Umbraco - how to set the value of a property using
A very convenient solution is to define the
n
th ordinal,'I_n
as a record: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 overnat
with your new datatype. Note that you may want to define addition as eitheradd 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.