Library zoo.iris.base_logic.lib.auth_gmultiset

Require Import iris.algebra.gmultiset.

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 AuthGmultisetG Σ A `{Countable A} :=
  { #[local] auth_gmultiset۰G۰inG :: inG Σ (authR (gmultisetUR A))
  }.

Definition auth_gmultiset۰Σ A `{Countable A} :=
  #[GFunctor (authR (gmultisetUR A))
  ].
#[global] Instance subGauth_gmultiset۰Σ Σ A `{Countable A} :
  subG (auth_gmultiset۰Σ A) Σ
  AuthGmultisetG Σ A.

Section auth_gmultiset۰G.
  Context `{auth_gmultiset۰G : AuthGmultisetG Σ A}.

  Implicit Type x y : gmultiset A.

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

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

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

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

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

  Lemma auth_gmultisetalloc :
     |==>
       γ,
      auth_gmultiset۰auth γ (DfracOwn 1) .

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

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

  Lemma auth_gmultisetsubseteq γ dq x y :
    auth_gmultiset۰auth γ dq x -∗
    auth_gmultiset۰frag γ y -∗
    y x.
  Lemma auth_gmultisetelem_of γ dq x b :
    auth_gmultiset۰auth γ dq x -∗
    auth_gmultiset۰frag γ {[+b+]} -∗
    b x.

  Lemma auth_gmultisetupdatealloc {γ x} y :
    auth_gmultiset۰auth γ (DfracOwn 1) x |==>
      auth_gmultiset۰auth γ (DfracOwn 1) (y x)
      auth_gmultiset۰frag γ y.
  Lemma auth_gmultisetupdateallocsingleton {γ x} a :
    auth_gmultiset۰auth γ (DfracOwn 1) x |==>
      auth_gmultiset۰auth γ (DfracOwn 1) ({[+a+]} x)
      auth_gmultiset۰frag γ {[+a+]}.

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

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