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
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Glen Mével
stdpp
Commits
fed72f20
Commit
fed72f20
authored
8 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
A generic filter operation on finite collections.
parent
54bdb7ad
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theories/fin_collections.v
+13
-0
13 additions, 0 deletions
theories/fin_collections.v
with
13 additions
and
0 deletions
theories/fin_collections.v
+
13
−
0
View file @
fed72f20
...
...
@@ -11,6 +11,10 @@ Instance collection_size `{Elements A C} : Size C := length ∘ elements.
Definition
collection_fold
`{
Elements
A
C
}
{
B
}
(
f
:
A
→
B
→
B
)
(
b
:
B
)
:
C
→
B
:=
foldr
f
b
∘
elements
.
Instance
collection_filter
`{
Elements
A
C
,
Empty
C
,
Singleton
A
C
,
Union
C
}
:
Filter
A
C
:=
λ
P
_
X
,
of_list
(
filter
P
(
elements
X
))
.
Section
fin_collection
.
Context
`{
FinCollection
A
C
}
.
Implicit
Types
X
Y
:
C
.
...
...
@@ -184,6 +188,7 @@ Lemma collection_fold_proper {B} (R : relation B) `{!Equivalence R}
Proper
((
≡
)
==>
R
)
(
collection_fold
f
b
:
C
→
B
)
.
Proof
.
intros
??
E
.
apply
(
foldr_permutation
R
f
b
);
auto
.
by
rewrite
E
.
Qed
.
(** * Minimal elements *)
Lemma
minimal_exists
`{
!
StrictOrder
R
,
∀
x
y
,
Decision
(
R
x
y
)}
(
X
:
C
)
:
X
≢
∅
→
∃
x
,
x
∈
X
∧
minimal
R
x
X
.
Proof
.
...
...
@@ -205,6 +210,14 @@ Lemma minimal_exists_L
X
≠
∅
→
∃
x
,
x
∈
X
∧
minimal
R
x
X
.
Proof
.
unfold_leibniz
.
apply
minimal_exists
.
Qed
.
(** * Filter *)
Lemma
elem_of_filter
(
P
:
A
→
Prop
)
`{
!∀
x
,
Decision
(
P
x
)}
X
x
:
x
∈
filter
P
X
↔
P
x
∧
x
∈
X
.
Proof
.
unfold
filter
,
collection_filter
.
by
rewrite
elem_of_of_list
,
elem_of_list_filter
,
elem_of_elements
.
Qed
.
(** * Decision procedures *)
Global
Instance
set_Forall_dec
`
(
P
:
A
→
Prop
)
`{
∀
x
,
Decision
(
P
x
)}
X
:
Decision
(
set_Forall
P
X
)
|
100
.
...
...
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