Download data/lean/OAI/Algebra/DepthFive/CircuitRankAssembly.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 8.06 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Algebra/DepthFive/CircuitRankAssembly.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Algebra/DepthFive/CircuitRankAssembly.lean
-
curl -L -o CircuitRankAssembly.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Algebra/DepthFive/CircuitRankAssembly.lean
8.06 kB
| import OAI.Algebra.DepthFive.GateSums | |
| namespace OAI | |
| open scoped BigOperators | |
| noncomputable section | |
| namespace Problem335 | |
| /-- Finite subadditivity, with no assumptions on the individual summands. -/ | |
| theorem measure_finset_sum_le {A ΞΉ : Type*} [AddCommMonoid A] | |
| (R : A β β) (hzero : R 0 = 0) | |
| (hadd : β x y, R (x + y) β€ R x + R y) | |
| (s : Finset ΞΉ) (f : ΞΉ β A) : | |
| R (β j β s, f j) β€ β j β s, R (f j) := by | |
| classical | |
| induction s using Finset.induction with | |
| | empty => simp [hzero] | |
| | @insert j s hj ih => | |
| rw [Finset.sum_insert hj, Finset.sum_insert hj] | |
| exact (hadd _ _).trans (add_le_add le_rfl ih) | |
| /-- Scalar weighting cannot increase a subadditive rank-like measure. -/ | |
| theorem measure_weighted_sum_le {K Ο ΞΉ : Type*} [CommSemiring K] | |
| (R : MvPolynomial Ο K β β) (hzero : R 0 = 0) | |
| (hadd : β x y, R (x + y) β€ R x + R y) | |
| (hscale : β a p, R (MvPolynomial.C a * p) β€ R p) | |
| (s : Finset ΞΉ) (a : ΞΉ β K) (p : ΞΉ β MvPolynomial Ο K) : | |
| R (β j β s, MvPolynomial.C (a j) * p j) β€ β j β s, R (p j) := by | |
| exact (measure_finset_sum_le R hzero hadd s _).trans | |
| (Finset.sum_le_sum (fun j _ => hscale (a j) (p j))) | |
| /-- Expand one selected factor and leave all other occurrences unchanged. | |
| This is the algebraic step behind the high-degree-factor case: in particular, | |
| other occurrences of the very same middle gate are not expanded. -/ | |
| theorem measure_one_factor_expansion_le {K Ο ΞΉ : Type*} [CommSemiring K] | |
| (R : MvPolynomial Ο K β β) (hzero : R 0 = 0) | |
| (hadd : β x y, R (x + y) β€ R x + R y) | |
| (hscale : β a p, R (MvPolynomial.C a * p) β€ R p) | |
| (s : Finset ΞΉ) (a : ΞΉ β K) (p : ΞΉ β MvPolynomial Ο K) | |
| (before after : MvPolynomial Ο K) : | |
| R (before * (β j β s, MvPolynomial.C (a j) * p j) * after) β€ | |
| β j β s, R (before * p j * after) := by | |
| have heq : | |
| before * (β j β s, MvPolynomial.C (a j) * p j) * after = | |
| β j β s, MvPolynomial.C (a j) * (before * p j * after) := by | |
| rw [Finset.mul_sum, Finset.sum_mul] | |
| apply Finset.sum_congr rfl | |
| intro j hj | |
| ring | |
| rw [heq] | |
| exact measure_weighted_sum_le R hzero hadd hscale s a _ | |
| /-- Only predecessors with nonzero aggregate coefficient need a bound. | |
| This matters for homogeneous circuits, since inactive gates can have arbitrary | |
| formal degree. -/ | |
| theorem measure_weighted_sum_le_card_mul {K Ο ΞΉ : Type*} [CommSemiring K] | |
| (R : MvPolynomial Ο K β β) (hzero : R 0 = 0) | |
| (hadd : β x y, R (x + y) β€ R x + R y) | |
| (hscale : β a p, R (MvPolynomial.C a * p) β€ R p) | |
| (s : Finset ΞΉ) (a : ΞΉ β K) (p : ΞΉ β MvPolynomial Ο K) | |
| (B : β) (hB : 0 β€ B) | |
| (hbound : β j β s, a j β 0 β R (p j) β€ B) : | |
| R (β j β s, MvPolynomial.C (a j) * p j) β€ (s.card : β) * B := by | |
| calc | |
| R (β j β s, MvPolynomial.C (a j) * p j) β€ | |
| β j β s, R (MvPolynomial.C (a j) * p j) := | |
| measure_finset_sum_le R hzero hadd s _ | |
| _ β€ β j β s, B := by | |
| apply Finset.sum_le_sum | |
| intro j hj | |
| by_cases ha : a j = 0 | |
| Β· simpa [ha, hzero] using hB | |
| Β· exact (hscale _ _).trans (hbound j hj ha) | |
| _ = (s.card : β) * B := by simp | |
| /-- A uniform bound on active output predecessors costs the number of upper | |
| product gates, never the number of output wires. -/ | |
| theorem circuit_measure_le_upperCount_mul {K : Type*} [CommSemiring K] {n : β} | |
| (c : Depth5Circuit K n) | |
| (R : MvPolynomial (Fin n Γ Fin n Γ Fin n) K β β) (hzero : R 0 = 0) | |
| (hadd : β x y, R (x + y) β€ R x + R y) | |
| (hscale : β a p, R (MvPolynomial.C a * p) β€ R p) | |
| (B : β) (hB : 0 β€ B) | |
| (hbound : β j, gateCoefficient c.outputInputs j β 0 β R (upperValue c j) β€ B) : | |
| R (circuitValue c) β€ (c.upperCount : β) * B := by | |
| rw [circuitValue_eq_sum] | |
| simpa using measure_weighted_sum_le_card_mul R hzero hadd hscale | |
| Finset.univ (gateCoefficient c.outputInputs) (upperValue c) B hB | |
| (fun j _ => hbound j) | |
| /-- Expanding one middle-gate occurrence costs at most the number of lower | |
| product gates. All other occurrences, including shared copies of the selected | |
| gate, are retained as factors in `before` and `after`. -/ | |
| theorem upper_measure_le_lowerCount_mul_of_split | |
| {K : Type*} [CommSemiring K] {n : β} (c : Depth5Circuit K n) | |
| (R : MvPolynomial (Fin n Γ Fin n Γ Fin n) K β β) (hzero : R 0 = 0) | |
| (hadd : β x y, R (x + y) β€ R x + R y) | |
| (hscale : β a p, R (MvPolynomial.C a * p) β€ R p) | |
| (u : Fin c.upperCount) (j : Fin c.middleCount) | |
| (before after : List (Fin c.middleCount)) | |
| (hsplit : c.upperInputs u = before ++ j :: after) | |
| (B : β) (hB : 0 β€ B) | |
| (hbound : β l, gateCoefficient (c.middleInputs j) l β 0 β | |
| R ((before.map (middleValue c)).prod * lowerValue c l * | |
| (after.map (middleValue c)).prod) β€ B) : | |
| R (upperValue c u) β€ (c.lowerCount : β) * B := by | |
| classical | |
| have heq : upperValue c u = | |
| β l : Fin c.lowerCount, | |
| MvPolynomial.C (gateCoefficient (c.middleInputs j) l) * | |
| ((before.map (middleValue c)).prod * lowerValue c l * | |
| (after.map (middleValue c)).prod) := by | |
| unfold upperValue | |
| rw [hsplit] | |
| simp only [List.map_append, List.map_cons, List.prod_append, List.prod_cons] | |
| rw [middleValue_eq_sum, Finset.sum_mul, Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro l hl | |
| ring | |
| rw [heq] | |
| simpa using measure_weighted_sum_le_card_mul R hzero hadd hscale | |
| Finset.univ (gateCoefficient (c.middleInputs j)) | |
| (fun l => (before.map (middleValue c)).prod * lowerValue c l * | |
| (after.map (middleValue c)).prod) B hB (fun l _ => hbound l) | |
| /-- The gate-count assembly step in the depth-five rank upper bound. | |
| Each active upper product is either bounded directly, or one occurrence can | |
| be expanded into active lower products with the same bound. -/ | |
| theorem circuit_measure_le_size_sq_mul_of_low_or_split | |
| {K : Type*} [CommSemiring K] {n : β} (c : Depth5Circuit K n) | |
| (R : MvPolynomial (Fin n Γ Fin n Γ Fin n) K β β) (hzero : R 0 = 0) | |
| (hadd : β x y, R (x + y) β€ R x + R y) | |
| (hscale : β a p, R (MvPolynomial.C a * p) β€ R p) | |
| (B : β) (hB : 0 β€ B) | |
| (hupper : β u, gateCoefficient c.outputInputs u β 0 β | |
| R (upperValue c u) β€ B β¨ | |
| β (j : Fin c.middleCount) (before after : List (Fin c.middleCount)), | |
| c.upperInputs u = before ++ j :: after β§ | |
| β l, gateCoefficient (c.middleInputs j) l β 0 β | |
| R ((before.map (middleValue c)).prod * lowerValue c l * | |
| (after.map (middleValue c)).prod) β€ B) : | |
| R (circuitValue c) β€ (circuitSize c : β) ^ 2 * B := by | |
| have honeNat : 1 β€ circuitSize c := by unfold circuitSize; omega | |
| have hlowerNat : c.lowerCount β€ circuitSize c := by unfold circuitSize; omega | |
| have hupperNat : c.upperCount β€ circuitSize c := by unfold circuitSize; omega | |
| have hone : (1 : β) β€ circuitSize c := by exact_mod_cast honeNat | |
| have hlower : (c.lowerCount : β) β€ circuitSize c := by exact_mod_cast hlowerNat | |
| have hupperCount : (c.upperCount : β) β€ circuitSize c := by exact_mod_cast hupperNat | |
| have hSB : 0 β€ (circuitSize c : β) * B := mul_nonneg (Nat.cast_nonneg _) hB | |
| have hgates : β u, gateCoefficient c.outputInputs u β 0 β | |
| R (upperValue c u) β€ (circuitSize c : β) * B := by | |
| intro u hu | |
| rcases hupper u hu with hlow | β¨j, before, after, hsplit, hboundβ© | |
| Β· exact hlow.trans (by nlinarith) | |
| Β· exact (upper_measure_le_lowerCount_mul_of_split c R hzero hadd hscale | |
| u j before after hsplit B hB hbound).trans (mul_le_mul_of_nonneg_right hlower hB) | |
| calc | |
| R (circuitValue c) β€ (c.upperCount : β) * ((circuitSize c : β) * B) := | |
| circuit_measure_le_upperCount_mul c R hzero hadd hscale _ hSB hgates | |
| _ β€ (circuitSize c : β) * ((circuitSize c : β) * B) := | |
| mul_le_mul_of_nonneg_right hupperCount hSB | |
| _ = (circuitSize c : β) ^ 2 * B := by ring | |
| end Problem335 | |
| end | |
| end OAI | |