Library zoo.iris.base_logic.lib.auth_dgset

Require Import iris.algebra.gset.

Require Import zoo.prelude.
Require Import zoo.iris.algebra.auth.
Require Export zoo.iris.base_logic.lib.base.
Require Import zoo.iris.diaframe.
Require Import zoo.options.

Class AuthDgsetG Σ A `{Countable A} :=
  { #[local] auth_dgset۰G۰inG :: inG Σ (authR (gset_disjUR A))
  }.

Definition auth_dgset۰Σ A `{Countable A} :=
  #[GFunctor (authR (gset_disjUR A))
  ].
#[global] Instance subGauth_dgset۰Σ Σ A `{Countable A} :
  subG (auth_dgset۰Σ A) Σ
  AuthDgsetG Σ A.

Section auth_dgset۰G.
  Context `{auth_dgset۰G : AuthDgsetG Σ A}.

  Implicit Type x y : gset A.

  Definition auth_dgset۰auth γ dq x :=
    own γ ({dq} GSet x).
  Definition auth_dgset۰frag γ y :=
    own γ ( GSet y).

  #[global] Instance auth_dgset۰authproper γ dq :
    Proper ((≡) ==> (≡)) (auth_dgset۰auth γ dq).
  #[global] Instance auth_dgset۰fragproper γ :
    Proper ((≡) ==> (≡)) (auth_dgset۰frag γ).

  #[global] Instance auth_dgset۰authtimeless γ dq x :
    Timeless (auth_dgset۰auth γ dq x).
  #[global] Instance auth_dgset۰fragtimeless γ y :
    Timeless (auth_dgset۰frag γ y).

  #[global] Instance auth_dgset۰authpersistent γ x :
    Persistent (auth_dgset۰auth γ DfracDiscarded x).

  #[global] Instance auth_dgset۰authfractional γ x :
    Fractional (λ q, auth_dgset۰auth γ (DfracOwn q) x).
  #[global] Instance auth_dgset۰authas_fractional γ q x :
    AsFractional (auth_dgset۰auth γ (DfracOwn q) x) (λ q, auth_dgset۰auth γ (DfracOwn q) x) q.

  Lemma auth_dgsetalloc x :
     |==>
       γ,
      auth_dgset۰auth γ (DfracOwn 1) x
      auth_dgset۰frag γ x.
  Lemma auth_dgsetallocempty :
     |==>
       γ,
      auth_dgset۰auth γ (DfracOwn 1) .

  Lemma auth_dgset۰authvalid γ dq x :
    auth_dgset۰auth γ dq x
     dq.
  Lemma auth_dgset۰authcombine γ dq1 x1 dq2 x2 :
    auth_dgset۰auth γ dq1 x1 -∗
    auth_dgset۰auth γ dq2 x2 -∗
      x1 = x2
      auth_dgset۰auth γ (dq1 dq2) x1.
  Lemma auth_dgset۰authvalidー2 γ dq1 x1 dq2 x2 :
    auth_dgset۰auth γ dq1 x1 -∗
    auth_dgset۰auth γ dq2 x2 -∗
       (dq1 dq2)
      x1 = x2.
  Lemma auth_dgset۰authagree γ dq1 x1 dq2 x2 :
    auth_dgset۰auth γ dq1 x1 -∗
    auth_dgset۰auth γ dq2 x2 -∗
    x1 = x2.
  Lemma auth_dgset۰authdfracne γ1 dq1 x1 γ2 dq2 x2 :
    ¬ (dq1 dq2)
    auth_dgset۰auth γ1 dq1 x1 -∗
    auth_dgset۰auth γ2 dq2 x2 -∗
    γ1 γ2.
  Lemma auth_dgset۰authne γ1 x1 γ2 dq2 x2 :
    auth_dgset۰auth γ1 (DfracOwn 1) x1 -∗
    auth_dgset۰auth γ2 dq2 x2 -∗
    γ1 γ2.
  Lemma auth_dgset۰authexclusive γ x1 dq2 x2 :
    auth_dgset۰auth γ (DfracOwn 1) x1 -∗
    auth_dgset۰auth γ dq2 x2 -∗
    False.
  Lemma auth_dgset۰authpersist γ dq x :
    auth_dgset۰auth γ dq x |==>
    auth_dgset۰auth γ DfracDiscarded x.

  Lemma auth_dgset۰fragdisjoint γ y1 y2 :
    auth_dgset۰frag γ y1 -∗
    auth_dgset۰frag γ y2 -∗
    y1 ## y2.
  Lemma auth_dgset۰fragsingletonne γ b1 b2 :
    auth_dgset۰frag γ {[b1]} -∗
    auth_dgset۰frag γ {[b2]} -∗
    b1 b2.
  Lemma auth_dgset۰fragexclusive γ y :
    y
    auth_dgset۰frag γ y -∗
    auth_dgset۰frag γ y -∗
    False.
  Lemma auth_dgset۰fragsingletonexclusive γ b :
    auth_dgset۰frag γ {[b]} -∗
    auth_dgset۰frag γ {[b]} -∗
    False.

  Lemma auth_dgset۰fragcombine γ y1 y2 :
    auth_dgset۰frag γ y1 -∗
    auth_dgset۰frag γ y2 -∗
    auth_dgset۰frag γ (y1 y2).

  Lemma auth_dgsetsubseteq γ dq x y :
    auth_dgset۰auth γ dq x -∗
    auth_dgset۰frag γ y -∗
    y x.
  Lemma auth_dgsetelem_of γ dq x b :
    auth_dgset۰auth γ dq x -∗
    auth_dgset۰frag γ {[b]} -∗
    b x.

  Lemma auth_dgsetupdatealloc {γ x} y :
    x ## y
    auth_dgset۰auth γ (DfracOwn 1) x |==>
      auth_dgset۰auth γ (DfracOwn 1) (y x)
      auth_dgset۰frag γ y.
  Lemma auth_dgsetupdateallocsingleton {γ x} a :
    a x
    auth_dgset۰auth γ (DfracOwn 1) x |==>
      auth_dgset۰auth γ (DfracOwn 1) ({[a]} x)
      auth_dgset۰frag γ {[a]}.

  Lemma auth_dgsetupdatedealloc {γ x} y :
    auth_dgset۰auth γ (DfracOwn 1) x -∗
    auth_dgset۰frag γ y ==∗
    auth_dgset۰auth γ (DfracOwn 1) (x y).
End auth_dgset۰G.

#[global] Opaque auth_dgset۰auth.
#[global] Opaque auth_dgset۰frag.