forked from plclub/metalib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FSetExtra.v
71 lines (49 loc) · 1.82 KB
/
FSetExtra.v
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
(* This file is distributed under the terms of the MIT License, also
known as the X11 Licence. A copy of this license is in the README
file that accompanied the original distribution of this file.
Based on code written by:
Brian Aydemir
Arthur Charg\'eraud *)
Require Import Coq.FSets.FSets.
Require Import CoqFSetInterface.
(* *********************************************************************** *)
(** * Interface *)
Module Type WSfun (X : DecidableType).
Include Type CoqFSetInterface.WSfun X.
(** Definition of when two sets are disjoint. *)
Definition disjoint E F := inter E F [=] empty.
(** We make [notin] a definition for [~ In x L]. We use this
definition whenever possible, so that the [intuition] tactic
does not turn [~ In x L] into [In x L -> False]. *)
Definition notin x L := ~ In x L.
(** The predicate [fresh_list L n xs] holds when [xs] is a list of
length [n] such that the elements are distinct from each other
and from the elements of [L]. *)
Fixpoint fresh_list
(L : t) (n : nat) (xs : list X.t) {struct xs} : Prop :=
match xs, n with
| nil, O =>
True
| cons x xs', S n' =>
notin x L /\ fresh_list (union L (singleton x)) n' xs'
| _, _ =>
False
end.
End WSfun.
(* *********************************************************************** *)
(** * Implementation *)
Module Make (X : DecidableType) <: WSfun X.
Include FSetWeakList.Make X.
Definition disjoint E F := Equal (inter E F) empty.
Definition notin x L := ~ In x L.
Fixpoint fresh_list
(L : t) (n : nat) (xs : list X.t) {struct xs} : Prop :=
match xs, n with
| nil, O =>
True
| cons x xs', S n' =>
notin x L /\ fresh_list (union L (singleton x)) n' xs'
| _, _ =>
False
end.
End Make.