math / data /lean /OAI /Combinatorics /LowSpaceSubsetSum /Representation /RepresentationHistoryCoupling.lean
Download data/lean/OAI/Combinatorics/LowSpaceSubsetSum/Representation/RepresentationHistoryCoupling.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 10.1 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/LowSpaceSubsetSum/Representation/RepresentationHistoryCoupling.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/LowSpaceSubsetSum/Representation/RepresentationHistoryCoupling.lean
-
curl -L -o RepresentationHistoryCoupling.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/LowSpaceSubsetSum/Representation/RepresentationHistoryCoupling.lean
10.1 kB
| import OAI.Combinatorics.LowSpaceSubsetSum.Separators.SeparatorSamplerCoupling | |
| import OAI.Combinatorics.LowSpaceSubsetSum.Counting.PrimeSamplerCoupling | |
| namespace OAI | |
| /-! # Bounded fresh-word sampling of the complete dependent representation trial -/ | |
| noncomputable section | |
| namespace LowSpaceSubsetSum.RepresentationSetup | |
| open scoped BigOperators | |
| attribute [local instance] Classical.propDecidable | |
| variable {n : β} (R : RepresentationSetup n) | |
| theorem factorExponents_le_n (z : Layout n) (i : Fin 3) : R.factorExponents z i β€ n := by | |
| have hs : R.halfSize β€ n := by | |
| have hm := R.orderedMixers_card z 0 | |
| have hc := Finset.card_le_univ (R.orderedMixers z 0) | |
| simp only [Fintype.card_fin] at hc | |
| omega | |
| have hf (j : Fin 3) : βR.lowExponent z jββ β€ n := | |
| Nat.floor_le_of_le ((R.lowExponent_le_halfSize z j).trans (by exact_mod_cast hs)) | |
| have h0 := hf 0 | |
| have h1 := hf 1 | |
| have h2 := hf 2 | |
| fin_cases i | |
| Β· change βR.lowExponent z 2ββ β€ n | |
| exact h2 | |
| Β· change βR.lowExponent z 1ββ - βR.lowExponent z 2ββ β€ n | |
| omega | |
| Β· change βR.lowExponent z 0ββ - βR.lowExponent z 1ββ β€ n | |
| omega | |
| def nestedCoupling (z : Layout n) : SamplerCoupling (R.PrimeSpace z) := | |
| triplePrimeCoupling n (R.factorExponents z 0) (R.factorExponents z 1) | |
| (R.factorExponents z 2) | |
| theorem nestedCoupling_uniform (z : Layout n) : | |
| (R.nestedCoupling z).idealLaw = FiniteLaw.uniform := triplePrimeCoupling_uniform _ _ _ _ | |
| theorem nestedCoupling_failure (z : Layout n) : | |
| (R.nestedCoupling z).failure β€ 3 * Real.exp (-((n : β) ^ 2 / 4)) := | |
| triplePrimeCoupling_failure (R.factorExponents_le_n z 0) | |
| (R.factorExponents_le_n z 1) (R.factorExponents_le_n z 2) | |
| def residuesCoupling {z : Layout n} (p : R.PrimeSpace z) : SamplerCoupling (R.Residues p) := by | |
| let : NeZero (prefixModulus p.val 0) := β¨(prefixModulus_pos p 0).ne'β© | |
| let : NeZero (prefixModulus p.val 1) := β¨(prefixModulus_pos p 1).ne'β© | |
| let : NeZero (prefixModulus p.val 2) := β¨(prefixModulus_pos p 2).ne'β© | |
| exact (finCoupling n (prefixModulus p.val 0)).prod | |
| ((finCoupling n (prefixModulus p.val 1)).prod (finCoupling n (prefixModulus p.val 2))) | |
| theorem residuesCoupling_uniform {z : Layout n} (p : R.PrimeSpace z) : | |
| (R.residuesCoupling p).idealLaw = FiniteLaw.uniform := by | |
| let : NeZero (prefixModulus p.val 0) := β¨(prefixModulus_pos p 0).ne'β© | |
| let : NeZero (prefixModulus p.val 1) := β¨(prefixModulus_pos p 1).ne'β© | |
| let : NeZero (prefixModulus p.val 2) := β¨(prefixModulus_pos p 2).ne'β© | |
| exact SamplerCoupling.prod_uniform _ _ (finCoupling_uniform _ _) | |
| (SamplerCoupling.prod_uniform _ _ (finCoupling_uniform _ _) (finCoupling_uniform _ _)) | |
| theorem residuesCoupling_failure {z : Layout n} (p : R.PrimeSpace z) : | |
| (R.residuesCoupling p).failure β€ 3 / (2 : β) ^ (n ^ 3) := by | |
| let : NeZero (prefixModulus p.val 0) := β¨(prefixModulus_pos p 0).ne'β© | |
| let : NeZero (prefixModulus p.val 1) := β¨(prefixModulus_pos p 1).ne'β© | |
| let : NeZero (prefixModulus p.val 2) := β¨(prefixModulus_pos p 2).ne'β© | |
| have h0 := finCoupling_failure n (prefixModulus p.val 0) | |
| have h1 := finCoupling_failure n (prefixModulus p.val 1) | |
| have h2 := finCoupling_failure n (prefixModulus p.val 2) | |
| have h12 := SamplerCoupling.prod_failure_le | |
| (finCoupling n (prefixModulus p.val 1)) (finCoupling n (prefixModulus p.val 2)) | |
| have h012 := SamplerCoupling.prod_failure_le | |
| (finCoupling n (prefixModulus p.val 0)) | |
| ((finCoupling n (prefixModulus p.val 1)).prod (finCoupling n (prefixModulus p.val 2))) | |
| change ((finCoupling n (prefixModulus p.val 0)).prod | |
| ((finCoupling n (prefixModulus p.val 1)).prod | |
| (finCoupling n (prefixModulus p.val 2)))).failure β€ _ | |
| simp only [div_eq_mul_inv, one_mul] at h0 h1 h2 β’ | |
| linarith | |
| def primeHistoryCoupling : SamplerCoupling R.PrimeHistory := | |
| R.partitionHistoryCoupling.bind (fun h => R.PrimeSpace h.1.1) | |
| (fun h => R.nestedCoupling h.1.1) | |
| def trialHistoryCoupling : SamplerCoupling R.TrialHistory := | |
| R.primeHistoryCoupling.bind (fun h => R.Residues h.2) (fun h => R.residuesCoupling h.2) | |
| def extraPrimeCoupling (z : Layout n) (hn : 100 β€ n) : | |
| SamplerCoupling (R.ExtraPrimeSpace z) := primeCoupling (R.extraPrimeParameter_range z hn).1 n | |
| theorem extraPrimeCoupling_uniform (z : Layout n) (hn : 100 β€ n) : | |
| (R.extraPrimeCoupling z hn).idealLaw = R.extraPrimeLaw z hn := | |
| primeCoupling_uniform _ _ | |
| theorem extraPrimeCoupling_failure (z : Layout n) (hn : 100 β€ n) : | |
| (R.extraPrimeCoupling z hn).failure β€ Real.exp (-((n : β) ^ 2 / 4)) := | |
| primeCoupling_failure (R.extraPrimeParameter_range z hn).1 (R.extraPrimeParameter_range z hn).2 | |
| def extraHistoryCoupling (hn : 100 β€ n) : SamplerCoupling R.ExtraTrialHistory := | |
| R.trialHistoryCoupling.bind (fun h => R.ExtraPrimeSpace h.1.1.1.1) | |
| (fun h => R.extraPrimeCoupling h.1.1.1.1 hn) | |
| def bucketHistoryCoupling (hn : 10000 β€ n) : | |
| SamplerCoupling (R.BucketTrialHistory (by omega)) := | |
| (R.extraHistoryCoupling (by omega)).bind (fun h => R.SeparatorDraws h.1.1 (by omega)) | |
| (fun h => R.separatorCoupling h.1.1 (by omega)) | |
| theorem primeHistoryCoupling_uniform : R.primeHistoryCoupling.idealLaw = R.primeLaw := by | |
| rw [primeHistoryCoupling, SamplerCoupling.bind_idealLaw, R.partitionHistoryCoupling_uniform] | |
| simp only [R.nestedCoupling_uniform, primeLaw] | |
| theorem trialHistoryCoupling_uniform : R.trialHistoryCoupling.idealLaw = R.trialLaw := by | |
| rw [trialHistoryCoupling, SamplerCoupling.bind_idealLaw, R.primeHistoryCoupling_uniform] | |
| simp only [R.residuesCoupling_uniform, trialLaw] | |
| theorem extraHistoryCoupling_uniform (hn : 100 β€ n) : | |
| (R.extraHistoryCoupling hn).idealLaw = R.extraTrialLaw hn := by | |
| rw [extraHistoryCoupling, SamplerCoupling.bind_idealLaw, R.trialHistoryCoupling_uniform] | |
| simp only [R.extraPrimeCoupling_uniform, extraTrialLaw] | |
| /-- The ideal marginal is the dependent history law, rather than the uniform | |
| law on the final sigma type. -/ | |
| theorem bucketHistoryCoupling_uniform (hn : 10000 β€ n) : | |
| (R.bucketHistoryCoupling hn).idealLaw = R.bucketTrialLaw hn := by | |
| rw [bucketHistoryCoupling, SamplerCoupling.bind_idealLaw, R.extraHistoryCoupling_uniform] | |
| simp only [R.separatorCoupling_uniform, bucketTrialLaw] | |
| def rangeCallBound (_R : RepresentationSetup n) : β := | |
| n + 3 * mixerSize n + 6 + 44 * (2 * blockHalf n 0) * 2 ^ (2 * blockHalf n 0) | |
| theorem guessHistoryCoupling_failure : | |
| R.guessHistoryCoupling.failure β€ (n + 3 : β) / (2 : β) ^ (n ^ 3) := by | |
| have h := SamplerCoupling.bind_failure_le R.layoutCoupling (fun _ => Guesses n) | |
| (fun _ => R.guessesCoupling) (3 / (2 : β) ^ (n ^ 3)) (fun _ => R.guessesCoupling_failure) | |
| change R.guessHistoryCoupling.failure β€ _ at h | |
| have h0 := R.layoutCoupling_failure | |
| push_cast | |
| simp only [add_mul, div_eq_mul_inv, add_mul] at h0 h β’ | |
| linarith | |
| theorem partitionHistoryCoupling_failure : | |
| R.partitionHistoryCoupling.failure β€ | |
| (n + 3 + 3 * mixerSize n : β) / (2 : β) ^ (n ^ 3) := by | |
| have h := SamplerCoupling.bind_failure_le R.guessHistoryCoupling (fun h => R.Partitions h.1) | |
| (fun h => R.partitionsCoupling h.1) (3 * mixerSize n / (2 : β) ^ (n ^ 3)) | |
| (fun h => R.partitionsCoupling_failure h.1) | |
| change R.partitionHistoryCoupling.failure β€ _ at h | |
| have h0 := R.guessHistoryCoupling_failure | |
| push_cast at h0 β’ | |
| simp only [div_eq_mul_inv, add_mul] at h0 h β’ | |
| linarith | |
| /-- Three low-factor prime calls and one extra-prime call; all other calls are | |
| counted explicitly from the actual permutation, guess, residue and family code. -/ | |
| theorem bucketHistoryCoupling_failure (hn : 10000 β€ n) : | |
| (R.bucketHistoryCoupling hn).failure β€ | |
| R.rangeCallBound / (2 : β) ^ (n ^ 3) + 4 * Real.exp (-((n : β) ^ 2 / 4)) := by | |
| let Ξ΄ := 1 / (2 : β) ^ (n ^ 3) | |
| let Ξ΅ := Real.exp (-((n : β) ^ 2 / 4)) | |
| have hp := SamplerCoupling.bind_failure_le R.partitionHistoryCoupling | |
| (fun h => R.PrimeSpace h.1.1) (fun h => R.nestedCoupling h.1.1) (3 * Ξ΅) | |
| (fun h => R.nestedCoupling_failure h.1.1) | |
| have hr := SamplerCoupling.bind_failure_le R.primeHistoryCoupling | |
| (fun h => R.Residues h.2) (fun h => R.residuesCoupling h.2) (3 * Ξ΄) | |
| (fun h => by simpa only [Ξ΄, div_eq_mul_inv, one_mul] using R.residuesCoupling_failure h.2) | |
| have hq := SamplerCoupling.bind_failure_le R.trialHistoryCoupling | |
| (fun h => R.ExtraPrimeSpace h.1.1.1.1) (fun h => R.extraPrimeCoupling h.1.1.1.1 (by omega)) | |
| Ξ΅ (fun h => R.extraPrimeCoupling_failure h.1.1.1.1 (by omega)) | |
| have hs := SamplerCoupling.bind_failure_le (R.extraHistoryCoupling (by omega)) | |
| (fun h => R.SeparatorDraws h.1.1 (by omega)) | |
| (fun h => R.separatorCoupling h.1.1 (by omega)) | |
| ((44 * (2 * blockHalf n 0) * 2 ^ (2 * blockHalf n 0) : β) * Ξ΄) | |
| (fun h => by simpa only [Ξ΄, div_eq_mul_inv, one_mul] using | |
| R.separatorCoupling_failure h.1.1 (by omega)) | |
| have h0 := R.partitionHistoryCoupling_failure | |
| change R.primeHistoryCoupling.failure β€ _ at hp | |
| change R.trialHistoryCoupling.failure β€ _ at hr | |
| change (R.extraHistoryCoupling (by omega)).failure β€ _ at hq | |
| change (R.bucketHistoryCoupling hn).failure β€ _ at hs | |
| dsimp only [Ξ΄, Ξ΅] at * | |
| simp only [rangeCallBound, Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_pow] | |
| push_cast at h0 hs | |
| simp only [div_eq_mul_inv, one_mul, add_mul] at h0 hp hr hq hs β’ | |
| linarith | |
| /-- Any proved ideal event transfers directly, with no conditioning on sampler success. -/ | |
| theorem bucketHistoryCoupling_event (hn : 10000 β€ n) | |
| (P : R.BucketTrialHistory (by omega) β Prop) : | |
| (R.bucketTrialLaw hn).probability P - | |
| (R.rangeCallBound / (2 : β) ^ (n ^ 3) + 4 * Real.exp (-((n : β) ^ 2 / 4))) β€ | |
| (R.bucketHistoryCoupling hn).boundedLaw.probability | |
| (fun h => β x, h = some x β§ P x) := by | |
| have h := (R.bucketHistoryCoupling hn).event_lower P | |
| rw [R.bucketHistoryCoupling_uniform hn] at h | |
| exact (sub_le_sub_left (R.bucketHistoryCoupling_failure hn) _).trans h | |
| end LowSpaceSubsetSum.RepresentationSetup | |
| end | |
| end OAI | |