Theory Gossip_Broadcast
section ‹Formalization of the Gossip-Broadcast›
theory Gossip_Broadcast
imports "../Discrete_Time_Markov_Chain"
begin
lemma inj_on_upd_PiE:
assumes "i ∉ I" shows "inj_on (λ(x,f). f(i := x)) (M × (Π⇩E i∈I. A i))"
unfolding PiE_def
proof (safe intro!: inj_onI ext)
fix f g :: "'a ⇒ 'b" and x y :: 'b
assume *: "f(i := x) = g(i := y)" "f ∈ extensional I" "g ∈ extensional I"
then show "x = y" by (auto simp: fun_eq_iff split: if_split_asm)
fix i' from * ‹i ∉ I› show "f i' = g i'"
by (cases "i' = i") (auto simp: fun_eq_iff extensional_def split: if_split_asm)
qed
lemma sum_folded_product:
fixes I :: "'i set" and f :: "'s ⇒ 'i ⇒ 'a::{semiring_0, comm_monoid_mult}"
assumes "finite I" "⋀i. i ∈ I ⟹ finite (S i)"
shows "(∑x∈Pi⇩E I S. ∏i∈I. f (x i) i) = (∏i∈I. ∑s∈S i. f s i)"
using assms proof (induct I)
case empty then show ?case by simp
next
case (insert i I)
have *: "Pi⇩E (insert i I) S = (λ(x, f). f(i := x)) ` (S i × Pi⇩E I S)"
by (auto simp: PiE_def intro!: image_eqI ext dest: extensional_arb)
have "(∑x∈Pi⇩E (insert i I) S. ∏i∈insert i I. f (x i) i) =
sum ((λx. ∏i∈insert i I. f (x i) i) ∘ ((λ(x, f). f(i := x)))) (S i × Pi⇩E I S)"
unfolding * using insert by (intro sum.reindex) (auto intro!: inj_on_upd_PiE)
also have "… = (∑(a, x)∈(S i × Pi⇩E I S). f a i * (∏i∈I. f (x i) i))"
using insert by (force intro!: sum.cong prod.cong arg_cong2[where f="(*)"])
also have "… = (∑a∈S i. f a i * (∑x∈Pi⇩E I S. ∏i∈I. f (x i) i))"
by (simp add: sum.cartesian_product sum_distrib_left)
finally show ?case
using insert by (simp add: sum_distrib_right)
qed
subsection ‹Definition of the Gossip-Broadcast›