Theory Brownian_Motion

theory Brownian_Motion
  imports Gaussian_Process
begin

section ‹Brownian motion›

text ‹A Brownian motion is a real-valued process on nonnegative time, starting
  at zero almost surely, with jointly independent centred normal increments
  and almost surely continuous paths.›

locale brownian_motion =
  fixes W :: "(real, 'a, real) stochastic_process"
  assumes index: "proc_index W = {0..}"
    and init_0: "AE w in proc_source W. process W 0 w = 0"
    and indep_increments: "indep_increments W"
    and normal_increments: "⋀s t. 0 ≤ s ⟹ s ≤ t ⟹
      distr (proc_source W) borel
        (λw. process W t w - process W s w) = centered_normal (t - s)"
    and AE_continuous: "AE w in proc_source W.
      continuous_on {0..} (λt. process W t w)"

text ‹The existence argument starts from the canonical Gaussian process.
  Its fourth increment moment has quadratic order in the time difference,
  which is the estimate needed for Kolmogorov--Chentsov.›

lemma gaussian_process_fourth_increment_moment_ordered:
  assumes s: "0 ≤ s" and st: "s ≤ t"
  shows "(∫+ w. ennreal (dist (process gaussian_process t w)
    (process gaussian_process s w) ^ 4) ∂proc_source gaussian_process) =
    ennreal (3 * (dist t s)^2)"
proof -
  have meas: "(λw. process gaussian_process t w -
    process gaussian_process s w) ∈ borel_measurable (proc_source gaussian_process)"
    using stochastic_process_measurable[of gaussian_process t]
      stochastic_process_measurable[of gaussian_process s]
    by (simp add: gaussian_process_target)
  have law: "distr (proc_source gaussian_process) borel
    (λw. process gaussian_process t w - process gaussian_process s w) =
    centered_normal (t - s)"
    by (rule gaussian_process_increment_law[OF s st])
  have f_base: "(λx :: real. ennreal (x^4)) ∈ borel_measurable borel"
    by measurable
  have f_meas: "(λx :: real. ennreal (x^4)) ∈
    borel_measurable (centered_normal (t - s))"
    using f_base
    by (simp only: measurable_cong_sets[OF sets_centered_normal refl])
  have f_meas_distr: "(λx :: real. ennreal (x^4)) ∈
    borel_measurable (distr (proc_source gaussian_process) borel
      (λw. process gaussian_process t w - process gaussian_process s w))"
    using f_meas by (simp only: law)
  have "(∫+ w. ennreal ((process gaussian_process t w -
      process gaussian_process s w)^4) ∂proc_source gaussian_process) =
    (∫+ x. ennreal (x^4) ∂centered_normal (t - s))"
    using nn_integral_distr[OF meas f_meas_distr] by (simp only: law)
  also have "... = ennreal (3 * (t - s)^2)"
    by (rule centered_normal_fourth_nn_integral) (use st in simp)
  finally show ?thesis using st
    by (simp add: dist_real_def power_even_abs)
qed

lemma gaussian_process_fourth_increment_moment:
  assumes s: "0 ≤ s" and t: "0 ≤ t"
  shows "(∫+ w. ennreal (dist (process gaussian_process t w)
    (process gaussian_process s w) ^ 4) ∂proc_source gaussian_process) =
    ennreal (3 * (dist t s)^2)"
proof (cases "s ≤ t")
  case True
  then show ?thesis by (rule gaussian_process_fourth_increment_moment_ordered[OF s])
next
  case False
  then have st: "t ≤ s" by simp
  have "(∫+ w. ennreal (dist (process gaussian_process t w)
      (process gaussian_process s w) ^ 4) ∂proc_source gaussian_process) =
    (∫+ w. ennreal (dist (process gaussian_process s w)
      (process gaussian_process t w) ^ 4) ∂proc_source gaussian_process)"
    by (simp add: dist_commute)
  also have "... = ennreal (3 * (dist s t)^2)"
    by (rule gaussian_process_fourth_increment_moment_ordered[OF t st])
  finally show ?thesis by (simp add: dist_commute)
