roseking's picture
Add lean source and binary files (part 84)
cdec422 verified
Raw History Blame Contribute Delete
12.9 kB
30
def globalLocalReferenceA (n : ℕ) (s : Fin n → O) : Matrix ι ι ℂ :=
body · 1 line
  eA.reference n (p.extractPrivate true n s,p.publicFrom n s)
33
def globalLocalReferenceB (n : ℕ) (s : Fin n → O) : Matrix η η ℂ :=
body · 1 line
  eB.reference n (p.extractPrivate false n s,p.publicFrom n s)
37
lemma globalLocalReferenceA_measurable [∀ n, IsMarkovKernel (κA n)] (n : ℕ) :
    Measurable (globalLocalReferenceA p κA eA n) :=
proof · 2 lines
  (eA.reference_measurable n).comp
    ((p.measurable_extractPrivate true n).prodMk (p.measurable_publicFrom n))
43
lemma globalLocalReferenceB_measurable [∀ n, IsMarkovKernel (κB n)] (n : ℕ) :
    Measurable (globalLocalReferenceB p κB eB n) :=
proof · 2 lines
  (eB.reference_measurable n).comp
    ((p.measurable_extractPrivate false n).prodMk (p.measurable_publicFrom n))
49
lemma globalLocalReferenceA_mean [∀ n, IsMarkovKernel (κA n)] (n : ℕ) (s : Fin n → O) (i j : ι) :
    (∫ o, globalLocalReferenceA p κA eA (n+1) (Fin.snoc s o) i j
      ∂p.instrumentKernel κA κB n s) = globalLocalReferenceA p κA eA n s i j := by
proof · 15 lines
  unfold globalLocalReferenceA
  simp_rw [p.extractPrivate_snoc, p.publicFrom_snoc]
  unfold LocalOutcomeSampler.instrumentKernel
  cases hrole : p.alice n with
  | true =>
    simp only [↓reduceIte,Kernel.comap_apply]
    exact eA.active_mean n _ i j
  | false =>
    simp only [Bool.false_eq_true,↓reduceIte,Kernel.comap_apply]
    change (∫ o, eA.reference (n+1) (localPassive
      (p.extractPrivate true n s,p.publicFrom n s)
      (p.sendB n ((p.extractPrivate false n s,p.publicFrom n s),o))) i j
      ∂κB n (p.extractPrivate false n s,p.publicFrom n s)) = _
    simp only [eA.passive_reference]
    simp
69
lemma globalLocalReferenceB_mean [∀ n, IsMarkovKernel (κB n)] (n : ℕ) (s : Fin n → O) (i j : η) :
    (∫ o, globalLocalReferenceB p κB eB (n+1) (Fin.snoc s o) i j
      ∂p.instrumentKernel κA κB n s) = globalLocalReferenceB p κB eB n s i j := by
proof · 15 lines
  unfold globalLocalReferenceB
  simp_rw [p.extractPrivate_snoc, p.publicFrom_snoc]
  unfold LocalOutcomeSampler.instrumentKernel
  cases hrole : p.alice n with
  | false =>
    simp only [↓reduceIte]
    exact eB.active_mean n _ i j
  | true =>
    simp only [Bool.true_eq_false,↓reduceIte,Kernel.comap_apply]
    change (∫ o, eB.reference (n+1) (localPassive
      (p.extractPrivate false n s,p.publicFrom n s)
      (p.sendA n ((p.extractPrivate true n s,p.publicFrom n s),o))) i j
      ∂κA n (p.extractPrivate true n s,p.publicFrom n s)) = _
    simp only [eB.passive_reference]
    simp
88
def jointReference (n : ℕ) (s : Fin n → O) : Matrix (ι × η) (ι × η) ℂ :=
body · 1 line
  globalLocalReferenceA p κA eA n s ⊗ₖ globalLocalReferenceB p κB eB n s
92
lemma jointReference_density [∀ n, IsMarkovKernel (κA n)] [∀ n, IsMarkovKernel (κB n)] (n : ℕ) (s : Fin n → O) :
    Density (jointReference p κA κB eA eB n s) := by
proof · 3 lines
  refine ⟨(eA.reference_density n _).1.kronecker (eB.reference_density n _).1,?_⟩
  simp only [jointReference, Matrix.trace_kronecker,globalLocalReferenceA,
    globalLocalReferenceB,(eA.reference_density n _).2,(eB.reference_density n _).2,one_mul]
