proposition: Lemma rsamplerC : ∀ {A : ord_choiceType} (o : Op) (c : raw_code A), ⊢ ⦃ λ '(h₀, h₁), h₀ = h₁ ⦄ a ← c ;; r ← (r ← sample o ;; ret r) ;; ret (a, r) ≈ r ← (r ← sample o ;; ret r) ;; a ← c ;; ret (a, r) ⦃ eq ⦄.
proof: Proof. intros A o c. eapply rrewrite_eqDistrL. - eapply rreflexivity_rule. - intro s. assert ( repr_sample_c : repr (r ← (r ← sample o ;; ret r) ;; a ← c ;; ret (a, r)) = bindrFree (spl o) (λ r, bindrFree (repr c) (λ a, retrFree (a,r))) ). { rewrite !repr_bind. f_equal. extensionality r. rewrite !repr_bind. reflexivity. } assert ( repr_c_sample : repr (a ← c ;; r ← (r ← sample o ;; ret r) ;; ret (a, r)) = bindrFree (repr c) (λ a, bindrFree (spl o) (λ r, retrFree (a,r))) ). { rewrite repr_bind. reflexivity. } rewrite repr_c_sample repr_sample_c. pose proof (sample_c_is_c_sample o (repr c) s) as hlp. unfold sample_c in hlp. unfold c_sample in hlp. apply hlp. 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)