Download data/lean/OAI/Probability/CriticalPercolation/Exploration/Node.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.49 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/Exploration/Node.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/CriticalPercolation/Exploration/Node.lean
-
curl -L -o Node.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/Exploration/Node.lean
5.49 kB
| import Mathlib | |
| import OAI.Probability.CriticalPercolation.Exploration.BitWeight | |
| namespace OAI | |
| section | |
| section | |
| open Set MeasureTheory ProbabilityTheory | |
| open scoped Classical | |
| open Real | |
| open Set Real | |
| open scoped Topology | |
| open scoped BigOperators | |
| open Set | |
| namespace CriticalPercolation.QueryTree | |
| open FiniteProduct FiniteEntropy | |
| variable {E : Type*} [Fintype E] | |
| omit [Fintype E] in | |
| lemma bitWeight_pos {p : β} (hp : p β Set.Ioo 0 1) (e : E) (b : Bool) : | |
| 0 < bitWeight p e b := by | |
| cases b <;> simp [bitWeight, hp.1, hp.2] | |
| theorem transcript_divergence_le {p : β} (hp : p β Set.Ioo 0 1) | |
| (t : QueryTree E) (hv : t.Valid β ) (P : (E β Bool) β β) (hP : β Ο, 0 β€ P Ο) : | |
| divergence (pushMass t.run P) (t.reference p) β€ divergence P (density (bitWeight p)) := by | |
| rw [β reference_eq_product_push p t β hv] | |
| exact divergence_pushMass_le t.run P _ hP | |
| (density_nonneg (bitWeight_nonneg β¨hp.1.le, hp.2.leβ©)) | |
| (fun Ο _ => Finset.prod_pos fun e _ => bitWeight_pos hp e (Ο e)) | |
| theorem quadratic_bias_budget {p : β} (hp : p β Set.Ioo 0 1) | |
| (t : QueryTree E) (hv : t.Valid β ) (P : (E β Bool) β β) | |
| (hP : β Ο, 0 β€ P Ο) (hMass : β Ο, P Ο = 1) : | |
| 2*t.charge (fun r => (r-p)^2) (pushMass t.run P) β€ | |
| divergence P (density (bitWeight p)) := by | |
| exact (divergence_reference_bounds hp t _ (pushMass_nonneg t.run P hP) | |
| (by rw [pushMass_sum, hMass])).1.trans (transcript_divergence_le hp t hv P hP) | |
| theorem transcript_divergence_upper {p : β} (hp : p β Set.Ioo 0 1) | |
| (t : QueryTree E) (P : (E β Bool) β β) | |
| (hP : β Ο, 0 β€ P Ο) (hMass : β Ο, P Ο = 1) : | |
| divergence (pushMass t.run P) (t.reference p) β€ | |
| (p*(1-p))β»ΒΉ*t.charge (fun r => (r-p)^2) (pushMass t.run P) := by | |
| exact (divergence_reference_bounds hp t _ (pushMass_nonneg t.run P hP) | |
| (by rw [pushMass_sum, hMass])).2 | |
| end CriticalPercolation.QueryTree | |
| namespace CriticalPercolation.QueryTree | |
| variable {E : Type*} | |
| @[reducible] def Node : QueryTree E β Type | |
| | .stop => PEmpty | |
| | .ask _ l r => PUnit β (l.Node β r.Node) | |
| instance nodeFintype : (t : QueryTree E) β Fintype t.Node | |
| | .stop => inferInstanceAs (Fintype PEmpty) | |
| | .ask _ l r => _ _ (inferInstanceAs (Fintype PUnit)) | |
| ( _ _ l.nodeFintype r.nodeFintype) | |
| def bit : (t : QueryTree E) β t.Node β E | |
| | .stop, n => PEmpty.elim n | |
| | .ask e _ _, .inl _ => e | |
| | .ask _ l _, .inr (.inl n) => l.bit n | |
| | .ask _ _ r, .inr (.inr n) => r.bit n | |
| def response : (t : QueryTree E) β t.Node β t.Leaf β Option Bool | |
| | .stop, n, _ => PEmpty.elim n | |
| | .ask _ _ _, .inl _, .inl _ => some false | |
| | .ask _ _ _, .inl _, .inr _ => some true | |
| | .ask _ l _, .inr (.inl n), .inl x => l.response n x | |
| | .ask _ _ _, .inr (.inl _), .inr _ => none | |
| | .ask _ _ _, .inr (.inr _), .inl _ => none | |
| | .ask _ _ r, .inr (.inr n), .inr x => r.response n x | |
| noncomputable def nodeMass (t : QueryTree E) (P : t.Leaf β β) (n : t.Node) : β := | |
| β x, if (t.response n x).isSome then P x else 0 | |
| noncomputable def nodeTrueMass (t : QueryTree E) (P : t.Leaf β β) (n : t.Node) : β := | |
| β x, if t.response n x = some true then P x else 0 | |
| lemma nodeMass_root (e : E) (l r : QueryTree E) (P : (ask e l r).Leaf β β) (z : PUnit) : | |
| (ask e l r).nodeMass P (.inl z) = | |
| (β x, P (.inl x)) + β x, P (.inr x) := by | |
| simp [nodeMass, response, Fintype.sum_sum_type] | |
| lemma nodeTrueMass_root (e : E) (l r : QueryTree E) (P : (ask e l r).Leaf β β) (z : PUnit) : | |
| (ask e l r).nodeTrueMass P (.inl z) = β x, P (.inr x) := by | |
| simp [nodeTrueMass, response, Fintype.sum_sum_type] | |
| lemma nodeMass_left (e : E) (l r : QueryTree E) (P : (ask e l r).Leaf β β) (n : l.Node) : | |
| (ask e l r).nodeMass P (.inr (.inl n)) = l.nodeMass (fun x => P (.inl x)) n := by | |
| simp [nodeMass, response, Fintype.sum_sum_type] | |
| apply Finset.sum_congr rfl | |
| intro x _ | |
| split_ifs <;> simp_all | |
| lemma nodeTrueMass_left (e : E) (l r : QueryTree E) (P : (ask e l r).Leaf β β) (n : l.Node) : | |
| (ask e l r).nodeTrueMass P (.inr (.inl n)) = l.nodeTrueMass (fun x => P (.inl x)) n := by | |
| simp [nodeTrueMass, response, Fintype.sum_sum_type] | |
| apply Finset.sum_congr rfl | |
| intro x _ | |
| split_ifs <;> simp_all | |
| lemma nodeMass_right (e : E) (l r : QueryTree E) (P : (ask e l r).Leaf β β) (n : r.Node) : | |
| (ask e l r).nodeMass P (.inr (.inr n)) = r.nodeMass (fun x => P (.inr x)) n := by | |
| simp [nodeMass, response, Fintype.sum_sum_type] | |
| apply Finset.sum_congr rfl | |
| intro x _ | |
| split_ifs <;> simp_all | |
| lemma nodeTrueMass_right (e : E) (l r : QueryTree E) (P : (ask e l r).Leaf β β) (n : r.Node) : | |
| (ask e l r).nodeTrueMass P (.inr (.inr n)) = r.nodeTrueMass (fun x => P (.inr x)) n := by | |
| simp [nodeTrueMass, response, Fintype.sum_sum_type] | |
| apply Finset.sum_congr rfl | |
| intro x _ | |
| split_ifs <;> simp_all | |
| lemma charge_eq_sum (F : β β β) (t : QueryTree E) (P : t.Leaf β β) : | |
| t.charge F P = β n, t.nodeMass P n * F (t.nodeTrueMass P n / t.nodeMass P n) := by | |
| induction t with | |
| | stop => simp [charge, Node] | |
| | ask e l r hl hr => | |
| change _ = β n : PUnit β (l.Node β r.Node), _ | |
| rw [Fintype.sum_sum_type, Fintype.sum_sum_type] | |
| simp only [Fintype.sum_unique, nodeMass_root, nodeTrueMass_root, | |
| nodeMass_left, nodeTrueMass_left, nodeMass_right, nodeTrueMass_right] | |
| rw [β hl, β hr] | |
| simp only [charge] | |
| ring | |
| end CriticalPercolation.QueryTree | |
| end | |
| end | |
| end OAI | |