Commit 67d0a0ab by Dan Frumin

### Introduce a single typeclass for logical state for logical relations

parent c61b7c2a
 From iris.program_logic Require Export weakestpre adequacy. From iris_logrel.F_mu_ref_conc Require Export rules. From iris.algebra Require Import auth. From iris.proofmode Require Import tactics. Set Default Proof Using "Type". Class heapPreG Σ := HeapPreG { heap_preG_iris :> invPreG Σ; heap_preG_heap :> gen_heapPreG loc val Σ }. Definition heapΣ : gFunctors := #[invΣ; gen_heapΣ loc val]. Instance subG_heapPreG {Σ} : subG heapΣ Σ → heapPreG Σ. Proof. solve_inG. Qed. Definition heap_adequacy Σ `{heapPreG Σ} e σ φ : (∀ `{heapG Σ}, True ⊢ WP e {{ v, ⌜φ v⌝ }}) → adequate e σ φ. Proof. intros Hwp; eapply (wp_adequacy _ _); iIntros (?) "". iMod (own_alloc (● to_gen_heap σ)) as (γ) "Hh". { apply: auth_auth_valid. exact: to_gen_heap_valid. } iModIntro. iExists (λ σ, own γ (● to_gen_heap σ)); iFrame. set (Hheap := GenHeapG loc val Σ _ _ _ γ). iApply (Hwp (HeapG _ _ _)). Qed.
 ... ... @@ -228,7 +228,7 @@ Ltac fold_interp := end. Section bin_log_related_under_typed_ctx. Context `{heapIG Σ, cfgSG Σ}. Context `{logrelG Σ}. Ltac fundamental := try (solve_ndisj); ... ...
 ... ... @@ -29,7 +29,7 @@ Definition FG_counter : expr := (FG_increment "x", counter_read "x"). Section CG_Counter. Context `{heapIG Σ, cfgSG Σ}. Context `{logrelG Σ}. (* Coarse-grained increment *) Lemma CG_increment_type Γ : ... ... @@ -314,12 +314,6 @@ Theorem counter_ctx_refinement : ∅ ⊨ FG_counter ≤ctx≤ CG_counter : TProd (TArrow TUnit TUnit) (TArrow TUnit TNat). Proof. set (Σ := #[invΣ ; gen_heapΣ loc val ; authΣ cfgUR ]). set (HG := HeapPreIG Σ _ _). eapply (logrel_ctxequiv Σ _). (* TODO: how to get rid of this bullshit with closed conditions? *) rewrite /FG_counter /CG_counter; try solve_closed. rewrite /FG_counter /CG_counter; try solve_closed. Transparent newlock. unfold newlock. solve_closed. intros. apply FG_CG_counter_refinement. eapply (logrel_ctxequiv logrelΣ); [solve_closed.. | intros ]. apply FG_CG_counter_refinement. Qed.
 ... ... @@ -17,7 +17,7 @@ Definition earlyChoice : val := λ: "x", let: "r" := rand #() in "x" <- #n 0;; "r". Section Refinement. Context `{heapIG Σ, cfgSG Σ}. Context `{logrelG Σ}. Definition choiceN : namespace := nroot .@ "choice". ... ...
 ... ... @@ -52,8 +52,7 @@ Qed. Hint Resolve with_lock_type : typeable. Section proof. Context `{cfgSG Σ}. Context `{heapIG Σ}. Context `{logrelG Σ}. Variable (E1 E2 : coPset). Lemma steps_newlock ρ j K ... ...
 ... ... @@ -29,7 +29,7 @@ Qed. Hint Resolve par_type : typeable. Section compatibility. Context `{heapIG Σ, cfgSG Σ}. Context `{logrelG Σ}. Lemma bin_log_related_par Γ E e1 e2 e1' e2' τ1 τ2 : ↑specN ⊆ E → ... ...
 ... ... @@ -5,7 +5,7 @@ From iris.base_logic Require Export big_op. From iris.program_logic Require Import ectx_lifting. Section fundamental. Context `{heapIG Σ, cfgSG Σ}. Context `{logrelG Σ}. Notation D := (prodC valC valC -n> iProp Σ). Implicit Types e : expr. Implicit Types Δ : listC D. ... ...
 ... ... @@ -25,7 +25,7 @@ Ltac inv_head_step := end. Section hax. Context `{heapIG Σ, cfgSG Σ}. Context `{logrelG Σ}. Notation D := (prodC valC valC -n> iProp Σ). Implicit Types Δ : listC D. ... ...
 ... ... @@ -38,7 +38,7 @@ Definition logN : namespace := nroot .@ "logN". (** interp : is a unary logical relation. *) Section logrel. Context `{heapIG Σ, cfgSG Σ}. Context `{logrelG Σ}. Notation D := (prodC valC valC -n> iProp Σ). Implicit Types τi : D. Implicit Types Δ : listC D. ... ... @@ -372,7 +372,7 @@ Notation "⟦ τ ⟧ₑ" := (interp_expr ⊤ ⊤ ⟦ τ ⟧). Notation "⟦ Γ ⟧*" := (interp_env Γ). Section bin_log_def. Context `{heapIG Σ, cfgSG Σ}. Context `{logrelG Σ}. Notation D := (prodC valC valC -n> iProp Σ). Definition bin_log_related_def (E1 E2 : coPset) (Γ : stringmap type) (e e' : expr) (τ : type) : iProp Σ := (∀ Δ (vvs : stringmap (val * val)) ρ, ... ...