qed

lemma gaussian_process_KC_bound:
  assumes "0 ≤ s" "0 ≤ t"
  shows "(∫+ w. dist (process gaussian_process t w)
    (process gaussian_process s w) powr 4 ∂proc_source gaussian_process) ≤
    3 * dist t s powr 2"
  using gaussian_process_fourth_increment_moment[OF assms]
  by (simp add: powr_realpow)

text ‹The fourth-moment estimate verifies the Kolmogorov--Chentsov
  hypotheses and therefore yields a modification whose paths are locally
  Holder continuous for every exponent below one quarter.›

lemma gaussian_process_Kolmogorov_Chentsov:
  assumes "0 < γ" "γ < 1 / 4"
  shows "Kolmogorov_Chentsov gaussian_process 4 1 3 γ"
proof (unfold_locales)
  fix s t :: real
  assume "0 ≤ s" "0 ≤ t"
  then show "(∫+ w. dist (process gaussian_process t w)
      (process gaussian_process s w) powr 4 ∂proc_source gaussian_process) ≤
    3 * dist t s powr (1 + 1)"
    using gaussian_process_KC_bound[OF ‹0 ≤ s› ‹0 ≤ t›] by simp
qed (use assms in ‹auto simp: gaussian_process_index gaussian_process_target›)

theorem gaussian_process_continuous_modification:
  assumes "0 < γ" "γ < 1 / 4"
  shows "∃B. modification gaussian_process B ∧
    (∀w. local_holder_on γ {0..} (λt. process B t w))"
  using Kolmogorov_Chentsov.continuous_modification
    [OF gaussian_process_Kolmogorov_Chentsov[OF assms]] .

text ‹Modification preserves the finite-dimensional laws.  In particular,
  the continuous version retains independent Gaussian increments and starts
  at zero almost surely, so it has all the Brownian motion properties.›

theorem brownian_continuous_modification:
  assumes gamma: "0 < γ" "γ < 1 / 4"
  shows "∃B. modification gaussian_process B ∧
    (∀w. local_holder_on γ {0..} (λt. process B t w)) ∧
    indep_increments B ∧
    (AE w in proc_source B. process B 0 w = 0) ∧
    (∀s t. 0 ≤ s ∧ s ≤ t ⟶
      distr (proc_source B) borel
        (λw. process B t w - process B s w) = centered_normal (t - s))"
