Commit 7f0bdb3c authored by Ike Mulder's avatar Ike Mulder
Browse files

Merged master back in.

parents b7a6d2b0 326964bd
Pipeline #60391 passed with stage
in 7 minutes and 31 seconds
...@@ -40,3 +40,8 @@ build-coq.8.14.1: ...@@ -40,3 +40,8 @@ build-coq.8.14.1:
variables: variables:
OPAM_PINS: "coq version 8.14.1" OPAM_PINS: "coq version 8.14.1"
build-coq.8.14.1:
<<: *template
variables:
OPAM_PINS: "coq version 8.14.1"
...@@ -327,7 +327,9 @@ Section other. ...@@ -327,7 +327,9 @@ Section other.
End other. End other.
Class IsValidOp {A : cmra} (a a1 a2 : A) Σ (P : iPropI Σ) := { From iris_automation.biabd Require Export proofmode_classes proofmode_instances.
(*Class IsValidOp {A : cmra} (a a1 a2 : A) Σ (P : iPropI Σ) := {
is_valid_merge : ✓ (a1 ⋅ a2) ⊢ □ P ; is_valid_merge : ✓ (a1 ⋅ a2) ⊢ □ P ;
is_valid_op : ✓ (a1 ⋅ a2) ⊢@{iPropI Σ} a ≡ a1 ⋅ a2 ; is_valid_op : ✓ (a1 ⋅ a2) ⊢@{iPropI Σ} a ≡ a1 ⋅ a2 ;
}. }.
...@@ -353,7 +355,7 @@ Class NonUnital {A : cmra} (a : A) Σ := ...@@ -353,7 +355,7 @@ Class NonUnital {A : cmra} (a : A) Σ :=
non_unital_element b : a ≡ a ⋅ b ⊢@{iPropI Σ} False. non_unital_element b : a ≡ a ⋅ b ⊢@{iPropI Σ} False.
Class HasRightId {A : cmra} (a : A) := Class HasRightId {A : cmra} (a : A) :=
has_right_id : c, a a c. has_right_id : ∃ c, a ≡ a ⋅ c. *)
Class CmraSubtract {A : cmra} (a b : A) (φ : Prop) (c : option A) := Class CmraSubtract {A : cmra} (a b : A) (φ : Prop) (c : option A) :=
cmra_subtract : φ default b (c' c; Some $ b c') a. cmra_subtract : φ default b (c' c; Some $ b c') a.
...@@ -382,7 +384,7 @@ From iris.proofmode Require Import base classes reduction tactics. ...@@ -382,7 +384,7 @@ From iris.proofmode Require Import base classes reduction tactics.
From iris.algebra Require Import agree frac. From iris.algebra Require Import agree frac.
Section validity. Section validity.
Implicit Types Σ : gFunctors. Implicit Types Σ : gFunctors. (*
Lemma from_isop {A : cmra} (a a1 a2 : A) {Σ} : Lemma from_isop {A : cmra} (a a1 a2 : A) {Σ} :
IsOp a a1 a2 → IsValidOp a a1 a2 Σ True%I. IsOp a a1 a2 → IsValidOp a a1 a2 Σ True%I.
Proof. Proof.
...@@ -406,7 +408,7 @@ Section validity. ...@@ -406,7 +408,7 @@ Section validity.
Global Instance merge_unital_proper a1 a2 Σ : Proper ((≡@{iPropI Σ}) ==> (iff)) (IsIncludedMergeUnital a1 a2). Global Instance merge_unital_proper a1 a2 Σ : Proper ((≡@{iPropI Σ}) ==> (iff)) (IsIncludedMergeUnital a1 a2).
Proof. solve_proper. Qed. Proof. solve_proper. Qed.
End proper. End proper. *)
Section base_instances_cmra. Section base_instances_cmra.
Context {A : cmra}. Context {A : cmra}.
...@@ -427,7 +429,7 @@ Section validity. ...@@ -427,7 +429,7 @@ Section validity.
split =>//. split =>//.
move => c /cmra_valid_validN Hn. move => c /cmra_valid_validN Hn.
by eapply H. by eapply H.
Qed. Qed. (*
Lemma is_included_merge' (a1 a2 : A) {Σ} (P : iPropI Σ) : Lemma is_included_merge' (a1 a2 : A) {Σ} (P : iPropI Σ) :
IsIncludedMerge a1 a2 P → IsIncludedMerge a1 a2 P →
...@@ -467,26 +469,26 @@ Section validity. ...@@ -467,26 +469,26 @@ Section validity.
rewrite H. rewrite H.
iLeft. iLeft.
by iApply "H✓". by iApply "H✓".
Qed. Qed. *)
End base_instances_cmra. End base_instances_cmra.
Section base_instances_ucmra. Section base_instances_ucmra.
Context {A : ucmra}. Context {A : ucmra}. (*
Global Instance valid_op_unit_left (a : A) Σ : Global Instance valid_op_unit_left (a : A) Σ :
IsValidOp a ε a Σ True%I | 5. IsValidOp a ε a Σ True%I | 5.
Proof. apply from_isop. rewrite /IsOp left_id //. Qed. Proof. apply from_isop. rewrite /IsOp left_id //. Qed.
Global Instance valid_op_unit_right (a : A) Σ: Global Instance valid_op_unit_right (a : A) Σ:
IsValidOp a a ε Σ True%I | 5. IsValidOp a a ε Σ True%I | 5.
Proof. apply from_isop. rewrite /IsOp right_id //. Qed. Proof. apply from_isop. rewrite /IsOp right_id //. Qed. *)
Global Instance ucmra_subtract_all (a : A) : UcmraSubtract a a True ε | 100. Global Instance ucmra_subtract_all (a : A) : UcmraSubtract a a True ε | 100.
(* this one may glance over pcore like info we can actually keep *) (* this one may glance over pcore like info we can actually keep *)
Proof. by rewrite /UcmraSubtract /CmraSubtract /= right_id => _. Qed. Proof. by rewrite /UcmraSubtract /CmraSubtract /= right_id => _. Qed.
Global Instance ucmra_subtract_unit (a : A) : UcmraSubtract a ε True a | 101. Global Instance ucmra_subtract_unit (a : A) : UcmraSubtract a ε True a | 101.
Proof. rewrite /UcmraSubtract /CmraSubtract /= left_id //. Qed. Proof. rewrite /UcmraSubtract /CmraSubtract /= left_id //. Qed. (*
Global Instance included_merge_unital_from_reg (a1 a2 : A) {Σ} (P : iProp Σ) : Global Instance included_merge_unital_from_reg (a1 a2 : A) {Σ} (P : iProp Σ) :
IsIncludedMerge a1 a2 P → IsIncludedMerge a1 a2 P →
...@@ -502,7 +504,7 @@ Section validity. ...@@ -502,7 +504,7 @@ Section validity.
iLeft. by iApply "H✓". iLeft. by iApply "H✓".
Qed. Qed.
Global Instance ucmra_has_right_id (a : A) : HasRightId a. Global Instance ucmra_has_right_id (a : A) : HasRightId a.
Proof. exists ε. by rewrite right_id. Qed. Proof. exists ε. by rewrite right_id. Qed. *)
Global Instance find_local_update_from_subtract (x x' : A) r φ : Global Instance find_local_update_from_subtract (x x' : A) r φ :
UcmraSubtract x' x φ r UcmraSubtract x' x φ r
...@@ -539,14 +541,14 @@ Section validity. ...@@ -539,14 +541,14 @@ Section validity.
Qed. Qed.
End base_instances_ucmra. End base_instances_ucmra.
Section numbers. Section numbers. (*
Global Instance nat_valid_op (a a1 a2 : nat) Σ: Global Instance nat_valid_op (a a1 a2 : nat) Σ:
IsOp a a1 a2 → IsValidOp a a1 a2 Σ True%I | 10. IsOp a a1 a2 → IsValidOp a a1 a2 Σ True%I | 10.
Proof. apply from_isop. Qed. Proof. apply from_isop. Qed. *)
Global Instance ucmra_subtract_nat (a1 a2 : nat) : Global Instance ucmra_subtract_nat (a1 a2 : nat) :
TCIf (SolveSepSideCondition (a1 < a2)%nat) False TCTrue (* guards against obviously impossible things *) TCIf (SolveSepSideCondition (a1 < a2)%nat) False TCTrue (* guards against obviously impossible things *)
UcmraSubtract a1 a2 (a2 a1) (a1 - a2)%nat. UcmraSubtract a1 a2 (a2 a1) (a1 - a2)%nat.
Proof. rewrite /UcmraSubtract /CmraSubtract /= nat_op => _ Ha. fold_leibniz. lia. Qed. Proof. rewrite /UcmraSubtract /CmraSubtract /= nat_op => _ Ha. fold_leibniz. lia. Qed. (*
Global Instance nat_included_merge (a1 a2 : nat) {Σ} : IsIncludedMerge a1 a2 (Σ := Σ) ⌜a1 ≤ a2⌝%I. Global Instance nat_included_merge (a1 a2 : nat) {Σ} : IsIncludedMerge a1 a2 (Σ := Σ) ⌜a1 ≤ a2⌝%I.
Proof. Proof.
rewrite /IsIncludedMerge. rewrite /IsIncludedMerge.
...@@ -557,13 +559,13 @@ Section validity. ...@@ -557,13 +559,13 @@ Section validity.
Global Instance nat_max_valid_op (a a1 a2 : max_nat) Σ : Global Instance nat_max_valid_op (a a1 a2 : max_nat) Σ :
IsOp a a1 a2 → IsValidOp a a1 a2 Σ True%I | 10. IsOp a a1 a2 → IsValidOp a a1 a2 Σ True%I | 10.
Proof. apply from_isop. Qed. Proof. apply from_isop. Qed. *)
Global Instance ucmra_subtract_max_nat (a1 a2 : nat) : Global Instance ucmra_subtract_max_nat (a1 a2 : nat) :
UcmraSubtract (MaxNat a1) (MaxNat a2) (a2 a1) (MaxNat a1). UcmraSubtract (MaxNat a1) (MaxNat a2) (a2 a1) (MaxNat a1).
Proof. Proof.
rewrite /UcmraSubtract /CmraSubtract /= max_nat_op => Ha. rewrite /UcmraSubtract /CmraSubtract /= max_nat_op => Ha.
fold_leibniz. f_equal. lia. fold_leibniz. f_equal. lia.
Qed. Qed. (*
Global Instance nat_max_included_merge (a1 a2 : nat) {Σ} : IsIncludedMerge (MaxNat a1) (MaxNat a2) (Σ := Σ) ⌜a1 ≤ a2⌝%I. Global Instance nat_max_included_merge (a1 a2 : nat) {Σ} : IsIncludedMerge (MaxNat a1) (MaxNat a2) (Σ := Σ) ⌜a1 ≤ a2⌝%I.
Proof. Proof.
rewrite /IsIncludedMerge. iIntros "_"; iSplit. rewrite /IsIncludedMerge. iIntros "_"; iSplit.
...@@ -573,32 +575,32 @@ Section validity. ...@@ -573,32 +575,32 @@ Section validity.
Global Instance nat_min_valid_op (a a1 a2 : min_nat) Σ : Global Instance nat_min_valid_op (a a1 a2 : min_nat) Σ :
IsOp a a1 a2 → IsValidOp a a1 a2 Σ True%I. IsOp a a1 a2 → IsValidOp a a1 a2 Σ True%I.
Proof. apply from_isop. Qed. Proof. apply from_isop. Qed. *)
Global Instance cmra_subtract_min_nat (a1 a2 : nat) : Global Instance cmra_subtract_min_nat (a1 a2 : nat) :
CmraSubtract (MinNat a1) (MinNat a2) (a1 a2) (Some $ MinNat a1). CmraSubtract (MinNat a1) (MinNat a2) (a1 a2) (Some $ MinNat a1).
Proof. Proof.
rewrite /UcmraSubtract /CmraSubtract /= min_nat_op_min => Ha. rewrite /UcmraSubtract /CmraSubtract /= min_nat_op_min => Ha.
fold_leibniz. f_equal. lia. fold_leibniz. f_equal. lia.
Qed. Qed. (*
Global Instance nat_min_included_merge (a1 a2 : nat) {Σ} : IsIncludedMerge (MinNat a1) (MinNat a2) (Σ := Σ) ⌜a2 ≤ a1⌝%I. Global Instance nat_min_included_merge (a1 a2 : nat) {Σ} : IsIncludedMerge (MinNat a1) (MinNat a2) (Σ := Σ) ⌜a2 ≤ a1⌝%I.
Proof. Proof.
rewrite /IsIncludedMerge. iIntros "_"; iSplit. rewrite /IsIncludedMerge. iIntros "_"; iSplit.
- by iDestruct 1 as %?%min_nat_included. - by iDestruct 1 as %?%min_nat_included.
- iIntros "%". iExists (MinNat a2). rewrite min_nat_op_min. iPureIntro. fold_leibniz. f_equal. lia. - iIntros "%". iExists (MinNat a2). rewrite min_nat_op_min. iPureIntro. fold_leibniz. f_equal. lia.
Qed. Qed. *)
Lemma nat_min_coalloc n : CoAllocate (MinNat n) (Some $ MinNat 0). Lemma nat_min_coalloc n : CoAllocate (MinNat n) (Some $ MinNat 0).
(* 0 is the maximal element for minnat. This is not an instance - we don't usually want to coallocate 0 with n *) (* 0 is the maximal element for minnat. This is not an instance - we don't usually want to coallocate 0 with n *)
Proof. Proof.
split => //. split => //.
move => [c] /min_nat_included /= /le_n_0_eq <- _ m. move => [c] /min_nat_included /= /le_n_0_eq <- _ m.
apply min_nat_included => /=. lia. apply min_nat_included => /=. lia.
Qed. Qed. (*
Global Instance min_nat_has_right_id n : HasRightId (MinNat n). Global Instance min_nat_has_right_id n : HasRightId (MinNat n).
Proof. exists (MinNat n). rewrite min_nat_op_min. fold_leibniz. f_equal. lia. Qed. Proof. exists (MinNat n). rewrite min_nat_op_min. fold_leibniz. f_equal. lia. Qed.
Global Instance positive_valid_op (a a1 a2 : positive) Σ : Global Instance positive_valid_op (a a1 a2 : positive) Σ :
IsOp a a1 a2 → IsValidOp a a1 a2 Σ True%I. IsOp a a1 a2 → IsValidOp a a1 a2 Σ True%I.
Proof. apply from_isop. Qed. Proof. apply from_isop. Qed. *)
Global Instance cmra_subtract_positive_lt (a1 a2 : positive) : Global Instance cmra_subtract_positive_lt (a1 a2 : positive) :
SolveSepSideCondition (a2 < a1)%positive SolveSepSideCondition (a2 < a1)%positive
CmraSubtract a1 a2 True (Some (a1 - a2)%positive). CmraSubtract a1 a2 True (Some (a1 - a2)%positive).
...@@ -609,7 +611,7 @@ Section validity. ...@@ -609,7 +611,7 @@ Section validity.
Global Instance cmra_subtract_positive_eq (a1 a2 : positive) : Global Instance cmra_subtract_positive_eq (a1 a2 : positive) :
SolveSepSideCondition (a2 = a1) SolveSepSideCondition (a2 = a1)
CmraSubtract a1 a2 True None. CmraSubtract a1 a2 True None.
Proof. by rewrite /CmraSubtract /= => ->. Qed. Proof. by rewrite /CmraSubtract /= => ->. Qed. (*
Global Instance positive_included_merge (a1 a2 : positive) {Σ} : IsIncludedMerge a1 a2 (Σ := Σ) ⌜(a1 < a2)%positive⌝%I. Global Instance positive_included_merge (a1 a2 : positive) {Σ} : IsIncludedMerge a1 a2 (Σ := Σ) ⌜(a1 < a2)%positive⌝%I.
Proof. Proof.
rewrite /IsIncludedMerge. iIntros "_"; iSplit. rewrite /IsIncludedMerge. iIntros "_"; iSplit.
...@@ -636,7 +638,7 @@ Section validity. ...@@ -636,7 +638,7 @@ Section validity.
rewrite /IsOp; split; last first. rewrite /IsOp; split; last first.
{ rewrite H; eauto. } { rewrite H; eauto. }
by iDestruct 1 as %?%frac_valid. by iDestruct 1 as %?%frac_valid.
Qed. Qed. *)
Global Instance frac_subtract_half (q : Qp) : Global Instance frac_subtract_half (q : Qp) :
CmraSubtract q (q/2)%Qp True (Some (q/2)%Qp) | 10. CmraSubtract q (q/2)%Qp True (Some (q/2)%Qp) | 10.
Proof. rewrite /CmraSubtract /= => _. by rewrite frac_op Qp_div_2. Qed. Proof. rewrite /CmraSubtract /= => _. by rewrite frac_op Qp_div_2. Qed.
...@@ -667,7 +669,7 @@ Section validity. ...@@ -667,7 +669,7 @@ Section validity.
Proof. Proof.
rewrite /CmraSubtract /= => Hφ1 Hφ2. rewrite /CmraSubtract /= => Hφ1 Hφ2.
case => /Hφ1 <- /Hφ2 <- //. case => /Hφ1 <- /Hφ2 <- //.
Qed. Qed. (*
Global Instance frac_included_merge (q1 q2 : Qp) {Σ} : IsIncludedMerge q1 q2 (Σ := Σ) ⌜(q1 < q2)%Qp⌝%I. Global Instance frac_included_merge (q1 q2 : Qp) {Σ} : IsIncludedMerge q1 q2 (Σ := Σ) ⌜(q1 < q2)%Qp⌝%I.
Proof. Proof.
rewrite /IsIncludedMerge. iIntros "_" ; iSplit. rewrite /IsIncludedMerge. iIntros "_" ; iSplit.
...@@ -692,7 +694,7 @@ Section validity. ...@@ -692,7 +694,7 @@ Section validity.
Proof. Proof.
rewrite /NonUnital => q. iIntros "%". fold_leibniz. rewrite /NonUnital => q. iIntros "%". fold_leibniz.
rewrite frac_op in H. apply eq_sym in H. by apply Qp_add_id_free in H. rewrite frac_op in H. apply eq_sym in H. by apply Qp_add_id_free in H.
Qed. Qed. *)
Global Instance frac_coallocate_half : Global Instance frac_coallocate_half :
CoAllocate (1/2)%Qp (Some $ 1/2)%Qp. CoAllocate (1/2)%Qp (Some $ 1/2)%Qp.
...@@ -732,7 +734,7 @@ Section validity. ...@@ -732,7 +734,7 @@ Section validity.
End numbers. End numbers.
Section sets. Section sets.
Context `{Countable K}. Context `{Countable K}. (*
Global Instance set_is_op_emp_l (X : gset K) : Global Instance set_is_op_emp_l (X : gset K) :
IsOp X ∅ X | 10. IsOp X ∅ X | 10.
Proof. rewrite /IsOp. set_solver. Qed. Proof. rewrite /IsOp. set_solver. Qed.
...@@ -745,11 +747,11 @@ Section validity. ...@@ -745,11 +747,11 @@ Section validity.
Global Instance set_is_valid_op (a a1 a2 : gset K) Σ : Global Instance set_is_valid_op (a a1 a2 : gset K) Σ :
IsOp a a1 a2 → IsValidOp a a1 a2 Σ True%I | 10. IsOp a a1 a2 → IsValidOp a a1 a2 Σ True%I | 10.
Proof. apply from_isop. Qed. Proof. apply from_isop. Qed. *)
Global Instance ucmra_set_subtract_refl (a : gset K): UcmraSubtract a a True a | 10. Global Instance ucmra_set_subtract_refl (a : gset K): UcmraSubtract a a True a | 10.
Proof. rewrite /UcmraSubtract /CmraSubtract /= gset_op. set_solver. Qed. Proof. rewrite /UcmraSubtract /CmraSubtract /= gset_op. set_solver. Qed.
Global Instance ucmra_set_subtract (a1 a2 : gset K) : UcmraSubtract a1 a2 (a2 a1) a1 | 20. Global Instance ucmra_set_subtract (a1 a2 : gset K) : UcmraSubtract a1 a2 (a2 a1) a1 | 20.
Proof. rewrite /UcmraSubtract /CmraSubtract /= gset_op. set_solver. Qed. Proof. rewrite /UcmraSubtract /CmraSubtract /= gset_op. set_solver. Qed. (*
Global Instance set_included_merge (a1 a2 : gset K) {Σ} : IsIncludedMerge a1 a2 (Σ := Σ) ⌜a1 ⊆ a2⌝%I. Global Instance set_included_merge (a1 a2 : gset K) {Σ} : IsIncludedMerge a1 a2 (Σ := Σ) ⌜a1 ⊆ a2⌝%I.
Proof. Proof.
rewrite /IsIncludedMerge. iIntros "_"; iSplit. rewrite /IsIncludedMerge. iIntros "_"; iSplit.
...@@ -770,7 +772,7 @@ Section validity. ...@@ -770,7 +772,7 @@ Section validity.
Proof. apply from_isop. rewrite /IsOp. rewrite gset_disj_union; [f_equal | ]; set_solver. Qed. Proof. apply from_isop. rewrite /IsOp. rewrite gset_disj_union; [f_equal | ]; set_solver. Qed.
Global Instance set_disj_valid_op_emp_r (X Y : gset K) Σ : Global Instance set_disj_valid_op_emp_r (X Y : gset K) Σ :
IsValidOp (GSet X) (GSet ∅) (GSet X) Σ True%I | 10. IsValidOp (GSet X) (GSet ∅) (GSet X) Σ True%I | 10.
Proof. apply from_isop. rewrite /IsOp. rewrite gset_disj_union; [f_equal | ]; set_solver. Qed. Proof. apply from_isop. rewrite /IsOp. rewrite gset_disj_union; [f_equal | ]; set_solver. Qed. *)
Global Instance ucmra_disjoint_set_subtract_refl (a : gset K) : Global Instance ucmra_disjoint_set_subtract_refl (a : gset K) :
UcmraSubtract (GSet a) (GSet a) True ε | 10. UcmraSubtract (GSet a) (GSet a) True ε | 10.
Proof. eapply ucmra_subtract_all. Qed. Proof. eapply ucmra_subtract_all. Qed.
...@@ -788,7 +790,7 @@ Section validity. ...@@ -788,7 +790,7 @@ Section validity.
rewrite decide_True //. rewrite decide_True //.
intros. f_equal. intros. f_equal.
by rewrite -union_difference_L. by rewrite -union_difference_L.
Qed. Qed. (*
Global Instance disj_set_included_merge (a1 a2 : gset K) {Σ} : IsIncludedMerge (GSet a1) (GSet a2) (Σ := Σ) ⌜a1 ⊆ a2⌝%I. Global Instance disj_set_included_merge (a1 a2 : gset K) {Σ} : IsIncludedMerge (GSet a1) (GSet a2) (Σ := Σ) ⌜a1 ⊆ a2⌝%I.
Proof. Proof.
rewrite /IsIncludedMerge. iIntros "_"; iSplit. rewrite /IsIncludedMerge. iIntros "_"; iSplit.
...@@ -797,13 +799,13 @@ Section validity. ...@@ -797,13 +799,13 @@ Section validity.
iExists (GSet (a2 ∖ a1)). iExists (GSet (a2 ∖ a1)).
iPureIntro. rewrite gset_disj_union; [|set_solver]. iPureIntro. rewrite gset_disj_union; [|set_solver].
fold_leibniz. f_equal. by apply union_difference_L. fold_leibniz. f_equal. by apply union_difference_L.
Qed. Qed. *)
(* no coallocate for both: gset is all _finite_ sets, these have no maximum element *) (* no coallocate for both: gset is all _finite_ sets, these have no maximum element *)
End sets. End sets.
Section multisets. Section multisets.
Context `{Countable K}. Context `{Countable K}. (*
Global Instance multiset_is_op_emp_l (X : gmultiset K) : Global Instance multiset_is_op_emp_l (X : gmultiset K) :
IsOp X ∅ X | 10. IsOp X ∅ X | 10.
Proof. rewrite /IsOp. multiset_solver. Qed. Proof. rewrite /IsOp. multiset_solver. Qed.
...@@ -816,7 +818,7 @@ Section validity. ...@@ -816,7 +818,7 @@ Section validity.
Global Instance multiset_is_valid_op (a a1 a2 : gmultiset K) Σ : Global Instance multiset_is_valid_op (a a1 a2 : gmultiset K) Σ :
IsOp a a1 a2 → IsValidOp a a1 a2 Σ True%I | 10. IsOp a a1 a2 → IsValidOp a a1 a2 Σ True%I | 10.
Proof. apply from_isop. Qed. Proof. apply from_isop. Qed. *)
Global Instance ucmra_multiset_subtract_refl (a : gmultiset K) : Global Instance ucmra_multiset_subtract_refl (a : gmultiset K) :
UcmraSubtract a a True ε | 10. UcmraSubtract a a True ε | 10.
Proof. apply ucmra_subtract_all. Qed. Proof. apply ucmra_subtract_all. Qed.
...@@ -828,17 +830,17 @@ Section validity. ...@@ -828,17 +830,17 @@ Section validity.
Proof. eapply ucmra_subtract_unit. Qed. Proof. eapply ucmra_subtract_unit. Qed.
Global Instance ucmra_multiset_subtract (a1 a2 : gmultiset K) : Global Instance ucmra_multiset_subtract (a1 a2 : gmultiset K) :
UcmraSubtract a1 a2 (a2 a1) (a1 a2) | 20. UcmraSubtract a1 a2 (a2 a1) (a1 a2) | 20.
Proof. rewrite /UcmraSubtract /CmraSubtract /= gmultiset_op. multiset_solver. Qed. Proof. rewrite /UcmraSubtract /CmraSubtract /= gmultiset_op. multiset_solver. Qed. (*
Global Instance multiset_included_merge (a1 a2 : gmultiset K) {Σ} : IsIncludedMerge a1 a2 (Σ := Σ) ⌜a1 ⊆ a2⌝%I. Global Instance multiset_included_merge (a1 a2 : gmultiset K) {Σ} : IsIncludedMerge a1 a2 (Σ := Σ) ⌜a1 ⊆ a2⌝%I.
Proof. Proof.
rewrite /IsIncludedMerge. iIntros "_"; iSplit. rewrite /IsIncludedMerge. iIntros "_"; iSplit.
- by iDestruct 1 as %?%gmultiset_included. - by iDestruct 1 as %?%gmultiset_included.
- iIntros "%". iExists (a2 ∖ a1). iPureIntro. fold_leibniz. rewrite gmultiset_op. multiset_solver. - iIntros "%". iExists (a2 ∖ a1). iPureIntro. fold_leibniz. rewrite gmultiset_op. multiset_solver.
Qed. Qed. *)
End multisets. End multisets.
Section recursive. Section recursive.
Implicit Types A : cmra. Implicit Types A : cmra. (*
Global Instance option_some_valid_op {A} (a a1 a2 : A) Σ P : Global Instance option_some_valid_op {A} (a a1 a2 : A) Σ P :
IsValidOp a a1 a2 Σ P → IsValidOp (Some a) (Some a1) (Some a2) Σ P. IsValidOp a a1 a2 Σ P → IsValidOp (Some a) (Some a1) (Some a2) Σ P.
...@@ -846,14 +848,14 @@ Section validity. ...@@ -846,14 +848,14 @@ Section validity.
case => HP Ha. case => HP Ha.
split; rewrite -Some_op option_validI //. split; rewrite -Some_op option_validI //.
by rewrite Ha option_equivI. by rewrite Ha option_equivI.
Qed. Qed. *)
Global Instance option_subtract {A} (a b : A) φ c : Global Instance option_subtract {A} (a b : A) φ c :
CmraSubtract a b φ c CmraSubtract a b φ c
UcmraSubtract (Some a) (Some b) φ c. UcmraSubtract (Some a) (Some b) φ c.
Proof. Proof.
rewrite /UcmraSubtract /CmraSubtract /= => Hφ /Hφ <-. rewrite /UcmraSubtract /CmraSubtract /= => Hφ /Hφ <-.
by destruct c. by destruct c.
Qed. Qed. (*
Global Instance option_included_merge {A} (a1 a2 : A) {Σ} (P : iProp Σ): Global Instance option_included_merge {A} (a1 a2 : A) {Σ} (P : iProp Σ):
IsIncludedMergeUnital a1 a2 P → IsIncludedMergeUnital a1 a2 P →
IsIncludedMerge (Some a1) (Some a2) P | 100. IsIncludedMerge (Some a1) (Some a2) P | 100.
...@@ -882,7 +884,7 @@ Section validity. ...@@ -882,7 +884,7 @@ Section validity.
by rewrite option_equivI -Some_op. by rewrite option_equivI -Some_op.
* iExists None. rewrite option_equivI. rewrite Some_op_opM /=. * iExists None. rewrite option_equivI. rewrite Some_op_opM /=.
by iRewrite "He". by iRewrite "He".
Qed. (* we need below, even though it is trivial, to handle recursive cases *) Qed. (* we need below, even though it is trivial, to handle recursive cases *)
Global Instance option_none_excl_included_merge {A} (a : optionUR A) {Σ} : Global Instance option_none_excl_included_merge {A} (a : optionUR A) {Σ} :
IsIncludedMerge None a (Σ := Σ) (True)%I. IsIncludedMerge None a (Σ := Σ) (True)%I.
Proof. Proof.
...@@ -901,7 +903,7 @@ Section validity. ...@@ -901,7 +903,7 @@ Section validity.
apply (Some_equiv_eq _ (a ⋅ c)) in H as [x [xH _]] => //. apply (Some_equiv_eq _ (a ⋅ c)) in H as [x [xH _]] => //.
- rewrite Some_op_opM /= in H. - rewrite Some_op_opM /= in H.
apply (Some_equiv_eq _ a) in H as [x [xH _]] => //. apply (Some_equiv_eq _ a) in H as [x [xH _]] => //.
Qed. Qed. *)
Global Instance option_some_coalloc {A} (a : A) (mb : option A) : Global Instance option_some_coalloc {A} (a : A) (mb : option A) :
CoAllocate a mb CoAllocate a mb
CoAllocate (Some a) (Some mb). CoAllocate (Some a) (Some mb).
...@@ -928,7 +930,7 @@ Section validity. ...@@ -928,7 +930,7 @@ Section validity.
{ intros. exists None. by rewrite right_id. } { intros. exists None. by rewrite right_id. }
rewrite -Some_op Some_valid. rewrite -Some_op Some_valid.
move => /Hmb //. move => /Hmb //.
Qed. Qed. (*
Global Instance sum_inl_valid_op {A1 A2} (a a1 a2 : A1) Σ P : Global Instance sum_inl_valid_op {A1 A2} (a a1 a2 : A1) Σ P :
IsValidOp a a1 a2 Σ P → IsValidOp (Cinl a) (Cinl (B := A2) a1) (Cinl (B := A2) a2) Σ P. IsValidOp a a1 a2 Σ P → IsValidOp (Cinl a) (Cinl (B := A2) a1) (Cinl (B := A2) a2) Σ P.
...@@ -961,7 +963,7 @@ Section validity. ...@@ -961,7 +963,7 @@ Section validity.
split; rewrite /op /= /cmra_op //=; eauto. split; rewrite /op /= /cmra_op //=; eauto.
rewrite uPred_cmra_valid_eq /= /uPred_cmra_valid_def /=. rewrite uPred_cmra_valid_eq /= /uPred_cmra_valid_def /=.
rewrite /validN /= /cmra_validN //=. rewrite /validN /= /cmra_validN //=.
Qed. Qed. *)
Lemma sum_inl_subtract {A1 A2} (a b : A1) φ c : Lemma sum_inl_subtract {A1 A2} (a b : A1) φ c :
CmraSubtract a b φ c CmraSubtract a b φ c
CmraSubtract (Cinl (B := A2) a) (Cinl (B := A2) b) φ (fmap Cinl c). CmraSubtract (Cinl (B := A2) a) (Cinl (B := A2) b) φ (fmap Cinl c).
...@@ -1001,7 +1003,7 @@ Section validity. ...@@ -1001,7 +1003,7 @@ Section validity.
Proof. Proof.
move => /sum_inr_subtract /= Hc. move => /sum_inr_subtract /= Hc.
apply Hc. apply Hc.
Qed. Qed. (*
Global Instance sum_inl_included_merge {A1 A2} (a1 a2 : A1) {Σ} (P : iProp Σ): Global Instance sum_inl_included_merge {A1 A2} (a1 a2 : A1) {Σ} (P : iProp Σ):
IsIncludedMerge a1 a2 P → IsIncludedMerge a1 a2 P →
IsIncludedMerge (Cinl (B := A2) a1) (Cinl (B := A2) a2) (P)%I | 100. IsIncludedMerge (Cinl (B := A2) a1) (Cinl (B := A2) a2) (P)%I | 100.
...@@ -1126,7 +1128,7 @@ Section validity. ...@@ -1126,7 +1128,7 @@ Section validity.
rewrite /MakeAnd. split; rewrite -pair_op prod_validI /=. rewrite /MakeAnd. split; rewrite -pair_op prod_validI /=.
- rewrite -H bi.intuitionistically_and -HP1 -HP2 //. - rewrite -H bi.intuitionistically_and -HP1 -HP2 //.
- rewrite prod_equivI /= -Hxs -Hys //. - rewrite prod_equivI /= -Hxs -Hys //.
Qed. Qed. *)
Global Instance prod_subtract_Some {A1 A2} (a1 b1 c1 : A1) (a2 b2 c2 : A2) φ1 φ2 : Global Instance prod_subtract_Some {A1 A2} (a1 b1 c1 : A1) (a2 b2 c2 : A2) φ1 φ2 :
CmraSubtract a1 b1 φ1 (Some c1) CmraSubtract a1 b1 φ1 (Some c1)
CmraSubtract a2 b2 φ2 (Some c2) CmraSubtract a2 b2 φ2 (Some c2)
...@@ -1142,7 +1144,7 @@ Section validity. ...@@ -1142,7 +1144,7 @@ Section validity.
UcmraSubtract a2 b2 φ2 c2 UcmraSubtract a2 b2 φ2 c2
TCEq p (c1, c2) (* avoids some unification troubles *) TCEq p (c1, c2) (* avoids some unification troubles *)
UcmraSubtract (a1, a2) (b1, b2) (φ1 φ2) p. UcmraSubtract (a1, a2) (b1, b2) (φ1 φ2) p.
Proof. rewrite /UcmraSubtract /CmraSubtract => Hφ1 Hφ2 -> [/Hφ1 <- /Hφ2 <-] //=. Qed. Proof. rewrite /UcmraSubtract /CmraSubtract => Hφ1 Hφ2 -> [/Hφ1 <- /Hφ2 <-] //=. Qed. (*
Global Instance prod_included_merge {A1 A2} (x1 x2 : A1) (y1 y2 : A2) {Σ} P1 P2 P : Global Instance prod_included_merge {A1 A2} (x1 x2 : A1) (y1 y2 : A2) {Σ} P1 P2 P :
IsIncludedMerge x1 x2 (Σ := Σ) P1 → IsIncludedMerge x1 x2 (Σ := Σ) P1 →
IsIncludedMerge y1 y2 (Σ := Σ) P2 → IsIncludedMerge y1 y2 (Σ := Σ) P2 →
...@@ -1384,7 +1386,7 @@ Section validity. ...@@ -1384,7 +1386,7 @@ Section validity.
eapply prod_included_merge_unital => //. eapply prod_included_merge_unital => //.
- right. split => //. - right. split => //.
- right. split => //. - right. split => //.
Qed. Qed. *)
Global Instance prod_coalloc {A1 A2} x1 mx2 y1 my2 : Global Instance prod_coalloc {A1 A2} x1 mx2 y1 my2 :
CoAllocate (A := A1) x1 mx2 CoAllocate (A := A1) x1 mx2
CoAllocate (A := A2) y1 my2 CoAllocate (A := A2) y1 my2
...@@ -1409,7 +1411,7 @@ Section validity. ...@@ -1409,7 +1411,7 @@ Section validity.
case => a1 a2. case => a1 a2.
rewrite -pair_op => /pair_valid. rewrite -pair_op => /pair_valid.
case => /Hxmax //. case => /Hxmax //.
Qed. Qed. (*
Global Instance prod_left_non_unital {A1 A2} (x1 : A1) (x2 : A2) Σ : Global Instance prod_left_non_unital {A1 A2} (x1 : A1) (x2 : A2) Σ :
NonUnital x1 Σ → NonUnital (x1, x2) Σ. NonUnital x1 Σ → NonUnital (x1, x2) Σ.
Proof. Proof.
...@@ -1434,11 +1436,14 @@ Section validity. ...@@ -1434,11 +1436,14 @@ Section validity.
Global Instance excl_valid_op {O : ofe} (a1 a2 : excl O) Σ: Global Instance excl_valid_op {O : ofe} (a1 a2 : excl O) Σ:
IsValidOp ExclBot a1 a2 Σ False%I. IsValidOp ExclBot a1 a2 Σ False%I.