Theory Survival_Model
theory Survival_Model
imports "HOL-Library.Rewrite" "HOL-Library.Extended_Nonnegative_Real" "HOL-Library.Extended_Real"
"HOL-Probability.Probability" Preliminaries
begin
section βΉSurvival ModelβΊ
text βΉ
The survival model is built on the probability space βΉπβΊ.
Additionally, the random variable βΉX : space π β ββΊ is introduced,
which represents the age at death.
βΊ
locale prob_space_actuary = MM_PS: prob_space π for π
locale survival_model = prob_space_actuary +
fixes X :: "'a β real"
assumes X_RV[simp]: "MM_PS.random_variable (borel :: real measure) X"
and X_pos_AE[simp]: "AE ΞΎ in π. X ΞΎ > 0"
begin
subsection βΉGeneral Theory of Survival ModelβΊ
interpretation distrX_RD: real_distribution "distr π borel X"
using MM_PS.real_distribution_distr by simp
lemma X_le_event[simp]: "{ΞΎ β space π. X ΞΎ β€ x} β MM_PS.events"
by measurable simp
lemma X_gt_event[simp]: "{ΞΎ β space π. X ΞΎ > x} β MM_PS.events"
by measurable simp
lemma X_compl_le_gt: "space π - {ΞΎ β space π. X ΞΎ β€ x} = {ΞΎ β space π. X ΞΎ > x}" for x::real
proof -
have "space π - {ΞΎ β space π. X ΞΎ β€ x} = space π - (X -` {..x})" by blast
also have "β¦ = (X -` {x<..}) β© space π" using vimage_compl_atMost by fastforce
also have "β¦ = {ΞΎ β space π. X ΞΎ > x}" by blast
finally show ?thesis .
qed
lemma X_compl_gt_le: "space π - {ΞΎ β space π. X ΞΎ > x} = {ΞΎ β space π. X ΞΎ β€ x}" for x::real
using X_compl_le_gt by blast
subsubsection βΉIntroduction of Survival Function for βΉXβΊβΊ
text βΉ
Note that βΉccdf (distr π borel X)βΊ is the survival (distributive) function for βΉXβΊ.
βΊ
lemma ccdfX_0_1: "ccdf (distr π borel X) 0 = 1"
apply (rewrite MM_PS.ccdf_distr_P, simp)
using X_pos_AE MM_PS.prob_space
using MM_PS.prob_Collect_eq_1 X_gt_event by presburger
lemma ccdfX_unborn_1: "ccdf (distr π borel X) x = 1" if "x β€ 0"
proof (rule antisym)
show "ccdf (distr π borel X) x β€ 1" using MM_PS.ccdf_distr_P by simp
show "ccdf (distr π borel X) x β₯ 1"
proof -
have "ccdf (distr π borel X) x β₯ ccdf (distr π borel X) 0"
using finite_borel_measure.ccdf_nonincreasing distrX_RD.finite_borel_measure_M that by simp
also have "ccdf (distr π borel X) 0 = 1" using ccdfX_0_1 that by simp
finally show ?thesis .
qed
qed
definition death_pt :: ereal (βΉ$ΟβΊ)
where "$Ο β‘ Inf (ereal ` {x β β. ccdf (distr π borel X) x = 0})"
lemma psi_nonneg: "$Ο β₯ 0"
unfolding death_pt_def
proof (rule Inf_greatest)
fix x'::ereal
assume "x' β ereal ` {x β β. ccdf (distr π borel X) x = 0}"
then obtain x::real where "x' = ereal x" and "ccdf (distr π borel X) x = 0" by blast
hence "ccdf (distr π borel X) 0 > ccdf (distr π borel X) x" using ccdfX_0_1 X_pos_AE by simp
hence "x β₯ 0"
using mono_invE finite_borel_measure.ccdf_nonincreasing distrX_RD.finite_borel_measure_M X_RV
by (smt(verit))
thus "x' β₯ 0" using βΉx' = ereal xβΊ by simp
qed
lemma ccdfX_beyond_0: "ccdf (distr π borel X) x = 0" if "x > $Ο" for x::real
proof -
have "ereal ` {y β β. ccdf (distr π borel X) y = 0} β {}" using death_pt_def that by force
hence "βy'β(ereal ` {y β β. ccdf (distr π borel X) y = 0}). y' < ereal x"
using that unfolding death_pt_def by (rule cInf_lessD)
then obtain "y'"
where "y' β (ereal ` {y β β. ccdf (distr π borel X) y = 0})" and "y' < ereal x" by blast
then obtain y::real
where "y' = ereal y" and "ccdf (distr π borel X) y = 0" and "ereal y < ereal x" by blast
hence "ccdf (distr π borel X) y = 0" and "y < x" by simp_all
hence "ccdf (distr π borel X) x β€ 0"
using finite_borel_measure.ccdf_nonincreasing distrX_RD.finite_borel_measure_M X_RV
by (metis order_less_le)
thus ?thesis using finite_borel_measure.ccdf_nonneg distrX_RD.finite_borel_measure_M X_RV by smt
qed
lemma ccdfX_psi_0: "ccdf (distr π borel X) (real_of_ereal $Ο) = 0" if "$Ο < β"
proof -
have "Β¦$ΟΒ¦ β β" using that psi_nonneg by simp
then obtain u::real where "$Ο = ereal u" using ereal_real' by blast
hence "real_of_ereal $Ο = u" by simp
moreover have "ccdf (distr π borel X) u = 0"
proof -
have "βx::real. x β u βΉ x β {u<..} βΉ ccdf (distr π borel X) x = 0"
by (rule ccdfX_beyond_0, simp add: βΉ$Ο = ereal uβΊ)
hence "(ccdf (distr π borel X) β€ 0) (at_right u)"
apply -
by (rule iffD2[OF Lim_cong_within[where ?g="(Ξ»x.0)"]], simp_all+)
moreover have "(ccdf (distr π borel X) β€ ccdf (distr π borel X) u) (at_right u)"
using finite_borel_measure.ccdf_is_right_cont distrX_RD.finite_borel_measure_M
continuous_within X_RV by blast
ultimately show ?thesis using tendsto_unique trivial_limit_at_right_real by blast
qed
ultimately show ?thesis by simp
qed
lemma ccdfX_0_equiv: "ccdf (distr π borel X) x = 0 β· x β₯ $Ο" for x::real
proof
assume "ccdf (distr π borel X) x = 0"
thus "ereal x β₯ $Ο" unfolding death_pt_def by (simp add: INF_lower)
next
assume "$Ο β€ ereal x"
hence "$Ο = ereal x β¨ $Ο < ereal x" unfolding less_eq_ereal_def by auto
thus "ccdf (distr π borel X) x = 0"
proof
assume β: "$Ο = ereal x"
hence "$Ο < β" by simp
moreover have "real_of_ereal $Ο = x" using β by simp
ultimately show "ccdf (distr π borel X) x = 0" using ccdfX_psi_0 by simp
next
assume "$Ο < ereal x"
thus "ccdf (distr π borel X) x = 0" by (rule ccdfX_beyond_0)
qed
qed
lemma psi_pos[simp]: "$Ο > 0"
proof (rule not_le_imp_less, rule notI)
show "$Ο β€ (0::ereal) βΉ False"
proof -
assume "$Ο β€ (0::ereal)"
hence "ccdf (distr π borel X) 0 = 0" using ccdfX_0_equiv by (simp add: zero_ereal_def)
moreover have "ccdf (distr π borel X) 0 = 1" using ccdfX_0_1 by simp
ultimately show "False" by simp
qed
qed
corollary psi_pos'[simp]: "$Ο > ereal 0"
using psi_pos zero_ereal_def by presburger
subsubsection βΉIntrodution of Future-Lifetime Random Variable βΉT(x)βΊβΊ
definition alive :: "real β 'a set"
where "alive x β‘ {ΞΎ β space π. X ΞΎ > x}"
lemma alive_event[simp]: "alive x β MM_PS.events" for x::real
unfolding alive_def by simp
lemma X_alivex_measurable[measurable, simp]: "X β borel_measurable (π β alive x)" for x::real
unfolding cond_prob_space_def by (measurable; simp add: measurable_restrict_space1)
definition futr_life :: "real β ('a β real)" (βΉTβΊ)
where "T x ①(λξ. X ξ - x)"
lemma T0_eq_X[simp]: "T 0 = X"
unfolding futr_life_def by simp
lemma Tx_measurable[measurable, simp]: "T x β borel_measurable π" for x::real
unfolding futr_life_def by (simp add: borel_measurable_diff)
lemma Tx_alivex_measurable[measurable, simp]: "T x β borel_measurable (π β alive x)" for x::real
unfolding futr_life_def by (simp add: borel_measurable_diff)
lemma alive_T: "alive x = {ΞΎ β space π. T x ΞΎ > 0}" for x::real
unfolding alive_def futr_life_def by force
lemma alivex_Tx_pos[simp]: "0 < T x ΞΎ" if "ΞΎ β space (π β alive x)" for x::real
using MM_PS.space_cond_prob_space alive_T that by simp
lemma PT0_eq_PX_lborel: "π«(ΞΎ in π. T 0 ΞΎ β A Β¦ T 0 ΞΎ > 0) = π«(ΞΎ in π. X ΞΎ β A)"
if "A β sets lborel" for A :: "real set"
apply (rewrite MM_PS.cond_prob_AE_prob, simp_all)
using that X_RV measurable_lborel1 predE pred_sets2 by blast
subsubsection βΉActuarial Notations on the Survival ModelβΊ
definition survive :: "real β real β real" (βΉ$p'_{_&_}βΊ [0,0] 200)
where "$p_{t&x} β‘ ccdf (distr (π β alive x) borel (T x)) t"
abbreviation survive_1 :: "real β real" (βΉ$p'__βΊ [101] 200)
where "$p_x β‘ $p_{1&x}"
definition die :: "real β real β real" (βΉ$q'_{_&_}βΊ [0,0] 200)
where "$q_{t&x} β‘ cdf (distr (π β alive x) borel (T x)) t"
abbreviation die_1 :: "real β real" (βΉ$q'__βΊ [101] 200)
where "$q_x β‘ $q_{1&x}"
definition die_defer :: "real β real β real β real" (βΉ$q'_{_Β¦_&_}βΊ [0,0,0] 200)
where "$q_{f¦t&x} = ¦$q_{f+t&x} - $q_{f&x}¦"
abbreviation die_defer_1 :: "real β real β real" (βΉ$q'_{_Β¦&_}βΊ [0,0] 200)
where "$q_{f¦&x} ①$q_{f¦1&x}"
definition life_expect :: "real β real" (βΉ$e`β'__βΊ [101] 200)
where "$e`β_x β‘ integralβ§L (π β alive x) (T x)"
definition temp_life_expect :: "real β real βreal" (βΉ$e`β'_{_:_}βΊ [0,0] 200)
where "$e`β_{x:n} β‘ integralβ§L (π β alive x) (λξ. min (T x ΞΎ) n)"
definition curt_life_expect :: "real β real" (βΉ$e'__βΊ [101] 200)
where "$e_x β‘ integralβ§L (π β alive x) (λξ. βT x ΞΎβ)"
definition temp_curt_life_expect :: "real β real β real" (βΉ$e'_{_:_}βΊ [0,0] 200)
where "$e_{x:n} β‘ integralβ§L (π β alive x) (λξ. βmin (T x ΞΎ) nβ)"
subsubsection βΉProperties of Survival Function for βΉT(x)βΊβΊ
context
fixes x::real
assumes x_lt_psi[simp]: "x < $Ο"
begin
lemma PXx_pos[simp]: "π«(ΞΎ in π. X ΞΎ > x) > 0"
proof -
have "π«(ΞΎ in π. X ΞΎ > x) = ccdf (distr π borel X) x"
unfolding alive_def using MM_PS.ccdf_distr_P by simp
also have "β¦ > 0"
using ccdfX_0_equiv distrX_RD.ccdf_nonneg x_lt_psi by (smt (verit) linorder_not_le)
finally show ?thesis .
qed
lemma PTx_pos[simp]: "π«(ΞΎ in π. T x ΞΎ > 0) > 0"
apply (rewrite alive_T[THEN sym])
unfolding alive_def by simp
interpretation alivex_PS: prob_space "π β alive x"
by (rule MM_PS.cond_prob_space_correct, simp_all add: alive_def)
interpretation distrTx_RD: real_distribution "distr (π β alive x) borel (T x)" by simp
lemma ccdfTx_cond_prob:
"ccdf (distr (π β alive x) borel (T x)) t = π«(ΞΎ in π. T x ΞΎ > t Β¦ T x ΞΎ > 0)" for t::real
apply (rewrite alivex_PS.ccdf_distr_P, simp)
unfolding alive_def
apply (rewrite MM_PS.cond_prob_space_cond_prob[THEN sym], simp_all add: pred_def)
unfolding futr_life_def by simp
lemma ccdfTx_0_1: "ccdf (distr (π β alive x) borel (T x)) 0 = 1"
apply (rewrite ccdfTx_cond_prob)
unfolding futr_life_def cond_prob_def
by (smt (verit, best) Collect_cong PXx_pos divide_eq_1_iff)
lemma ccdfTx_nonpos_1: "ccdf (distr (π β alive x) borel (T x)) t = 1" if "t β€ 0" for t :: real
using antisym ccdfTx_0_1 that
by (metis distrTx_RD.ccdf_bounded_prob distrTx_RD.ccdf_nonincreasing)
lemma ccdfTx_0_equiv: "ccdf (distr (π β alive x) borel (T x)) t = 0 β· x+t β₯ $Ο" for t::real
proof -
have "ccdf (distr (π β alive x) borel (T x)) t =
π«(ΞΎ in π. X ΞΎ > x+t β§ X ΞΎ > x) / π«(ΞΎ in π. X ΞΎ > x)"
apply (rewrite ccdfTx_cond_prob)
unfolding cond_prob_def futr_life_def by (smt (verit) Collect_cong)
hence "ccdf (distr (π β alive x) borel (T x)) t = 0 β·
π«(ΞΎ in π. X ΞΎ > x+t β§ X ΞΎ > x) / π«(ΞΎ in π. X ΞΎ > x) = 0"
by simp
also have "β¦ β· π«(ΞΎ in π. X ΞΎ > x+t β§ X ΞΎ > x) = 0"
using x_lt_psi PXx_pos by (smt (verit) divide_eq_0_iff)
also have "β¦ β· x+t β₯ $Ο"
using ccdfX_0_equiv MM_PS.ccdf_distr_P
by (smt (verit) Collect_cong X_RV le_ereal_le linorder_not_le x_lt_psi)
finally show ?thesis .
qed
lemma ccdfTx_continuous_on_nonpos[simp]:
"continuous_on {..0} (ccdf (distr (π β alive x) borel (T x)))"
by (metis atMost_iff ccdfTx_nonpos_1 continuous_on_cong continuous_on_const)
lemma ccdfTx_differentiable_on_nonpos[simp]:
"(ccdf (distr (π β alive x) borel (T x))) differentiable_on {..0}"
by (rewrite differentiable_on_cong[where f="Ξ»_. 1"]; simp add: ccdfTx_nonpos_1)
lemma ccdfTx_has_real_derivative_0_at_neg:
"(ccdf (distr (π β alive x) borel (T x)) has_real_derivative 0) (at t)" if "t < 0" for t::real
apply (rewrite has_real_derivative_iff_has_vector_derivative)
apply (rule has_vector_derivative_transform_within_open[of "Ξ»_. 1" _ _ "{..<0}"])
using ccdfTx_nonpos_1 that by simp_all
lemma ccdfTx_integrable_Icc:
"set_integrable lborel {a..b} (ccdf (distr (π β alive x) borel (T x)))" for a b :: real
proof -
have "(β«β§+t. ennreal (indicat_real {a..b} t * ccdf (distr (π β alive x) borel (T x)) t) βlborel)
< β€"
proof -
have "(β«β§+t. ennreal (indicat_real {a..b} t * ccdf (distr (π β alive x) borel (T x)) t) βlborel)
β€ (β«β§+t. ennreal (indicat_real {a..b} t) βlborel)"
apply (rule nn_integral_mono)
using distrTx_RD.ccdf_bounded
by (simp add: distrTx_RD.ccdf_bounded_prob indicator_times_eq_if(1))
also have "β¦ = nn_integral lborel (indicator {a..b})" by (meson ennreal_indicator)
also have "β¦ = emeasure lborel {a..b}" by (rewrite nn_integral_indicator; simp)
also have "β¦ < β€"
using emeasure_lborel_Icc_eq ennreal_less_top infinity_ennreal_def by presburger
finally show ?thesis .
qed
thus ?thesis
unfolding set_integrable_def
apply (intro integrableI_nonneg, simp_all)
using distrTx_RD.ccdf_nonneg by (intro always_eventually) auto
qed
corollary ccdfTx_integrable_on_Icc:
"ccdf (distr (π β alive x) borel (T x)) integrable_on {a..b}" for a b :: real
using set_borel_integral_eq_integral ccdfTx_integrable_Icc by force
lemma ccdfTx_PX:
"ccdf (distr (π β alive x) borel (T x)) t = π«(ΞΎ in π. X ΞΎ > x+t) / π«(ΞΎ in π. X ΞΎ > x)"
if "t β₯ 0" for t::real
apply (rewrite ccdfTx_cond_prob)
unfolding cond_prob_def futr_life_def PXx_pos by (smt (verit) Collect_cong that)
lemma ccdfTx_ccdfX: "ccdf (distr (π β alive x) borel (T x)) t =
ccdf (distr π borel X) (x + t) / ccdf (distr π borel X) x"
if "t β₯ 0" for t::real
using ccdfTx_PX that MM_PS.ccdf_distr_P X_RV by presburger
lemma ccdfT0_eq_ccdfX: "ccdf (distr (π β alive 0) borel (T 0)) = ccdf (distr π borel X)"
proof
fix x
show "ccdf (distr (π β alive 0) borel (T 0)) x = ccdf (distr π borel X) x"
proof (cases βΉx β₯ 0βΊ)
case True
thus ?thesis
using survival_model.ccdfTx_ccdfX[where x=0] ccdfX_0_1 survival_model_axioms by fastforce
next
case False
hence "x β€ 0" by simp
thus ?thesis
apply (rewrite ccdfX_unborn_1, simp)
by (rewrite survival_model.ccdfTx_nonpos_1; simp add: survival_model_axioms)
qed
qed
lemma continuous_ccdfX_ccdfTx:
"continuous (at (x+t) within {x..}) (ccdf (distr π borel X)) β·
continuous (at t within {0..}) (ccdf (distr (π β alive x) borel (T x)))"
if "t β₯ 0" for t::real
proof -
let ?srvl = "ccdf (distr π borel X)"
have [simp]: "π«(ΞΎ in π. X ΞΎ > x) β 0" using PXx_pos by force
have β: "βu. u β₯ 0 βΉ ccdf (distr (π β alive x) borel (T x)) u =
?srvl (x + u) / π«(ΞΎ in π. X ΞΎ > x)"
using survive_def MM_PS.ccdf_distr_P ccdfTx_PX that by simp
have "continuous (at t within {0..}) (ccdf (distr (π β alive x) borel (T x))) β·
continuous (at t within {0..}) (Ξ»u. ?srvl (x+u) / π«(ΞΎ in π. x < X ΞΎ))"
proof -
have "ββ©F u in at t within {0..}. ccdf (distr (π β alive x) borel (T x)) u =
?srvl (x+u) / π«(ΞΎ in π. X ΞΎ > x)"
using β by (rewrite eventually_at_topological, simp_all) blast
thus ?thesis
by (intro continuous_at_within_cong, simp_all add: β that)
qed
also have "β¦ β· continuous (at t within {0..}) (Ξ»u. ?srvl (x+u))"
by (rewrite at "_ = β" continuous_cdivide_iff[of "π«(ΞΎ in π. X ΞΎ > x)"], simp_all)
also have "β¦ β· continuous (at (x+t) within {x..}) ?srvl"
proof
let ?subx = "Ξ»v. v-x"
assume LHS: "continuous (at t within {0..}) (Ξ»u. ?srvl (x+u))"
hence "continuous (at (?subx (x+t)) within ?subx ` {x..}) (Ξ»u. ?srvl (x+u))"
proof -
have "?subx ` {x..} = {0..}"
by (metis (no_types, lifting) add.commute add_uminus_conv_diff diff_self
image_add_atLeast image_cong)
thus ?thesis using LHS by simp
qed
moreover have "continuous (at (x+t) within {x..}) ?subx" by (simp add: continuous_diff)
ultimately have "continuous (at (x+t) within {x..}) (Ξ»u. ?srvl (x + (?subx u)))"
using continuous_within_compose2 by force
thus "continuous (at (x+t) within {x..}) ?srvl" by simp
next
assume RHS: "continuous (at (x+t) within {x..}) ?srvl"
hence "continuous (at ((plus x) t) within (plus x) ` {0..}) ?srvl" by simp
moreover have "continuous (at t within {0..}) (plus x)" by (simp add: continuous_add)
ultimately show "continuous (at t within {0..}) (Ξ»u. ?srvl (x+u))"
using continuous_within_compose2 by force
qed
finally show ?thesis by simp
qed
lemma isCont_ccdfX_ccdfTx:
"isCont (ccdf (distr π borel X)) (x+t) β·
isCont (ccdf (distr (π β alive x) borel (T x))) t"
if "t > 0" for t::real
proof -
have "isCont (ccdf (distr π borel X)) (x+t) β·
continuous (at (x+t) within {x<..}) (ccdf (distr π borel X))"
by (smt (verit) at_within_open greaterThan_iff open_greaterThan that)
also have "β¦ β· continuous (at (x+t) within {x..}) (ccdf (distr π borel X))"
by (meson Ioi_le_Ico calculation continuous_within_subset top_greatest)
also have "β¦ β· continuous (at t within {0..}) (ccdf (distr (π β alive x) borel (T x)))"
using that continuous_ccdfX_ccdfTx by force
also have "β¦ β· continuous (at t within {0<..}) (ccdf (distr (π β alive x) borel (T x)))"
by (metis Ioi_le_Ico at_within_open continuous_at_imp_continuous_at_within
continuous_within_subset greaterThan_iff open_greaterThan that)
also have "β¦ β· isCont (ccdf (distr (π β alive x) borel (T x))) t"
by (metis at_within_open greaterThan_iff open_greaterThan that)
finally show ?thesis .
qed
lemma has_real_derivative_ccdfX_ccdfTx:
"((ccdf (distr π borel X)) has_real_derivative D) (at (x+t)) β·
((ccdf (distr (π β alive x) borel (T x))) has_real_derivative (D / π«(ΞΎ in π. X ΞΎ > x))) (at t)"
if "t > 0" for t D :: real
proof -
have "((ccdf (distr (π β alive x) borel (T x))) has_real_derivative
(D / π«(ΞΎ in π. X ΞΎ > x))) (at t) β·
((Ξ»t. (ccdf (distr π borel X)) (x+t) / π«(ΞΎ in π. X ΞΎ > x)) has_real_derivative
(D / π«(ΞΎ in π. X ΞΎ > x))) (at t)"
proof -
let ?d = "t/2"
{ fix u::real assume "dist u t < ?d"
hence "u > 0" by (smt (verit) dist_real_def dist_triangle_half_r)
hence "ccdf (distr (π β alive x) borel (T x)) u =
ccdf (distr π borel X) (x + u) / MM_PS.prob {ΞΎ::'a β space π. x < X ΞΎ}"
using survive_def MM_PS.ccdf_distr_P ccdfTx_PX that by simp }
moreover have "?d > 0" using that by simp
ultimately show ?thesis
apply -
apply (rule DERIV_cong_ev, simp)
apply (rewrite eventually_nhds_metric, blast)
by simp
qed
also have "β¦ β· ((Ξ»t. (ccdf (distr π borel X)) (x+t)) has_real_derivative D) (at t)"
using PXx_pos by (rewrite DERIV_cdivide_iff[of "π«(ΞΎ in π. X ΞΎ > x)", THEN sym]; force)
also have "β¦ β· (ccdf (distr π borel X) has_real_derivative D) (at (x+t))"
by (simp add: DERIV_shift add.commute)
finally show ?thesis by simp
qed
lemma differentiable_ccdfX_ccdfTx:
"(ccdf (distr π borel X)) differentiable at (x+t) β·
(ccdf (distr (π β alive x) borel (T x))) differentiable at t"
if "t > 0" for t::real
apply (rewrite differentiable_eq_field_differentiable_real)+
unfolding field_differentiable_def using has_real_derivative_ccdfX_ccdfTx that
by (smt (verit, del_insts) PXx_pos nonzero_mult_div_cancel_left)
subsubsection βΉProperties of βΉ$p_{t&x}βΊβΊ
lemma p_0_1: "$p_{0&x} = 1"
unfolding survive_def using ccdfTx_0_1 by simp
lemma p_nonneg[simp]: "$p_{t&x} β₯ 0" for t::real
unfolding survive_def using distrTx_RD.ccdf_nonneg by simp
lemma p_le_1[simp]: "$p_{t&x} β€ 1" for t::real
unfolding survive_def using distrTx_RD.ccdf_bounded_prob by auto
lemma p_0_equiv: "$p_{t&x} = 0 β· x+t β₯ $Ο" for t::real
unfolding survive_def by (rule ccdfTx_0_equiv)
lemma p_PTx: "$p_{t&x} = π«(ΞΎ in π. T x ΞΎ > t Β¦ T x ΞΎ > 0)" for t::real
unfolding survive_def using ccdfTx_cond_prob by simp
lemma p_PX: "$p_{t&x} = π«(ΞΎ in π. X ΞΎ > x + t) / π«(ΞΎ in π. X ΞΎ > x)" if "t β₯ 0" for t::real
unfolding survive_def using ccdfTx_PX that by simp
lemma p_mult: "$p_{t+t' & x} = $p_{t&x} * $p_{t' & x+t}"
if "t β₯ 0" "t' β₯ 0" "x+t < $Ο" for t t' :: real
proof -
have "$p_{t+t' & x} = π«(ΞΎ in π. X ΞΎ > x+t+t') / π«(ΞΎ in π. X ΞΎ > x)"
apply (rewrite p_PX; (simp add: that)?)
by (rule disjI2, smt (verit, best) Collect_cong)
also have "β¦ = (π«(ΞΎ in π. X ΞΎ > x+t+t') / π«(ΞΎ in π. X ΞΎ > x+t)) *
(π«(ΞΎ in π. X ΞΎ > x+t) / π«(ΞΎ in π. X ΞΎ > x))"
using that survival_model.PXx_pos survival_model_axioms by fastforce
also have "β¦ = $p_{t&x} * $p_{t' & x+t}"
apply (rewrite p_PX, simp add: that)
by (rewrite survival_model.p_PX, simp_all add: that survival_model_axioms)
finally show ?thesis .
qed
lemma p_PTx_ge_ccdf_isCont: "$p_{t&x} = π«(ΞΎ in π. T x ΞΎ β₯ t Β¦ T x ΞΎ > 0)"
if "isCont (ccdf (distr π borel X)) (x+t)" "t > 0" for t::real
unfolding survive_def using that isCont_ccdfX_ccdfTx
apply (rewrite alivex_PS.ccdf_continuous_distr_P_ge, simp_all)
by (rewrite MM_PS.cond_prob_space_cond_prob, simp_all add: alive_T)
end
subsubsection βΉProperties of Survival Function for βΉXβΊβΊ
lemma ccdfX_continuous_unborn[simp]: "continuous_on {..0} (ccdf (distr π borel X))"
using ccdfTx_continuous_on_nonpos by (metis ccdfT0_eq_ccdfX psi_pos')
lemma ccdfX_differentiable_unborn[simp]: "(ccdf (distr π borel X)) differentiable_on {..0}"
using ccdfTx_differentiable_on_nonpos by (metis ccdfT0_eq_ccdfX psi_pos')
lemma ccdfX_has_real_derivative_0_unborn:
"(ccdf (distr π borel X) has_real_derivative 0) (at x)" if "x < 0" for x::real
using ccdfTx_has_real_derivative_0_at_neg by (metis ccdfT0_eq_ccdfX psi_pos' that)
lemma ccdfX_integrable_Icc:
"set_integrable lborel {a..b} (ccdf (distr π borel X))" for a b :: real
using ccdfTx_integrable_Icc by (metis ccdfT0_eq_ccdfX psi_pos')
corollary ccdfX_integrable_on_Icc:
"ccdf (distr π borel X) integrable_on {a..b}" for a b :: real
using set_borel_integral_eq_integral ccdfX_integrable_Icc by force
lemma ccdfX_p: "ccdf (distr π borel X) x = $p_{x&0}" for x::real
by (metis ccdfT0_eq_ccdfX survive_def psi_pos')
subsubsection βΉIntroduction of Cumulative Distributive Function for βΉXβΊβΊ
lemma cdfX_0_0: "cdf (distr π borel X) 0 = 0"
using ccdfX_0_1 distrX_RD.ccdf_cdf distrX_RD.prob_space by fastforce
lemma cdfX_unborn_0: "cdf (distr π borel X) x = 0" if "x β€ 0"
using ccdfX_unborn_1 cdfX_0_0 distrX_RD.cdf_ccdf that by fastforce
lemma cdfX_beyond_1: "cdf (distr π borel X) x = 1" if "x > $Ο" for x::real
using ccdfX_beyond_0 distrX_RD.cdf_ccdf that distrX_RD.prob_space by force
lemma cdfX_psi_1: "cdf (distr π borel X) (real_of_ereal $Ο) = 1" if "$Ο < β"
using ccdfX_psi_0 distrX_RD.cdf_ccdf distrX_RD.prob_space that by fastforce
lemma cdfX_1_equiv: "cdf (distr π borel X) x = 1 β· x β₯ $Ο" for x::real
using ccdfX_0_equiv distrX_RD.cdf_ccdf distrX_RD.prob_space by force
subsubsection βΉProperties of Cumulative Distributive Function for βΉT(x)βΊβΊ
context
fixes x::real
assumes x_lt_psi[simp]: "x < $Ο"
begin
interpretation alivex_PS: prob_space "π β alive x"
by (rule MM_PS.cond_prob_space_correct, simp_all add: alive_def)
interpretation distrTx_RD: real_distribution "distr (π β alive x) borel (T x)" by simp
lemma cdfTx_cond_prob:
"cdf (distr (π β alive x) borel (T x)) t = π«(ΞΎ in π. T x ΞΎ β€ t Β¦ T x ΞΎ > 0)" for t::real
apply (rewrite distrTx_RD.cdf_ccdf, rewrite distrTx_RD.prob_space)
apply (rewrite ccdfTx_cond_prob, simp)
by (rewrite not_less[THEN sym], rewrite MM_PS.cond_prob_neg; simp)
lemma cdfTx_0_0: "cdf (distr (π β alive x) borel (T x)) 0 = 0"
using ccdfTx_0_1 distrTx_RD.cdf_ccdf distrTx_RD.prob_space by force
lemma cdfTx_nonpos_0: "cdf (distr (π β alive x) borel (T x)) t = 0" if "t β€ 0" for t :: real
using ccdfTx_nonpos_1 distrTx_RD.cdf_ccdf distrTx_RD.prob_space that by force
lemma cdfTx_1_equiv: "cdf (distr (π β alive x) borel (T x)) t = 1 β· x+t β₯ $Ο" for t::real
using ccdfTx_0_equiv distrTx_RD.cdf_ccdf distrTx_RD.prob_space by force
lemma cdfTx_continuous_on_nonpos[simp]:
"continuous_on {..0} (cdf (distr (π β alive x) borel (T x)))"
by (rewrite continuous_on_cong[where g="Ξ»t. 0"]) (simp_all add: cdfTx_nonpos_0)+
lemma cdfTx_differentiable_on_nonpos[simp]:
"(cdf (distr (π β alive x) borel (T x))) differentiable_on {..0}"
by (rewrite differentiable_on_cong[where f="Ξ»t. 0"]; simp add: cdfTx_nonpos_0)
lemma cdfTx_has_real_derivative_0_at_neg:
"(cdf (distr (π β alive x) borel (T x)) has_real_derivative 0) (at t)" if "t < 0" for t::real
apply (rewrite has_real_derivative_iff_has_vector_derivative)
apply (rule has_vector_derivative_transform_within_open[of "Ξ»_. 0" _ _ "{..<0}"])
using cdfTx_nonpos_0 that by simp_all
lemma cdfTx_integrable_Icc:
"set_integrable lborel {a..b} (cdf (distr (π β alive x) borel (T x)))" for a b :: real
proof -
have "set_integrable lborel {a..b} (Ξ»_. 1::real)"
unfolding set_integrable_def
using emeasure_compact_finite by (simp, intro integrable_real_indicator; force)
thus ?thesis
apply (rewrite distrTx_RD.cdf_ccdf, rewrite distrTx_RD.prob_space)
using ccdfTx_integrable_Icc by (rewrite set_integral_diff; simp)
qed
corollary cdfTx_integrable_on_Icc:
"cdf (distr (π β alive x) borel (T x)) integrable_on {a..b}" for a b :: real
using cdfTx_integrable_Icc set_borel_integral_eq_integral by force
lemma cdfTx_PX:
"cdf (distr (π β alive x) borel (T x)) t = π«(ΞΎ in π. x < X ΞΎ β§ X ΞΎ β€ x+t) / π«(ΞΎ in π. X ΞΎ > x)"
for t::real
apply (rewrite cdfTx_cond_prob)
unfolding cond_prob_def futr_life_def PXx_pos by (smt (verit) Collect_cong)
lemma cdfT0_eq_cdfX: "cdf (distr (π β alive 0) borel (T 0)) = cdf (distr π borel X)"
proof
interpret alive0_PS: prob_space "π β alive 0"
apply (rule MM_PS.cond_prob_space_correct, simp)
using PXx_pos alive_def psi_pos' by presburger
interpret distrT0_RD: real_distribution "distr (π β alive 0) borel (T 0)" by simp
show "βx. cdf (distr (π β alive 0) borel (T 0)) x = cdf (distr π borel X) x"
using ccdfT0_eq_ccdfX distrX_RD.ccdf_cdf distrT0_RD.ccdf_cdf
by (smt (verit, best) distrT0_RD.prob_space distrX_RD.prob_space psi_pos')
qed
lemma continuous_cdfX_cdfTx:
"continuous (at (x+t) within {x..}) (cdf (distr π borel X)) β·
continuous (at t within {0..}) (cdf (distr (π β alive x) borel (T x)))"
if "t β₯ 0" for t::real
proof -
have "continuous (at (x+t) within {x..}) (cdf (distr π borel X)) β·
continuous (at (x+t) within {x..}) (ccdf (distr π borel X))"
by (rule distrX_RD.continuous_cdf_ccdf)
also have "β¦ β· continuous (at t within {0..}) (ccdf (distr (π β alive x) borel (T x)))"
using continuous_ccdfX_ccdfTx that by simp
also have "β¦ β· continuous (at t within {0..}) (cdf (distr (π β alive x) borel (T x)))"
using distrTx_RD.continuous_cdf_ccdf by simp
finally show ?thesis .
qed
lemma isCont_cdfX_cdfTx:
"isCont (cdf (distr π borel X)) (x+t) β·
isCont (cdf (distr (π β alive x) borel (T x))) t"
if "t > 0" for t::real
apply (rewrite distrX_RD.isCont_cdf_ccdf)
apply (rewrite isCont_ccdfX_ccdfTx, simp_all add: that)
by (rule distrTx_RD.isCont_cdf_ccdf[THEN sym])
lemma has_real_derivative_cdfX_cdfTx:
"((cdf (distr π borel X)) has_real_derivative D) (at (x+t)) β·
((cdf (distr (π β alive x) borel (T x))) has_real_derivative (D / π«(ΞΎ in π. X ΞΎ > x))) (at t)"
if "t > 0" for t D :: real
proof -
have "((cdf (distr π borel X)) has_real_derivative D) (at (x+t)) β·
(ccdf (distr π borel X) has_real_derivative -D) (at (x+t))"
using distrX_RD.has_real_derivative_cdf_ccdf by force
also have "β¦ β·
((ccdf (distr (π β alive x) borel (T x))) has_real_derivative (-D / π«(ΞΎ in π. X ΞΎ > x))) (at t)"
using has_real_derivative_ccdfX_ccdfTx that by simp
also have "β¦ β·
((cdf (distr (π β alive x) borel (T x))) has_real_derivative (D / π«(ΞΎ in π. X ΞΎ > x))) (at t)"
by (simp add: distrTx_RD.has_real_derivative_cdf_ccdf)
finally show ?thesis .
qed
lemma differentiable_cdfX_cdfTx:
"(cdf (distr π borel X)) differentiable at (x+t) β·
(cdf (distr (π β alive x) borel (T x))) differentiable at t"
if "t > 0" for t::real
apply (rewrite differentiable_eq_field_differentiable_real)+
unfolding field_differentiable_def using has_real_derivative_cdfX_cdfTx that
by (meson differentiable_ccdfX_ccdfTx distrTx_RD.finite_borel_measure_axioms
distrX_RD.finite_borel_measure_axioms finite_borel_measure.differentiable_cdf_ccdf
real_differentiable_def x_lt_psi)
subsubsection βΉProperties of βΉ$q_{t&x}βΊβΊ
lemma q_nonpos_0: "$q_{t&x} = 0" if "t β€ 0" for t::real
unfolding die_def using that cdfTx_nonpos_0 by simp
corollary q_0_0: "$q_{0&x} = 0"
using q_nonpos_0 by simp
lemma q_nonneg[simp]: "$q_{t&x} β₯ 0" for t::real
unfolding die_def using distrTx_RD.cdf_nonneg by simp
lemma q_le_1[simp]: "$q_{t&x} β€ 1" for t::real
unfolding die_def using distrTx_RD.cdf_bounded_prob by force
lemma q_1_equiv: "$q_{t&x} = 1 β· x+t β₯ $Ο" for t::real
unfolding die_def using cdfTx_1_equiv by simp
lemma q_PTx: "$q_{t&x} = π«(ΞΎ in π. T x ΞΎ β€ t Β¦ T x ΞΎ > 0)" for t::real
unfolding die_def using cdfTx_cond_prob by simp
lemma q_PX: "$q_{t&x} = π«(ΞΎ in π. x < X ΞΎ β§ X ΞΎ β€ x + t) / π«(ΞΎ in π. X ΞΎ > x)"
unfolding die_def using cdfTx_PX by simp
lemma q_defer_0_q[simp]: "$q_{0Β¦t&x} = $q_{t&x}" for t::real
unfolding die_defer_def using q_0_0 by simp
lemma q_defer_0_0: "$q_{f¦0&x} = 0" for f::real
unfolding die_defer_def by simp
lemma q_defer_nonneg[simp]: "$q_{fΒ¦t&x} β₯ 0" for f t :: real
unfolding die_defer_def by simp
lemma q_defer_q: "$q_{fΒ¦t&x} = $q_{f+t & x} - $q_{f&x}" if "t β₯ 0" for f t :: real
unfolding die_defer_def die_def using distrTx_RD.cdf_nondecreasing that by simp
corollary q_defer_le_1[simp]: "$q_{fΒ¦t&x} β€ 1" if "t β₯ 0" for f t :: real
by (smt (verit, ccfv_SIG) q_defer_q q_le_1 q_nonneg that)
lemma q_defer_PTx: "$q_{fΒ¦t&x} = π«(ΞΎ in π. f < T x ΞΎ β§ T x ΞΎ β€ f + t Β¦ T x ΞΎ > 0)"
if "t β₯ 0" for f t :: real
proof -
have "$q_{f¦t&x} = $q_{f+t & x} - $q_{f&x}" using q_defer_q that by simp
also have "β¦ = π«(ΞΎ in π. T x ΞΎ β€ f + t Β¦ T x ΞΎ > 0) - π«(ΞΎ in π. T x ΞΎ β€ f Β¦ T x ΞΎ > 0)"
using q_PTx by simp
also have "β¦ = π«(ΞΎ in (π β alive x). T x ΞΎ β€ f + t) - π«(ΞΎ in (π β alive x). T x ΞΎ β€ f)"
using MM_PS.cond_prob_space_cond_prob alive_T by simp
also have "β¦ = π«(ΞΎ in (π β alive x). f < T x ΞΎ β§ T x ΞΎ β€ f + t)"
proof -
have "{ΞΎ β space (π β alive x). T x ΞΎ β€ f + t} - {ΞΎ β space (π β alive x). T x ΞΎ β€ f} =
{ΞΎ β space (π β alive x). f < T x ΞΎ β§ T x ΞΎ β€ f + t}"
using that by force
hence "alivex_PS.prob
({ΞΎ β space (π β alive x). T x ΞΎ β€ f + t} - {ΞΎ β space (π β alive x). T x ΞΎ β€ f}) =
π«(ΞΎ in (π β alive x). f < T x ΞΎ β§ T x ΞΎ β€ f + t)"
by simp
moreover have "{ΞΎ β space (π β alive x). T x ΞΎ β€ f} β {ΞΎ β space (π β alive x). T x ΞΎ β€ f + t}"
using that by force
ultimately show ?thesis by (rewrite alivex_PS.finite_measure_Diff[THEN sym]; simp)
qed
also have "β¦ = π«(ΞΎ in π. f < T x ΞΎ β§ T x ΞΎ β€ f + t Β¦ T x ΞΎ > 0)"
using MM_PS.cond_prob_space_cond_prob alive_T by simp
finally show ?thesis .
qed
lemma q_defer_PX: "$q_{fΒ¦t&x} = π«(ΞΎ in π. x + f < X ΞΎ β§ X ΞΎ β€ x + f + t) / π«(ΞΎ in π. X ΞΎ > x)"
if "f β₯ 0" "t β₯ 0" for f t :: real
proof -
have "$q_{fΒ¦t&x} = π«(ΞΎ in π. f < T x ΞΎ β§ T x ΞΎ β€ f + t β§ T x ΞΎ > 0) / π«(ΞΎ in π. T x ΞΎ > 0)"
apply (rewrite q_defer_PTx; (simp add: that)?)
unfolding cond_prob_def by simp
also have "β¦ = π«(ΞΎ in π. f < T x ΞΎ β§ T x ΞΎ β€ f + t) / π«(ΞΎ in π. T x ΞΎ > 0)"
proof -
have "βΞΎ. ΞΎ β space π βΉ f < T x ΞΎ β§ T x ΞΎ β€ f + t β§ T x ΞΎ > 0 β· f < T x ΞΎ β§ T x ΞΎ β€ f + t"
using that by auto
hence "{ΞΎ β space π. f < T x ΞΎ β§ T x ΞΎ β€ f + t β§ T x ΞΎ > 0} =
{ΞΎ β space π. f < T x ΞΎ β§ T x ΞΎ β€ f + t}" by blast
thus ?thesis by simp
qed
also have "β¦ = π«(ΞΎ in π. x + f < X ΞΎ β§ X ΞΎ β€ x + f + t) / π«(ΞΎ in π. X ΞΎ > x)"
unfolding futr_life_def by (smt (verit) Collect_cong)
finally show ?thesis .
qed
lemma q_defer_old_0: "$q_{fΒ¦t&x} = 0" if "x+f β₯ $Ο" "t β₯ 0" for f t :: real
proof -
have "$q_{f¦t&x} = $q_{f+t & x} - $q_{f&x}" using q_defer_q that by simp
moreover have "$q_{f+t & x} = 1" using q_1_equiv that le_ereal_le by auto
moreover have "$q_{f&x} = 1" using q_1_equiv that by simp
ultimately show ?thesis by simp
qed
end
subsubsection βΉProperties of Cumulative Distributive Function for βΉXβΊβΊ
lemma cdfX_continuous_unborn[simp]: "continuous_on {..0} (cdf (distr π borel X))"
using cdfTx_continuous_on_nonpos by (metis cdfT0_eq_cdfX psi_pos')
lemma cdfX_differentiable_unborn[simp]: "(cdf (distr π borel X)) differentiable_on {..0}"
using cdfTx_differentiable_on_nonpos by (metis cdfT0_eq_cdfX psi_pos')
lemma cdfX_has_real_derivative_0_unborn:
"(cdf (distr π borel X) has_real_derivative 0) (at x)" if "x < 0" for x::real
using cdfTx_has_real_derivative_0_at_neg by (metis cdfT0_eq_cdfX psi_pos' that)
lemma cdfX_integrable_Icc:
"set_integrable lborel {a..b} (cdf (distr π borel X))" for a b :: real
using cdfTx_integrable_Icc by (metis cdfT0_eq_cdfX psi_pos')
corollary cdfX_integrable_on_Icc:
"cdf (distr π borel X) integrable_on {a..b}" for a b :: real
using cdfX_integrable_Icc set_borel_integral_eq_integral by force
lemma cdfX_q: "cdf (distr π borel X) x = $q_{x&0}" if "x β₯ 0" for x::real
by (metis cdfT0_eq_cdfX die_def psi_pos')
subsubsection βΉRelations between βΉ$p_{t&x}βΊ and βΉ$q_{t&x}βΊβΊ
context
fixes x::real
assumes x_lt_psi[simp]: "x < $Ο"
begin
interpretation alivex_PS: prob_space "π β alive x"
by (rule MM_PS.cond_prob_space_correct, simp_all add: alive_def)
interpretation distrTx_RD: real_distribution "distr (π β alive x) borel (T x)" by simp
lemma p_q_1: "$p_{t&x} + $q_{t&x} = 1" for t::real
unfolding survive_def die_def using distrTx_RD.add_cdf_ccdf
by (smt (verit) distrTx_RD.prob_space x_lt_psi)
lemma q_defer_p: "$q_{fΒ¦t&x} = $p_{f&x} - $p_{f+t & x}" if "t β₯ 0" for f t :: real
using q_defer_q p_q_1 that x_lt_psi by smt
lemma q_defer_p_q_defer: "$p_{f&x} * $q_{f'Β¦t & x+f} = $q_{f+f'Β¦t & x}"
if "x+f < $Ο" "f β₯ 0" "f' β₯ 0" "t β₯ 0" for f f' t :: real
proof -
have "$p_{f&x} * $q_{f'Β¦t & x+f} =
π«(ΞΎ in π. X ΞΎ > x+f) / π«(ΞΎ in π. X ΞΎ > x) *
π«(ΞΎ in π. x+f+f' < X ΞΎ β§ X ΞΎ β€ x+f+f'+t) / π«(ΞΎ in π. X ΞΎ > x+f)"
apply (rewrite p_PX, (simp_all add: that)[2])
by (rewrite survival_model.q_defer_PX, simp_all add: that survival_model_axioms)
also have "β¦ = π«(ΞΎ in π. x+f+f' < X ΞΎ β§ X ΞΎ β€ x+f+f'+t) / π«(ΞΎ in π. X ΞΎ > x)"
using survival_model.PXx_pos[of π X "x+f"] nonzero_mult_div_cancel_left that
by (smt (verit, ccfv_SIG) survival_model_axioms times_divide_eq_left times_divide_eq_right)
also have "β¦ = $q_{f+f'Β¦t & x}"
by (rewrite q_defer_PX; simp add: that group_cancel.add1)
finally show ?thesis .
qed
lemma q_defer_pq: "$q_{f¦t&x} = $p_{f&x} * $q_{t & x+f}"
if "x+f < $Ο" "t β₯ 0" "f β₯ 0" for f t :: real
using q_defer_p_q_defer[where f'=0] that
by (simp add: survival_model.q_defer_0_q survival_model_axioms)
subsubsection βΉProperties of Life ExpectationβΊ
lemma e_nonneg: "$e`β_x β₯ 0"
unfolding life_expect_def
by (rule Bochner_Integration.integral_nonneg, simp add: less_eq_real_def)
lemma e_P: "$e`β_x =
MM_PS.expectation (λξ. indicator (alive x) ΞΎ * T x ΞΎ) / π«(ΞΎ in π. T x ΞΎ > 0)"
unfolding life_expect_def
by (rewrite MM_PS.integral_cond_prob_space_nn, auto simp add: alive_T)
proposition nn_integral_T_p:
"(β«β§+ΞΎ. ennreal (T x ΞΎ) β(π β alive x)) = (β«β§+tβ{0..}. ennreal ($p_{t&x}) βlborel)"
apply (rewrite alivex_PS.expectation_nonneg_tail, simp_all add: less_imp_le)
apply (rule nn_integral_cong)
unfolding survive_def using distrTx_RD.prob_space distrTx_RD.ccdf_cdf by presburger
lemma nn_integral_T_pos: "(β«β§+ΞΎ. ennreal (T x ΞΎ) β(π β alive x)) > 0"
proof -
let ?f = "Ξ»t. - ccdf (distr (π β alive x) borel (T x)) t"
have "βt u. t β€ u βΉ ?f t β€ ?f u" using distrTx_RD.ccdf_nonincreasing by simp
moreover have "continuous (at_right 0) ?f"
using distrTx_RD.ccdf_is_right_cont by (intro continuous_intros)
ultimately have "βe>0. βd>0. ?f (0 + d) - ?f 0 < e"
using continuous_at_right_real_increasing by simp
hence "βd>0. ?f (0 + d) - ?f 0 < 1/2" by (smt (verit, del_insts) field_sum_of_halves)
from this obtain d where d_pos: "d > 0" and "$p_{d&x} β₯ 1/2"
using p_0_1 unfolding survive_def by auto
hence "βt. tβ{0..d} βΉ $p_{t&x} β₯ 1/2"
unfolding survive_def using distrTx_RD.ccdf_nonincreasing by force
hence "(β«β§+tβ{0..d}. ennreal ($p_{t&x}) βlborel) β₯ (β«β§+tβ{0..d}. ennreal (1/2) βlborel)"
apply (intro nn_set_integral_mono, simp_all)
unfolding survive_def using Tx_alivex_measurable apply force
by (rule AE_I2) (smt (verit) ennreal_half ennreal_leI half_bounded_equal)
moreover have "(β«β§+tβ{0..}. ennreal ($p_{t&x}) βlborel) β₯ (β«β§+tβ{0..d}. ennreal ($p_{t&x}) βlborel)"
by (rule nn_set_integral_set_mono) simp
moreover have "(β«β§+tβ{0..d}. ennreal (1/2) βlborel) > 0"
apply (rewrite nn_integral_cmult_indicator, simp_all)
using d_pos emeasure_lborel_Icc ennreal_zero_less_mult_iff by fastforce
ultimately show ?thesis using nn_integral_T_p by simp
qed
lemma e_pos_Tx: "$e`β_x > 0" if "integrable (π β alive x) (T x)"
unfolding life_expect_def
apply (rewrite integral_eq_nn_integral, simp_all)
apply (smt (verit, ccfv_SIG) AE_I2 alivex_Tx_pos)
using nn_integral_T_pos that
by (smt (verit) AE_I2 alivex_Tx_pos enn2real_ennreal ennreal_less_zero_iff
nn_integral_cong nn_integral_eq_integral)
proposition e_LBINT_p: "$e`β_x = (LBINT t:{0..}. $p_{t&x})"
unfolding life_expect_def apply (rewrite integral_eq_nn_integral, simp_all add: less_imp_le)
unfolding set_lebesgue_integral_def apply (rewrite integral_eq_nn_integral, simp_all)
apply (measurable, simp add: survive_def)
by (rewrite nn_integral_T_p) (simp add: indicator_mult_ennreal mult.commute)
corollary e_integral_p: "$e`β_x = integral {0..} (Ξ»t. $p_{t&x})"
proof -
have "$e`β_x = (LBINT t:{0..}. $p_{t&x})" using e_LBINT_p by simp
also have "β¦ = integral {0..} (Ξ»t. $p_{t&x})"
apply (rule set_borel_integral_eq_integral_nonneg, simp_all)
unfolding survive_def by simp
finally show ?thesis .
qed
lemma e_pos: "$e`β_x > 0" if "set_integrable lborel {0..} (Ξ»t. $p_{t&x})"
proof -
have "(β«β§+tβ{0..}. ennreal ($p_{t&x}) βlborel) = ennreal (β«tβ{0..}. $p_{t&x} βlborel)"
by (intro set_nn_integral_eq_set_integral; simp add: that)
also have "β¦ < β" using that by simp
finally have "(β«β§+ΞΎ. ennreal (T x ΞΎ) β(π β alive x)) < β" using nn_integral_T_p by simp
hence "integrable (π β alive x) (T x)"
by (smt (verit) alivex_Tx_pos integrableI_bounded nn_integral_cong real_norm_def
survival_model.Tx_alivex_measurable survival_model_axioms)
thus ?thesis by (rule e_pos_Tx)
qed
corollary e_pos': "$e`β_x > 0" if "(Ξ»t. $p_{t&x}) integrable_on {0..}"
apply (rule e_pos)
using that apply (rewrite integrable_on_iff_set_integrable_nonneg; simp)
unfolding survive_def by simp
lemma e_LBINT_p_Icc: "$e`β_x = (LBINT t:{0..n}. $p_{t&x})" if "x+n β₯ $Ο" for n::real
proof -
have [simp]: "{0..n} β© {n<..} = {}" using ivl_disj_int_one(7) by blast
have [simp]: "{0..n} βͺ {n<..} = {0..}"
by (smt (verit) ereal_less_le ivl_disj_un_one(7) leD that x_lt_psi)
have [simp]: "βt. n < t βΉ 0 β€ t" using that x_lt_psi by (smt (verit) ereal_less_le leD)
have [simp]: "βt. n < t βΉ $Ο β€ ereal (x+t)" using that by (simp add: le_ereal_le)
have gt_n_0: "has_bochner_integral lborel (Ξ»t. indicat_real {n<..} t * $p_{t&x}) 0"
apply (rewrite has_bochner_integral_cong[where N=lborel and g="Ξ»t.0" and y=0], simp_all)
using p_0_equiv that x_lt_psi
apply (smt (verit, ccfv_SIG) greaterThan_iff indicator_simps le_ereal_le linorder_not_le)
by (rule has_bochner_integral_zero)
hence gt_n: "set_integrable lborel {n<..} (Ξ»t. $p_{t&x})"
unfolding set_integrable_def using integrable.simps by auto
moreover have le_n: "set_integrable lborel {0..n} (Ξ»t. $p_{t&x})"
unfolding survive_def by (intro ccdfTx_integrable_Icc) simp
ultimately have "set_integrable lborel ({0..n} βͺ {n<..}) (Ξ»t. $p_{t&x})"
using set_integrable_Un by force
hence "set_integrable lborel {0..} (Ξ»t. $p_{t&x})" by force
thus ?thesis
apply (rewrite e_LBINT_p, simp)
apply (rewrite set_integral_Un[of "{0..n}" "{n<..}", simplified], simp_all add: gt_n le_n)
unfolding set_lebesgue_integral_def using gt_n_0 has_bochner_integral_integral_eq by fastforce
qed
lemma e_integral_p_Icc: "$e`β_x = integral {0..n} (Ξ»t. $p_{t&x})" if "x+n β₯ $Ο" for n::real
using that apply (rewrite e_LBINT_p_Icc, simp_all)
using ccdfTx_integrable_Icc unfolding survive_def
by (rewrite set_borel_integral_eq_integral; simp)
lemma temp_e_le_n: "$e`β_{x:n} β€ n" if "n β₯ 0" for n::real
proof -
have nni_n: "(β«β§+_. ennreal n β(π β alive x)) = ennreal n"
by (rewrite nn_integral_const, rewrite alivex_PS.emeasure_space_1) simp
hence hbi_n: "has_bochner_integral (π β alive x) (Ξ»_. n) n"
by (intro has_bochner_integral_nn_integral; simp add: that)
hence "integrable (π β alive x) (Ξ»_. n)" by simp
moreover have "integrable (π β alive x) (λξ. min (T x ΞΎ) n)"
proof -
have "(β«β§+ΞΎ. ennreal (norm (min (T x ΞΎ) n)) β(π β alive x)) β€ β«β§+_. ennreal n β(π β alive x)"
apply (rule nn_integral_mono, rule ennreal_leI)
apply (rewrite real_norm_def, rewrite abs_of_nonneg; simp add: that)
by (smt (verit) alivex_Tx_pos)
also have "β¦ < β" using nni_n by simp
finally have "(β«β§+ΞΎ. ennreal (norm (min (T x ΞΎ) n)) β(π β alive x)) < β" .
thus ?thesis by (intro integrableI_bounded; simp)
qed
ultimately have "$e`β_{x:n} β€ integralβ§L (π β alive x) (Ξ»_. n)"
unfolding temp_life_expect_def by (intro integral_mono; simp)
also have "β¦ = n" using hbi_n has_bochner_integral_iff by blast
finally show ?thesis .
qed
lemma temp_e_P: "$e`β_{x:n} =
MM_PS.expectation (λξ. indicator (alive x) ΞΎ * min (T x ΞΎ) n) / π«(ΞΎ in π. T x ΞΎ > 0)"
if "n β₯ 0" for n::real
unfolding temp_life_expect_def
by (rewrite MM_PS.integral_cond_prob_space_nn; simp add: alive_T that)
lemma temp_e_LBINT_p: "$e`β_{x:n} = (LBINT t:{0..n}. $p_{t&x})" if "n β₯ 0" for n::real
proof -
let ?minTxn = "λξ. min (T x ξ) n"
let ?F = "cdf (distr (π β alive x) borel (T x))"
let ?Fn = "cdf (distr (π β alive x) borel ?minTxn)"
interpret distrTxn_RD: real_distribution "distr (π β alive x) borel ?minTxn" by (simp add: that)
have [simp]: "βΞΎ. ΞΎ β space (π β alive x) βΉ 0 β€ T x ΞΎ" by (smt (verit) alivex_Tx_pos)
have "(β«β§+ΞΎ. ennreal (min (T x ΞΎ) n) β(π β alive x)) = (β«β§+tβ{0..}. ennreal (1 - ?Fn t) βlborel)"
by (rewrite alivex_PS.expectation_nonneg_tail; simp add: that)
also have "β¦ = (β«β§+tβ{0..}. (ennreal (1 - ?F t) * indicator {..<n} t) βlborel)"
apply (rule nn_integral_cong)
by (rewrite alivex_PS.cdf_distr_min; simp add: indicator_mult_ennreal mult.commute)
also have "β¦ = (β«β§+tβ{0..<n}. ennreal (1 - ?F t) βlborel)"
apply (rule nn_integral_cong) using nn_integral_set_ennreal
by (smt (verit, best) Int_def atLeastLessThan_def ennreal_mult_right_cong
indicator_simps mem_Collect_eq mult.commute mult_1)
also have "β¦ = (β«β§+tβ{0..n}. ennreal (1 - ?F t) βlborel)"
proof -
have "sym_diff {0..<n} {0..n} = {n}" using that by force
thus ?thesis by (intro nn_integral_null_delta; force)
qed
also have "β¦ = ennreal (LBINT t:{0..n}. $p_{t&x})"
proof -
have "set_integrable lborel {0..n} (Ξ»t. $p_{t&x})"
unfolding survive_def by (intro ccdfTx_integrable_Icc) simp
thus ?thesis
unfolding set_lebesgue_integral_def unfolding set_integrable_def
apply (rewrite nn_integral_eq_integral[THEN sym]; simp)
apply (rule nn_integral_cong, simp)
unfolding survive_def using distrTx_RD.ccdf_cdf distrTx_RD.prob_space nn_integral_set_ennreal
by (simp add: indicator_mult_ennreal mult.commute)
qed
finally have "(β«β§+ΞΎ. ennreal (min (T x ΞΎ) n) β(π β alive x)) =
ennreal (LBINT t:{0..n}. $p_{t&x})" .
thus ?thesis
unfolding temp_life_expect_def by (rewrite integral_eq_nn_integral; simp add: that)
qed
lemma temp_e_integral_p: "$e`β_{x:n} = integral {0..n} (Ξ»t. $p_{t&x})" if "n β₯ 0" for n::real
using that apply (rewrite temp_e_LBINT_p, simp_all)
using ccdfTx_integrable_Icc unfolding survive_def
by (rewrite set_borel_integral_eq_integral; simp)
lemma e_eq_temp: "$e`β_x = $e`β_{x:n}" if "n β₯ 0" "x+n β₯ $Ο" for n::real
using that e_LBINT_p_Icc temp_e_LBINT_p by simp
lemma curt_e_P: "$e_x =
MM_PS.expectation (λξ. indicator (alive x) ΞΎ * βT x ΞΎβ) / π«(ΞΎ in π. T x ΞΎ > 0)"
unfolding curt_life_expect_def
apply (rewrite MM_PS.integral_cond_prob_space_nn; simp add: alive_T)
by (metis (no_types, lifting) Bochner_Integration.integral_cong indicator_simps of_int_0 of_int_1)
lemma curt_e_sum_P: "$e_x = (βk. π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0))"
if "summable (Ξ»k. π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0))"
proof -
let ?F_flrTx = "cdf (distr (π β alive x) borel (λξ. βT x ΞΎβ))"
have [simp]: "βΞΎ. ΞΎ β space (π β alive x) βΉ 0 β€ T x ΞΎ" by (smt (verit) alivex_Tx_pos)
have "integralβ§N (π β alive x) (λξ. ennreal βT x ΞΎβ) =
(β«β§+tβ{0..}. ennreal (1 - ?F_flrTx t) βlborel)"
by (rewrite alivex_PS.expectation_nonneg_tail; simp)
also have "β¦ = (β«β§+tβ{0::real..}. ennreal π«(ΞΎ in π. T x ΞΎ β₯ βtβ + 1 Β¦ T x ΞΎ > 0) βlborel)"
proof -
{ fix t::real assume "t β₯ 0"
hence "1 - ?F_flrTx t = π«(ΞΎ in π. T x ΞΎ β₯ real_of_int βtβ + 1 Β¦ T x ΞΎ > 0)"
proof -
have "1 - ?F_flrTx t = 1 - π«(ΞΎ in (π β alive x). T x ΞΎ < real_of_int βtβ + 1)"
by (rewrite alivex_PS.cdf_distr_floor_P; simp)
also have "β¦ = 1 - π«(ΞΎ in π. T x ΞΎ < real_of_int βtβ + 1 Β¦ T x ΞΎ > 0)"
using alive_T by (rewrite MM_PS.cond_prob_space_cond_prob; simp)
also have "β¦ = π«(ΞΎ in π. T x ΞΎ β₯ real_of_int βtβ + 1 Β¦ T x ΞΎ > 0)"
by (rewrite not_le[THEN sym], rewrite MM_PS.cond_prob_neg; simp)
finally show ?thesis .
qed }
thus ?thesis
apply -
by (rule nn_set_integral_cong2, rule AE_I2) simp
qed
also have "β¦ = (βk. β«β§+tβ{k..<k+1}. ennreal π«(ΞΎ in π. T x ΞΎ β₯ βtβ + 1 Β¦ T x ΞΎ > 0) βlborel)"
apply (rewrite nn_integral_disjoint_family[THEN sym]; simp)
apply (rewrite add.commute, rule Ico_nat_disjoint)
by (rewrite Ico_nat_union[THEN sym], simp add: add.commute)
also have "β¦ = (βk. β«β§+tβ{k..<k+1::nat}. ennreal π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0) βlborel)"
proof -
{ fix k::nat and t::real
assume "real k β€ t" and "t < 1 + real k"
hence "real_of_int βtβ = real k"
by (metis add.commute floor_eq2 of_int_of_nat_eq)
hence "π«(ΞΎ in π. T x ΞΎ β₯ real_of_int βtβ + 1 Β¦ T x ΞΎ > 0) =
π«(ΞΎ in π. T x ΞΎ β₯ 1 + real k Β¦ T x ΞΎ > 0)"
by (simp add: add.commute) }
thus ?thesis
apply -
apply (rule suminf_cong, rule nn_set_integral_cong2, rule AE_I2)
by (rule impI) simp
qed
also have "β¦ = (βk. ennreal π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0))"
by (rewrite nn_integral_cmult_indicator; simp add: add.commute)
also have "β¦ = ennreal (βk. π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0))"
by (rewrite suminf_ennreal2; simp add: that)
finally have "integralβ§N (π β alive x) (λξ. ennreal βT x ΞΎβ) =
ennreal (βk. π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0))" .
hence "integralβ§L (π β alive x) (λξ. βT x ΞΎβ) = (βk. π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0))"
apply (rewrite integral_eq_nn_integral; simp)
apply (rewrite enn2real_ennreal; simp add: add.commute)
apply (rule suminf_nonneg; simp?)
by (rewrite add.commute, simp add: that)
thus ?thesis unfolding curt_life_expect_def by (simp add: add.commute)
qed
lemma curt_e_sum_P_finite: "$e_x = (βk<n. π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0))"
if "x+n+1 > $Ο" for n::nat
proof -
from that have psi_fin: "$Ο < β" by force
let ?P = "Ξ»k::nat. π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0)"
let ?P_fin = "Ξ»k::nat. if kβ{..<n} then ?P k else 0"
have "βk. ?P k = ?P_fin k"
proof -
fix k
show "?P k = ?P_fin k"
proof (cases βΉk β {..<n}βΊ)
case True
thus ?thesis by simp
next
case False
hence "Β¬ k < n" by simp
hence "x + k + 1 > real_of_ereal $Ο"
using that psi_nonneg real_of_ereal_ord_simps(4) by fastforce
hence "{ΞΎ β space π. T x ΞΎ β₯ k + 1 β§ T x ΞΎ > 0} β {ΞΎ β space π. X ΞΎ > real_of_ereal $Ο}"
unfolding futr_life_def using that less_ereal_le of_nat_1 of_nat_add by force
hence "π«(ΞΎ in π. T x ΞΎ β₯ k + 1 β§ T x ΞΎ > 0) β€ π«(ΞΎ in π. X ΞΎ > real_of_ereal $Ο)"
by (intro MM_PS.finite_measure_mono, simp_all)
also have "β¦ = 0" using MM_PS.ccdf_distr_P X_RV ccdfX_psi_0 psi_fin by presburger
finally have "π«(ΞΎ in π. T x ΞΎ β₯ k + 1 β§ T x ΞΎ > 0) = 0" using measure_le_0_iff by blast
hence "?P k = 0" unfolding cond_prob_def by (simp add: add.commute)
thus ?thesis by simp
qed
qed
moreover have "?P_fin sums (βk<n. ?P k)" using sums_If_finite_set by force
ultimately have β: "?P sums (βk<n. ?P k)" using sums_cong by simp
moreover hence "summable ?P" using sums_summable by blast
ultimately have "?P sums $e_x" using curt_e_sum_P by force
hence "$e_x = (βk<n. ?P k)" by (rewrite sums_unique2[of "?P"]; simp add: β)
thus ?thesis by (simp add: add.commute)
qed
lemma curt_e_sum_p: "$e_x = (βk. $p_{k+1&x})"
if "summable (Ξ»k. $p_{k+1&x})" "βk::nat. isCont (Ξ»t. $p_{t&x}) (k+1)"
proof -
have "βk::nat. $p_{k+1&x} = π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0)"
apply (rewrite p_PTx_ge_ccdf_isCont, simp_all)
using that(2) isCont_ccdfX_ccdfTx unfolding survive_def by simp
thus ?thesis using that p_PTx_ge_ccdf_isCont curt_e_sum_P by presburger
qed
lemma curt_e_rec: "$e_x = $p_x * (1 + $e_(x+1))"
if "summable (Ξ»k. $p_{k+1&x})" "βk::nat. isCont (Ξ»t. $p_{t&x}) (real k + 1)" "x+1 < $Ο"
proof -
have px_neq_0[simp]: "$p_x β 0" using p_0_equiv that by auto
have "(Ξ»k. $p_{k+1&x}) sums $e_x"
using that apply (rewrite curt_e_sum_p, simp_all add: add.commute)
by (rule summable_sums, simp add: that)
hence "(Ξ»k. $p_x * $p_{k&x+1}) sums $e_x"
apply (rewrite sums_cong[where g="Ξ»k. $p_{k+1&x}"]; simp?)
using p_mult by (smt (verit) of_nat_0_le_iff that(3) x_lt_psi)
hence "(Ξ»k. $p_{k&x+1}) sums ($e_x / $p_x)"
using sums_mult_D that by (smt (verit, best) linorder_not_le p_0_equiv sums_cong x_lt_psi)
hence p_e_p: "(Ξ»k. $p_{Suc k & x+1}) sums ($e_x / $p_x - $p_{0&x+1})"
using sums_split_initial_segment[where n=1] by force
moreover have "(Ξ»k. $p_{Suc k & x+1}) sums $e_(x+1)"
proof -
have [simp]: "summable (Ξ»k::nat. $p_{real k + 1 & x + 1})"
apply (intro sums_summable[where l="$e_x / $p_x - $p_{0&x+1}"])
using p_e_p by (simp add: add.commute)
have [simp]: "βk::nat. isCont (Ξ»t. $p_{t&x+1}) (real k + 1)"
proof -
fix k::nat
have "isCont (Ξ»t. $p_x * $p_{t-1&x+1}) (real k + 2)"
proof -
let ?S="{real k + 1 <..< real k + 3}"
have "open ?S" by simp
moreover have "real k + 2 β ?S" by simp
moreover have "βt. t β ?S βΉ $p_x * $p_{t-1&x+1} = $p_{t&x}"
using p_mult
by (smt (verit, del_insts) greaterThanLessThan_iff of_nat_0_le_iff that(3) x_lt_psi)
ultimately show ?thesis
apply (rewrite isCont_cong[where g="Ξ»t. $p_{t&x}"])
apply (rewrite eventually_nhds, blast)
using that by (smt (verit) of_nat_1 of_nat_add)
qed
hence "isCont (Ξ»t. $p_x * $p_{t-1&x+1} / $p_x) (real k + 2)"
by (intro isCont_divide[where g="Ξ»t. $p_x"], auto)
hence "isCont ((Ξ»t. $p_{t-1&x+1}) β (Ξ»t. t+1)) (real k + 1)"
by simp (rule continuous_at_compose, simp_all add: add.commute)
thus "isCont (Ξ»t. $p_{t&x+1}) (real k + 1)" unfolding comp_def by simp
qed
show ?thesis
apply (rewrite survival_model.curt_e_sum_p; simp add: survival_model_axioms that)
using summable_sums by (rewrite add.commute) force
qed
ultimately have "$e_x / $p_x - $p_{0&x+1} = $e_(x+1)" by (rule sums_unique2)
thus ?thesis
using p_0_1 that
by (smt (verit) px_neq_0 divide_mult_cancel mult.commute mult_cancel_left2 p_mult that(3))
qed
lemma curt_e_sum_p_finite: "$e_x = (βk<n. $p_{k+1&x})"
if "βk::nat. k < n βΉ isCont (Ξ»t. $p_{t&x}) (real k + 1)" "x+n+1 > $Ο" for n::nat
proof -
have "βk::nat. k < n βΉ $p_{k+1&x} = π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0)"
apply (rewrite p_PTx_ge_ccdf_isCont, simp_all)
using that isCont_ccdfX_ccdfTx unfolding survive_def by (smt (verit) of_nat_0_le_iff x_lt_psi)
thus ?thesis using that p_PTx_ge_ccdf_isCont curt_e_sum_P_finite by simp
qed
lemma temp_curt_e_P: "$e_{x:n} =
MM_PS.expectation (λξ. indicator (alive x) ΞΎ * βmin (T x ΞΎ) nβ) / π«(ΞΎ in π. T x ΞΎ > 0)"
if "n β₯ 0" for n::real
unfolding temp_curt_life_expect_def
apply (rewrite MM_PS.integral_cond_prob_space_nn; simp add: alive_T that)
apply (rule disjI2, rule Bochner_Integration.integral_cong; simp)
using indicator_simps of_int_0 of_int_1 by smt
lemma temp_curt_e_sum_P: "$e_{x:n} = (βk<n. π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0))" for n::nat
proof -
let ?F_flrminTx = "cdf (distr (π β alive x) borel (λξ. βmin (T x ΞΎ) nβ))"
have [simp]: "βΞΎ. ΞΎ β space (π β alive x) βΉ 0 β€ T x ΞΎ" by (smt (verit) alivex_Tx_pos)
have "integralβ§N (π β alive x) (λξ. ennreal βmin (T x ΞΎ) nβ) =
(β«β§+tβ{0..}. ennreal (1 - ?F_flrminTx t) βlborel)"
by (rewrite alivex_PS.expectation_nonneg_tail; simp)
also have "β¦ = (β«β§+tβ{0::real..}. ennreal
((1 - π«(ΞΎ in (π β alive x). T x ΞΎ < βtβ + 1)) * of_bool (βtβ + 1 β€ n)) βlborel)"
proof -
have "βt. t β₯ 0 βΉ ennreal (1 - ?F_flrminTx t) =
ennreal ((1 - π«(ΞΎ in (π β alive x). T x ΞΎ < βtβ + 1)) * of_bool (βtβ + 1 β€ n))"
proof -
fix t::real assume "t β₯ 0"
thus "ennreal (1 - ?F_flrminTx t) =
ennreal ((1 - π«(ΞΎ in (π β alive x). T x ΞΎ < βtβ + 1)) * of_bool (βtβ + 1 β€ n))"
proof (cases βΉβtβ + 1 β€ nβΊ)
case True
thus ?thesis
apply (rewrite alivex_PS.cdf_distr_floor_P; simp)
using min_less_iff_disj
by (smt (verit, ccfv_SIG) Collect_cong
floor_eq floor_less_cancel floor_of_nat of_int_floor_le)
next
case False
thus ?thesis
apply (rewrite alivex_PS.cdf_distr_floor_P; simp)
using min_less_iff_disj
by (smt (verit, ccfv_SIG) Collect_cong MM_PS.space_cond_prob_space alive_T alive_event
alivex_PS.prob_space mem_Collect_eq of_int_of_nat_eq of_nat_less_of_int_iff)
qed
qed
thus ?thesis
by (intro nn_set_integral_cong2, intro AE_I2) auto
qed
also have "β¦ = (β«β§+tβ{0..<n}. ennreal (1 - π«(ΞΎ in (π β alive x). T x ΞΎ < βtβ + 1)) βlborel)"
proof -
{ fix t::real
have "(βtβ + 1 β€ n) = (t < n)" by linarith
hence "βr::real.
ennreal (r * of_bool (βtβ + 1 β€ n)) * indicator {0..} t = ennreal r * indicator {0..<n} t"
unfolding atLeastLessThan_def by (simp add: indicator_def) }
thus ?thesis by simp
qed
also have "β¦ = (β«β§+tβ{0..<n}. ennreal π«(ΞΎ in (π β alive x). T x ΞΎ β₯ βtβ + 1) βlborel)"
by (rewrite alivex_PS.prob_neg[THEN sym]; simp add: not_less)
also have "β¦ = (βk<n. β«β§+tβ{k..<k+1}. ennreal π«(ΞΎ in (π β alive x). T x ΞΎ β₯ βtβ + 1) βlborel)"
apply (rewrite Ico_nat_union_finite[of n, THEN sym])
apply (rewrite nn_integral_disjoint_family_on_finite; simp add: add.commute)
apply (rule disjoint_family_on_mono[of _ "{0..}"]; simp)
by (rewrite add.commute, rule Ico_nat_disjoint)
also have "β¦ = (βk<n. ennreal π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0))"
proof -
{ fix k::nat
assume "k < n"
hence "(β«β§+tβ{k..<(1 + real k)}.
ennreal π«(ΞΎ in (π β alive x). T x ΞΎ β₯ real_of_int βtβ + 1) βlborel) =
π«(ΞΎ in π. T x ΞΎ β₯ 1 + real k Β¦ T x ΞΎ > 0)" (is "?LHS = ?RHS")
proof -
have "?LHS = (β«β§+tβ{k..<(1 + real k)}. ennreal π«(ΞΎ in (π β alive x). T x ΞΎ β₯ k + 1) βlborel)"
proof -
{ fix t::real
assume "k β€ t" "t < 1 + real k"
hence "real_of_int βtβ = real k" by (smt (verit) floor_eq2 of_int_of_nat_eq)
hence "π«(ΞΎ in (π β alive x). T x ΞΎ β₯ real_of_int βtβ + 1) =
π«(ΞΎ in (π β alive x). T x ΞΎ β₯ 1 + real k)"
by (simp add: add.commute) }
thus ?thesis by (intro nn_set_integral_cong2, intro AE_I2) auto
qed
also have "β¦ = ennreal π«(ΞΎ in (π β alive x). T x ΞΎ β₯ k + 1)"
by (rewrite nn_integral_cmult_indicator; simp)
also have "β¦ = ?RHS"
by (rewrite MM_PS.cond_prob_space_cond_prob, simp_all add: alive_T)
finally show ?thesis .
qed }
thus ?thesis by (intro sum.cong) auto
qed
also have "β¦ = ennreal (βk<n. π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0))" by simp
finally have "integralβ§N (π β alive x) (λξ. ennreal βmin (T x ΞΎ) nβ) =
ennreal (βk<n. π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0))" .
hence "integralβ§L (π β alive x) (λξ. βmin (T x ΞΎ) nβ) =
(βk<n. π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0))"
apply (intro nn_integral_eq_integrable[THEN iffD1, THEN conjunct2]; simp)
using MM_PS.cond_prob_nonneg by (meson sum_nonneg)
thus ?thesis unfolding temp_curt_life_expect_def by simp
qed
corollary curt_e_eq_temp: "$e_x = $e_{x:n}" if "x+n+1 > $Ο" for n::nat
using curt_e_sum_P_finite temp_curt_e_sum_P that by simp
lemma temp_curt_e_sum_p: "$e_{x:n} = (βk<n. $p_{k+1&x})"
if "βk::nat. k < n βΉ isCont (Ξ»t. $p_{t&x}) (real k + 1)" for n::nat
proof -
have "βk::nat. k < n βΉ $p_{k+1&x} = π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0)"
apply (rewrite p_PTx_ge_ccdf_isCont, simp_all)
using that isCont_ccdfX_ccdfTx unfolding survive_def by (smt (verit) of_nat_0_le_iff x_lt_psi)
thus ?thesis
apply (rewrite temp_curt_e_sum_P)
by (rule sum.cong) simp_all
qed
lemma temp_curt_e_rec: "$e_{x:n} = $p_x * (1 + $e_{x+1:n-1})"
if "βk::nat. k < n βΉ isCont (Ξ»t. $p_{t&x}) (real k + 1)" "x+1 < $Ο" "n β 0" for n::nat
proof -
have [simp]: "$p_x β 0" using p_0_equiv that by auto
have [simp]: "βk. k < n-1 βΉ isCont (Ξ»t. $p_{t&x+1}) (real k + 1)"
proof -
fix k::nat assume k_n: "k < n-1"
have "isCont (Ξ»t. $p_x * $p_{t-1&x+1}) (real k + 2)"
proof -
let ?S="{real k + 1 <..< real k + 3}"
have "open ?S" by simp
moreover have "real k + 2 β ?S" by simp
moreover have "βt. t β ?S βΉ $p_x * $p_{t-1&x+1} = $p_{t&x}"
using p_mult
by (smt (verit, del_insts) greaterThanLessThan_iff of_nat_0_le_iff that(2) x_lt_psi)
ultimately show ?thesis
apply (rewrite isCont_cong[where g="Ξ»t. $p_{t&x}"])
apply (rewrite eventually_nhds, blast)
using that k_n by (smt (verit) less_diff_conv of_nat_1 of_nat_add)
qed
hence "isCont (Ξ»t. $p_x * $p_{t-1&x+1} / $p_x) (real k + 2)"
by (intro isCont_divide[where g="Ξ»t. $p_x"], auto)
hence "isCont ((Ξ»t. $p_{t-1&x+1}) β (Ξ»t. t+1)) (real k + 1)"
by simp (rule continuous_at_compose, simp_all add: add.commute)
thus "isCont (Ξ»t. $p_{t&x+1}) (real k + 1)" unfolding comp_def by simp
qed
have "$p_x * (1 + $e_{x+1:n-1}) = $p_x * (1 + (βk<(n-1). $p_{k+1&x+1}))"
by (rewrite survival_model.temp_curt_e_sum_p; simp add: survival_model_axioms that)
also have "β¦ = $p_x + (βk<(n-1). $p_x * $p_{k+1&x+1})"
apply (rewrite distrib_left, simp)
by (rewrite vector_space_over_itself.scale_sum_right, simp)
also have "β¦ = $p_x + (βk<(n-1). $p_{k+2&x})"
apply (rewrite sum.cong, simp_all add: add.commute)
using p_mult by (smt (verit) of_nat_0_le_iff that(2) x_lt_psi)
also have "β¦ = (βk<Suc(n-1). $p_{k+1&x})"
apply (rewrite lessThan_atLeast0)+
by (rewrite sum.atLeast0_lessThan_Suc_shift) simp
also have "β¦ = $e_{x:n}" using that by (rewrite temp_curt_e_sum_p; simp)
finally show ?thesis by simp
qed
end
lemma p_set_integrable_shift:
"set_integrable lborel {0..} (Ξ»t. $p_{t&0}) β· set_integrable lborel {0..} (Ξ»t. $p_{t&x})"
if "x < $Ο" for x::real
proof -
have "set_integrable lborel {0..} (Ξ»t. $p_{t&0}) β· set_integrable lborel {x..} (Ξ»t. $p_{t&0})"
by (rule set_integrable_Ici_equiv)
(metis (no_types, lifting) ccdfX_integrable_Icc ccdfX_p set_integrable_cong)
also have "β¦ β· set_integrable lborel {0..} (Ξ»t. $p_{x+t&0})"
using set_integrable_Ici_shift[of x x] by force
also have "β¦ β· set_integrable lborel {0..} (Ξ»t. $p_{x+t&0} / $p_{x&0})"
using that p_0_equiv by (rewrite set_integrable_mult_divide_iff; simp)
also have "β¦ β· set_integrable lborel {0..} (Ξ»t. $p_{t&x})"
by (rule set_integrable_cong; simp) (simp add: ccdfTx_ccdfX ccdfX_p survive_def that)
finally show ?thesis .
qed
lemma e_p_e: "$e`β_x = $e`β_{x:n} + $p_{n&x} * $e`β_(x+n)"
if "set_integrable lborel {0..} (Ξ»t. $p_{t&x})" "n β₯ 0" "x+n < $Ο" for x n :: real
proof -
have [simp]: "ereal x < $Ο" using that by (simp add: ereal_less_le)
hence "$e`β_x = (LBINT t:{0..}. $p_{t&x})" by (simp add: e_LBINT_p)
also have "β¦ = (LBINT t:{0..n}. $p_{t&x}) + (LBINT t:{n..}. $p_{t&x})"
proof -
have "AE t in lborel. Β¬ (tβ{0..n} β§ tβ{n..})" using AE_lborel_singleton by force
moreover have "{0..} = {0..n} βͺ {n..}" using that by auto
moreover have "set_integrable lborel {0..n} (Ξ»t. $p_{t&x})"
using that
by (metis Icc_subset_Ici_iff atLeastAtMost_borel order.refl set_integrable_subset sets_lborel)
moreover have "set_integrable lborel {n..} (Ξ»t. $p_{t&x})"
using that by (metis atLeast_borel atLeast_subset_iff set_integrable_subset sets_lborel)
ultimately show ?thesis
using set_integral_Un_AE
by (metis (no_types, lifting) AE_cong atLeastAtMost_borel atLeast_borel sets_lborel)
qed
also have "β¦ = (LBINT t:{0..n}. $p_{t&x}) + $p_{n&x} * (LBINT t:{0..}. $p_{t & x+n})"
proof -
have "(LBINT t:{n..}. $p_{t&x}) = (LBINT t:{0..}. $p_{n+t & x})"
using lborel_set_integral_Ici_shift[of n _ n, simplified] by force
also have "β¦ = (LBINT t:{0..}. $p_{n&x} * $p_{t & x+n})"
apply (rule set_lebesgue_integral_cong; simp)
using that p_mult by force
finally show ?thesis by simp
qed
also have "β¦ = $e`β_{x:n} + $p_{n&x} * $e`β_(x+n)"
apply (rewrite temp_e_LBINT_p, (simp_all add: that)[2])
by (rewrite e_LBINT_p; simp add: that)
finally show ?thesis .
qed
proposition x_ex_mono: "x + $e`β_x β€ y + $e`β_y" if "x β€ y" "y < $Ο" for x y :: real
proof -
have x_lt_psi[simp]: "ereal x < $Ο" using that ereal_less_le by simp
show ?thesis
proof (cases βΉset_integrable lborel {0..} (Ξ»t. $p_{t&x})βΊ)
case True
hence "$e`β_x = $e`β_{x:y-x} + $p_{y-x&x}*$e`β_y" by (rewrite e_p_e[of x "y-x"]; simp add: that)
also have "β¦ β€ y - x + $e`β_y"
proof -
have "$e`β_{x:y-x} β€ y - x" using that by (intro temp_e_le_n; simp)
moreover have "$p_{y-x&x}*$e`β_y β€ $e`β_y"
using p_le_1 x_lt_psi that
by (smt (verit, ccfv_threshold) e_nonneg mult_less_cancel_right1)
ultimately show ?thesis by simp
qed
finally show ?thesis by simp
next
case False
hence "$e`β_x = 0"
using e_LBINT_p not_integrable_integral_eq
unfolding set_integrable_def set_lebesgue_integral_def
by simp
moreover have "$e`β_y = 0"
proof -
have "Β¬ set_integrable lborel {0..} (Ξ»t. $p_{t&y})"
using that False
apply (rewrite p_set_integrable_shift[THEN sym], simp)
by (rewrite p_set_integrable_shift[of x]; simp)
thus ?thesis
using e_LBINT_p not_integrable_integral_eq that
unfolding set_integrable_def set_lebesgue_integral_def
by simp
qed
ultimately show ?thesis using that by simp
qed
qed
proposition x_ex_const_equiv: "x + $e`β_x = y + $e`β_y β· $q_{y-x&x} = 0"
if "set_integrable lborel {0..} (Ξ»t. $p_{t&0})" "x β€ y" "y < $Ο" for x y :: real
proof -
have ey: "set_integrable lborel {0..} (Ξ»t. $p_{t&y})" using that p_set_integrable_shift by blast
have x_lt_psi[simp]: "ereal x < $Ο" using that ereal_less_le by simp
hence ex: "set_integrable lborel {0..} (Ξ»t. $p_{t&x})" using that p_set_integrable_shift by blast
show ?thesis
proof
assume const: "x + $e`β_x = y + $e`β_y"
hence "0 = y - x - $e`β_x + $e`β_y" by simp
also have "β¦ = y - x - $e`β_{x:y-x} - $p_{y-x&x}*$e`β_y + $e`β_y"
using e_p_e[of x "y-x"] ex that by simp
also have "β¦ = (y - x - $e`β_{x:y-x}) + (1 - $p_{y-x&x})*$e`β_y"
by (simp add: left_diff_distrib)
finally have "0 = (y - x - $e`β_{x:y-x}) + (1 - $p_{y-x&x})*$e`β_y" .
moreover have "y - x - $e`β_{x:y-x} β₯ 0" using temp_e_le_n that by simp
ultimately have "(1 - $p_{y-x&x})*$e`β_y = 0"
by (smt (verit, ccfv_threshold) e_nonneg mult_nonneg_nonneg p_le_1 that x_lt_psi)
moreover have "$e`β_y > 0" using that e_pos ey by simp
ultimately have "1 - $p_{y-x&x} = 0" by simp
thus "$q_{y-x&x} = 0" by (smt (verit) p_q_1 x_lt_psi)
next
interpret alivex_PS: prob_space "π β alive x"
by (rule MM_PS.cond_prob_space_correct, simp_all add: alive_def)
interpret distrTx_RD: real_distribution "distr (π β alive x) borel (T x)" by simp
assume "$q_{y-x&x} = 0"
hence p1: "$p_{y-x&x} = 1" using p_q_1 by (metis add.right_neutral x_lt_psi)
hence "βt. tβ{0..y-x} βΉ $p_{t&x} = 1"
unfolding survive_def using distrTx_RD.ccdf_nonincreasing
by simp (smt (verit) distrTx_RD.ccdf_bounded_prob)
hence "$e`β_{x:y-x} = y - x"
using that apply (rewrite temp_e_LBINT_p; simp)
by (rewrite set_lebesgue_integral_cong[where g="Ξ»_. 1"]; simp)
moreover have "$e`β_x = $e`β_{x:y-x} + $p_{y-x&x}*$e`β_y"
by (rewrite e_p_e[of x "y-x"]; simp add: that ex)
ultimately show "x + $e`β_x = y + $e`β_y" using p1 by simp
qed
qed
end
subsection βΉPiecewise Differentiable Survival FunctionβΊ
locale smooth_survival_function = survival_model +
assumes ccdfX_piecewise_differentiable[simp]:
"(ccdf (distr π borel X)) piecewise_differentiable_on UNIV"
begin
interpretation distrX_RD: real_distribution "distr π borel X"
using MM_PS.real_distribution_distr by simp
subsubsection βΉProperties of Survival Function for βΉXβΊβΊ
lemma ccdfX_continuous[simp]: "continuous_on UNIV (ccdf (distr π borel X))"
using ccdfX_piecewise_differentiable piecewise_differentiable_on_imp_continuous_on by fastforce
corollary ccdfX_borel_measurable[measurable]: "ccdf (distr π borel X) β borel_measurable borel"
by (rule borel_measurable_continuous_onI) simp
lemma ccdfX_nondifferentiable_finite_set[simp]:
"finite {x. Β¬ ccdf (distr π borel X) differentiable at x}"
proof -
obtain S where
fin: "finite S" and "βx. x β S βΉ (ccdf (distr π borel X)) differentiable at x"
using ccdfX_piecewise_differentiable unfolding piecewise_differentiable_on_def by blast
hence "{x. Β¬ ccdf (distr π borel X) differentiable at x} β S" by blast
thus ?thesis using finite_subset fin by blast
qed
lemma ccdfX_differentiable_open_set: "open {x. ccdf (distr π borel X) differentiable at x}"
using ccdfX_nondifferentiable_finite_set finite_imp_closed
by (metis (mono_tags, lifting) Collect_cong open_Collect_neg)
lemma ccdfX_differentiable_borel_set[measurable, simp]:
"{x. ccdf (distr π borel X) differentiable at x} β sets borel"
using ccdfX_differentiable_open_set by simp
lemma ccdfX_differentiable_AE:
"AE x in lborel. (ccdf (distr π borel X)) differentiable at x"
apply (rule AE_I'[of "{x. Β¬ ccdf (distr π borel X) differentiable at x}"], simp_all)
using ccdfX_nondifferentiable_finite_set by (simp add: finite_imp_null_set_lborel)
lemma deriv_ccdfX_measurable[measurable]: "deriv (ccdf (distr π borel X)) β borel_measurable borel"
proof -
have "set_borel_measurable borel UNIV (deriv (ccdf (distr π borel X)))"
by (rule piecewise_differentiable_on_deriv_measurable_real; simp)
thus ?thesis unfolding set_borel_measurable_def by simp
qed
subsubsection βΉProperties of Cumulative Distributive Function for βΉXβΊβΊ
lemma cdfX_piecewise_differentiable[simp]:
"(cdf (distr π borel X)) piecewise_differentiable_on UNIV"
by (rewrite distrX_RD.cdf_ccdf) (rule piecewise_differentiable_diff; simp)
lemma cdfX_continuous[simp]: "continuous_on UNIV (cdf (distr π borel X))"
using cdfX_piecewise_differentiable piecewise_differentiable_on_imp_continuous_on by fastforce
corollary cdfX_borel_measurable[measurable]: "cdf (distr π borel X) β borel_measurable borel"
by (rule borel_measurable_continuous_onI) simp
lemma cdfX_nondifferentiable_finite_set[simp]:
"finite {x. Β¬ cdf (distr π borel X) differentiable at x}"
using distrX_RD.differentiable_cdf_ccdf ccdfX_nondifferentiable_finite_set by simp
lemma cdfX_differentiable_open_set: "open {x. cdf (distr π borel X) differentiable at x}"
using distrX_RD.differentiable_cdf_ccdf ccdfX_differentiable_open_set by simp
lemma cdfX_differentiable_borel_set[measurable, simp]:
"{x. cdf (distr π borel X) differentiable at x} β sets borel"
using cdfX_differentiable_open_set by simp
lemma cdfX_differentiable_AE:
"AE x in lborel. (cdf (distr π borel X)) differentiable at x"
using ccdfX_differentiable_AE distrX_RD.differentiable_cdf_ccdf AE_iffI by simp
lemma deriv_cdfX_measurable[measurable]: "deriv (cdf (distr π borel X)) β borel_measurable borel"
proof -
have "set_borel_measurable borel UNIV (deriv (cdf (distr π borel X)))"
by (rule piecewise_differentiable_on_deriv_measurable_real; simp)
thus ?thesis unfolding set_borel_measurable_def by simp
qed
subsubsection βΉIntroduction of Probability Density Functions of βΉXβΊ and βΉT(x)βΊβΊ
definition pdfX :: "real β real"
where "pdfX x β‘ if cdf (distr π borel X) differentiable at x
then deriv (cdf (distr π borel X)) x else 0"
definition pdfT :: "real β real β real"
where "pdfT x t β‘ if cdf (distr (π β alive x) borel (T x)) differentiable at t
then deriv (cdf (distr (π β alive x) borel (T x))) t else 0"
lemma pdfX_measurable[measurable]: "pdfX β borel_measurable borel"
proof -
let ?cdfX = "cdf (distr π borel X)"
have "countable {x. Β¬ ?cdfX differentiable at x}"
using cdfX_nondifferentiable_finite_set uncountable_infinite by force
thus ?thesis
unfolding pdfX_def
apply -
by (rule measurable_discrete_difference
[where X="{x. Β¬ ?cdfX differentiable at x}" and f="deriv ?cdfX"]; simp)
qed
lemma distributed_pdfX: "distributed π lborel X pdfX"
proof -
let ?cdfX = "cdf (distr π borel X)"
obtain S where fin: "finite S" and diff: "βt. t β S βΉ ?cdfX differentiable at t"
using cdfX_piecewise_differentiable unfolding piecewise_differentiable_on_def by blast
{ fix t::real assume t_notin: "t β S"
have "?cdfX differentiable at t" using diff t_notin by simp
hence "(?cdfX has_real_derivative pdfX t) (at t)"
unfolding pdfX_def using DERIV_deriv_iff_real_differentiable by auto }
thus ?thesis
by (intro MM_PS.distributed_deriv_cdf[where S=S]; simp add: fin)
qed
lemma pdfT0_X: "pdfT 0 = pdfX"
unfolding pdfT_def pdfX_def using cdfT0_eq_cdfX psi_pos' by fastforce
subsubsection βΉProperties of Survival Function for βΉT(x)βΊβΊ
context
fixes x::real
assumes x_lt_psi[simp]: "x < $Ο"
begin
interpretation alivex_PS: prob_space "π β alive x"
by (rule MM_PS.cond_prob_space_correct; simp add: alive_def)
interpretation distrTx_RD: real_distribution "distr (π β alive x) borel (T x)" by simp
lemma ccdfTx_continuous_on_nonneg[simp]:
"continuous_on {0..} (ccdf (distr (π β alive x) borel (T x)))"
apply (rewrite continuous_on_eq_continuous_within, auto)
apply (rewrite continuous_ccdfX_ccdfTx[THEN sym], auto)
by (metis UNIV_I ccdfX_continuous continuous_at_imp_continuous_at_within
continuous_on_eq_continuous_within)
lemma ccdfTx_continuous[simp]: "continuous_on UNIV (ccdf (distr (π β alive x) borel (T x)))"
proof -
have [simp]: "{..0::real} βͺ {0..} = UNIV" by auto
have "continuous_on {..0} (ccdf (distr (π β alive x) borel (T x)))"
by (rule ccdfTx_continuous_on_nonpos) simp
moreover have "continuous_on {0..} (ccdf (distr (π β alive x) borel (T x)))" by simp
ultimately have "continuous_on ({..0} βͺ {0..}) (ccdf (distr (π β alive x) borel (T x)))"
by (intro continuous_on_closed_Un) simp_all
thus ?thesis by simp
qed
corollary ccdfTx_borel_measurable[measurable]:
"ccdf (distr (π β alive x) borel (T x)) β borel_measurable borel"
by (rule borel_measurable_continuous_onI) simp
lemma ccdfTx_nondifferentiable_finite_set[simp]:
"finite {t. Β¬ ccdf (distr (π β alive x) borel (T x)) differentiable at t}"
proof -
let ?P = "Ξ»t. ccdf (distr (π β alive x) borel (T x)) differentiable at t"
have "{t. t < 0 β§ Β¬ ?P t} = {}"
proof (rule equals0I)
fix t assume asm: "t β {t. t < 0 β§ Β¬ ?P t}"
hence "?P t" using ccdfTx_has_real_derivative_0_at_neg real_differentiable_def x_lt_psi by blast
with asm show False by simp
qed
hence "{t. Β¬ ?P t} β insert 0 {t. t > 0 β§ Β¬ ?P t}" by force
moreover have "finite {t. t > 0 β§ Β¬ ?P t}"
proof -
have "{t. Β¬ ccdf (distr π borel X) differentiable at (x+t)} =
plus (-x) ` {s. Β¬ ccdf (distr π borel X) differentiable at s}"
by force
hence "finite {t. Β¬ ccdf (distr π borel X) differentiable at (x+t)}"
using ccdfX_nondifferentiable_finite_set by simp
thus ?thesis
using finite_subset differentiable_ccdfX_ccdfTx
by (metis (no_types, lifting) mem_Collect_eq subsetI x_lt_psi)
qed
ultimately show ?thesis using finite_subset by auto
qed
lemma ccdfTx_differentiable_open_set:
"open {t. ccdf (distr (π β alive x) borel (T x)) differentiable at t}"
using ccdfTx_nondifferentiable_finite_set finite_imp_closed
by (metis (mono_tags, lifting) Collect_cong open_Collect_neg)
lemma ccdfTx_differentiable_borel_set[measurable, simp]:
"{t. ccdf (distr (π β alive x) borel (T x)) differentiable at t} β sets borel"
using ccdfTx_differentiable_open_set by simp
lemma ccdfTx_differentiable_AE:
"AE t in lborel. (ccdf (distr (π β alive x) borel (T x))) differentiable at t"
apply (rule AE_I'[of "{t. Β¬ ccdf (distr (π β alive x) borel (T x)) differentiable at t}"]; simp?)
using ccdfTx_nondifferentiable_finite_set by (simp add: finite_imp_null_set_lborel)
lemma ccdfTx_piecewise_differentiable[simp]:
"(ccdf (distr (π β alive x) borel (T x))) piecewise_differentiable_on UNIV"
proof -
have "βtβUNIV-{t. Β¬ ccdf (distr (π β alive x) borel (T x)) differentiable at t}.
ccdf (distr (π β alive x) borel (T x)) differentiable at t"
by auto
thus ?thesis
unfolding piecewise_differentiable_on_def
using ccdfTx_continuous ccdfTx_nondifferentiable_finite_set by blast
qed
lemma deriv_ccdfTx_measurable[measurable]:
"deriv (ccdf (distr (π β alive x) borel (T x))) β borel_measurable borel"
proof -
have "set_borel_measurable borel UNIV (deriv (ccdf (distr (π β alive x) borel (T x))))"
by (rule piecewise_differentiable_on_deriv_measurable_real; simp)
thus ?thesis unfolding set_borel_measurable_def by simp
qed
subsubsection βΉProperties of Cumulative Distributive Function for βΉT(x)βΊβΊ
lemma cdfTx_continuous[simp]:
"continuous_on UNIV (cdf (distr (π β alive x) borel (T x)))"
using distrTx_RD.cdf_ccdf ccdfTx_continuous by (simp add: continuous_on_eq_continuous_within)
corollary cdfTx_borel_measurable[measurable]:
"cdf (distr (π β alive x) borel (T x)) β borel_measurable borel"
by (rule borel_measurable_continuous_onI) simp
lemma cdfTx_nondifferentiable_finite_set[simp]:
"finite {t. Β¬ cdf (distr (π β alive x) borel (T x)) differentiable at t}"
using distrTx_RD.differentiable_cdf_ccdf by simp
lemma cdfTx_differentiable_open_set:
"open {t. cdf (distr (π β alive x) borel (T x)) differentiable at t}"
using distrTx_RD.differentiable_cdf_ccdf ccdfTx_differentiable_open_set by simp
lemma cdfTx_differentiable_borel_set[measurable, simp]:
"{t. cdf (distr (π β alive x) borel (T x)) differentiable at t} β sets borel"
using cdfTx_differentiable_open_set by simp
lemma cdfTx_differentiable_AE:
"AE t in lborel. (cdf (distr (π β alive x) borel (T x))) differentiable at t"
by (rewrite distrTx_RD.differentiable_cdf_ccdf, simp add: ccdfTx_differentiable_AE)
lemma cdfTx_piecewise_differentiable[simp]:
"(cdf (distr (π β alive x) borel (T x))) piecewise_differentiable_on UNIV"
using piecewise_differentiable_diff piecewise_differentiable_const ccdfTx_piecewise_differentiable
by (rewrite distrTx_RD.cdf_ccdf) blast
lemma deriv_cdfTx_measurable[measurable]:
"deriv (cdf (distr (π β alive x) borel (T x))) β borel_measurable borel"
proof -
have "set_borel_measurable borel UNIV (deriv (cdf (distr (π β alive x) borel (T x))))"
by (rule piecewise_differentiable_on_deriv_measurable_real; simp)
thus ?thesis unfolding set_borel_measurable_def by simp
qed
subsubsection βΉProperties of Probability Density Function of βΉT(x)βΊβΊ
lemma pdfTx_nonneg: "pdfT x t β₯ 0" for t::real
proof -
fix t
show "pdfT x t β₯ 0"
proof (cases βΉcdf (distr (π β alive x) borel (T x)) differentiable at tβΊ)
case True
have "mono_on UNIV (cdf (distr (π β alive x) borel (T x)))"
unfolding mono_on_def using distrTx_RD.cdf_nondecreasing by blast
moreover have "(cdf (distr (π β alive x) borel (T x)) has_real_derivative pdfT x t) (at t)"
unfolding pdfT_def using True DERIV_deriv_iff_real_differentiable by presburger
ultimately show ?thesis by (rule mono_on_imp_deriv_nonneg) simp
next
case False
thus ?thesis unfolding pdfT_def by simp
qed
qed
lemma pdfTx_neg_0: "pdfT x t = 0" if "t < 0" for t::real
proof -
let ?e = "-t/2"
have "(cdf (distr (π β alive x) borel (T x)) has_real_derivative 0) (at t)"
apply (rewrite DERIV_cong_ev[of t t _ "Ξ»_. 0" 0 0], simp_all add: that)
apply (rewrite eventually_nhds)
apply (rule exI[of _ "ball t ?e"], auto simp add: that)
by (rule cdfTx_nonpos_0; simp add: dist_real_def)
thus ?thesis unfolding pdfT_def by (meson DERIV_imp_deriv)
qed
lemma pdfTx_0_0: "pdfT x 0 = 0"
proof (cases βΉcdf (distr (π β alive x) borel (T x)) differentiable at 0βΊ)
case True
let ?cdfx = "cdf (distr (π β alive x) borel (T x))"
have "(?cdfx has_real_derivative 0) (at 0)"
proof -
from True obtain c where cdfx_deriv: "(?cdfx has_real_derivative c) (at 0)"
unfolding differentiable_def using has_real_derivative by blast
hence "(?cdfx has_real_derivative c) (at 0 within {..0})"
by (rule has_field_derivative_at_within)
moreover have "(?cdfx has_real_derivative 0) (at 0 within {..0})"
proof -
have "ββ©F t in at 0 within {..0}. ?cdfx t = 0"
proof -
{ fix t assume "t β {..0::real}" "t β 0" "dist t 0 < 1"
hence "?cdfx t = 0" using cdfTx_nonpos_0 x_lt_psi by blast }
hence "βd>0::real. βtβ{..0}. tβ 0 β§ dist t 0 < d βΆ ?cdfx t = 0" by (smt (verit))
thus ?thesis by (rewrite eventually_at) simp
qed
moreover have "?cdfx 0 = 0"
proof -
have "continuous (at 0 within {..0}) ?cdfx"
using True differentiable_imp_continuous_within differentiable_subset by blast
thus ?thesis by (simp add: cdfTx_nonpos_0)
qed
ultimately show ?thesis
by (rewrite has_field_derivative_cong_eventually[of _ "Ξ»_. 0::real" 0 "{..0}" 0]; simp)
qed
ultimately have "c = 0"
using has_real_derivative_iff_has_vector_derivative
apply (intro vector_derivative_unique_within[of 0 "{..0}" ?cdfx c 0]; blast?)
by (rewrite at_within_eq_bot_iff)
(metis closure_lessThan islimpt_in_closure limpt_of_closure
trivial_limit_at_left_real trivial_limit_within)
thus "(?cdfx has_real_derivative 0) (at 0)" using cdfx_deriv by simp
qed
thus ?thesis unfolding pdfT_def by (meson DERIV_imp_deriv)
next
case False
thus ?thesis unfolding pdfT_def by simp
qed
lemma pdfTx_nonpos_0: "pdfT x t = 0" if "t β€ 0" for t::real
using pdfTx_neg_0 pdfTx_0_0 that by force
lemma pdfTx_beyond_0: "pdfT x t = 0" if "x+t β₯ $Ο" for t::real
proof (cases βΉt β€ 0βΊ)
case True
thus ?thesis using pdfTx_nonpos_0 by simp
next
let ?cdfTx = "cdf (distr (π β alive x) borel (T x))"
case False
hence t_pos: "t > 0" by simp
thus ?thesis
proof -
have "(?cdfTx has_real_derivative 0) (at_right t)"
apply (rewrite has_field_derivative_cong_eventually[where g="Ξ»_. 1"], simp_all)
apply (rewrite eventually_at_right_field)
using that cdfTx_1_equiv
by (intro exI[of _"t+1"], auto simp add: le_ereal_less less_eq_ereal_def)
thus ?thesis unfolding pdfT_def
by (meson has_real_derivative_iff_has_vector_derivative has_vector_derivative_at_within
DERIV_deriv_iff_real_differentiable trivial_limit_at_right_real
vector_derivative_unique_within)
qed
qed
lemma pdfTx_pdfX: "pdfT x t = pdfX (x+t) / π«(ΞΎ in π. X ΞΎ > x)" if "t > 0" for t::real
proof (cases βΉcdf (distr π borel X) differentiable at (x+t)βΊ)
case True
let ?cdfX = "cdf (distr π borel X)"
let ?cdfTx = "cdf (distr (π β alive x) borel (T x))"
have [simp]: "?cdfTx differentiable at t" using differentiable_cdfX_cdfTx that True by simp
have "pdfT x t = deriv ?cdfTx t" unfolding pdfT_def using that differentiable_cdfX_cdfTx by simp
hence "(?cdfTx has_field_derivative (pdfT x t)) (at t)"
using True DERIV_deriv_iff_real_differentiable by simp
moreover have "βu. dist u t < t βΉ
?cdfX (x+u) / π«(ΞΎ in π. X ΞΎ > x) - (1 / π«(ΞΎ in π. X ΞΎ > x) - 1) = ?cdfTx u"
proof -
fix u::real
assume "dist u t < t"
hence [simp]: "u > 0" using dist_real_def by fastforce
have "?cdfX (x+u) / π«(ΞΎ in π. X ΞΎ > x) - (1 / π«(ΞΎ in π. X ΞΎ > x) - 1) =
(1 - π«(ΞΎ in π. X ΞΎ > x+u)) / π«(ΞΎ in π. X ΞΎ > x) - (1 / π«(ΞΎ in π. X ΞΎ > x) - 1)"
using MM_PS.ccdf_distr_P X_RV distrX_RD.cdf_ccdf distrX_RD.prob_space by presburger
also have "β¦ = 1 - π«(ΞΎ in π. X ΞΎ > x+u) / π«(ΞΎ in π. X ΞΎ > x)"
by (simp add: diff_divide_distrib)
also have "β¦ = ?cdfTx u"
apply (rewrite ccdfTx_PX[THEN sym], simp_all add: less_eq_real_def)
using distrTx_RD.cdf_ccdf distrTx_RD.prob_space by presburger
finally show "?cdfX (x+u) / π«(ΞΎ in π. X ΞΎ > x) - (1 / π«(ΞΎ in π. X ΞΎ > x) - 1) = ?cdfTx u" .
qed
ultimately have "((Ξ»u. ?cdfX (x+u) / π«(ΞΎ in π. X ΞΎ > x) - (1 / π«(ΞΎ in π. X ΞΎ > x) - 1))
has_field_derivative (pdfT x t)) (at t)"
apply -
by (rule has_field_derivative_transform_within[where d=t]; simp add: that)
hence "((Ξ»u. ?cdfX (x+u) / π«(ΞΎ in π. X ΞΎ > x)) has_field_derivative (pdfT x t)) (at t)"
unfolding has_field_derivative_def
using has_derivative_add_const[where c="1 / π«(ΞΎ in π. X ΞΎ > x) - 1"] by force
hence "((Ξ»u. ?cdfX (x+u) / π«(ΞΎ in π. X ΞΎ > x) * π«(ΞΎ in π. X ΞΎ > x)) has_field_derivative
pdfT x t * π«(ΞΎ in π. X ΞΎ > x)) (at t)"
using DERIV_cmult_right[where c="π«(ΞΎ in π. X ΞΎ > x)"] by force
hence "((Ξ»u. ?cdfX (x+u)) has_field_derivative pdfT x t * π«(ΞΎ in π. X ΞΎ > x)) (at t)"
unfolding has_field_derivative_def using has_derivative_transform PXx_pos x_lt_psi
by (smt (verit) Collect_cong UNIV_I nonzero_mult_div_cancel_right times_divide_eq_left)
hence "(?cdfX has_field_derivative pdfT x t * π«(ΞΎ in π. X ΞΎ > x)) (at (x+t))"
using DERIV_at_within_shift by force
moreover have "(?cdfX has_field_derivative deriv ?cdfX (x+t)) (at (x+t))"
using True DERIV_deriv_iff_real_differentiable by blast
ultimately have "pdfT x t * π«(ΞΎ in π. X ΞΎ > x) = deriv ?cdfX (x+t)"
by (simp add: DERIV_imp_deriv)
thus "pdfT x t = pdfX (x+t) / π«(ΞΎ in π. X ΞΎ > x)"
unfolding pdfX_def using True
by simp (metis PXx_pos nonzero_mult_div_cancel_right x_lt_psi zero_less_measure_iff)
next
case False
hence [simp]: "Β¬ cdf (distr (π β alive x) borel (T x)) differentiable at t"
using differentiable_cdfX_cdfTx that by simp
thus "pdfT x t = pdfX (x+t) / π«(ΞΎ in π. X ΞΎ > x)" unfolding pdfT_def pdfX_def using False by simp
qed
lemma pdfTx_measurable[measurable]: "pdfT x β borel_measurable borel"
proof -
let ?cdfTx = "cdf (distr (π β alive x) borel (T x))"
have "countable {x. Β¬ ?cdfTx differentiable at x}"
using cdfX_nondifferentiable_finite_set uncountable_infinite by force
thus ?thesis
unfolding pdfT_def
apply -
by (rule measurable_discrete_difference
[where X="{x. Β¬ ?cdfTx differentiable at x}" and f="deriv ?cdfTx"]; simp)
qed
lemma distributed_pdfTx: "distributed (π β alive x) lborel (T x) (pdfT x)"
proof -
let ?cdfTx = "cdf (distr (π β alive x) borel (T x))"
obtain S where fin: "finite S" and diff: "βt. t β S βΉ ?cdfTx differentiable at t"
using cdfTx_piecewise_differentiable unfolding piecewise_differentiable_on_def by blast
{ fix t::real assume t_notin: "t β S"
have "?cdfTx differentiable at t" using diff t_notin by simp
hence "(?cdfTx has_real_derivative pdfT x t) (at t)"
unfolding pdfT_def using DERIV_deriv_iff_real_differentiable by force }
thus ?thesis
by (intro alivex_PS.distributed_deriv_cdf[where S=S]; simp add: fin)
qed
lemma nn_integral_pdfTx_1: "(β«β§+s. pdfT x s βlborel) = 1"
proof -
have "(β«β§+s. pdfT x s βlborel) = emeasure (density lborel (pdfT x)) UNIV"
by (rewrite emeasure_density) simp_all
also have "β¦ = emeasure (distr (π β alive x) lborel (T x)) UNIV"
using distributed_pdfTx unfolding distributed_def by simp
also have "β¦ = 1"
by (metis distrTx_RD.emeasure_space_1 distrTx_RD.space_eq_univ distr_cong sets_lborel)
finally show ?thesis .
qed
corollary has_bochner_integral_pdfTx_1: "has_bochner_integral lborel (pdfT x) 1"
by (rule has_bochner_integral_nn_integral; simp add: pdfTx_nonneg nn_integral_pdfTx_1)
corollary LBINT_pdfTx_1: "(LBINT s. pdfT x s) = 1"
using has_bochner_integral_pdfTx_1 by (simp add: has_bochner_integral_integral_eq)
corollary pdfTx_has_integral_1: "(pdfT x has_integral 1) UNIV"
by (rule nn_integral_has_integral; simp add: pdfTx_nonneg nn_integral_pdfTx_1)
lemma set_nn_integral_pdfTx_1: "(β«β§+sβ{0..}. pdfT x s βlborel) = 1"
apply (rewrite nn_integral_pdfTx_1[THEN sym])
apply (rule nn_integral_cong)
using pdfTx_nonpos_0
by (metis atLeast_iff ennreal_0 indicator_simps(1) linorder_le_cases
mult.commute mult_1 mult_zero_left)
corollary has_bochner_integral_pdfTx_1_nonpos:
"has_bochner_integral lborel (Ξ»s. pdfT x s * indicator {0..} s) 1"
apply (rule has_bochner_integral_nn_integral, simp_all)
using pdfTx_nonneg apply simp
using set_nn_integral_pdfTx_1 by (simp add: nn_integral_set_ennreal)
corollary set_LBINT_pdfTx_1: "(LBINT s:{0..}. pdfT x s) = 1"
unfolding set_lebesgue_integral_def
using has_bochner_integral_pdfTx_1_nonpos has_bochner_integral_integral_eq
apply (simp, rewrite mult.commute)
by (smt (verit) Bochner_Integration.integral_cong has_bochner_integral_integral_eq)
corollary pdfTx_has_integral_1_nonpos: "(pdfT x has_integral 1) {0..}"
proof -
have "set_integrable lebesgue {0..} (pdfT x)"
unfolding set_integrable_def
apply (rewrite integrable_completion, simp_all)
using has_bochner_integral_pdfTx_1_nonpos by (rewrite mult.commute, rule integrable.intros)
moreover have "(LINT s:{0..}|lebesgue. pdfT x s) = 1"
using set_LBINT_pdfTx_1 unfolding set_lebesgue_integral_def
by (rewrite integral_completion; simp)
ultimately show ?thesis using has_integral_set_lebesgue by force
qed
lemma set_nn_integral_pdfTx_PTx: "(β«β§+sβA. pdfT x s βlborel) = π«(ΞΎ in π. T x ΞΎ β A Β¦ T x ΞΎ > 0)"
if "A β sets lborel" for A :: "real set"
proof -
have [simp]: "A β sets borel" using that by simp
have "(β«β§+sβA. pdfT x s βlborel) = emeasure (density lborel (pdfT x)) A"
using that by (rewrite emeasure_density; force)
also have "β¦ = emeasure (distr (π β alive x) lborel (T x)) A"
using distributed_pdfTx unfolding distributed_def by simp
also have "β¦ = ennreal π«(ΞΎ in (π β alive x). T x ΞΎ β A)"
apply (rewrite emeasure_distr, simp_all)
apply (rewrite finite_measure.emeasure_eq_measure, simp)
by (smt (verit) Collect_cong vimage_eq Int_def)
also have "β¦ = ennreal π«(ΞΎ in π. T x ΞΎ β A Β¦ T x ΞΎ > 0)"
unfolding alive_def
apply (rewrite MM_PS.cond_prob_space_cond_prob[THEN sym], simp_all add: pred_def futr_life_def)
using borel_measurable_diff X_RV that by measurable
finally show ?thesis .
qed
lemma pdfTx_set_integrable: "set_integrable lborel A (pdfT x)" if "A β sets lborel"
unfolding set_integrable_def
using that pdfTx_nonneg apply (intro integrableI_nonneg, simp_all)
apply (rewrite mult.commute)
using set_nn_integral_pdfTx_PTx that
by (metis (no_types, lifting) ennreal_indicator ennreal_less_top ennreal_mult' nn_integral_cong)
lemma set_integral_pdfTx_PTx: "(LBINT s:A. pdfT x s) = π«(ΞΎ in π. T x ΞΎ β A Β¦ T x ΞΎ > 0)"
if "A β sets lborel" for A :: "real set"
unfolding set_lebesgue_integral_def
apply (rewrite integral_eq_nn_integral)
using that apply (simp_all add: pdfTx_nonneg)
apply (rewrite indicator_mult_ennreal[THEN sym], rewrite mult.commute)
by (rewrite set_nn_integral_pdfTx_PTx; simp)
lemma pdfTx_has_integral_PTx: "(pdfT x has_integral π«(ΞΎ in π. T x ΞΎ β A Β¦ T x ΞΎ > 0)) A"
if "A β sets lborel" for A :: "real set"
proof -
have "((Ξ»s. pdfT x s * indicat_real A s) has_integral π«(ΞΎ in π. T x ΞΎ β A Β¦ T x ΞΎ > 0)) UNIV"
using that pdfTx_nonneg apply (intro nn_integral_has_integral, simp_all)
using set_nn_integral_pdfTx_PTx that by (simp add: nn_integral_set_ennreal)
thus ?thesis
by (smt (verit) has_integral_cong has_integral_restrict_UNIV
indicator_eq_0_iff indicator_simps(1) mult_cancel_left2 mult_eq_0_iff)
qed
corollary pdfTx_has_integral_PTx_Icc:
"(pdfT x has_integral π«(ΞΎ in π. a β€ T x ΞΎ β§ T x ΞΎ β€ b Β¦ T x ΞΎ > 0)) {a..b}" for a b :: real
using pdfTx_has_integral_PTx[of "{a..b}"] by simp
corollary pdfTx_integrable_on_Icc: "pdfT x integrable_on {a..b}" for a b :: real
using pdfTx_has_integral_PTx_Icc by auto
end
subsubsection βΉProperties of Probability Density Function of βΉXβΊβΊ
lemma pdfX_nonneg: "pdfX x β₯ 0" for x::real
using pdfTx_nonneg pdfT0_X psi_pos' by smt
lemma pdfX_nonpos_0: "pdfX x = 0" if "x β€ 0" for x::real
using pdfTx_nonpos_0 pdfT0_X psi_pos' that by smt
lemma pdfX_beyond_0: "pdfX x = 0" if "x β₯ $Ο" for x::real
using pdfTx_beyond_0 pdfT0_X psi_pos' that by smt
lemma nn_integral_pdfX_1: "integralβ§N lborel pdfX = 1"
using nn_integral_pdfTx_1 pdfT0_X psi_pos' by metis
corollary has_bochner_integral_pdfX_1: "has_bochner_integral lborel pdfX 1"
by (rule has_bochner_integral_nn_integral; simp add: pdfX_nonneg nn_integral_pdfX_1)
corollary LBINT_pdfX_1: "(LBINT s. pdfX s) = 1"
using has_bochner_integral_pdfX_1 by (simp add: has_bochner_integral_integral_eq)
corollary pdfX_has_integral_1: "(pdfX has_integral 1) UNIV"
by (rule nn_integral_has_integral; simp add: pdfX_nonneg nn_integral_pdfX_1)
lemma set_nn_integral_pdfX_PX: "set_nn_integral lborel A pdfX = π«(ΞΎ in π. X ΞΎ β A)"
if "A β sets lborel" for A :: "real set"
using PT0_eq_PX_lborel that
by (rewrite pdfT0_X[THEN sym], rewrite set_nn_integral_pdfTx_PTx; simp)
lemma pdfX_set_integrable: "set_integrable lborel A pdfX" if "A β sets lborel" for A :: "real set"
using pdfTx_set_integrable pdfT0_X psi_pos' that by smt
lemma set_integral_pdfX_PX: "(LBINT s:A. pdfX s) = π«(ΞΎ in π. X ΞΎ β A)"
if "A β sets lborel" for A :: "real set"
using PT0_eq_PX_lborel that by (rewrite pdfT0_X[THEN sym], rewrite set_integral_pdfTx_PTx; simp)
lemma pdfX_has_integral_PX: "(pdfX has_integral π«(ΞΎ in π. X ΞΎ β A)) A"
if "A β sets lborel" for A :: "real set"
using that apply (rewrite pdfT0_X[THEN sym], rewrite PT0_eq_PX_lborel[THEN sym], simp)
by (rule pdfTx_has_integral_PTx; simp)
corollary pdfX_has_integral_PX_Icc: "(pdfX has_integral π«(ΞΎ in π. a β€ X ΞΎ β§ X ΞΎ β€ b)) {a..b}"
for a b :: real
using pdfX_has_integral_PX[of "{a..b}"] by simp
corollary pdfX_integrable_on_Icc: "pdfX integrable_on {a..b}" for a b :: real
using pdfX_has_integral_PX_Icc by auto
subsubsection βΉRelations between Life Expectation and Probability Density FunctionβΊ
context
fixes x::real
assumes x_lt_psi[simp]: "x < $Ο"
begin
interpretation alivex_PS: prob_space "π β alive x"
by (rule MM_PS.cond_prob_space_correct; simp add: alive_def)
interpretation distrTx_RD: real_distribution "distr (π β alive x) borel (T x)" by simp
proposition nn_integral_T_pdfT:
"(β«β§+ΞΎ. ennreal (g (T x ΞΎ)) β(π β alive x)) = (β«β§+sβ{0..}. ennreal (pdfT x s * g s) βlborel)"
if "g β borel_measurable lborel" for g :: "real β real"
proof -
have "(β«β§+ΞΎ. ennreal (g (T x ΞΎ)) β(π β alive x)) = β«β§+s. ennreal (pdfT x s) * ennreal (g s) βlborel"
proof -
have "distributed (π β alive x) lborel (T x) (Ξ»s. ennreal (pdfT x s))"
by (intro distributed_pdfTx) simp
moreover have "(Ξ»s. ennreal (g s)) β borel_measurable borel" using that by measurable
ultimately show ?thesis by (rewrite distributed_nn_integral; simp)
qed
also have "β¦ = β«β§+s. ennreal (pdfT x s * g s) βlborel" using ennreal_mult' pdfTx_nonneg by force
also have "β¦ = (β«β§+sβ{0..}. ennreal (pdfT x s * g s) βlborel)"
apply (rule nn_integral_cong, simp)
by (metis atLeast_iff ennreal_0 indicator_simps linorder_not_le mult_1 mult_commute_abs
mult_zero_left pdfTx_neg_0 x_lt_psi)
finally show ?thesis .
qed
lemma expectation_LBINT_pdfT_nonneg:
"alivex_PS.expectation (λξ. g (T x ξ)) = (LBINT s:{0..}. pdfT x s * g s)"
if "βs. s β₯ 0 βΉ g s β₯ 0" "g β borel_measurable lborel" for g :: "real β real"
using that apply (rewrite integral_eq_nn_integral, simp)
apply (rule AE_I2, metis alivex_Tx_pos less_imp_le)
unfolding set_lebesgue_integral_def apply (rewrite integral_eq_nn_integral, simp_all)
apply (rule AE_I2,
metis indicator_pos_le pdfTx_nonpos_0 x_lt_psi zero_le_mult_iff zero_le_square pdfTx_nonneg)
by (rewrite nn_integral_T_pdfT) (simp_all add: indicator_mult_ennreal mult.commute)
corollary expectation_integral_pdfT_nonneg:
"alivex_PS.expectation (λξ. g (T x ξ)) = integral {0..} (λs. pdfT x s * g s)"
if "βs. s β₯ 0 βΉ g s β₯ 0" "g β borel_measurable lborel" for g :: "real β real"
proof -
have "alivex_PS.expectation (λξ. g (T x ξ)) = (LBINT s:{0..}. pdfT x s * g s)"
using expectation_LBINT_pdfT_nonneg that by simp
also have "β¦ = integral {0..} (Ξ»s. pdfT x s * g s)"
using that pdfTx_nonneg by (intro set_borel_integral_eq_integral_nonneg; simp)
finally show ?thesis .
qed
proposition expectation_LBINT_pdfT:
"alivex_PS.expectation (λξ. g (T x ξ)) = (LBINT s:{0..}. pdfT x s * g s)"
if "set_integrable lborel {0..} (Ξ»s. pdfT x s * g s)" "g β borel_measurable lborel"
for g :: "real β real"
proof -
have pg_fin: "(β«β§+ΞΎ. ennreal (g (T x ΞΎ)) β(π β alive x)) β β"
using that apply (rewrite nn_integral_T_pdfT, simp)
using that unfolding set_integrable_def apply (rewrite in asm real_integrable_def, simp)
by (simp add: indicator_mult_ennreal mult.commute)
moreover have mg_fin: "(β«β§+ΞΎ. ennreal (- g (T x ΞΎ)) β(π β alive x)) β β"
using that apply (rewrite nn_integral_T_pdfT[of "Ξ»s. - g s"], simp)
using that unfolding set_integrable_def apply (rewrite in asm real_integrable_def, simp)
by (simp add: indicator_mult_ennreal mult.commute)
ultimately have [simp]: "integrable (π β alive x) (λξ. g (T x ΞΎ))"
using that by (rewrite real_integrable_def; simp)
have "(β«β§+sβ{0..}. ennreal (pdfT x s * max 0 (g s)) βlborel) =
(β«β§+sβ{0..}. ennreal (pdfT x s * g s) βlborel)"
using SPMF.ennreal_max_0 ennreal_mult' pdfTx_nonneg x_lt_psi by presburger
also have "β¦ < β"
using pg_fin nn_integral_T_pdfT that top.not_eq_extremum by auto
finally have "(β«β§+sβ{0..}. ennreal (pdfT x s * max 0 (g s)) βlborel) < β" .
hence [simp]: "set_integrable lborel {0..} (Ξ»s. pdfT x s * max 0 (g s))"
unfolding set_integrable_def using that apply (intro integrableI_nonneg, simp_all)
using pdfTx_nonneg apply (intro AE_I2, force)
by (metis (no_types, lifting) indicator_mult_ennreal mult.commute nn_integral_cong)
have "(β«β§+sβ{0..}. ennreal (pdfT x s * max 0 (- g s)) βlborel) =
(β«β§+sβ{0..}. ennreal (pdfT x s * - g s) βlborel)"
using SPMF.ennreal_max_0 ennreal_mult' pdfTx_nonneg x_lt_psi by presburger
also have "β¦ < β"
using mg_fin nn_integral_T_pdfT[of "Ξ»s. - g s"] that top.not_eq_extremum by force
finally have "(β«β§+sβ{0..}. ennreal (pdfT x s * max 0 (- g s)) βlborel) < β" .
hence [simp]: "set_integrable lborel {0..} (Ξ»s. pdfT x s * max 0 (- g s))"
unfolding set_integrable_def using that apply (intro integrableI_nonneg, simp_all)
using pdfTx_nonneg apply (intro AE_I2, force)
by (metis (no_types, lifting) indicator_mult_ennreal mult.commute nn_integral_cong)
have "alivex_PS.expectation (λξ. g (T x ξ)) =
alivex_PS.expectation (λξ. max 0 (g (T x ξ))) - alivex_PS.expectation (λξ. max 0 (- g (T x ξ)))"
by (rewrite Bochner_Integration.integral_cong
[where N="π β alive x" and g="λξ. max 0 (g (T x ΞΎ)) - max 0 (- g (T x ΞΎ))"]; simp)
moreover have "alivex_PS.expectation (λξ. max 0 (g (T x ξ))) =
(LBINT s:{0..}. pdfT x s * max 0 (g s))"
using that by (rewrite expectation_LBINT_pdfT_nonneg[where g="Ξ»s. max 0 (g s)"]) simp_all
moreover have "alivex_PS.expectation (λξ. max 0 (- g (T x ξ))) =
(LBINT s:{0..}. pdfT x s * max 0 (- g s))"
using that by (rewrite expectation_LBINT_pdfT_nonneg[where g="Ξ»s. max 0 (- g s)"]) simp_all
ultimately have "alivex_PS.expectation (λξ. g (T x ξ)) =
(LBINT s:{0..}. pdfT x s * max 0 (g s)) - (LBINT s:{0..}. pdfT x s * max 0 (- g s))" by simp
also have "β¦ = (LBINT s:{0..}. (pdfT x s * max 0 (g s) - pdfT x s * max 0 (- g s)))"
by (rewrite set_integral_diff; simp)
also have "β¦ = (LBINT s:{0..}. pdfT x s * (max 0 (g s) - max 0 (- g s)))"
by (simp add: right_diff_distrib)
also have "β¦ = (LBINT s:{0..}. pdfT x s * g s)"
using minus_max_eq_min
by (metis (no_types, opaque_lifting) diff_zero max_def min_def minus_diff_eq)
finally show ?thesis .
qed
corollary expectation_integral_pdfT:
"alivex_PS.expectation (λξ. g (T x ξ)) = integral {0..} (λs. pdfT x s * g s)"
if "(Ξ»s. pdfT x s * g s) absolutely_integrable_on {0..}" "g β borel_measurable lborel"
for g :: "real β real"
proof -
have [simp]: "set_integrable lborel {0..} (Ξ»s. pdfT x s * g s)"
using that by (rewrite absolutely_integrable_on_iff_set_integrable; simp)
show ?thesis
apply (rewrite set_borel_integral_eq_integral(2)[THEN sym], simp)
using that by (rewrite expectation_LBINT_pdfT; simp)
qed
corollary e_LBINT_pdfT: "$e`β_x = (LBINT s:{0..}. pdfT x s * s)"
unfolding life_expect_def using expectation_LBINT_pdfT_nonneg by force
corollary e_integral_pdfT: "$e`β_x = integral {0..} (Ξ»s. pdfT x s * s)"
unfolding life_expect_def using expectation_integral_pdfT_nonneg by force
end
corollary e_LBINT_pdfX: "$e`β_0 = (LBINT x:{0..}. pdfX x * x)"
using e_LBINT_pdfT pdfT0_X psi_pos' by presburger
corollary e_integral_pdfX: "$e`β_0 = integral {0..} (Ξ»x. pdfX x * x)"
using e_integral_pdfT pdfT0_X psi_pos' by presburger
subsubsection βΉIntroduction of Force of MortalityβΊ
definition force_mortal :: "real β real" (βΉ$ΞΌ'__βΊ [101] 200)
where "$ΞΌ_x β‘ MM_PS.hazard_rate X x"
lemma mu_pdfX: "$ΞΌ_x = pdfX x / ccdf (distr π borel X) x"
if "(cdf (distr π borel X)) differentiable at x" for x::real
unfolding force_mortal_def pdfX_def
by (rewrite MM_PS.hazard_rate_deriv_cdf, simp_all add: that)
lemma mu_unborn_0: "$ΞΌ_x = 0" if "x < 0" for x::real
apply (rewrite mu_pdfX)
using cdfX_has_real_derivative_0_unborn real_differentiable_def that apply blast
using pdfX_nonpos_0 that by auto
lemma mu_beyond_0: "$ΞΌ_x = 0" if "x β₯ $Ο" for x::real
unfolding force_mortal_def using MM_PS.hazard_rate_0_ccdf_0 ccdfX_0_equiv that by simp
lemma mu_nonneg_differentiable: "$ΞΌ_x β₯ 0"
if "(cdf (distr π borel X)) differentiable at x" for x::real
apply (rewrite mu_pdfX, simp add: that)
using pdfX_nonneg distrX_RD.ccdf_nonneg by simp
lemma mu_nonneg_AE: "AE x in lborel. $ΞΌ_x β₯ 0"
using cdfX_differentiable_AE mu_nonneg_differentiable by auto
lemma mu_measurable[measurable]: "(Ξ»x. $ΞΌ_x) β borel_measurable borel"
proof -
obtain S where
"finite S" and "βx. x β S βΉ (cdf (distr π borel X)) differentiable at x"
using cdfX_piecewise_differentiable unfolding piecewise_differentiable_on_def by blast
thus ?thesis
apply (rewrite measurable_discrete_difference
[where f="Ξ»x. pdfX x / ccdf (distr π borel X) x" and X=S], simp_all)
by (simp_all add: MM_PS.ccdf_distr_measurable borel_measurable_divide countable_finite mu_pdfX)
qed
lemma mu_deriv_ccdf: "$ΞΌ_x = - deriv (ccdf (distr π borel X)) x / ccdf (distr π borel X) x"
if "(ccdf (distr π borel X)) differentiable at x" "x < $Ο" for x::real
unfolding force_mortal_def
by (rewrite MM_PS.hazard_rate_deriv_ccdf; simp add: that)
lemma mu_deriv_ln: "$ΞΌ_x = - deriv (Ξ»x. ln (ccdf (distr π borel X) x)) x"
if "(ccdf (distr π borel X)) differentiable at x" "x < $Ο" for x::real
unfolding force_mortal_def
apply (rewrite MM_PS.hazard_rate_deriv_ln_ccdf, simp_all add: that)
using ccdfX_0_equiv that by force
lemma p_exp_integral_mu: "$p_{t&x} = exp (- integral {x..x+t} (Ξ»y. $ΞΌ_y))"
if "x β₯ 0" "t β₯ 0" "x+t < $Ο" for x t :: real
proof -
have [simp]: "x < $Ο" using that by (simp add: ereal_less_le)
have "$p_{t&x} = (ccdf (distr π borel X) (x+t)) / (ccdf (distr π borel X) x)"
apply (rewrite p_PX, simp_all add: that)
by (rewrite MM_PS.ccdf_distr_P, simp)+ simp
also have "β¦ = exp (- integral {x..x+t} (MM_PS.hazard_rate X))"
apply (rule MM_PS.ccdf_exp_cumulative_hazard, simp_all add: that)
using ccdfX_piecewise_differentiable piecewise_differentiable_on_subset apply blast
using ccdfX_continuous continuous_on_subset apply blast
using ccdfX_0_equiv that ereal_less_le linorder_not_le by force
also have "β¦ = exp (- integral {x..x+t} (Ξ»y. $ΞΌ_y))" unfolding force_mortal_def by simp
finally show ?thesis .
qed
corollary ccdfX_exp_integral_mu: "ccdf (distr π borel X) x = exp (- integral {0..x} (Ξ»y. $ΞΌ_y))"
if "0 β€ x β§ x < $Ο" for x::real
by (rewrite p_exp_integral_mu[where t=x and x=0, simplified, THEN sym]; simp add: that ccdfX_p)
subsubsection βΉProperties of Force of MortalityβΊ
context
fixes x::real
assumes x_lt_psi[simp]: "x < $Ο"
begin
interpretation alivex_PS: prob_space "π β alive x"
by (rule MM_PS.cond_prob_space_correct; simp add: alive_def)
interpretation distrTx_RD: real_distribution "distr (π β alive x) borel (T x)" by simp
lemma hazard_rate_Tx_mu: "alivex_PS.hazard_rate (T x) t = $ΞΌ_(x+t)"
if "t β₯ 0" "x+t < $Ο" for t::real
proof -
have [simp]: "π«(ΞΎ in π. X ΞΎ > x) > 0" by force
moreover have [simp]: "π«(ΞΎ in π. X ΞΎ > x + t) > 0" using that by force
moreover have [simp]: "{ΞΎ β space (π β alive x). X ΞΎ > x + t} = {ΞΎ β space π. X ΞΎ > x + t}"
unfolding alive_def using that by (rewrite MM_PS.space_cond_prob_space, simp_all, force)
hence [simp]: "{ΞΎ β space (π β alive x). X ΞΎ > x + t} β MM_PS.events" by simp
ultimately have β[simp]: "π«(ΞΎ in (π β alive x). X ΞΎ > x + t) > 0"
unfolding alive_def
apply (rewrite MM_PS.cond_prob_space_cond_prob[THEN sym], (simp_all add: pred_def)[3])
unfolding cond_prob_def by (smt (verit) Collect_cong divide_pos_pos)
have "alivex_PS.hazard_rate (T x) t =
Lim (at_right 0) (Ξ»dt. π«(ΞΎ in (π β alive x). t < T x ΞΎ β§ T x ΞΎ β€ t + dt Β¦ T x ΞΎ > t) / dt)"
unfolding alivex_PS.hazard_rate_def by simp
also have "β¦ = Lim (at_right 0)
(Ξ»dt. π«(ΞΎ in (π β alive x). x + t < X ΞΎ β§ X ΞΎ β€ x + t + dt Β¦ X ΞΎ > x + t) / dt)"
apply (rule Lim_cong, rule eventually_at_rightI[of 0 1], simp_all)
unfolding futr_life_def cond_prob_def using Collect_cong by smt
also have "β¦ =
Lim (at_right 0) (Ξ»dt. π«(ΞΎ in π. x + t < X ΞΎ β§ X ΞΎ β€ x + t + dt Β¦ X ΞΎ > x + t) / dt)"
proof -
have "βdt. π«(ΞΎ in (π β alive x). x + t < X ΞΎ β§ X ΞΎ β€ x + t + dt Β¦ X ΞΎ > x + t) =
π«(ΞΎ in π. x + t < X ΞΎ β§ X ΞΎ β€ x + t + dt Β¦ X ΞΎ > x + t)"
proof -
fix dt
let ?rngX = "λξ. x + t < X ξ ⧠X ξ †x + t + dt"
have "π«(ΞΎ in (π β alive x). ?rngX ΞΎ Β¦ X ΞΎ > x + t) =
π«(ΞΎ in ((π β alive x) β {Ξ· β space (π β alive x). X Ξ· > x + t}). ?rngX ΞΎ)"
using β by (rewrite alivex_PS.cond_prob_space_cond_prob) simp_all
also have "β¦ = π«(ΞΎ in (π β {Ξ· β space π. X Ξ· > x + t}). ?rngX ΞΎ)"
proof -
have "(π β alive x) β {Ξ· β space (π β alive x). X Ξ· > x + t} =
π β {Ξ· β space (π β alive x). X Ξ· > x + t}"
apply (rewrite MM_PS.cond_cond_prob_space, simp_all)
unfolding alive_def using that by force
also have "β¦ = π β {Ξ· β space π. X Ξ· > x + t}" by simp
finally have "(π β alive x) β {Ξ· β space (π β alive x). X Ξ· > x + t} =
π β {Ξ· β space π. X Ξ· > x + t}" .
thus ?thesis by simp
qed
also have "β¦ = π«(ΞΎ in π. x + t < X ΞΎ β§ X ΞΎ β€ x + t + dt Β¦ X ΞΎ > x + t)"
by (rewrite MM_PS.cond_prob_space_cond_prob, simp_all add: pred_def sets.sets_Collect_conj)
finally show "π«(ΞΎ in (π β alive x). ?rngX ΞΎ Β¦ X ΞΎ > x + t) =
π«(ΞΎ in π. x + t < X ΞΎ β§ X ΞΎ β€ x + t + dt Β¦ X ΞΎ > x + t)" .
qed
thus ?thesis
apply -
by (rule Lim_cong, rule eventually_at_rightI[of 0 1]; simp)
qed
also have "β¦ = $ΞΌ_(x+t)" unfolding force_mortal_def MM_PS.hazard_rate_def by simp
finally show ?thesis .
qed
lemma pdfTx_p_mu: "pdfT x t = $p_{t&x} * $ΞΌ_(x+t)"
if "(cdf (distr (π β alive x) borel (T x))) differentiable at t" "t > 0" for t::real
proof (cases βΉx+t < $ΟβΊ)
case True
hence [simp]: "t β₯ 0" and "(ccdf (distr (π β alive x) borel (T x))) t β 0"
using that p_0_equiv unfolding survive_def by auto
have "deriv (cdf (distr (π β alive x) borel (T x))) t =
ccdf (distr (π β alive x) borel (T x)) t * alivex_PS.hazard_rate (T x) t"
by (rule alivex_PS.deriv_cdf_hazard_rate; simp add: that)
thus ?thesis unfolding survive_def pdfT_def using hazard_rate_Tx_mu True that by simp
next
case False
hence "x+t β₯ $Ο" by simp
thus ?thesis using pdfTx_beyond_0 mu_beyond_0 by simp
qed
lemma deriv_t_p_mu: "deriv (Ξ»s. $p_{s&x}) t = - $p_{t&x} * $ΞΌ_(x+t)"
if "(Ξ»s. $p_{s&x}) differentiable at t" "t > 0" for t::real
proof -
let ?cdfTx = "cdf (distr (π β alive x) borel (T x))"
have diff: "?cdfTx differentiable at t"
using that distrTx_RD.differentiable_cdf_ccdf unfolding survive_def by blast
hence "deriv ?cdfTx t = $p_{t&x} * $ΞΌ_(x+t)" using that pdfTx_p_mu pdfT_def by simp
moreover have "deriv ?cdfTx t = - deriv (Ξ»s. $p_{s&x}) t"
using that diff distrTx_RD.deriv_cdf_ccdf unfolding survive_def by presburger
ultimately show ?thesis by simp
qed
lemma pdfTx_p_mu_AE: "AE s in lborel. s > 0 βΆ pdfT x s = $p_{s&x} * $ΞΌ_(x+s)"
proof -
let ?cdfX = "cdf (distr π borel X)"
let ?cdfTx = "cdf (distr (π β alive x) borel (T x))"
from cdfX_differentiable_AE obtain N
where diff: "βr. r β space lborel - N βΉ ?cdfX differentiable at r"
and null: "N β null_sets lborel"
using AE_E3 by blast
let ?N' = "{s. x+s β N}"
have "?N' β null_sets lborel"
using null_sets_translation[of N "-x", simplified] null by (simp add: add.commute)
moreover have "{s β space lborel. Β¬ (s > 0 βΆ pdfT x s = $p_{s&x} * $ΞΌ_(x+s))} β ?N'"
proof (rewrite Compl_subset_Compl_iff[THEN sym], safe)
fix s::real
assume "s β space lborel" and "x+s β N" and "s > 0"
thus "pdfT x s = $p_{s&x} * $ΞΌ_(x+s)"
apply (intro pdfTx_p_mu, simp_all)
by (rewrite differentiable_cdfX_cdfTx[THEN sym]; simp add: diff)
qed
ultimately show ?thesis using AE_I'[of ?N'] by simp
qed
lemma LBINT_p_mu_q_defer: "(LBINT s:{f<..f+t}. $p_{s&x} * $μ_(x+s)) = $q_{f¦t&x}"
if "t β₯ 0" "f β₯ 0" for t f :: real
proof -
have "(LBINT s:{f<..f+t}. $p_{s&x} * $ΞΌ_(x+s)) = (LBINT s:{f<..f+t}. pdfT x s)"
apply (rule set_lebesgue_integral_cong_AE; simp)
apply (simp add: survive_def)
using pdfTx_p_mu_AE apply (rule AE_mp)
using that by (intro always_eventually; simp add: ereal_less_le)
also have "β¦ = enn2real (β«β§+sβ{f<..f+t}. ennreal (pdfT x s) βlborel)"
proof -
have "(β«β§+sβ{f<..f+t}. ennreal (pdfT x s) βlborel) < β€"
proof -
have "(β«β§+sβ{f<..f+t}. ennreal (pdfT x s) βlborel) β€ β«β§+s. ennreal (pdfT x s) βlborel"
by (smt (verit) indicator_simps le_zero_eq linorder_le_cases
mult.right_neutral mult_zero_right nn_integral_mono)
also have "β¦ < β€" using nn_integral_pdfTx_1 by simp
finally show ?thesis .
qed
thus ?thesis
unfolding set_lebesgue_integral_def
by (rewrite enn2real_nn_integral_eq_integral[where g="Ξ»s. pdfT x s * indicator {f<..f+t} s"])
(simp_all add: pdfTx_nonneg mult.commute ennreal_indicator ennreal_mult')
qed
also have "β¦ = measure (density lborel (pdfT x)) {f<..f+t}"
unfolding measure_def by (rewrite emeasure_density; simp)
also have "β¦ = measure (distr (π β alive x) lborel (T x)) {f<..f+t}"
using distributed_pdfTx unfolding distributed_def by simp
also have "β¦ =
cdf (distr (π β alive x) lborel (T x)) (f+t) - cdf (distr (π β alive x) lborel (T x)) f"
using that finite_borel_measure.cdf_diff_eq2
by (smt (verit) distrTx_RD.finite_borel_measure_axioms distr_cong sets_lborel)
also have "⦠= $q_{f¦t&x}"
using q_defer_q die_def that by (metis distr_cong sets_lborel x_lt_psi)
finally show ?thesis .
qed
corollary LBINT_p_mu_q: "(LBINT s:{0<..t}. $p_{s&x} * $ΞΌ_(x+s)) = $q_{t&x}" if "t β₯ 0" for t::real
using LBINT_p_mu_q_defer that by force
lemma set_integrable_p_mu: "set_integrable lborel {f<..f+t} (Ξ»s. $p_{s&x} * $ΞΌ_(x+s))"
if "t β₯ 0" "f β₯ 0" for t f :: real
proof -
have "(Ξ»s. $p_{s&x}) β borel_measurable borel" unfolding survive_def by simp
moreover have "AE s in lborel. f < s β§ s β€ f + t βΆ $p_{s&x} * $ΞΌ_(x+s) = pdfT x s"
using pdfTx_p_mu_AE apply (rule AE_mp)
using that by (intro always_eventually; simp add: ereal_less_le)
moreover have "set_integrable lborel {f<..f+t} (pdfT x)" using pdfTx_set_integrable by simp
ultimately show ?thesis by (rewrite set_integrable_cong_AE[where g="pdfT x"]; simp)
qed
lemma p_mu_has_integral_q_defer_Ioc:
"((λs. $p_{s&x} * $μ_(x+s)) has_integral $q_{f¦t&x}) {f<..f+t}"
if "t β₯ 0" "f β₯ 0" for t f :: real
apply (rewrite LBINT_p_mu_q_defer[THEN sym], simp_all add: that)
apply (rewrite set_borel_integral_eq_integral, simp add: set_integrable_p_mu that)
by (rewrite has_integral_integral[THEN sym];
simp add: set_borel_integral_eq_integral set_integrable_p_mu that)
lemma p_mu_has_integral_q_defer_Icc:
"((Ξ»s. $p_{s&x} * $ΞΌ_(x+s)) has_integral $q_{fΒ¦t&x}) {f..f+t}" if "t β₯ 0" "f β₯ 0" for t f :: real
proof -
have "negligible {f}" by simp
hence [simp]: "negligible ({f..f+t} - {f<..f+t})"
by (smt (verit) Diff_iff atLeastAtMost_iff greaterThanAtMost_iff insertI1
negligible_sing negligible_subset subsetI)
have [simp]: "negligible ({f<..f+t} - {f..f+t})" by (simp add: subset_eq)
show ?thesis
apply (rewrite has_integral_spike_set_eq[where T="{f<..f+t}"])
apply (rule negligible_subset[of "{f..f+t} - {f<..f+t}"], simp, blast)
apply (rule negligible_subset[of "{f<..f+t} - {f..f+t}"], simp, blast)
using p_mu_has_integral_q_defer_Ioc that by simp
qed
corollary p_mu_has_integral_q_Icc:
"((Ξ»s. $p_{s&x} * $ΞΌ_(x+s)) has_integral $q_{t&x}) {0..t}" if "t β₯ 0" for t::real
using p_mu_has_integral_q_defer_Icc[where f=0] that by simp
corollary p_mu_integrable_on_Icc:
"(Ξ»s. $p_{s&x} * $ΞΌ_(x+s)) integrable_on {0..t}" if "t β₯ 0" for t::real
using p_mu_has_integral_q_Icc that by auto
lemma e_ennreal_p_mu: "(β«β§+ΞΎ. ennreal (T x ΞΎ) β(π β alive x)) =
(β«β§+sβ{0..}. ennreal ($p_{s&x} * $ΞΌ_(x+s) * s) βlborel)"
proof -
have [simp]: "sym_diff {0..} {0<..} = {0::real}" by force
have "(β«β§+ΞΎ. ennreal (T x ΞΎ) β(π β alive x)) = (β«β§+sβ{0..}. ennreal (pdfT x s * s) βlborel)"
by (rewrite nn_integral_T_pdfT[where g="Ξ»s. s"]; simp)
also have "β¦ = (β«β§+sβ{0<..}. ennreal (pdfT x s * s) βlborel)"
by (rewrite nn_integral_null_delta; force)
also have "β¦ = (β«β§+sβ{0<..}. ennreal ($p_{s&x} * $ΞΌ_(x+s) * s) βlborel)"
apply (rule nn_integral_cong_AE)
using pdfTx_p_mu_AE apply (rule AE_mp, intro AE_I2) by force
also have "β¦ = (β«β§+sβ{0..}. ennreal ($p_{s&x} * $ΞΌ_(x+s) * s) βlborel)"
by (rewrite nn_integral_null_delta[THEN sym]; force)
finally show ?thesis .
qed
lemma e_LBINT_p_mu: "$e`β_x = (LBINT s:{0..}. $p_{s&x} * $ΞΌ_(x+s) * s)"
proof -
let ?f = "Ξ»s. $p_{s&x} * $ΞΌ_(x+s) * s"
have [simp]: "(Ξ»s. ?f s * indicat_real {0..} s) β borel_measurable borel"
by measurable (simp_all add: survive_def)
hence [simp]: "(Ξ»s. indicat_real {0..} s * ?f s) β borel_measurable borel"
by (meson measurable_cong mult.commute)
have [simp]: "AE s in lborel. ?f s * indicat_real {0..} s β₯ 0"
proof -
have "AE s in lborel. pdfT x s * s * indicat_real {0..} s β₯ 0"
using pdfTx_nonneg pdfTx_nonpos_0 x_lt_psi
by (intro AE_I2) (smt (verit, del_insts) indicator_pos_le mult_eq_0_iff mult_nonneg_nonneg)
thus ?thesis
apply (rule AE_mp)
using pdfTx_p_mu_AE apply (rule AE_mp)
by (rule AE_I2) (metis atLeast_iff indicator_simps(2) mult_eq_0_iff order_le_less)
qed
hence [simp]: "AE s in lborel. indicat_real {0..} s * ?f s β₯ 0"
by (metis (no_types, lifting) AE_cong mult.commute)
show ?thesis
proof (cases βΉintegrable (π β alive x) (T x)βΊ)
case True
hence "ennreal ($e`β_x) = β«β§+ΞΎ. ennreal (T x ΞΎ) β(π β alive x)"
unfolding life_expect_def apply (rewrite nn_integral_eq_integral, simp_all)
by (smt (verit) AE_I2 alivex_Tx_pos)
also have "β¦ = β«β§+s. ennreal (?f s * indicat_real {0..} s) βlborel"
by (simp add: nn_integral_set_ennreal e_ennreal_p_mu)
also have "β¦ = ennreal (LBINT s:{0..}. ?f s)"
proof -
have "integrable lborel (Ξ»s. ?f s * indicat_real {0..} s)"
proof -
have "(β«β§+s. ennreal (?f s * indicat_real {0..} s) βlborel) < β"
by (metis calculation ennreal_less_top infinity_ennreal_def)
thus ?thesis by (intro integrableI_nonneg; simp)
qed
thus ?thesis
unfolding set_lebesgue_integral_def
by (rewrite nn_integral_eq_integral, simp_all) (meson mult.commute)
qed
finally have "ennreal ($e`β_x) = ennreal (LBINT s:{0..}. ?f s)" .
moreover have "(LBINT s:{0..}. ?f s) β₯ 0"
unfolding set_lebesgue_integral_def by (rule integral_nonneg_AE) simp
ultimately show ?thesis using e_nonneg by simp
next
case False
hence "$e`β_x = 0" unfolding life_expect_def using not_integrable_integral_eq by force
also have "β¦ = (LBINT s:{0..}. ?f s)"
proof -
have "β = β«β§+ΞΎ. ennreal (T x ΞΎ) β(π β alive x)"
using nn_integral_nonneg_infinite False
by (smt (verit) AE_cong Tx_alivex_measurable alivex_PS.AE_prob_1 alivex_PS.prob_space
alivex_Tx_pos nn_integral_cong)
hence "0 = enn2real (β«β§+sβ{0..}. ennreal (?f s) βlborel)" using e_ennreal_p_mu by simp
also have "β¦ = (LBINT s:{0..}. ?f s)"
unfolding set_lebesgue_integral_def apply (rewrite integral_eq_nn_integral, simp_all)
by (simp add: indicator_mult_ennreal mult.commute)
finally show ?thesis by simp
qed
finally show ?thesis .
qed
qed
lemma e_integral_p_mu: "$e`β_x = integral {0..} (Ξ»s. $p_{s&x} * $ΞΌ_(x+s) * s)"
proof -
have "(LBINT s:{0..}. $p_{s&x} * $ΞΌ_(x+s) * s) = integral {0..} (Ξ»s. $p_{s&x} * $ΞΌ_(x+s) * s)"
proof -
have "AE s in lborel. s β₯ 0 βΆ $p_{s&x} * $ΞΌ_(x+s) * s β₯ 0"
proof -
have "AE s in lborel. $ΞΌ_(x+s) β₯ 0" by (rule AE_translation, rule mu_nonneg_AE)
with p_nonneg show ?thesis by force
qed
moreover have "(Ξ»s. $p_{s&x} * $ΞΌ_(x+s) * s) β borel_measurable borel"
unfolding survive_def by simp
ultimately show ?thesis by (intro set_borel_integral_eq_integral_nonneg_AE; simp)
qed
thus ?thesis using e_LBINT_p_mu by simp
qed
end
lemma p_has_real_derivative_x_ccdfX:
"((Ξ»y. $p_{t&y}) has_real_derivative
((deriv svl (x+t) * svl x - svl (x+t) * deriv svl x) / (svl x)β§2)) (at x)"
if "svl β‘ ccdf (distr π borel X)" "svl differentiable at x" "svl differentiable at (x+t)"
"t β₯ 0" "x < $Ο" for x t :: real
proof -
have "open {y. svl differentiable at y}" using ccdfX_differentiable_open_set that by simp
with that obtain e0 where e0_pos: "e0 > 0" and ball_e0: "ball x e0 β {y. svl differentiable at y}"
using open_contains_ball by blast
define e where "e β‘ if $Ο < β then min e0 (real_of_ereal $Ο - x) else e0"
have "e > 0 β§ ball x e β {y. svl y β 0 β§ svl differentiable at y}"
proof (cases βΉ$Ο < ββΊ)
case True
hence "e > 0"
proof -
have "real_of_ereal $Ο - x > 0" using not_inftyI True that by force
with e0_pos show ?thesis unfolding e_def using True by simp
qed
moreover have "ball x e β {y. svl y β 0}"
proof -
have "e β€ real_of_ereal $Ο - x" unfolding e_def using True by simp
hence "ball x e β {..< real_of_ereal $Ο}" unfolding ball_def dist_real_def by force
thus ?thesis using that ccdfX_0_equiv
using True ereal_less_real_iff psi_nonneg by auto
qed
moreover have "ball x e β {y. svl differentiable at y}"
proof -
have "e β€ e0" unfolding e_def using True by simp
hence "ball x e β ball x e0" by force
with ball_e0 show ?thesis by simp
qed
ultimately show ?thesis by blast
next
case False
hence "ball x e β {y. svl y β 0}" using ccdfX_0_equiv that by simp
with False show ?thesis unfolding e_def using e0_pos ball_e0 by force
qed
hence e_pos: "e > 0" and ball_e: "ball x e β {y. svl y β 0 β§ svl differentiable at y}" by auto
hence ball_svl: "βy. y β ball x e βΉ svl y β 0 β§ svl field_differentiable at y"
using differentiable_eq_field_differentiable_real by blast
hence "βy. y β ball x e βΉ $p_{t&y} = svl (y+t) / svl y"
unfolding survive_def using that ccdfX_0_equiv by (rewrite ccdfTx_ccdfX, simp_all) force
moreover from ball_svl have "((Ξ»y. svl (y+t) / svl y) has_real_derivative
((deriv svl (x+t) * svl x - svl (x+t) * deriv svl x) / (svl x)β§2)) (at x)"
apply (rewrite power2_eq_square)
apply (rule DERIV_divide)
using DERIV_deriv_iff_real_differentiable DERIV_shift that apply blast
using that DERIV_deriv_iff_real_differentiable apply simp
by (simp add: e_pos)
ultimately show ?thesis
using e_pos
apply (rewrite has_field_derivative_cong_eventually[where g="Ξ»y. svl (y+t) / svl y"], simp_all)
by (smt (verit) dist_commute eventually_at)
qed
lemma p_has_real_derivative_x_p_mu:
"((Ξ»y. $p_{t&y}) has_real_derivative $p_{t&x} * ($ΞΌ_x - $ΞΌ_(x+t))) (at x)"
if "ccdf (distr π borel X) differentiable at x" "ccdf (distr π borel X) differentiable at (x+t)"
"t β₯ 0" "x < $Ο" for x t :: real
proof (cases βΉx+t < $ΟβΊ)
case True
let ?svl = "ccdf (distr π borel X)"
have [simp]: "?svl x β 0" using that ccdfX_0_equiv by (smt (verit) le_ereal_le linorder_not_le)
have [simp]: "?svl field_differentiable at (x+t)"
using that differentiable_eq_field_differentiable_real by simp
have "((Ξ»y. $p_{t&y}) has_real_derivative
((deriv ?svl (x+t) * ?svl x - ?svl (x+t) * deriv ?svl x) / (?svl x)β§2)) (at x)"
using p_has_real_derivative_x_ccdfX that by simp
moreover have "(deriv ?svl (x+t) * ?svl x - ?svl (x+t) * deriv ?svl x) / (?svl x)β§2 =
$p_{t&x} * ($ΞΌ_x - $ΞΌ_(x+t))" (is "?LHS = ?RHS")
proof -
have "deriv ?svl (x+t) = deriv (Ξ»y. ?svl (y+t)) x"
using that by (metis DERIV_deriv_iff_real_differentiable DERIV_imp_deriv DERIV_shift)
hence "?LHS = (deriv (Ξ»y. ?svl (y+t)) x * ?svl x - ?svl (x+t) * deriv ?svl x) / (?svl x)β§2"
by simp
also have "β¦ = (deriv (Ξ»y. ?svl (y+t)) x - ?svl (x+t) * deriv ?svl x / ?svl x) / ?svl x"
by (simp add: add_divide_eq_if_simps(4) power2_eq_square)
also have "β¦ = (- ?svl (x+t) * $ΞΌ_(x+t) + ?svl (x+t) * $ΞΌ_x) / ?svl x"
proof -
have "deriv (Ξ»y. ?svl (y+t)) x = - ?svl (x+t) * $ΞΌ_(x+t)"
apply (rewrite add.commute, rewrite deriv_shift[THEN sym], rewrite add.commute, simp)
using add.commute that by (metis MM_PS.deriv_ccdf_hazard_rate X_RV force_mortal_def)
moreover have "- ?svl (x+t) * deriv ?svl x / ?svl x = ?svl (x+t) * $ΞΌ_x"
using that by (simp add: MM_PS.deriv_ccdf_hazard_rate force_mortal_def)
ultimately show ?thesis by simp
qed
also have "β¦ = ?svl (x+t) * ($ΞΌ_x - $ΞΌ_(x+t)) / ?svl x" by (simp add: mult_diff_mult)
also have "β¦ = ?RHS" unfolding survive_def using ccdfTx_ccdfX that by simp
ultimately show ?thesis by simp
qed
ultimately show ?thesis by simp
next
case False
hence ptx_0: "$p_{t&x} = 0" using p_0_equiv that by simp
moreover have "((Ξ»y. $p_{t&y}) has_real_derivative 0) (at x)"
proof -
have "βy. x < y βΉ y < $Ο βΉ $p_{t&y} = 0"
using False p_0_equiv that by (smt (verit, ccfv_SIG) ereal_less_le linorder_not_le)
hence "ββ©F x in at_right x. $p_{t&x} = 0"
apply (rewrite eventually_at_right_field)
using that by (meson ereal_dense2 ereal_le_less less_eq_ereal_def less_ereal.simps)
hence "((Ξ»y. $p_{t&y}) has_real_derivative 0) (at_right x)"
using ptx_0 by (rewrite has_field_derivative_cong_eventually[where g="Ξ»_. 0"]; simp)
thus ?thesis
using vector_derivative_unique_within p_has_real_derivative_x_ccdfX that
by (metis has_field_derivative_at_within has_real_derivative_iff_has_vector_derivative
trivial_limit_at_right_real)
qed
ultimately show ?thesis by simp
qed
corollary deriv_x_p_mu: "deriv (Ξ»y. $p_{t&y}) x = $p_{t&x} * ($ΞΌ_x - $ΞΌ_(x+t))"
if "ccdf (distr π borel X) differentiable at x" "ccdf (distr π borel X) differentiable at (x+t)"
"t β₯ 0" "x < $Ο" for x t :: real
using that p_has_real_derivative_x_p_mu DERIV_imp_deriv by blast
lemma e_has_derivative_mu_e: "((Ξ»x. $e`β_x) has_real_derivative ($ΞΌ_x * $e`β_x - 1)) (at x)"
if "βx. xβ{a<..<b} βΉ set_integrable lborel {x..} (ccdf (distr π borel X))"
"ccdf (distr π borel X) differentiable at x" "xβ{a<..<b}" "b β€ $Ο"
for a b x :: real
proof -
let ?svl = "ccdf (distr π borel X)"
have x_lt_psi[simp]: "x < $Ο" using that ereal_le_less by simp
hence svlx_neq0[simp]: "?svl x β 0" by (simp add: ccdfX_0_equiv linorder_not_le)
define d ::real where "d β‘ min (b-x) (x-a)"
have d_pos: "d > 0" unfolding d_def using that ereal_less_real_iff by force
have e_svl: "βy. y < $Ο βΉ $e`β_y = (LBINT t:{0..}. ?svl (y+t)) / ?svl y"
apply (rewrite e_LBINT_p, simp)
apply (rewrite set_integral_divide_zero[THEN sym])
apply (rule set_lebesgue_integral_cong, simp_all)
unfolding survive_def using ccdfTx_ccdfX by force
have "((Ξ»y. LBINT t:{0..}. ?svl (y+t)) has_real_derivative (- ?svl x)) (at x)"
proof -
{ fix y assume "dist y x < d"
hence y_ab: "y β {a<..<b}" unfolding d_def dist_real_def by force
hence "set_integrable lborel {y..} ?svl" using that by simp
hence "set_integrable lborel (einterval y β) ?svl"
by (rewrite set_integrable_discrete_difference[where X="{y}"]; simp) force
moreover have "βu. ((Ξ»u. u-y) has_real_derivative (1-0)) (at u)"
by (rule derivative_intros) auto
moreover have "βu. y < u βΉ isCont (Ξ»t. ?svl (y+t)) (u-y)"
apply (rewrite add.commute, rewrite isCont_shift, simp)
using ccdfX_continuous continuous_on_eq_continuous_within by blast
moreover have "((ereal β (Ξ»u. u-y) β real_of_ereal) β€ 0) (at_right (ereal y))"
by (smt (verit, ccfv_SIG) LIM_zero Lim_cong_within ereal_tendsto_simps1(2)
ereal_tendsto_simps2(1) tendsto_ident_at zero_ereal_def)
moreover have "((ereal β (Ξ»u. u-y) β real_of_ereal) β€ β) (at_left β)"
proof -
have "βr u. r+y+1 β€ u βΉ r < u-y" by auto
hence "βr. ββ©F u in at_top. r < u - y" by (rule eventually_at_top_linorderI)
thus ?thesis by (rewrite ereal_tendsto_simps, rewrite tendsto_PInfty) simp
qed
ultimately have "(LBINT t=0..β. ?svl (y+t)) = (LBINT u=y..β. ?svl (y+(u-y)) * 1)"
using distrX_RD.ccdf_nonneg by (intro interval_integral_substitution_nonneg(2); simp)
moreover have "(LBINT t:{0..}. ?svl (y+t)) = (LBINT t=0..β. ?svl (y+t))"
unfolding interval_lebesgue_integral_def einterval_def apply simp
by (rule set_integral_discrete_difference[where X="{0}"]; force)
moreover have "(LBINT u=y..β. ?svl (y+(u-y))*1) = (LBINT u:{y..}. ?svl u)"
unfolding interval_lebesgue_integral_def einterval_def apply simp
by (rule set_integral_discrete_difference[where X="{y}"]; force)
ultimately have "(LBINT t:{0..}. ?svl (y+t)) = (LBINT u:{y..}. ?svl u)" by simp }
hence "ββ©F y in nhds x. (LBINT t:{0..}. ?svl (y+t)) = (LBINT u:{y..}. ?svl u)"
using d_pos by (rewrite eventually_nhds_metric) auto
moreover have "((Ξ»y. LBINT u:{y..}. ?svl u) has_real_derivative (- ?svl x)) (at x)"
proof -
have "((Ξ»y. integral {y..b} ?svl) has_real_derivative (- ?svl x)) (at x within {a..b})"
using that apply (intro integral_has_real_derivative'; simp)
using ccdfX_continuous continuous_on_subset by blast
hence "((Ξ»y. integral {y..b} ?svl) has_real_derivative (- ?svl x)) (at x)"
using that apply (rewrite at_within_open[where S="{a<..<b}", THEN sym], simp_all)
by (rule DERIV_subset[where s="{a..b}"]) auto
moreover have "ββ©F y in nhds x. (LBINT u:{y..b}. ?svl u) = integral {y..b} ?svl"
apply (rewrite eventually_nhds_metric)
using d_pos by (metis ccdfX_integrable_Icc set_borel_integral_eq_integral(2))
ultimately have "((Ξ»y. LBINT u:{y..b}. ?svl u) has_real_derivative (- ?svl x)) (at x)"
by (rewrite DERIV_cong_ev; simp)
hence "((Ξ»y. (LBINT u:{y..b}. ?svl u) + (LBINT u:{b<..}. ?svl u)) has_real_derivative
(- ?svl x)) (at x)"
by (rewrite to "- ?svl x + 0" add_0_right[THEN sym], rule DERIV_add; simp)
moreover have "ββ©F y in nhds x.
(LBINT u:{y..}. ?svl u) = (LBINT u:{y..b}. ?svl u) + (LBINT u:{b<..}. ?svl u)"
proof -
{ fix y assume "dist y x < d"
hence y_ab: "y β {a<..<b}" unfolding d_def dist_real_def by force
hence "set_integrable lborel {y..} ?svl" using that by simp
hence "set_integrable lborel {y..b} ?svl" "set_integrable lborel {b<..} ?svl"
apply (rule set_integrable_subset, simp_all)+
using y_ab by force
moreover have "{y..b} β© {b<..} = {}" "{y..} = {y..b} βͺ {b<..}" using y_ab by force+
ultimately have
"(LBINT u:{y..}. ?svl u) = (LBINT u:{y..b}. ?svl u) + (LBINT u:{b<..}. ?svl u)"
using set_integral_Un by simp }
thus ?thesis using d_pos by (rewrite eventually_nhds_metric) blast
qed
ultimately show ?thesis by (rewrite has_field_derivative_cong_ev; simp)
qed
ultimately show ?thesis by (rewrite DERIV_cong_ev; simp)
qed
moreover have "(?svl has_real_derivative (deriv ?svl x)) (at x)"
using that DERIV_deriv_iff_real_differentiable by blast
ultimately have "((Ξ»y. (LBINT t:{0..}. ?svl (y+t)) / ?svl y) has_real_derivative
((- ?svl x) * ?svl x - (LBINT t:{0..}. ?svl (x+t)) * deriv ?svl x) / (?svl x * ?svl x)) (at x)"
by (rule DERIV_divide) simp
moreover have "eventually (Ξ»y. (LBINT t:{0..}. ?svl (y+t)) / ?svl y = $e`β_y) (at x)"
proof -
{ fix y assume "dist y x < d" "y β x"
hence "y < $Ο"
unfolding dist_real_def d_def using that ereal_le_less by fastforce
hence "$e`β_y = (LBINT t:{0..}. ?svl (y+t)) / ?svl y" by (rule e_svl) }
thus ?thesis
apply (rewrite eventually_at_filter, rewrite eventually_nhds_metric)
using d_pos that by metis
qed
ultimately have "((Ξ»y. $e`β_y) has_real_derivative
((- ?svl x) * ?svl x - (LBINT t:{0..}. ?svl (x+t)) * deriv ?svl x) / (?svl x * ?svl x)) (at x)"
using e_svl by (rewrite has_field_derivative_cong_eventually[THEN sym]; simp)
moreover have
"((- ?svl x) * ?svl x - (LBINT t:{0..}. ?svl (x+t)) * deriv ?svl x) / (?svl x * ?svl x) =
$ΞΌ_x * $e`β_x - 1" (is "?LHS = ?RHS")
proof -
have "?LHS = -1 + (LBINT t:{0..}. ?svl (x+t)) / ?svl x * (- deriv ?svl x / ?svl x)"
by simp (smt (verit) svlx_neq0 add_divide_distrib divide_eq_minus_1_iff
mult_minus_left real_divide_square_eq)
also have "β¦ = -1 + $e`β_x * $ΞΌ_x" using e_svl mu_deriv_ccdf that by force
also have "β¦ = ?RHS" by simp
finally show ?thesis .
qed
ultimately show ?thesis by simp
qed
corollary e_has_derivative_mu_e': "((Ξ»x. $e`β_x) has_real_derivative ($ΞΌ_x * $e`β_x - 1)) (at x)"
if "βx. xβ{a<..<b} βΉ ccdf (distr π borel X) integrable_on {x..}"
"ccdf (distr π borel X) differentiable at x" "xβ{a<..<b}" "b β€ $Ο"
for a b x :: real
using that apply (intro e_has_derivative_mu_e[where a=a], simp_all)
using distrX_RD.ccdf_nonneg by (rewrite integrable_on_iff_set_integrable_nonneg; simp)
subsubsection βΉProperties of Curtate Life ExpectationβΊ
context
fixes x::real
assumes x_lt_psi[simp]: "x < $Ο"
begin
lemma isCont_p_nat: "isCont (Ξ»t. $p_{t&x}) (k + (1::real))" for k::nat
proof -
fix k::nat
have "continuous_on {0<..} (Ξ»t. $p_{t&x})"
unfolding survive_def
using ccdfTx_continuous_on_nonneg continuous_on_subset Ioi_le_Ico x_lt_psi by blast
hence "βtβ{0<..}. isCont (Ξ»t. $p_{t&x}) t"
using continuous_on_eq_continuous_at open_greaterThan by blast
thus "isCont (Ξ»t. $p_{t&x}) (real k+1)" by force
qed
lemma curt_e_sum_p_smooth: "$e_x = (βk. $p_{k+1&x})" if "summable (Ξ»k. $p_{k+1&x})"
using curt_e_sum_p isCont_p_nat that by simp
lemma curt_e_rec_smooth: "$e_x = $p_x * (1 + $e_(x+1))" if "summable (Ξ»k. $p_{k+1&x})" "x+1 < $Ο"
using curt_e_rec isCont_p_nat that by simp
lemma curt_e_sum_p_finite_smooth: "$e_x = (βk<n. $p_{k+1&x})" if "x+n+1 > $Ο" for n::nat
using curt_e_sum_p_finite isCont_p_nat that by simp
lemma temp_curt_e_sum_p_smooth: "$e_{x:n} = (βk<n. $p_{k+1&x})" for n::nat
using temp_curt_e_sum_p isCont_p_nat by simp
lemma temp_curt_e_rec_smooth: "$e_{x:n} = $p_x * (1 + $e_{x+1:n-1})"
if "x+1 < $Ο" "n β 0" for n::nat
using temp_curt_e_rec isCont_p_nat that by simp
end
end
subsection βΉLimited Survival FunctionβΊ
locale limited_survival_function = survival_model +
assumes psi_limited[simp]: "$Ο < β"
begin
definition ult_age :: nat (βΉ$ΟβΊ)
where "$Ο β‘ LEAST x::nat. ccdf (distr π borel X) x = 0"
lemma ccdfX_ceil_psi_0: "ccdf (distr π borel X) βreal_of_ereal $Οβ = 0"
proof -
have "real_of_ereal $Ο β€ βreal_of_ereal $Οβ" by simp
thus ?thesis using ccdfX_0_equiv psi_limited ccdfX_psi_0 le_ereal_le by presburger
qed
lemma ccdfX_omega_0: "ccdf (distr π borel X) $Ο = 0"
unfolding ult_age_def
proof (rule LeastI_ex)
have "βreal_of_ereal $Οβ β₯ 0" using psi_nonneg real_of_ereal_pos by fastforce
thus "βx::nat. ccdf (distr π borel X) (real x) = 0"
using ccdfX_ceil_psi_0 by (metis of_int_of_nat_eq zero_le_imp_eq_int)
qed
corollary psi_le_omega: "$Ο β€ $Ο"
using ccdfX_0_equiv ccdfX_omega_0 by blast
corollary omega_pos: "$Ο > 0"
using psi_le_omega order.strict_iff_not by fastforce
lemma omega_ceil_psi: "$Ο = βreal_of_ereal $Οβ"
proof (rule antisym)
let ?cpsi = "βreal_of_ereal $Οβ"
have β: "?cpsi β₯ 0" using psi_nonneg real_of_ereal_pos by fastforce
moreover have "ccdf (distr π borel X) ?cpsi = 0" by (rule ccdfX_ceil_psi_0)
ultimately have "$Ο β€ nat ?cpsi"
unfolding ult_age_def using wellorder_Least_lemma of_nat_nat by smt
thus "int $Ο β€ ?cpsi" using le_nat_iff β by blast
next
show "βreal_of_ereal $Οβ β€ int $Ο"
using psi_le_omega by (simp add: ceiling_le_iff real_of_ereal_ord_simps(2))
qed
lemma ccdfX_0_equiv_nat: "ccdf (distr π borel X) x = 0 β· x β₯ $Ο" for x::nat
proof
assume "ccdf (distr π borel X) (real x) = 0"
thus "x β₯ $Ο" unfolding ult_age_def using wellorder_Least_lemma by fastforce
next
assume "x β₯ $Ο"
hence "ereal (real x) β₯ $Ο" using psi_le_omega le_ereal_le of_nat_mono by blast
thus "ccdf (distr π borel X) (real x) = 0" using ccdfX_0_equiv by simp
qed
lemma psi_le_iff_omega_le: "$Ο β€ x β· $Ο β€ x" for x::nat
using ccdfX_0_equiv ccdfX_0_equiv_nat by presburger
context
fixes x::nat
assumes x_lt_omega[simp]: "x < $Ο"
begin
lemma x_lt_psi[simp]: "x < $Ο"
using x_lt_omega psi_le_iff_omega_le by (meson linorder_not_less)
lemma p_0_1_nat: "$p_{0&x} = 1"
using p_0_1 by simp
lemma p_0_equiv_nat: "$p_{t&x} = 0 β· x+t β₯ $Ο" for t::nat
using psi_le_iff_omega_le p_0_equiv by (metis of_nat_add x_lt_psi)
lemma q_0_0_nat: "$q_{0&x} = 0"
using p_q_1 p_0_1_nat by (smt (verit) x_lt_psi)
lemma q_1_equiv_nat: "$q_{t&x} = 1 β· x+t β₯ $Ο" for t::nat
using p_q_1 p_0_equiv_nat by (smt (verit) x_lt_psi)
lemma q_defer_old_0_nat: "$q_{fΒ¦t&x} = 0" if "$Ο β€ x+f" for f t :: nat
using q_defer_old_0 psi_le_iff_omega_le that by (metis of_nat_0_le_iff of_nat_add x_lt_psi)
lemma curt_e_sum_P_finite_nat: "$e_x = (βk<n. π«(ΞΎ in π. T x ΞΎ β₯ k + 1 Β¦ T x ΞΎ > 0))"
if "x+n β₯ $Ο" for n::nat
apply (rule curt_e_sum_P_finite, simp)
using that psi_le_iff_omega_le by (smt (verit) le_ereal_less of_nat_add)
lemma curt_e_sum_p_finite_nat: "$e_x = (βk<n. $p_{k+1&x})"
if "βk::nat. k < n βΉ isCont (Ξ»t. $p_{t&x}) (real k + 1)" "x+n β₯ $Ο" for n::nat
apply (rule curt_e_sum_p_finite, simp_all add: that)
using that psi_le_iff_omega_le by (smt (verit) le_ereal_less of_nat_add)
end
lemma q_omega_1: "$q_($Ο-1) = 1"
using q_1_equiv_nat
by (metis diff_less dual_order.refl le_diff_conv of_nat_1 omega_pos zero_less_one)
end
end