98
lemma jointReference_measurable (n : ℕ) :
    Measurable (jointReference p κA κB eA eB n) := by
proof · 10 lines
  have hm : Measurable (fun s i j => jointReference p κA κB eA eB n s i j) := by
    apply Measurable.of_eval; intro i
    apply Measurable.of_eval; intro j
    exact (((Matrix.entryLinearMap ℂ ℂ i.1 j.1).toContinuousLinearMap).measurable.comp
      (globalLocalReferenceA_measurable p κA eA n)).mul
      (((Matrix.entryLinearMap ℂ ℂ i.2 j.2).toContinuousLinearMap).measurable.comp
      (globalLocalReferenceB_measurable p κB eB n))
  have hM : Continuous (Matrix.of : ((ι × η) → (ι × η) → ℂ) → Matrix (ι × η) (ι × η) ℂ) :=
    continuous_matrix (fun i j => continuous_apply_apply i j)
  exact hM.measurable.comp hm
112
lemma jointReference_mean [∀ n, IsMarkovKernel (κA n)] [∀ n, IsMarkovKernel (κB n)] (n : ℕ) (s : Fin n → O) (i j : ι × η) :
    (∫ o, jointReference p κA κB eA eB (n+1) (Fin.snoc s o) i j
      ∂p.instrumentKernel κA κB n s) = jointReference p κA κB eA eB n s i j := by
proof · 28 lines
  change (∫ o, globalLocalReferenceA p κA eA (n+1) (Fin.snoc s o) i.1 j.1 *
    globalLocalReferenceB p κB eB (n+1) (Fin.snoc s o) i.2 j.2
    ∂p.instrumentKernel κA κB n s) =
    globalLocalReferenceA p κA eA n s i.1 j.1 * globalLocalReferenceB p κB eB n s i.2 j.2
  simp only [globalLocalReferenceA,globalLocalReferenceB]
  simp_rw [p.extractPrivate_snoc,p.publicFrom_snoc]
  unfold LocalOutcomeSampler.instrumentKernel
  cases hrole : p.alice n with
  | true =>
    simp only [Bool.true_eq_false,↓reduceIte,Kernel.comap_apply]
    change (∫ o, eA.reference (n+1) (localActive
      (p.extractPrivate true n s,p.publicFrom n s) o
      (p.sendA n ((p.extractPrivate true n s,p.publicFrom n s),o))) i.1 j.1 *
      eB.reference (n+1) (localPassive (p.extractPrivate false n s,p.publicFrom n s)
      (p.sendA n ((p.extractPrivate true n s,p.publicFrom n s),o))) i.2 j.2
      ∂κA n (p.extractPrivate true n s,p.publicFrom n s)) = _
    simp_rw [eB.passive_reference]
    rw [integral_mul_const,eA.active_mean]
  | false =>
    simp only [Bool.false_eq_true,↓reduceIte,Kernel.comap_apply]
    change (∫ o, eA.reference (n+1) (localPassive
      (p.extractPrivate true n s,p.publicFrom n s)
      (p.sendB n ((p.extractPrivate false n s,p.publicFrom n s),o))) i.1 j.1 *
      eB.reference (n+1) (localActive (p.extractPrivate false n s,p.publicFrom n s) o
      (p.sendB n ((p.extractPrivate false n s,p.publicFrom n s),o))) i.2 j.2
      ∂κB n (p.extractPrivate false n s,p.publicFrom n s)) = _
    simp_rw [eA.passive_reference]
    rw [integral_const_mul,eB.active_mean]
152
theorem exists_adaptive_instrument_sampler {O : Type v6512_0} {M : Type v6512_1} [MeasurableSpace O]
    [StandardBorelSpace O] [Nonempty O] [MeasurableSpace M]
    (alice : (n : ℕ) → (Fin n → M) → Bool) (hq : ∀ n, Measurable (alice n))
    (κA κB : (n : ℕ) → Kernel ((Fin n → (O ⊕ Unit)) × (Fin n → M)) O)
    [∀ n, IsMarkovKernel (κA n)] [∀ n, IsMarkovKernel (κB n)]
    (sendA sendB : (n : ℕ) → ((Fin n → (O ⊕ Unit)) × (Fin n → M)) × O → M)
    (ha : ∀ n, Measurable (sendA n)) (hb : ∀ n, Measurable (sendB n)) :
    ∃ p : AdaptiveOutcomeSampler O M,
      p.alice = alice ∧ p.sendA = sendA ∧ p.sendB = sendB ∧
      (∀ n s, volume.map (fun u => p.sampleA n (s,u)) = κA n s) ∧
      (∀ n s, volume.map (fun u => p.sampleB n (s,u)) = κB n s) := by
