proposition: Lemma r_get_put_swap : ∀ ℓ ℓ' v, ℓ' != ℓ → ⊢ ⦃ λ '(h₀, h₁), h₀ = h₁ ⦄ x ← get ℓ' ;; #put ℓ := v ;; ret x ≈ #put ℓ := v ;; x ← get ℓ' ;; ret x ⦃ eq ⦄.
proof: Proof. intros ℓ ℓ' v ne. eapply from_sem_jdg. intros [s₀ s₁]. hnf. intro P. hnf. intros [hpre hpost]. simpl repr. Opaque get_heap. simpl. Transparent get_heap. eexists (dunit (_, _)). split. - unfold coupling. split. + unfold lmg. unfold dfst. unfold SDistr_unit. apply distr_ext. intro. rewrite dlet_unit. cbn - [get_heap]. reflexivity. + unfold rmg. unfold dsnd. unfold SDistr_unit. apply distr_ext. intro. rewrite dlet_unit. cbn - [get_heap]. reflexivity. - intros [] [] hh. eapply hpost. rewrite dunit1E in hh. lazymatch type of hh with | context [ ?x == ?y ] => destruct (x == y) eqn:e end. 2:{ rewrite e in hh. simpl in hh. rewrite order.Order.POrderTheory.ltxx in hh. discriminate. } move: e => /eqP e. noconf e. subst. f_equal. apply get_heap_set_heap. auto. Qed.
imports: Coq(Utf8) Relational(OrderEnrichedCategory OrderEnrichedRelativeMonadExamples) mathcomp(ssrnat ssreflect ssrfun ssrbool ssrnum eqtype choice reals distr seq all_algebra fintype realsum) extructures(ord fset fmap) Mon(SPropBase) Crypt(Prelude Axioms ChoiceAsOrd SubDistr Couplings RulesStateProb UniformStateProb UniformDistrLemmas StateTransfThetaDens StateTransformingLaxMorph choice_type pkg_core_definition pkg_notation pkg_tactics pkg_composition pkg_heap pkg_semantics pkg_lookup pkg_advantage pkg_invariants pkg_distr) Equations.Prop.DepElim Equations(Equations) Crypt(FreeProbProg)