proof -
  obtain B where mod: "modification gaussian_process B"
    and holder: "∀w. local_holder_on γ {0..} (λt. process B t w)"
    using gaussian_process_continuous_modification[OF gamma] by blast
  have compat: "compatible gaussian_process B" by (rule modificationD(1)[OF mod])
  have source: "proc_source B = proc_source gaussian_process"
    using compatible_source[OF compat] by simp
  have target: "sets (proc_target B) = sets borel"
    using compatible_target[OF compat] by (simp add: gaussian_process_target)
  have indep: "indep_increments B"
    using modification_indep_increments[OF mod target] gaussian_process_indep_increments
    by blast
  have zero: "AE w in proc_source B. process B 0 w = 0"
  proof -
    have ae: "AE w in proc_source gaussian_process.
      process gaussian_process 0 w = process B 0 w"
      by (rule modificationD(2)[OF mod]) (simp add: gaussian_process_index)
    show ?thesis using ae gaussian_process_starts_at_zero
      by (simp only: source) auto
  qed
  have inc: "distr (proc_source B) borel
      (λw. process B t w - process B s w) = centered_normal (t - s)"
    if s: "0 ≤ s" and st: "s ≤ t" for s t
  proof -
    have s_index: "s ∈ proc_index gaussian_process"
      using s by (simp add: gaussian_process_index)
    have t_index: "t ∈ proc_index gaussian_process"
      using s st by (simp add: gaussian_process_index)
    have ae_s: "AE w in proc_source gaussian_process.
      process gaussian_process s w = process B s w"
      by (rule modificationD(2)[OF mod s_index])
    have ae_t: "AE w in proc_source gaussian_process.
      process gaussian_process t w = process B t w"
      by (rule modificationD(2)[OF mod t_index])
    have ae: "AE w in proc_source gaussian_process.
      process B t w - process B s w =
        process gaussian_process t w - process gaussian_process s w"
      using ae_s ae_t by eventually_elim simp
    have rv_gauss: "(λw. process gaussian_process t w -
      process gaussian_process s w) ∈ borel_measurable (proc_source gaussian_process)"
      using stochastic_process_measurable[of gaussian_process t]
        stochastic_process_measurable[of gaussian_process s]
      by (simp add: gaussian_process_target)
    have B_t: "process B t ∈ borel_measurable (proc_source B)"
      using stochastic_process_measurable[of B t]
      by (simp only: measurable_cong_sets[OF refl target])
    have B_s: "process B s ∈ borel_measurable (proc_source B)"
      using stochastic_process_measurable[of B s]
      by (simp only: measurable_cong_sets[OF refl target])
    have rv_B: "(λw. process B t w - process B s w) ∈
      borel_measurable (proc_source B)"
      using B_t B_s by simp
    have "distr (proc_source B) borel
      (λw. process B t w - process B s w) =
      distr (proc_source gaussian_process) borel
        (λw. process gaussian_process t w - process gaussian_process s w)"
      by (rule distr_cong_AE[OF source refl _ rv_B rv_gauss])
         (use ae in ‹simp only: source›)
    also have "... = centered_normal (t - s)"
      by (rule gaussian_process_increment_law[OF s st])
    finally show ?thesis .
  qed
  show ?thesis using mod holder indep zero inc by blast
qed

text ‹We now choose one such modification (with the concrete Holder exponent
  one eighth) and give it a permanent name.  The subsequent interpretation
  packages the transferred properties and path continuity into the
  @{locale brownian_motion} locale.›

definition brownian_process :: "(real, real ⇒ real, real) stochastic_process" where
  "brownian_process = (SOME B. modification gaussian_process B ∧
    (∀w. local_holder_on (1/8) {0..} (λt. process B t w)) ∧
    indep_increments B ∧
    (AE w in proc_source B. process B 0 w = 0) ∧
    (∀s t. 0 ≤ s ∧ s ≤ t ⟶
      distr (proc_source B) borel
        (λw. process B t w - process B s w) = centered_normal (t - s)))"

lemma brownian_process_properties:
  "modification gaussian_process brownian_process ∧
    (∀w. local_holder_on (1/8) {0..} (λt. process brownian_process t w)) ∧
    indep_increments brownian_process ∧
    (AE w in proc_source brownian_process. process brownian_process 0 w = 0) ∧
    (∀s t. 0 ≤ s ∧ s ≤ t ⟶
      distr (proc_source brownian_process) borel
        (λw. process brownian_process t w - process brownian_process s w) =
      centered_normal (t - s))"
proof -
  have existence: "∃B :: (real, real ⇒ real, real) stochastic_process.
    modification gaussian_process B ∧
    (∀w. local_holder_on (1/8) {0..} (λt. process B t w)) ∧
    indep_increments B ∧
    (AE w in proc_source B. process B 0 w = 0) ∧
    (∀s t. 0 ≤ s ∧ s ≤ t ⟶
      distr (proc_source B) borel
        (λw. process B t w - process B s w) = centered_normal (t - s))"
    using brownian_continuous_modification[of "1/8"] by simp
  show ?thesis unfolding brownian_process_def by (rule someI_ex[OF existence])
qed

lemma brownian_process_modification:
  "modification gaussian_process brownian_process"
  using brownian_process_properties by blast

lemma brownian_process_local_holder:
  "local_holder_on (1/8) {0..} (λt. process brownian_process t w)"
  using brownian_process_properties by blast

lemma brownian_process_indep_increments:
  "indep_increments brownian_process"
  using brownian_process_properties by blast

