How can you check whether two sets are equal in FStar? The following expression is of type Type0 not Tot Prims.bool so I'm not sure how to use it to determine if the sets are equal (for example in a conditional). Is there a different function that should be used instead of Set.equal?
Set.equal (Set.as_set [1; 2; 3]) Set.empty
The sets defined in
FStar.Setare using functions as representation. Therefore, a setsof integers for instance, is nothing else than a function mapping integers to booleans. For instance, the set{1, 2}is represented as the following function:You can add/remove value (that is, crafting a new lambda), or asks for a value being a member (that is, applying the function).
However, when it comes to comparing two sets of type
T, you're out of luck : fors1ands2two sets,s1 = s2means that for any valuex : T,s1 x = s2 x. When the set ofT's inhabitants is inifinite, this is not computable.Solution The function representation is not suitable for you. You should have a representation whose comparaison is computable.
FStar.OrdSet.fstdefines sets as lists: you should use that one instead.Note that this
OrdSetmodule requires a total order on the values held in the set. (If you want have set of non-ordered values, I implemented that a while ago, but it's a bit hacky...)