cfahlgren1/math / lean /OAI /Probability /DilutedSpin /FinitePiInjective.lean
cfahlgren1's picture
download
raw
4.18 kB
import OAI.Probability.DilutedSpin.Core
namespace OAI
section
section
namespace DilutedSpinGlass.FiniteLaw
open scoped BigOperators
noncomputable local instance (p : Prop) : Decidable p := Classical.propDecidable p
variable {ι κ : Type*} {α : κ → Type*}
noncomputable def injectionFactor (e : ι → κ) (g : (i : ι) → α (e i) → ℝ)
(j : κ) (x : α j) : ℝ := by
classical
exact if h : ∃ i, e i = j then g (Classical.choose h) ((Classical.choose_spec h).symm ▸ x) else 1
lemma injectionFactor_apply (e : ι → κ) (he : Function.Injective e)
(g : (i : ι) → α (e i) → ℝ) (i : ι) (x : α (e i)) :
injectionFactor e g (e i) x = g i x := by
classical
unfold injectionFactor
have h : ∃ j, e j = e i := ⟨i,rfl⟩
rw [dite_eq_left h]
have ht : ∀ (j : ι) (hj : e j = e i), g j (hj.symm ▸ x) = g i x := by
intro j hj
have hji := he hj
subst j
rfl
exact ht _ (Classical.choose_spec h)
lemma injectionFactor_outside (e : ι → κ) (g : (i : ι) → α (e i) → ℝ)
(j : κ) (h : j ∉ Set.range e) (x : α j) : injectionFactor e g j x = 1 := by
classical
exact dite_eq_right h
variable [Fintype ι] [Fintype κ] [DecidableEq κ] [∀ i, Fintype (α i)]
/-- A finite family of distinct child coordinates has the corresponding
product law, regardless of the unused coordinates in the full old tree. -/
lemma expect_pi_injective_product (P : (j : κ) → FiniteLaw (α j))
(e : ι → κ) (he : Function.Injective e) (g : (i : ι) → α (e i) → ℝ) :
(pi P).expect (fun x => ∏ i, g i (x (e i))) = ∏ i, (P (e i)).expect (g i) := by
have hx (x : (j : κ) → α j) : (∏ i, g i (x (e i))) =
∏ j, injectionFactor e g j (x j) :=
Fintype.prod_of_injective e he _ _ (fun j hj => injectionFactor_outside e g j hj (x j))
(fun i => (injectionFactor_apply e he g i (x (e i))).symm)
rw [(pi P).expect_congr hx,expect_pi_product]
symm
apply Fintype.prod_of_injective e he
· intro j hj
exact ((P j).expect_congr (fun x => injectionFactor_outside e g j hj x)).trans
((P j).expect_const 1)
· intro i
exact (P (e i)).expect_congr (fun x => (injectionFactor_apply e he g i x).symm)
lemma product_point_indicator {β : ι → Type*} (x y : (i : ι) → β i) :
(∏ i, (if x i = y i then (1:ℝ) else 0)) = (if x = y then 1 else 0) := by
classical
by_cases h : x = y
· subst y; simp
· rw [ite_eq_right h]
obtain ⟨i,hi⟩ : ∃ i, x i ≠ y i := by
by_contra hh
exact h (funext (fun i => not_not.mp (not_exists.mp hh i)))
exact Finset.prod_eq_zero (Finset.mem_univ i) (ite_eq_right hi)
lemma finite_indicator_expansion {β : ι → Type*} [∀ i, Fintype (β i)]
(H : ((i : ι) → β i) → ℝ) (x : (i : ι) → β i) :
H x = ∑ y, H y * ∏ i, (if x i = y i then (1:ℝ) else 0) := by
classical
simp_rw [product_point_indicator]
simp
variable [DecidableEq ι]
lemma expect_pi_injective (P : (j : κ) → FiniteLaw (α j))
(e : ι → κ) (he : Function.Injective e) (H : ((i : ι) → α (e i)) → ℝ) :
(pi P).expect (fun x => H (fun i => x (e i))) = (pi (fun i => P (e i))).expect H := by
classical
have hl : (pi P).expect (fun x => H (fun i => x (e i))) =
∑ y, H y * ∏ i, (P (e i)).expect (fun x => if x = y i then (1:ℝ) else 0) := by
rw [(pi P).expect_congr (fun x => finite_indicator_expansion H (fun i => x (e i)))]
simp only [expect_fintype_sum,expect_mul_left]
apply Finset.sum_congr (by ext; simp)
intro y _
exact congrArg (H y * ·) (expect_pi_injective_product P e he
(fun i x => if x = y i then (1:ℝ) else 0))
have hr : (pi (fun i => P (e i))).expect H =
∑ y, H y * ∏ i, (P (e i)).expect (fun x => if x = y i then (1:ℝ) else 0) := by
rw [(pi (fun i => P (e i))).expect_congr (finite_indicator_expansion H)]
simp only [expect_fintype_sum,expect_mul_left]
apply Finset.sum_congr (by ext; simp)
intro y _
exact congrArg (H y * ·) (expect_pi_product (fun i => P (e i))
(fun i x => if x = y i then (1:ℝ) else 0))
exact hl.trans hr.symm
end DilutedSpinGlass.FiniteLaw
end
end
end OAI

Xet Storage Details

Size:
4.18 kB
·
Xet hash:
588303354216dae8806e2d073bb95347cbf0029ebcc52a20daae148bb464a32e

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.