lemma brownian_process_starts_at_zero:
  "AE w in proc_source brownian_process. process brownian_process 0 w = 0"
  using brownian_process_properties by blast

lemma brownian_process_increment_law:
  assumes "0 ≤ s" "s ≤ t"
  shows "distr (proc_source brownian_process) borel
    (λw. process brownian_process t w - process brownian_process s w) =
    centered_normal (t - s)"
  using brownian_process_properties assms by blast

interpretation constructed_brownian_motion: brownian_motion brownian_process
proof
  show "proc_index brownian_process = {0..}"
    using brownian_process_modification
    by (metis compatible_index gaussian_process_index modificationD(1))
  show "AE w in proc_source brownian_process. process brownian_process 0 w = 0"
    by (rule brownian_process_starts_at_zero)
  show "indep_increments brownian_process"
    by (rule brownian_process_indep_increments)
  show "distr (proc_source brownian_process) borel
    (λw. process brownian_process t w - process brownian_process s w) =
    centered_normal (t - s)" if "0 ≤ s" "s ≤ t" for s t
    by (rule brownian_process_increment_law[OF that(1) that(2)])
  show "AE w in proc_source brownian_process.
    continuous_on {0..} (λt. process brownian_process t w)"
    using brownian_process_local_holder local_holder_imp_continuous by blast
qed

lemma modification_gaussian_joint_law:
  assumes mod: "modification gaussian_process B"
    and finite: "finite T" and subset: "T ⊆ {0..}"
  shows "distr (proc_source B) (PiM T (λ_. borel))
    (λw. λt∈T. process B t w) = gaussian_set_law T"
