Download data/lean/OAI/Combinatorics/GotsmanLinial/EdgeRecovery.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 9.46 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/GotsmanLinial/EdgeRecovery.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/GotsmanLinial/EdgeRecovery.lean
-
curl -L -o EdgeRecovery.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/GotsmanLinial/EdgeRecovery.lean
9.46 kB
| import OAI.Combinatorics.GotsmanLinial.HilbertSchmidt | |
| import OAI.Combinatorics.GotsmanLinial.SignParity | |
| import Mathlib.Algebra.Order.BigOperators.Group.Finset | |
| import Mathlib.Data.Fintype.BigOperators | |
| import Mathlib.Tactic.Linarith | |
| import Mathlib.Tactic.NormNum | |
| import Mathlib.Tactic.Ring | |
| namespace OAI | |
| /-! | |
| # Recovering constant-sign edges from grading energy | |
| The counting argument is separated from construction of the grading matrix. | |
| Its hypotheses are explicit entrywise, total-energy, and distance-energy facts. | |
| No edge-count or anticommutator conclusion is assumed. | |
| -/ | |
| open scoped BigOperators | |
| namespace LeanBlast.GotsmanLinial | |
| variable {Ξ± ΞΉ : Type*} [Fintype Ξ±] [Fintype ΞΉ] | |
| /-- A finite distance layer, also useful for weights indexed by ordered pairs. -/ | |
| def distanceShell (d : Ξ± β β) (k : β) : Finset Ξ± := | |
| Finset.univ.filter fun a => d a = k | |
| @[simp] theorem mem_distanceShell (d : Ξ± β β) (k : β) (a : Ξ±) : | |
| a β distanceShell d k β d a = k := by | |
| simp [distanceShell] | |
| /-- Pointwise distance counting: distance-zero entries are the only possible | |
| source of a deficit between total mass and distance-weighted mass. -/ | |
| theorem twice_mass_sub_neighbor_le_distance (d : Ξ± β β) (w : Ξ± β β) | |
| (hw : β a, 0 β€ w a) : | |
| 2 * (β a, w a) - (β a β distanceShell d 1, w a) β€ | |
| 2 * (β a β distanceShell d 0, w a) + β a, (d a : β) * w a := by | |
| have hpoint : β a, | |
| 2 * w a - (if d a = 1 then w a else 0) β€ | |
| 2 * (if d a = 0 then w a else 0) + (d a : β) * w a := by | |
| intro a | |
| by_cases h0 : d a = 0 | |
| Β· simp [h0] | |
| by_cases h1 : d a = 1 | |
| Β· rw [ite_eq_left h1, ite_eq_right h0, h1] | |
| norm_num | |
| linarith | |
| have h2 : 2 β€ d a := by omega | |
| have h2R : (2 : β) β€ (d a : β) := by exact_mod_cast h2 | |
| simpa only [ite_eq_right h0, ite_eq_right h1, sub_zero, mul_zero, zero_add] using | |
| mul_le_mul_of_nonneg_right h2R (hw a) | |
| have hsum := Finset.sum_le_sum (s := Finset.univ) fun a _ => hpoint a | |
| simpa only [distanceShell, Finset.sum_filter, Finset.sum_sub_distrib, | |
| Finset.sum_add_distrib, Finset.mul_sum] using hsum | |
| /-- The sum of the nonnegative neighbor deficits is controlled by twice the | |
| distance-zero energy. Equivalently, `Aβ + F β€ 2 Aβ`. -/ | |
| theorem neighbor_deficit_le_twice_zero_mass (d : Ξ± β β) (w : Ξ± β β) | |
| (hw : β a, 0 β€ w a) | |
| (htotal : (β a, w a) = ((distanceShell d 1).card : β) / 4) | |
| (henergy : (β a, (d a : β) * w a) β€ β a, w a) : | |
| (β a β distanceShell d 1, ((1 / 4 : β) - w a)) β€ | |
| 2 * (β a β distanceShell d 0, w a) := by | |
| have hpoint := twice_mass_sub_neighbor_le_distance d w hw | |
| rw [Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul] | |
| linarith | |
| /-- Restricting the nonnegative deficits to any chosen neighbor subset gives | |
| the counting bound needed before applying the anticommutator identity. -/ | |
| theorem selected_neighbor_card_le_eight_mass (d : Ξ± β β) (w : Ξ± β β) | |
| (s : Finset Ξ±) (hs : s β distanceShell d 1) | |
| (hw : β a, 0 β€ w a) | |
| (hcap : β a β distanceShell d 1, w a β€ (1 / 4 : β)) | |
| (htotal : (β a, w a) = ((distanceShell d 1).card : β) / 4) | |
| (henergy : (β a, (d a : β) * w a) β€ β a, w a) : | |
| (s.card : β) β€ 8 * ((β a β distanceShell d 0, w a) + β a β s, w a) := by | |
| have hrestrict := Finset.sum_le_sum_of_subset_of_nonneg hs | |
| (fun a ha _ => sub_nonneg.mpr (hcap a ha)) | |
| have hdeficit := neighbor_deficit_le_twice_zero_mass d w hw htotal henergy | |
| have hmass : 0 β€ β a β s, w a := Finset.sum_nonneg fun a _ => hw a | |
| have hselected : (β a β s, ((1 / 4 : β) - w a)) = | |
| (s.card : β) / 4 - β a β s, w a := by | |
| rw [Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul] | |
| ring | |
| rw [hselected] at hrestrict | |
| linarith | |
| /-- On an equal-sign pair the anticommutator has four times the squared entry | |
| mass. The diagonal is included as an equal-sign pair. -/ | |
| theorem anticommutator_entry_sq_of_same_sign [DecidableEq ΞΉ] | |
| (M : Matrix ΞΉ ΞΉ β) (h : ΞΉ β β) (hh : β i, h i = 1 β¨ h i = -1) | |
| (i j : ΞΉ) (hij : h i = h j) : | |
| β(M * Matrix.diagonal (fun i => (h i : β)) + | |
| Matrix.diagonal (fun i => (h i : β)) * M) i jβ ^ 2 = | |
| 4 * βM i jβ ^ 2 := by | |
| simp only [Matrix.add_apply, Matrix.mul_diagonal, Matrix.diagonal_mul] | |
| rw [β hij] | |
| have hfactor : M i j * (h i : β) + (h i : β) * M i j = | |
| (2 : β) * (h i : β) * M i j := by ring | |
| rw [hfactor] | |
| have hnorm : β(h i : β)β = 1 := by | |
| rcases hh i with hi | hi <;> simp [hi] | |
| rw [norm_mul, norm_mul, hnorm] | |
| norm_num [mul_pow] | |
| /-- The diagonal and a disjoint set of equal-sign neighbor entries contribute | |
| four times their mass to the Hilbert--Schmidt squared norm. -/ | |
| theorem anticommutator_energy_ge_selected [DecidableEq ΞΉ] | |
| (Ο : ΞΉ β ΞΉ β β) (hzero : β i j, Ο i j = 0 β i = j) | |
| (M : Matrix ΞΉ ΞΉ β) (h : ΞΉ β β) (hh : β i, h i = 1 β¨ h i = -1) | |
| (s : Finset (ΞΉ Γ ΞΉ)) | |
| (hs : s β distanceShell (fun p : ΞΉ Γ ΞΉ => Ο p.1 p.2) 1) | |
| (hsign : β p β s, h p.1 = h p.2) : | |
| 4 * ((β p β distanceShell (fun p : ΞΉ Γ ΞΉ => Ο p.1 p.2) 0, | |
| βM p.1 p.2β ^ 2) + β p β s, βM p.1 p.2β ^ 2) β€ | |
| hsNormSq (M * Matrix.diagonal (fun i => (h i : β)) + | |
| Matrix.diagonal (fun i => (h i : β)) * M) := by | |
| classical | |
| let D := distanceShell (fun p : ΞΉ Γ ΞΉ => Ο p.1 p.2) 0 | |
| let T := M * Matrix.diagonal (fun i => (h i : β)) + | |
| Matrix.diagonal (fun i => (h i : β)) * M | |
| have hdisj : Disjoint D s := by | |
| apply Finset.disjoint_left.mpr | |
| intro p hpD hps | |
| have h0 : Ο p.1 p.2 = 0 := by simpa only [D, mem_distanceShell] using hpD | |
| have h1 : Ο p.1 p.2 = 1 := by simpa only [mem_distanceShell] using hs hps | |
| omega | |
| have hsame : β p β D βͺ s, h p.1 = h p.2 := by | |
| intro p hp | |
| rcases Finset.mem_union.mp hp with hpD | hps | |
| Β· have h0 : Ο p.1 p.2 = 0 := by simpa only [D, mem_distanceShell] using hpD | |
| rw [hzero _ _ h0] | |
| Β· exact hsign p hps | |
| have hentries : (β p β D βͺ s, 4 * βM p.1 p.2β ^ 2) = | |
| β p β D βͺ s, βT p.1 p.2β ^ 2 := by | |
| apply Finset.sum_congr rfl | |
| intro p hp | |
| exact (anticommutator_entry_sq_of_same_sign M h hh p.1 p.2 (hsame p hp)).symm | |
| have hsubset : (β p β D βͺ s, βT p.1 p.2β ^ 2) β€ | |
| β p : ΞΉ Γ ΞΉ, βT p.1 p.2β ^ 2 := | |
| Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) | |
| (fun p _ _ => sq_nonneg βT p.1 p.2β) | |
| have hsplit : (β p β D βͺ s, 4 * βM p.1 p.2β ^ 2) = | |
| 4 * ((β p β D, βM p.1 p.2β ^ 2) + β p β s, βM p.1 p.2β ^ 2) := by | |
| rw [Finset.sum_union hdisj, β Finset.mul_sum, β Finset.mul_sum, mul_add] | |
| rw [β hentries, hsplit] at hsubset | |
| simpa only [D, T, hsNormSq, Fintype.sum_prod_type] using hsubset | |
| /-- Abstract edge recovery from the exact finite matrix energy hypotheses. | |
| The chosen set may be any subset of constant-sign distance-one pairs. -/ | |
| theorem edge_recovery_for_subset [DecidableEq ΞΉ] | |
| (Ο : ΞΉ β ΞΉ β β) (hzero : β i j, Ο i j = 0 β i = j) | |
| (M : Matrix ΞΉ ΞΉ β) (h : ΞΉ β β) (hh : β i, h i = 1 β¨ h i = -1) | |
| (s : Finset (ΞΉ Γ ΞΉ)) | |
| (hs : s β distanceShell (fun p : ΞΉ Γ ΞΉ => Ο p.1 p.2) 1) | |
| (hsign : β p β s, h p.1 = h p.2) | |
| (hcap : β i j, Ο i j = 1 β βM i jβ ^ 2 β€ (1 / 4 : β)) | |
| (htotal : hsNormSq M = | |
| ((distanceShell (fun p : ΞΉ Γ ΞΉ => Ο p.1 p.2) 1).card : β) / 4) | |
| (henergy : (β i, β j, (Ο i j : β) * βM i jβ ^ 2) β€ hsNormSq M) : | |
| (s.card : β) β€ 2 * hsNormSq | |
| (M * Matrix.diagonal (fun i => (h i : β)) + | |
| Matrix.diagonal (fun i => (h i : β)) * M) := by | |
| have hcount := selected_neighbor_card_le_eight_mass | |
| (fun p : ΞΉ Γ ΞΉ => Ο p.1 p.2) (fun p => βM p.1 p.2β ^ 2) s hs | |
| (fun p => sq_nonneg _) (fun p hp => hcap p.1 p.2 (by simpa only [mem_distanceShell] using hp)) | |
| (by simpa only [hsNormSq, Fintype.sum_prod_type] using htotal) | |
| (by simpa only [hsNormSq, Fintype.sum_prod_type] using henergy) | |
| have hanti := anticommutator_energy_ge_selected Ο hzero M h hh s hs hsign | |
| linarith | |
| /-- The edge-recovery inequality on the Boolean cube, from the three | |
| matrix facts established by the grading and commutator constructions. -/ | |
| theorem edge_recovery {n : β} (M : Matrix (Cube n) (Cube n) β) | |
| (h : Cube n β β) (hh : β x, h x = 1 β¨ h x = -1) | |
| (htotal : hsNormSq M = (n : β) * (2 : β) ^ n / 4) | |
| (hdistance : (β x, β y, (hammingDist x y : β) * βM x yβ ^ 2) β€ hsNormSq M) | |
| (hcap : β x y, x β y β βM x yβ ^ 2 β€ (1 / 4 : β)) : | |
| ((orderedConstantEdges h).card : β) β€ | |
| 2 * hsNormSq (M * Matrix.diagonal (fun x => (h x : β)) + | |
| Matrix.diagonal (fun x => (h x : β)) * M) := by | |
| classical | |
| apply edge_recovery_for_subset (fun x y : Cube n => hammingDist x y) | |
| (fun _ _ hxy => hammingDist_eq_zero.mp hxy) M h hh (orderedConstantEdges h) | |
| Β· exact Finset.filter_subset _ _ | |
| Β· intro p hp | |
| exact (Finset.mem_filter.mp hp).2 | |
| Β· intro x y hxy | |
| apply hcap x y | |
| intro heq | |
| subst y | |
| simp only [hammingDist_self, Nat.zero_ne_one] at hxy | |
| Β· change hsNormSq M = ((orderedNeighborPairs n).card : β) / 4 | |
| rw [card_orderedNeighborPairs] | |
| simpa only [Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat] using htotal | |
| Β· exact hdistance | |
| end LeanBlast.GotsmanLinial | |
| end OAI | |