@@ -25,8 +25,6 @@ Section prng_logrel.
2525 Context {A : ofe}.
2626 Variable (P : A -n> iProp).
2727
28- Definition prng_logrel_NS : namespace := nroot .@ "prng-logrel".
29-
3028 (* expr_pred: gitree value predicate -> gitree predicate *)
3129 Local Notation expr_pred := (expr_pred s rs P).
3230
@@ -53,7 +51,6 @@ Section prng_logrel.
5351 (* subst_valid: (S : Names) (Γ : Context S) -> interptation of Γ -> iProp *)
5452 Notation ssubst_valid := (ssubst_valid1 rs ty val_pred expr_pred).
5553
56- (* we made [Tprng] persistent by wrapping the [pointsto]/[has_prng_state] predicate in an invariant *)
5754 #[global] Instance prng_lang_val_pred_persist τ βv : Persistent (val_pred τ βv).
5855 Proof . induction τ; try apply _. Qed .
5956
@@ -300,7 +297,7 @@ Local Definition rs : gReifiers NotCtxDep _ := gReifiers_cons reify_prng gReifie
300297
301298#[local] Parameter Hdisj : ∀ (Σ : gFunctors) (P Q : iProp Σ), disjunction_property P Q.
302299
303- Program Definition InputLangGitreeGS {R} `{!Cofe R}
300+ Program Definition PrngLangGitreeGS {R} `{!Cofe R}
304301 {a : is_ctx_dep} {n} (rs : gReifiers a n)
305302 (Σ : gFunctors)
306303 (H1 : invGS Σ) (H2 : stateG rs R Σ)
@@ -324,18 +321,16 @@ Next Obligation.
324321 - by iDestruct "H" as "(_ & ?)".
325322Qed .
326323
327- (* TODO: adeequacy and safety proof for the PRNG lang
328- adapt the proofs for input-lang.
329- *)
324+ (* XXX: need this command to typecheck [β ≡ Err e] *)
325+ Open Scope stdpp.
330326
331- (*
332- Lemma logpred_adequacy cr Σ R
333- `{!Cofe R, !SubOfe natO R, !SubOfe logO R, !SubOfe unitO R}
327+ Lemma logpred_adequacy (cr : nat) Σ R
328+ `{!Cofe R, !SubOfe natO R, !SubOfe unitO R, !SubOfe locO R}
334329 `{!invGpreS Σ} `{!statePreG rs R Σ} `{!prngPreG Σ}
335330 (τ : ty)
336331 (α : interp_scope ∅ -n> IT (gReifiers_ops rs) R)
337332 (β : IT (gReifiers_ops rs) R) st st' k :
338- (∀ `{H1 : !gitreeGS_gen rs R Σ},
333+ (∀ `{H1 : !gitreeGS_gen rs R Σ} `{H2 : !prngG Σ} ,
339334 (£ cr ⊢ valid1 rs notStuck (λne _ : unitO, True)%I □ α τ)%I) →
340335 external_steps (gReifiers_sReifier rs) (α ı_scope) st β st' [] k →
341336 is_Some (IT_to_V β)
@@ -346,9 +341,10 @@ Proof.
346341 eapply (wp_progress_gen Σ 1 NotCtxDep rs (S cr) (λ x, x) notStuck
347342 [] k (α ı_scope) β st st' Hdisj Hst).
348343 intros H1 H2.
349- pose H3 : gitreeGS_gen rs R Σ := InputLangGitreeGS rs Σ H1 H2.
344+ pose H3 : gitreeGS_gen rs R Σ := PrngLangGitreeGS rs Σ H1 H2.
350345 simpl in H3.
351- exists (val_pred (s:=notStuck) (P:=(λne _:unitO, True)) τ)%I. split.
346+ exists (λ _, True)%I. split.
347+ (*exists (val_pred (s:=notStuck) (P:=(λne _:unitO, True)) τ)%I. split.*)
352348 { apply _. }
353349 iExists (@state_interp_fun _ _ rs _ _ _ H3).
354350 iExists (@aux_interp_fun _ _ rs _ _ _ H3).
@@ -360,7 +356,6 @@ Proof.
360356 simpl.
361357 iAssert (True%I) as "G"; first done; iFrame "G"; iClear "G".
362358 iModIntro. iIntros "((Hone & Hcr) & Hst)".
363- iPoseProof (Hlog H3 with "Hcr") as "Hlog".
364359 destruct st as [σ []].
365360 iAssert (has_substate σ) with "[Hst]" as "Hs".
366361 {
@@ -379,32 +374,44 @@ Proof.
379374 rewrite (eq_pi _ _ Heq eq_refl)//.
380375 }
381376 iApply fupd_wp.
382- iMod (inv_alloc (nroot.@"ioE") _
383- (∃ σ,
377+ iMod (new_prngG σ) as (H4) "Hprng".
378+ iMod (inv_alloc (nroot.@"prngE") _
379+ (∃ σ : state,
384380 £ 1 ∗ has_substate (σ : oFunctor_car
385- (sReifier_state reify_io )
381+ (sReifier_state reify_prng )
386382 (IT (sReifier_ops (gReifiers_sReifier rs)) R)
387- (IT (sReifier_ops (gReifiers_sReifier rs)) R)))%I
388- with "[Hone Hs]") as "#Hinv".
389- {
390- iNext. iExists σ.
391- iFrame "Hone Hs".
392- }
393- iSpecialize ("Hlog" with "Hinv []").
383+ (IT (sReifier_ops (gReifiers_sReifier rs)) R))
384+ ∗ has_prngs σ)%I
385+ with "[Hone Hs Hprng]") as "#Hinv".
394386 {
395- iIntros (x).
396- destruct x.
387+ iNext. iExists σ. iFrame.
397388 }
398- iSpecialize ("Hlog" $! tt with "[//]").
399- iApply (wp_wand with"Hlog").
389+ iSimpl in "Hinv".
390+ iPoseProof (Hlog H3 with "Hcr") as "Hlog".
391+ iSpecialize ("Hlog" $! ı_scope).
392+ iSpecialize ("Hlog" with "Hinv").
393+ iAssert (ssubst_valid1 rs ty val_pred
394+ (expr_pred notStuck rs (λne _ : unitO, True)%I) □ ı_scope) as "Hvalid".
395+ {
396+ by iIntros "%Hempty".
397+ }
398+ iSpecialize ("Hlog" with "Hvalid").
399+ iSpecialize ("Hlog" $! () I).
400+ iApply (wp_wand with "Hlog").
400401 iModIntro.
401- iIntros ( βv). simpl. iDestruct 1 as (_) "[H _] ".
402- by iFrame .
402+ iIntros (βv) "_ ".
403+ done .
403404Qed .
404405
405- Lemma prng_lang_safety e τ σ st' (β : IT (sReifier_ops (gReifiers_sReifier rs)) natO) k :
406+ Let R := sumO natO (sumO unitO locO).
407+ Let sRef := gReifiers_sReifier rs.
408+ Let sOps := sReifier_ops sRef.
409+ Let IT := IT sOps R.
410+ Let fullState := sReifier_state sRef ♯ IT.
411+
412+ Lemma prng_lang_safety e τ (st st' : fullState) (β : IT) k :
406413 typed □ e τ →
407- external_steps (gReifiers_sReifier rs) (interp_expr rs e ı_scope) (σ, ()) β st' [] k →
414+ external_steps (gReifiers_sReifier rs) (interp_expr rs e ı_scope) st β st' [] k →
408415 is_Some (IT_to_V β)
409416 ∨ (∃ β1 st1 l, external_step (gReifiers_sReifier rs) β st' β1 st1 l).
410417Proof .
@@ -418,15 +425,14 @@ Proof.
418425 - by right.
419426 - done.
420427 }
421- pose (Σ:=#[invΣ;stateΣ rs natO]).
422- assert (invGpreS Σ).
423- { apply _. }
424- assert (statePreG rs natO Σ).
425- { apply _. }
428+ pose (Σ:=#[invΣ;stateΣ rs R;prngΣ]).
429+ assert (invGpreS Σ) by apply _.
430+ assert (statePreG rs R Σ) by apply _.
431+ assert (prngPreG Σ) by apply _.
426432 eapply (logpred_adequacy 0 Σ); eauto.
427- intros ?. iIntros "_".
433+ intros ?? . iIntros "_".
428434 by iApply fundamental.
429435Qed .
430436
431- *)
432437End safety_adeqaucy.
438+ Print Assumptions prng_lang_safety.
0 commit comments