Buckets:
| import OAI.Probability.DilutedSpin.TreeSampling | |
| namespace OAI | |
| section | |
| open MeasureTheory ProbabilityTheory Filter | |
| open scoped BigOperators ENNReal NNReal Topology | |
| DilutedSpinGlass.instMeasurableSpaceCarrier_challenge DilutedSpinGlass.instBorelSpaceCarrier_challenge | |
| namespace DilutedSpinGlass.FiniteLaw | |
| open scoped BigOperators | |
| /-- Fubini at an arbitrary coordinate, retaining dependent finite sample types. -/ | |
| theorem expect_pi_split {ι : Type*} [Fintype ι] [DecidableEq ι] | |
| {α : ι → Type*} [∀ i, Fintype (α i)] (Q : (i : ι) → FiniteLaw (α i)) | |
| (i : ι) (H : ((i : ι) → α i) → ℝ) : | |
| (pi Q).expect H = (Q i).expect (fun a => | |
| (pi (fun j : {j // j ≠ i} => Q j)).expect | |
| (fun rest => H ((Equiv.piSplitAt i α).symm (a,rest)))) := by | |
| classical | |
| have hprod (x : (i : ι) → α i) : | |
| (∏ j, (Q j).weight (x j)) = | |
| (Q i).weight (x i) * ∏ j : {j // j ≠ i}, (Q j).weight (x j) := by | |
| let : Fintype {j : ι // j = i} := Subtype.fintype (fun j => j = i) | |
| have hh := Fintype.prod_subtype_mul_prod_subtype (fun j => j = i) | |
| (fun j => (Q j).weight (x j)) | |
| rw [Fintype.prod_subsingleton _ ⟨i,rfl⟩] at hh | |
| exact hh.symm | |
| simp only [expect, pi] | |
| rw [← (Equiv.piSplitAt i α).symm.sum_comp] | |
| rw [Fintype.sum_prod_type] | |
| apply Finset.sum_congr rfl | |
| intro a _ | |
| rw [Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro rest _ | |
| rw [hprod] | |
| have hh : (∏ j : {j // j ≠ i}, (Q j).weight | |
| ((Equiv.piSplitAt i α).symm (a,rest) j)) = | |
| ∏ j : {j // j ≠ i}, (Q j).weight (rest j) := by | |
| apply Finset.prod_congr rfl | |
| intro j _ | |
| simp only [Equiv.piSplitAt_symm_apply, dite_eq_right j.property] | |
| rw [hh] | |
| simp only [Equiv.piSplitAt_symm_apply, dite_true] | |
| ring | |
| /-- Split off the new first child at a root attachment. -/ | |
| theorem expect_pi_cons {n : ℕ} {α : Fin (n+1) → Type*} [∀ i, Fintype (α i)] | |
| (Q : (i : Fin (n+1)) → FiniteLaw (α i)) (H : ((i : Fin (n+1)) → α i) → ℝ) : | |
| (pi Q).expect H = (Q 0).expect (fun a => | |
| (pi (fun j : Fin n => Q j.succ)).expect (fun rest => H (Fin.cons a rest))) := by | |
| classical | |
| simp only [expect, pi] | |
| rw [← (Fin.consEquiv α).sum_comp, Fintype.sum_prod_type] | |
| apply Finset.sum_congr rfl | |
| intro a _ | |
| rw [Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro rest _ | |
| rw [Fin.prod_univ_succ] | |
| simp only [Fin.consEquiv_apply, Fin.cons_zero, Fin.cons_succ] | |
| ring_nf | |
| rfl | |
| end DilutedSpinGlass.FiniteLaw | |
| namespace DilutedSpinGlass.FiniteLaw | |
| open scoped BigOperators | |
| private noncomputable def delta {α : Type*} (x y : α) : ℝ := by | |
| classical | |
| exact if x = y then 1 else 0 | |
| private theorem delta_pi {ι : Type*} [Fintype ι] {α : ι → Type*} | |
| (x y : (i : ι) → α i) : | |
| (∏ i, delta (x i) (y i)) = delta x y := by | |
| classical | |
| by_cases h : x = y | |
| · subst y | |
| simp [delta] | |
| · have hn : ∃ i, x i ≠ y i := by | |
| by_contra hn | |
| apply h | |
| funext i | |
| exact not_not.mp (not_exists.mp hn i) | |
| obtain ⟨i,hi⟩ := hn | |
| rw [delta, ite_eq_right h] | |
| exact Finset.prod_eq_zero (Finset.mem_univ i) (by simp [delta,hi]) | |
| private theorem expand_pi {ι : Type*} [Fintype ι] [DecidableEq ι] | |
| {α : ι → Type*} [∀ i, Fintype (α i)] (H : ((i : ι) → α i) → ℝ) | |
| (x : (i : ι) → α i) : H x = ∑ y, H y * ∏ i, delta (x i) (y i) := by | |
| classical | |
| simp_rw [delta_pi] | |
| simp [delta] | |
| private theorem expect_pi_expand {ι : Type*} [Fintype ι] [DecidableEq ι] | |
| {α β : ι → Type*} [∀ i, Fintype (α i)] [∀ i, Fintype (β i)] | |
| (P : (i : ι) → FiniteLaw (α i)) (φ : (i : ι) → α i → β i) | |
| (w : (i : ι) → α i → ℝ) (H : ((i : ι) → β i) → ℝ) : | |
| (pi P).expect (fun x => H (fun i => φ i (x i)) * ∏ i, w i (x i)) = | |
| ∑ y, H y * ∏ i, (P i).expect (fun x => w i x * delta (φ i x) (y i)) := by | |
| classical | |
| have heq (x : (i : ι) → α i) : | |
| H (fun i => φ i (x i)) * (∏ i, w i (x i)) = | |
| ∑ y, H y * ∏ i, (w i (x i) * delta (φ i (x i)) (y i)) := by | |
| rw [expand_pi H (fun i => φ i (x i)), Finset.sum_mul] | |
| apply Finset.sum_congr rfl | |
| intro y _ | |
| rw [Finset.prod_mul_distrib] | |
| ring | |
| rw [(pi P).expect_congr heq] | |
| simp only [expect_fintype_sum, expect_mul_left] | |
| apply Finset.sum_congr rfl | |
| intro y _ | |
| rw [expect_pi_product P (fun i x => w i x * delta (φ i x) (y i))] | |
| /-- Tensorization of arbitrary signed one-coordinate changes. This permits | |
| inserting a marked new branch at a single child without assuming the test | |
| factors across the old children. -/ | |
| theorem expect_pi_weighted_map {ι : Type*} [Fintype ι] [DecidableEq ι] | |
| {α β : ι → Type*} [∀ i, Fintype (α i)] [∀ i, Fintype (β i)] | |
| (P : (i : ι) → FiniteLaw (α i)) (Q : (i : ι) → FiniteLaw (β i)) | |
| (φ : (i : ι) → α i → β i) (w : (i : ι) → α i → ℝ) (v : (i : ι) → β i → ℝ) | |
| (h : ∀ i (g : β i → ℝ), (P i).expect (fun x => w i x * g (φ i x)) = | |
| (Q i).expect (fun y => v i y * g y)) (H : ((i : ι) → β i) → ℝ) : | |
| (pi P).expect (fun x => H (fun i => φ i (x i)) * ∏ i, w i (x i)) = | |
| (pi Q).expect (fun y => H y * ∏ i, v i (y i)) := by | |
| rw [expect_pi_expand P φ w H, expect_pi_expand Q (fun _ y => y) v H] | |
| apply Finset.sum_congr rfl | |
| intro y _ | |
| congr 1 | |
| apply Finset.prod_congr rfl | |
| intro i _ | |
| exact h i (fun x => delta x (y i)) | |
| end DilutedSpinGlass.FiniteLaw | |
| namespace DilutedSpinGlass.FiniteLaw | |
| theorem expect_pi_marginal {ι : Type*} [Fintype ι] [DecidableEq ι] | |
| {α : ι → Type*} [∀ i, Fintype (α i)] (P : (i : ι) → FiniteLaw (α i)) | |
| (i : ι) (f : α i → ℝ) : (pi P).expect (fun x => f (x i)) = (P i).expect f := by | |
| erw [expect_pi_split P i] | |
| simp! only [Equiv.piSplitAt_symm_apply, dite_true, expect_const] | |
| end DilutedSpinGlass.FiniteLaw | |
| end | |
| end OAI | |
Xet Storage Details
- Size:
- 5.86 kB
- Xet hash:
- c1fc9be790defb467c37fde8ca615a2994debe2cee8c20af92ab9a06d5663486
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.