Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Iris
Iris
Commits
a9e2d8f3
Commit
a9e2d8f3
authored
Feb 02, 2017
by
Robbert Krebbers
Browse files
Another failed approach to avoid declaring other projections than the carrier as canonical.
parent
bf069d12
Changes
5
Hide whitespace changes
Inline
Side-by-side
theories/algebra/cmra.v
View file @
a9e2d8f3
...
...
@@ -35,92 +35,101 @@ Notation "x ≼{ n } y" := (includedN n x y)
Instance
:
Params
(@
includedN
)
4
.
Hint
Extern
0
(
_
≼
{
_
}
_
)
=>
reflexivity
.
Record
CMRAMixin
A
`
{
Dist
A
,
Equiv
A
,
PCore
A
,
Op
A
,
Valid
A
,
ValidN
A
}
:
=
{
Record
cmra_laws
A
`
{
Dist
A
,
Equiv
A
,
PCore
A
,
Op
A
,
Valid
A
,
ValidN
A
}
:
=
{
(* setoids *)
mixin
_cmra_op_ne
(
x
:
A
)
:
NonExpansive
(
op
x
)
;
mixin
_cmra_pcore_ne
n
x
y
cx
:
law
_cmra_op_ne
(
x
:
A
)
:
NonExpansive
(
op
x
)
;
law
_cmra_pcore_ne
n
x
y
cx
:
x
≡
{
n
}
≡
y
→
pcore
x
=
Some
cx
→
∃
cy
,
pcore
y
=
Some
cy
∧
cx
≡
{
n
}
≡
cy
;
mixin
_cmra_validN_ne
n
:
Proper
(
dist
n
==>
impl
)
(
validN
n
)
;
law
_cmra_validN_ne
n
:
Proper
(
dist
n
==>
impl
)
(
validN
n
)
;
(* valid *)
mixin
_cmra_valid_validN
x
:
✓
x
↔
∀
n
,
✓
{
n
}
x
;
mixin
_cmra_validN_S
n
x
:
✓
{
S
n
}
x
→
✓
{
n
}
x
;
law
_cmra_valid_validN
x
:
✓
x
↔
∀
n
,
✓
{
n
}
x
;
law
_cmra_validN_S
n
x
:
✓
{
S
n
}
x
→
✓
{
n
}
x
;
(* monoid *)
mixin
_cmra_assoc
:
Assoc
(
≡
)
(
⋅
)
;
mixin
_cmra_comm
:
Comm
(
≡
)
(
⋅
)
;
mixin
_cmra_pcore_l
x
cx
:
pcore
x
=
Some
cx
→
cx
⋅
x
≡
x
;
mixin
_cmra_pcore_idemp
x
cx
:
pcore
x
=
Some
cx
→
pcore
cx
≡
Some
cx
;
mixin
_cmra_pcore_mono
x
y
cx
:
law
_cmra_assoc
:
Assoc
(
≡
)
(
⋅
)
;
law
_cmra_comm
:
Comm
(
≡
)
(
⋅
)
;
law
_cmra_pcore_l
x
cx
:
pcore
x
=
Some
cx
→
cx
⋅
x
≡
x
;
law
_cmra_pcore_idemp
x
cx
:
pcore
x
=
Some
cx
→
pcore
cx
≡
Some
cx
;
law
_cmra_pcore_mono
x
y
cx
:
x
≼
y
→
pcore
x
=
Some
cx
→
∃
cy
,
pcore
y
=
Some
cy
∧
cx
≼
cy
;
mixin
_cmra_validN_op_l
n
x
y
:
✓
{
n
}
(
x
⋅
y
)
→
✓
{
n
}
x
;
mixin
_cmra_extend
n
x
y1
y2
:
law
_cmra_validN_op_l
n
x
y
:
✓
{
n
}
(
x
⋅
y
)
→
✓
{
n
}
x
;
law
_cmra_extend
n
x
y1
y2
:
✓
{
n
}
x
→
x
≡
{
n
}
≡
y1
⋅
y2
→
∃
z1
z2
,
x
≡
z1
⋅
z2
∧
z1
≡
{
n
}
≡
y1
∧
z2
≡
{
n
}
≡
y2
}.
(** Bundeled version *)
Structure
cmraT
:
=
CMRAT'
{
cmra_car
:
>
Type
;
cmra_equiv
:
Equiv
cmra_car
;
cmra_dist
:
Dist
cmra_car
;
cmra_pcore
:
PCore
cmra_car
;
cmra_op
:
Op
cmra_car
;
cmra_valid
:
Valid
cmra_car
;
cmra_validN
:
ValidN
cmra_car
;
cmra_ofe_mixin
:
OfeMixin
cmra_car
;
cmra_mixin
:
CMRAMixin
cmra_car
;
_
:
Type
Record
cmra_mixin
(
A
:
Type
)
:
=
CMRAMixin
{
cmra_mixin_equiv
:
Equiv
A
;
cmra_mixin_dist
:
Dist
A
;
cmra_mixin_pcore
:
PCore
A
;
cmra_mixin_op
:
Op
A
;
cmra_mixin_valid
:
Valid
A
;
cmra_mixin_validN
:
ValidN
A
;
cmra_mixin_ofe_laws_of
:
ofe_laws
A
;
cmra_mixin_laws_of
:
cmra_laws
A
;
}.
Arguments
CMRAT'
_
{
_
_
_
_
_
_
}
_
_
_
.
Notation
CMRAT
A
m
m'
:
=
(
CMRAT'
A
m
m'
A
).
Arguments
CMRAMixin
{
_
_
_
_
_
_
_
}
_
_
.
(** Bundeled version *)
Structure
cmraT
:
=
CMRAT'
{
cmra_car
:
>
Type
;
_
:
cmra_mixin
cmra_car
;
_
:
Type
}.
Notation
CMRAT
A
m
:
=
(
CMRAT'
A
m
A
).
Add
Printing
Constructor
cmraT
.
Arguments
cmra_car
:
simpl
never
.
Arguments
cmra_equiv
:
simpl
never
.
Arguments
cmra_dist
:
simpl
never
.
Definition
cmra_mixin_of
(
A
:
cmraT
)
:
cmra_mixin
A
:
=
let
'
CMRAT'
_
m
_
:
=
A
in
m
.
Arguments
cmra_mixin_of
:
simpl
never
.
Definition
cmra_pcore
{
A
:
cmraT
}
:
PCore
A
:
=
cmra_mixin_pcore
_
(
cmra_mixin_of
A
).
Arguments
cmra_pcore
:
simpl
never
.
Arguments
cmra_op
:
simpl
never
.
Arguments
cmra_valid
:
simpl
never
.
Arguments
cmra_validN
:
simpl
never
.
Arguments
cmra_ofe_mixin
:
simpl
never
.
Arguments
cmra_mixin
:
simpl
never
.
Add
Printing
Constructor
cmraT
.
Hint
Extern
0
(
PCore
_
)
=>
eapply
(@
cmra_pcore
_
)
:
typeclass_instances
.
Definition
cmra_op
{
A
:
cmraT
}
:
Op
A
:
=
cmra_mixin_op
_
(
cmra_mixin_of
A
).
Arguments
cmra_op
:
simpl
never
.
Hint
Extern
0
(
Op
_
)
=>
eapply
(@
cmra_op
_
)
:
typeclass_instances
.
Definition
cmra_valid
{
A
:
cmraT
}
:
Valid
A
:
=
cmra_mixin_valid
_
(
cmra_mixin_of
A
).
Arguments
cmra_valid
:
simpl
never
.
Hint
Extern
0
(
Valid
_
)
=>
eapply
(@
cmra_valid
_
)
:
typeclass_instances
.
Definition
cmra_validN
{
A
:
cmraT
}
:
ValidN
A
:
=
cmra_mixin_validN
_
(
cmra_mixin_of
A
).
Arguments
cmra_validN
:
simpl
never
.
Hint
Extern
0
(
ValidN
_
)
=>
eapply
(@
cmra_validN
_
)
:
typeclass_instances
.
Coercion
cmra_ofeC
(
A
:
cmraT
)
:
ofeT
:
=
OfeT
A
(
cmra_ofe_mixin
A
).
Definition
cmra_ofe_mixin_of
{
A
}
(
m
:
cmra_mixin
A
)
:
ofe_mixin
A
:
=
OfeMixin
(
cmra_mixin_ofe_laws_of
_
m
).
Coercion
cmra_ofeC
(
A
:
cmraT
)
:
ofeT
:
=
OfeT
A
(
cmra_ofe_mixin_of
(
cmra_mixin_of
A
)).
Canonical
Structure
cmra_ofeC
.
(** Lifting properties from the mixin *)
Section
cmra_mixin
.
Context
{
A
:
cmraT
}.
Implicit
Types
x
y
:
A
.
Local
Coercion
cmra_mixin_of
:
cmraT
>->
cmra_mixin
.
Global
Instance
cmra_op_ne
(
x
:
A
)
:
NonExpansive
(
op
x
).
Proof
.
apply
(
mixin
_cmra_op_ne
_
(
cmra_mixin
A
)).
Qed
.
Proof
.
apply
(
law
_cmra_op_ne
_
(
cmra_mixin
_laws_of
_
A
)).
Qed
.
Lemma
cmra_pcore_ne
n
x
y
cx
:
x
≡
{
n
}
≡
y
→
pcore
x
=
Some
cx
→
∃
cy
,
pcore
y
=
Some
cy
∧
cx
≡
{
n
}
≡
cy
.
Proof
.
apply
(
mixin
_cmra_pcore_ne
_
(
cmra_mixin
A
)).
Qed
.
Proof
.
apply
(
law
_cmra_pcore_ne
_
(
cmra_mixin
_laws_of
_
A
)).
Qed
.
Global
Instance
cmra_validN_ne
n
:
Proper
(
dist
n
==>
impl
)
(@
validN
A
_
n
).
Proof
.
apply
(
mixin
_cmra_validN_ne
_
(
cmra_mixin
A
)).
Qed
.
Proof
.
apply
(
law
_cmra_validN_ne
_
(
cmra_mixin
_laws_of
_
A
)).
Qed
.
Lemma
cmra_valid_validN
x
:
✓
x
↔
∀
n
,
✓
{
n
}
x
.
Proof
.
apply
(
mixin
_cmra_valid_validN
_
(
cmra_mixin
A
)).
Qed
.
Proof
.
apply
(
law
_cmra_valid_validN
_
(
cmra_mixin
_laws_of
_
A
)).
Qed
.
Lemma
cmra_validN_S
n
x
:
✓
{
S
n
}
x
→
✓
{
n
}
x
.
Proof
.
apply
(
mixin
_cmra_validN_S
_
(
cmra_mixin
A
)).
Qed
.
Proof
.
apply
(
law
_cmra_validN_S
_
(
cmra_mixin
_laws_of
_
A
)).
Qed
.
Global
Instance
cmra_assoc
:
Assoc
(
≡
)
(@
op
A
_
).
Proof
.
apply
(
mixin
_cmra_assoc
_
(
cmra_mixin
A
)).
Qed
.
Proof
.
apply
(
law
_cmra_assoc
_
(
cmra_mixin
_laws_of
_
A
)).
Qed
.
Global
Instance
cmra_comm
:
Comm
(
≡
)
(@
op
A
_
).
Proof
.
apply
(
mixin
_cmra_comm
_
(
cmra_mixin
A
)).
Qed
.
Proof
.
apply
(
law
_cmra_comm
_
(
cmra_mixin
_laws_of
_
A
)).
Qed
.
Lemma
cmra_pcore_l
x
cx
:
pcore
x
=
Some
cx
→
cx
⋅
x
≡
x
.
Proof
.
apply
(
mixin
_cmra_pcore_l
_
(
cmra_mixin
A
)).
Qed
.
Proof
.
apply
(
law
_cmra_pcore_l
_
(
cmra_mixin
_laws_of
_
A
)).
Qed
.
Lemma
cmra_pcore_idemp
x
cx
:
pcore
x
=
Some
cx
→
pcore
cx
≡
Some
cx
.
Proof
.
apply
(
mixin
_cmra_pcore_idemp
_
(
cmra_mixin
A
)).
Qed
.
Proof
.
apply
(
law
_cmra_pcore_idemp
_
(
cmra_mixin
_laws_of
_
A
)).
Qed
.
Lemma
cmra_pcore_mono
x
y
cx
:
x
≼
y
→
pcore
x
=
Some
cx
→
∃
cy
,
pcore
y
=
Some
cy
∧
cx
≼
cy
.
Proof
.
apply
(
mixin
_cmra_pcore_mono
_
(
cmra_mixin
A
)).
Qed
.
Proof
.
apply
(
law
_cmra_pcore_mono
_
(
cmra_mixin
_laws_of
_
A
)).
Qed
.
Lemma
cmra_validN_op_l
n
x
y
:
✓
{
n
}
(
x
⋅
y
)
→
✓
{
n
}
x
.
Proof
.
apply
(
mixin
_cmra_validN_op_l
_
(
cmra_mixin
A
)).
Qed
.
Proof
.
apply
(
law
_cmra_validN_op_l
_
(
cmra_mixin
_laws_of
_
A
)).
Qed
.
Lemma
cmra_extend
n
x
y1
y2
:
✓
{
n
}
x
→
x
≡
{
n
}
≡
y1
⋅
y2
→
∃
z1
z2
,
x
≡
z1
⋅
z2
∧
z1
≡
{
n
}
≡
y1
∧
z2
≡
{
n
}
≡
y2
.
Proof
.
apply
(
mixin
_cmra_extend
_
(
cmra_mixin
A
)).
Qed
.
Proof
.
apply
(
law
_cmra_extend
_
(
cmra_mixin
_laws_of
_
A
)).
Qed
.
End
cmra_mixin
.
Definition
opM
{
A
:
cmraT
}
(
x
:
A
)
(
my
:
option
A
)
:
=
...
...
@@ -163,56 +172,66 @@ Arguments core' _ _ _ /.
(** * CMRAs with a unit element *)
(** We use the notation ∅ because for most instances (maps, sets, etc) the
`empty' element is the unit. *)
Record
UCMRAMixin
A
`
{
Dist
A
,
Equiv
A
,
PCore
A
,
Op
A
,
Valid
A
,
Empty
A
}
:
=
{
Record
ucmra_laws
A
`
{
Dist
A
,
Equiv
A
,
PCore
A
,
Op
A
,
Valid
A
,
Empty
A
}
:
=
{
mixin_ucmra_unit_valid
:
✓
∅
;
mixin_ucmra_unit_left_id
:
LeftId
(
≡
)
∅
(
⋅
)
;
mixin_ucmra_pcore_unit
:
pcore
∅
≡
Some
∅
}.
Structure
ucmraT
:
=
UCMRAT'
{
ucmra_car
:
>
Type
;
ucmra_equiv
:
Equiv
ucmra_car
;
ucmra_dist
:
Dist
ucmra_car
;
ucmra_pcore
:
PCore
ucmra_car
;
ucmra_op
:
Op
ucmra_car
;
ucmra_valid
:
Valid
ucmra_car
;
ucmra_validN
:
ValidN
ucmra_car
;
ucmra_empty
:
Empty
ucmra_car
;
ucmra_ofe_mixin
:
OfeMixin
ucmra_car
;
ucmra_cmra_mixin
:
CMRAMixin
ucmra_car
;
ucmra_mixin
:
UCMRAMixin
ucmra_car
;
_
:
Type
;
Record
ucmra_mixin
(
A
:
Type
)
:
=
UCMRAMixin
{
ucmra_mixin_equiv
:
Equiv
A
;
ucmra_mixin_dist
:
Dist
A
;
ucmra_mixin_pcore
:
PCore
A
;
ucmra_mixin_op
:
Op
A
;
ucmra_mixin_valid
:
Valid
A
;
ucmra_mixin_validN
:
ValidN
A
;
ucmra_mixin_empty
:
Empty
A
;
ucmra_mixin_ofe_laws_of
:
ofe_laws
A
;
ucmra_mixin_cmra_laws_of
:
cmra_laws
A
;
ucmra_mixin_laws_of
:
ucmra_laws
A
;
}.
Arguments
UCMRAT'
_
{
_
_
_
_
_
_
_
}
_
_
_
_
.
Notation
UCMRAT
A
m
m'
m''
:
=
(
UCMRAT'
A
m
m'
m''
A
).
Arguments
ucmra_car
:
simpl
never
.
Arguments
ucmra_equiv
:
simpl
never
.
Arguments
ucmra_dist
:
simpl
never
.
Arguments
ucmra_pcore
:
simpl
never
.
Arguments
ucmra_op
:
simpl
never
.
Arguments
ucmra_valid
:
simpl
never
.
Arguments
ucmra_validN
:
simpl
never
.
Arguments
ucmra_ofe_mixin
:
simpl
never
.
Arguments
ucmra_cmra_mixin
:
simpl
never
.
Arguments
ucmra_mixin
:
simpl
never
.
Arguments
UCMRAMixin
{
_
_
_
_
_
_
_
_
}
_
_
_
.
Structure
ucmraT
:
=
UCMRAT'
{
ucmra_car
:
>
Type
;
_
:
ucmra_mixin
ucmra_car
;
_
:
Type
}.
Notation
UCMRAT
A
m
:
=
(
UCMRAT'
A
m
A
).
Add
Printing
Constructor
ucmraT
.
Arguments
ucmra_car
:
simpl
never
.
Definition
ucmra_mixin_of
(
A
:
ucmraT
)
:
ucmra_mixin
A
:
=
let
'
UCMRAT'
_
m
_
:
=
A
in
m
.
Arguments
ucmra_mixin_of
:
simpl
never
.
Definition
ucmra_empty
{
A
:
ucmraT
}
:
Empty
A
:
=
ucmra_mixin_empty
_
(
ucmra_mixin_of
A
).
Arguments
ucmra_empty
:
simpl
never
.
Hint
Extern
0
(
Empty
_
)
=>
eapply
(@
ucmra_empty
_
)
:
typeclass_instances
.
Coercion
ucmra_ofeC
(
A
:
ucmraT
)
:
ofeT
:
=
OfeT
A
(
ucmra_ofe_mixin
A
).
Definition
ucmra_ofe_mixin_of
{
A
}
(
m
:
ucmra_mixin
A
)
:
ofe_mixin
A
:
=
OfeMixin
(
ucmra_mixin_ofe_laws_of
_
m
).
Definition
ucmra_cmra_mixin_of
{
A
}
(
m
:
ucmra_mixin
A
)
:
cmra_mixin
A
:
=
CMRAMixin
(
ucmra_mixin_ofe_laws_of
_
m
)
(
ucmra_mixin_cmra_laws_of
_
m
).
Arguments
ucmra_ofe_mixin_of
:
simpl
never
.
Arguments
ucmra_cmra_mixin_of
:
simpl
never
.
Coercion
ucmra_ofeC
(
A
:
ucmraT
)
:
ofeT
:
=
OfeT
A
(
ucmra_ofe_mixin_of
(
ucmra_mixin_of
A
)).
Canonical
Structure
ucmra_ofeC
.
Coercion
ucmra_cmraR
(
A
:
ucmraT
)
:
cmraT
:
=
CMRAT
A
(
ucmra_
ofe
_mixin
A
)
(
ucmra_
cmra_
mixin
A
).
CMRAT
A
(
ucmra_
cmra
_mixin
_of
(
ucmra_mixin
_of
A
)
)
.
Canonical
Structure
ucmra_cmraR
.
(** Lifting properties from the mixin *)
Section
ucmra_mixin
.
Context
{
A
:
ucmraT
}.
Implicit
Types
x
y
:
A
.
Local
Coercion
ucmra_mixin_of
:
ucmraT
>->
ucmra_mixin
.
Lemma
ucmra_unit_valid
:
✓
(
∅
:
A
).
Proof
.
apply
(
mixin_ucmra_unit_valid
_
(
ucmra_mixin
A
)).
Qed
.
Proof
.
apply
(
mixin_ucmra_unit_valid
_
(
ucmra_mixin
_laws_of
_
A
)).
Qed
.
Global
Instance
ucmra_unit_left_id
:
LeftId
(
≡
)
∅
(@
op
A
_
).
Proof
.
apply
(
mixin_ucmra_unit_left_id
_
(
ucmra_mixin
A
)).
Qed
.
Proof
.
apply
(
mixin_ucmra_unit_left_id
_
(
ucmra_mixin
_laws_of
_
A
)).
Qed
.
Lemma
ucmra_pcore_unit
:
pcore
(
∅
:
A
)
≡
Some
∅
.
Proof
.
apply
(
mixin_ucmra_pcore_unit
_
(
ucmra_mixin
A
)).
Qed
.
Proof
.
apply
(
mixin_ucmra_pcore_unit
_
(
ucmra_mixin
_laws_of
_
A
)).
Qed
.
End
ucmra_mixin
.
(** * Discrete CMRAs *)
...
...
@@ -698,7 +717,7 @@ Section cmra_total.
Context
(
extend
:
∀
n
(
x
y1
y2
:
A
),
✓
{
n
}
x
→
x
≡
{
n
}
≡
y1
⋅
y2
→
∃
z1
z2
,
x
≡
z1
⋅
z2
∧
z1
≡
{
n
}
≡
y1
∧
z2
≡
{
n
}
≡
y2
).
Lemma
cmra_total_
mixin
:
CMRAMixin
A
.
Lemma
cmra_total_
laws
:
cmra_laws
A
.
Proof
using
Type
*.
split
;
auto
.
-
intros
n
x
y
?
Hcx
%
core_ne
Hx
;
move
:
Hcx
.
rewrite
/
core
/=
Hx
/=.
...
...
@@ -850,7 +869,7 @@ End cmra_transport.
(** * Instances *)
(** ** Discrete CMRA *)
Record
RAMixin
A
`
{
Equiv
A
,
PCore
A
,
Op
A
,
Valid
A
}
:
=
{
Record
ra_laws
A
`
{
Equiv
A
,
PCore
A
,
Op
A
,
Valid
A
}
:
=
{
(* setoids *)
ra_op_proper
(
x
:
A
)
:
Proper
((
≡
)
==>
(
≡
))
(
op
x
)
;
ra_core_proper
x
y
cx
:
...
...
@@ -869,18 +888,19 @@ Record RAMixin A `{Equiv A, PCore A, Op A, Valid A} := {
Section
discrete
.
Local
Set
Default
Proof
Using
"Type*"
.
Context
`
{
Equiv
A
,
PCore
A
,
Op
A
,
Valid
A
,
@
Equivalence
A
(
≡
)}.
Context
(
ra_mix
:
RAMixin
A
).
Context
(
laws
:
ra_laws
A
).
Existing
Instances
discrete_dist
.
Instance
discrete_validN
:
ValidN
A
:
=
λ
n
x
,
✓
x
.
Definition
discrete_cmra_
mixin
:
CMRAMixin
A
.
Definition
discrete_cmra_
laws
:
cmra_laws
A
.
Proof
.
destruct
ra_mix
;
split
;
try
done
.
destruct
laws
;
split
;
try
done
.
-
intros
x
;
split
;
first
done
.
by
move
=>
/(
_
0
).
-
intros
n
x
y1
y2
??
;
by
exists
y1
,
y2
.
Qed
.
End
discrete
.
(*
Notation discreteR A ra_mix :=
(CMRAT A discrete_ofe_mixin (discrete_cmra_mixin ra_mix)).
Notation discreteUR A ra_mix ucmra_mix :=
...
...
@@ -889,7 +909,7 @@ Notation discreteUR A ra_mix ucmra_mix :=
Global Instance discrete_cmra_discrete `{Equiv A, PCore A, Op A, Valid A,
@Equivalence A (≡)} (ra_mix : RAMixin A) : CMRADiscrete (discreteR A ra_mix).
Proof. split. apply _. done. Qed.
*)
Section
ra_total
.
Local
Set
Default
Proof
Using
"Type*"
.
Context
A
`
{
Equiv
A
,
PCore
A
,
Op
A
,
Valid
A
}.
...
...
@@ -903,7 +923,7 @@ Section ra_total.
Context
(
core_idemp
:
∀
x
:
A
,
core
(
core
x
)
≡
core
x
).
Context
(
core_mono
:
∀
x
y
:
A
,
x
≼
y
→
core
x
≼
core
y
).
Context
(
valid_op_l
:
∀
x
y
:
A
,
✓
(
x
⋅
y
)
→
✓
x
).
Lemma
ra_total_
mixin
:
RAMixin
A
.
Lemma
ra_total_
laws
:
ra_laws
A
.
Proof
.
split
;
auto
.
-
intros
x
y
?
Hcx
%
core_proper
Hx
;
move
:
Hcx
.
rewrite
/
core
/=
Hx
/=.
...
...
@@ -922,15 +942,17 @@ Section unit.
Instance
unit_validN
:
ValidN
()
:
=
λ
n
x
,
True
.
Instance
unit_pcore
:
PCore
()
:
=
λ
x
,
Some
x
.
Instance
unit_op
:
Op
()
:
=
λ
x
y
,
().
Lemma
unit_cmra_mixin
:
CMRAMixin
().
Proof
.
apply
discrete_cmra_mixin
,
ra_total_mixin
;
by
eauto
.
Qed
.
Canonical
Structure
unitR
:
cmraT
:
=
CMRAT
()
unit_ofe_mixin
unit_cmra_mixin
.
Lemma
unit_cmra_laws
:
cmra_laws
().
Proof
.
apply
discrete_cmra_laws
,
ra_total_laws
;
by
eauto
.
Qed
.
Definition
unit_cmra_mixin
:
=
CMRAMixin
unit_ofe_laws
unit_cmra_laws
.
Canonical
Structure
unitR
:
cmraT
:
=
CMRAT
()
unit_cmra_mixin
.
Instance
unit_empty
:
Empty
()
:
=
().
Lemma
unit_ucmra_
mixin
:
UCMRAMixin
().
Lemma
unit_ucmra_
laws
:
ucmra_laws
().
Proof
.
done
.
Qed
.
Canonical
Structure
unitUR
:
ucmraT
:
=
UCMRAT
()
unit_ofe_mixin
unit_cmra_mixin
unit_ucmra_mixin
.
Definition
unit_ucmra_mixin
:
=
UCMRAMixin
unit_ofe_laws
unit_cmra_laws
unit_ucmra_laws
.
Canonical
Structure
unitUR
:
ucmraT
:
=
UCMRAT
()
unit_ucmra_mixin
.
Global
Instance
unit_cmra_discrete
:
CMRADiscrete
unitR
.
Proof
.
done
.
Qed
.
...
...
@@ -953,31 +975,35 @@ Section nat.
-
intros
[
z
->]
;
unfold
op
,
nat_op
;
lia
.
-
exists
(
y
-
x
).
by
apply
le_plus_minus
.
Qed
.
Lemma
nat_ra_
mixin
:
RAMixin
nat
.
Lemma
nat_ra_
laws
:
ra_laws
nat
.
Proof
.
apply
ra_total_
mixin
;
try
by
eauto
.
apply
ra_total_
laws
;
try
by
eauto
.
-
solve_proper
.
-
intros
x
y
z
.
apply
Nat
.
add_assoc
.
-
intros
x
y
.
apply
Nat
.
add_comm
.
-
by
exists
0
.
Qed
.
(*
Definition nat_cmra_mixin := CMRAMixin unit_ofe_laws unit_cmra_laws.
Canonical Structure natR : cmraT := discreteR nat nat_ra_mixin.
*)
Instance
nat_empty
:
Empty
nat
:
=
0
.
Lemma
nat_ucmra_
mixin
:
UCMRAMixin
nat
.
Lemma
nat_ucmra_
laws
:
ucmra_laws
nat
.
Proof
.
split
;
apply
_
||
done
.
Qed
.
(*
Canonical Structure natUR : ucmraT :=
discreteUR nat nat_ra_mixin nat_ucmra_mixin.
Global Instance nat_cmra_discrete : CMRADiscrete natR.
Proof. constructor; apply _ || done. Qed.
Global Instance nat_cancelable (x : nat) : Cancelable x.
Proof. by intros ???? ?%Nat.add_cancel_l. Qed.
*)
End
nat
.
Definition
mnat
:
=
nat
.
(*
Section mnat.
Instance mnat_valid : Valid mnat := λ x, True.
Instance mnat_validN : ValidN mnat := λ n x, True.
...
...
@@ -1045,6 +1071,7 @@ Section positive.
by apply leibniz_equiv.
Qed.
End positive.
*)
(** ** Product *)
Section
prod
.
...
...
@@ -1082,7 +1109,7 @@ Section prod.
intros
[[
z1
Hz1
]
[
z2
Hz2
]]
;
exists
(
z1
,
z2
)
;
split
;
auto
.
Qed
.
Definition
prod_cmra_
mixin
:
CMRAMixin
(
A
*
B
).
Definition
prod_cmra_
laws
:
cmra_laws
(
A
*
B
).
Proof
.
split
;
try
apply
_
.
-
by
intros
n
x
y1
y2
[
Hy1
Hy2
]
;
split
;
rewrite
/=
?Hy1
?Hy2
.
...
...
@@ -1111,8 +1138,8 @@ Section prod.
destruct
(
cmra_extend
n
(
x
.
2
)
(
y1
.
2
)
(
y2
.
2
))
as
(
z21
&
z22
&?&?&?)
;
auto
.
by
exists
(
z11
,
z21
),
(
z12
,
z22
).
Qed
.
Canonical
Structure
prodR
:
=
CMRAT
(
A
*
B
)
prod_ofe_mixin
prod_cmra_mixin
.
Definition
prod_cmra_mixin
:
=
CMRAMixin
prod_ofe_laws
prod_cmra_laws
.
Canonical
Structure
prodR
:
=
CMRAT
(
A
*
B
)
prod_cmra_mixin
.
Lemma
pair_op
(
a
a'
:
A
)
(
b
b'
:
B
)
:
(
a
,
b
)
⋅
(
a'
,
b'
)
=
(
a
⋅
a'
,
b
⋅
b'
).
Proof
.
done
.
Qed
.
...
...
@@ -1152,15 +1179,16 @@ Section prod_unit.
Context
{
A
B
:
ucmraT
}.
Instance
prod_empty
`
{
Empty
A
,
Empty
B
}
:
Empty
(
A
*
B
)
:
=
(
∅
,
∅
).
Lemma
prod_ucmra_
mixin
:
UCMRAMixin
(
A
*
B
).
Lemma
prod_ucmra_
laws
:
ucmra_laws
(
A
*
B
).
Proof
.
split
.
-
split
;
apply
ucmra_unit_valid
.
-
by
split
;
rewrite
/=
left_id
.
-
rewrite
prod_pcore_Some'
;
split
;
apply
(
persistent
_
).
Qed
.
Canonical
Structure
prodUR
:
=
UCMRAT
(
A
*
B
)
prod_ofe_mixin
prod_cmra_mixin
prod_ucmra_mixin
.
Definition
prod_ucmra_mixin
:
=
UCMRAMixin
prod_ofe_laws
prod_cmra_laws
prod_ucmra_laws
.
Canonical
Structure
prodUR
:
=
UCMRAT
(
A
*
B
)
prod_ucmra_mixin
.
Lemma
pair_split
(
x
:
A
)
(
y
:
B
)
:
(
x
,
y
)
≡
(
x
,
∅
)
⋅
(
∅
,
y
).
Proof
.
by
rewrite
pair_op
left_id
right_id
.
Qed
.
...
...
@@ -1263,9 +1291,9 @@ Section option.
+
exists
(
Some
z
)
;
by
constructor
.
Qed
.
Lemma
option_cmra_
mixin
:
CMRAMixin
(
option
A
).
Lemma
option_cmra_
laws
:
cmra_laws
(
option
A
).
Proof
.
apply
cmra_total_
mixin
.
apply
cmra_total_
laws
.
-
eauto
.
-
by
intros
[
x
|]
n
;
destruct
1
;
constructor
;
cofe_subst
.
-
destruct
1
;
by
cofe_subst
.
...
...
@@ -1295,17 +1323,18 @@ Section option.
+
by
exists
None
,
(
Some
x
)
;
repeat
constructor
.
+
exists
None
,
None
;
repeat
constructor
.
Qed
.
Canonical
Structure
optionR
:
=
CMRAT
(
option
A
)
option_ofe_mixin
option_cmra_mixin
.
Definition
option_cmra_mixin
:
=
CMRAMixin
option_ofe_laws
option_cmra_laws
.
Canonical
Structure
optionR
:
=
CMRAT
(
option
A
)
option_cmra_mixin
.
Global
Instance
option_cmra_discrete
:
CMRADiscrete
A
→
CMRADiscrete
optionR
.
Proof
.
split
;
[
apply
_
|].
by
intros
[
x
|]
;
[
apply
(
cmra_discrete_valid
x
)|].
Qed
.
Instance
option_empty
:
Empty
(
option
A
)
:
=
None
.
Lemma
option_ucmra_
mixin
:
UCMRAMixin
option
R
.
Lemma
option_ucmra_
laws
:
ucmra_laws
(
option
A
)
.
Proof
.
split
.
done
.
by
intros
[].
done
.
Qed
.
Canonical
Structure
optionUR
:
=
UCMRAT
(
option
A
)
option_ofe_mixin
option_cmra_mixin
option_ucmra_mixin
.
Definition
option_ucmra_mixin
:
=
UCMRAMixin
option_ofe_laws
option_cmra_laws
option_ucmra_laws
.
Canonical
Structure
optionUR
:
=
UCMRAT
(
option
A
)
option_ucmra_mixin
.
(** Misc *)
Global
Instance
Some_cmra_monotone
:
CMRAMonotone
Some
.
...
...
theories/algebra/cofe_solver.v
View file @
a9e2d8f3
...
...
@@ -52,7 +52,7 @@ Record tower := {
}.
Instance
tower_equiv
:
Equiv
tower
:
=
λ
X
Y
,
∀
k
,
X
k
≡
Y
k
.
Instance
tower_dist
:
Dist
tower
:
=
λ
n
X
Y
,
∀
k
,
X
k
≡
{
n
}
≡
Y
k
.
Definition
tower_ofe_
mixin
:
O
fe
Mixin
tower
.
Lemma
tower_ofe_
laws
:
o
fe
_laws
tower
.
Proof
.
split
.
-
intros
X
Y
;
split
;
[
by
intros
HXY
n
k
;
apply
equiv_dist
|].
...
...
@@ -64,6 +64,7 @@ Proof.
-
intros
k
X
Y
HXY
n
;
apply
dist_S
.
by
rewrite
-(
g_tower
X
)
(
HXY
(
S
n
))
g_tower
.
Qed
.
Definition
tower_ofe_mixin
:
=
OfeMixin
tower_ofe_laws
.
Definition
T
:
ofeT
:
=
OfeT
tower
tower_ofe_mixin
.
Program
Definition
tower_chain
(
c
:
chain
T
)
(
k
:
nat
)
:
chain
(
A
k
)
:
=
...
...
theories/algebra/gmap.v
View file @
a9e2d8f3
From
iris
.
algebra
Require
Export
cmra
.
From
iris
.
prelude
Require
Export
gmap
.
(*
From iris.algebra Require Import updates local_updates.
From iris.base_logic Require Import base_logic.
*)
Set
Default
Proof
Using
"Type"
.
Section
cofe
.
...
...
@@ -10,12 +12,33 @@ Implicit Types m : gmap K A.
Instance
gmap_dist
:
Dist
(
gmap
K
A
)
:
=
λ
n
m1
m2
,
∀
i
,
m1
!!
i
≡
{
n
}
≡
m2
!!
i
.
Definition
gmap_ofe_mixin
:
O
fe
Mixin
(
gmap
K
A
).
Definition
gmap_ofe_mixin
:
o
fe
_laws
(
gmap
K
A
).
Proof
.
split
.
-
intros
m1
m2
;
split
.
+
by
intros
Hm
n
k
;
apply
equiv_dist
.
+
intros
Hm
k
;
apply
equiv_dist
;
intros
n
;
apply
Hm
.
+
intros
Hm
k
.
Check
@
equiv_dist
.
apply
equiv_dist
.
(** FOOBAR -- This gives:
Error:
In environment
K : Type
EqDecision0 : EqDecision K
H : Countable K
A : ofeT
m1, m2 : gmap K A
Hm : ∀ n : nat, m1 ≡{n}≡ m2
k : K
Unable to unify
"(?M4301 ≡ ?M4302 → ∀ n : nat, ?M4301 ≡{n}≡ ?M4302)
∧ ((∀ n : nat, ?M4301 ≡{n}≡ ?M4302) → ?M4301 ≡ ?M4302)" with
"option_Forall2 equiv (m1 !! k) (m2 !! k)".
*)
(
A
:
=
optionC
A
).
apply
H0
.
apply
equiv_dist
.
intros
n
;
apply
Hm
.
-
intros
n
;
split
.
+
by
intros
m
k
.
+
by
intros
m1
m2
?
k
.
...
...
theories/algebra/ofe.v
View file @
a9e2d8f3
...
...
@@ -33,40 +33,45 @@ Tactic Notation "cofe_subst" :=
|
H
:
@
dist
?A
?d
?n
_
?x
|-
_
=>
symmetry
in
H
;
setoid_subst_aux
(@
dist
A
d
n
)
x
end
.
Record
O
fe
Mixin
A
`
{
Equiv
A
,
Dist
A
}
:
=
{
mixin
_equiv_dist
x
y
:
x
≡
y
↔
∀
n
,
x
≡
{
n
}
≡
y
;
mixin
_dist_equivalence
n
:
Equivalence
(
dist
n
)
;
mixin
_dist_S
n
x
y
:
x
≡
{
S
n
}
≡
y
→
x
≡
{
n
}
≡
y
Record
o
fe
_laws
A
`
{
Equiv
A
,
Dist
A
}
:
=
{
law
_equiv_dist
x
y
:
x
≡
y
↔
∀
n
,
x
≡
{
n
}
≡
y
;
law
_dist_equivalence
n
:
Equivalence
(
dist
n
)
;
law
_dist_S
n
x
y
:
x
≡
{
S
n
}
≡
y
→
x
≡
{
n
}
≡
y
}.
Record
ofe_mixin
A
:
=
OfeMixin
{
ofe_mixin_equiv
:
Equiv
A
;
ofe_mixin_dist
:
Dist
A
;
ofe_mixin_laws_of
:
ofe_laws
A
;
}.
Arguments
OfeMixin
{
_
_
_
}
_
.
(** Bundeled version *)
Structure
ofeT
:
=
OfeT'
{
ofe_car
:
>
Type
;
ofe_equiv
:
Equiv
ofe_car
;
ofe_dist
:
Dist
ofe_car
;
ofe_mixin
:
OfeMixin
ofe_car
;
_
:
Type
}.
Arguments
OfeT'
_
{
_
_
}
_
_
.
Structure
ofeT
:
=
OfeT'
{
ofe_car
:
>
Type
;
_
:
ofe_mixin
ofe_car
;
_
:
Type
}.