assert.v 703 Bytes
Newer Older
1 2
From iris.program_logic Require Export weakestpre.
From iris.heap_lang Require Export lang.
3 4
From iris.proofmode Require Import tactics.
From iris.heap_lang Require Import proofmode notation.
5
Set Default Proof Using "Type".
6

7
Definition assert : val :=
8
  λ: "v", if: "v" #() then #() else #0 #0. (* #0 #0 is unsafe *)
9 10
(* just below ;; *)
Notation "'assert:' e" := (assert (λ: <>, e))%E (at level 99) : expr_scope.
11

12
Lemma wp_assert `{heapG Σ} E (Φ : val  iProp Σ) e `{!Closed [] e} :
13
  WP e @ E {{ v, v = #true   Φ #() }} - WP assert: e @ E {{ Φ }}.
14
Proof.
15
  iIntros "HΦ". rewrite /assert. wp_let. wp_seq.
Robbert Krebbers's avatar
Robbert Krebbers committed
16
  iApply (wp_wand with "HΦ"). iIntros (v) "[% ?]"; subst. by wp_if.
17
Qed.