From ec27d524299589023710cf9d051c9d89d56b651b Mon Sep 17 00:00:00 2001 From: Ralf Jung <jung@mpi-sws.org> Date: Sun, 3 Mar 2019 15:34:01 +0100 Subject: [PATCH] add test with a closed proof --- tests/one_shot.ref | 1 + tests/one_shot.v | 35 ++++++++++++++++++++++++++++++++++- theories/algebra/ofe.v | 1 + 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/one_shot.ref b/tests/one_shot.ref index 08d4ddb27..c06e1621c 100644 --- a/tests/one_shot.ref +++ b/tests/one_shot.ref @@ -40,3 +40,4 @@ | InjR "m" => assert: #m = "m" end {{ _, True }} +Closed under the global context diff --git a/tests/one_shot.v b/tests/one_shot.v index 37fcbef63..a71159b6a 100644 --- a/tests/one_shot.v +++ b/tests/one_shot.v @@ -1,8 +1,9 @@ From iris.program_logic Require Export weakestpre hoare. From iris.heap_lang Require Export lang. From iris.algebra Require Import excl agree csum. -From iris.heap_lang Require Import assert proofmode notation. +From iris.heap_lang Require Import assert proofmode notation adequacy. From iris.proofmode Require Import tactics. +From iris.heap_lang.lib Require Import par. Set Default Proof Using "Type". Definition one_shot_example : val := λ: <>, @@ -95,3 +96,35 @@ Proof. - iIntros "!# _". wp_apply (wp_wand with "Hf2"). by iIntros (v) "#? !# _". Qed. End proof. + +(* Have a client with a closed proof. *) +Definition client : expr := + let: "ff" := one_shot_example #() in + (Fst "ff" #5 ||| let: "check" := Snd "ff" #() in "check" #()). + +Section client. + Local Set Default Proof Using "Type*". + Context `{!heapG Σ, !one_shotG Σ, !spawnG Σ}. + + Lemma client_safe : WP client {{ _, True }}%I. + Proof. + rewrite /client. wp_apply wp_one_shot. iIntros (f1 f2) "[#Hf1 #Hf2]". + wp_let. wp_apply wp_par. + - wp_apply "Hf1". + - wp_proj. wp_bind (f2 _)%E. iApply wp_wand; first by iExact "Hf2". + iIntros (check) "Hcheck". wp_pures. iApply "Hcheck". + - auto. + Qed. +End client. + +(** Put together all library functors. *) +Definition clientΣ : gFunctors := #[ heapΣ; one_shotΣ; spawnΣ ]. +(** This lemma implicitly shows that these functors are enough to meet +all library assumptions. *) +Lemma client_adequate σ : adequate NotStuck client σ (λ _ _, True). +Proof. apply (heap_adequacy clientΣ)=> ?. apply client_safe. Qed. + +(* Since we check the output of the test files, this means +our test suite will fail if we ever accidentally add an axiom +to anything used by this proof. *) +Print Assumptions client_adequate. diff --git a/theories/algebra/ofe.v b/theories/algebra/ofe.v index 536fbbc6c..f7672c263 100644 --- a/theories/algebra/ofe.v +++ b/theories/algebra/ofe.v @@ -683,6 +683,7 @@ Bind Scope cFunctor_scope with cFunctor. Class cFunctorContractive (F : cFunctor) := cFunctor_contractive A1 A2 B1 B2 :> Contractive (@cFunctor_map F A1 A2 B1 B2). +Hint Mode cFunctorContractive ! : typeclass_instances. Definition cFunctor_diag (F: cFunctor) (A: ofeT) : ofeT := cFunctor_car F A A. Coercion cFunctor_diag : cFunctor >-> Funclass. -- GitLab