Library zoo.iris.base_logic.lib.auth_nat_max

Require Import zoo.prelude.
Require Import zoo.common.math.
Require Import zoo.iris.base_logic.lib.auth_monoi.
Require Export zoo.iris.base_logic.lib.base.
Require Import zoo.iris.diaframe.
Require Import zoo.options.

Class AuthNatMaxG Σ :=
  { #[local] auth_nat_max۰G۰mono۰G :: AuthMonoiG Σ (≤)
  }.

Definition auth_nat_max۰Σ :=
  #[auth_monoi۰Σ (≤)
  ].
#[global] Instance subGauth_nat_max۰Σ Σ :
  subG auth_nat_max۰Σ Σ
  AuthNatMaxG Σ.

Section auth_nat_max۰G.
  Context `{auth_nat_max۰G : !AuthNatMaxG Σ}.

  Implicit Type n m p : nat.

  Definition auth_nat_max۰auth γ dq n :=
    auth_monoi۰auth (≤) γ dq n.
  Definition auth_nat_max۰lb γ n :=
    auth_monoi۰lb (≤) γ n.

  #[global] Instance auth_nat_max۰authtimeless γ dq n :
    Timeless (auth_nat_max۰auth γ dq n).
  #[global] Instance auth_nat_max۰lbtimeless γ n :
    Timeless (auth_nat_max۰lb γ n).

  #[global] Instance auth_nat_max۰authpersistent γ n :
    Persistent (auth_nat_max۰auth γ DfracDiscarded n).
  #[global] Instance auth_nat_max۰lbpersistent γ n :
    Persistent (auth_nat_max۰lb γ n).

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

  Lemma auth_nat_maxalloc n :
     |==>
       γ,
      auth_nat_max۰auth γ (DfracOwn 1) n.

  Lemma auth_nat_max۰authvalid γ dq a :
    auth_nat_max۰auth γ dq a
     dq.
  Lemma auth_nat_max۰authcombine γ dq1 n1 dq2 n2 :
    auth_nat_max۰auth γ dq1 n1 -∗
    auth_nat_max۰auth γ dq2 n2 -∗
      n1 = n2
      auth_nat_max۰auth γ (dq1 dq2) n1.
  Lemma auth_nat_max۰authvalidー2 γ dq1 n1 dq2 n2 :
    auth_nat_max۰auth γ dq1 n1 -∗
    auth_nat_max۰auth γ dq2 n2 -∗
       (dq1 dq2)
      n1 = n2.
  Lemma auth_nat_max۰authagree γ dq1 n1 dq2 n2 :
    auth_nat_max۰auth γ dq1 n1 -∗
    auth_nat_max۰auth γ dq2 n2 -∗
    n1 = n2.
  Lemma auth_nat_max۰authdfracne γ1 dq1 n1 γ2 dq2 n2 :
    ¬ (dq1 dq2)
    auth_nat_max۰auth γ1 dq1 n1 -∗
    auth_nat_max۰auth γ2 dq2 n2 -∗
    γ1 γ2.
  Lemma auth_nat_max۰authne γ1 n1 γ2 dq2 n2 :
    auth_nat_max۰auth γ1 (DfracOwn 1) n1 -∗
    auth_nat_max۰auth γ2 dq2 n2 -∗
    γ1 γ2.
  Lemma auth_nat_max۰authexclusive γ n1 dq2 n2 :
    auth_nat_max۰auth γ (DfracOwn 1) n1 -∗
    auth_nat_max۰auth γ dq2 n2 -∗
    False.
  Lemma auth_nat_max۰authpersist γ dq n :
    auth_nat_max۰auth γ dq n |==>
    auth_nat_max۰auth γ DfracDiscarded n.

  Lemma auth_nat_max۰lbー0 γ :
     |==>
      auth_nat_max۰lb γ 0.
  Lemma auth_nat_max۰lbget γ q n :
    auth_nat_max۰auth γ q n
    auth_nat_max۰lb γ n.
  Lemma auth_nat_max۰lble {γ n} n' :
    n' n
    auth_nat_max۰lb γ n
    auth_nat_max۰lb γ n'.
  Lemma auth_nat_max۰lbmax γ n1 n2 :
    auth_nat_max۰lb γ n1 -∗
    auth_nat_max۰lb γ n2 -∗
    auth_nat_max۰lb γ (n1 `max` n2).

  Lemma auth_nat_max۰lbvalid γ dq n m :
    auth_nat_max۰auth γ dq n -∗
    auth_nat_max۰lb γ m -∗
    m n.

  Lemma auth_nat_maxupdate {γ n} n' :
    n n'
    auth_nat_max۰auth γ (DfracOwn 1) n |==>
    auth_nat_max۰auth γ (DfracOwn 1) n'.
End auth_nat_max۰G.

#[global] Opaque auth_nat_max۰auth.
#[global] Opaque auth_nat_max۰lb.