Download data/lean/OAI/Computability/VertexCover/Sampling/TraceLaw.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.69 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/VertexCover/Sampling/TraceLaw.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/VertexCover/Sampling/TraceLaw.lean
-
curl -L -o TraceLaw.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/VertexCover/Sampling/TraceLaw.lean
5.69 kB
| import Mathlib | |
| import OAI.Computability.VertexCover.Sampling.Basic | |
| import OAI.Computability.VertexCover.Sampling.FiniteTrials | |
| 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 | |
| variable {Ο : Type*} [Fintype Ο] | |
| def traceAverage (w : Ο β β) : Nat β (List Ο β β) β β | |
| | 0, observable => observable [] | |
| | n + 1, observable => β s, w s * traceAverage w n (fun tail => observable (s :: tail)) | |
| theorem traceAverage_const (w : Ο β β) (hw : β s, w s = 1) (n : Nat) (Β«cΒ» : β) : | |
| traceAverage w n (fun _ => Β«cΒ») = Β«cΒ» := by | |
| induction n with | |
| | zero => rfl | |
| | succ n ih => simp [traceAverage, ih, β Finset.sum_mul, hw] | |
| theorem traceAverage_mono (w : Ο β β) (hw : β s, 0 β€ w s) (n : Nat) | |
| (f g : List Ο β β) (hfg : β xs, f xs β€ g xs) : | |
| traceAverage w n f β€ traceAverage w n g := by | |
| induction n generalizing f g with | |
| | zero => exact hfg [] | |
| | succ n ih => | |
| apply Finset.sum_le_sum | |
| intro s _ | |
| exact mul_le_mul_of_nonneg_left | |
| (ih (fun tail => f (s :: tail)) (fun tail => g (s :: tail)) | |
| (fun tail => hfg (s :: tail))) (hw s) | |
| theorem traceAverage_sum {ΞΉ : Type*} [Fintype ΞΉ] (w : Ο β β) (n : Nat) | |
| (f : ΞΉ β List Ο β β) : | |
| traceAverage w n (fun xs => β i, f i xs) = β i, traceAverage w n (f i) := by | |
| induction n generalizing f with | |
| | zero => rfl | |
| | succ n ih => | |
| simp only [traceAverage] | |
| simp_rw [ih, Finset.mul_sum] | |
| exact Finset.sum_comm | |
| variable [DecidableEq Ο] | |
| theorem firstAccepted_law (w : Ο β β) (accept : Ο β Bool) | |
| (hw : β s, w s = 1) (n : Nat) (output : Option Ο) : | |
| traceAverage w n (fun proposals => | |
| if firstAccepted accept proposals = output then 1 else 0) = | |
| firstHitWeight w accept n output := by | |
| classical | |
| induction n generalizing output with | |
| | zero => cases output <;> simp [traceAverage, firstAccepted, firstHitWeight] | |
| | succ n ih => | |
| have hstep : traceAverage w (n + 1) (fun proposals => | |
| if firstAccepted accept proposals = output then 1 else 0) = | |
| β s, w s * (if accept s then (if some s = output then 1 else 0) | |
| else firstHitWeight w accept n output) := by | |
| unfold traceAverage | |
| apply Finset.sum_congr rfl | |
| intro s _ | |
| congr 1 | |
| by_cases hs : accept s = true | |
| Β· simp [firstAccepted, hs, traceAverage_const w hw] | |
| Β· simpa [firstAccepted, hs] using ih output | |
| rw [hstep] | |
| cases output with | |
| | none => | |
| simp only [Option.some_ne_none, ite_false, firstHitWeight] | |
| rw [eventMass, Finset.sum_mul] | |
| apply Finset.sum_congr rfl | |
| intro s _ | |
| cases accept s <;> simp | |
| | some t => | |
| simp only [Option.some.injEq, firstHitWeight] | |
| calc | |
| β s, w s * (if accept s then (if s = t then 1 else 0) | |
| else firstHitWeight w accept n (some t)) = | |
| β s, ((if s = t then (if accept s then w s else 0) else 0) + | |
| (if !(accept s) then w s else 0) * firstHitWeight w accept n (some t)) := by | |
| apply Finset.sum_congr rfl | |
| intro s _ | |
| by_cases he : s = t | |
| Β· subst s | |
| by_cases hs : accept t = true <;> simp [hs] | |
| Β· by_cases hs : accept s = true <;> simp [hs, he] | |
| _ = (if accept t then w t else 0) + | |
| eventMass w (fun s => !(accept s)) * firstHitWeight w accept n (some t) := by | |
| rw [Finset.sum_add_distrib, β Finset.sum_mul] | |
| simp [eventMass] | |
| def goodFirstIndicator (accept good : Ο β Bool) (proposals : List Ο) : β := | |
| match firstAccepted accept proposals with | |
| | none => 0 | |
| | some s => if good s then 1 else 0 | |
| theorem goodFirstIndicator_expansion (accept good : Ο β Bool) (proposals : List Ο) : | |
| goodFirstIndicator accept good proposals = | |
| β s, if good s then (if firstAccepted accept proposals = some s then 1 else 0) else 0 := by | |
| classical | |
| cases h : firstAccepted accept proposals with | |
| | none => simp [goodFirstIndicator, h] | |
| | some t => | |
| simp only [goodFirstIndicator, h, Option.some.injEq] | |
| calc | |
| (if good t then (1 : β) else 0) = | |
| β s, if t = s then (if good s then (1 : β) else 0) else 0 := by simp | |
| _ = β s, if good s then (if t = s then (1 : β) else 0) else 0 := by | |
| apply Finset.sum_congr rfl | |
| intro s _ | |
| by_cases hg : good s = true <;> by_cases ht : t = s <;> simp [hg, ht] | |
| theorem goodFirstIndicator_law (w : Ο β β) (accept good : Ο β Bool) | |
| (hw : β s, w s = 1) (n : Nat) : | |
| traceAverage w n (goodFirstIndicator accept good) = goodFirstMass w accept good n := by | |
| classical | |
| change traceAverage w n (fun xs => goodFirstIndicator accept good xs) = _ | |
| simp_rw [goodFirstIndicator_expansion] | |
| rw [traceAverage_sum] | |
| unfold goodFirstMass | |
| apply Finset.sum_congr rfl | |
| intro s _ | |
| by_cases hg : good s = true | |
| Β· simpa [hg] using firstAccepted_law w accept hw n (some s) | |
| Β· simp [hg, traceAverage_const w hw] | |
| 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 | |