proposition: Lemma rswap_bind_cmd_eq : ∀ {A₀ A₁ B : choiceType} c₀ c₁ (r : A₀ → A₁ → raw_code B), ⊢ ⦃ λ '(h₀, h₁), h₀ = h₁ ⦄ a₀ ← c₀ ;; a₁ ← cmd c₁ ;; ret (a₀, a₁) ≈ a₁ ← cmd c₁ ;; a₀ ← c₀ ;; ret (a₀, a₁) ⦃ eq ⦄ → ⊢ ⦃ λ '(h₀, h₁), h₀ = h₁ ⦄ a₀ ← c₀ ;; a₁ ← cmd c₁ ;; r a₀ a₁ ≈ a₁ ← cmd c₁ ;; a₀ ← c₀ ;; r a₀ a₁ ⦃ eq ⦄.
proof: Proof. intros A₀ A₁ B c₀ c₁ r h. apply rsymmetry. apply rsym_pre. 1: auto. eapply rpost_weaken_rule. 1: eapply rswap_cmd_bind_eq. - eapply r_bind with (f₀ := λ '(x, y), ret (y,x)) (f₁ := λ '(x, y), ret (y,x)) in h. 2:{ simpl. intros [] []. eapply rpre_hypothesis_rule. intros ? ? e. noconf e. eapply rpre_weaken_rule. 1: eapply rreflexivity_rule. simpl. intuition subst. reflexivity. } rewrite bind_assoc in h. rewrite bind_cmd_bind in h. setoid_rewrite bind_cmd_bind in h. setoid_rewrite bind_assoc in h. simpl in h. apply rsymmetry. apply rsym_pre. 1: auto. eapply rpost_weaken_rule. 1: eauto. intuition subst. reflexivity. - intuition 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)