Skip to content

Commit 2771e39

Browse files
basic view updates
1 parent c3049ed commit 2771e39

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

src/Iris/Algebra/View.lean

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Iris.Algebra.OFE
99
import Iris.Algebra.Frac
1010
import Iris.Algebra.DFrac
1111
import Iris.Algebra.Agree
12+
import Iris.Algebra.Updates
1213

1314
open Iris
1415

@@ -615,4 +616,73 @@ theorem view_both_included : ((●V a1 : View F R) • ◯V b1) ≼ ((●V a2)
615616
view_both_dfrac_included.trans <| and_iff_right_iff_imp.mpr <| fun _ => .inr rfl
616617

617618
end cmra
619+
620+
section updates
621+
622+
variable [UFraction F] [OFE A] [IB : UCMRA B] {R : view_rel A B} [ViewRel R]
623+
624+
theorem view_updateP {Pab : A → B → Prop}
625+
(Hup : ∀ n bf, R n a (b • bf) → ∃ a' b', Pab a' b' ∧ R n a' (b' • bf)) :
626+
((●V a) • ◯V b : View F R) ~~>: fun k => ∃ a' b', k = ((●V a') • ◯V b' : View F R) ∧ Pab a' b' := by
627+
refine UpdateP.total.mpr (fun n ⟨ag, bf⟩ => ?_)
628+
rcases ag with (_|⟨dq, ag⟩)
629+
· intro H
630+
simp [CMRA.op, op, CMRA.ValidN, optionOp, validN] at H
631+
obtain ⟨_, a0, He', Hrel'⟩ := H
632+
have He := toAgree.inj He'; clear He'
633+
have Hrel : R n a (b • bf) := by
634+
apply ViewRel.mono Hrel' He.symm _ n.le_refl
635+
apply Iris.OFE.Dist.to_incN
636+
refine CMRA.comm.dist.trans (.trans ?_ CMRA.comm.dist)
637+
refine CMRA.op_ne.ne ?_
638+
exact (CMRA.unit_left_id_dist b).symm
639+
obtain ⟨a', b', Hab', Hrel''⟩ := Hup _ _ Hrel
640+
refine ⟨((●V a') • ◯V b'), ?_, ⟨by trivial, ?_⟩⟩
641+
· exists a'; exists b'
642+
· refine ⟨a', .rfl, ?_⟩
643+
apply ViewRel.mono Hrel'' .rfl _ n.le_refl
644+
simp [CMRA.op, op]
645+
apply Iris.OFE.Dist.to_incN
646+
refine CMRA.comm.dist.trans (.trans ?_ CMRA.comm.dist)
647+
refine CMRA.op_ne.ne ?_
648+
exact (CMRA.unit_left_id_dist b')
649+
· -- FIXME: Why doesn't this synthesize?
650+
have _ : CMRA.Exclusive (DFrac.own One.one : DFrac F) := by
651+
apply own_whole_exclusive <| UFraction.one_whole
652+
exact (CMRA.not_valid_exclN_op_left ·.1 |>.elim)
653+
654+
theorem view_update (Hup : ∀ n bf, R n a (b • bf) → R n a' (b' • bf)) :
655+
((●V a) • ◯V b : View F R) ~~> (●V a') • ◯V b' := by
656+
apply Update.of_updateP
657+
apply UpdateP.weaken
658+
· apply view_updateP (Pab := fun a b => a = a' ∧ b = b')
659+
intro _ _ H
660+
exact ⟨a', b', ⟨rfl, rfl⟩, Hup _ _ H⟩
661+
· rintro y ⟨a', b', H, rfl, rfl⟩; exact H.symm
662+
663+
theorem view_update_alloc (Hup : ∀ n bf, R n a bf → R n a' (b' • bf)) :
664+
((●V a) ~~> ((●V a' : View F R) • ◯V b')) := by
665+
refine Update.equiv_left CMRA.unit_right_id ?_
666+
refine view_update (fun n bf H => Hup n bf <| ViewRel.mono H .rfl ?_ n.le_refl)
667+
exact CMRA.incN_op_right n UCMRA.unit bf
668+
669+
theorem view_update_dealloc (Hup : (∀ n bf, R n a (b • bf) → R n a' bf)) :
670+
((●V a : View F R) • ◯V b) ~~> ●V a' := by
671+
refine Update.equiv_right CMRA.unit_right_id ?_
672+
refine view_update (fun n bf H => ?_)
673+
refine ViewRel.mono (Hup n bf H) .rfl ?_ n.le_refl
674+
exact Iris.OFE.Dist.to_incN (CMRA.unit_left_id_dist bf)
675+
676+
theorem view_update_auth (Hup : ∀ n bf, R n a bf → R n a' bf) :
677+
(●V a : View F R) ~~> ●V a' := by
678+
refine Update.equiv_right CMRA.unit_right_id ?_
679+
refine Update.equiv_left CMRA.unit_right_id ?_
680+
refine view_update (fun n bf H => ?_)
681+
exact ViewRel.mono (Hup n _ H) .rfl .rfl n.le_refl
682+
683+
684+
end updates
685+
686+
687+
618688
end View

0 commit comments

Comments
 (0)