Download data/lean/OAI/Computability/VertexCover/Sampling/ThresholdPartition.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.52 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/VertexCover/Sampling/ThresholdPartition.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/VertexCover/Sampling/ThresholdPartition.lean
-
curl -L -o ThresholdPartition.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/VertexCover/Sampling/ThresholdPartition.lean
7.52 kB
| import Mathlib | |
| namespace OAI | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| section | |
| namespace UniqueGames.Foundations.CorrelatedSampling | |
| noncomputable section | |
| structure ThresholdInterval where | |
| lo : β | |
| hi : β | |
| valid : lo β€ hi | |
| def splitPoint (I : ThresholdInterval) (t : β) : β := max I.lo (min t I.hi) | |
| def splitLeft (I : ThresholdInterval) (t : β) : ThresholdInterval := | |
| β¨I.lo, splitPoint I t, le_max_left _ _β© | |
| def splitRight (I : ThresholdInterval) (t : β) : ThresholdInterval := | |
| β¨splitPoint I t, I.hi, max_le I.valid (min_le_right _ _)β© | |
| def cutAt (r : β) (I : ThresholdInterval) : Prop := I.hi β€ r β¨ r β€ I.lo | |
| def intervalCDF (r : β) (I : ThresholdInterval) : β := min r I.hi - min r I.lo | |
| theorem split_cdf (I : ThresholdInterval) (t r : β) : | |
| intervalCDF r (splitLeft I t) + intervalCDF r (splitRight I t) = intervalCDF r I := by | |
| unfold intervalCDF splitLeft splitRight | |
| ring | |
| theorem accepted_interval_mass (I : ThresholdInterval) (r : β) (hc : cutAt r I) : | |
| (if I.lo < r then I.hi - I.lo else 0) = intervalCDF r I := by | |
| by_cases hl : I.lo < r | |
| Β· have hu : I.hi β€ r := hc.resolve_right (not_le_of_gt hl) | |
| simp [hl, intervalCDF, min_eq_right hu, min_eq_right (le_of_lt hl)] | |
| Β· have hr : r β€ I.lo := le_of_not_gt hl | |
| simp [hl, intervalCDF, min_eq_left hr, min_eq_left (hr.trans I.valid)] | |
| theorem splitLeft_cut (I : ThresholdInterval) (t : β) : cutAt t (splitLeft I t) := by | |
| by_cases h : I.lo β€ t | |
| Β· exact Or.inl (max_le h (min_le_left _ _)) | |
| Β· exact Or.inr (le_of_lt (lt_of_not_ge h)) | |
| theorem splitRight_cut (I : ThresholdInterval) (t : β) : cutAt t (splitRight I t) := by | |
| by_cases h : t β€ I.hi | |
| Β· right | |
| change t β€ max I.lo (min t I.hi) | |
| rw [min_eq_left h] | |
| exact le_max_right _ _ | |
| Β· exact Or.inl (le_of_lt (lt_of_not_ge h)) | |
| theorem splitLeft_preserves_cut (I : ThresholdInterval) (t r : β) (h : cutAt r I) : | |
| cutAt r (splitLeft I t) := by | |
| rcases h with h | h | |
| Β· exact Or.inl ((max_le I.valid (min_le_right _ _)).trans h) | |
| Β· exact Or.inr h | |
| theorem splitRight_preserves_cut (I : ThresholdInterval) (t r : β) (h : cutAt r I) : | |
| cutAt r (splitRight I t) := by | |
| rcases h with h | h | |
| Β· exact Or.inl h | |
| Β· exact Or.inr (h.trans (le_max_left _ _)) | |
| def splitAll (t : β) : List ThresholdInterval β List ThresholdInterval | |
| | [] => [] | |
| | I :: rest => splitLeft I t :: splitRight I t :: splitAll t rest | |
| def unitThresholdInterval : ThresholdInterval := β¨0, 1, by norm_numβ© | |
| def thresholdPartition : List β β List ThresholdInterval | |
| | [] => [unitThresholdInterval] | |
| | t :: rest => splitAll t (thresholdPartition rest) | |
| def sumOnIntervals (f : ThresholdInterval β β) : List ThresholdInterval β β | |
| | [] => 0 | |
| | I :: rest => f I + sumOnIntervals f rest | |
| theorem sumOn_splitAll (f : ThresholdInterval β β) (t : β) | |
| (hf : β I, f (splitLeft I t) + f (splitRight I t) = f I) | |
| (intervals : List ThresholdInterval) : | |
| sumOnIntervals f (splitAll t intervals) = sumOnIntervals f intervals := by | |
| induction intervals with | |
| | nil => rfl | |
| | cons I rest ih => | |
| simp only [splitAll, sumOnIntervals, ih] | |
| rw [β add_assoc, hf] | |
| theorem partition_sum (f : ThresholdInterval β β) | |
| (hf : β t I, f (splitLeft I t) + f (splitRight I t) = f I) | |
| (thresholds : List β) : | |
| sumOnIntervals f (thresholdPartition thresholds) = f unitThresholdInterval := by | |
| induction thresholds with | |
| | nil => simp [thresholdPartition, sumOnIntervals] | |
| | cons t rest ih => | |
| rw [thresholdPartition, sumOn_splitAll f t (hf t), ih] | |
| theorem partition_total_mass (thresholds : List β) : | |
| sumOnIntervals (fun I => I.hi - I.lo) (thresholdPartition thresholds) = 1 := by | |
| have h := partition_sum (fun I => I.hi - I.lo) | |
| (fun t I => by simp only [splitLeft, splitRight]; ring) thresholds | |
| simpa [unitThresholdInterval] using h | |
| theorem partition_cdf (thresholds : List β) (r : β) (h0 : 0 β€ r) (h1 : r β€ 1) : | |
| sumOnIntervals (intervalCDF r) (thresholdPartition thresholds) = r := by | |
| have h := partition_sum (intervalCDF r) (fun t I => split_cdf I t r) thresholds | |
| simpa [intervalCDF, unitThresholdInterval, min_eq_left h1, min_eq_right h0] using h | |
| theorem splitAll_new_cuts (intervals : List ThresholdInterval) (t : β) : | |
| β I β splitAll t intervals, cutAt t I := by | |
| induction intervals with | |
| | nil => intro I h; simp [splitAll] at h | |
| | cons J rest ih => | |
| intro I h | |
| rcases List.mem_cons.mp h with h | h | |
| Β· subst I; exact splitLeft_cut J t | |
| Β· rcases List.mem_cons.mp h with h | h | |
| Β· subst I; exact splitRight_cut J t | |
| Β· exact ih I h | |
| theorem splitAll_preserves_cuts (intervals : List ThresholdInterval) (t r : β) : | |
| (β I β intervals, cutAt r I) β β I β splitAll t intervals, cutAt r I := by | |
| induction intervals with | |
| | nil => intro _ I h; simp [splitAll] at h | |
| | cons J rest ih => | |
| intro hc I h | |
| have hJ : cutAt r J := hc J (by simp) | |
| have hrest : β K β rest, cutAt r K := fun K hK => hc K (by simp [hK]) | |
| rcases List.mem_cons.mp h with h | h | |
| Β· subst I; exact splitLeft_preserves_cut J t r hJ | |
| Β· rcases List.mem_cons.mp h with h | h | |
| Β· subst I; exact splitRight_preserves_cut J t r hJ | |
| Β· exact ih hrest I h | |
| theorem partition_cuts (thresholds : List β) (r : β) : | |
| r β thresholds β β I β thresholdPartition thresholds, cutAt r I := by | |
| induction thresholds with | |
| | nil => intro hr; simp at hr | |
| | cons t rest ih => | |
| intro hr | |
| rcases List.mem_cons.mp hr with h | h | |
| Β· subst r; exact splitAll_new_cuts (thresholdPartition rest) t | |
| Β· exact splitAll_preserves_cuts (thresholdPartition rest) t r (ih h) | |
| theorem sumOnIntervals_congr (f g : ThresholdInterval β β) (intervals : List ThresholdInterval) : | |
| (β I β intervals, f I = g I) β sumOnIntervals f intervals = sumOnIntervals g intervals := by | |
| induction intervals with | |
| | nil => intro _; rfl | |
| | cons J rest ih => | |
| intro h | |
| have hJ := h J (by simp) | |
| have hr : β I β rest, f I = g I := fun I hI => h I (by simp [hI]) | |
| simp only [sumOnIntervals, hJ, ih hr] | |
| theorem partition_acceptance_mass (thresholds : List β) (r : β) | |
| (hr : r β thresholds) (h0 : 0 β€ r) (h1 : r β€ 1) : | |
| sumOnIntervals (fun I => if I.lo < r then I.hi - I.lo else 0) | |
| (thresholdPartition thresholds) = r := by | |
| calc | |
| _ = sumOnIntervals (intervalCDF r) (thresholdPartition thresholds) := | |
| sumOnIntervals_congr _ _ _ (fun I hI => | |
| accepted_interval_mass I r (partition_cuts thresholds r hr I hI)) | |
| _ = r := partition_cdf thresholds r h0 h1 | |
| theorem sum_interval_get (f : ThresholdInterval β β) (intervals : List ThresholdInterval) : | |
| (β i : Fin intervals.length, f intervals[i]) = sumOnIntervals f intervals := by | |
| induction intervals with | |
| | nil => simp [sumOnIntervals] | |
| | cons I rest ih => | |
| simpa [Fin.sum_univ_succ, sumOnIntervals] using congrArg (fun x : β => f I + x) ih | |
| end | |
| end UniqueGames.Foundations.CorrelatedSampling | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end OAI | |