proposition: Lemma rswap_cmd : ∀ (A₀ A₁ B : choiceType) (post : postcond B B) (c₀ : command A₀) (c₁ : command A₁) (r : A₀ → A₁ → raw_code B), (∀ b, post b b) → (∀ a₀ a₁, ⊢ ⦃ λ '(s₁, s₀), s₀ = s₁ ⦄ r a₀ a₁ ≈ r a₀ a₁ ⦃ post ⦄) → ⊢ ⦃ λ '(h₀, h₁), h₀ = h₁ ⦄ a₀ ← cmd c₀ ;; a₁ ← cmd c₁ ;; ret (a₀, a₁) ≈ a₁ ← cmd c₁ ;; a₀ ← cmd c₀ ;; ret (a₀, a₁) ⦃ eq ⦄ → ⊢ ⦃ λ '(h₀, h₁), h₀ = h₁ ⦄ a₀ ← cmd c₀ ;; a₁ ← cmd c₁ ;; r a₀ a₁ ≈ a₁ ← cmd c₁ ;; a₀ ← cmd c₀ ;; r a₀ a₁ ⦃ post ⦄.
proof: Proof. intros A₀ A₁ B post c₀ c₁ r hpost hr h. eapply from_sem_jdg. repeat setoid_rewrite repr_cmd_bind. eapply (swap_ruleR (λ a₀ a₁, repr (r a₀ a₁)) (repr_cmd c₀) (repr_cmd c₁)). - intros a₀ a₁. eapply to_sem_jdg. eapply hr. - intros ? ? []. eauto. - intro s. unshelve eapply coupling_eq. + exact: (λ '(h1, h2), h1 = h2). + eapply to_sem_jdg in h. repeat (setoid_rewrite repr_cmd_bind in h). auto. + 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)