英文:
Is there a library for sets that works with bool in Coq?
问题
我正在寻求使用数学集合和某种通用类型的子集进行工作。
我知道通常这表示为 U -> Prop
,就像在Ensembles库中一样。
我想知道是否有一种表示集合的方式是可决定的,也许集合可以表示为 S : U -> bool
,我们可以决定任何元素是否在S中,还是这根本不可能?
理想情况下,我希望能够计算出,给定类型U的一组元素,属于某个集合S的这些元素的子集。
英文:
I am looking to work with mathematical sets and subsets of some universal type.
I know this is normally represented as U -> Prop
, such as in the Ensembles library.
I was wondering if there is perhaps some representation of sets that is decidable, perhaps where sets are represented as S : U -> bool
where we can decide for any element of U whether it is in S, or is this simply impossible?
Ideally, I would like to be able to compute, given a collection of elements of type U, the subset of those elements that are in some set S as well.
答案1
得分: 1
你可能希望查看mathcomp/ssreflect框架的finset
库,如果你还不了解它的话:finset.v。
英文:
You might want to have a look at the finset
library of the mathcomp/ssreflect framework, if you don't know about it already: finset.v.
答案2
得分: 1
以下是要翻译的内容:
在Coq中有几个用于处理集合的库:
- Ensembles:在Coq标准库中可用,集合可以是无限的,但有点笨拙。
- MSets:在Coq标准库中可用,仅限有限集合,一旦提取出来就行为良好,但界面有些笨拙。还请参阅这篇关于实现的论文。
- std++的fin_sets:仅限有限集合,成员资格是可判定的,包括用于某些集合目标的
set_solver
策略。 - MathComp的finset:有限集合适用于有限类型,成员资格是可判定的。还请参阅有关finset和finmap(下一项)的指南。
- MathComp的finmap:适用于选择类型(例如可数类型)的有限集合,成员资格是可判定的。
通常,一旦您使用了std++或MathComp的某个部分,最好使用全部,部分原因是这些库有一些复杂的学习曲线(我认为是值得的)。
英文:
There are several libraries to work with sets in Coq:
- Ensembles: available in the Coq standard library, the sets can be infinite, a bit clunky.
- MSets: available in the Coq standard library, finite sets only, behaves well once extracted but the interface is clunky. See also this paper on the implementation.
- fin_sets from std++: finite sets only, membership is decidable, includes a
set_solver
tactic for some kinds of set goals. - finset from MathComp: finite sets for finite types, membership is decidable. See also this guide on finset and finmap (the next item).
- finmap from MathComp: finite sets for choice types (eg coutable types), membership is decidable.
Typically, once you use some part of std++ or of MathComp you are better off using all of it, in part because there is some non-trivial learning curve to these libraries (worth it, IMO).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论