proposition: Lemma r_get_swap : ∀ ℓ ℓ', ⊢ ⦃ λ '(h₀, h₁), h₀ = h₁ ⦄ x ← get ℓ ;; y ← get ℓ' ;; ret (x, y) ≈ y ← get ℓ' ;; x ← get ℓ ;; ret (x, y) ⦃ eq ⦄.
proof: Proof. intros ℓ ℓ'. eapply from_sem_jdg. intros [s₀ s₁]. hnf. intro P. hnf. intros [hpre hpost]. simpl. unfold SDistr_carrier. unfold F_choice_prod_obj. simpl. exists (dunit (get_heap s₀ ℓ, get_heap s₀ ℓ', s₀, (get_heap s₁ ℓ, get_heap s₁ ℓ', s₁))). split. - unfold coupling. split. + unfold lmg. unfold dfst. unfold SDistr_unit. apply distr_ext. intro. rewrite dlet_unit. reflexivity. + unfold rmg. unfold dsnd. unfold SDistr_unit. apply distr_ext. intro. rewrite dlet_unit. 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. inversion e. subst. reflexivity. 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)