Download data/lean/OAI/Computability/DirectedFeedback/Machines/MachineProductFinish.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 37 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/DirectedFeedback/Machines/MachineProductFinish.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/DirectedFeedback/Machines/MachineProductFinish.lean
-
curl -L -o MachineProductFinish.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/DirectedFeedback/Machines/MachineProductFinish.lean
37 kB
| import Mathlib | |
| import OAI.Computability.DirectedFeedback.Machines.MachineProductProgram | |
| namespace OAI | |
| namespace DFVSGames.Explicit.MachineProductFinish | |
| open Turing | |
| open DFVSGames.Foundations | |
| open Complexity Hastad | |
| open MachineComposition | |
| open MachineProductProgram | |
| variable {q t : Nat} | |
| noncomputable section | |
| theorem base_ready (H : Target.Instance q) (t : Nat) : | |
| MachineProductLoop.BaseReady H (MachineProductHeaders.baseTapes H t) := by | |
| constructor | |
| Β· intro bit | |
| exact β¨rfl, rfl, rfl, fun _ => rfl, rfl, rfl, rfl, rfl, rflβ© | |
| Β· rfl | |
| Β· simp [MachineProductHeaders.baseTapes, MachineProductHeaders.frame, auxiliary] | |
| Β· simp [MachineProductHeaders.baseTapes, MachineProductHeaders.frame, auxiliary] | |
| def afterRows (H : Target.Instance q) (t : Nat) : | |
| TM2.Cfg (fun _ : Tape t => Bool) (Label q t) State := | |
| SourceOdometerSchedule.finalConfiguration (nextCheck q t t) ((), ()) | |
| (Sum.inl (6 : Fin 10)) (MachineProductHeaders.baseTapes H t) (MachineProductLoop.rowBits (t := t) H) | |
| theorem afterRows_output (H : Target.Instance q) (t : Nat) : | |
| (afterRows H t).stk (output t) = [] := by | |
| simp [afterRows, SourceOdometerSchedule.finalConfiguration, SourceOdometerSchedule.configuration, | |
| SourceOdometerSchedule.setDigits, SourceOdometerSchedule.setAcc, output, auxiliary, | |
| MachineProductHeaders.baseTapes, MachineProductHeaders.frame] | |
| theorem allRows_eq (H : Target.Instance q) (t : Nat) : | |
| (MachineTupleOdometer.tupleOrder H.constraints.length t).flatMap (MachineProductLoop.rowBits (t := t) H) = | |
| ProductMachineSemantics.allRowsBits H t := by | |
| simp only [MachineTupleOdometer.tupleOrder, ProductMachineSemantics.allRowsBits, | |
| List.ofFn_eq_map, List.flatMap_map, MachineProductLoop.rowBits] | |
| theorem afterRows_accumulator (H : Target.Instance q) | |
| (presentation : MachineOutputContract.SimpleBipartite H) (t : Nat) (ht : 0 < t) : | |
| ((afterRows H t).stk (accumulator t)).reverse = | |
| gameBits (ProductPaddedOutput.output H presentation t ht) := by | |
| change ((SourceOdometerSchedule.allBits (MachineProductLoop.rowBits (t := t) H)).reverse ++ | |
| MachineProductHeaders.baseTapes H t (accumulator t)).reverse = _ | |
| rw [MachineProductHeaders.baseTapes, MachineProductHeaders.frame_accumulator, | |
| List.reverse_append, List.reverse_reverse, List.reverse_reverse] | |
| rw [SourceOdometerSchedule.allBits, allRows_eq] | |
| exact ProductMachineSemantics.gameBits_eq H presentation t ht | |
| def finishInTime (base : Tape t β List Bool) (emptyOutput : base (output t) = []) : | |
| StateTransition.EvalsToInTime (TM2.step (program q t)) | |
| β¨some .finishStart, (((), ()), none), baseβ© | |
| (some β¨none, (((), ()), none), | |
| SourceRuntimeFinish.canonicalTapes (output t) (base (accumulator t)).reverseβ©) | |
| (1 + SourceRuntimeFinish.finishCost (clearKeys t) (accumulator t) base) := by | |
| have enter : StateTransition.EvalsToInTime (TM2.step (program q t)) | |
| β¨some .finishStart, (((), ()), none), baseβ© | |
| (some β¨SourceRuntimeFinish.entry (clearKeys t) Label.finish, (((), ()), none), baseβ©) 1 := by | |
| refine β¨β¨1, ?_β©, Nat.le_refl _β© | |
| change some (TM2.stepAux (program q t .finishStart) _ _) = _ | |
| simp only [program, DFVSGames.Reduction.MachineTransfer.exitAt] | |
| split <;> simp_all [TM2.stepAux] | |
| have finish := SourceRuntimeFinish.finishInTime (clearKeys t) (accumulator t) (output t) | |
| (by simp [accumulator, output, auxiliary]) | |
| (by simp) (by simp) (by intro k h1 h2; simp [h1, h2]) | |
| ((), ()) Label.finish none (program q t) (fun _ => rfl) base emptyOutput ((), ()) none | |
| have joined := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ enter finish | |
| exact { toEvalsTo := joined.toEvalsTo | |
| steps_le_m := by simpa only [Nat.add_comm] using joined.steps_le_m } | |
| theorem finishCost_le_uniform (base : Tape t β List Bool) (bound : Nat) | |
| (bounded : β k, (base k).length β€ bound) : | |
| SourceRuntimeFinish.finishCost (clearKeys t) (accumulator t) base β€ | |
| ((clearKeys t).length + 1) * bound + (clearKeys t).length + 2 := by | |
| have clear := MachineDrainMany.steps_le_uniform (clearKeys t) base bound bounded | |
| have acc := bounded (accumulator t) | |
| unfold SourceRuntimeFinish.finishCost | |
| rw [Nat.add_mul, Nat.one_mul] | |
| rw [Nat.mul_add, Nat.mul_one] at clear | |
| omega | |
| theorem finish_afterRows (H : Target.Instance q) | |
| (presentation : MachineOutputContract.SimpleBipartite H) (t : Nat) (ht : 0 < t) : | |
| Nonempty (StateTransition.EvalsToInTime (machine q t).step (afterRows H t) | |
| (some (haltList (machine q t) (gameBits (ProductPaddedOutput.output H presentation t ht)))) | |
| (1 + SourceRuntimeFinish.finishCost (clearKeys t) (accumulator t) (afterRows H t).stk)) := by | |
| have run := finishInTime (q := q) (afterRows H t).stk (afterRows_output H t) | |
| rw [afterRows_accumulator H presentation t ht] at run | |
| have hstart : (afterRows H t).l = some .finishStart := by simp [afterRows, | |
| SourceOdometerSchedule.finalConfiguration, SourceOdometerSchedule.configuration, nextCheck] | |
| have hstate : (afterRows H t).var = (((), ()), none) := rfl | |
| have halt : (β¨none, (((), ()), none), SourceRuntimeFinish.canonicalTapes (output t) | |
| (gameBits (ProductPaddedOutput.output H presentation t ht))β© : | |
| TM2.Cfg (fun _ : Tape t => Bool) (Label q t) State) = | |
| haltList (machine q t) (gameBits (ProductPaddedOutput.output H presentation t ht)) := by | |
| unfold haltList SourceRuntimeFinish.canonicalTapes | |
| congr 1 | |
| funext k | |
| by_cases hk : k = output t <;> simp [machine, hk] | |
| rfl | |
| rw [halt] at run | |
| have hcfg : (β¨some .finishStart, (((), ()), none), (afterRows H t).stkβ© : | |
| TM2.Cfg (fun _ : Tape t => Bool) (Label q t) State) = | |
| afterRows H t := by cases h : afterRows H t; simp_all | |
| rw [hcfg] at run | |
| exact β¨runβ© | |
| end | |
| end DFVSGames.Explicit.MachineProductFinish | |
| namespace DFVSGames.Explicit.MachineProductRuntime | |
| open Turing | |
| open DFVSGames.Foundations Target Complexity Hastad | |
| open MachineProductProgram | |
| noncomputable section | |
| def loopPolynomial (q t : Nat) : Polynomial Nat := | |
| (Polynomial.C (q ^ t + 2) * MachineProductBounds.fieldPolynomial t + | |
| Polynomial.C (2 * t)) * Polynomial.X ^ t | |
| theorem loop_budget {q : Nat} (H : Instance q) (t : Nat) : | |
| (MachineProductLoop.bodyBound H t + 2 * t) * H.constraints.length ^ t β€ | |
| (loopPolynomial q t).eval (gameBits H).length := by | |
| have hlen := MachineProductLoop.input_length H | |
| have hm : H.constraints.length β€ (gameBits H).length := by omega | |
| simp only [loopPolynomial, Polynomial.eval_mul, Polynomial.eval_add, | |
| Polynomial.eval_C, Polynomial.eval_pow, Polynomial.eval_X] | |
| exact Nat.mul_le_mul_left _ (Nat.pow_le_pow_left hm t) | |
| def prefixPolynomial (q t : Nat) : Polynomial Nat := | |
| MachineProductHeaders.timePolynomial t + loopPolynomial q t | |
| def prefixInTime {q : Nat} (H : Instance q) (t : Nat) : | |
| StateTransition.EvalsToInTime (machine q t).step | |
| (initList (machine q t) (gameBits H)) | |
| (some (MachineProductFinish.afterRows H t)) | |
| ((prefixPolynomial q t).eval (gameBits H).length) := by | |
| let first := MachineProductHeaders.inPolynomialTime H t | |
| let loop := Classical.choice (MachineProductLoop.traversalInTime H | |
| (MachineProductHeaders.baseTapes H t) (MachineProductFinish.base_ready H t)) | |
| let second : StateTransition.EvalsToInTime (machine q t).step | |
| (SourceOdometerSchedule.initialConfiguration (m := H.constraints.length) | |
| t (rowMain q t) ((), ()) (MachineProductHeaders.baseTapes H t)) | |
| (some (MachineProductFinish.afterRows H t)) | |
| ((loopPolynomial q t).eval (gameBits H).length) := { | |
| toEvalsTo := loop.toEvalsTo | |
| steps_le_m := loop.steps_le_m.trans (loop_budget H t) } | |
| let joined := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ first second | |
| exact { | |
| toEvalsTo := joined.toEvalsTo | |
| steps_le_m := by | |
| simpa only [prefixPolynomial, Polynomial.eval_add, Nat.add_comm] | |
| using joined.steps_le_m } | |
| def timePolynomial (q t : Nat) : Polynomial Nat := | |
| SourceRuntimeSpace.completedTime (machine q t) (clearKeys t).length | |
| (prefixPolynomial q t) + 1 | |
| def outputInTime {q : Nat} (H : Instance q) | |
| (presentation : MachineOutputContract.SimpleBipartite H) (t : Nat) (ht : 0 < t) : | |
| TM2OutputsInTime (machine q t) (gameBits H) | |
| (some (gameBits (ProductPaddedOutput.output H presentation t ht))) | |
| ((timePolynomial q t).eval (gameBits H).length) := by | |
| let initialRun := prefixInTime H t | |
| let finish := Classical.choice (MachineProductFinish.finish_afterRows H presentation t ht) | |
| let whole := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ initialRun finish | |
| have keepAccumulator : accumulator t β clearKeys t := by simp | |
| have keepOutput : output t β clearKeys t := by simp | |
| have covers (k : Tape t) (ha : k β accumulator t) (ho : k β output t) : | |
| k β clearKeys t := (mem_clearKeys t k).mpr β¨ha, hoβ© | |
| have bound := SourceRuntimeSpace.finishCost_le_of_prefix (machine q t) (gameBits H) | |
| initialRun (clearKeys t) (accumulator t) (output t) | |
| keepAccumulator keepOutput covers | |
| (MachineProductFinish.afterRows H t).stk (MachineProductFinish.afterRows_output H t) | |
| (fun _ => rfl) | |
| change StateTransition.EvalsToInTime (machine q t).step _ | |
| (some (haltList (machine q t) _)) _ | |
| refine { toEvalsTo := whole.toEvalsTo, steps_le_m := whole.steps_le_m.trans ?_ } | |
| simp only [timePolynomial, Polynomial.eval_add, Polynomial.eval_one, | |
| SourceRuntimeSpace.completedTime_eval] | |
| simp only [machine] at bound β’ | |
| change SourceRuntimeFinish.finishCost (clearKeys t) (accumulator t) | |
| (MachineProductFinish.afterRows H t).stk β€ _ at bound | |
| omega | |
| abbrev Input (q : Nat) := Ξ£ H : Instance q, MachineOutputContract.SimpleBipartite H | |
| def construct {q : Nat} (t : Nat) (ht : 0 < t) (H : Input q) : Instance (q ^ t) := | |
| ProductPaddedOutput.output H.1 H.2 t ht | |
| def computation (q t : Nat) (ht : 0 < t) : | |
| TM2ComputableInPolyTime (fun H : Input q => gameBits H.1) gameBits | |
| (construct t ht) where | |
| tm := machine q t | |
| inputAlphabet := Equiv.refl Bool | |
| outputAlphabet := Equiv.refl Bool | |
| time := timePolynomial q t | |
| outputsFun H := by | |
| change TM2OutputsInTime (machine q t) ((gameBits H.1).map id) | |
| (some ((gameBits (construct t ht H)).map id)) _ | |
| convert outputInTime H.1 H.2 t ht using 1 | |
| simp only [machine, List.map_id, construct] | |
| theorem finiteAlphabet (q t : Nat) (ht : 0 < t) : | |
| MachineFiniteAlphabet.FiniteAlphabet (computation q t ht).tm := | |
| MachineFiniteAlphabet.of_bool _ (fun _ => rfl) | |
| variable {A : Type} {q : Nat} {encode : A β List Bool} {f : A β Instance q} | |
| def certify (upstream : TM2ComputableInPolyTime encode gameBits f) | |
| (presentation : β a, MachineOutputContract.SimpleBipartite (f a)) : | |
| TM2ComputableInPolyTime encode (fun H : Input q => gameBits H.1) | |
| (fun a => β¨f a, presentation aβ©) where | |
| tm := upstream.tm | |
| inputAlphabet := upstream.inputAlphabet | |
| outputAlphabet := upstream.outputAlphabet | |
| time := upstream.time | |
| outputsFun := upstream.outputsFun | |
| def compose (upstream : TM2ComputableInPolyTime encode gameBits f) | |
| (presentation : β a, MachineOutputContract.SimpleBipartite (f a)) | |
| (t : Nat) (ht : 0 < t) : | |
| TM2ComputableInPolyTime encode gameBits | |
| (fun a => ProductPaddedOutput.output (f a) (presentation a) t ht) := | |
| MachineSequential.composeBits (certify upstream presentation) (computation q t ht) | |
| theorem compose_finiteAlphabet (upstream : TM2ComputableInPolyTime encode gameBits f) | |
| (presentation : β a, MachineOutputContract.SimpleBipartite (f a)) | |
| (t : Nat) (ht : 0 < t) (finite : MachineFiniteAlphabet.FiniteAlphabet upstream.tm) : | |
| MachineFiniteAlphabet.FiniteAlphabet (compose upstream presentation t ht).tm := | |
| MachineFiniteAlphabet.composeBits (certify upstream presentation) (computation q t ht) | |
| finite (finiteAlphabet q t ht) | |
| end | |
| end DFVSGames.Explicit.MachineProductRuntime | |
| namespace DFVSGames.Repetition.Analytic | |
| open scoped BigOperators | |
| noncomputable section | |
| variable {ΞΉ : Type*} [Fintype ΞΉ] | |
| def quadraticMass (w f g : ΞΉ β β) : β := | |
| β i, w i * ((f i) ^ 2 + (g i) ^ 2) / 2 | |
| def gatedCorrelation (w f g : ΞΉ β β) (gate : ΞΉ β Bool) : β := | |
| β i, if gate i then w i * f i * g i else 0 | |
| def gatedMinimum (w f g : ΞΉ β β) (gate : ΞΉ β Bool) : β := | |
| β i, if gate i then w i * min ((f i) ^ 2) ((g i) ^ 2) else 0 | |
| def gatedMaximum (w f g : ΞΉ β β) (gate : ΞΉ β Bool) : β := | |
| β i, if gate i then w i * max ((f i) ^ 2) ((g i) ^ 2) else 0 | |
| theorem quadraticMass_nonnegative (w f g : ΞΉ β β) (hw : β i, 0 β€ w i) : | |
| 0 β€ quadraticMass w f g := by | |
| apply Finset.sum_nonneg | |
| intro i _ | |
| exact div_nonneg (mul_nonneg (hw i) (add_nonneg (sq_nonneg _) (sq_nonneg _))) | |
| (by norm_num) | |
| theorem gatedCorrelation_nonnegative (w f g : ΞΉ β β) (gate : ΞΉ β Bool) | |
| (hw : β i, 0 β€ w i) (hf : β i, 0 β€ f i) (hg : β i, 0 β€ g i) : | |
| 0 β€ gatedCorrelation w f g gate := by | |
| apply Finset.sum_nonneg | |
| intro i _ | |
| split | |
| Β· exact mul_nonneg (mul_nonneg (hw i) (hf i)) (hg i) | |
| Β· exact le_rfl | |
| theorem gatedCorrelation_le_mass (w f g : ΞΉ β β) (gate : ΞΉ β Bool) | |
| (hw : β i, 0 β€ w i) : gatedCorrelation w f g gate β€ quadraticMass w f g := by | |
| apply Finset.sum_le_sum | |
| intro i _ | |
| split | |
| Β· have hfg : f i * g i β€ ((f i) ^ 2 + (g i) ^ 2) / 2 := by | |
| nlinarith [sq_nonneg (f i - g i)] | |
| simpa only [β mul_assoc, mul_div_assoc] using mul_le_mul_of_nonneg_left hfg (hw i) | |
| Β· exact div_nonneg (mul_nonneg (hw i) (add_nonneg (sq_nonneg _) (sq_nonneg _))) | |
| (by norm_num) | |
| theorem gatedMinimum_nonnegative (w f g : ΞΉ β β) (gate : ΞΉ β Bool) | |
| (hw : β i, 0 β€ w i) : 0 β€ gatedMinimum w f g gate := by | |
| apply Finset.sum_nonneg | |
| intro i _ | |
| split | |
| Β· exact mul_nonneg (hw i) (le_min (sq_nonneg _) (sq_nonneg _)) | |
| Β· exact le_rfl | |
| theorem gatedMinimum_le_mass (w f g : ΞΉ β β) (gate : ΞΉ β Bool) | |
| (hw : β i, 0 β€ w i) : gatedMinimum w f g gate β€ quadraticMass w f g := by | |
| apply Finset.sum_le_sum | |
| intro i _ | |
| split | |
| Β· have hmin : min ((f i) ^ 2) ((g i) ^ 2) β€ ((f i) ^ 2 + (g i) ^ 2) / 2 := by | |
| have hβ := min_le_left ((f i) ^ 2) ((g i) ^ 2) | |
| have hβ := min_le_right ((f i) ^ 2) ((g i) ^ 2) | |
| linarith | |
| simpa only [mul_div_assoc] using mul_le_mul_of_nonneg_left hmin (hw i) | |
| Β· exact div_nonneg (mul_nonneg (hw i) (add_nonneg (sq_nonneg _) (sq_nonneg _))) | |
| (by norm_num) | |
| theorem gatedMinimum_add_maximum_le (w f g : ΞΉ β β) (gate : ΞΉ β Bool) | |
| (hw : β i, 0 β€ w i) : | |
| gatedMinimum w f g gate + gatedMaximum w f g gate β€ 2 * quadraticMass w f g := by | |
| unfold gatedMinimum gatedMaximum quadraticMass | |
| rw [β Finset.sum_add_distrib, Finset.mul_sum] | |
| apply Finset.sum_le_sum | |
| intro i _ | |
| by_cases hi : gate i = true | |
| Β· simp only [hi, βreduceIte] | |
| have h := min_add_max ((f i) ^ 2) ((g i) ^ 2) | |
| rw [β mul_add, h] | |
| ring_nf ; exact le_rfl | |
| Β· simp only [hi, Bool.false_eq_true, βreduceIte, zero_add] | |
| have := hw i | |
| positivity | |
| theorem gatedCorrelation_sq_le_min_mul_max (w f g : ΞΉ β β) (gate : ΞΉ β Bool) | |
| (hw : β i, 0 β€ w i) : | |
| gatedCorrelation w f g gate ^ 2 β€ | |
| gatedMinimum w f g gate * gatedMaximum w f g gate := by | |
| apply Finset.sum_sq_le_sum_mul_sum_of_sq_le_mul | |
| Β· intro i _ | |
| split | |
| Β· exact mul_nonneg (hw i) (le_min (sq_nonneg _) (sq_nonneg _)) | |
| Β· exact le_rfl | |
| Β· intro i _ | |
| split | |
| Β· exact mul_nonneg (hw i) ((sq_nonneg (f i)).trans (le_max_left _ _)) | |
| Β· exact le_rfl | |
| Β· intro i _ | |
| by_cases hi : gate i = true | |
| Β· simp only [hi, βreduceIte] | |
| rcases le_total ((f i) ^ 2) ((g i) ^ 2) with h | h | |
| Β· rw [min_eq_left h, max_eq_right h] | |
| ring_nf ; exact le_rfl | |
| Β· rw [min_eq_right h, max_eq_left h] | |
| ring_nf ; exact le_rfl | |
| Β· simp [hi] | |
| theorem gatedCorrelation_sq_le_min_quadratic (w f g : ΞΉ β β) (gate : ΞΉ β Bool) | |
| (hw : β i, 0 β€ w i) : | |
| gatedCorrelation w f g gate ^ 2 β€ | |
| gatedMinimum w f g gate * | |
| (2 * quadraticMass w f g - gatedMinimum w f g gate) := by | |
| have hmax := gatedMinimum_add_maximum_le w f g gate hw | |
| have hmin := gatedMinimum_nonnegative w f g gate hw | |
| exact (gatedCorrelation_sq_le_min_mul_max w f g gate hw).trans | |
| (mul_le_mul_of_nonneg_left (by linarith) hmin) | |
| theorem gatedMinimum_cheeger (w f g : ΞΉ β β) (gate : ΞΉ β Bool) | |
| (hw : β i, 0 β€ w i) : | |
| quadraticMass w f g - | |
| Real.sqrt (quadraticMass w f g ^ 2 - gatedCorrelation w f g gate ^ 2) β€ | |
| gatedMinimum w f g gate := by | |
| have h := gatedCorrelation_sq_le_min_quadratic w f g gate hw | |
| have hsq : (quadraticMass w f g - gatedMinimum w f g gate) ^ 2 β€ | |
| quadraticMass w f g ^ 2 - gatedCorrelation w f g gate ^ 2 := by | |
| nlinarith | |
| have hsqrt := Real.le_sqrt_of_sq_le hsq | |
| linarith | |
| theorem gatedMinimum_near_one (w f g : ΞΉ β β) (gate : ΞΉ β Bool) | |
| (hw : β i, 0 β€ w i) {Ξ· : β} (_hΞ· : 0 β€ Ξ·) (hΞ·β : Ξ· β€ 1) | |
| (hmass : quadraticMass w f g β€ 1) | |
| (hcorrelation : 1 - Ξ· β€ gatedCorrelation w f g gate) : | |
| 1 - Real.sqrt (2 * Ξ·) β€ gatedMinimum w f g gate := by | |
| have hmin := gatedMinimum_nonnegative w f g gate hw | |
| have h := gatedCorrelation_sq_le_min_quadratic w f g gate hw | |
| have hcorr : 0 β€ gatedCorrelation w f g gate := by linarith | |
| have hsqcorr : (1 - Ξ·) ^ 2 β€ gatedCorrelation w f g gate ^ 2 := by | |
| nlinarith | |
| have hupper : gatedMinimum w f g gate * | |
| (2 * quadraticMass w f g - gatedMinimum w f g gate) β€ | |
| gatedMinimum w f g gate * (2 - gatedMinimum w f g gate) := by | |
| apply mul_le_mul_of_nonneg_left _ hmin | |
| linarith | |
| have hsq : (1 - gatedMinimum w f g gate) ^ 2 β€ 2 * Ξ· := by | |
| nlinarith [sq_nonneg Ξ·] | |
| have hsqrt := Real.le_sqrt_of_sq_le hsq | |
| linarith | |
| theorem gatedMinimum_unit_mass (w f g : ΞΉ β β) (gate : ΞΉ β Bool) | |
| (hw : β i, 0 β€ w i) (hf : β i, 0 β€ f i) (hg : β i, 0 β€ g i) | |
| (hmass : quadraticMass w f g = 1) : | |
| 1 - Real.sqrt (2 * (1 - gatedCorrelation w f g gate)) β€ | |
| gatedMinimum w f g gate := by | |
| have hcβ := gatedCorrelation_nonnegative w f g gate hw hf hg | |
| have hcβ := gatedCorrelation_le_mass w f g gate hw | |
| rw [hmass] at hcβ | |
| apply gatedMinimum_near_one w f g gate hw | |
| Β· linarith | |
| Β· linarith | |
| Β· exact hmass.le | |
| Β· linarith | |
| end | |
| end DFVSGames.Repetition.Analytic | |
| namespace DFVSGames.Repetition | |
| open scoped BigOperators | |
| open Foundations.Games | |
| noncomputable section | |
| variable {V A Ξ© E : Type*} [Fintype V] [Fintype Ξ©] [Fintype E] | |
| def rowSquareMass (f : V β Ξ© β β) (v : V) : β := β Ο, (f v Ο) ^ 2 | |
| def paddedAmplitude [DecidableEq V] (f : V β Ξ© β β) (v : V) : Ξ© β V β β | |
| | Sum.inl Ο => f v Ο | |
| | Sum.inr w => if v = w then Real.sqrt (1 - rowSquareMass f v) else 0 | |
| def paddedLabel (a : V β Ξ© β A) (fallback : A) (v : V) : Ξ© β V β A | |
| | Sum.inl Ο => a v Ο | |
| | Sum.inr _ => fallback | |
| omit [Fintype V] in | |
| theorem paddedAmplitude_nonnegative [DecidableEq V] (f : V β Ξ© β β) | |
| (hf : β v Ο, 0 β€ f v Ο) (v : V) (Ο : Ξ© β V) : | |
| 0 β€ paddedAmplitude f v Ο := by | |
| cases Ο with | |
| | inl Ο => exact hf v Ο | |
| | inr w => | |
| simp only [paddedAmplitude] | |
| split | |
| Β· exact Real.sqrt_nonneg _ | |
| Β· exact le_rfl | |
| theorem paddedAmplitude_row [DecidableEq V] (f : V β Ξ© β β) | |
| (hrow : β v, rowSquareMass f v β€ 1) (v : V) : | |
| rowSquareMass (paddedAmplitude f) v = 1 := by | |
| have hs : Real.sqrt (1 - rowSquareMass f v) ^ 2 = 1 - rowSquareMass f v := | |
| Real.sq_sqrt (sub_nonneg.mpr (hrow v)) | |
| simp only [rowSquareMass] at hs | |
| simp only [rowSquareMass, Fintype.sum_sum_type, paddedAmplitude] | |
| simp only [ite_pow, zero_pow (by decide : 2 β 0)] | |
| rw [Finset.sum_ite_eq, ite_eq_left (Finset.mem_univ v), hs] | |
| ring | |
| def pairEnergy (Ξ½ : FiniteDistribution E) (left right : E β V) | |
| (R : E β A β A β Bool) (a : V β Ξ© β A) (f : V β Ξ© β β) : β := | |
| Ξ½.expectation fun e => β Ο, | |
| if R e (a (left e) Ο) (a (right e) Ο) | |
| then f (left e) Ο * f (right e) Ο else 0 | |
| def pairOverlap (Ξ½ : FiniteDistribution E) (left right : E β V) | |
| (R : E β A β A β Bool) (a : V β Ξ© β A) (f : V β Ξ© β β) : β := | |
| Ξ½.expectation fun e => β Ο, | |
| if R e (a (left e) Ο) (a (right e) Ο) | |
| then min ((f (left e) Ο) ^ 2) ((f (right e) Ο) ^ 2) else 0 | |
| omit [Fintype V] in | |
| theorem pairEnergy_nonnegative (Ξ½ : FiniteDistribution E) (left right : E β V) | |
| (R : E β A β A β Bool) (a : V β Ξ© β A) (f : V β Ξ© β β) | |
| (hf : β v Ο, 0 β€ f v Ο) : 0 β€ pairEnergy Ξ½ left right R a f := by | |
| apply Finset.sum_nonneg | |
| intro e _ | |
| apply mul_nonneg (Ξ½.nonnegative e) | |
| apply Finset.sum_nonneg | |
| intro Ο _ | |
| split | |
| Β· exact mul_nonneg (hf (left e) Ο) (hf (right e) Ο) | |
| Β· exact le_rfl | |
| theorem pairEnergy_le_padded [DecidableEq V] (Ξ½ : FiniteDistribution E) | |
| (left right : E β V) (R : E β A β A β Bool) | |
| (a : V β Ξ© β A) (f : V β Ξ© β β) | |
| (hf : β v Ο, 0 β€ f v Ο) (fallback : A) : | |
| pairEnergy Ξ½ left right R a f β€ | |
| pairEnergy Ξ½ left right R (paddedLabel a fallback) (paddedAmplitude f) := by | |
| unfold pairEnergy FiniteDistribution.expectation | |
| apply Finset.sum_le_sum | |
| intro e _ | |
| apply mul_le_mul_of_nonneg_left _ (Ξ½.nonnegative e) | |
| dsimp only | |
| rw [Fintype.sum_sum_type] | |
| simp only [paddedLabel, paddedAmplitude] | |
| have hnonneg : 0 β€ β w : V, | |
| if R e fallback fallback then | |
| (if left e = w then Real.sqrt (1 - rowSquareMass f (left e)) else 0) * | |
| (if right e = w then Real.sqrt (1 - rowSquareMass f (right e)) else 0) | |
| else 0 := by | |
| apply Finset.sum_nonneg | |
| intro w _ | |
| split | |
| Β· exact mul_nonneg (paddedAmplitude_nonnegative f hf (left e) (Sum.inr w)) | |
| (paddedAmplitude_nonnegative f hf (right e) (Sum.inr w)) | |
| Β· exact le_rfl | |
| exact le_add_of_nonneg_right hnonneg | |
| end | |
| end DFVSGames.Repetition | |
| namespace DFVSGames.Repetition | |
| open scoped BigOperators | |
| open Foundations.Games | |
| noncomputable section | |
| variable {V A Ξ© E : Type*} [Fintype V] [Fintype Ξ©] [Fintype E] | |
| omit [Fintype V] in | |
| theorem pairQuadraticMass_eq_one (Ξ½ : FiniteDistribution E) (left right : E β V) | |
| (f : V β Ξ© β β) (hrow : β v, rowSquareMass f v = 1) : | |
| Analytic.quadraticMass (fun p : E Γ Ξ© => Ξ½.weight p.1) | |
| (fun p => f (left p.1) p.2) (fun p => f (right p.1) p.2) = 1 := by | |
| unfold Analytic.quadraticMass | |
| rw [Fintype.sum_prod_type] | |
| have he (e : E) : | |
| (β Ο, Ξ½.weight e * ((f (left e) Ο) ^ 2 + (f (right e) Ο) ^ 2) / 2) = | |
| Ξ½.weight e := by | |
| calc | |
| _ = Ξ½.weight e * | |
| ((β Ο, (f (left e) Ο) ^ 2) + (β Ο, (f (right e) Ο) ^ 2)) / 2 := by | |
| simp only [div_eq_mul_inv, mul_add, add_mul, Finset.sum_add_distrib, | |
| Finset.mul_sum, Finset.sum_mul] | |
| _ = Ξ½.weight e := by | |
| change Ξ½.weight e * (rowSquareMass f (left e) + rowSquareMass f (right e)) / 2 = _ | |
| rw [hrow, hrow] | |
| ring | |
| simp_rw [he] | |
| exact Ξ½.normalized | |
| omit [Fintype V] in | |
| theorem pairGatedCorrelation_eq_energy (Ξ½ : FiniteDistribution E) (left right : E β V) | |
| (R : E β A β A β Bool) (a : V β Ξ© β A) (f : V β Ξ© β β) : | |
| Analytic.gatedCorrelation (fun p : E Γ Ξ© => Ξ½.weight p.1) | |
| (fun p => f (left p.1) p.2) (fun p => f (right p.1) p.2) | |
| (fun p => R p.1 (a (left p.1) p.2) (a (right p.1) p.2)) = | |
| pairEnergy Ξ½ left right R a f := by | |
| simp only [Analytic.gatedCorrelation, pairEnergy, FiniteDistribution.expectation, | |
| Fintype.sum_prod_type, Finset.mul_sum, mul_ite, mul_zero, mul_assoc] | |
| omit [Fintype V] in | |
| theorem pairGatedMinimum_eq_overlap (Ξ½ : FiniteDistribution E) (left right : E β V) | |
| (R : E β A β A β Bool) (a : V β Ξ© β A) (f : V β Ξ© β β) : | |
| Analytic.gatedMinimum (fun p : E Γ Ξ© => Ξ½.weight p.1) | |
| (fun p => f (left p.1) p.2) (fun p => f (right p.1) p.2) | |
| (fun p => R p.1 (a (left p.1) p.2) (a (right p.1) p.2)) = | |
| pairOverlap Ξ½ left right R a f := by | |
| simp only [Analytic.gatedMinimum, pairOverlap, FiniteDistribution.expectation, | |
| Fintype.sum_prod_type, Finset.mul_sum, mul_ite, mul_zero] | |
| omit [Fintype V] in | |
| theorem pairEnergy_le_one_of_unit_rows (Ξ½ : FiniteDistribution E) (left right : E β V) | |
| (R : E β A β A β Bool) (a : V β Ξ© β A) (f : V β Ξ© β β) | |
| (hrow : β v, rowSquareMass f v = 1) : pairEnergy Ξ½ left right R a f β€ 1 := by | |
| have h := Analytic.gatedCorrelation_le_mass (fun p : E Γ Ξ© => Ξ½.weight p.1) | |
| (fun p => f (left p.1) p.2) (fun p => f (right p.1) p.2) | |
| (fun p => R p.1 (a (left p.1) p.2) (a (right p.1) p.2)) | |
| (fun p => Ξ½.nonnegative p.1) | |
| rw [pairGatedCorrelation_eq_energy, pairQuadraticMass_eq_one Ξ½ left right f hrow] at h | |
| exact h | |
| omit [Fintype V] in | |
| theorem pairOverlap_ge_energy (Ξ½ : FiniteDistribution E) (left right : E β V) | |
| (R : E β A β A β Bool) (a : V β Ξ© β A) (f : V β Ξ© β β) | |
| (hf : β v Ο, 0 β€ f v Ο) (hrow : β v, rowSquareMass f v = 1) : | |
| 1 - Real.sqrt (2 * (1 - pairEnergy Ξ½ left right R a f)) β€ | |
| pairOverlap Ξ½ left right R a f := by | |
| have h := Analytic.gatedMinimum_unit_mass (fun p : E Γ Ξ© => Ξ½.weight p.1) | |
| (fun p => f (left p.1) p.2) (fun p => f (right p.1) p.2) | |
| (fun p => R p.1 (a (left p.1) p.2) (a (right p.1) p.2)) | |
| (fun p => Ξ½.nonnegative p.1) (fun p => hf (left p.1) p.2) | |
| (fun p => hf (right p.1) p.2) (pairQuadraticMass_eq_one Ξ½ left right f hrow) | |
| rw [pairGatedCorrelation_eq_energy, pairGatedMinimum_eq_overlap] at h | |
| exact h | |
| end | |
| end DFVSGames.Repetition | |
| namespace DFVSGames.Foundations.CorrelatedSampling | |
| def firstAccepted {Ο : Type*} (accept : Ο β Bool) : List Ο β Option Ο | |
| | [] => none | |
| | proposal :: rest => | |
| if accept proposal then some proposal else firstAccepted accept rest | |
| theorem first_union_common {Ο : Type*} (left right : Ο β Bool) | |
| (proposals : List Ο) (proposal : Ο) | |
| (hfirst : firstAccepted (fun s => left s || right s) proposals = some proposal) | |
| (hleft : left proposal = true) (hright : right proposal = true) : | |
| firstAccepted left proposals = some proposal β§ | |
| firstAccepted right proposals = some proposal := by | |
| induction proposals with | |
| | nil => simp [firstAccepted] at hfirst | |
| | cons head tail ih => | |
| by_cases hl : left head = true | |
| Β· have heq : head = proposal := by | |
| simpa [firstAccepted, hl] using hfirst | |
| subst head | |
| simp [firstAccepted, hleft, hright] | |
| Β· by_cases hr : right head = true | |
| Β· have heq : head = proposal := by | |
| simpa [firstAccepted, hl, hr] using hfirst | |
| subst head | |
| exact False.elim (hl hleft) | |
| Β· have htail : firstAccepted (fun s => left s || right s) tail = some proposal := by | |
| simpa [firstAccepted, hl, hr] using hfirst | |
| simpa [firstAccepted, hl, hr] using ih htail | |
| def thresholdSample {Ξ± : Type*} (mass : Ξ± β Nat) (proposals : List (Ξ± Γ Nat)) : | |
| Option Ξ± := | |
| (firstAccepted (fun s => decide (s.2 < mass s.1)) proposals).map Prod.fst | |
| theorem thresholdSample_agreement {Ξ± : Type*} (left right : Ξ± β Nat) | |
| (proposals : List (Ξ± Γ Nat)) (a : Ξ±) (height : Nat) | |
| (hfirst : firstAccepted | |
| (fun s => decide (s.2 < left s.1) || decide (s.2 < right s.1)) proposals = | |
| some (a, height)) | |
| (hcommon : height < min (left a) (right a)) : | |
| thresholdSample left proposals = some a β§ | |
| thresholdSample right proposals = some a := by | |
| have h := first_union_common | |
| (fun s : Ξ± Γ Nat => decide (s.2 < left s.1)) | |
| (fun s : Ξ± Γ Nat => decide (s.2 < right s.1)) proposals (a, height) hfirst | |
| (by simpa using (lt_min_iff.mp hcommon).1) | |
| (by simpa using (lt_min_iff.mp hcommon).2) | |
| simp [thresholdSample, h.1, h.2] | |
| noncomputable section FiniteWeights | |
| variable {Ξ± : Type*} [Fintype Ξ±] | |
| def totalVariation (p q : Ξ± β β) : β := (β a, |p a - q a|) / 2 | |
| def overlapMass (p q : Ξ± β β) : β := β a, min (p a) (q a) | |
| def unionMass (p q : Ξ± β β) : β := β a, max (p a) (q a) | |
| theorem totalVariation_nonneg (p q : Ξ± β β) : 0 β€ totalVariation p q := by | |
| unfold totalVariation | |
| exact div_nonneg (Finset.sum_nonneg (fun _ _ => abs_nonneg _)) (by norm_num) | |
| theorem overlapMass_nonneg (p q : Ξ± β β) (hp : β a, 0 β€ p a) | |
| (hq : β a, 0 β€ q a) : 0 β€ overlapMass p q := by | |
| exact Finset.sum_nonneg (fun a _ => le_min (hp a) (hq a)) | |
| private theorem min_abs_identity_inline_Basic (x y : β) : 2 * min x y + |x - y| = x + y := by | |
| rcases le_total x y with h | h | |
| Β· rw [min_eq_left h, abs_of_nonpos (sub_nonpos.mpr h)] | |
| ring | |
| Β· rw [min_eq_right h, abs_of_nonneg (sub_nonneg.mpr h)] | |
| ring | |
| private theorem max_abs_identity_inline_Basic (x y : β) : 2 * max x y - |x - y| = x + y := by | |
| rcases le_total x y with h | h | |
| Β· rw [max_eq_right h, abs_of_nonpos (sub_nonpos.mpr h)] | |
| ring | |
| Β· rw [max_eq_left h, abs_of_nonneg (sub_nonneg.mpr h)] | |
| ring | |
| theorem overlapMass_eq (p q : Ξ± β β) (hp : β a, p a = 1) (hq : β a, q a = 1) : | |
| overlapMass p q = 1 - totalVariation p q := by | |
| have h := Finset.sum_congr (sβ := Finset.univ) (sβ := Finset.univ) rfl | |
| (fun a _ => min_abs_identity_inline_Basic (p a) (q a)) | |
| simp only [Finset.sum_add_distrib, β Finset.mul_sum, hp, hq] at h | |
| unfold overlapMass totalVariation | |
| linarith | |
| theorem unionMass_eq (p q : Ξ± β β) (hp : β a, p a = 1) (hq : β a, q a = 1) : | |
| unionMass p q = 1 + totalVariation p q := by | |
| have h := Finset.sum_congr (sβ := Finset.univ) (sβ := Finset.univ) rfl | |
| (fun a _ => max_abs_identity_inline_Basic (p a) (q a)) | |
| simp only [Finset.sum_sub_distrib, Finset.sum_add_distrib, β Finset.mul_sum, hp, hq] at h | |
| unfold unionMass totalVariation | |
| linarith | |
| theorem totalVariation_le_one (p q : Ξ± β β) (hp : β a, 0 β€ p a) | |
| (hq : β a, 0 β€ q a) (hpsum : β a, p a = 1) (hqsum : β a, q a = 1) : | |
| totalVariation p q β€ 1 := by | |
| have h := overlapMass_nonneg p q hp hq | |
| rw [overlapMass_eq p q hpsum hqsum] at h | |
| linarith | |
| theorem overlap_union_ratio (p q : Ξ± β β) | |
| (hp : β a, p a = 1) (hq : β a, q a = 1) : | |
| overlapMass p q / unionMass p q = | |
| (1 - totalVariation p q) / (1 + totalVariation p q) := by | |
| rw [overlapMass_eq p q hp hq, unionMass_eq p q hp hq] | |
| theorem overlap_union_ratio_lower_bound (p q : Ξ± β β) | |
| (hp : β a, p a = 1) (hq : β a, q a = 1) : | |
| 1 - 2 * totalVariation p q β€ overlapMass p q / unionMass p q := by | |
| rw [overlap_union_ratio p q hp hq] | |
| have htv := totalVariation_nonneg p q | |
| have hden : 0 < 1 + totalVariation p q := by linarith | |
| apply (le_div_iffβ hden).2 | |
| nlinarith [sq_nonneg (totalVariation p q)] | |
| theorem first_union_disagreement_upper_bound (p q : Ξ± β β) | |
| (hp : β a, p a = 1) (hq : β a, q a = 1) : | |
| 1 - overlapMass p q / unionMass p q β€ 2 * totalVariation p q := by | |
| linarith [overlap_union_ratio_lower_bound p q hp hq] | |
| end FiniteWeights | |
| noncomputable section | |
| variable {Ο : Type*} [Fintype Ο] | |
| def eventMass (w : Ο β β) (event : Ο β Bool) : β := | |
| β s, if event s then w s else 0 | |
| theorem eventMass_nonneg (w : Ο β β) (event : Ο β Bool) (hw : β s, 0 β€ w s) : | |
| 0 β€ eventMass w event := by | |
| apply Finset.sum_nonneg | |
| intro s _ | |
| split <;> simp_all | |
| theorem eventMass_complement (w : Ο β β) (event : Ο β Bool) | |
| (hw : β s, w s = 1) : | |
| eventMass w event + eventMass w (fun s => !(event s)) = 1 := by | |
| unfold eventMass | |
| rw [β Finset.sum_add_distrib] | |
| calc | |
| β s, ((if event s then w s else 0) + (if !event s then w s else 0)) = β s, w s := by | |
| apply Finset.sum_congr rfl | |
| intro s _ | |
| cases event s <;> simp | |
| _ = 1 := hw | |
| def geometricMass (r : β) : Nat β β | |
| | 0 => 0 | |
| | n + 1 => 1 + r * geometricMass r n | |
| theorem geometricMass_nonneg (r : β) (hr : 0 β€ r) (n : Nat) : | |
| 0 β€ geometricMass r n := by | |
| induction n with | |
| | zero => simp [geometricMass] | |
| | succ n ih => exact add_nonneg (by norm_num) (mul_nonneg hr ih) | |
| theorem geometricMass_identity (r : β) (n : Nat) : | |
| (1 - r) * geometricMass r n = 1 - r ^ n := by | |
| induction n with | |
| | zero => simp [geometricMass] | |
| | succ n ih => | |
| simp only [geometricMass, pow_succ] | |
| calc | |
| (1 - r) * (1 + r * geometricMass r n) = | |
| (1 - r) + r * ((1 - r) * geometricMass r n) := by ring | |
| _ = 1 - r ^ n * r := by rw [ih]; ring | |
| def firstHitWeight (w : Ο β β) (accept : Ο β Bool) : Nat β Option Ο β β | |
| | 0, none => 1 | |
| | 0, some _ => 0 | |
| | n + 1, none => eventMass w (fun s => !(accept s)) * firstHitWeight w accept n none | |
| | n + 1, some s => | |
| (if accept s then w s else 0) + | |
| eventMass w (fun s => !(accept s)) * firstHitWeight w accept n (some s) | |
| theorem firstHitWeight_nonneg (w : Ο β β) (accept : Ο β Bool) | |
| (hw : β s, 0 β€ w s) (n : Nat) (output : Option Ο) : | |
| 0 β€ firstHitWeight w accept n output := by | |
| induction n generalizing output with | |
| | zero => cases output <;> simp [firstHitWeight] | |
| | succ n ih => | |
| have hr := eventMass_nonneg w (fun s => !(accept s)) hw | |
| cases output with | |
| | none => exact mul_nonneg hr (ih none) | |
| | some s => | |
| apply add_nonneg | |
| Β· split <;> simp_all | |
| Β· exact mul_nonneg hr (ih (some s)) | |
| theorem firstHitWeight_none (w : Ο β β) (accept : Ο β Bool) (n : Nat) : | |
| firstHitWeight w accept n none = eventMass w (fun s => !(accept s)) ^ n := by | |
| induction n with | |
| | zero => simp [firstHitWeight] | |
| | succ n ih => simp [firstHitWeight, ih, pow_succ, mul_comm] | |
| theorem firstHitWeight_some (w : Ο β β) (accept : Ο β Bool) (n : Nat) (s : Ο) : | |
| firstHitWeight w accept n (some s) = | |
| (if accept s then w s else 0) * | |
| geometricMass (eventMass w (fun s => !(accept s))) n := by | |
| induction n with | |
| | zero => simp [firstHitWeight, geometricMass] | |
| | succ n ih => | |
| rw [firstHitWeight, geometricMass, ih] | |
| ring | |
| theorem firstHitWeight_normalized (w : Ο β β) (accept : Ο β Bool) | |
| (hw : β s, w s = 1) (n : Nat) : β output, firstHitWeight w accept n output = 1 := by | |
| rw [Fintype.sum_option, firstHitWeight_none] | |
| simp_rw [firstHitWeight_some] | |
| rw [β Finset.sum_mul] | |
| change eventMass w (fun s => !(accept s)) ^ n + | |
| eventMass w accept * geometricMass (eventMass w (fun s => !(accept s))) n = 1 | |
| have hc := eventMass_complement w accept hw | |
| have hg := geometricMass_identity (eventMass w (fun s => !(accept s))) n | |
| have ha : eventMass w accept = 1 - eventMass w (fun s => !(accept s)) := by linarith | |
| rw [ha, hg] | |
| ring | |
| def goodFirstMass (w : Ο β β) (accept good : Ο β Bool) (n : Nat) : β := | |
| β s, if good s then firstHitWeight w accept n (some s) else 0 | |
| theorem goodFirstMass_eq (w : Ο β β) (accept good : Ο β Bool) (n : Nat) : | |
| goodFirstMass w accept good n = | |
| eventMass w (fun s => accept s && good s) * | |
| geometricMass (eventMass w (fun s => !(accept s))) n := by | |
| unfold goodFirstMass eventMass | |
| rw [Finset.sum_mul] | |
| apply Finset.sum_congr rfl | |
| intro s _ | |
| rw [firstHitWeight_some] | |
| cases ha : accept s <;> cases hg : good s <;> simp [ha, hg, eventMass] | |
| theorem goodFirstMass_exact (w : Ο β β) (accept good : Ο β Bool) | |
| (hw : β s, w s = 1) (ha : eventMass w accept β 0) (n : Nat) : | |
| goodFirstMass w accept good n = | |
| eventMass w (fun s => accept s && good s) / eventMass w accept * | |
| (1 - eventMass w (fun s => !(accept s)) ^ n) := by | |
| rw [goodFirstMass_eq] | |
| have hc := eventMass_complement w accept hw | |
| have hg := geometricMass_identity (eventMass w (fun s => !(accept s))) n | |
| have hgeom : eventMass w accept * | |
| geometricMass (eventMass w (fun s => !(accept s))) n = | |
| 1 - eventMass w (fun s => !(accept s)) ^ n := by | |
| have heq : eventMass w accept = 1 - eventMass w (fun s => !(accept s)) := by linarith | |
| rw [heq, hg] | |
| rw [β hgeom] | |
| field_simp | |
| theorem commonMass_le_acceptMass (w : Ο β β) (accept good : Ο β Bool) | |
| (hw : β s, 0 β€ w s) : | |
| eventMass w (fun s => accept s && good s) β€ eventMass w accept := by | |
| apply Finset.sum_le_sum | |
| intro s _ | |
| cases ha : accept s <;> cases hg : good s <;> simp [ha, hg, hw s] | |
| theorem goodFirstMass_lower_bound (w : Ο β β) (accept good : Ο β Bool) | |
| (hw : β s, 0 β€ w s) (hw_sum : β s, w s = 1) | |
| (ha : 0 < eventMass w accept) (n : Nat) : | |
| eventMass w (fun s => accept s && good s) / eventMass w accept - | |
| eventMass w (fun s => !(accept s)) ^ n β€ goodFirstMass w accept good n := by | |
| rw [goodFirstMass_exact w accept good hw_sum (ne_of_gt ha) n] | |
| have hratio : eventMass w (fun s => accept s && good s) / eventMass w accept β€ 1 := by | |
| apply (div_le_one ha).2 | |
| exact commonMass_le_acceptMass w accept good hw | |
| have htail : 0 β€ eventMass w (fun s => !(accept s)) ^ n := | |
| pow_nonneg (eventMass_nonneg w (fun s => !(accept s)) hw) n | |
| nlinarith | |
| end | |
| end DFVSGames.Foundations.CorrelatedSampling | |
| end OAI | |