Theory Gaussian_Finite_Dimensional

theory Gaussian_Finite_Dimensional
  imports Gaussian_Increments
begin

section ‹Finite-dimensional laws from independent increments›

text ‹The list of times will be assumed sorted, distinct, and nonnegative in
  subsequent results. Index 0 represents the increment from time 0 to ts!0.
  Out-of-range indices are assigned variance 0 to keep this definition total.›

definition increment_variance :: "real list ⇒ nat ⇒ real" where
  "increment_variance ts i =
    (if i ≥ length ts then 0
     else if i = 0 then ts ! 0
     else ts ! i - ts ! (i - 1))"

lemma increment_variance_nonnegative:
  assumes "sorted ts" "∀t∈set ts. 0 ≤ t" "i < length ts"
  shows "0 ≤ increment_variance ts i"
  using assms by (cases i) (auto simp: increment_variance_def sorted_iff_nth_mono)

definition increment_law :: "real list ⇒ (nat ⇒ real) measure" where
  "increment_law ts =
    PiM {..<length ts} (λi. centered_normal (increment_variance ts i))"

lemma prob_space_increment_law [intro]: "prob_space (increment_law ts)"
  unfolding increment_law_def
  by (rule prob_space_PiM) (simp add: prob_space_centered_normal)

lemma sets_increment_law [simp]:
  "sets (increment_law ts) = sets (PiM {..<length ts} (λ_. borel))"
  unfolding increment_law_def
  by (rule sets_PiM_cong) simp_all

lemma increment_law_component:
  assumes "i < length ts"
  shows "distr (increment_law ts) (centered_normal (increment_variance ts i))
           (λw. w i) = centered_normal (increment_variance ts i)"
  unfolding increment_law_def
  by (rule distr_PiM_component) (auto simp: assms)

definition partial_sums :: "nat ⇒ (nat ⇒ real) ⇒ nat ⇒ real" where
  "partial_sums n increments i =
    (if i < n then (∑j≤i. increments j) else undefined)"

lemma partial_sums_increment:
  assumes "0 < i" "i < n"
  shows "partial_sums n w i - partial_sums n w (i - 1) = w i"
  using assms by (cases i) (simp_all add: partial_sums_def)

definition gaussian_finite_law :: "real list ⇒ (nat ⇒ real) measure" where
  "gaussian_finite_law ts =
    distr (increment_law ts) (PiM {..<length ts} (λ_. borel))
      (partial_sums (length ts))"

lemma measurable_partial_sums:
  "partial_sums (length ts) ∈
    measurable (increment_law ts) (PiM {..<length ts} (λ_. borel))"
