Library zoo_persistent.pstack

Require Import zoo.prelude.
Require Import zoo.base.
Require Import zoo_std.option.
Require Export zoo_persistent.pstack__code.
Require Import zoo_persistent.pstack__types.
Require Import zoo.options.

Implicit Type v t : val.

Section zoo۰G.
  Context `{zoo۰G : !ZooG Σ}.

  Definition pstack۰model t vs : iProp Σ :=
    list۰model t vs.

  #[global] Instance pstack۰modeltimeless t vs :
    Timeless (pstack۰model t vs).

  #[global] Instance pstack۰modelpersistent t vs :
    Persistent (pstack۰model t vs).

  Lemma pstack۰modelnil :
     pstack۰model pstack٠empty [].

  Lemma pstack٠is_emptyspec t vs :
    {{{
      pstack۰model t vs
    }}}
      pstack٠is_empty t
    {{{
      RET #(bool_decide (vs = []%list));
      True
    }}}.

  Lemma pstack٠pushspec t vs v :
    {{{
      pstack۰model t vs
    }}}
      pstack٠push t v
    {{{
      t'
    , RET t';
      pstack۰model t' (v :: vs)
    }}}.

  Lemma pstack٠popspec t vs :
    {{{
      pstack۰model t vs
    }}}
      pstack٠pop t
    {{{
      o
    , RET o;
      match o with
      | None
          vs = []
      | Some p
           v vs' t',
          vs = v :: vs'
          p = (v, t')%V
          pstack۰model t' vs'
      end
    }}}.
End zoo۰G.

Require zoo_persistent.pstack__opaque.

#[global] Opaque pstack۰model.