Download data/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveStateExpansion.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.07 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveStateExpansion.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveStateExpansion.lean
-
curl -L -o ActiveStateExpansion.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/TwoPoint/Bounds/ActiveStateExpansion.lean
6.07 kB
| import OAI.NumberTheory.TwoPoint.Circuits.CircuitEncoding | |
| import OAI.NumberTheory.TwoPoint.Bounds.ScalarComparison | |
| import Mathlib.Data.Nat.Choose.Bounds | |
| namespace OAI | |
| /-! Exact active-prime states give small scalar expansions after the | |
| degree truncation. All absent prime tests remain in each conjunction. -/ | |
| namespace TwoPointCorrelations | |
| open Finset | |
| open scoped Classical | |
| def activeState {n : β} (x : BooleanCube n) : Finset (Fin n) := | |
| univ.filter (fun i => x i = true) | |
| def boundedActiveStates (n M : β) : Finset (Finset (Fin n)) := | |
| univ.powerset.filter (fun S => S.card β€ M) | |
| lemma mem_boundedActiveStates {n M : β} {S : Finset (Fin n)} : | |
| S β boundedActiveStates n M β S.card β€ M := by | |
| simp only [boundedActiveStates, mem_filter, mem_powerset, subset_univ, true_and] | |
| lemma boundedActiveStates_card (n M : β) : | |
| (boundedActiveStates n M).card β€ (M + 1) * (n + 1) ^ M := by | |
| have he : boundedActiveStates n M = | |
| (range (M + 1)).biUnion (fun r => univ.powersetCard r) := by | |
| ext S | |
| simp only [mem_boundedActiveStates, mem_biUnion, mem_range, mem_powersetCard, | |
| subset_univ, true_and] | |
| constructor | |
| Β· intro hS | |
| exact β¨S.card, by omega, rflβ© | |
| Β· rintro β¨r, hr, heβ© | |
| omega | |
| rw [he] | |
| apply (card_biUnion_le).trans | |
| calc | |
| (β r β range (M + 1), (univ.powersetCard r : Finset (Finset (Fin n))).card) = | |
| β r β range (M + 1), n.choose r := by | |
| simp only [card_powersetCard, card_univ, Fintype.card_fin] | |
| _ β€ β _r β range (M + 1), (n + 1) ^ M := by | |
| apply sum_le_sum | |
| intro r hr | |
| exact (Nat.choose_le_pow n r).trans | |
| ((Nat.pow_le_pow_left (Nat.le_succ n) r).trans | |
| (Nat.pow_le_pow_right (by omega) (by simp only [mem_range] at hr; omega))) | |
| _ = _ := by simp | |
| def activeStateCircuit {n : β} (S : Finset (Fin n)) : AC0Circuit n := | |
| .andGate (fun i : Fin n => .literal i (decide (i β S))) | |
| lemma activeStateCircuit_eval {n : β} (S : Finset (Fin n)) (x : BooleanCube n) : | |
| (activeStateCircuit S).eval x = true β activeState x = S := by | |
| simp only [activeStateCircuit, AC0Circuit.eval, decide_eq_true_eq] | |
| constructor | |
| Β· intro h | |
| ext i | |
| have hi := h i | |
| by_cases hs : i β S <;> cases hx : x i <;> | |
| simp_all [activeState] | |
| Β· intro h i | |
| have hi : x i = true β i β S := by | |
| rw [β h] | |
| simp only [activeState, mem_filter, mem_univ, true_and] | |
| by_cases hs : i β S <;> cases hx : x i <;> | |
| simp_all [activeState] | |
| lemma activeStateCircuit_depth {n : β} (S : Finset (Fin n)) : | |
| (activeStateCircuit S).depth β€ 1 := by | |
| simp [activeStateCircuit, AC0Circuit.depth] | |
| lemma activeStateCircuit_size {n : β} (S : Finset (Fin n)) : | |
| (activeStateCircuit S).size = 1 + n := by | |
| simp [activeStateCircuit, AC0Circuit.size] | |
| theorem activeState_scalar_expansion {n : β} (M : β) | |
| (f : Finset (Fin n) β β) (x : BooleanCube n) : | |
| (if (activeState x).card β€ M then f (activeState x) else 0) = | |
| β S β boundedActiveStates n M, f S * (activeStateCircuit S).indicator x := by | |
| simp only [AC0Circuit.indicator] | |
| have hval (S : Finset (Fin n)) : | |
| (if (activeStateCircuit S).eval x = true then (1 : β) else 0) = | |
| if activeState x = S then 1 else 0 := by | |
| simp only [activeStateCircuit_eval] | |
| simp only [hval, mul_ite, mul_one, mul_zero] | |
| by_cases hx : (activeState x).card β€ M | |
| Β· rw [ite_eq_left hx, sum_eq_single_of_mem (activeState x) (mem_boundedActiveStates.mpr hx)] | |
| Β· simp | |
| Β· intro S _ hS | |
| exact ite_eq_right (Ne.symm hS) | |
| Β· rw [ite_eq_right hx] | |
| symm | |
| apply sum_eq_zero | |
| intro S hS | |
| apply ite_eq_right | |
| intro he | |
| exact hx (he.symm βΈ mem_boundedActiveStates.mp hS) | |
| lemma activeState_coefficient_mass {n M : β} (f : Finset (Fin n) β β) (C : β) | |
| (hf : β S β boundedActiveStates n M, |f S| β€ C) : | |
| β S β boundedActiveStates n M, |f S| β€ ((M + 1) * (n + 1) ^ M : β) * C := by | |
| by_cases hC : 0 β€ C | |
| Β· calc | |
| _ β€ β _S β boundedActiveStates n M, C := sum_le_sum hf | |
| _ = ((boundedActiveStates n M).card : β) * C := by simp | |
| _ β€ _ := mul_le_mul_of_nonneg_right (by exact_mod_cast boundedActiveStates_card n M) hC | |
| Β· have hz : β β boundedActiveStates n M := mem_boundedActiveStates.mpr (by simp) | |
| exact False.elim (hC ((abs_nonneg (f β )).trans (hf β hz))) | |
| theorem activeState_average_comparison {n : β} {Ξ± Ξ² : Type*} [Fintype Ξ±] [Fintype Ξ²] | |
| (M : β) (f : Finset (Fin n) β β) (x : Ξ± β BooleanCube n) (y : Ξ² β BooleanCube n) | |
| (C Ξ΅ : β) (hΞ΅ : 0 β€ Ξ΅) | |
| (hf : β S β boundedActiveStates n M, |f S| β€ C) | |
| (hcompare : β S β boundedActiveStates n M, | |
| |uniformAverage (fun a => (activeStateCircuit S).indicator (x a)) - | |
| uniformAverage (fun b => (activeStateCircuit S).indicator (y b))| β€ Ξ΅) : | |
| |uniformAverage (fun a => if (activeState (x a)).card β€ M then f (activeState (x a)) else 0) - | |
| uniformAverage (fun b => if (activeState (y b)).card β€ M then f (activeState (y b)) else 0)| β€ | |
| (((M + 1) * (n + 1) ^ M : β) : β) * C * Ξ΅ := by | |
| let S := boundedActiveStates n M | |
| have hrep (z : BooleanCube n) : | |
| (if (activeState z).card β€ M then f (activeState z) else 0) = | |
| β t : S, f t.val * (activeStateCircuit t.val).indicator z := by | |
| rw [activeState_scalar_expansion] | |
| exact (sum_coe_sort S (fun t => f t * (activeStateCircuit t).indicator z)).symm | |
| simp_rw [hrep] | |
| have hb := scalar_average_comparison_uniform | |
| (fun (t : S) a => (activeStateCircuit t.val).indicator (x a)) | |
| (fun (t : S) b => (activeStateCircuit t.val).indicator (y b)) | |
| (fun t : S => f t.val) Ξ΅ (fun t => hcompare t.val t.property) | |
| apply hb.trans | |
| apply mul_le_mul_of_nonneg_right _ hΞ΅ | |
| change (β t : boundedActiveStates n M, |f t.val|) β€ _ | |
| calc | |
| _ = β t β boundedActiveStates n M, |f t| := | |
| sum_coe_sort (boundedActiveStates n M) (fun t => |f t|) | |
| _ β€ _ := activeState_coefficient_mass f C hf | |
| end TwoPointCorrelations | |
| end OAI | |