proof (rule measurable_PiM_single')
  fix i assume i: "i ∈ {..<length ts}"
  have eq: "borel_measurable (increment_law ts) =
      borel_measurable (PiM {..<length ts} (λ_. borel))"
    by (rule measurable_cong_sets) simp_all
  show "(λw. partial_sums (length ts) w i) ∈ borel_measurable (increment_law ts)"
    using i by (auto simp: eq partial_sums_def intro!: borel_measurable_sum measurable_component_singleton)
next
  show "partial_sums (length ts) ∈
    space (increment_law ts) → (ΠE i∈{..<length ts}. space borel)"
    by (auto simp: partial_sums_def space_PiM PiE_iff split: if_splits)
qed

lemma sets_gaussian_finite_law [simp]:
  "sets (gaussian_finite_law ts) = sets (PiM {..<length ts} (λ_. borel))"
  by (simp add: gaussian_finite_law_def)

lemma prob_space_gaussian_finite_law [intro]: "prob_space (gaussian_finite_law ts)"
  unfolding gaussian_finite_law_def
  by (rule prob_space.prob_space_distr[OF prob_space_increment_law measurable_partial_sums])

lemma gaussian_finite_law_empty:
  "gaussian_finite_law [] = PiM {} (λ_. borel)"
proof -
  have "gaussian_finite_law [] =
    distr (count_space {λ_. undefined}) (count_space {λ_. undefined}) (partial_sums 0)"
    by (simp add: gaussian_finite_law_def increment_law_def PiM_empty)
  also have "... = distr (count_space {λ_. undefined}) (count_space {λ_. undefined}) id"
    by (rule distr_cong) (auto simp: partial_sums_def)
  also have "... = PiM {} (λ_. borel)"
    by (simp add: PiM_empty id_def)
  finally show ?thesis .
qed

lemma gaussian_finite_law_initial:
  assumes ts: "ts ≠ []"
  shows "distr (gaussian_finite_law ts) borel (λw. w 0) =
    centered_normal (ts ! 0)"
proof -
  have idx: "0 < length ts" using ts by simp
  have coord: "(λw. w 0) ∈ measurable (PiM {..<length ts} (λ_. borel)) borel"
    by (rule measurable_component_singleton) (simp add: ts)
  have "distr (gaussian_finite_law ts) borel (λw. w 0) =
        distr (increment_law ts) borel ((λw. w 0) ∘ partial_sums (length ts))"
    unfolding gaussian_finite_law_def
    by (rule distr_distr[OF coord measurable_partial_sums])
  also have "... = distr (increment_law ts) borel (λw. w 0)"
    by (rule distr_cong) (simp_all add: partial_sums_def ts)
  also have "... = centered_normal (increment_variance ts 0)"
    using increment_law_component[OF idx]
    by (simp cong: distr_cong)
  also have "... = centered_normal (ts ! 0)"
    using idx by (simp add: increment_variance_def)
  finally show ?thesis .
qed

lemma gaussian_finite_law_starts_at_zero:
  assumes ts: "ts ≠ []" "ts ! 0 = 0"
  shows "AE w in gaussian_finite_law ts. w 0 = 0"
proof -
  have coord: "(λw. w 0) ∈ borel_measurable (gaussian_finite_law ts)"
    by (simp add: gaussian_finite_law_def measurable_component_singleton ts)
  have law: "distr (gaussian_finite_law ts) borel (λw. w 0) = return borel 0"
    using gaussian_finite_law_initial[OF ts(1)] ts(2) by simp
  have ae_zero: "AE x in return borel (0::real). x = 0"
    by (subst AE_return) (auto simp: Measurable.pred_def)
  have "AE x in distr (gaussian_finite_law ts) borel (λw. w 0). x = 0"
    using ae_zero by (simp only: law)
  then show ?thesis by (rule AE_distrD[OF coord])
qed

lemma gaussian_finite_law_increment:
  assumes i: "0 < i" "i < length ts"
  shows "distr (gaussian_finite_law ts) borel (λw. w i - w (i - 1)) =
    centered_normal (increment_variance ts i)"
proof -
  have first: "(λw :: nat ⇒ real. w i) ∈
      borel_measurable (PiM {..<length ts} (λ_. borel))"
    by (rule measurable_component_singleton) (use i in auto)
  have second: "(λw :: nat ⇒ real. w (i - 1)) ∈
      borel_measurable (PiM {..<length ts} (λ_. borel))"
    by (rule measurable_component_singleton) (use i in auto)
  have coord: "(λw :: nat ⇒ real. w i - w (i - 1)) ∈
      borel_measurable (PiM {..<length ts} (λ_. borel))"
    using first second by (rule borel_measurable_diff)
  have "distr (gaussian_finite_law ts) borel (λw. w i - w (i - 1)) =
        distr (increment_law ts) borel
          ((λw. w i - w (i - 1)) ∘ partial_sums (length ts))"
    unfolding gaussian_finite_law_def
    by (rule distr_distr[OF coord measurable_partial_sums])
  also have "... = distr (increment_law ts) borel (λw. w i)"
    using partial_sums_increment[OF i] by (intro distr_cong) (auto simp: comp_def)
  also have "... = centered_normal (increment_variance ts i)"
    using increment_law_component[OF i(2)] by (simp cong: distr_cong)
  finally show ?thesis .
qed

lemma increment_law_independent:
  assumes nonempty: "ts ≠ []"
  shows "prob_space.indep_vars (increment_law ts)
     (λi. centered_normal (increment_variance ts i)) (λi w. w i)
     {..<length ts}"
proof -
  let ?I = "{..<length ts}"
  let ?M = "λi. centered_normal (increment_variance ts i)"
  have prod: "product_prob_space ?M"
    by (rule product_prob_spaceI) (rule prob_space_centered_normal)
  have rv: "⋀i. i ∈ ?I ⟹
    (λw. w i) ∈ measurable (increment_law ts) (?M i)"
    by (simp add: increment_law_def measurable_component_singleton)
  have identity: "(λw. λi∈?I. w i) = (λw. restrict w ?I)"
    by (simp add: fun_eq_iff restrict_def)
  have restricted: "PiM ?I ?M =
    distr (increment_law ts) (PiM ?I ?M) (λw. restrict w ?I)"
    unfolding increment_law_def
    by (rule product_prob_space.distr_restrict[OF prod]) simp_all
  have law: "distr (increment_law ts) (PiM ?I ?M)
          (λw. λi∈?I. w i) = PiM ?I ?M"
    by (subst identity) (rule restricted[symmetric])
  have iff: "prob_space.indep_vars (increment_law ts) ?M (λi w. w i) ?I ⟷
    distr (increment_law ts) (PiM ?I ?M) (λw. λi∈?I. w i) =
      PiM ?I (λi. distr (increment_law ts) (?M i) (λw. w i))"
    by (rule prob_space.indep_vars_iff_distr_eq_PiM'[OF prob_space_increment_law])
       (use nonempty rv in auto)
  have marginals: "PiM ?I (λi. distr (increment_law ts) (?M i) (λw. w i)) =
    PiM ?I ?M"
    by (rule PiM_cong) (auto intro: increment_law_component)
  show ?thesis using iff law marginals by simp
qed

definition coordinate_increments :: "nat ⇒ (nat ⇒ real) ⇒ nat ⇒ real" where
  "coordinate_increments n w i =
    (if i < n then (if i = 0 then w 0 else w i - w (i - 1)) else undefined)"

lemma coordinate_increments_partial_sums:
  "coordinate_increments n (partial_sums n w) = restrict w {..<n}"
proof (rule ext)
  fix i
  have initial: "0 < n ⟹ partial_sums n w 0 = w 0"
    by (simp add: partial_sums_def)
  show "coordinate_increments n (partial_sums n w) i = restrict w {..<n} i"
  proof (cases "i < n")
    case False
    then show ?thesis by (simp add: coordinate_increments_def restrict_def)
  next
    case True
    show ?thesis
    proof (cases "i = 0")
      case True
      with ‹i < n› show ?thesis
        by (simp add: coordinate_increments_def restrict_def initial)
    next
      case False
      with True have pos: "0 < i" by simp
      have step: "partial_sums n w i - partial_sums n w (i - 1) = w i"
        by (rule partial_sums_increment[OF pos True])
      with True False show ?thesis
        by (simp add: coordinate_increments_def restrict_def)
    qed
  qed
qed

lemma partial_sums_coordinate_increments:
  "partial_sums n (coordinate_increments n w) = restrict w {..<n}"
proof -
  have telescope: "(∑j≤i. coordinate_increments n w j) = w i"
    if i: "i < n" for i
    using i
  proof (induction i)
    case 0
    then show ?case by (simp add: coordinate_increments_def)
  next
    case (Suc i)
    then show ?case by (simp add: coordinate_increments_def)
  qed
  show ?thesis using telescope
    by (intro ext) (auto simp: partial_sums_def restrict_def)
qed

lemma measurable_coordinate_increments:
  "coordinate_increments (length ts) ∈
    measurable (PiM {..<length ts} (λ_. borel)) (increment_law ts)"
proof -
  let ?I = "{..<length ts}"
  let ?B = "λ_. borel"
  have meas: "coordinate_increments (length ts) ∈ measurable (PiM ?I ?B) (PiM ?I ?B)"
  proof (rule measurable_PiM_single')
    fix i assume i: "i ∈ ?I"
    have first: "(λw :: nat ⇒ real. w i) ∈ borel_measurable (PiM ?I ?B)"
      by (rule measurable_component_singleton) (use i in auto)
    show "(λw. coordinate_increments (length ts) w i) ∈
      borel_measurable (PiM ?I ?B)"
    proof (cases "i = 0")
      case True
      with i first show ?thesis by (simp add: coordinate_increments_def)
    next
      case False
      have second: "(λw :: nat ⇒ real. w (i - 1)) ∈
        borel_measurable (PiM ?I ?B)"
        by (rule measurable_component_singleton) (use i False in auto)
      from i False first second show ?thesis
        by (simp add: coordinate_increments_def borel_measurable_diff)
    qed
  next
    show "coordinate_increments (length ts) ∈
      space (PiM ?I ?B) → (ΠE i∈?I. space borel)"
      by (auto simp: coordinate_increments_def space_PiM PiE_iff split: if_splits)
  qed
  show ?thesis using meas
    by (simp only: measurable_cong_sets[OF refl sets_increment_law[symmetric]])
qed

lemma gaussian_finite_law_coordinate_increments:
  "distr (gaussian_finite_law ts) (increment_law ts)
    (coordinate_increments (length ts)) = increment_law ts"
proof -
  let ?I = "{..<length ts}"
  have prod: "product_prob_space (λi. centered_normal (increment_variance ts i))"
    by (rule product_prob_spaceI) (rule prob_space_centered_normal)
  have "distr (gaussian_finite_law ts) (increment_law ts)
      (coordinate_increments (length ts)) =
    distr (increment_law ts) (increment_law ts)
      (coordinate_increments (length ts) ∘ partial_sums (length ts))"
    unfolding gaussian_finite_law_def
    by (rule distr_distr[OF measurable_coordinate_increments measurable_partial_sums])
  also have "... = distr (increment_law ts) (increment_law ts)
    (λw. restrict w ?I)"
    using coordinate_increments_partial_sums by (intro distr_cong) (auto simp: comp_def)
  also have "... = increment_law ts"
    unfolding increment_law_def
    by (rule sym, rule product_prob_space.distr_restrict[OF prod]) simp_all
  finally show ?thesis .
qed

lemma gaussian_finite_law_independent_increments:
  assumes nonempty: "ts ≠ []"
  shows "prob_space.indep_vars (gaussian_finite_law ts)
    (λi. centered_normal (increment_variance ts i))
    (λi w. coordinate_increments (length ts) w i) {..<length ts}"
proof -
  let ?I = "{..<length ts}"
  let ?M = "λi. centered_normal (increment_variance ts i)"
  let ?D = "coordinate_increments (length ts)"
  have full: "?D ∈ measurable (gaussian_finite_law ts) (increment_law ts)"
    using measurable_coordinate_increments
    by (simp only: measurable_cong_sets[OF sets_gaussian_finite_law refl])
  have component: "(λw. w i) ∈ measurable (increment_law ts) (?M i)"
    if "i ∈ ?I" for i
    unfolding increment_law_def
    by (rule measurable_component_singleton) (use that in auto)
  have rv: "(λw. ?D w i) ∈ measurable (gaussian_finite_law ts) (?M i)"
    if "i ∈ ?I" for i
    using measurable_compose[OF full component[OF that]] by (simp add: comp_def)
  have identity: "(λw. λi∈?I. ?D w i) = ?D"
    by (auto simp: fun_eq_iff coordinate_increments_def)
  have joint: "distr (gaussian_finite_law ts) (PiM ?I ?M)
      (λw. λi∈?I. ?D w i) = PiM ?I ?M"
    using gaussian_finite_law_coordinate_increments[of ts]
    by (simp only: identity increment_law_def)
  have marginals: "distr (gaussian_finite_law ts) (?M i) (λw. ?D w i) = ?M i"
    if i: "i ∈ ?I" for i
  proof -
    have "distr (gaussian_finite_law ts) (?M i) (λw. ?D w i) =
      distr (distr (gaussian_finite_law ts) (increment_law ts) ?D)
        (?M i) (λw. w i)"
      using distr_distr[OF component[OF i] full] by (simp add: comp_def)
    also have "... = ?M i"
      using increment_law_component[of i ts] i
      by (simp add: gaussian_finite_law_coordinate_increments)
    finally show ?thesis .
  qed
  have iff: "prob_space.indep_vars (gaussian_finite_law ts) ?M
      (λi w. ?D w i) ?I ⟷
    distr (gaussian_finite_law ts) (PiM ?I ?M)
      (λw. λi∈?I. ?D w i) =
    PiM ?I (λi. distr (gaussian_finite_law ts) (?M i) (λw. ?D w i))"
    by (rule prob_space.indep_vars_iff_distr_eq_PiM'[OF prob_space_gaussian_finite_law])
       (use nonempty rv in auto)
  have product: "PiM ?I (λi. distr (gaussian_finite_law ts) (?M i) (λw. ?D w i)) =
    PiM ?I ?M"
    by (rule PiM_cong) (auto intro: marginals)
  show ?thesis using iff joint product by simp
qed

lemma gaussian_finite_law_independent_borel_increments:
  assumes "ts ≠ []"
  shows "prob_space.indep_vars (gaussian_finite_law ts) (λ_. borel)
    (λi w. coordinate_increments (length ts) w i) {..<length ts}"
proof -
  interpret P: prob_space "gaussian_finite_law ts" by (rule prob_space_gaussian_finite_law)
  have independent: "P.indep_vars
    (λi. centered_normal (increment_variance ts i))
    (λi w. coordinate_increments (length ts) w i) {..<length ts}"
    by (rule gaussian_finite_law_independent_increments[OF assms])
  show ?thesis
    using independent
    by (simp add: P.indep_vars_def2 cong: measurable_cong_sets)
qed

lemma gaussian_finite_law_coordinate_increment:
  assumes i: "i < length ts"
  shows "distr (gaussian_finite_law ts) borel
    (λw. coordinate_increments (length ts) w i) =
    centered_normal (increment_variance ts i)"
proof (cases i)
  case 0
  with i show ?thesis
    by (simp add: coordinate_increments_def increment_variance_def
      gaussian_finite_law_initial)
next
  case (Suc j)
  with i gaussian_finite_law_increment[of "Suc j" ts] show ?thesis
    by (simp add: coordinate_increments_def)
qed

lemma gaussian_finite_law_adjacent_independent:
  assumes bound: "Suc i < length ts"
  shows "prob_space.indep_var (gaussian_finite_law ts)
    borel (λw. coordinate_increments (length ts) w i)
    borel (λw. coordinate_increments (length ts) w (Suc i))"
proof -
  interpret P: prob_space "gaussian_finite_law ts" by (rule prob_space_gaussian_finite_law)
  let ?X = "λi w. coordinate_increments (length ts) w i"
  have nonempty: "ts ≠ []" using bound by auto
  have independent: "P.indep_vars (λ_. borel) ?X (insert i {Suc i})"
    by (rule P.indep_vars_subset[OF gaussian_finite_law_independent_borel_increments[OF nonempty]])
       (use bound in auto)
  have "P.indep_var borel (?X i) borel (λw. ∑j∈{Suc i}. ?X j w)"
    by (rule P.indep_vars_sum[OF _ _ independent]) simp_all
  then show ?thesis by simp
qed

lemma gaussian_finite_law_adjacent_sum:
  assumes sorted: "sorted ts" and nonnegative: "∀t∈set ts. 0 ≤ t"
    and bound: "Suc i < length ts"
  shows "distr (gaussian_finite_law ts) borel
    (λw. coordinate_increments (length ts) w i +
      coordinate_increments (length ts) w (Suc i)) =
    centered_normal (increment_variance ts i + increment_variance ts (Suc i))"
proof -
  interpret P: prob_space "gaussian_finite_law ts" by (rule prob_space_gaussian_finite_law)
  let ?X = "λw. coordinate_increments (length ts) w i"
  let ?Y = "λw. coordinate_increments (length ts) w (Suc i)"
  have independent: "P.indep_var borel ?X borel ?Y"
    by (rule gaussian_finite_law_adjacent_independent[OF bound])
  have measurable_X: "?X ∈ borel_measurable (gaussian_finite_law ts)"
    using independent unfolding P.indep_var_def P.indep_vars_def2
    by (auto split: bool.splits)
  have measurable_Y: "?Y ∈ borel_measurable (gaussian_finite_law ts)"
    using independent unfolding P.indep_var_def P.indep_vars_def2
    by (auto split: bool.splits)
  have i: "i < length ts" using bound by simp
  show ?thesis
    by (rule centered_normal_add[OF prob_space_gaussian_finite_law independent
      measurable_X measurable_Y
      increment_variance_nonnegative[OF sorted nonnegative i]
      increment_variance_nonnegative[OF sorted nonnegative bound]
      gaussian_finite_law_coordinate_increment[OF i]
      gaussian_finite_law_coordinate_increment[OF bound]])
qed

definition delete_time :: "real list ⇒ nat ⇒ real list" where
  "delete_time ts j = take j ts @ drop (Suc j) ts"

lemma delete_time_length:
  assumes "j < length ts"
  shows "length (delete_time ts j) = length ts - 1"
  using assms by (simp add: delete_time_def)

lemma delete_time_nth:
  assumes "j < length ts" "i < length (delete_time ts j)"
  shows "delete_time ts j ! i = (if i < j then ts ! i else ts ! Suc i)"
  using assms by (auto simp: delete_time_def nth_append)

lemma increment_variance_delete_time_merged:
  assumes bound: "Suc j < length ts"
  shows "increment_variance (delete_time ts j) j =
    increment_variance ts j + increment_variance ts (Suc j)"
proof -
  have j: "j < length ts" using bound by simp
  have len: "length (delete_time ts j) = length ts - 1"
    by (rule delete_time_length[OF j])
  have idx: "j < length (delete_time ts j)" using bound len by simp
  have curr: "delete_time ts j ! j = ts ! Suc j"
    using delete_time_nth[OF j idx] by simp
  show ?thesis
  proof (cases j)
    case 0
    have nonempty: "ts ≠ []" using bound by auto
    from 0 bound len curr nonempty show ?thesis
      by (simp add: increment_variance_def)
  next
    case (Suc k)
    have prev: "delete_time ts j ! (j - 1) = ts ! (j - 1)"
      using delete_time_nth[OF j, of "j - 1"] Suc idx by simp
    with Suc bound len curr idx show ?thesis
      by (simp add: increment_variance_def)
  qed
qed

definition delete_coordinate :: "nat ⇒ nat ⇒ (nat ⇒ real) ⇒ nat ⇒ real" where
  "delete_coordinate n j w i =
    (if i < n - 1 then w (if i < j then i else Suc i) else undefined)"

lemma delete_coordinate_merged_increment:
  assumes bound: "Suc j < n"
  shows "coordinate_increments (n - 1) (delete_coordinate n j w) j =
    coordinate_increments n w j + coordinate_increments n w (Suc j)"
proof (cases j)
  case 0
  have idx: "j < n - 1" using bound by simp
  with 0 bound show ?thesis
    by (simp add: coordinate_increments_def delete_coordinate_def)
next
  case (Suc k)
  have idx: "j < n - 1" using bound by simp
  with Suc bound show ?thesis
    by (simp add: coordinate_increments_def delete_coordinate_def)
qed

lemma increment_variance_delete_time_unaffected:
  assumes j: "j < length ts" and i: "i < length (delete_time ts j)"
    and different: "i ≠ j"
  shows "increment_variance (delete_time ts j) i =
    increment_variance ts (if i < j then i else Suc i)"
proof -
  have len: "length (delete_time ts j) = length ts - 1"
    by (rule delete_time_length[OF j])
  have bound: "Suc i < length ts" using i len by simp
  have curr: "delete_time ts j ! i = (if i < j then ts ! i else ts ! Suc i)"
    by (rule delete_time_nth[OF j i])
  show ?thesis
  proof (cases i)
    case 0
    have nonempty: "ts ≠ []" using j by auto
    from 0 different i len bound curr nonempty show ?thesis
      by (simp add: increment_variance_def)
  next
    case (Suc k)
    have prev: "delete_time ts j ! k = (if k < j then ts ! k else ts ! Suc k)"
      by (rule delete_time_nth[OF j]) (use i Suc in auto)
    from Suc different i len bound curr prev show ?thesis
      by (auto simp: increment_variance_def)
  qed
qed

lemma delete_coordinate_unaffected_increment:
  assumes j: "j < length ts" and i: "i < length (delete_time ts j)"
    and different: "i ≠ j"
  shows "coordinate_increments (length (delete_time ts j))
      (delete_coordinate (length ts) j w) i =
    coordinate_increments (length ts) w (if i < j then i else Suc i)"
proof -
  have len: "length (delete_time ts j) = length ts - 1"
    by (rule delete_time_length[OF j])
  have bound: "Suc i < length ts" using i len by simp
  show ?thesis using i different len bound
    by (cases i) (auto simp: coordinate_increments_def delete_coordinate_def)
qed

lemma measurable_delete_coordinate:
  assumes j: "j < length ts"
  shows "delete_coordinate (length ts) j ∈
    measurable (PiM {..<length ts} (λ_. borel))
      (PiM {..<length (delete_time ts j)} (λ_. borel))"
proof (rule measurable_PiM_single')
  fix i assume i: "i ∈ {..<length (delete_time ts j)}"
  have len: "length (delete_time ts j) = length ts - 1"
    by (rule delete_time_length[OF j])
  have idx: "(if i < j then i else Suc i) < length ts"
    using i len by auto
  show "(λw. delete_coordinate (length ts) j w i) ∈
    borel_measurable (PiM {..<length ts} (λ_. borel))"
    using i len idx by (simp add: delete_coordinate_def measurable_component_singleton)
next
  show "delete_coordinate (length ts) j ∈
    space (PiM {..<length ts} (λ_. borel)) →
      (ΠE i∈{..<length (delete_time ts j)}. space borel)"
    using delete_time_length[OF j]
    by (auto simp: delete_coordinate_def space_PiM PiE_iff split: if_splits)
qed

lemma gaussian_finite_law_deleted_time_unaffected_increment:
  assumes j: "j < length ts" and i: "i < length (delete_time ts j)"
    and different: "i ≠ j"
  shows "distr (gaussian_finite_law ts) borel
    (λw. coordinate_increments (length (delete_time ts j))
      (delete_coordinate (length ts) j w) i) =
    centered_normal (increment_variance (delete_time ts j) i)"
proof -
  have old: "(if i < j then i else Suc i) < length ts"
    using i delete_time_length[OF j] by auto
  have "distr (gaussian_finite_law ts) borel
    (λw. coordinate_increments (length (delete_time ts j))
      (delete_coordinate (length ts) j w) i) =
    distr (gaussian_finite_law ts) borel
      (λw. coordinate_increments (length ts) w
        (if i < j then i else Suc i))"
    using delete_coordinate_unaffected_increment[OF j i different]
    by (intro distr_cong) auto
  also have "... = centered_normal
    (increment_variance ts (if i < j then i else Suc i))"
    by (rule gaussian_finite_law_coordinate_increment[OF old])
  also have "... = centered_normal (increment_variance (delete_time ts j) i)"
    by (simp only: increment_variance_delete_time_unaffected[OF j i different])
  finally show ?thesis .
qed

lemma gaussian_finite_law_deleted_time_merged_increment:
  assumes sorted: "sorted ts" and nonnegative: "∀t∈set ts. 0 ≤ t"
    and bound: "Suc j < length ts"
  shows "distr (gaussian_finite_law ts) borel
    (λw. coordinate_increments (length (delete_time ts j))
      (delete_coordinate (length ts) j w) j) =
    centered_normal (increment_variance (delete_time ts j) j)"
proof -
  have len: "length (delete_time ts j) = length ts - 1"
    by (rule delete_time_length) (use bound in auto)
  have "distr (gaussian_finite_law ts) borel
    (λw. coordinate_increments (length (delete_time ts j))
      (delete_coordinate (length ts) j w) j) =
    distr (gaussian_finite_law ts) borel
      (λw. coordinate_increments (length ts) w j +
        coordinate_increments (length ts) w (Suc j))"
    using delete_coordinate_merged_increment[OF bound]
    by (intro distr_cong) (auto simp: len)
  also have "... = centered_normal
    (increment_variance ts j + increment_variance ts (Suc j))"
    by (rule gaussian_finite_law_adjacent_sum[OF sorted nonnegative bound])
  also have "... = centered_normal (increment_variance (delete_time ts j) j)"
    by (simp only: increment_variance_delete_time_merged[OF bound])
  finally show ?thesis .
qed

definition deletion_block :: "nat ⇒ nat ⇒ nat set" where
  "deletion_block j i =
    (if i = j then {j, Suc j} else {if i < j then i else Suc i})"

lemma deletion_block_subset:
  assumes bound: "Suc j < n" and i: "i < n - 1"
  shows "deletion_block j i ⊆ {..<n}"
  using assms by (auto simp: deletion_block_def)

lemma deletion_blocks_disjoint:
  "disjoint_family_on (deletion_block j) {..<n - 1}"
  by (auto simp: disjoint_family_on_def deletion_block_def)

lemma gaussian_finite_law_deleted_time_independent_increments:
  assumes bound: "Suc j < length ts"
  shows "prob_space.indep_vars (gaussian_finite_law ts) (λ_. borel)
    (λi w. coordinate_increments (length (delete_time ts j))
      (delete_coordinate (length ts) j w) i)
    {..<length (delete_time ts j)}"
proof -
  interpret P: prob_space "gaussian_finite_law ts" by (rule prob_space_gaussian_finite_law)
  let ?n = "length ts"
  let ?I = "{..<length (delete_time ts j)}"
  let ?K = "deletion_block j"
  let ?X = "λk w. coordinate_increments ?n w k"
  let ?R = "λi w. restrict (λk. ?X k w) (?K i)"
  let ?Y = "λi (u :: nat ⇒ real). if i = j then u j + u (Suc j)
    else u (if i < j then i else Suc i)"
  have len: "length (delete_time ts j) = ?n - 1"
    by (rule delete_time_length) (use bound in auto)
  have nonempty: "ts ≠ []" using bound by auto
  have independent: "P.indep_vars (λ_. borel) ?X {..<?n}"
    by (rule gaussian_finite_law_independent_borel_increments[OF nonempty])
  have blocks: "P.indep_vars (λi. PiM (?K i) (λ_. borel)) ?R ?I"
  proof (rule P.indep_vars_restrict[OF independent])
    fix i assume i: "i ∈ ?I"
    show "?K i ⊆ {..<?n}"
      by (rule deletion_block_subset[OF bound]) (use i in ‹simp add: len›)
  next
    show "disjoint_family_on ?K ?I"
      using deletion_blocks_disjoint[of j ?n] by (simp only: len)
  qed
  have measurable: "?Y i ∈ borel_measurable (PiM (?K i) (λ_. borel))"
    if i: "i ∈ ?I" for i
  proof (cases "i = j")
    case True
    have a: "(λu :: nat ⇒ real. u j) ∈
      borel_measurable (PiM (?K i) (λ_. borel))"
      by (rule measurable_component_singleton) (simp add: deletion_block_def True)
    have b: "(λu :: nat ⇒ real. u (Suc j)) ∈
      borel_measurable (PiM (?K i) (λ_. borel))"
      by (rule measurable_component_singleton) (simp add: deletion_block_def True)
    have aj: "(λu :: nat ⇒ real. u j) ∈
      borel_measurable (PiM (?K j) (λ_. borel))"
      using a True by simp
    have bj: "(λu :: nat ⇒ real. u (Suc j)) ∈
      borel_measurable (PiM (?K j) (λ_. borel))"
      using b True by simp
    have sum_meas: "(λ(u :: nat ⇒ real). u j + u (Suc j)) ∈
      borel_measurable (PiM (?K j) (λ_. borel))"
      by (rule borel_measurable_add[OF aj bj])
    show ?thesis using sum_meas True by (simp only: True if_True)
  next
    case False
    have "(if i < j then i else Suc i) ∈ ?K i"
      by (simp add: deletion_block_def False)
    then show ?thesis using False
      by (simp add: measurable_component_singleton)
  qed
  have composed: "P.indep_vars (λ_. borel) (λi w. ?Y i (?R i w)) ?I"
    by (rule P.indep_vars_compose2[OF blocks measurable])
  have eq: "?Y i (?R i w) =
    coordinate_increments (length (delete_time ts j))
      (delete_coordinate ?n j w) i" if i: "i ∈ ?I" for i w
  proof (cases "i = j")
    case True
    from True len delete_coordinate_merged_increment[OF bound, of w]
    show ?thesis by (simp add: deletion_block_def)
  next
    case False
    with i bound show ?thesis
      by (simp add: deletion_block_def
        delete_coordinate_unaffected_increment[of j ts i w])
  qed
  have same: "P.indep_vars (λ_. borel) (λi w. ?Y i (?R i w)) ?I =
    P.indep_vars (λ_. borel)
      (λi w. coordinate_increments (length (delete_time ts j))
        (delete_coordinate ?n j w) i) ?I"
    by (rule P.indep_vars_cong) (use eq in auto)
  show ?thesis using composed same by simp
qed

lemma gaussian_finite_law_deleted_time_increment_law:
  assumes sorted: "sorted ts" and nonnegative: "∀t∈set ts. 0 ≤ t"
    and bound: "Suc j < length ts"
  shows "distr (gaussian_finite_law ts) (increment_law (delete_time ts j))
    (λw. coordinate_increments (length (delete_time ts j))
      (delete_coordinate (length ts) j w)) = increment_law (delete_time ts j)"
proof -
  interpret P: prob_space "gaussian_finite_law ts" by (rule prob_space_gaussian_finite_law)
  let ?ds = "delete_time ts j"
  let ?I = "{..<length ?ds}"
  let ?D = "λw. coordinate_increments (length ?ds)
    (delete_coordinate (length ts) j w)"
  have j: "j < length ts" using bound by simp
  have len: "length ?ds = length ts - 1" by (rule delete_time_length[OF j])
  have independent: "P.indep_vars (λ_. borel) (λi w. ?D w i) ?I"
    by (rule gaussian_finite_law_deleted_time_independent_increments[OF bound])
  have rv: "(λw. ?D w i) ∈ borel_measurable (gaussian_finite_law ts)"
    if "i ∈ ?I" for i
    using independent that by (simp add: P.indep_vars_def2)
  have marginals: "distr (gaussian_finite_law ts) borel (λw. ?D w i) =
      centered_normal (increment_variance ?ds i)" if i: "i ∈ ?I" for i
  proof (cases "i = j")
    case True
    then show ?thesis
      by (simp only: gaussian_finite_law_deleted_time_merged_increment
        [OF sorted nonnegative bound])
  next
    case False
    show ?thesis
      by (rule gaussian_finite_law_deleted_time_unaffected_increment[OF j])
         (use i False in auto)
  qed
  have positive: "0 < length ?ds" using bound len by arith
  have nonempty: "?I ≠ {}" using positive by auto
  have identity: "(λw. λi∈?I. ?D w i) = ?D"
    by (auto simp: fun_eq_iff coordinate_increments_def)
  have iff: "P.indep_vars (λ_. borel) (λi w. ?D w i) ?I ⟷
    distr (gaussian_finite_law ts) (PiM ?I (λ_. borel))
      (λw. λi∈?I. ?D w i) =
    PiM ?I (λi. distr (gaussian_finite_law ts) borel (λw. ?D w i))"
    by (rule P.indep_vars_iff_distr_eq_PiM') (use nonempty rv in auto)
  have product: "PiM ?I (λi. distr (gaussian_finite_law ts) borel (λw. ?D w i)) =
    increment_law ?ds"
    unfolding increment_law_def
    by (rule PiM_cong) (use marginals in auto)
  have joint: "distr (gaussian_finite_law ts) (PiM ?I (λ_. borel)) ?D =
    increment_law ?ds"
    using independent iff product by (simp only: identity)
  have same: "distr (gaussian_finite_law ts) (increment_law ?ds) ?D =
    distr (gaussian_finite_law ts) (PiM ?I (λ_. borel)) ?D"
    by (rule distr_cong) auto
  show ?thesis using same joint by simp
qed

theorem gaussian_finite_law_delete_time:
  assumes sorted: "sorted ts" and nonnegative: "∀t∈set ts. 0 ≤ t"
    and bound: "Suc j < length ts"
  shows "distr (gaussian_finite_law ts)
    (PiM {..<length (delete_time ts j)} (λ_. borel))
    (delete_coordinate (length ts) j) = gaussian_finite_law (delete_time ts j)"
proof -
  let ?ds = "delete_time ts j"
  let ?n = "length ts"
  let ?I = "{..<length ?ds}"
  let ?B = "λ_. borel"
  let ?del = "delete_coordinate ?n j"
  let ?D = "coordinate_increments (length ?ds) ∘ ?del"
  have j: "j < ?n" using bound by simp
  have len: "length ?ds = ?n - 1" by (rule delete_time_length[OF j])
  have measurable_del: "?del ∈ measurable (gaussian_finite_law ts) (PiM ?I ?B)"
    using measurable_delete_coordinate[OF j]
    by (simp only: measurable_cong_sets[OF sets_gaussian_finite_law refl])
  have measurable_D: "?D ∈ measurable (gaussian_finite_law ts) (increment_law ?ds)"
    by (rule measurable_comp[OF measurable_del measurable_coordinate_increments[of ?ds]])
  have measurable_sums: "partial_sums (length ?ds) ∈
    measurable (increment_law ?ds) (PiM ?I ?B)"
    by (rule measurable_partial_sums)
  have inverse: "partial_sums (length ?ds) (?D w) = ?del w" for w
    by (auto simp: comp_def partial_sums_coordinate_increments len
      delete_coordinate_def restrict_def fun_eq_iff)
  have "distr (gaussian_finite_law ts) (PiM ?I ?B) ?del =
    distr (gaussian_finite_law ts) (PiM ?I ?B)
      (partial_sums (length ?ds) ∘ ?D)"
    using inverse by (intro distr_cong) (auto simp: comp_def)
  also have "... = distr (distr (gaussian_finite_law ts) (increment_law ?ds) ?D)
    (PiM ?I ?B) (partial_sums (length ?ds))"
    by (rule distr_distr[OF measurable_sums measurable_D, symmetric])
  also have "... = gaussian_finite_law ?ds"
    using gaussian_finite_law_deleted_time_increment_law[OF sorted nonnegative bound]
    by (simp add: gaussian_finite_law_def comp_def)
  finally show ?thesis .
qed

lemma partial_sums_restrict:
  assumes "k ≤ n"
  shows "restrict (partial_sums n w) {..<k} =
    partial_sums k (restrict w {..<k})"
  using assms by (intro ext) (auto simp: restrict_def partial_sums_def intro!: sum.cong)

lemma increment_variance_take:
  assumes "k ≤ length ts" "i < k"
  shows "increment_variance (take k ts) i = increment_variance ts i"
proof -
  have len: "length (take k ts) = k" using assms by simp
  have nth: "take k ts ! j = ts ! j" if "j < k" for j
    using that assms by simp
  show ?thesis
    using assms len nth by (cases i) (auto simp: increment_variance_def)
qed

lemma increment_law_prefix:
  assumes k: "k ≤ length ts"
  shows "distr (increment_law ts)
    (PiM {..<k} (λi. centered_normal (increment_variance (take k ts) i)))
    (λw. restrict w {..<k}) = increment_law (take k ts)"
proof -
  have prod: "product_prob_space (λi. centered_normal (increment_variance ts i))"
    by (rule product_prob_spaceI) (rule prob_space_centered_normal)
  have targets: "PiM {..<k} (λi. centered_normal (increment_variance (take k ts) i)) =
      PiM {..<k} (λi. centered_normal (increment_variance ts i))"
    by (intro PiM_cong) (auto simp: k increment_variance_take)
  have restricted: "distr (PiM {..<length ts}
        (λi. centered_normal (increment_variance ts i)))
        (PiM {..<k} (λi. centered_normal (increment_variance ts i)))
        (λw. restrict w {..<k}) =
      PiM {..<k} (λi. centered_normal (increment_variance ts i))"
    by (rule sym, rule product_prob_space.distr_restrict[OF prod]) (use k in auto)
  show ?thesis
    unfolding increment_law_def
    using k by (simp only: length_take min_absorb2 targets restricted)
qed

lemma gaussian_finite_law_prefix:
  assumes k: "k ≤ length ts"
  shows "distr (gaussian_finite_law ts) (PiM {..<k} (λ_. borel))
    (λw. restrict w {..<k}) = gaussian_finite_law (take k ts)"
proof -
  let ?B = "λ_. borel"
  have length: "length (take k ts) = k" using k by simp
  have measurable_restrict: "(λw. restrict w {..<k}) ∈
      measurable (PiM {..<length ts} ?B) (PiM {..<k} ?B)"
    by (rule measurable_restrict_subset) (use k in auto)
  have measurable_sums: "partial_sums k ∈
      measurable (increment_law (take k ts)) (PiM {..<k} ?B)"
    using measurable_partial_sums[of "take k ts"] by (simp only: length)
  have target_sets: "sets (increment_law (take k ts)) = sets (PiM {..<k} ?B)"
    by (simp only: sets_increment_law length)
  have measurable_increments: "(λw. restrict w {..<k}) ∈
      measurable (increment_law ts) (increment_law (take k ts))"
    using measurable_restrict
    by (simp only: measurable_cong_sets[OF sets_increment_law target_sets])
  have "distr (gaussian_finite_law ts) (PiM {..<k} ?B)
      (λw. restrict w {..<k}) =
    distr (increment_law ts) (PiM {..<k} ?B)
      ((λw. restrict w {..<k}) ∘ partial_sums (length ts))"
    unfolding gaussian_finite_law_def
    by (rule distr_distr[OF measurable_restrict measurable_partial_sums])
  also have "... = distr (increment_law ts) (PiM {..<k} ?B)
      (partial_sums k ∘ (λw. restrict w {..<k}))"
    using partial_sums_restrict[OF k] by (intro distr_cong) (auto simp: comp_def)
  also have "... = distr (distr (increment_law ts) (increment_law (take k ts))
      (λw. restrict w {..<k})) (PiM {..<k} ?B) (partial_sums k)"
    by (rule distr_distr[OF measurable_sums measurable_increments, symmetric])
  also have "... = gaussian_finite_law (take k ts)"
  proof -
    have prefix: "distr (increment_law ts) (increment_law (take k ts))
        (λw. restrict w {..<k}) = increment_law (take k ts)"
      using increment_law_prefix[OF k]
      by (simp only: increment_law_def length)
    show ?thesis by (simp only: prefix gaussian_finite_law_def length)
  qed
  finally show ?thesis .
qed

corollary gaussian_finite_law_butlast:
  assumes "ts ≠ []"
  shows "distr (gaussian_finite_law ts)
    (PiM {..<length (butlast ts)} (λ_. borel))
    (λw. restrict w {..<length (butlast ts)}) =
    gaussian_finite_law (butlast ts)"
  using gaussian_finite_law_prefix[of "length ts - 1" ts] assms
  by (simp add: butlast_conv_take)

corollary gaussian_finite_law_delete_time_any:
  assumes sorted: "sorted ts" and nonnegative: "∀t∈set ts. 0 ≤ t"
    and j: "j < length ts"
  shows "distr (gaussian_finite_law ts)
    (PiM {..<length (delete_time ts j)} (λ_. borel))
    (delete_coordinate (length ts) j) = gaussian_finite_law (delete_time ts j)"
proof (cases "Suc j < length ts")
  case True
  show ?thesis by (rule gaussian_finite_law_delete_time[OF sorted nonnegative True])
next
  case False
  have last: "Suc j = length ts" using False j by arith
  have ds: "delete_time ts j = take j ts"
    using last by (simp add: delete_time_def)
  have dc: "delete_coordinate (length ts) j = (λw. restrict w {..<j})"
    using last by (auto simp: fun_eq_iff delete_coordinate_def restrict_def)
  have prefix: "distr (gaussian_finite_law ts)
      (PiM {..<j} (λ_. borel)) (λw. restrict w {..<j}) =
      gaussian_finite_law (take j ts)"
    by (rule gaussian_finite_law_prefix) (use j in auto)
  show ?thesis using prefix by (simp only: ds dc length_take min_absorb2[OF less_imp_le[OF j]])
qed

lemma increment_variance_scale:
  "increment_variance (map (λt. c * t) ts) i =
    c * increment_variance ts i"
  by (auto simp: increment_variance_def algebra_simps)

lemma increment_law_scale:
  assumes c: "0 < c" and sorted: "sorted ts"
    and nonnegative: "∀t∈set ts. 0 ≤ t"
  shows "distr (increment_law (map (λt. c * t) ts)) (increment_law ts)
    (compose {..<length ts} (λx. x / sqrt c)) = increment_law ts"
proof -
  let ?I = "{..<length ts}"
  let ?us = "map (λt. c * t) ts"
  have src: "product_prob_space (λi. centered_normal (increment_variance ?us i))"
    by (rule product_prob_spaceI) (rule prob_space_centered_normal)
  have tgt: "product_prob_space (λi. centered_normal (increment_variance ts i))"
    by (rule product_prob_spaceI) (rule prob_space_centered_normal)
  have base: "(λx::real. x / sqrt c) ∈ borel_measurable borel"
    by measurable
  have meas: "(λx. x / sqrt c) ∈ measurable
    (centered_normal (increment_variance ?us i))
    (centered_normal (increment_variance ts i))" for i
    using base
    by (simp only: measurable_cong_sets[OF sets_centered_normal sets_centered_normal])
  have "distr (increment_law ?us) (increment_law ts)
      (compose ?I (λx. x / sqrt c)) =
    PiM ?I (λi. distr (centered_normal (increment_variance ?us i))
      (centered_normal (increment_variance ts i)) (λx. x / sqrt c))"
    unfolding increment_law_def
    by (simp only: length_map; rule distr_PiM_finite_prob_space[OF _ src tgt meas]; simp)
  also have "... = increment_law ts"
  proof -
    have component: "distr (centered_normal (increment_variance ?us i))
      (centered_normal (increment_variance ts i)) (λx. x / sqrt c) =
      centered_normal (increment_variance ts i)" if "i ∈ ?I" for i
    proof -
      have v: "0 ≤ increment_variance ts i"
        by (rule increment_variance_nonnegative[OF sorted nonnegative]) (use that in auto)
      have "distr (centered_normal (increment_variance ?us i))
        (centered_normal (increment_variance ts i)) (λx. x / sqrt c) =
        distr (centered_normal (increment_variance ?us i)) borel
          (λx. x / sqrt c)"
        by (rule distr_cong) simp_all
      also have "... = centered_normal (increment_variance ts i)"
        by (simp only: increment_variance_scale centered_normal_scale[OF c v])
      finally show ?thesis .
    qed
    show ?thesis unfolding increment_law_def
      by (rule PiM_cong) (use component in auto)
  qed
  finally show ?thesis .
qed

lemma gaussian_finite_law_scale:
  assumes c: "0 < c" and sorted: "sorted ts"
    and nonnegative: "∀t∈set ts. 0 ≤ t"
  shows "distr (gaussian_finite_law (map (λt. c * t) ts))
    (PiM {..<length ts} (λ_. borel))
    (compose {..<length ts} (λx. x / sqrt c)) =
    gaussian_finite_law ts"
proof -
  let ?I = "{..<length ts}"
  let ?F = "compose ?I (λx. x / sqrt c)"
  let ?us = "map (λt. c * t) ts"
  have map_meas: "?F ∈ measurable (PiM ?I (λ_. borel))
    (PiM ?I (λ_. borel))"
  proof (rule measurable_PiM_single')
    fix i assume i: "i ∈ ?I"
    have coord: "(λw::nat ⇒ real. w i) ∈
      borel_measurable (PiM ?I (λ_. borel))"
      by (rule measurable_component_singleton) (use i in auto)
    show "(λw. ?F w i) ∈ borel_measurable (PiM ?I (λ_. borel))"
      using coord i by (simp add: compose_def)
  next
    show "?F ∈ space (PiM ?I (λ_. borel)) →
      (ΠE i∈?I. space borel)"
      by (auto simp: compose_def PiE_iff split: if_splits)
  qed
  have map_finite: "?F ∈ measurable (gaussian_finite_law ?us)
    (PiM ?I (λ_. borel))"
    using map_meas by (simp only: length_map
      measurable_cong_sets[OF sets_gaussian_finite_law refl])
  have sums_meas: "partial_sums (length ts) ∈
    measurable (increment_law ?us) (PiM ?I (λ_. borel))"
    using measurable_partial_sums[of ?us] by (simp only: length_map)
  have inc_meas: "?F ∈ measurable (increment_law ?us) (increment_law ts)"
    using map_meas by (simp only: length_map
      measurable_cong_sets[OF sets_increment_law sets_increment_law])
  have comm: "partial_sums (length ts) (?F w) =
    ?F (partial_sums (length ts) w)" for w
    by (auto simp: fun_eq_iff partial_sums_def compose_def sum_divide_distrib)
  have "distr (gaussian_finite_law ?us) (PiM ?I (λ_. borel)) ?F =
    distr (increment_law ?us) (PiM ?I (λ_. borel))
      (?F ∘ partial_sums (length ts))"
    unfolding gaussian_finite_law_def
    by (simp only: length_map; rule distr_distr[OF map_meas sums_meas])
  also have "... = distr (increment_law ?us) (PiM ?I (λ_. borel))
    (partial_sums (length ts) ∘ ?F)"
    by (intro distr_cong) (auto simp: comp_def comm)
  also have "... = distr (distr (increment_law ?us) (increment_law ts) ?F)
    (PiM ?I (λ_. borel)) (partial_sums (length ts))"
    by (rule distr_distr[OF measurable_partial_sums inc_meas, symmetric])
  also have "... = gaussian_finite_law ts"
    using increment_law_scale[OF c sorted nonnegative]
    by (simp only: gaussian_finite_law_def)
  finally show ?thesis .
qed

text ‹Single-time deletion consistency for the actual joint laws.
  AFP stochastic-process distributions form a product of marginals, not the
  joint law.›

end