File: UsingSets.v

package info (click to toggle)
coq-ext-lib 0.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 808 kB
  • sloc: makefile: 44; python: 31; sh: 4; lisp: 3
file content (34 lines) | stat: -rw-r--r-- 852 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Require Import Coq.Bool.Bool.
Require Import ExtLib.Structures.Sets.
Require Import ExtLib.Structures.Reducible.
Require Import ExtLib.Structures.Functor.

Set Implicit Arguments.
Set Strict Implicit.

(** Program with respect to the set interface **)
Section with_set.
  Variable V : Type.
  Context {set : Type}.
  Context {Set_set : DSet set V}.

  Definition contains_both (v1 v2 : V) (s : set) : bool :=
    contains v1 s && contains v2 s.

  (** Iteration requires foldability **)
  Context {Foldable_set : Foldable set V}.

  Definition toList (s : set) : list V :=
    fold (@cons _) nil s.

End with_set.

(** Instantiate the set **)
Require Import ExtLib.Data.Set.ListSet.
Require Import ExtLib.ExtLib.

Eval compute in contains_both 0 1 empty.

Eval compute in toList (add true (add true empty)).

Eval compute in fmap negb (add true empty).