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
6c6ef520
Commit
6c6ef520
authored
9 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
Nice notation for mkSet.
parent
9a16f9be
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/sets.v
+17
-12
17 additions, 12 deletions
theories/sets.v
with
17 additions
and
12 deletions
theories/sets.v
+
17
−
12
View file @
6c6ef520
(* Copyright (c) 2012-2015, Robbert Krebbers. *)
(* This file is distributed under the terms of the BSD license. *)
(** This file implements sets as functions into Prop. *)
From
stdpp
Require
Export
prelude
.
From
stdpp
Require
Export
tactics
.
Record
set
(
A
:
Type
)
:
Type
:=
mkSet
{
set_car
:
A
→
Prop
}
.
Add
Printing
Constructor
set
.
Arguments
mkSet
{_}
_
.
Arguments
set_car
{_}
_
_
.
Instance
set_all
{
A
}
:
Top
(
set
A
)
:=
mkSet
(
λ
_
,
True
)
.
Instance
set_empty
{
A
}
:
Empty
(
set
A
)
:=
mkSet
(
λ
_,
False
)
.
Instance
set_singleton
{
A
}
:
Singleton
A
(
set
A
)
:=
λ
x
,
mkSet
(
x
=
)
.
Notation
"{[ x | P ]}"
:=
(
mkSet
(
λ
x
,
P
))
(
at
level
1
,
format
"{[ x | P ]}"
)
:
C_scope
.
Instance
set_elem_of
{
A
}
:
ElemOf
A
(
set
A
)
:=
λ
x
X
,
set_car
X
x
.
Instance
set_union
{
A
}
:
Union
(
set
A
)
:=
λ
X1
X2
,
mkSet
(
λ
x
,
x
∈
X1
∨
x
∈
X2
)
.
Instance
set_all
{
A
}
:
Top
(
set
A
)
:=
{[
_
|
True
]}
.
Instance
set_empty
{
A
}
:
Empty
(
set
A
)
:=
{[
_
|
False
]}
.
Instance
set_singleton
{
A
}
:
Singleton
A
(
set
A
)
:=
λ
y
,
{[
x
|
y
=
x
]}
.
Instance
set_union
{
A
}
:
Union
(
set
A
)
:=
λ
X1
X2
,
{[
x
|
x
∈
X1
∨
x
∈
X2
]}
.
Instance
set_intersection
{
A
}
:
Intersection
(
set
A
)
:=
λ
X1
X2
,
mkSet
(
λ
x
,
x
∈
X1
∧
x
∈
X2
)
.
{[
x
|
x
∈
X1
∧
x
∈
X2
]}
.
Instance
set_difference
{
A
}
:
Difference
(
set
A
)
:=
λ
X1
X2
,
mkSet
(
λ
x
,
x
∈
X1
∧
x
∉
X2
)
.
{[
x
|
x
∈
X1
∧
x
∉
X2
]}
.
Instance
set_collection
:
Collection
A
(
set
A
)
.
Proof
.
by
split
;
[
split
|
|];
repeat
intro
.
Qed
.
Proof
.
split
;
[
split
|
|];
by
repeat
intro
.
Qed
.
Lemma
mkSet_
elem_of
{
A
}
(
f
:
A
→
Prop
)
x
:
(
x
∈
mkSet
f
)
=
f
x
.
Lemma
elem_of
_mkSet
{
A
}
(
P
:
A
→
Prop
)
x
:
(
x
∈
{[
x
|
P
x
]}
)
=
P
x
.
Proof
.
done
.
Qed
.
Lemma
mkSet_
not_elem_of
{
A
}
(
f
:
A
→
Prop
)
x
:
(
x
∉
mkSet
f
)
=
(
¬
f
x
)
.
Lemma
not_elem_of
_mkSet
{
A
}
(
P
:
A
→
Prop
)
x
:
(
x
∉
{[
x
|
P
x
]}
)
=
(
¬
P
x
)
.
Proof
.
done
.
Qed
.
Instance
set_ret
:
MRet
set
:=
λ
A
(
x
:
A
),
{[
x
]}
.
Instance
set_bind
:
MBind
set
:=
λ
A
B
(
f
:
A
→
set
B
)
(
X
:
set
A
),
mkSet
(
λ
b
,
∃
a
,
b
∈
f
a
∧
a
∈
X
)
.
Instance
set_fmap
:
FMap
set
:=
λ
A
B
(
f
:
A
→
B
)
(
X
:
set
A
),
mkSet
(
λ
b
,
∃
a
,
b
=
f
a
∧
a
∈
X
)
.
{[
b
|
∃
a
,
b
=
f
a
∧
a
∈
X
]}
.
Instance
set_join
:
MJoin
set
:=
λ
A
(
XX
:
set
(
set
A
)),
mkSet
(
λ
a
,
∃
X
,
a
∈
X
∧
X
∈
XX
)
.
{[
a
|
∃
X
,
a
∈
X
∧
X
∈
XX
]}
.
Instance
set_collection_monad
:
CollectionMonad
set
.
Proof
.
by
split
;
try
apply
_
.
Qed
.
...
...
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