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
ef14edb5
Commit
ef14edb5
authored
8 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
Some general option_Forall2 properties.
parent
2744cd18
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theories/option.v
+22
-12
22 additions, 12 deletions
theories/option.v
with
22 additions
and
12 deletions
theories/option.v
+
22
−
12
View file @
ef14edb5
...
...
@@ -80,9 +80,9 @@ Lemma not_eq_None_Some {A} (mx : option A) : mx ≠ None ↔ is_Some mx.
Proof
.
rewrite
eq_None_not_Some
;
apply
dec_stable
;
tauto
.
Qed
.
(** Lifting a relation point-wise to option *)
Inductive
option_Forall2
{
A
B
}
(
P
:
A
→
B
→
Prop
)
:
option
A
→
option
B
→
Prop
:=
|
Some_Forall2
x
y
:
P
x
y
→
option_Forall2
P
(
Some
x
)
(
Some
y
)
|
None_Forall2
:
option_Forall2
P
None
None
.
Inductive
option_Forall2
{
A
B
}
(
R
:
A
→
B
→
Prop
)
:
option
A
→
option
B
→
Prop
:=
|
Some_Forall2
x
y
:
R
x
y
→
option_Forall2
R
(
Some
x
)
(
Some
y
)
|
None_Forall2
:
option_Forall2
R
None
None
.
Definition
option_relation
{
A
B
}
(
R
:
A
→
B
→
Prop
)
(
P
:
A
→
Prop
)
(
Q
:
B
→
Prop
)
(
mx
:
option
A
)
(
my
:
option
B
)
:
Prop
:=
match
mx
,
my
with
...
...
@@ -92,22 +92,30 @@ Definition option_relation {A B} (R: A → B → Prop) (P: A → Prop) (Q: B →
|
None
,
None
=>
True
end
.
Section
Forall2
.
Context
{
A
}
(
R
:
relation
A
)
.
Global
Instance
option_Forall2_refl
:
Reflexive
R
→
Reflexive
(
option_Forall2
R
)
.
Proof
.
intros
?
[?|];
by
constructor
.
Qed
.
Global
Instance
option_Forall2_sym
:
Symmetric
R
→
Symmetric
(
option_Forall2
R
)
.
Proof
.
destruct
2
;
by
constructor
.
Qed
.
Global
Instance
option_Forall2_trans
:
Transitive
R
→
Transitive
(
option_Forall2
R
)
.
Proof
.
destruct
2
;
inversion_clear
1
;
constructor
;
etrans
;
eauto
.
Qed
.
Global
Instance
option_Forall2_equiv
:
Equivalence
R
→
Equivalence
(
option_Forall2
R
)
.
Proof
.
destruct
1
;
split
;
apply
_
.
Qed
.
End
Forall2
.
(** Setoids *)
Instance
option_equiv
`{
Equiv
A
}
:
Equiv
(
option
A
)
:=
option_Forall2
(
≡
)
.
Section
setoids
.
Context
`{
Equiv
A
}
`{
!
Equivalence
((
≡
)
:
relation
A
)}
.
Global
Instance
option_equiv
:
Equiv
(
option
A
)
:=
option_Forall2
(
≡
)
.
Lemma
equiv_option_Forall2
mx
my
:
mx
≡
my
↔
option_Forall2
(
≡
)
mx
my
.
Proof
.
split
;
destruct
1
;
constructor
;
auto
.
Qed
.
Proof
.
done
.
Qed
.
Global
Instance
option_equivalence
:
Equivalence
((
≡
)
:
relation
(
option
A
))
.
Proof
.
split
.
-
by
intros
[];
constructor
.
-
by
destruct
1
;
constructor
.
-
destruct
1
;
inversion
1
;
constructor
;
etrans
;
eauto
.
Qed
.
Proof
.
apply
_
.
Qed
.
Global
Instance
Some_proper
:
Proper
((
≡
)
==>
(
≡
))
(
@
Some
A
)
.
Proof
.
by
constructor
.
Qed
.
Global
Instance
option_leibniz
`{
!
LeibnizEquiv
A
}
:
LeibnizEquiv
(
option
A
)
.
...
...
@@ -129,6 +137,8 @@ Section setoids.
Proof
.
by
destruct
2
.
Qed
.
End
setoids
.
Typeclasses
Opaque
option_equiv
.
(** Equality on [option] is decidable. *)
Instance
option_eq_None_dec
{
A
}
(
mx
:
option
A
)
:
Decision
(
mx
=
None
)
:=
match
mx
with
Some
_
=>
right
(
Some_ne_None
_)
|
None
=>
left
eq_refl
end
.
...
...
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