Library zoo_std.condition
Require Import zoo.prelude.
Require Import zoo.base.
Require Export zoo_std.mutex.
Require Export zoo_std.condition__code.
Require Import zoo_std.condition__types.
Require Import zoo.options.
Implicit Type b : bool.
Implicit Type t pred : val.
Section mutex۰G.
Context `{mutex۰G : MutexG Σ}.
Definition condition۰inv t : iProp Σ :=
True.
#[global] Instance condition۰invーpersistent t :
Persistent (condition۰inv t).
Lemma condition٠createーspec :
{{{
True
}}}
condition٠create ()
{{{
t
, RET t;
condition۰inv t
}}}.
Lemma condition٠createーdiaspec :
DIASPEC
{{
True
}}
condition٠create ()
{{ t,
RET t;
condition۰inv t
}}.
Lemma condition٠notifyーspec t :
{{{
condition۰inv t
}}}
condition٠notify t
{{{
RET ();
True
}}}.
Lemma condition٠notifyーdiaspec t :
DIASPEC
{{
condition۰inv t
}}
condition٠notify t
{{
RET ();
True
}}.
Lemma condition٠notify_allーspec t :
{{{
condition۰inv t
}}}
condition٠notify_all t
{{{
RET ();
True
}}}.
#[global] Instance condition٠notify_allーdiaspec t :
DIASPEC
{{
condition۰inv t
}}
condition٠notify_all t
{{
RET ();
True
}}.
Lemma condition٠waitーspec t mtx P :
{{{
condition۰inv t ∗
mutex۰inv mtx P ∗
mutex۰locked mtx ∗
P
}}}
condition٠wait t mtx
{{{
RET ();
mutex۰locked mtx ∗
P
}}}.
Lemma condition٠waitーdiaspec t mtx P :
DIASPEC
{{
condition۰inv t ∗
mutex۰inv mtx P ∗
mutex۰locked mtx ∗
P
}}
condition٠wait t mtx
{{
RET ();
mutex۰locked mtx ∗
P
}}.
Lemma condition٠wait_untilーspec' Ψ t mtx pred P :
{{{
condition۰inv t ∗
mutex۰inv mtx P ∗
mutex۰locked mtx ∗
P ∗
Ψ false ∗
□ (
mutex۰locked mtx -∗
P -∗
Ψ false -∗
WP pred () {{ res,
∃ b,
⌜res = #b⌝ ∗
mutex۰locked mtx ∗
(if b then True else P) ∗
Ψ b
}}
)
}}}
condition٠wait_until t mtx pred
{{{
RET ();
mutex۰locked mtx ∗
Ψ true
}}}.
Lemma condition٠wait_untilーspec Ψ t mtx pred P :
{{{
condition۰inv t ∗
mutex۰inv mtx P ∗
mutex۰locked mtx ∗
P ∗
Ψ false ∗
□ (
mutex۰locked mtx -∗
P -∗
Ψ false -∗
WP pred () {{ res,
∃ b,
⌜res = #b⌝ ∗
mutex۰locked mtx ∗
P ∗
Ψ b
}}
)
}}}
condition٠wait_until t mtx pred
{{{
RET ();
mutex۰locked mtx ∗
P ∗
Ψ true
}}}.
Lemma condition٠wait_whileーspec' Ψ t mtx pred P :
{{{
condition۰inv t ∗
mutex۰inv mtx P ∗
mutex۰locked mtx ∗
P ∗
Ψ true ∗
□ (
mutex۰locked mtx -∗
P -∗
Ψ true -∗
WP pred () {{ res,
∃ b,
⌜res = #b⌝ ∗
mutex۰locked mtx ∗
(if b then P else True) ∗
Ψ b
}}
)
}}}
condition٠wait_while t mtx pred
{{{
RET ();
mutex۰locked mtx ∗
Ψ false
}}}.
Lemma condition٠wait_whileーspec Ψ t mtx pred P :
{{{
condition۰inv t ∗
mutex۰inv mtx P ∗
mutex۰locked mtx ∗
P ∗
Ψ true ∗
□ (
mutex۰locked mtx -∗
P -∗
Ψ true -∗
WP pred () {{ res,
∃ b,
⌜res = #b⌝ ∗
mutex۰locked mtx ∗
P ∗
Ψ b
}}
)
}}}
condition٠wait_while t mtx pred
{{{
RET ();
mutex۰locked mtx ∗
P ∗
Ψ false
}}}.
End mutex۰G.
Require zoo_std.condition__opaque.
#[global] Opaque condition۰inv.
Require Import zoo.base.
Require Export zoo_std.mutex.
Require Export zoo_std.condition__code.
Require Import zoo_std.condition__types.
Require Import zoo.options.
Implicit Type b : bool.
Implicit Type t pred : val.
Section mutex۰G.
Context `{mutex۰G : MutexG Σ}.
Definition condition۰inv t : iProp Σ :=
True.
#[global] Instance condition۰invーpersistent t :
Persistent (condition۰inv t).
Lemma condition٠createーspec :
{{{
True
}}}
condition٠create ()
{{{
t
, RET t;
condition۰inv t
}}}.
Lemma condition٠createーdiaspec :
DIASPEC
{{
True
}}
condition٠create ()
{{ t,
RET t;
condition۰inv t
}}.
Lemma condition٠notifyーspec t :
{{{
condition۰inv t
}}}
condition٠notify t
{{{
RET ();
True
}}}.
Lemma condition٠notifyーdiaspec t :
DIASPEC
{{
condition۰inv t
}}
condition٠notify t
{{
RET ();
True
}}.
Lemma condition٠notify_allーspec t :
{{{
condition۰inv t
}}}
condition٠notify_all t
{{{
RET ();
True
}}}.
#[global] Instance condition٠notify_allーdiaspec t :
DIASPEC
{{
condition۰inv t
}}
condition٠notify_all t
{{
RET ();
True
}}.
Lemma condition٠waitーspec t mtx P :
{{{
condition۰inv t ∗
mutex۰inv mtx P ∗
mutex۰locked mtx ∗
P
}}}
condition٠wait t mtx
{{{
RET ();
mutex۰locked mtx ∗
P
}}}.
Lemma condition٠waitーdiaspec t mtx P :
DIASPEC
{{
condition۰inv t ∗
mutex۰inv mtx P ∗
mutex۰locked mtx ∗
P
}}
condition٠wait t mtx
{{
RET ();
mutex۰locked mtx ∗
P
}}.
Lemma condition٠wait_untilーspec' Ψ t mtx pred P :
{{{
condition۰inv t ∗
mutex۰inv mtx P ∗
mutex۰locked mtx ∗
P ∗
Ψ false ∗
□ (
mutex۰locked mtx -∗
P -∗
Ψ false -∗
WP pred () {{ res,
∃ b,
⌜res = #b⌝ ∗
mutex۰locked mtx ∗
(if b then True else P) ∗
Ψ b
}}
)
}}}
condition٠wait_until t mtx pred
{{{
RET ();
mutex۰locked mtx ∗
Ψ true
}}}.
Lemma condition٠wait_untilーspec Ψ t mtx pred P :
{{{
condition۰inv t ∗
mutex۰inv mtx P ∗
mutex۰locked mtx ∗
P ∗
Ψ false ∗
□ (
mutex۰locked mtx -∗
P -∗
Ψ false -∗
WP pred () {{ res,
∃ b,
⌜res = #b⌝ ∗
mutex۰locked mtx ∗
P ∗
Ψ b
}}
)
}}}
condition٠wait_until t mtx pred
{{{
RET ();
mutex۰locked mtx ∗
P ∗
Ψ true
}}}.
Lemma condition٠wait_whileーspec' Ψ t mtx pred P :
{{{
condition۰inv t ∗
mutex۰inv mtx P ∗
mutex۰locked mtx ∗
P ∗
Ψ true ∗
□ (
mutex۰locked mtx -∗
P -∗
Ψ true -∗
WP pred () {{ res,
∃ b,
⌜res = #b⌝ ∗
mutex۰locked mtx ∗
(if b then P else True) ∗
Ψ b
}}
)
}}}
condition٠wait_while t mtx pred
{{{
RET ();
mutex۰locked mtx ∗
Ψ false
}}}.
Lemma condition٠wait_whileーspec Ψ t mtx pred P :
{{{
condition۰inv t ∗
mutex۰inv mtx P ∗
mutex۰locked mtx ∗
P ∗
Ψ true ∗
□ (
mutex۰locked mtx -∗
P -∗
Ψ true -∗
WP pred () {{ res,
∃ b,
⌜res = #b⌝ ∗
mutex۰locked mtx ∗
P ∗
Ψ b
}}
)
}}}
condition٠wait_while t mtx pred
{{{
RET ();
mutex۰locked mtx ∗
P ∗
Ψ false
}}}.
End mutex۰G.
Require zoo_std.condition__opaque.
#[global] Opaque condition۰inv.