proposition: Theorem rswap_ruleR : ∀ {A₀ A₁ B : ord_choiceType} {post : postcond B B} (c₀ : raw_code A₀) (c₁ : raw_code A₁) (r : A₀ → A₁ → raw_code B), (∀ b b', b = b' → post b b') → (∀ a₀ a₁, ⊢ ⦃ λ '(s₁, s₀), s₀ = s₁ ⦄ r a₀ a₁ ≈ r a₀ a₁ ⦃ post ⦄) → ⊢ ⦃ λ '(h₀, h₁), h₀ = h₁ ⦄ a₀ ← c₀ ;; a₁ ← c₁ ;; ret (a₀, a₁) ≈ a₁ ← c₁ ;; a₀ ← c₀ ;; ret (a₀, a₁) ⦃ eq ⦄ → ⊢ ⦃ λ '(h₀, h₁), h₀ = h₁ ⦄ a₀ ← c₀ ;; a₁ ← c₁ ;; r a₀ a₁ ≈ a₁ ← c₁ ;; a₀ ← c₀ ;; r a₀ a₁ ⦃ post ⦄.
proof: Proof. intros A₀ A₁ B post c₀ c₁ r postr hr h. eapply from_sem_jdg. repeat setoid_rewrite repr_bind. simpl. eapply (swap_ruleR (λ a₀ a₁, repr (r a₀ a₁)) (repr c₀) (repr c₁)). - intros. eapply to_sem_jdg. apply hr. - apply postr. - intro s. unshelve eapply coupling_eq. + exact (λ '(h₀, h₁), h₀ = h₁). + eapply to_sem_jdg in h. repeat setoid_rewrite repr_bind in h. apply h. + 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)