'How to create a Powerset of MSetList?
I am creating an MSetList P with elements of type String, and I would like to obtain the Powerset of P. I am not being able to figure it out.
Code below.
Thanks for your help :-)
Require Import
Coq.MSets.MSetList
Coq.Strings.String
Coq.Structures.OrdersEx.
Module set := Make OrdersEx.String_as_OT.
Definition P := set.add "A"%string (set.add "B"%string (set.add "C"%string (set.add "D"%string set.empty))).
Compute P.
Solution 1:[1]
Answer was provided on the Coq Discourse Forum by Yves Bertot
The construction of set shows that you are using the
Makefunction with a module as argument. If you typePrint Make., you see that this is a functor taking a module of typeOrderedTypeas argument, and it produces a module with many fields, among whicht,eq,eq_equiv,lt,lt_strorder,lt_compat,compare,compare_spec, andeq_dec. If you typePrint OrderedType., you see that these field are the ones required to make anOrderedType.So Make constructs all the fields that would be required to call Make again, thus producing the powerset.
You can just type :
Module pset := Make set.and you will simply obtain a structure of sets, whose elements are in
set.t. The following example was tested with coq 8.15.Require Import Coq.MSets.MSetList Coq.Strings.String Coq.Structures.OrdersEx. Module set := Make OrdersEx.String_as_OT. Module pset := Make set. Definition set1 := set.add "A"%string set.empty. Definition set2 := set.add "B"%string set.empty. Definition set3 := set.add "C"%string set1. Definition pset1 := pset.add set1 (pset.add set2 pset.empty). Compute pset.mem set3 pset1. Compute pset.mem set2 pset1.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | georgionic |