proof · 7 lines
  have hA (n : ℕ) := sample_instrument_kernel (κA n)
  have hB (n : ℕ) := sample_instrument_kernel (κB n)
  choose fA hfA hlawA hrestA using hA
  choose fB hfB hlawB hrestB using hB
  exact ⟨⟨alice,hq,fun n pair => fA n pair.1 pair.2,
    fun n pair => fB n pair.1 pair.2,sendA,sendB,hfA,hfB,ha,hb⟩,
    rfl,rfl,rfl,hlawA,hlawB⟩
185
lemma publicMatrix_positive (W : Ω → Matrix ι ι ℂ)
    (hW : ∀ x, (W x).PosSemidef) (x : Ω) :
    (publicMatrix C μ W x).PosSemidef :=
proof · 1 line
  (integral_nonneg_of_ae (Filter.Eventually.of_forall (fun y => (hW y).nonneg))).posSemidef
204
lemma filter_eq_of_filtration {κ : Type v7524_0} [Fintype κ] [DecidableEq κ]
    (W : PositiveMatrixMeasure Ω ι) (V : PositiveMatrixMeasure Ω κ)
    (K : Matrix κ ι ℂ) (F : Filtration ℕ mΩ) (hm : mΩ = ⨆ n, F n)
    (h : ∀ n S, MeasurableSet[F n] S → V.value S = K * W.value S * Kᴴ) :
    V = W.filter K := by
proof · 4 lines
  apply V.ext_on_filtration (W.filter K) F hm
  intro n S hS
  rw [filter_value]
  exact h n S hS
233
lemma bitReference_total_trace (htrace : trace (S 1) = 1) :
    trace (bitReference J S false) + trace (bitReference J S true) = 1 := by
proof · 1 line
  rw [← Matrix.trace_add, bitReference_sum J S r, htrace]
240
lemma bitReference_filter [DecidableEq ι] {κ : Type v7591_0} [Fintype κ] [DecidableEq κ]
    (K : Matrix κ ι ℂ) (i : Bool) :
    bitReference J (filterFunctional K S) i =
      K * bitReference J S i * Kᴴ := rfl
260
def tensorReferenceFunctional (S : A →ₗ[ℂ] Matrix ι ι ℂ)
    (T : B →ₗ[ℂ] Matrix η η ℂ) :
    (TensorProduct ℂ A B) →ₗ[ℂ] Matrix (ι × η) (ι × η) ℂ :=
body · 1 line
  TensorProduct.lift ((Matrix.kroneckerBilinear (R := ℂ) (α := ℂ)).compl₁₂ S T)
266
lemma tensorReferenceFunctional_apply (S : A →ₗ[ℂ] Matrix ι ι ℂ)
    (T : B →ₗ[ℂ] Matrix η η ℂ) (a : A) (b : B) :
    tensorReferenceFunctional S T (a ⊗ₜ[ℂ] b) = S a ⊗ₖ T b := rfl
270
theorem tensorReferenceFunctional_precompose
    (S : A →ₗ[ℂ] Matrix ι ι ℂ) (T : B →ₗ[ℂ] Matrix η η ℂ)
    (L : A' →ₗ[ℂ] A) (N : B' →ₗ[ℂ] B) :
    (tensorReferenceFunctional S T).comp (TensorProduct.map L N) =
      tensorReferenceFunctional (S.comp L) (T.comp N) := by
proof · 3 lines
  apply TensorProduct.ext'
  intro a b
  simp only [LinearMap.comp_apply, TensorProduct.map_tmul, tensorReferenceFunctional_apply]
279
lemma product_event_reference [One A] [One B] [One A']
    (S : A →ₗ[ℂ] Matrix ι ι ℂ) (T : B →ₗ[ℂ] Matrix η η ℂ)
    (L : A' →ₗ[ℂ] A) :
    ((tensorReferenceFunctional S T).comp
      (TensorProduct.map L (LinearMap.id : B →ₗ[ℂ] B))) (1 ⊗ₜ[ℂ] 1) =
        S (L 1) ⊗ₖ T 1 := by
proof · 2 lines
  simp only [LinearMap.comp_apply, TensorProduct.map_tmul, LinearMap.id_apply,
    tensorReferenceFunctional_apply]