Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
stdpp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gregory Malecha
stdpp
Commits
f6b1bf4b
Commit
f6b1bf4b
authored
5 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
New class `SetUnfoldElemOf` that specializes `SetUnfold` to improve performance.
parent
a8e9b673
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
theories/fin_sets.v
+6
-6
6 additions, 6 deletions
theories/fin_sets.v
theories/gmultiset.v
+3
-2
3 additions, 2 deletions
theories/gmultiset.v
theories/propset.v
+2
-2
2 additions, 2 deletions
theories/propset.v
theories/sets.v
+53
-33
53 additions, 33 deletions
theories/sets.v
with
64 additions
and
43 deletions
theories/fin_sets.v
+
6
−
6
View file @
f6b1bf4b
...
@@ -60,8 +60,8 @@ Defined.
...
@@ -60,8 +60,8 @@ Defined.
(** * The [elements] operation *)
(** * The [elements] operation *)
Global
Instance
set_unfold_elements
X
x
P
:
Global
Instance
set_unfold_elements
X
x
P
:
SetUnfold
(
x
∈
X
)
P
→
SetUnfold
(
x
∈
elements
X
)
P
.
SetUnfold
ElemOf
x
X
P
→
SetUnfold
ElemOf
x
(
elements
X
)
P
.
Proof
.
constructor
.
by
rewrite
elem_of_elements
,
(
set_unfold
(
x
∈
X
)
P
)
.
Qed
.
Proof
.
constructor
.
by
rewrite
elem_of_elements
,
(
set_unfold
_elem_of
x
X
P
)
.
Qed
.
Global
Instance
elements_proper
:
Proper
((
≡
)
==>
(
≡
ₚ
))
(
elements
(
C
:=
C
))
.
Global
Instance
elements_proper
:
Proper
((
≡
)
==>
(
≡
ₚ
))
(
elements
(
C
:=
C
))
.
Proof
.
Proof
.
...
@@ -278,9 +278,9 @@ Section filter.
...
@@ -278,9 +278,9 @@ Section filter.
by
rewrite
elem_of_list_to_set
,
elem_of_list_filter
,
elem_of_elements
.
by
rewrite
elem_of_list_to_set
,
elem_of_list_filter
,
elem_of_elements
.
Qed
.
Qed
.
Global
Instance
set_unfold_filter
X
Q
:
Global
Instance
set_unfold_filter
X
Q
:
SetUnfold
(
x
∈
X
)
Q
→
SetUnfold
(
x
∈
filter
P
X
)
(
P
x
∧
Q
)
.
SetUnfold
ElemOf
x
X
Q
→
SetUnfold
ElemOf
x
(
filter
P
X
)
(
P
x
∧
Q
)
.
Proof
.
Proof
.
intros
??;
constructor
.
by
rewrite
elem_of_filter
,
(
set_unfold
(
x
∈
X
)
Q
)
.
intros
??;
constructor
.
by
rewrite
elem_of_filter
,
(
set_unfold
_elem_of
x
X
Q
)
.
Qed
.
Qed
.
Lemma
filter_empty
:
filter
P
(
∅:
C
)
≡
∅.
Lemma
filter_empty
:
filter
P
(
∅:
C
)
≡
∅.
...
@@ -316,8 +316,8 @@ Section map.
...
@@ -316,8 +316,8 @@ Section map.
by
setoid_rewrite
elem_of_elements
.
by
setoid_rewrite
elem_of_elements
.
Qed
.
Qed
.
Global
Instance
set_unfold_map
(
f
:
A
→
B
)
(
X
:
C
)
(
P
:
A
→
Prop
)
:
Global
Instance
set_unfold_map
(
f
:
A
→
B
)
(
X
:
C
)
(
P
:
A
→
Prop
)
:
(
∀
y
,
SetUnfold
(
y
∈
X
)
(
P
y
))
→
(
∀
y
,
SetUnfold
ElemOf
y
X
(
P
y
))
→
SetUnfold
(
x
∈
set_map
(
D
:=
D
)
f
X
)
(
∃
y
,
x
=
f
y
∧
P
y
)
.
SetUnfold
ElemOf
x
(
set_map
(
D
:=
D
)
f
X
)
(
∃
y
,
x
=
f
y
∧
P
y
)
.
Proof
.
constructor
.
rewrite
elem_of_map
;
naive_solver
.
Qed
.
Proof
.
constructor
.
rewrite
elem_of_map
;
naive_solver
.
Qed
.
Global
Instance
set_map_proper
:
Global
Instance
set_map_proper
:
...
...
This diff is collapsed.
Click to expand it.
theories/gmultiset.v
+
3
−
2
View file @
f6b1bf4b
...
@@ -136,10 +136,11 @@ Lemma gmultiset_elem_of_disj_union X Y x : x ∈ X ⊎ Y ↔ x ∈ X ∨ x ∈ Y
...
@@ -136,10 +136,11 @@ Lemma gmultiset_elem_of_disj_union X Y x : x ∈ X ⊎ Y ↔ x ∈ X ∨ x ∈ Y
Proof
.
rewrite
!
elem_of_multiplicity
,
multiplicity_disj_union
.
lia
.
Qed
.
Proof
.
rewrite
!
elem_of_multiplicity
,
multiplicity_disj_union
.
lia
.
Qed
.
Global
Instance
set_unfold_gmultiset_disj_union
x
X
Y
P
Q
:
Global
Instance
set_unfold_gmultiset_disj_union
x
X
Y
P
Q
:
SetUnfold
(
x
∈
X
)
P
→
SetUnfold
(
x
∈
Y
)
Q
→
SetUnfold
(
x
∈
X
⊎
Y
)
(
P
∨
Q
)
.
SetUnfoldElemOf
x
X
P
→
SetUnfoldElemOf
x
Y
Q
→
SetUnfoldElemOf
x
(
X
⊎
Y
)
(
P
∨
Q
)
.
Proof
.
Proof
.
intros
??;
constructor
.
rewrite
gmultiset_elem_of_disj_union
.
intros
??;
constructor
.
rewrite
gmultiset_elem_of_disj_union
.
by
rewrite
<-
(
set_unfold
(
x
∈
X
)
P
),
<-
(
set_unfold
(
x
∈
Y
)
Q
)
.
by
rewrite
<-
(
set_unfold
_elem_of
x
X
P
),
<-
(
set_unfold
_elem_of
x
Y
Q
)
.
Qed
.
Qed
.
(* Algebraic laws *)
(* Algebraic laws *)
...
...
This diff is collapsed.
Click to expand it.
theories/propset.v
+
2
−
2
View file @
f6b1bf4b
...
@@ -44,10 +44,10 @@ Instance propset_join : MJoin propset := λ A (XX : propset (propset A)),
...
@@ -44,10 +44,10 @@ Instance propset_join : MJoin propset := λ A (XX : propset (propset A)),
Instance
propset_monad_set
:
MonadSet
propset
.
Instance
propset_monad_set
:
MonadSet
propset
.
Proof
.
by
split
;
try
apply
_
.
Qed
.
Proof
.
by
split
;
try
apply
_
.
Qed
.
Instance
set_unfold_propset_top
{
A
}
(
x
:
A
)
:
SetUnfold
(
x
∈
(
⊤
:
propset
A
)
)
True
.
Instance
set_unfold_propset_top
{
A
}
(
x
:
A
)
:
SetUnfold
ElemOf
x
(
⊤
:
propset
A
)
True
.
Proof
.
by
constructor
.
Qed
.
Proof
.
by
constructor
.
Qed
.
Instance
set_unfold_PropSet
{
A
}
(
P
:
A
→
Prop
)
x
Q
:
Instance
set_unfold_PropSet
{
A
}
(
P
:
A
→
Prop
)
x
Q
:
SetUnfoldSimpl
(
P
x
)
Q
→
SetUnfold
(
x
∈
PropSet
P
)
Q
.
SetUnfoldSimpl
(
P
x
)
Q
→
SetUnfold
ElemOf
x
(
PropSet
P
)
Q
.
Proof
.
intros
HPQ
.
constructor
.
apply
HPQ
.
Qed
.
Proof
.
intros
HPQ
.
constructor
.
apply
HPQ
.
Qed
.
Global
Opaque
propset_elem_of
propset_top
propset_empty
propset_singleton
.
Global
Opaque
propset_elem_of
propset_top
propset_empty
propset_singleton
.
...
...
This diff is collapsed.
Click to expand it.
theories/sets.v
+
53
−
33
View file @
f6b1bf4b
...
@@ -96,6 +96,20 @@ Class SetUnfold (P Q : Prop) := { set_unfold : P ↔ Q }.
...
@@ -96,6 +96,20 @@ Class SetUnfold (P Q : Prop) := { set_unfold : P ↔ Q }.
Arguments
set_unfold
_
_
{_}
:
assert
.
Arguments
set_unfold
_
_
{_}
:
assert
.
Hint
Mode
SetUnfold
+
-
:
typeclass_instances
.
Hint
Mode
SetUnfold
+
-
:
typeclass_instances
.
(** The class [SetUnfoldElemOf] is a more specialized version of [SetUnfold]
for propositions of the shape [x ∈ X] to improve performance. *)
Class
SetUnfoldElemOf
`{
ElemOf
A
C
}
(
x
:
A
)
(
X
:
C
)
(
Q
:
Prop
)
:=
{
set_unfold_elem_of
:
x
∈
X
↔
Q
}
.
Arguments
set_unfold_elem_of
{_
_
_}
_
_
_
{_}
:
assert
.
Hint
Mode
SetUnfoldElemOf
+
+
+
-
+
-
:
typeclass_instances
.
Instance
set_unfold_elem_of_default
`{
ElemOf
A
C
}
(
x
:
A
)
(
X
:
C
)
:
SetUnfoldElemOf
x
X
(
x
∈
X
)
|
1000
.
Proof
.
done
.
Qed
.
Instance
set_unfold_elem_of_set_unfold
`{
ElemOf
A
C
}
(
x
:
A
)
(
X
:
C
)
Q
:
SetUnfoldElemOf
x
X
Q
→
SetUnfold
(
x
∈
X
)
Q
.
Proof
.
by
destruct
1
;
constructor
.
Qed
.
Class
SetUnfoldSimpl
(
P
Q
:
Prop
)
:=
{
set_unfold_simpl
:
SetUnfold
P
Q
}
.
Class
SetUnfoldSimpl
(
P
Q
:
Prop
)
:=
{
set_unfold_simpl
:
SetUnfold
P
Q
}
.
Hint
Extern
0
(
SetUnfoldSimpl
_
_)
=>
csimpl
;
constructor
:
typeclass_instances
.
Hint
Extern
0
(
SetUnfoldSimpl
_
_)
=>
csimpl
;
constructor
:
typeclass_instances
.
...
@@ -146,47 +160,49 @@ Section set_unfold_simple.
...
@@ -146,47 +160,49 @@ Section set_unfold_simple.
Implicit
Types
x
y
:
A
.
Implicit
Types
x
y
:
A
.
Implicit
Types
X
Y
:
C
.
Implicit
Types
X
Y
:
C
.
Global
Instance
set_unfold_empty
x
:
SetUnfold
(
x
∈
(
∅
:
C
)
)
False
.
Global
Instance
set_unfold_empty
x
:
SetUnfold
ElemOf
x
(
∅
:
C
)
False
.
Proof
.
constructor
.
split
.
apply
not_elem_of_empty
.
done
.
Qed
.
Proof
.
constructor
.
split
.
apply
not_elem_of_empty
.
done
.
Qed
.
Global
Instance
set_unfold_singleton
x
y
:
SetUnfold
(
x
∈
({[
y
]}
:
C
)
)
(
x
=
y
)
.
Global
Instance
set_unfold_singleton
x
y
:
SetUnfold
ElemOf
x
({[
y
]}
:
C
)
(
x
=
y
)
.
Proof
.
constructor
;
apply
elem_of_singleton
.
Qed
.
Proof
.
constructor
;
apply
elem_of_singleton
.
Qed
.
Global
Instance
set_unfold_union
x
X
Y
P
Q
:
Global
Instance
set_unfold_union
x
X
Y
P
Q
:
SetUnfold
(
x
∈
X
)
P
→
SetUnfold
(
x
∈
Y
)
Q
→
SetUnfold
(
x
∈
X
∪
Y
)
(
P
∨
Q
)
.
SetUnfoldElemOf
x
X
P
→
SetUnfoldElemOf
x
Y
Q
→
SetUnfoldElemOf
x
(
X
∪
Y
)
(
P
∨
Q
)
.
Proof
.
Proof
.
intros
??;
constructor
.
intros
??;
constructor
.
by
rewrite
elem_of_union
,
(
set_unfold
(
x
∈
X
)
P
),
(
set_unfold
(
x
∈
Y
)
Q
)
.
by
rewrite
elem_of_union
,
(
set_unfold_elem_of
x
X
P
),
(
set_unfold_elem_of
x
Y
Q
)
.
Qed
.
Qed
.
Global
Instance
set_unfold_equiv_same
X
:
SetUnfold
(
X
≡
X
)
True
|
1
.
Global
Instance
set_unfold_equiv_same
X
:
SetUnfold
(
X
≡
X
)
True
|
1
.
Proof
.
done
.
Qed
.
Proof
.
done
.
Qed
.
Global
Instance
set_unfold_equiv_empty_l
X
(
P
:
A
→
Prop
)
:
Global
Instance
set_unfold_equiv_empty_l
X
(
P
:
A
→
Prop
)
:
(
∀
x
,
SetUnfold
(
x
∈
X
)
(
P
x
))
→
SetUnfold
(
∅
≡
X
)
(
∀
x
,
¬
P
x
)
|
5
.
(
∀
x
,
SetUnfold
ElemOf
x
X
(
P
x
))
→
SetUnfold
(
∅
≡
X
)
(
∀
x
,
¬
P
x
)
|
5
.
Proof
.
Proof
.
intros
?;
constructor
.
unfold
equiv
,
set_equiv
.
intros
?;
constructor
.
unfold
equiv
,
set_equiv
.
pose
proof
(
not_elem_of_empty
(
C
:=
C
));
naive_solver
.
pose
proof
(
not_elem_of_empty
(
C
:=
C
));
naive_solver
.
Qed
.
Qed
.
Global
Instance
set_unfold_equiv_empty_r
(
P
:
A
→
Prop
)
X
:
Global
Instance
set_unfold_equiv_empty_r
(
P
:
A
→
Prop
)
X
:
(
∀
x
,
SetUnfold
(
x
∈
X
)
(
P
x
))
→
SetUnfold
(
X
≡
∅
)
(
∀
x
,
¬
P
x
)
|
5
.
(
∀
x
,
SetUnfold
ElemOf
x
X
(
P
x
))
→
SetUnfold
(
X
≡
∅
)
(
∀
x
,
¬
P
x
)
|
5
.
Proof
.
Proof
.
intros
?;
constructor
.
unfold
equiv
,
set_equiv
.
intros
?;
constructor
.
unfold
equiv
,
set_equiv
.
pose
proof
(
not_elem_of_empty
(
C
:=
C
));
naive_solver
.
pose
proof
(
not_elem_of_empty
(
C
:=
C
));
naive_solver
.
Qed
.
Qed
.
Global
Instance
set_unfold_equiv
(
P
Q
:
A
→
Prop
)
X
:
Global
Instance
set_unfold_equiv
(
P
Q
:
A
→
Prop
)
X
:
(
∀
x
,
SetUnfold
(
x
∈
X
)
(
P
x
))
→
(
∀
x
,
SetUnfold
(
x
∈
Y
)
(
Q
x
))
→
(
∀
x
,
SetUnfold
ElemOf
x
X
(
P
x
))
→
(
∀
x
,
SetUnfold
ElemOf
x
Y
(
Q
x
))
→
SetUnfold
(
X
≡
Y
)
(
∀
x
,
P
x
↔
Q
x
)
|
10
.
SetUnfold
(
X
≡
Y
)
(
∀
x
,
P
x
↔
Q
x
)
|
10
.
Proof
.
constructor
.
apply
forall_proper
;
naive_solver
.
Qed
.
Proof
.
constructor
.
apply
forall_proper
;
naive_solver
.
Qed
.
Global
Instance
set_unfold_subseteq
(
P
Q
:
A
→
Prop
)
X
Y
:
Global
Instance
set_unfold_subseteq
(
P
Q
:
A
→
Prop
)
X
Y
:
(
∀
x
,
SetUnfold
(
x
∈
X
)
(
P
x
))
→
(
∀
x
,
SetUnfold
(
x
∈
Y
)
(
Q
x
))
→
(
∀
x
,
SetUnfold
ElemOf
x
X
(
P
x
))
→
(
∀
x
,
SetUnfold
ElemOf
x
Y
(
Q
x
))
→
SetUnfold
(
X
⊆
Y
)
(
∀
x
,
P
x
→
Q
x
)
.
SetUnfold
(
X
⊆
Y
)
(
∀
x
,
P
x
→
Q
x
)
.
Proof
.
constructor
.
apply
forall_proper
;
naive_solver
.
Qed
.
Proof
.
constructor
.
apply
forall_proper
;
naive_solver
.
Qed
.
Global
Instance
set_unfold_subset
(
P
Q
:
A
→
Prop
)
X
:
Global
Instance
set_unfold_subset
(
P
Q
:
A
→
Prop
)
X
:
(
∀
x
,
SetUnfold
(
x
∈
X
)
(
P
x
))
→
(
∀
x
,
SetUnfold
(
x
∈
Y
)
(
Q
x
))
→
(
∀
x
,
SetUnfold
ElemOf
x
X
(
P
x
))
→
(
∀
x
,
SetUnfold
ElemOf
x
Y
(
Q
x
))
→
SetUnfold
(
X
⊂
Y
)
((
∀
x
,
P
x
→
Q
x
)
∧
¬∀
x
,
Q
x
→
P
x
)
.
SetUnfold
(
X
⊂
Y
)
((
∀
x
,
P
x
→
Q
x
)
∧
¬∀
x
,
Q
x
→
P
x
)
.
Proof
.
Proof
.
constructor
.
unfold
strict
.
constructor
.
unfold
strict
.
repeat
f_equiv
;
apply
forall_proper
;
naive_solver
.
repeat
f_equiv
;
apply
forall_proper
;
naive_solver
.
Qed
.
Qed
.
Global
Instance
set_unfold_disjoint
(
P
Q
:
A
→
Prop
)
X
Y
:
Global
Instance
set_unfold_disjoint
(
P
Q
:
A
→
Prop
)
X
Y
:
(
∀
x
,
SetUnfold
(
x
∈
X
)
(
P
x
))
→
(
∀
x
,
SetUnfold
(
x
∈
Y
)
(
Q
x
))
→
(
∀
x
,
SetUnfold
ElemOf
x
X
(
P
x
))
→
(
∀
x
,
SetUnfold
ElemOf
x
Y
(
Q
x
))
→
SetUnfold
(
X
##
Y
)
(
∀
x
,
P
x
→
Q
x
→
False
)
.
SetUnfold
(
X
##
Y
)
(
∀
x
,
P
x
→
Q
x
→
False
)
.
Proof
.
constructor
.
unfold
disjoint
,
set_disjoint
.
naive_solver
.
Qed
.
Proof
.
constructor
.
unfold
disjoint
,
set_disjoint
.
naive_solver
.
Qed
.
...
@@ -194,13 +210,13 @@ Section set_unfold_simple.
...
@@ -194,13 +210,13 @@ Section set_unfold_simple.
Global
Instance
set_unfold_equiv_same_L
X
:
SetUnfold
(
X
=
X
)
True
|
1
.
Global
Instance
set_unfold_equiv_same_L
X
:
SetUnfold
(
X
=
X
)
True
|
1
.
Proof
.
done
.
Qed
.
Proof
.
done
.
Qed
.
Global
Instance
set_unfold_equiv_empty_l_L
X
(
P
:
A
→
Prop
)
:
Global
Instance
set_unfold_equiv_empty_l_L
X
(
P
:
A
→
Prop
)
:
(
∀
x
,
SetUnfold
(
x
∈
X
)
(
P
x
))
→
SetUnfold
(
∅
=
X
)
(
∀
x
,
¬
P
x
)
|
5
.
(
∀
x
,
SetUnfold
ElemOf
x
X
(
P
x
))
→
SetUnfold
(
∅
=
X
)
(
∀
x
,
¬
P
x
)
|
5
.
Proof
.
constructor
.
unfold_leibniz
.
by
apply
set_unfold_equiv_empty_l
.
Qed
.
Proof
.
constructor
.
unfold_leibniz
.
by
apply
set_unfold_equiv_empty_l
.
Qed
.
Global
Instance
set_unfold_equiv_empty_r_L
(
P
:
A
→
Prop
)
X
:
Global
Instance
set_unfold_equiv_empty_r_L
(
P
:
A
→
Prop
)
X
:
(
∀
x
,
SetUnfold
(
x
∈
X
)
(
P
x
))
→
SetUnfold
(
X
=
∅
)
(
∀
x
,
¬
P
x
)
|
5
.
(
∀
x
,
SetUnfold
ElemOf
x
X
(
P
x
))
→
SetUnfold
(
X
=
∅
)
(
∀
x
,
¬
P
x
)
|
5
.
Proof
.
constructor
.
unfold_leibniz
.
by
apply
set_unfold_equiv_empty_r
.
Qed
.
Proof
.
constructor
.
unfold_leibniz
.
by
apply
set_unfold_equiv_empty_r
.
Qed
.
Global
Instance
set_unfold_equiv_L
(
P
Q
:
A
→
Prop
)
X
Y
:
Global
Instance
set_unfold_equiv_L
(
P
Q
:
A
→
Prop
)
X
Y
:
(
∀
x
,
SetUnfold
(
x
∈
X
)
(
P
x
))
→
(
∀
x
,
SetUnfold
(
x
∈
Y
)
(
Q
x
))
→
(
∀
x
,
SetUnfold
ElemOf
x
X
(
P
x
))
→
(
∀
x
,
SetUnfold
ElemOf
x
Y
(
Q
x
))
→
SetUnfold
(
X
=
Y
)
(
∀
x
,
P
x
↔
Q
x
)
|
10
.
SetUnfold
(
X
=
Y
)
(
∀
x
,
P
x
↔
Q
x
)
|
10
.
Proof
.
constructor
.
unfold_leibniz
.
by
apply
set_unfold_equiv
.
Qed
.
Proof
.
constructor
.
unfold_leibniz
.
by
apply
set_unfold_equiv
.
Qed
.
End
set_unfold_simple
.
End
set_unfold_simple
.
...
@@ -211,16 +227,18 @@ Section set_unfold.
...
@@ -211,16 +227,18 @@ Section set_unfold.
Implicit
Types
X
Y
:
C
.
Implicit
Types
X
Y
:
C
.
Global
Instance
set_unfold_intersection
x
X
Y
P
Q
:
Global
Instance
set_unfold_intersection
x
X
Y
P
Q
:
SetUnfold
(
x
∈
X
)
P
→
SetUnfold
(
x
∈
Y
)
Q
→
SetUnfold
(
x
∈
X
∩
Y
)
(
P
∧
Q
)
.
SetUnfoldElemOf
x
X
P
→
SetUnfoldElemOf
x
Y
Q
→
SetUnfoldElemOf
x
(
X
∩
Y
)
(
P
∧
Q
)
.
Proof
.
Proof
.
intros
??;
constructor
.
rewrite
elem_of_intersection
.
intros
??;
constructor
.
rewrite
elem_of_intersection
.
by
rewrite
(
set_unfold
(
x
∈
X
)
P
),
(
set_unfold
(
x
∈
Y
)
Q
)
.
by
rewrite
(
set_unfold
_elem_of
x
X
P
),
(
set_unfold
_elem_of
x
Y
Q
)
.
Qed
.
Qed
.
Global
Instance
set_unfold_difference
x
X
Y
P
Q
:
Global
Instance
set_unfold_difference
x
X
Y
P
Q
:
SetUnfold
(
x
∈
X
)
P
→
SetUnfold
(
x
∈
Y
)
Q
→
SetUnfold
(
x
∈
X
∖
Y
)
(
P
∧
¬
Q
)
.
SetUnfoldElemOf
x
X
P
→
SetUnfoldElemOf
x
Y
Q
→
SetUnfoldElemOf
x
(
X
∖
Y
)
(
P
∧
¬
Q
)
.
Proof
.
Proof
.
intros
??;
constructor
.
rewrite
elem_of_difference
.
intros
??;
constructor
.
rewrite
elem_of_difference
.
by
rewrite
(
set_unfold
(
x
∈
X
)
P
),
(
set_unfold
(
x
∈
Y
)
Q
)
.
by
rewrite
(
set_unfold
_elem_of
x
X
P
),
(
set_unfold
_elem_of
x
Y
Q
)
.
Qed
.
Qed
.
End
set_unfold
.
End
set_unfold
.
...
@@ -228,18 +246,19 @@ Section set_unfold_monad.
...
@@ -228,18 +246,19 @@ Section set_unfold_monad.
Context
`{
MonadSet
M
}
.
Context
`{
MonadSet
M
}
.
Global
Instance
set_unfold_ret
{
A
}
(
x
y
:
A
)
:
Global
Instance
set_unfold_ret
{
A
}
(
x
y
:
A
)
:
SetUnfold
(
x
∈
mret
(
M
:=
M
)
y
)
(
x
=
y
)
.
SetUnfold
ElemOf
x
(
mret
(
M
:=
M
)
y
)
(
x
=
y
)
.
Proof
.
constructor
;
apply
elem_of_ret
.
Qed
.
Proof
.
constructor
;
apply
elem_of_ret
.
Qed
.
Global
Instance
set_unfold_bind
{
A
B
}
(
f
:
A
→
M
B
)
X
(
P
Q
:
A
→
Prop
)
:
Global
Instance
set_unfold_bind
{
A
B
}
(
f
:
A
→
M
B
)
X
(
P
Q
:
A
→
Prop
)
:
(
∀
y
,
SetUnfold
(
y
∈
X
)
(
P
y
))
→
(
∀
y
,
SetUnfold
(
x
∈
f
y
)
(
Q
y
))
→
(
∀
y
,
SetUnfold
ElemOf
y
X
(
P
y
))
→
(
∀
y
,
SetUnfold
ElemOf
x
(
f
y
)
(
Q
y
))
→
SetUnfold
(
x
∈
X
≫=
f
)
(
∃
y
,
Q
y
∧
P
y
)
.
SetUnfold
ElemOf
x
(
X
≫=
f
)
(
∃
y
,
Q
y
∧
P
y
)
.
Proof
.
constructor
.
rewrite
elem_of_bind
;
naive_solver
.
Qed
.
Proof
.
constructor
.
rewrite
elem_of_bind
;
naive_solver
.
Qed
.
Global
Instance
set_unfold_fmap
{
A
B
}
(
f
:
A
→
B
)
(
X
:
M
A
)
(
P
:
A
→
Prop
)
:
Global
Instance
set_unfold_fmap
{
A
B
}
(
f
:
A
→
B
)
(
X
:
M
A
)
(
P
:
A
→
Prop
)
:
(
∀
y
,
SetUnfold
(
y
∈
X
)
(
P
y
))
→
(
∀
y
,
SetUnfold
ElemOf
y
X
(
P
y
))
→
SetUnfold
(
x
∈
f
<$>
X
)
(
∃
y
,
x
=
f
y
∧
P
y
)
.
SetUnfold
ElemOf
x
(
f
<$>
X
)
(
∃
y
,
x
=
f
y
∧
P
y
)
.
Proof
.
constructor
.
rewrite
elem_of_fmap
;
naive_solver
.
Qed
.
Proof
.
constructor
.
rewrite
elem_of_fmap
;
naive_solver
.
Qed
.
Global
Instance
set_unfold_join
{
A
}
(
X
:
M
(
M
A
))
(
P
:
M
A
→
Prop
)
:
Global
Instance
set_unfold_join
{
A
}
(
X
:
M
(
M
A
))
(
P
:
M
A
→
Prop
)
:
(
∀
Y
,
SetUnfold
(
Y
∈
X
)
(
P
Y
))
→
SetUnfold
(
x
∈
mjoin
X
)
(
∃
Y
,
x
∈
Y
∧
P
Y
)
.
(
∀
Y
,
SetUnfoldElemOf
Y
X
(
P
Y
))
→
SetUnfoldElemOf
x
(
mjoin
X
)
(
∃
Y
,
x
∈
Y
∧
P
Y
)
.
Proof
.
constructor
.
rewrite
elem_of_join
;
naive_solver
.
Qed
.
Proof
.
constructor
.
rewrite
elem_of_join
;
naive_solver
.
Qed
.
End
set_unfold_monad
.
End
set_unfold_monad
.
...
@@ -248,19 +267,20 @@ Section set_unfold_list.
...
@@ -248,19 +267,20 @@ Section set_unfold_list.
Implicit
Types
x
:
A
.
Implicit
Types
x
:
A
.
Implicit
Types
l
:
list
A
.
Implicit
Types
l
:
list
A
.
Global
Instance
set_unfold_nil
x
:
SetUnfold
(
x
∈
[]
)
False
.
Global
Instance
set_unfold_nil
x
:
SetUnfold
ElemOf
x
[]
False
.
Proof
.
constructor
;
apply
elem_of_nil
.
Qed
.
Proof
.
constructor
;
apply
elem_of_nil
.
Qed
.
Global
Instance
set_unfold_cons
x
y
l
P
:
Global
Instance
set_unfold_cons
x
y
l
P
:
SetUnfold
(
x
∈
l
)
P
→
SetUnfold
(
x
∈
y
::
l
)
(
x
=
y
∨
P
)
.
SetUnfold
ElemOf
x
l
P
→
SetUnfold
ElemOf
x
(
y
::
l
)
(
x
=
y
∨
P
)
.
Proof
.
constructor
.
by
rewrite
elem_of_cons
,
(
set_unfold
(
x
∈
l
)
P
)
.
Qed
.
Proof
.
constructor
.
by
rewrite
elem_of_cons
,
(
set_unfold
_elem_of
x
l
P
)
.
Qed
.
Global
Instance
set_unfold_app
x
l
k
P
Q
:
Global
Instance
set_unfold_app
x
l
k
P
Q
:
SetUnfold
(
x
∈
l
)
P
→
SetUnfold
(
x
∈
k
)
Q
→
SetUnfold
(
x
∈
l
++
k
)
(
P
∨
Q
)
.
SetUnfoldElemOf
x
l
P
→
SetUnfoldElemOf
x
k
Q
→
SetUnfoldElemOf
x
(
l
++
k
)
(
P
∨
Q
)
.
Proof
.
Proof
.
intros
??;
constructor
.
intros
??;
constructor
.
by
rewrite
elem_of_app
,
(
set_unfold
(
x
∈
l
)
P
),
(
set_unfold
(
x
∈
k
)
Q
)
.
by
rewrite
elem_of_app
,
(
set_unfold
_elem_of
x
l
P
),
(
set_unfold
_elem_of
x
k
Q
)
.
Qed
.
Qed
.
Global
Instance
set_unfold_included
l
k
(
P
Q
:
A
→
Prop
)
:
Global
Instance
set_unfold_included
l
k
(
P
Q
:
A
→
Prop
)
:
(
∀
x
,
SetUnfold
(
x
∈
l
)
(
P
x
))
→
(
∀
x
,
SetUnfold
(
x
∈
k
)
(
Q
x
))
→
(
∀
x
,
SetUnfold
ElemOf
x
l
(
P
x
))
→
(
∀
x
,
SetUnfold
ElemOf
x
k
(
Q
x
))
→
SetUnfold
(
l
⊆
k
)
(
∀
x
,
P
x
→
Q
x
)
.
SetUnfold
(
l
⊆
k
)
(
∀
x
,
P
x
→
Q
x
)
.
Proof
.
Proof
.
constructor
;
unfold
subseteq
,
list_subseteq
.
constructor
;
unfold
subseteq
,
list_subseteq
.
...
@@ -768,10 +788,10 @@ Section option_and_list_to_set.
...
@@ -768,10 +788,10 @@ Section option_and_list_to_set.
Proof
.
by
rewrite
elem_of_list_to_set
.
Qed
.
Proof
.
by
rewrite
elem_of_list_to_set
.
Qed
.
Global
Instance
set_unfold_option_to_set
(
mx
:
option
A
)
x
:
Global
Instance
set_unfold_option_to_set
(
mx
:
option
A
)
x
:
SetUnfold
(
x
∈
option_to_set
(
C
:=
C
)
mx
)
(
mx
=
Some
x
)
.
SetUnfold
ElemOf
x
(
option_to_set
(
C
:=
C
)
mx
)
(
mx
=
Some
x
)
.
Proof
.
constructor
;
apply
elem_of_option_to_set
.
Qed
.
Proof
.
constructor
;
apply
elem_of_option_to_set
.
Qed
.
Global
Instance
set_unfold_list_to_set
(
l
:
list
A
)
x
P
:
Global
Instance
set_unfold_list_to_set
(
l
:
list
A
)
x
P
:
SetUnfold
(
x
∈
l
)
P
→
SetUnfold
(
x
∈
list_to_set
(
C
:=
C
)
l
)
P
.
SetUnfold
ElemOf
x
l
P
→
SetUnfold
ElemOf
x
(
list_to_set
(
C
:=
C
)
l
)
P
.
Proof
.
constructor
.
by
rewrite
elem_of_list_to_set
,
(
set_unfold
(
x
∈
l
)
P
)
.
Qed
.
Proof
.
constructor
.
by
rewrite
elem_of_list_to_set
,
(
set_unfold
(
x
∈
l
)
P
)
.
Qed
.
Lemma
list_to_set_nil
:
list_to_set
[]
=@
{
C
}
∅.
Lemma
list_to_set_nil
:
list_to_set
[]
=@
{
C
}
∅.
...
@@ -812,7 +832,7 @@ Section set_monad_base.
...
@@ -812,7 +832,7 @@ Section set_monad_base.
destruct
(
decide
P
);
naive_solver
.
destruct
(
decide
P
);
naive_solver
.
Qed
.
Qed
.
Global
Instance
set_unfold_guard
`{
Decision
P
}
{
A
}
(
x
:
A
)
(
X
:
M
A
)
Q
:
Global
Instance
set_unfold_guard
`{
Decision
P
}
{
A
}
(
x
:
A
)
(
X
:
M
A
)
Q
:
SetUnfold
(
x
∈
X
)
Q
→
SetUnfold
(
x
∈
guard
P
;
X
)
(
P
∧
Q
)
.
SetUnfold
ElemOf
x
X
Q
→
SetUnfold
ElemOf
x
(
guard
P
;
X
)
(
P
∧
Q
)
.
Proof
.
constructor
.
by
rewrite
elem_of_guard
,
(
set_unfold
(
x
∈
X
)
Q
)
.
Qed
.
Proof
.
constructor
.
by
rewrite
elem_of_guard
,
(
set_unfold
(
x
∈
X
)
Q
)
.
Qed
.
Lemma
bind_empty
{
A
B
}
(
f
:
A
→
M
B
)
X
:
Lemma
bind_empty
{
A
B
}
(
f
:
A
→
M
B
)
X
:
X
≫=
f
≡
∅
↔
X
≡
∅
∨
∀
x
,
x
∈
X
→
f
x
≡
∅.
X
≫=
f
≡
∅
↔
X
≡
∅
∨
∀
x
,
x
∈
X
→
f
x
≡
∅.
...
@@ -1029,7 +1049,7 @@ Section set_seq.
...
@@ -1029,7 +1049,7 @@ Section set_seq.
-
rewrite
elem_of_union
,
elem_of_singleton
,
IH
.
lia
.
-
rewrite
elem_of_union
,
elem_of_singleton
,
IH
.
lia
.
Qed
.
Qed
.
Global
Instance
set_unfold_seq
start
len
:
Global
Instance
set_unfold_seq
start
len
:
SetUnfold
(
x
∈
set_seq
(
C
:=
C
)
start
len
)
(
start
≤
x
<
start
+
len
)
.
SetUnfold
ElemOf
x
(
set_seq
(
C
:=
C
)
start
len
)
(
start
≤
x
<
start
+
len
)
.
Proof
.
constructor
;
apply
elem_of_set_seq
.
Qed
.
Proof
.
constructor
;
apply
elem_of_set_seq
.
Qed
.
Lemma
set_seq_plus_disjoint
start
len1
len2
:
Lemma
set_seq_plus_disjoint
start
len1
len2
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment