Library examples.pool_quicksort

Require Import zoo.prelude.
Require Import zoo.common.list.
Require Import zoo.base.
Require Export examples.pool_quicksort__code.
Require Import examples.pool_quicksort__types.
Require Import zoo.options.

Section pool۰G.
  Context `{pool۰G : PoolG}.

  #[local] Lemma pool_quicksort٠partitionspec arr i i_ xs sz :
    (0 i)%Z
    i_ = i
    (1 < sz)%Z
    length xs = sz
    {{{
      array۰slice arr i_ (DfracOwn 1) (#*@{Z} xs)
    }}}
      pool_quicksort٠partition arr #i #sz
    {{{
      xs1 p pivot xs2
    , RET #p;
      p = (i_ + length xs1)%nat
      xs ≡ₚ xs1 ++ pivot :: xs2
      Forall ((≥)%Z pivot) xs1
      Forall ((≤)%Z pivot) xs2
      array۰slice arr i_ (DfracOwn 1) (#*@{Z} xs1 ++ #@{Z} pivot :: #*@{Z} xs2)
    }}}.
  #[local] Lemma pool_quicksort٠main₂spec pool ctx scope arr i i_ xs sz :
    (0 i)%Z
    i_ = i
    length xs = sz
    {{{
      pool۰context pool ctx scope
      array۰slice arr i_ (DfracOwn 1) (#*@{Z} xs)
    }}}
      pool_quicksort٠main₂ ctx arr #i #sz
    {{{
      RET ();
      pool۰context pool ctx scope
      pool۰consumer pool (
         xs',
        xs ≡ₚ xs'
        StronglySorted (≤)%Z xs'
        array۰slice arr i_ (DfracOwn 1) (#*@{Z} xs')
      )
    }}}.
  #[local] Lemma pool_quicksort٠main₁spec pool ctx scope arr xs :
    {{{
      pool۰context pool ctx scope
      array۰model arr (DfracOwn 1) (#*@{Z} xs)
    }}}
      pool_quicksort٠main₁ ctx arr
    {{{
      RET ();
      pool۰context pool ctx scope
      pool۰consumer pool (
         xs',
        xs ≡ₚ xs'
        StronglySorted (≤)%Z xs'
        array۰model arr (DfracOwn 1) (#*@{Z} xs')
      )
    }}}.

  Lemma pool_quicksort٠mainspec (num_dom : nat) arr xs :
    {{{
      array۰model arr (DfracOwn 1) (#*@{Z} xs)
    }}}
      pool_quicksort٠main #num_dom arr
    {{{
      xs'
    , RET ();
      xs ≡ₚ xs'
      StronglySorted (≤)%Z xs'
      array۰model arr (DfracOwn 1) (#*@{Z} xs')
    }}}.
End pool۰G.

Require examples.pool_quicksort__opaque.