|
| 1 | +import Iris.Algebra.CMRA |
| 2 | + |
| 3 | +namespace Iris |
| 4 | + |
| 5 | +def LocalUpdate {α: Type}[CMRA α] (x y: α × α) := |
| 6 | + ∀n mz, ✓{n} x.1 → x.1 ≡{n}≡ x.2 •? mz → ✓{n} y.1 ∧ y.1 ≡{n}≡ y.2 •? mz |
| 7 | + |
| 8 | +infixr:50 " ~l~> " => LocalUpdate |
| 9 | + |
| 10 | +namespace LocalUpdate |
| 11 | + |
| 12 | +section CMRA |
| 13 | + variable [cmr: CMRA α] |
| 14 | + |
| 15 | + -- Global Instance local_update_proper : |
| 16 | + -- Proper ((≡) ==> (≡) ==> iff) (@local_update SI A). |
| 17 | + -- Proof. unfold local_update. by repeat intro; setoid_subst. Qed. |
| 18 | + |
| 19 | + -- Global Instance local_update_preorder : PreOrder (@local_update SI A). |
| 20 | + -- Proof. split; unfold local_update; red; naive_solver. Qed. |
| 21 | + |
| 22 | + theorem exclusive_local_update {y: α}[CMRA.Exclusive y](x x': α)(vx': ✓ x'): (x,y) ~l~> (x', x') := |
| 23 | + fun n mz vx e => |
| 24 | + have : mz = none := CMRA.none_of_excl_valid_op ((OFE.Dist.validN e).mp vx) |
| 25 | + have : x' ≡{n}≡ x' •? mz := calc |
| 26 | + x' ≡{n}≡ x' := OFE.Dist.of_eq rfl |
| 27 | + _ = x' •? mz := by rw[this]; rfl |
| 28 | + ⟨vx'.validN, this⟩ |
| 29 | + |
| 30 | + theorem op_local_update (x y z : α) (h : ∀ n, ✓{n} x → ✓{n} (z • x)) : (x, y) ~l~> (z • x, z • y) := |
| 31 | + fun n mz vx (e : x ≡{n}≡ y •? mz) => |
| 32 | + have g1 : ✓{n} (z • x) := h n vx |
| 33 | + have g2 := calc |
| 34 | + (z • x) ≡{n}≡ z • (y •? mz) := CMRA.op_right_dist z e |
| 35 | + _ ≡{n}≡ (z • y) •? mz := OFE.Dist.symm (CMRA.op_opM_assoc_dist z y mz) |
| 36 | + ⟨g1, g2⟩ |
| 37 | + |
| 38 | + theorem op_local_update_discrete [CMRA.Discrete α] (x y z : α) |
| 39 | + (h : ✓ x → ✓ (z • x)) : (x, y) ~l~> (z • x, z • y) := |
| 40 | + fun n mz vx e => |
| 41 | + have this n (vx: ✓{n} x): ✓{n} (z • x) := |
| 42 | + CMRA.Valid.validN (h ((CMRA.valid_iff_validN' n).mpr vx)) |
| 43 | + op_local_update x y z this n mz vx e |
| 44 | + |
| 45 | + theorem op_local_update_frame (x y x' y' yf : α) |
| 46 | + (h : (x, y) ~l~> (x', y')) : (x, y • yf) ~l~> (x', y' • yf) := |
| 47 | + fun n mz vx e => |
| 48 | + have := h n (some yf • mz) vx |
| 49 | + have := calc |
| 50 | + x ≡{n}≡ (y • yf) •? mz := e |
| 51 | + _ ≡{n}≡ y •? (some yf • mz) := (CMRA.op_some_opM_assoc y yf mz).dist |
| 52 | + have u := h n (some yf • mz) vx this |
| 53 | + have := calc |
| 54 | + x' ≡{n}≡ y' •? (some yf • mz) := u.2 |
| 55 | + _ ≡{n}≡ (y' • yf) •? mz := (CMRA.op_some_opM_assoc y' yf mz).symm.dist |
| 56 | + ⟨u.1, this⟩ |
| 57 | + |
| 58 | + theorem cancel_local_update (x y z : α) [CMRA.Cancelable x] : (x • y, x • z) ~l~> (y, z) := |
| 59 | + sorry |
| 60 | + |
| 61 | + theorem replace_local_update (x y : α) [CMRA.IdFree x] (h : ✓ y) : (x, x) ~l~> (y, y) := |
| 62 | + sorry |
| 63 | + |
| 64 | + theorem core_id_local_update (x y z : α) [CMRA.CoreId y] (h : y ≼ x) : (x, z) ~l~> (x, z • y) := |
| 65 | + sorry |
| 66 | + |
| 67 | + theorem local_update_discrete [CMRA.Discrete α] (x y x' y' : α) : |
| 68 | + (x, y) ~l~> (x', y') ↔ ∀ (mz : α), ✓ x → x ≡ y •? mz → (✓ x' ∧ x' ≡ y' •? mz) := |
| 69 | + sorry |
| 70 | + |
| 71 | + theorem local_update_valid0 (x y x' y' : α) : |
| 72 | + (✓{0} x → ✓{0} y → some y ≼{0} some x → (x, y) ~l~> (x', y')) → |
| 73 | + (x, y) ~l~> (x', y') := |
| 74 | + sorry |
| 75 | + |
| 76 | + theorem local_update_valid [CMRA.Discrete α] (x y x' y' : α) : |
| 77 | + (✓ x → ✓ y → some y ≼ some x → (x, y) ~l~> (x', y')) → |
| 78 | + (x, y) ~l~> (x', y') := |
| 79 | + sorry |
| 80 | + |
| 81 | + theorem local_update_total_valid0 [CMRA.IsTotal α] (x y x' y' : α) : |
| 82 | + (✓{0} x → ✓{0} y → y ≼{0} x → (x, y) ~l~> (x', y')) → |
| 83 | + (x, y) ~l~> (x', y') := |
| 84 | + sorry |
| 85 | + |
| 86 | + theorem local_update_total_valid [CMRA.IsTotal α] [CMRA.Discrete α] (x y x' y' : α) : |
| 87 | + (✓ x → ✓ y → y ≼ x → (x, y) ~l~> (x', y')) → |
| 88 | + (x, y) ~l~> (x', y') := |
| 89 | + sorry |
| 90 | +end CMRA |
| 91 | + |
| 92 | +section UCMRA |
| 93 | + variable [uc: UCMRA α] |
| 94 | + |
| 95 | + -- the rest of the section |
| 96 | +end UCMRA |
| 97 | + |
| 98 | +section updates_unital |
| 99 | + variable [UCMRA α] |
| 100 | + -- variable {x y : α} |
| 101 | + |
| 102 | + theorem local_update_unital (x y x' y' : α) : |
| 103 | + (x, y) ~l~> (x', y') ↔ ∀ n z, |
| 104 | + ✓{n} x → x ≡{n}≡ y • z → (✓{n} x' ∧ x' ≡{n}≡ y' • z) := |
| 105 | + sorry |
| 106 | + |
| 107 | + theorem local_update_unital_discrete [CMRA.Discrete α] (x y x' y' : α) : |
| 108 | + (x, y) ~l~> (x', y') ↔ ∀ z, |
| 109 | + ✓ x → x ≡ y • z → (✓ x' ∧ x' ≡ y' • z) := |
| 110 | + sorry |
| 111 | + |
| 112 | + theorem cancel_local_update_unit (x y : α) [CMRA.Cancelable x] : |
| 113 | + (x • y, x) ~l~> (y, unit) := |
| 114 | + sorry |
| 115 | +end updates_unital |
| 116 | + |
| 117 | +-- section updates_unit |
| 118 | + |
| 119 | +-- theorem unit_local_update (x y x' y' : Unit) : (x, y) ~l~> (x', y') := |
| 120 | +-- sorry |
| 121 | +-- end updates_unit |
| 122 | + |
| 123 | +-- section updates_discrete_fun |
| 124 | + |
| 125 | +-- theorem discrete_fun_local_update {α : Type} {B : α → UCMRA} |
| 126 | +-- (f g f' g' : ∀ x, B x) : |
| 127 | +-- (∀ x : α, (f x, g x) ~l~> (f' x, g' x)) → |
| 128 | +-- (f, g) ~l~> (f', g') := |
| 129 | +-- sorry |
| 130 | +-- end updates_discrete_fun |
| 131 | + |
| 132 | +-- section updates_product |
| 133 | + |
| 134 | +-- theorem prod_local_update {α β : Type} [CMRA α] [CMRA β] |
| 135 | +-- (x y x' y' : α × β) : |
| 136 | +-- (x.1, y.1) ~l~> (x'.1, y'.1) → |
| 137 | +-- (x.2, y.2) ~l~> (x'.2, y'.2) → |
| 138 | +-- (x, y) ~l~> (x', y') := |
| 139 | +-- sorry |
| 140 | + |
| 141 | +-- theorem prod_local_update' {α β : Type} [CMRA α] [CMRA β] |
| 142 | +-- (x1 y1 x1' y1' : α) (x2 y2 x2' y2' : β) : |
| 143 | +-- (x1, y1) ~l~> (x1', y1') → |
| 144 | +-- (x2, y2) ~l~> (x2', y2') → |
| 145 | +-- ((x1, x2), (y1, y2)) ~l~> ((x1', x2'), (y1', y2')) := |
| 146 | +-- sorry |
| 147 | + |
| 148 | +-- theorem prod_local_update_1 {α β : Type} [CMRA α] [CMRA β] |
| 149 | +-- (x1 y1 x1' y1' : α) (x2 y2 : β) : |
| 150 | +-- (x1, y1) ~l~> (x1', y1') → |
| 151 | +-- ((x1, x2), (y1, y2)) ~l~> ((x1', x2), (y1', y2)) := |
| 152 | +-- sorry |
| 153 | + |
| 154 | +-- theorem prod_local_update_2 {α β : Type} [CMRA α] [CMRA β] |
| 155 | +-- (x1 y1 : α) (x2 y2 x2' y2' : β) : |
| 156 | +-- (x2, y2) ~l~> (x2', y2') → |
| 157 | +-- ((x1, x2), (y1, y2)) ~l~> ((x1, x2'), (y1, y2')) := |
| 158 | +-- sorry |
| 159 | +-- end updates_product |
| 160 | + |
| 161 | +section updates_option |
| 162 | + theorem option_local_update {α : Type} [CMRA α] |
| 163 | + (x y x' y' : α) : |
| 164 | + (x, y) ~l~> (x', y') → |
| 165 | + (some x, some y) ~l~> (some x', some y') := |
| 166 | + sorry |
| 167 | + |
| 168 | + theorem option_local_update_none {α : Type} [UCMRA α] |
| 169 | + (x x' y' : α) : |
| 170 | + (x, UCMRA.unit) ~l~> (x', y') → |
| 171 | + (some x, none) ~l~> (some x', some y') := |
| 172 | + sorry |
| 173 | + |
| 174 | + theorem alloc_option_local_update {α : Type} [CMRA α] (x : α) (y : α) : |
| 175 | + ✓ x → |
| 176 | + (none, y) ~l~> (some x, some x) := |
| 177 | + sorry |
| 178 | + |
| 179 | + theorem delete_option_local_update {α : Type} [CMRA α] |
| 180 | + (x : Option α) (y : α) [CMRA.Exclusive y] : |
| 181 | + (x, some y) ~l~> (none, none) := |
| 182 | + sorry |
| 183 | + |
| 184 | + theorem delete_option_local_update_cancelable {α : Type} [CMRA α] |
| 185 | + (mx : Option α) [CMRA.Cancelable mx] : |
| 186 | + (mx, mx) ~l~> (none, none) := |
| 187 | + sorry |
| 188 | +end updates_option |
| 189 | + |
| 190 | +end LocalUpdate |
0 commit comments