Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Iris
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
Terraform modules
Monitor
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
Simcha van Collem
Iris
Commits
2717af5d
Commit
2717af5d
authored
9 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
Clean up algebra/option.
Improve names, simplify definition of dist.
parent
908be24e
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
algebra/option.v
+27
-17
27 additions, 17 deletions
algebra/option.v
with
27 additions
and
17 deletions
algebra/option.v
+
27
−
17
View file @
2717af5d
...
@@ -4,40 +4,50 @@ From iris.algebra Require Import upred.
...
@@ -4,40 +4,50 @@ From iris.algebra Require Import upred.
(* COFE *)
(* COFE *)
Section
cofe
.
Section
cofe
.
Context
{
A
:
cofeT
}
.
Context
{
A
:
cofeT
}
.
Inductive
option_dist
:
Dist
(
option
A
)
:=
|
Some_dist
n
x
y
:
x
≡
{
n
}
≡
y
→
Some
x
≡
{
n
}
≡
Some
y
Inductive
option_dist'
(
n
:
nat
)
:
relation
(
option
A
)
:=
|
None_dist
n
:
None
≡
{
n
}
≡
None
.
|
Some_dist
x
y
:
x
≡
{
n
}
≡
y
→
option_dist'
n
(
Some
x
)
(
Some
y
)
Existing
Instance
option_dist
.
|
None_dist
:
option_dist'
n
None
None
.
Instance
option_dist
:
Dist
(
option
A
)
:=
option_dist'
.
Lemma
dist_option_Forall2
n
mx
my
:
mx
≡
{
n
}
≡
my
↔
option_Forall2
(
dist
n
)
mx
my
.
Proof
.
split
;
destruct
1
;
constructor
;
auto
.
Qed
.
Program
Definition
option_chain
(
c
:
chain
(
option
A
))
(
x
:
A
)
:
chain
A
:=
Program
Definition
option_chain
(
c
:
chain
(
option
A
))
(
x
:
A
)
:
chain
A
:=
{|
chain_car
n
:=
from_option
x
(
c
n
)
|}
.
{|
chain_car
n
:=
from_option
x
(
c
n
)
|}
.
Next
Obligation
.
intros
c
x
n
i
?;
simpl
.
by
destruct
(
chain_cauchy
c
n
i
)
.
Qed
.
Next
Obligation
.
intros
c
x
n
i
?;
simpl
.
by
destruct
(
chain_cauchy
c
n
i
)
.
Qed
.
Instance
option_compl
:
Compl
(
option
A
)
:=
λ
c
,
Instance
option_compl
:
Compl
(
option
A
)
:=
λ
c
,
match
c
0
with
Some
x
=>
Some
(
compl
(
option_chain
c
x
))
|
None
=>
None
end
.
match
c
0
with
Some
x
=>
Some
(
compl
(
option_chain
c
x
))
|
None
=>
None
end
.
Definition
option_cofe_mixin
:
CofeMixin
(
option
A
)
.
Definition
option_cofe_mixin
:
CofeMixin
(
option
A
)
.
Proof
.
Proof
.
split
.
split
.
-
intros
mx
my
;
split
;
[
by
destruct
1
;
constructor
;
apply
equiv_dist
|]
.
-
intros
mx
my
;
split
;
[
by
destruct
1
;
constructor
;
apply
equiv_dist
|]
.
intros
Hxy
;
feed
inversion
(
Hxy
1
);
subst
;
constructor
;
apply
equiv_dist
.
intros
Hxy
;
destruct
(
Hxy
0
)
;
constructor
;
apply
equiv_dist
.
by
intros
n
;
feed
inversion
(
Hxy
n
)
.
by
intros
n
;
feed
inversion
(
Hxy
n
)
.
-
intros
n
;
split
.
-
intros
n
;
split
.
+
by
intros
[
x
|];
constructor
.
+
by
intros
[
x
|];
constructor
.
+
by
destruct
1
;
constructor
.
+
by
destruct
1
;
constructor
.
+
destruct
1
;
inversion_clear
1
;
constructor
;
etrans
;
eauto
.
+
destruct
1
;
inversion_clear
1
;
constructor
;
etrans
;
eauto
.
-
by
inversion_clear
1
;
constructor
;
apply
dist_S
.
-
destruct
1
;
constructor
;
by
apply
dist_S
.
-
intros
n
c
;
rewrite
/
compl
/
option_compl
.
-
intros
n
c
;
rewrite
/
compl
/
option_compl
.
feed
inversion
(
chain_cauchy
c
0
n
);
first
auto
with
lia
;
constructor
.
feed
inversion
(
chain_cauchy
c
0
n
);
first
auto
with
lia
;
constructor
.
rewrite
(
conv_compl
n
(
option_chain
c
_))
/=.
destruct
(
c
n
);
naive_solver
.
rewrite
(
conv_compl
n
(
option_chain
c
_))
/=.
destruct
(
c
n
);
naive_solver
.
Qed
.
Qed
.
Canonical
Structure
optionC
:=
CofeT
option_cofe_mixin
.
Canonical
Structure
optionC
:=
CofeT
option_cofe_mixin
.
Global
Instance
option_discrete
:
Discrete
A
→
Discrete
optionC
.
Global
Instance
option_discrete
:
Discrete
A
→
Discrete
optionC
.
Proof
.
inversion_clear
2
;
constructor
;
by
apply
(
timeless
_)
.
Qed
.
Proof
.
destruct
2
;
constructor
;
by
apply
(
timeless
_)
.
Qed
.
Global
Instance
Some_ne
:
Proper
(
dist
n
==>
dist
n
)
(
@
Some
A
)
.
Global
Instance
Some_ne
:
Proper
(
dist
n
==>
dist
n
)
(
@
Some
A
)
.
Proof
.
by
constructor
.
Qed
.
Proof
.
by
constructor
.
Qed
.
Global
Instance
is_Some_ne
n
:
Proper
(
dist
n
==>
iff
)
(
@
is_Some
A
)
.
Global
Instance
is_Some_ne
n
:
Proper
(
dist
n
==>
iff
)
(
@
is_Some
A
)
.
Proof
.
inversion_clear
1
;
split
;
eauto
.
Qed
.
Proof
.
destruct
1
;
split
;
eauto
.
Qed
.
Global
Instance
Some_dist_inj
:
Inj
(
dist
n
)
(
dist
n
)
(
@
Some
A
)
.
Global
Instance
Some_dist_inj
:
Inj
(
dist
n
)
(
dist
n
)
(
@
Some
A
)
.
Proof
.
by
inversion_clear
1
.
Qed
.
Proof
.
by
inversion_clear
1
.
Qed
.
Global
Instance
from_option_ne
n
:
Proper
(
dist
n
==>
dist
n
==>
dist
n
)
(
@
from_option
A
)
.
Proof
.
by
destruct
2
.
Qed
.
Global
Instance
None_timeless
:
Timeless
(
@
None
A
)
.
Global
Instance
None_timeless
:
Timeless
(
@
None
A
)
.
Proof
.
inversion_clear
1
;
constructor
.
Qed
.
Proof
.
inversion_clear
1
;
constructor
.
Qed
.
Global
Instance
Some_timeless
x
:
Timeless
x
→
Timeless
(
Some
x
)
.
Global
Instance
Some_timeless
x
:
Timeless
x
→
Timeless
(
Some
x
)
.
...
@@ -125,16 +135,16 @@ Global Instance option_persistent (mx : option A) :
...
@@ -125,16 +135,16 @@ Global Instance option_persistent (mx : option A) :
Proof
.
intros
.
destruct
mx
.
apply
_
.
apply
cmra_unit_persistent
.
Qed
.
Proof
.
intros
.
destruct
mx
.
apply
_
.
apply
cmra_unit_persistent
.
Qed
.
(** Internalized properties *)
(** Internalized properties *)
Lemma
option_equivI
{
M
}
(
x
y
:
option
A
)
:
Lemma
option_equivI
{
M
}
(
m
x
m
y
:
option
A
)
:
(
x
≡
y
)
⊣⊢
(
match
x
,
y
with
(
m
x
≡
m
y
)
⊣⊢
(
match
m
x
,
m
y
with
|
Some
a
,
Some
b
=>
a
≡
b
|
None
,
None
=>
True
|
_,
_
=>
False
|
Some
x
,
Some
y
=>
x
≡
y
|
None
,
None
=>
True
|
_,
_
=>
False
end
:
uPred
M
)
.
end
:
uPred
M
)
.
Proof
.
Proof
.
uPred
.
unseal
.
do
2
split
.
by
destruct
1
.
by
destruct
x
,
y
;
try
constructor
.
uPred
.
unseal
.
do
2
split
.
by
destruct
1
.
by
destruct
m
x
,
m
y
;
try
constructor
.
Qed
.
Qed
.
Lemma
option_validI
{
M
}
(
x
:
option
A
)
:
Lemma
option_validI
{
M
}
(
m
x
:
option
A
)
:
(
✓
x
)
⊣⊢
(
match
x
with
Some
a
=>
✓
a
|
None
=>
True
end
:
uPred
M
)
.
(
✓
m
x
)
⊣⊢
(
match
m
x
with
Some
x
=>
✓
x
|
None
=>
True
end
:
uPred
M
)
.
Proof
.
uPred
.
unseal
.
by
destruct
x
.
Qed
.
Proof
.
uPred
.
unseal
.
by
destruct
m
x
.
Qed
.
(** Updates *)
(** Updates *)
Lemma
option_updateP
(
P
:
A
→
Prop
)
(
Q
:
option
A
→
Prop
)
x
:
Lemma
option_updateP
(
P
:
A
→
Prop
)
(
Q
:
option
A
→
Prop
)
x
:
...
@@ -146,7 +156,7 @@ Proof.
...
@@ -146,7 +156,7 @@ Proof.
by
exists
(
Some
y'
);
split
;
[
auto
|
apply
cmra_validN_op_l
with
(
core
x
)]
.
by
exists
(
Some
y'
);
split
;
[
auto
|
apply
cmra_validN_op_l
with
(
core
x
)]
.
Qed
.
Qed
.
Lemma
option_updateP'
(
P
:
A
→
Prop
)
x
:
Lemma
option_updateP'
(
P
:
A
→
Prop
)
x
:
x
~~>:
P
→
Some
x
~~>:
λ
y
,
default
False
y
P
.
x
~~>:
P
→
Some
x
~~>:
λ
m
y
,
default
False
m
y
P
.
Proof
.
eauto
using
option_updateP
.
Qed
.
Proof
.
eauto
using
option_updateP
.
Qed
.
Lemma
option_update
x
y
:
x
~~>
y
→
Some
x
~~>
Some
y
.
Lemma
option_update
x
y
:
x
~~>
y
→
Some
x
~~>
Some
y
.
Proof
.
Proof
.
...
...
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