Theory Crowds_Protocol
section ‹Formalization of the Crowds-Protocol›
theory Crowds_Protocol
imports "../Discrete_Time_Markov_Chain"
begin
lemma cond_prob_nonneg[simp]: "0 ≤ cond_prob M A B"
by (auto simp: cond_prob_def)
lemma (in MC_syntax) emeasure_suntil_geometric:
assumes [measurable]: "Measurable.pred S P"
assumes "s ∈ X" and *[simp]: "0 ≤ p" "0 ≤ r"
assumes r: "⋀s. s ∈ X ⟹ emeasure (T s) {ω∈space (T s). P ω} = ennreal r"
assumes p: "⋀s. s ∈ X ⟹ emeasure (K s) X = ennreal p" "p < 1"
assumes "⋀t. AE ω in T t. ¬ (P ⊓ (HLD X ⊓ nxt (HLD X suntil P))) ω"
shows "emeasure (T s) {ω∈space (T s). (HLD X suntil P) ω} = r / (1 - p)"
proof (subst emeasure_suntil_disj)
let ?F = "λF s. emeasure (T s) {ω ∈ space (T s). P ω} + ∫⇧+ t. F t * indicator X t ∂K s"
let ?f = "λx. ennreal r + ennreal p * x"
have "mono ?F" "mono ?f"
by (auto intro!: monoI max.mono add_mono nn_integral_mono mult_left_mono mult_right_mono simp: le_fun_def)
have 1: "lfp ?f ≤ lfp ?F s"
using ‹s ∈ X›
proof (induction arbitrary: s rule: lfp_ordinal_induct[OF ‹mono ?f›])
case step: (1 x)
then have "?f x ≤ ?F (λ_. x) s"
by (auto simp: p r[simplified] nn_integral_cmult mult.commute[of _ x]
intro!: add_mono mult_right_mono)
also have "?F (λ_. x) ≤ ?F (lfp ?F)"
using step
by (intro le_funI add_mono order_refl nn_integral_mono) (auto simp: split: split_indicator)
finally show ?case
by (subst lfp_unfold[OF ‹mono ?F›]) (auto simp: le_fun_def)
qed (auto intro!: Sup_least)
also have 2: "lfp ?F s ≤ r / (1 - p)"
using ‹s ∈ X›
proof (induction arbitrary: s rule: lfp_ordinal_induct[OF ‹mono ?F›])
case (1 S)
with r have "?F S s ≤ ennreal r + (∫⇧+x. ennreal (r / (1 - p)) * indicator X x ∂K s)"
by (intro add_mono nn_integral_mono) (auto split: split_indicator)
also have "… ≤ ennreal r + ennreal (r * p / (1 - p))"
using ‹s ∈ X› by (simp add: nn_integral_cmult_indicator p ennreal_mult''[symmetric])
also have "… = ennreal (r / (1 - p))"
using ‹p < 1› by (simp add: field_simps ennreal_plus[symmetric] del: ennreal_plus)
finally show ?case .
qed (auto intro!: SUP_least)
finally obtain x where x: "lfp ?f = ennreal x" and [simp]: "0 ≤ x"
by (cases "lfp ?f") (auto simp: top_unique)
from ‹p < 1› have "⋀x. x = r + p * x ⟹ x = r / (1 - p)"
by (auto simp: field_simps)
with lfp_unfold[OF ‹mono ?f›] ‹p < 1› have "lfp ?f = r / (1 - p)"
unfolding x by (auto simp add: ennreal_plus[symmetric] ennreal_mult[symmetric] simp del: ennreal_plus)
with 1 2 show "lfp ?F s = ennreal (r / (1 - p))"
by auto
qed fact+
subsection ‹Definition of the Crowds-Protocol›