@@ -333,11 +333,76 @@ Section fundamental.
333333 all: iApply (region_valid_in_regionL with "H"); eauto.
334334 Qed .
335335
336+ Lemma big_sepL_exists {Σ'} `{EqDecision A, Countable A} {B} {P : A -> B -> iProp Σ'} {l : list A} {Hnodup : NoDup l} :
337+ ([∗ list] x ∈ l, ∃ y, P x y)%I ⊣⊢ ∃ m : gmap A B, ⌜ dom m = list_to_set l ⌝ ∗ [∗ map] x ↦ y ∈ m, P x y.
338+ Proof .
339+ induction l; cbn.
340+ - iSplit; iIntros "H"; last done.
341+ iExists ∅; now iSplit.
342+ - rewrite NoDup_cons in Hnodup.
343+ destruct (Hnodup) as [Hal Hnodup'].
344+ specialize (IHl Hnodup').
345+ rewrite IHl.
346+ iSplit.
347+ + iIntros "[(%y & Hy) (%m & %Hm & HPs)]".
348+ iExists (insert a y m).
349+ iSplitR.
350+ { iPureIntro. rewrite (dom_insert_L m a y). now f_equal. }
351+ rewrite big_opM_insert; last (apply not_elem_of_dom; set_solver).
352+ now iFrame.
353+ + iIntros "(%m & %Hm & HPs)".
354+ assert (a ∈ dom m) as Ha by set_solver.
355+ apply elem_of_dom in Ha.
356+ destruct Ha as [y Hay].
357+ rewrite (big_sepM_delete _ m a y Hay).
358+ iDestruct "HPs" as "(HPay & HPs)".
359+ iSplitL "HPay"; first now iExists _.
360+ iExists _; iFrame; iPureIntro.
361+ rewrite dom_delete_L Hm; set_solver.
362+ Qed .
363+
364+ Lemma big_sepS_exists {Σ'} `{EqDecision A, Countable A} {B} {P : A -> B -> iProp Σ'} {l : gset A} :
365+ ([∗ set] x ∈ l, ∃ y, P x y)%I ⊣⊢ ∃ m : gmap A B, ⌜ dom m = l ⌝ ∗ [∗ map] x ↦ y ∈ m, P x y.
366+ Proof .
367+ rewrite big_opS_elements.
368+ rewrite big_sepL_exists; last now apply NoDup_elements.
369+ iSplit; iIntros "(%m & %Heq & HPs)";
370+ iExists m; iFrame; iPureIntro;
371+ now rewrite Heq list_to_set_elements_L.
372+ Qed .
373+
336374 Theorem fundamental' :
337375 (□ custom_enclave_contract_gen) ∗ system_inv ∗ na_own logrel_nais ⊤
338376 ⊢ ([∗ list] r ∈ all_registers, (∃ v, interp v ∗ r ↦ᵣ v)%I) -∗
339377 interp_conf.
340378 Proof .
341379 iIntros "(#Hencs & Hinv & Hnais) Hregs".
342- Admitted .
380+ rewrite <-(big_sepS_list_to_set _ _ all_registers_NoDup).
381+ assert (PC ∈ list_to_set (C := gset RegName) all_registers) as Hpc
382+ by eapply elem_of_list_to_set, all_registers_correct.
383+ rewrite (big_sepS_delete (fun x => ∃ v, interp v ∗ x ↦ᵣ v)%I _ PC Hpc).
384+ iDestruct "Hregs" as "[(%w & Hw & HPC) Hregs]".
385+ rewrite big_sepS_exists.
386+ iDestruct "Hregs" as "(%lregs & %Hlregs & Hlregs)".
387+ rewrite big_sepM_sep.
388+ iDestruct "Hlregs" as "(Hslregs & Hlregs)".
389+ iDestruct (fundamental _ (insert PC (LWInt 0) lregs) with "[$Hencs $Hinv] Hw") as "Hwe".
390+ iApply ("Hwe" with "[$Hnais HPC Hslregs Hlregs]").
391+ iSplitL "Hslregs".
392+ - iSplitR; first iPureIntro.
393+ { intros. cbn. eapply lookup_insert_is_Some'.
394+ destruct (decide (PC = x)); first now left.
395+ right. apply elem_of_dom. rewrite Hlregs.
396+ now set_solver. }
397+ iIntros (r lv HrnPC Hlkp).
398+ rewrite lookup_insert_ne in Hlkp; last done.
399+ iApply (big_sepM_lookup with "Hslregs"); done.
400+ - rewrite insert_insert.
401+ unfold registers_mapsto.
402+ rewrite big_sepM_insert.
403+ now iFrame.
404+ apply not_elem_of_dom.
405+ rewrite Hlregs.
406+ set_solver.
407+ Qed .
343408End fundamental.
0 commit comments