proof -
  have compat: "compatible gaussian_process B"
    by (rule modificationD(1)[OF mod])
  have source: "proc_source B = proc_source gaussian_process"
    using compatible_source[OF compat] by simp
  have target: "sets (proc_target B) = sets borel"
    using compatible_target[OF compat] by (simp add: gaussian_process_target)
  have measurable_coords: "(λw. λt∈T. process X t w) ∈
    measurable (proc_source X) (PiM T (λ_. borel))"
    if target_X: "sets (proc_target X) = sets borel"
    for X :: "(real, real ⇒ real, real) stochastic_process"
  proof (rule measurable_PiM_single')
    fix t assume t: "t ∈ T"
    have coord: "process X t ∈ borel_measurable (proc_source X)"
      using stochastic_process_measurable[of X t]
      by (simp only: measurable_cong_sets[OF refl target_X])
    show "(λw. (λt∈T. process X t w) t) ∈
      borel_measurable (proc_source X)"
      using coord t by simp
  next
    show "(λw. λt∈T. process X t w) ∈
      space (proc_source X) → (ΠE t∈T. space borel)"
      by (auto simp: PiE_iff split: if_splits)
  qed
  have rv_B: "(λw. λt∈T. process B t w) ∈
    measurable (proc_source B) (PiM T (λ_. borel))"
    by (rule measurable_coords[OF target])
  have rv_gauss: "(λw. λt∈T. process gaussian_process t w) ∈
    measurable (proc_source gaussian_process) (PiM T (λ_. borel))"
    by (rule measurable_coords) (simp add: gaussian_process_target)
  have ae_coords: "AE w in proc_source gaussian_process.
    ∀t∈T. process B t w = process gaussian_process t w"
  proof (rule AE_finite_allI[OF finite])
    fix t assume "t ∈ T"
    then have "t ∈ proc_index gaussian_process"
      using subset by (auto simp: gaussian_process_index)
    then have eq: "AE w in proc_source gaussian_process.
      process gaussian_process t w = process B t w"
      by (rule modificationD(2)[OF mod])
    show "AE w in proc_source gaussian_process.
      process B t w = process gaussian_process t w"
      using eq by eventually_elim simp
  qed
  have ae_maps: "AE w in proc_source gaussian_process.
    (λt∈T. process B t w) =
    (λt∈T. process gaussian_process t w)"
    using ae_coords by eventually_elim (auto simp: fun_eq_iff)
  have "distr (proc_source B) (PiM T (λ_. borel))
      (λw. λt∈T. process B t w) =
    distr (proc_source gaussian_process) (PiM T (λ_. borel))
      (λw. λt∈T. process gaussian_process t w)"
    by (rule distr_cong_AE[OF source refl _ rv_B rv_gauss])
       (use ae_maps in ‹simp only: source›)
  also have "... = gaussian_set_law T"
    using gaussian_process_joint_law[OF finite subset]
    by (simp only: gaussian_process_target)
  finally show ?thesis .
qed

lemma brownian_process_joint_law:
  assumes "finite T" "T ⊆ {0..}"
  shows "distr (proc_source brownian_process) (PiM T (λ_. borel))
    (λw. λt∈T. process brownian_process t w) = gaussian_set_law T"
  by (rule modification_gaussian_joint_law[OF brownian_process_modification assms])

lemma brownian_process_ordered_list_joint:
  assumes sorted: "sorted ts" and distinct: "distinct ts"
    and nonnegative: "∀t∈set ts. 0 ≤ t"
  shows "distr (proc_source brownian_process)
    (PiM {..<length ts} (λ_. borel))
    (λw. λi∈{..<length ts}. process brownian_process (ts ! i) w) =
    gaussian_finite_law ts"
proof -
  let ?I = "{..<length ts}"
  let ?F = "λw. λi∈?I. process brownian_process (ts ! i) w"
  let ?G = "λw. λi∈?I. process gaussian_process (ts ! i) w"
  have mod: "modification gaussian_process brownian_process"
    by (rule brownian_process_modification)
  have source: "proc_source brownian_process = proc_source gaussian_process"
    using compatible_source[OF modificationD(1)[OF mod]] by simp
  have target: "sets (proc_target brownian_process) = sets borel"
    using compatible_target[OF modificationD(1)[OF mod]]
    by (simp add: gaussian_process_target)
  have rv: "?F ∈ measurable (proc_source brownian_process)
    (PiM ?I (λ_. borel))"
  proof (rule measurable_PiM_single')
    fix i assume i: "i ∈ ?I"
    have coord: "process brownian_process (ts ! i) ∈
      borel_measurable (proc_source brownian_process)"
      using stochastic_process_measurable[of brownian_process "ts ! i"]
      by (simp only: measurable_cong_sets[OF refl target])
    show "(λw. ?F w i) ∈ borel_measurable (proc_source brownian_process)"
      using coord i by simp
  next
    show "?F ∈ space (proc_source brownian_process) →
      (ΠE i∈?I. space borel)"
      by (auto simp: PiE_iff split: if_splits)
  qed
  have rv_gauss: "?G ∈ measurable (proc_source gaussian_process)
    (PiM ?I (λ_. borel))"
    by (rule measurable_gaussian_process_ordered_coordinates)
  have ae_coords: "AE w in proc_source gaussian_process.
    ∀i∈?I. process brownian_process (ts ! i) w =
      process gaussian_process (ts ! i) w"
  proof (rule AE_finite_allI)
    fix i assume i: "i ∈ ?I"
    have t: "ts ! i ∈ proc_index gaussian_process"
      using nonnegative i by (auto simp: gaussian_process_index)
    have "AE w in proc_source gaussian_process.
      process gaussian_process (ts ! i) w = process brownian_process (ts ! i) w"
      by (rule modificationD(2)[OF mod t])
    then show "AE w in proc_source gaussian_process.
      process brownian_process (ts ! i) w = process gaussian_process (ts ! i) w"
      by eventually_elim simp
  qed simp
  have ae: "AE w in proc_source gaussian_process. ?F w = ?G w"
    using ae_coords by eventually_elim (auto simp: fun_eq_iff)
  have "distr (proc_source brownian_process) (PiM ?I (λ_. borel)) ?F =
    distr (proc_source gaussian_process) (PiM ?I (λ_. borel)) ?G"
    by (rule distr_cong_AE[OF source refl _ rv rv_gauss])
       (use ae in ‹simp only: source›)
  also have "... = gaussian_finite_law ts"
    by (rule gaussian_process_ordered_list_joint[OF sorted distinct nonnegative])
  finally show ?thesis .
qed

lemma brownian_process_ordered_list_scale:
  assumes c: "0 < c" and sorted: "sorted ts" and distinct: "distinct ts"
    and nonnegative: "∀t∈set ts. 0 ≤ t"
  shows "distr (proc_source brownian_process)
    (PiM {..<length ts} (λ_. borel))
    (λw. λi∈{..<length ts}.
      process brownian_process (c * (ts ! i)) w / sqrt c) =
    gaussian_finite_law ts"
proof -
  let ?I = "{..<length ts}"
  let ?us = "map (λt. c * t) ts"
  let ?F = "compose ?I (λx. x / sqrt c)"
  let ?G = "λw. λi∈?I. process brownian_process (?us ! i) w"
  have sorted_us: "sorted ?us"
    using sorted c by (simp add: sorted_map sorted_wrt_iff_nth_less
      sorted_iff_nth_mono_less mult_left_mono)
  have distinct_us: "distinct ?us"
    using distinct c by (simp add: distinct_map inj_on_def)
  have nonnegative_us: "∀t∈set ?us. 0 ≤ t"
    using nonnegative c by auto
  have target: "sets (proc_target brownian_process) = sets borel"
    using compatible_target[OF modificationD(1)[OF brownian_process_modification]]
    by (simp add: gaussian_process_target)
  have G_meas: "?G ∈ measurable (proc_source brownian_process)
    (PiM ?I (λ_. borel))"
  proof (rule measurable_PiM_single')
    fix i assume i: "i ∈ ?I"
    have coord: "process brownian_process (?us ! i) ∈
      borel_measurable (proc_source brownian_process)"
      using stochastic_process_measurable[of brownian_process "?us ! i"]
      by (simp only: measurable_cong_sets[OF refl target])
    show "(λw. ?G w i) ∈ borel_measurable (proc_source brownian_process)"
      using coord i by simp
  next
    show "?G ∈ space (proc_source brownian_process) →
      (ΠE i∈?I. space borel)"
      by (auto simp: PiE_iff split: if_splits)
  qed
  have F_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 mapping: "(λw. λi∈?I.
      process brownian_process (c * (ts ! i)) w / sqrt c) = ?F ∘ ?G"
    by (auto simp: fun_eq_iff compose_def)
  have "distr (proc_source brownian_process) (PiM ?I (λ_. borel))
      (?F ∘ ?G) =
    distr (distr (proc_source brownian_process) (PiM ?I (λ_. borel)) ?G)
      (PiM ?I (λ_. borel)) ?F"
    by (rule distr_distr[OF F_meas G_meas, symmetric])
  also have "... = gaussian_finite_law ts"
    using brownian_process_ordered_list_joint[OF sorted_us distinct_us nonnegative_us]
      gaussian_finite_law_scale[OF c sorted nonnegative]
    by simp
  finally show ?thesis using mapping by simp
qed

theorem brownian_process_finite_scale_invariance:
  assumes c: "0 < c" and finite: "finite T" and subset: "T ⊆ {0..}"
  shows "distr (proc_source brownian_process) (PiM T (λ_. borel))
    (λw. λt∈T. process brownian_process (c * t) w / sqrt c) =
    gaussian_set_law T"
proof -
  let ?ts = "ordered_times T"
  let ?I = "{..<length ?ts}"
  let ?F = "λw. λi∈?I.
    process brownian_process (c * (?ts ! i)) w / sqrt c"
  let ?H = "λw. λt∈T.
    process brownian_process (c * t) w / sqrt c"
  have sorted: "sorted ?ts" and distinct: "distinct ?ts"
    and times: "set ?ts = T"
    using ordered_times_finite[OF finite] by auto
  have nonnegative: "∀t∈set ?ts. 0 ≤ t"
    using times subset by auto
  have target: "sets (proc_target brownian_process) = sets borel"
    using compatible_target[OF modificationD(1)[OF brownian_process_modification]]
    by (simp add: gaussian_process_target)
  have F_meas: "?F ∈ measurable (proc_source brownian_process)
    (PiM ?I (λ_. borel))"
  proof (rule measurable_PiM_single')
    fix i assume i: "i ∈ ?I"
    have coord: "process brownian_process (c * (?ts ! i)) ∈
      borel_measurable (proc_source brownian_process)"
      using stochastic_process_measurable[of brownian_process "c * (?ts ! i)"]
      by (simp only: measurable_cong_sets[OF refl target])
    show "(λw. ?F w i) ∈ borel_measurable (proc_source brownian_process)"
      using coord i by simp
  next
    show "?F ∈ space (proc_source brownian_process) →
      (ΠE i∈?I. space borel)"
      by (auto simp: PiE_iff split: if_splits)
  qed
  have set_meas: "set_coordinates T ∈ measurable
    (PiM ?I (λ_. borel)) (PiM T (λ_. borel))"
    by (rule measurable_set_coordinates[OF finite])
  have mapping: "?H = set_coordinates T ∘ ?F"
    using time_index_unique[OF finite] by (auto simp: fun_eq_iff set_coordinates_def)
  have "distr (proc_source brownian_process) (PiM T (λ_. borel)) ?H =
    distr (distr (proc_source brownian_process) (PiM ?I (λ_. borel)) ?F)
      (PiM T (λ_. borel)) (set_coordinates T)"
    by (simp only: mapping distr_distr[OF set_meas F_meas, symmetric])
  also have "... = gaussian_set_law T"
    using brownian_process_ordered_list_scale[OF c sorted distinct nonnegative]
    by (simp only: gaussian_set_law_def)
  finally show ?thesis .
qed

theorem brownian_process_scale_invariance:
  assumes "0 < c" "finite T" "T ⊆ {0..}"
  shows "distr (proc_source brownian_process) (PiM T (λ_. borel))
    (λw. λt∈T. process brownian_process (c * t) w / sqrt c) =
    distr (proc_source brownian_process) (PiM T (λ_. borel))
      (λw. λt∈T. process brownian_process t w)"
  using brownian_process_finite_scale_invariance[OF assms]
    brownian_process_joint_law[OF assms(2,3)] by simp

theorem brownian_process_path_scale_invariance:
  assumes c: "0 < c"
  shows "distr (proc_source brownian_process)
    (PiM {0..} (λ_. borel :: real measure))
    (λw. λt∈{0..}. process brownian_process (c * t) w / sqrt c) =
    gaussian_path_law"
proof -
  let ?I = "{0..} :: real set"
  let ?B = "λ_. borel :: real measure"
  let ?F = "λw. λt∈?I. process brownian_process (c * t) w / sqrt c"
  let ?P = "distr (proc_source brownian_process) (PiM ?I ?B) ?F"
  have target: "sets (proc_target brownian_process) = sets borel"
    using compatible_target[OF modificationD(1)[OF brownian_process_modification]]
    by (simp add: gaussian_process_target)
  have meas_F: "?F ∈ measurable (proc_source brownian_process) (PiM ?I ?B)"
  proof (rule measurable_PiM_single')
    fix t assume t: "t ∈ ?I"
    have coord: "process brownian_process (c * t) ∈
      borel_measurable (proc_source brownian_process)"
      using stochastic_process_measurable[of brownian_process "c * t"]
      by (simp only: measurable_cong_sets[OF refl target])
    show "(λw. ?F w t) ∈ borel_measurable (proc_source brownian_process)"
      using coord t by simp
  next
    show "?F ∈ space (proc_source brownian_process) →
      (ΠE t∈?I. space borel)"
      by (auto simp: PiE_iff split: if_splits)
  qed
  have prob_source: "prob_space (proc_source brownian_process)"
    using compatible_source[OF modificationD(1)[OF brownian_process_modification]]
      prob_space_gaussian_path_law by (simp add: gaussian_process_source)
  have fin_P: "finite_measure ?P"
    using prob_space.prob_space_distr[OF prob_source meas_F]
    by (simp add: prob_space_def)
  have sets_P: "sets ?P = sets (PiM ?I ?B)" by simp
  have sets_Q: "sets gaussian_path_law = sets (PiM ?I ?B)"
    by (rule sets_gaussian_path_law)
  have space_Q: "space gaussian_path_law = space (PiM ?I ?B)"
    by (rule sets_eq_imp_space_eq[OF sets_Q])
  show ?thesis
  proof (rule measure_eqI_PiM_infinite[OF sets_P sets_Q _ fin_P])
    fix A J
    assume finite: "finite J" and subset: "J ⊆ ?I"
      and events: "⋀t. t ∈ J ⟹ A t ∈ sets (?B t)"
    have restr_meas: "(λf. restrict f J) ∈
      measurable (PiM ?I ?B) (PiM J ?B)"
      by (rule measurable_restrict_subset[OF subset])
    have restr_P: "(λf. restrict f J) ∈ measurable ?P (PiM J ?B)"
      using restr_meas by (simp only: measurable_cong_sets[OF sets_P refl])
    have restr_Q: "(λf. restrict f J) ∈
      measurable gaussian_path_law (PiM J ?B)"
      using restr_meas by (simp only: measurable_cong_sets[OF sets_Q refl])
    have event: "PiE J A ∈ sets (PiM J ?B)"
      by (rule sets_PiM_I_finite[OF finite]) (use events in auto)
    have comp: "(λf. restrict f J) ∘ ?F =
      (λw. λt∈J. process brownian_process (c * t) w / sqrt c)"
      using subset by (auto simp: fun_eq_iff restrict_def)
    have law_P: "distr ?P (PiM J ?B) (λf. restrict f J) = gaussian_set_law J"
    proof -
      have "distr ?P (PiM J ?B) (λf. restrict f J) =
        distr (proc_source brownian_process) (PiM J ?B)
          ((λf. restrict f J) ∘ ?F)"
        by (rule distr_distr[OF restr_meas meas_F])
      also have "... = gaussian_set_law J"
        using brownian_process_finite_scale_invariance[OF c finite subset]
        by (simp only: comp)
      finally show ?thesis .
    qed
    have law_Q: "distr gaussian_path_law (PiM J ?B)
      (λf. restrict f J) = gaussian_set_law J"
      by (rule gaussian_limit_marginal[OF finite subset])
    have emb_P: "prod_emb ?I ?B J (PiE J A) =
      (λf. restrict f J) -` (PiE J A) ∩ space ?P"
      by (simp add: prod_emb_def space_PiM)
    have emb_Q: "prod_emb ?I ?B J (PiE J A) =
      (λf. restrict f J) -` (PiE J A) ∩ space gaussian_path_law"
      by (simp add: prod_emb_def space_PiM space_Q)
    show "emeasure ?P (prod_emb ?I ?B J (PiE J A)) =
      emeasure gaussian_path_law (prod_emb ?I ?B J (PiE J A))"
      using emeasure_distr[OF restr_P event] emeasure_distr[OF restr_Q event]
        law_P law_Q emb_P emb_Q by simp
  qed
qed

corollary brownian_process_full_scale_invariance:
  assumes "0 < c"
  shows "distr (proc_source brownian_process)
    (PiM {0..} (λ_. borel :: real measure))
    (λw. λt∈{0..}. process brownian_process (c * t) w / sqrt c) =
    distr (proc_source brownian_process)
      (PiM {0..} (λ_. borel :: real measure))
      (λw. λt∈{0..}. process brownian_process t w)"
  using brownian_process_path_scale_invariance[OF assms]
    brownian_process_path_scale_invariance[of 1] by simp

text ‹The named process has Gaussian joint laws, independent normal
  increments, locally Holder-continuous paths, and Brownian scale invariance
  as an equality of full path-space distributions.›

end