|
| 1 | +import Iris.Algebra.CMRA |
| 2 | + |
| 3 | +namespace Iris |
| 4 | + |
| 5 | +def cmra_updateP [CMRA A] (x : A) (P : A → Prop) := ∀ n mz, |
| 6 | + ✓{n} (x •? mz) → ∃ y, P y ∧ ✓{n} (y •? mz) |
| 7 | +infixr:50 " ~~>: " => cmra_updateP |
| 8 | + |
| 9 | +def cmra_update [CMRA A] (x y : A) := ∀ n mz, |
| 10 | + ✓{n} (x •? mz) → ✓{n} (y •? mz) |
| 11 | +infixr:50 " ~~> " => cmra_update |
| 12 | + |
| 13 | +section updates |
| 14 | +variable [CMRA α] |
| 15 | + |
| 16 | +-- (* Global Instance cmra_updateP_proper : |
| 17 | +-- Proper ((≡) ==> pointwise_relation _ iff ==> iff) (@cmra_updateP SI A). |
| 18 | +-- Proof. Admitted. *) |
| 19 | + |
| 20 | +-- (* Global Instance cmra_update_proper : |
| 21 | +-- Proper ((≡) ==> (≡) ==> iff) (@cmra_update SI A). |
| 22 | +-- Proof. Admitted. *) |
| 23 | + |
| 24 | +theorem cmra_update_updateP {x y: α} : x ~~> y ↔ x ~~>: (y =.) := sorry |
| 25 | + |
| 26 | +theorem cmra_updateP_id (P : α → Prop) x : P x → x ~~>: P := sorry |
| 27 | + |
| 28 | +theorem cmra_updateP_compose (P Q : α → Prop) x : |
| 29 | + x ~~>: P → (∀ y, P y → y ~~>: Q) → x ~~>: Q := sorry |
| 30 | + |
| 31 | +theorem cmra_updateP_compose_l (Q : α → Prop) x y : x ~~> y → y ~~>: Q → x ~~>: Q := sorry |
| 32 | + |
| 33 | +theorem cmra_updateP_weaken (P Q : α → Prop) x : |
| 34 | + x ~~>: P → (∀ y, P y → Q y) → x ~~>: Q := sorry |
| 35 | + |
| 36 | +theorem cmra_update_exclusive {x y: α} [CMRA.Exclusive x] y: |
| 37 | + ✓ y → x ~~> y := sorry |
| 38 | + |
| 39 | +-- (** Updates form a preorder. *) |
| 40 | +-- (** We set this rewrite relation's cost above the stdlib's |
| 41 | +-- ([impl], [iff], [eq], ...) and [≡] but below [⊑]. |
| 42 | +-- [eq] (at 100) < [≡] (at 150) < [cmra_update] (at 170) < [⊑] (at 200) *) |
| 43 | + |
| 44 | +-- (* Global Instance cmra_update_rewrite_relation : |
| 45 | +-- RewriteRelation (@cmra_update SI A) | 170 := {}. *) |
| 46 | + |
| 47 | +-- (* Global Instance cmra_update_preorder : PreOrder (@cmra_update SI A). |
| 48 | +-- Proof. Admitted. *) |
| 49 | + |
| 50 | +-- (* Global Instance cmra_update_proper_update : |
| 51 | +-- Proper (flip cmra_update ==> cmra_update ==> impl) (@cmra_update SI A). |
| 52 | +-- Proof. Admitted. *) |
| 53 | + |
| 54 | +-- (* Global Instance cmra_update_flip_proper_update : |
| 55 | +-- Proper (cmra_update ==> flip cmra_update ==> flip impl) (@cmra_update SI A). |
| 56 | +-- Proof. Admitted. *) |
| 57 | + |
| 58 | +theorem cmra_updateP_op (P1 P2 Q : α → Prop) x1 x2 : |
| 59 | + x1 ~~>: P1 → x2 ~~>: P2 → (∀ y1 y2, P1 y1 → P2 y2 → Q (y1 • y2)) → |
| 60 | + x1 • x2 ~~>: Q := sorry |
| 61 | + |
| 62 | +theorem cmra_updateP_op' (P1 P2 : α → Prop) {x1 x2: α} : |
| 63 | + x1 ~~>: P1 → x2 ~~>: P2 → |
| 64 | + x1 • x2 ~~>: λ y ↦ ∃ y1 y2, y = y1 • y2 ∧ P1 y1 ∧ P2 y2 := sorry |
| 65 | + |
| 66 | +theorem cmra_update_op {x1 x2 y1 y2 : α} : x1 ~~> y1 → x2 ~~> y2 → x1 • x2 ~~> y1 • y2 := sorry |
| 67 | + |
| 68 | +-- (* Global Instance cmra_update_op_proper : |
| 69 | +-- Proper (cmra_update ==> cmra_update ==> cmra_update) (op (A:=A)). |
| 70 | +-- Proof. Admitted. *) |
| 71 | + |
| 72 | +-- (* Global Instance cmra_update_op_flip_proper : |
| 73 | +-- Proper (flip cmra_update ==> flip cmra_update ==> flip cmra_update) (op (A:=A)). |
| 74 | +-- Proof. Admitted. *) |
| 75 | + |
| 76 | + |
| 77 | +-- (* Global Instance cmra_update_op_proper : |
| 78 | +-- Proper (cmra_update ==> cmra_update ==> cmra_update) (op (A:=A)). |
| 79 | +-- Proof. Admitted. *) |
| 80 | + |
| 81 | +-- (* Global Instance cmra_update_op_flip_proper : |
| 82 | +-- Proper (flip cmra_update ==> flip cmra_update ==> flip cmra_update) (op (A:=A)). |
| 83 | +-- Proof. Admitted. *) |
| 84 | + |
| 85 | + |
| 86 | +theorem cmra_update_op_l [CMRA α] (x y : α) : x • y ~~> x := by admit |
| 87 | + |
| 88 | +theorem cmra_update_op_r [CMRA α] (x y : α) : x • y ~~> y := by admit |
| 89 | + |
| 90 | +theorem cmra_update_included [CMRA α] (x y : α) : x ≼ y → y ~~> x := by admit |
| 91 | + |
| 92 | +theorem cmra_update_valid0 [CMRA α] (x y : α) : (∀ (h₀ : ✓{0} x), x ~~> y) → x ~~> y := by admit |
| 93 | + |
| 94 | +-- (** ** Frame preserving updates for total and discete CMRAs *) |
| 95 | + |
| 96 | +theorem cmra_total_updateP [CMRA α] [CMRA.IsTotal α] (x : α) (P : α → Prop) : |
| 97 | + x ~~>: P ↔ ∀ (n : Nat) (z : α), ✓{n} (x • z) → ∃ y, P y ∧ ✓{n} (y • z) := by admit |
| 98 | + |
| 99 | +theorem cmra_total_update [CMRA α] [CMRA.IsTotal α] (x y : α) : |
| 100 | + x ~~> y ↔ ∀ (n : Nat) (z : α), ✓{n} (x • z) → ✓{n} (y • z) := by admit |
| 101 | + |
| 102 | + |
| 103 | +theorem cmra_discrete_updateP [CMRA α] [CMRA.Discrete α] (x : α) (P : α → Prop) : |
| 104 | + x ~~>: P ↔ ∀ (mz : Option α), ✓ (x •? mz) → ∃ y, P y ∧ ✓ (y •? mz) := by admit |
| 105 | + |
| 106 | +theorem cmra_discrete_update [CMRA α] [CMRA.Discrete α] (x y : α) : |
| 107 | + x ~~> y ↔ ∀ (mz : Option α), ✓ (x •? mz) → ✓ (y •? mz) := by admit |
| 108 | + |
| 109 | +theorem cmra_discrete_total_updateP [CMRA α] [CMRA.Discrete α] [CMRA.IsTotal α] |
| 110 | + (x : α) (P : α → Prop) : |
| 111 | + x ~~>: P ↔ ∀ (z : α), ✓ (x • z) → ∃ y, P y ∧ ✓ (y • z) := by admit |
| 112 | + |
| 113 | +theorem cmra_discrete_total_update [CMRA α] [CMRA.Discrete α] [CMRA.IsTotal α] |
| 114 | + (x y : α) : |
| 115 | + x ~~> y ↔ ∀ (z : α), ✓ (x • z) → ✓ (y • z) := by admit |
| 116 | + |
| 117 | +end updates |
| 118 | + |
| 119 | +-- (** * Transport *) |
| 120 | +-- Section cmra_transport. |
| 121 | +-- Context {SI : sidx} {A B : cmra} (H : A = B). |
| 122 | +-- Notation T := (cmra_transport H). |
| 123 | +-- Lemma cmra_transport_updateP (P : A → Prop) (Q : B → Prop) x : |
| 124 | +-- x ~~>: P → (∀ y, P y → Q (T y)) → T x ~~>: Q. |
| 125 | +-- Proof. Admitted. |
| 126 | + |
| 127 | +-- Lemma cmra_transport_updateP' (P : A → Prop) x : |
| 128 | +-- x ~~>: P → T x ~~>: λ y, ∃ y', y = cmra_transport H y' ∧ P y'. |
| 129 | +-- Proof. Admitted. |
| 130 | + |
| 131 | +-- End cmra_transport. |
| 132 | + |
| 133 | +-- (** * Isomorphism *) |
| 134 | +section iso_cmra |
| 135 | + variable [CMRA α] [CMRA β] (f : α → β) (g : β → α) |
| 136 | + |
| 137 | + theorem iso_cmra_updateP (P : β → Prop) (Q : α → Prop) (y : β) |
| 138 | + (gf : ∀ x, g (f x) ≡ x) |
| 139 | + (g_op : ∀ y1 y2, g (y1 • y2) ≡ g y1 • g y2) |
| 140 | + (g_validN : ∀ n y, ✓{n} (g y) ↔ ✓{n} y) : |
| 141 | + y ~~>: P → |
| 142 | + (∀ y', P y' → Q (g y')) → |
| 143 | + g y ~~>: Q := |
| 144 | + sorry |
| 145 | + |
| 146 | + theorem iso_cmra_updateP' (P : β → Prop) (y : β) |
| 147 | + (gf : ∀ x, g (f x) ≡ x) |
| 148 | + (g_op : ∀ y1 y2, g (y1 • y2) ≡ g y1 • g y2) |
| 149 | + (g_validN : ∀ n y, ✓{n} (g y) ↔ ✓{n} y) : |
| 150 | + y ~~>: P → |
| 151 | + g y ~~>: λ x ↦ ∃ y, x = g y ∧ P y := |
| 152 | + sorry |
| 153 | +end iso_cmra |
| 154 | + |
| 155 | +section update_lift_cmra |
| 156 | + variable [CMRA α] [CMRA β] |
| 157 | + |
| 158 | + theorem cmra_update_lift_updateP (f : β → α) (b : β) (b' : β) |
| 159 | + (H : ∀ P, b ~~>: P → f b ~~>: λ a' ↦ ∃ b', a' = f b' ∧ P b') : |
| 160 | + b ~~> b' → |
| 161 | + f b ~~> f b' := |
| 162 | + sorry |
| 163 | +end update_lift_cmra |
| 164 | + |
| 165 | +section prod |
| 166 | + variable [CMRA α] [CMRA β] |
| 167 | + |
| 168 | + theorem prod_updateP (P1 : α → Prop) (P2 : β → Prop) (Q : α × β → Prop) (x : α × β) : |
| 169 | + x.1 ~~>: P1 → x.2 ~~>: P2 → (∀ a b, P1 a → P2 b → Q (a, b)) → x ~~>: Q := |
| 170 | + sorry |
| 171 | + |
| 172 | + theorem prod_updateP' (P1 : α → Prop) (P2 : β → Prop) (x : α × β) : |
| 173 | + x.1 ~~>: P1 → x.2 ~~>: P2 → x ~~>: λ y ↦ P1 (y.1) ∧ P2 (y.2) := |
| 174 | + sorry |
| 175 | + |
| 176 | + theorem prod_update (x : α × β) : |
| 177 | + x.1 ~~> y.1 → x.2 ~~> y.2 → x ~~> y := |
| 178 | + sorry |
| 179 | +end prod |
| 180 | + |
| 181 | +section option |
| 182 | + variable [CMRA α] |
| 183 | + |
| 184 | + theorem option_updateP (P : α → Prop) (x : α) : |
| 185 | + x ~~>: P → (∀ y, P y → Q (some y)) → some x ~~>: Q := |
| 186 | + sorry |
| 187 | + |
| 188 | + theorem option_updateP' (P : α → Prop) (x : α) : |
| 189 | + x ~~>: P → some x ~~>: Option.rec False P := |
| 190 | + sorry |
| 191 | + |
| 192 | + theorem option_update (x y : α) : |
| 193 | + x ~~> y → some x ~~> some y := |
| 194 | + sorry |
| 195 | +end option |
0 commit comments